StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTofAssociator.C
1 // $Id: StTofAssociator.C,v 1.1 2004/04/25 18:52:02 geurts Exp $
2 // $Log: StTofAssociator.C,v $
3 // Revision 1.1 2004/04/25 18:52:02 geurts
4 // *** empty log message ***
5 //
6 
7 class StChain;
8 StChain *chain=0;
9 
10 void StTofAssociator(Int_t nevents=1,
11  const char *MainFile="/afs/rhic/star/data/samples/*.geant.root",
12  const char* histoFile="embedTOFp.root",
13  const char* dirHistoFile="/auto/u/geurts/Embedding/tofp")
14 {
15 
16  // Dynamically link needed shared libs
17  gSystem->Load("St_base");
18  gSystem->Load("StChain");
19 
20  gSystem->Load("St_Tables");
21  gSystem->Load("StUtilities");
22  gSystem->Load("StIOMaker");
23  gSystem->Load("StarClassLibrary");
24  gSystem->Load("StDetectorDbMaker");
25 
26  gSystem->Load("StTpcDb");
27  gSystem->Load("StEvent");
28  gSystem->Load("StEventMaker"); //not needed if event.root branch present
29  gSystem->Load("StEmcUtil");
30 
31  gSystem->Load("StMcEvent");
32  gSystem->Load("StMcEventMaker");
33  gSystem->Load("StAssociationMaker");
34  gSystem->Load("StTofpMcAnalysisMaker");
35 
36  // TOF related goodies
37  gSystem->Load("StTofUtil");
38  gSystem->Load("StDbLib");
39  gSystem->Load("StDbBroker");
40  gSystem->Load("St_db_Maker");
41  //--TOF
42 
43 
44  chain = new StChain("StChain");
45  //chain->SetDebug();
46 
47  // Now we add Makers to the chain...
48 
49  StIOMaker* ioMaker = new StIOMaker("IO","r",MainFile,"bfcTree");
50  //ioMaker->SetDebug();
51  ioMaker->SetIOMode("r");
52  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
53  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
54  //ioMaker->SetBranch("eventBranch",0,"r"); //activate geant Branch
55  ioMaker->SetBranch("dstBranch",0,"r"); //activate Event Branch
56  ioMaker->SetBranch("runcoBranch",0,"r"); //activate runco Branch
57 
58  // Note, the title "events" is used in the Association Maker, so don't change it.
59  // StEventMaker is not needed for event.root files
60  StEventMaker* eventReader = new StEventMaker("events","title");
61  eventReader->doPrintMemoryInfo = kFALSE;
62  StMcEventMaker* mcEventReader = new StMcEventMaker; // Make an instance...
63  mcEventReader->doPrintMemoryInfo = false;
64  mcEventReader->doUseTpc = true;
65  mcEventReader->doUseSvt = false;
66  mcEventReader->doUseFtpc = false;
67  mcEventReader->doUseRich = false;
68  mcEventReader->doUseBemc = false;
69  mcEventReader->doUseBsmd = false;
70 
71  StAssociationMaker* associator = new StAssociationMaker;
72  associator->doPrintMemoryInfo = false;
73 
74  // If you need to use L3 TRIGGER uncomment the line:
75  // associator->useL3Trigger();
76  //associator->SetDebug();
77  //associator->doPrintMemoryInfo = kTRUE;
79  examples->SetDebug();
80 
81  // Define the cuts for the Associations
82 
83  StMcParameterDB* parameterDB = StMcParameterDB::instance();
84  // TPC
85  parameterDB->setXCutTpc(.5); // 5 mm
86  parameterDB->setYCutTpc(.5); // 5 mm
87  parameterDB->setZCutTpc(.5); // 5 mm
88  parameterDB->setReqCommonHitsTpc(3); // Require 3 hits in common for tracks to be associated
89  // FTPC
90  parameterDB->setRCutFtpc(.3); // 3 mm
91  parameterDB->setPhiCutFtpc(5*(3.1415927/180.0)); // 5 degrees
92  parameterDB->setReqCommonHitsFtpc(3); // Require 3 hits in common for tracks to be associated
93  // SVT
94  parameterDB->setXCutSvt(.08); // 800 um
95  parameterDB->setYCutSvt(.08); // 800 um
96  parameterDB->setZCutSvt(.08); // 800 um
97  parameterDB->setReqCommonHitsSvt(1); // Require 1 hits in common for tracks to be associated
98 
99  // TOF--
100  char *db2 = "StarDb";
101  if (gSystem->AccessPathName(db2) !=0) {
102  printf("File %s does not exist\n",db2);
103  db2 = "";
104  }
105  St_db_Maker *dbMk = new St_db_Maker("dbName","MySQL:StarDb","$STAR/StarDb",db2);
106  dbMk->SetDateTime(010102,000);
107  // --TOF
108 
109  // now execute the chain member functions
110 
111  chain->PrintInfo();
112  Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers
113  if (initStat) chain->Fatal(initStat, "during Init()");
114 
115  int istat=0,iev=1;
116  EventLoop: if (iev<=nevents && istat!=2) {
117  chain->Clear();
118  cout << "---------------------- Processing Event : " << iev << " ----------------------" << endl;
119  istat = chain->Make(iev); // This should call the Make() method in ALL makers
120  if (istat == 2) { cout << "Last Event Processed. Status = " << istat << endl; }
121  if (istat == 3) { cout << "Error Event Processed. Status = " << istat << endl; }
122  iev++; goto EventLoop;
123  } // Event Loop
124 
125 
126  char histfile[200];
127  sprintf(histfile,"%s%s",dirHistoFile,histoFile);
128  TFile file(histfile,"RECREATE");
129 
130  TOrdCollection *histograms = new TOrdCollection;
131  histograms->AddLast(examples->hMcElectron);
132  histograms->AddLast(examples->hRcElectron);
133  histograms->AddLast(examples->hMatchElectron);
134  histograms->AddLast(examples->hMomResPtPion);
135  histograms->AddLast(examples->hMultRef);
136  histograms->AddLast(examples->hMcPionPlus);
137  histograms->AddLast(examples->hRcPionPlus);
138  histograms->AddLast(examples->hMatchPionPlus);
139  histograms->AddLast(examples->hMcPionMin);
140  histograms->AddLast(examples->hRcPionMin);
141  histograms->AddLast(examples->hMatchPionMin);
142  histograms->AddLast(examples->hMcKaonPlus);
143  histograms->AddLast(examples->hRcKaonPlus);
144  histograms->AddLast(examples->hMatchKaonPlus);
145  histograms->AddLast(examples->hMcKaonMin);
146  histograms->AddLast(examples->hRcKaonMin);
147  histograms->AddLast(examples->hMatchKaonMin);
148  histograms->AddLast(examples->hMcProton);
149  histograms->AddLast(examples->hRcProton);
150  histograms->AddLast(examples->hMatchProton);
151  histograms->AddLast(examples->hMcAntiProton);
152  histograms->AddLast(examples->hRcAntiProton);
153  histograms->AddLast(examples->hMatchAntiProton);
154  histograms->AddLast(examples->hTofpSlatIdA0);
155  histograms->AddLast(examples->hTofpSlatIdA1);
156  histograms->AddLast(examples->hTofpSlatIdB1);
157  histograms->AddLast(examples->hTofpSlatIdD1);
158  histograms->AddLast(examples->hTofpSlatIdD2);
159  histograms->AddLast(examples->hTofpSlatIdE1);
160  histograms->AddLast(examples->hTofpSlatIdE2);
161  histograms->AddLast(examples->hTofpSlatIdE3);
162  histograms->AddLast(examples->hTofpSlatIdE4);
163  histograms->AddLast(examples->hTofpSlatIdE5);
164  histograms->AddLast(examples->hTofpSlatIdF1);
165  histograms->AddLast(examples->hTofpSlatHitVecSize);
166 
167  histograms->Write();
168 
169  file.Close();
170 
171 
172 
173  if(iev>200) chain->Finish(); // This should call the Finish() method in ALL makers,
174  // comment it out if you want to keep the objects
175  // available at the command line after running
176  // the macro.
177 
178  // To look at the ntuple after the macro has executed:
179  // f1 = new TFile("TrackMapNtuple.root"); //This opens the file, and loads the Ntuple
180  // TrackNtuple->Draw("px:pxrec") //Once loaded, the Ntuple is available by name.
181  // To look at the Histograms once the Macro has executed:
182  // TList* dList = chain->GetMaker("McAnalysis")->Histograms();
183  // TH2F* hitRes = dList->At(0); //or whatever index from 0 to 3
184 }
185 
TH1D * hTofpSlatIdE4
recovered from ss
TH1D * hTofpSlatIdA0
2D tray hit positions (F)
TH1D * hTofpSlatIdB1
valid slat
TH2F * hRcElectron
TPC reconstructed pbar.
TH1F * hMultRef
MC/RC momentum resolution.
TH2F * hRcKaonMin
TPC reconstructed K+.
TH2F * hRcAntiProton
TPC reconstructed p+.
TH2F * hMatchKaonMin
TOF matched K+.
TH1D * hTofpSlatIdE2
one slat for one track match
TH1D * hTofpSlatIdE5
recovered from closest hitplane
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
TH1D * hTofpSlatIdA1
events per slat
TH2F * hMcKaonMin
montecarlo K+
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
TH2F * hMatchPionMin
TOF matched pi+.
TH1D * hTofpSlatHitVecSize
primary track match per slat
TH2F * hMcKaonPlus
montecarlo pi-
TH1D * hTofpSlatIdE1
single track match per slat
TH2F * hMcPionMin
montecarlo pi+
TH1D * hTofpSlatIdD1
#tracks match valid slat
TH2F * hMatchProton
TOF matched K-.
virtual Int_t Finish()
Definition: StChain.cxx:85
TH2F * hMatchPionPlus
TPC reconstructed e-.
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
TH2F * hMatchKaonPlus
TOF matched pi-.
TH2F * hRcProton
TPC reconstructed K-.
TH2F * hMatchElectron
TOF matched pbar.
TH2F * hMcAntiProton
montecarlo p+
TH1D * hTofpSlatIdE3
recovered from hitprof-weight
TH2F * hMomResPtPion
TOF matched e-.
Bool_t doPrintMemoryInfo
lots of screen output
TH2F * hRcPionPlus
montecarlo e-
TH2F * hRcPionMin
TPC reconstructed pi+.
virtual Int_t Make()
Definition: StChain.cxx:110
TH2F * hMcElectron
montecarlo pbar
TH1D * hTofpSlatIdF1
total recovered slat per track match
TH1D * hTofpSlatIdD2
track match per valid slat
TH2F * hRcKaonPlus
TPC reconstructed pi-.
TH2F * hMatchAntiProton
TOF matched p+.
Bool_t doPrintMemoryInfo
lots of screen output
Definition: StEventMaker.h:100
TH2F * hMcProton
montecarlo K-