StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WriteStiEvents.C
1 //
2 // $ID:$
3 //
4 // A cut down version of RunStiMaker to just write out event.root files.
5 //
6 // A. Rose, M. Calderon
7 // $Log: WriteStiEvents.C,v $
8 // Revision 1.2 2002/09/15 15:54:35 andrewar
9 // Added bool simulated to argument list; true = simulated data,
10 // false= real data. This fixes the timestamp issue where we explicitly
11 // try to set a timestamp, even if one exists - which it does for real
12 // data.
13 //
14 // Revision 1.1 2002/06/07 19:26:57 andrewar
15 // First commit. Set to do nothing but track and write out.
16 // Data file defaults to public event file in ITTF area.
17 //
18 //
19 
20 void WriteStiEvents(Int_t nevents=1,
21  const Char_t *Mainfile = "/star/data22/ITTF/EvalData/MCFiles/auau200/rcf0183_12_300evts.geant.root",
22  const Char_t *outfile= "test.event.root",
23  bool simulated = true)
24 {
25 
26  gSystem->Load("St_base");
27  gSystem->Load("StChain");
28  gSystem->Load("StUtilities");
29  gSystem->Load("St_Tables");
30  gSystem->Load("StarClassLibrary");
31 
32  gSystem->Load("StIOMaker");
33  gSystem->Load("StEvent");
34  gSystem->Load("StEmcUtil");
35  gSystem->Load("StMcEvent");
36  gSystem->Load("StMcEventMaker");
37  gSystem->Load("StAssociationMaker");
38 
39  gSystem->Load("St_db_Maker");
40  gSystem->Load("StDbLib");
41  gSystem->Load("StDbBroker");
42  gSystem->Load("StDbUtilities");
43  gSystem->Load("StTpcDb");
44  gSystem->Load("StDetectorDbMaker");
45  gSystem->Load("StTreeMaker");
46  gSystem->Load("StSvtClassLibrary");
47  gSystem->Load("StSvtDbMaker");
48 
49  gSystem->Load("Sti");
50  gSystem->Load("libGui");
51  gSystem->Load("StiGui");
52 // gSystem->Load("StiEvaluator");
53  gSystem->Load("StiMaker");
54 
55  chain = new StChain("StChain");
56  StIOMaker *IOMk = new StIOMaker("IO","r",Mainfile);
57  IOMk->SetBranch("*",0,"0"); //deactivate all branches
58  //IOMk->SetBranch("dstBranch",0,"r");
59  //IOMk->SetBranch("runcoBranch",0,"r");
60  IOMk->SetBranch("eventBranch",0,"r");
61  IOMk->SetBranch("geantBranch",0,"r");
62 
63  dbaseMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb");
64  if (simulated) dbaseMk-> SetDateTime(20010801,000000);
65  tpcDbMk = new StTpcDbMaker("tpcDb");
66  svtDbMk = new StSvtDbMaker("svtDb");
67  detDbMk = new StDetectorDbMaker("detDb");
68 
69 
70  bool doFit = false;
71  bool optimized = false;
72 
73  StiMaker* anaMk = StiMaker::instance();
74  StiRootIOBroker* stiIO = anaMk->getIOBroker();//StiRootIOBroker::instance();
75  stiIO->setTPHFMinPadrow(1);
76  stiIO->setTPHFMaxPadrow(45);
77  stiIO->setETSFLowerBound(5);
78  stiIO->setETSFMaxHits(6);
79 
80  stiIO->setDoTrackFit(doFit);
81 
82  //Set Kalman Track Finder (KTF) run-time values:
83  stiIO->setKTFMcsCalculated(false);
84  stiIO->setKTFElossCalculated(false);
85  stiIO->setKTFMaxChi2ForSelection(50);
86  stiIO->setKTFBField(.5); //Tesla
87  stiIO->setKTFMassHypothesis(.1395); //GeV
88  stiIO->setKTFMinContiguousHitCount(2);
89  stiIO->setKTFMaxNullCount(40);
90  stiIO->setKTFMaxContiguousNullCount(25);
91  stiIO->setKTFMinSearchRadius(.5); //cm
92  stiIO->setKTFMaxSearchRadius(4.); //cm
93  stiIO->setKTFSearchWindowScale(5.); //cm
94 
95  //Set Local Track Seed Finder (LTSF) run-time values
96  stiIO->setLTSFZWindow(5.);
97  stiIO->setLTSFYWindow(2.);
98  stiIO->setLTSFSeedLength(2);
99 
100  stiIO->setLTSFDoHelixFit(true);
101  stiIO->setLTSFExtrapYWindow(1.);
102  stiIO->setLTSFExtrapZWindow(2.);
103  stiIO->setLTSFExtrapMaxSkipped(2);
104  stiIO->setLTSFExtrapMinLength(4);
105  stiIO->setLTSFExtrapMaxLength(5);
106  stiIO->setLTSFUseVertex(true);
107 
108  stiIO->setLTMDeltaR(1.); //10% in r
109 
110  //Add sectors:
111  for (unsigned int sector=1; sector<=12; ++sector) {
112  stiIO->addLTSFSector(sector);
113  }
114  //Add padrows;
115  //for (unsigned int padrow=1; padrow<=45; ++padrow) {
116  for (unsigned int padrow=6; padrow<=45; padrow+=1) {
117  stiIO->addLTSFPadrow(padrow);
118  }
119 
120  //This line has to match the corresponding enumeration in StiIOBroker.h
121  enum SeedFinderType {kUndefined=0, kComposite=1, kEvaluable=2};
122  //stiIO->setSeedFinderType(kEvaluable);
123  stiIO->setSeedFinderType(kComposite);
124 
125  //Set up the track filter (this mas to macth the correspoinding enumeration in StiIOBroker.h)
126  enum FilterType {kPtFilter=0, kEtaFilter=1, kChi2Filter=2, kNptsFilter=3, kNFitPtsFilter=4,
127  kNGapsFilter=5, kFitPointRatioFilter=6, kPrimaryDcaFilter=7};
128 
129  stiIO->addFilterType(kPtFilter);
130  stiIO->setFilterPtMin(.1); //GeV
131  stiIO->setFilterPtMax(50.); //GeV
132 
133  stiIO->addFilterType(kEtaFilter);
134  stiIO->setFilterEtaMin(-2.);
135  stiIO->setFilterEtaMax(2.);
136 
137  stiIO->addFilterType(kChi2Filter);
138  stiIO->setFilterChi2Max(10.);
139 
140  stiIO->addFilterType(kNptsFilter);
141  stiIO->setFilterNptsMin(8);
142 
143  stiIO->addFilterType(kNFitPtsFilter);
144  stiIO->setFilterNFitPtsMin(5);
145 
146  stiIO->addFilterType(kNGapsFilter);
147  stiIO->setFilterNGapsMax(20);
148 
149  stiIO->addFilterType(kPrimaryDcaFilter);
150  stiIO->setFilterPrimaryDcaMax(100.);
151 
152  if (!simulated) stiIO->setSimulated(false);
153 
154  if (simulated){
155  StMcEventMaker* mcEventReader = mcEventReader = new StMcEventMaker();
156  mcEventReader->doUseFtpc = kFALSE;
157  mcEventReader->doUseRich = kFALSE;
158  mcEventReader->doUseBemc = kFALSE;
159  mcEventReader->doUseBsmd = kFALSE;
160  }
161  cout << "!!!! doEvents: will write out .event.root file !!" << endl << endl;
162  StTreeMaker *outMk = new StTreeMaker("EvOut","","bfcTree");
163  outMk->SetIOMode("w");
164  outMk->SetBranch("eventBranch",outfile,"w");
165  outMk->IntoBranch("eventBranch","StEvent");
166 
167  if (simulated) StAssociationMaker* assocMakerIt = new StAssociationMaker();
168  if (simulated) assocMakerIt->useInTracker();
169  //assocMakerIt->SetDebug();
170 
171  chain->PrintInfo();
172 
173  Int_t iInit = chain->Init();
174  if (iInit) chain->Fatal(iInit,"on init");
175  chain->InitRun(0);
176 
177  //
178  // Event loop
179  //
180  int istat=0,i=1;
181  EventLoop: if (i <= nevents && istat!=2) {
182 
183  cout << endl << "============================ Event " << i
184  << " start ============================" << endl;
185 
186  chain->Clear();
187  istat = chain->Make(i);
188 
189  if (istat==2)
190  {cout << "Last event processed. Status = " << istat << endl;}
191  if (istat==3)
192  {cout << "Error event processed. Status = " << istat << endl;}
193 
194 
195 
196  i++;
197  goto EventLoop;
198  }
199  i--;
200  cout << endl << "============================ Event " << i
201  << " finish ============================" << endl;
202 
203  return;
204 }
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
virtual Int_t Make()
Definition: StChain.cxx:110