StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StAssociator.C
1 // $Id: StAssociator.C,v 1.38 2007/10/01 13:54:03 jeromel Exp $
2 // $Log: StAssociator.C,v $
3 // Revision 1.38 2007/10/01 13:54:03 jeromel
4 // Old issue for Ming Shao
5 //
6 // Revision 1.37 2006/08/15 21:43:01 jeromel
7 // Fix rhic -> rhic.bnl.gov
8 //
9 // Revision 1.36 2005/07/07 21:19:18 calderon
10 // Load EEmcUtil.
11 //
12 // Revision 1.35 2004/03/26 23:29:02 calderon
13 // Added switch to control the id or distance association.
14 //
15 // Revision 1.34 2003/03/19 17:16:19 calderon
16 // remove loading of StarRoot (it's loaded by default).
17 //
18 // Revision 1.33 2002/09/22 18:27:11 calderon
19 // Revert to loading St_Tables instead of all tables individually to avoid
20 // chasing dependencies every time someone else requires another table.
21 //
22 // Revision 1.32 2002/04/24 18:25:21 calderon
23 // added gSystem->Load("libtpc_Tables");
24 // ioMaker->SetBranch("eventBranch",0,"r");
25 //
26 // Revision 1.31 2002/04/05 02:34:22 calderon
27 // Added
28 // gSystem->Load("StDetectorDbMaker");
29 // The hijing files produced now have the event.root branch, in this case,
30 // the StEventMaker should NOT be used. So this is now the default, StEventMaker
31 // is neither loaded nor instantiated.
32 //
33 // Revision 1.30 2001/10/23 18:58:50 hardtke
34 // Load StTpcDb library
35 //
36 // Revision 1.29 2001/06/15 19:33:13 jeromel
37 // StarRoot
38 //
39 // Revision 1.28 2001/05/30 22:48:13 calderon
40 // don't load St_emc_Maker, not needed and caused problems
41 // with optimized libraries.
42 //
43 // Revision 1.27 2001/04/27 18:44:10 calderon
44 // added comment on usage of L3Trigger switch
45 //
46 // Revision 1.26 2001/04/25 21:16:57 jeromel
47 // Added libgeometry_Tables missing for some StEmcUtil calls.
48 //
49 // Revision 1.25 2001/04/09 18:39:42 jeromel
50 // Just checking (could not commit before). No changes.
51 //
52 // Revision 1.21 2000/06/08 20:09:22 calderon
53 // load St_emc_Maker to work with new Emc Hit classes
54 //
55 // Revision 1.20 2000/05/11 22:14:27 calderon
56 // Go back to getting the histograms from the TList.
57 //
58 // Revision 1.19 2000/05/11 16:20:33 calderon
59 // histograms have to be obtained directly from maker again.
60 // Examples of using the loading of hits in StMcEventMaker (commented out by
61 // default).
62 //
63 // Revision 1.18 2000/04/20 17:02:42 calderon
64 // Modified macros to continue looping when status = 3
65 // Pick up maker with name "StMcAnalysisMaker" instead of "McAnalysis"
66 // in StAssociator.C
67 //
68 // Revision 1.17 2000/04/13 22:01:41 calderon
69 // proper table and branch activating as per Kathy
70 //
71 // Revision 1.16 2000/04/13 21:46:21 kathy
72 // remove loading of libtpc_Tables since l3Track table is now dst_track type from global
73 //
74 // Revision 1.15 2000/04/12 17:39:02 kathy
75 // change to only load table libraries needed: lib*_Tables instead of all tables: St_Tables
76 //
77 // Revision 1.14 2000/01/19 21:00:40 kathy
78 // update macros to use standard default xdf files in /afs/rhic.bnl.gov/star/data/samples
79 //
80 // Revision 1.13 2000/01/19 19:38:12 calderon
81 // activate runco branch
82 //
83 // Revision 1.12 2000/01/12 20:23:01 calderon
84 // Changed default file to the one produced weekly by Lidia in
85 // /star/rcf/test/dev/tfs_Linux/Tue/year_2a/hc_standard/
86 //
87 // Revision 1.11 1999/12/14 18:18:01 calderon
88 // using new StMcEvent, StEvent & StAssociationMaker
89 //
90 // Revision 1.10 1999/11/03 22:39:35 calderon
91 // Changed default file. Previous one was removed.
92 //
93 // Revision 1.9 1999/10/01 13:59:18 calderon
94 // Opened up default Local X cut to 5 mm as a result of
95 // studies on merged tracks.
96 // Changed default Hit resolution histogram to plot from global z vs global x
97 // to the more significant global z vs local x which are the variables
98 // used in the association criterion.
99 // The global z vs global x still belongs to StMcAnalysisMaker and is built
100 // using the multimap, the global z vs local x is made by default in
101 // StAssociationMaker without any requirement of association to serve
102 // as a diagnostic.
103 // Changed size of default canvas
104 //
105 // Revision 1.8 1999/09/10 19:11:55 calderon
106 // Write the Ntuple in StMcAnalysisMaker into a file.
107 // This way it can be accessed after the macro finishes,
108 // otherwise it gets deleted.
109 //
110 // Revision 1.7 1999/09/10 00:02:24 calderon
111 // Made the following changes:
112 // -load StUtilities
113 // -add line to print number of processed events
114 // -create canvas here
115 // -no longer draw # of Pings histogram
116 //
117 // Revision 1.6 1999/07/29 15:08:36 calderon
118 // Include Mom. Resolution example (Histograms & Ntuple)
119 //
120 // Revision 1.5 1999/07/28 21:29:34 calderon
121 // Modified event loop: use 'if' and 'goto' to avoid using 'for'
122 //
123 // Revision 1.4 1999/07/28 20:27:45 calderon
124 // Version with SL99f libraries
125 //
126 // Revision 1.3 1999/07/23 14:35:41 calderon
127 // Updated names of default files and of packages
128 //
129 // Revision 1.2 1999/07/23 10:53:48 kathy
130 // put in header info in Manuel's macros
131 //
133 // owner: Manuel Calderon de la Barca Sanchez
134 //
135 // what it does: reads .geant.root file,
136 // runs a chain of 4 makers:
137 // StEventReaderMaker, StMcEventMaker,StAssociationMaker,
138 // StMcAnalysisMaker
139 //
140 // note: for more info on StMcEvent and StAssociationMaker, do a
141 // cvs checkout and say "make" in the doc/tex directory - you'll
142 // get a ps file with user guide and reference manual.
144 
145 class StChain;
146 StChain *chain=0;
147 
148 void StAssociator(Int_t nevents=1,
149 const char *MainFile="/afs/rhic.bnl.gov/star/data/samples/*.geant.root")
150 {
151 
152  // Dynamically link needed shared libs
153  gSystem->Load("St_base");
154  gSystem->Load("StChain");
155  gSystem->Load("StBFChain");
156 
157  gSystem->Load("St_Tables");
158  gSystem->Load("StUtilities");
159  gSystem->Load("StIOMaker");
160  gSystem->Load("StarClassLibrary");
161  gSystem->Load("StDetectorDbMaker");
162 
163 
164  gSystem->Load("StTpcDb");
165  gSystem->Load("StEvent");
166 // gSystem->Load("StEventMaker"); //not needed if event.root branch present
167  gSystem->Load("StEmcUtil");
168  gSystem->Load("StEEmcUtil");
169 
170  gSystem->Load("StMcEvent");
171  gSystem->Load("StMcEventMaker");
172  gSystem->Load("StAssociationMaker");
173  gSystem->Load("StMcAnalysisMaker");
174 
175  chain = new StChain("StChain");
176  chain->SetDebug();
177 
178  // Now we add Makers to the chain...
179 
180  StIOMaker* ioMaker = new StIOMaker("IO","r",MainFile,"bfcTree");
181  ioMaker->SetDebug();
182  ioMaker->SetIOMode("r");
183  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
184  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
185  ioMaker->SetBranch("eventBranch",0,"r"); //activate geant Branch
186 // ioMaker->SetBranch("dstBranch",0,"r"); //activate Event Branch
187 // ioMaker->SetBranch("runcoBranch",0,"r"); //activate runco Branch
188 
189  // Note, the title "events" is used in the Association Maker, so don't change it.
190  // StEventMaker is not needed for event.root files
191 // StEventMaker* eventReader = new StEventMaker("events","title");
192 // eventReader->doPrintMemoryInfo = kFALSE;
193  StMcEventMaker* mcEventReader = new StMcEventMaker; // Make an instance...
194  StAssociationMaker* associator = new StAssociationMaker;
195 
196  // If you need to use L3 TRIGGER uncomment the line:
197  // associator->useL3Trigger();
198  //associator->SetDebug();
199  // For tracks created with the Sti package (ITTF), uncomment the next line:
200  //associator->useInTracker();
201  // Switch to use the distance or id association.
202  associator->useDistanceAssoc();
203  //associator->useIdAssoc();
204  // Note: useDistanceAssoc and useIdAssoc are mutually exclusive
205  // and they set and unset the same flag.
206  // The flag will be set by the call done at the end.
207  //associator->doPrintMemoryInfo = kTRUE;
208  StMcAnalysisMaker* examples = new StMcAnalysisMaker;
209 
210  // Define the cuts for the Associations
211 
212  StMcParameterDB* parameterDB = StMcParameterDB::instance();
213  // TPC
214  parameterDB->setXCutTpc(.6); // 6 mm
215  parameterDB->setYCutTpc(.6); // 6 mm
216  parameterDB->setZCutTpc(.6); // 6 mm
217  parameterDB->setReqCommonHitsTpc(3); // Require 3 hits in common for tracks to be associated
218  // FTPC
219  parameterDB->setRCutFtpc(.3); // 3 mm
220  parameterDB->setPhiCutFtpc(5*(3.1415927/180.0)); // 5 degrees
221  parameterDB->setReqCommonHitsFtpc(3); // Require 3 hits in common for tracks to be associated
222  // SVT
223  parameterDB->setXCutSvt(.08); // 800 um
224  parameterDB->setYCutSvt(.08); // 800 um
225  parameterDB->setZCutSvt(.08); // 800 um
226  parameterDB->setReqCommonHitsSvt(1); // Require 1 hits in common for tracks to be associated
227 
228 
229  // now execute the chain member functions
230 
231  chain->PrintInfo();
232  Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers
233  if (initStat) chain->Fatal(initStat, "during Init()");
234 
235  int istat=0,iev=1;
236  EventLoop: if (iev<=nevents && istat!=2) {
237  chain->Clear();
238  cout << "---------------------- Processing Event : " << iev << " ----------------------" << endl;
239  istat = chain->Make(iev); // This should call the Make() method in ALL makers
240  if (istat == 2) { cout << "Last Event Processed. Status = " << istat << endl; }
241  if (istat == 3) { cout << "Error Event Processed. Status = " << istat << endl; }
242  iev++; goto EventLoop;
243  } // Event Loop
244  examples->mAssociationCanvas = new TCanvas("mAssociationCanvas", "Histograms",200,10,600,600);
245  TCanvas* myCanvas = examples->mAssociationCanvas;
246  myCanvas->Divide(2,2);
247 
248  myCanvas->cd(1);
249  gPad->SetLogy(0);
250  examples->mTrackNtuple->Draw("(p-prec)/p:commTpcHits","prec!=0");
251 
252  TList* dList = chain->GetMaker("StMcAnalysisMaker")->Histograms();
253  TH2F* hitRes = dList->At(0);
254  TH1F* momRes = dList->At(1);
255  TH2F* coordRc = dList->At(2);
256  TH2F* coordMc = dList->At(3);
257 
258  myCanvas->cd(2);
259  gPad->SetLogy(0);
260  hitRes->Draw("box");
261 
262  myCanvas->cd(3);
263  gPad->SetLogy(0);
264  momRes->Draw();
265 
266  myCanvas->cd(4);
267  gPad->SetLogy(0);
268  coordRc->SetMarkerStyle(20);
269  coordRc->Draw();
270 
271  myCanvas->cd(4);
272  gPad->SetLogy(0);
273  coordMc->SetMarkerColor(2);
274  coordMc->SetMarkerStyle(20);
275  coordMc->Draw("same");
276 
277  if(iev>200) chain->Finish(); // This should call the Finish() method in ALL makers,
278  // comment it out if you want to keep the objects
279  // available at the command line after running
280  // the macro.
281 
282  // To look at the ntuple after the macro has executed:
283  // f1 = new TFile("TrackMapNtuple.root"); //This opens the file, and loads the Ntuple
284  // TrackNtuple->Draw("px:pxrec") //Once loaded, the Ntuple is available by name.
285  // To look at the Histograms once the Macro has executed:
286  // TList* dList = chain->GetMaker("McAnalysis")->Histograms();
287  // TH2F* hitRes = dList->At(0); //or whatever index from 0 to 3
288 }
289 
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
TCanvas * mAssociationCanvas
Miscellaneous info of the TPC hit pairs.
TNtuple * mTrackNtuple
File to contain the mTrackNtuple, otherwise it is deleted!
virtual Int_t Finish()
Definition: StChain.cxx:85
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