10 void UpdateBeamline(
St_db_Maker* db, vertexSeed_st& beamline)
13 TDataSet *ds = db->GetInputDB(
"Calibrations/rhic");
15 vertexSeed_st *vs = ds ? ((St_vertexSeed *)ds->FindObject(
"vertexSeed"))->GetTable() : 0;
18 std::cout <<
"UpdateBeamline: Data from \"Calibrations/rhic/vertexSeed\" not found\n"
19 <<
"Beamline parameters won't be updated" << std::endl;
23 std::cout <<
"BeamLine parameters:\n"
24 <<
"x(z) = (" << vs->x0 <<
" +/- " << vs->err_x0 <<
") + (" << vs->dxdz <<
" +/- " << vs->err_dxdz <<
") * z\n"
25 <<
"y(z) = (" << vs->y0 <<
" +/- " << vs->err_y0 <<
") + (" << vs->dydz <<
" +/- " << vs->err_dydz <<
") * z" << std::endl;
39 void GenerateVertex(
const char *dataFileName = 0,
40 const TVector3 vtxSpread=TVector3(0.03, 0.03, 50),
const double vtxZOffset = 0,
41 int nevents = 1000,
int seed = 0,
const char *daqfile =
"@run10179086.list",
const char *vertexfile =
"vertex.txt",
const char *flag =
"Jet")
44 gSystem->Load(
"St_base");
45 gSystem->Load(
"StChain");
46 gSystem->Load(
"StBFChain");
47 gSystem->Load(
"StUtilities");
48 gSystem->Load(
"StIOMaker");
49 gSystem->Load(
"StarClassLibrary");
52 gSystem->Load(
"St_Tables");
53 gSystem->Load(
"StDbLib");
54 gSystem->Load(
"StDbBroker");
55 gSystem->Load(
"St_db_Maker");
64 io->SetBranch(
"*", 0,
"0");
72 vertexSeed_st beamline;
75 FILE *VERTEXFILE = fopen(vertexfile,
"w");
78 TString rootfile = vertexfile;
79 rootfile.ReplaceAll(
".txt",
".root");
81 TFile *ofile = TFile::Open(rootfile,
"recreate");
85 TH1F *hVz =
new TH1F(
"hVz ",
"; vz [cm]", 100, -50, 50);
86 TH2F *hVxy =
new TH2F(
"hVxy",
"; vx [cm]; vy [cm]", 50, -2.5, 2.5, 50, -2.5, 2.5);
87 TH2F *hVzx =
new TH2F(
"hVzx",
"; vz [cm]; vx [cm]", 100, -50, 50, 50, -2.5, 2.5);
88 TH2F *hVzy =
new TH2F(
"hVzy",
"; vz [cm]; vy [cm]", 100, -50, 50, 50, -2.5, 2.5);
91 gRandom->SetSeed(seed);
94 for (
int iEvent = 1; iEvent <= nevents; ++iEvent) {
96 int iMake = chain->
Make(iEvent);
100 if (flag ==
"Jet" && iMake % 10 ==
kStEOF) io->Rewind();
102 if (flag ==
"Jet" && iMake % 10 ==
kStFatal)
break;
104 if (flag ==
"W" && iMake ==
kStEOF)
break;
107 if (chain->GetEvtHddr()->IsNewRun()) {
109 printf(
"time stamp = %s\n", chain->GetDateTime().AsSQLString());
110 UpdateBeamline(db, beamline);
118 tf =
new TFile(dataFileName);
119 gDirectory->cd(
"Event");
120 vz = zVertexOneTofMatch->GetRandom();
121 cout <<
"Random zVertex Value from Data is: " << vz << endl;
123 vz = gRandom->Gaus(vtxZOffset, vtxSpread.Z());
127 double x0 = gRandom->Gaus(beamline.x0, beamline.err_x0);
128 double y0 = gRandom->Gaus(beamline.y0, beamline.err_y0);
130 double dxdz = gRandom->Gaus(beamline.dxdz, beamline.err_dxdz);
131 double dydz = gRandom->Gaus(beamline.dydz, beamline.err_dydz);
133 double vx = gRandom->Gaus(x0 + dxdz * vz, vtxSpread.X() );
134 double vy = gRandom->Gaus(y0 + dydz * vz, vtxSpread.Y() );
136 fprintf(VERTEXFILE,
"%14f %14f %14f\n", vx, vy, vz);
156 void GenerateVertex4Jpsi(
char *dataFileName = 0,
int nevents = 1000,
int seed = 0,
const char *daqfile =
"@run10179086.list",
157 const char *vertexfile =
"vertex.txt",
const char *flag =
"Jet")
159 const TVector3 vertexSpread(0.055, 0.02, 48.79);
160 const double vertexZOffset = -2.107;
162 GenerateVertex(dataFileName, vertexSpread, vertexZOffset, nevents, seed, daqfile, vertexfile, flag);
169 void GenerateVertex4WBoson(
char *dataFileName = 0,
int nevents = 1000,
int seed = 0,
const char *daqfile =
"@run10179086.list",
170 const char *vertexfile =
"vertex.txt",
const char *flag =
"Jet")
172 const TVector3 vertexSpread(0.01, 0.01, 5);
173 const double vertexZOffset = 0;
175 GenerateVertex(dataFileName, vertexSpread, vertexZOffset, nevents, seed, daqfile, vertexfile, flag);
182 void GenerateVertex4VPD(
char *dataFileName = 0,
int nevents = 1000,
int seed = 0,
const char *daqfile =
"@run10179086.list",
183 const char *vertexfile =
"vertex.txt",
const char *flag =
"Jet")
185 const TVector3 vertexSpread(0.0372, 0.015, 33.43);
186 const double vertexZOffset = -1.443;
188 GenerateVertex(dataFileName, vertexSpread, vertexZOffset, nevents, seed, daqfile, vertexfile, flag);
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
virtual void Clear(Option_t *option="")
User defined functions.
virtual Int_t GetRunNumber() const
Returns the current RunNumber.