00001 // $Id: StAssociator.C,v 1.38 2007/10/01 13:54:03 jeromel Exp $ 00002 // $Log: StAssociator.C,v $ 00003 // Revision 1.38 2007/10/01 13:54:03 jeromel 00004 // Old issue for Ming Shao 00005 // 00006 // Revision 1.37 2006/08/15 21:43:01 jeromel 00007 // Fix rhic -> rhic.bnl.gov 00008 // 00009 // Revision 1.36 2005/07/07 21:19:18 calderon 00010 // Load EEmcUtil. 00011 // 00012 // Revision 1.35 2004/03/26 23:29:02 calderon 00013 // Added switch to control the id or distance association. 00014 // 00015 // Revision 1.34 2003/03/19 17:16:19 calderon 00016 // remove loading of StarRoot (it's loaded by default). 00017 // 00018 // Revision 1.33 2002/09/22 18:27:11 calderon 00019 // Revert to loading St_Tables instead of all tables individually to avoid 00020 // chasing dependencies every time someone else requires another table. 00021 // 00022 // Revision 1.32 2002/04/24 18:25:21 calderon 00023 // added gSystem->Load("libtpc_Tables"); 00024 // ioMaker->SetBranch("eventBranch",0,"r"); 00025 // 00026 // Revision 1.31 2002/04/05 02:34:22 calderon 00027 // Added 00028 // gSystem->Load("StDetectorDbMaker"); 00029 // The hijing files produced now have the event.root branch, in this case, 00030 // the StEventMaker should NOT be used. So this is now the default, StEventMaker 00031 // is neither loaded nor instantiated. 00032 // 00033 // Revision 1.30 2001/10/23 18:58:50 hardtke 00034 // Load StTpcDb library 00035 // 00036 // Revision 1.29 2001/06/15 19:33:13 jeromel 00037 // StarRoot 00038 // 00039 // Revision 1.28 2001/05/30 22:48:13 calderon 00040 // don't load St_emc_Maker, not needed and caused problems 00041 // with optimized libraries. 00042 // 00043 // Revision 1.27 2001/04/27 18:44:10 calderon 00044 // added comment on usage of L3Trigger switch 00045 // 00046 // Revision 1.26 2001/04/25 21:16:57 jeromel 00047 // Added libgeometry_Tables missing for some StEmcUtil calls. 00048 // 00049 // Revision 1.25 2001/04/09 18:39:42 jeromel 00050 // Just checking (could not commit before). No changes. 00051 // 00052 // Revision 1.21 2000/06/08 20:09:22 calderon 00053 // load St_emc_Maker to work with new Emc Hit classes 00054 // 00055 // Revision 1.20 2000/05/11 22:14:27 calderon 00056 // Go back to getting the histograms from the TList. 00057 // 00058 // Revision 1.19 2000/05/11 16:20:33 calderon 00059 // histograms have to be obtained directly from maker again. 00060 // Examples of using the loading of hits in StMcEventMaker (commented out by 00061 // default). 00062 // 00063 // Revision 1.18 2000/04/20 17:02:42 calderon 00064 // Modified macros to continue looping when status = 3 00065 // Pick up maker with name "StMcAnalysisMaker" instead of "McAnalysis" 00066 // in StAssociator.C 00067 // 00068 // Revision 1.17 2000/04/13 22:01:41 calderon 00069 // proper table and branch activating as per Kathy 00070 // 00071 // Revision 1.16 2000/04/13 21:46:21 kathy 00072 // remove loading of libtpc_Tables since l3Track table is now dst_track type from global 00073 // 00074 // Revision 1.15 2000/04/12 17:39:02 kathy 00075 // change to only load table libraries needed: lib*_Tables instead of all tables: St_Tables 00076 // 00077 // Revision 1.14 2000/01/19 21:00:40 kathy 00078 // update macros to use standard default xdf files in /afs/rhic.bnl.gov/star/data/samples 00079 // 00080 // Revision 1.13 2000/01/19 19:38:12 calderon 00081 // activate runco branch 00082 // 00083 // Revision 1.12 2000/01/12 20:23:01 calderon 00084 // Changed default file to the one produced weekly by Lidia in 00085 // /star/rcf/test/dev/tfs_Linux/Tue/year_2a/hc_standard/ 00086 // 00087 // Revision 1.11 1999/12/14 18:18:01 calderon 00088 // using new StMcEvent, StEvent & StAssociationMaker 00089 // 00090 // Revision 1.10 1999/11/03 22:39:35 calderon 00091 // Changed default file. Previous one was removed. 00092 // 00093 // Revision 1.9 1999/10/01 13:59:18 calderon 00094 // Opened up default Local X cut to 5 mm as a result of 00095 // studies on merged tracks. 00096 // Changed default Hit resolution histogram to plot from global z vs global x 00097 // to the more significant global z vs local x which are the variables 00098 // used in the association criterion. 00099 // The global z vs global x still belongs to StMcAnalysisMaker and is built 00100 // using the multimap, the global z vs local x is made by default in 00101 // StAssociationMaker without any requirement of association to serve 00102 // as a diagnostic. 00103 // Changed size of default canvas 00104 // 00105 // Revision 1.8 1999/09/10 19:11:55 calderon 00106 // Write the Ntuple in StMcAnalysisMaker into a file. 00107 // This way it can be accessed after the macro finishes, 00108 // otherwise it gets deleted. 00109 // 00110 // Revision 1.7 1999/09/10 00:02:24 calderon 00111 // Made the following changes: 00112 // -load StUtilities 00113 // -add line to print number of processed events 00114 // -create canvas here 00115 // -no longer draw # of Pings histogram 00116 // 00117 // Revision 1.6 1999/07/29 15:08:36 calderon 00118 // Include Mom. Resolution example (Histograms & Ntuple) 00119 // 00120 // Revision 1.5 1999/07/28 21:29:34 calderon 00121 // Modified event loop: use 'if' and 'goto' to avoid using 'for' 00122 // 00123 // Revision 1.4 1999/07/28 20:27:45 calderon 00124 // Version with SL99f libraries 00125 // 00126 // Revision 1.3 1999/07/23 14:35:41 calderon 00127 // Updated names of default files and of packages 00128 // 00129 // Revision 1.2 1999/07/23 10:53:48 kathy 00130 // put in header info in Manuel's macros 00131 // 00133 // owner: Manuel Calderon de la Barca Sanchez 00134 // 00135 // what it does: reads .geant.root file, 00136 // runs a chain of 4 makers: 00137 // StEventReaderMaker, StMcEventMaker,StAssociationMaker, 00138 // StMcAnalysisMaker 00139 // 00140 // note: for more info on StMcEvent and StAssociationMaker, do a 00141 // cvs checkout and say "make" in the doc/tex directory - you'll 00142 // get a ps file with user guide and reference manual. 00144 00145 class StChain; 00146 StChain *chain=0; 00147 00148 void StAssociator(Int_t nevents=1, 00149 const char *MainFile="/afs/rhic.bnl.gov/star/data/samples/*.geant.root") 00150 { 00151 00152 // Dynamically link needed shared libs 00153 gSystem->Load("St_base"); 00154 gSystem->Load("StChain"); 00155 gSystem->Load("StBFChain"); 00156 00157 gSystem->Load("St_Tables"); 00158 gSystem->Load("StUtilities"); 00159 gSystem->Load("StIOMaker"); 00160 gSystem->Load("StarClassLibrary"); 00161 gSystem->Load("StDetectorDbMaker"); 00162 00163 00164 gSystem->Load("StTpcDb"); 00165 gSystem->Load("StEvent"); 00166 // gSystem->Load("StEventMaker"); //not needed if event.root branch present 00167 gSystem->Load("StEmcUtil"); 00168 gSystem->Load("StEEmcUtil"); 00169 00170 gSystem->Load("StMcEvent"); 00171 gSystem->Load("StMcEventMaker"); 00172 gSystem->Load("StAssociationMaker"); 00173 gSystem->Load("StMcAnalysisMaker"); 00174 00175 chain = new StChain("StChain"); 00176 chain->SetDebug(); 00177 00178 // Now we add Makers to the chain... 00179 00180 StIOMaker* ioMaker = new StIOMaker("IO","r",MainFile,"bfcTree"); 00181 ioMaker->SetDebug(); 00182 ioMaker->SetIOMode("r"); 00183 ioMaker->SetBranch("*",0,"0"); //deactivate all branches 00184 ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch 00185 ioMaker->SetBranch("eventBranch",0,"r"); //activate geant Branch 00186 // ioMaker->SetBranch("dstBranch",0,"r"); //activate Event Branch 00187 // ioMaker->SetBranch("runcoBranch",0,"r"); //activate runco Branch 00188 00189 // Note, the title "events" is used in the Association Maker, so don't change it. 00190 // StEventMaker is not needed for event.root files 00191 // StEventMaker* eventReader = new StEventMaker("events","title"); 00192 // eventReader->doPrintMemoryInfo = kFALSE; 00193 StMcEventMaker* mcEventReader = new StMcEventMaker; // Make an instance... 00194 StAssociationMaker* associator = new StAssociationMaker; 00195 00196 // If you need to use L3 TRIGGER uncomment the line: 00197 // associator->useL3Trigger(); 00198 //associator->SetDebug(); 00199 // For tracks created with the Sti package (ITTF), uncomment the next line: 00200 //associator->useInTracker(); 00201 // Switch to use the distance or id association. 00202 associator->useDistanceAssoc(); 00203 //associator->useIdAssoc(); 00204 // Note: useDistanceAssoc and useIdAssoc are mutually exclusive 00205 // and they set and unset the same flag. 00206 // The flag will be set by the call done at the end. 00207 //associator->doPrintMemoryInfo = kTRUE; 00208 StMcAnalysisMaker* examples = new StMcAnalysisMaker; 00209 00210 // Define the cuts for the Associations 00211 00212 StMcParameterDB* parameterDB = StMcParameterDB::instance(); 00213 // TPC 00214 parameterDB->setXCutTpc(.6); // 6 mm 00215 parameterDB->setYCutTpc(.6); // 6 mm 00216 parameterDB->setZCutTpc(.6); // 6 mm 00217 parameterDB->setReqCommonHitsTpc(3); // Require 3 hits in common for tracks to be associated 00218 // FTPC 00219 parameterDB->setRCutFtpc(.3); // 3 mm 00220 parameterDB->setPhiCutFtpc(5*(3.1415927/180.0)); // 5 degrees 00221 parameterDB->setReqCommonHitsFtpc(3); // Require 3 hits in common for tracks to be associated 00222 // SVT 00223 parameterDB->setXCutSvt(.08); // 800 um 00224 parameterDB->setYCutSvt(.08); // 800 um 00225 parameterDB->setZCutSvt(.08); // 800 um 00226 parameterDB->setReqCommonHitsSvt(1); // Require 1 hits in common for tracks to be associated 00227 00228 00229 // now execute the chain member functions 00230 00231 chain->PrintInfo(); 00232 Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers 00233 if (initStat) chain->Fatal(initStat, "during Init()"); 00234 00235 int istat=0,iev=1; 00236 EventLoop: if (iev<=nevents && istat!=2) { 00237 chain->Clear(); 00238 cout << "---------------------- Processing Event : " << iev << " ----------------------" << endl; 00239 istat = chain->Make(iev); // This should call the Make() method in ALL makers 00240 if (istat == 2) { cout << "Last Event Processed. Status = " << istat << endl; } 00241 if (istat == 3) { cout << "Error Event Processed. Status = " << istat << endl; } 00242 iev++; goto EventLoop; 00243 } // Event Loop 00244 examples->mAssociationCanvas = new TCanvas("mAssociationCanvas", "Histograms",200,10,600,600); 00245 TCanvas* myCanvas = examples->mAssociationCanvas; 00246 myCanvas->Divide(2,2); 00247 00248 myCanvas->cd(1); 00249 gPad->SetLogy(0); 00250 examples->mTrackNtuple->Draw("(p-prec)/p:commTpcHits","prec!=0"); 00251 00252 TList* dList = chain->GetMaker("StMcAnalysisMaker")->Histograms(); 00253 TH2F* hitRes = dList->At(0); 00254 TH1F* momRes = dList->At(1); 00255 TH2F* coordRc = dList->At(2); 00256 TH2F* coordMc = dList->At(3); 00257 00258 myCanvas->cd(2); 00259 gPad->SetLogy(0); 00260 hitRes->Draw("box"); 00261 00262 myCanvas->cd(3); 00263 gPad->SetLogy(0); 00264 momRes->Draw(); 00265 00266 myCanvas->cd(4); 00267 gPad->SetLogy(0); 00268 coordRc->SetMarkerStyle(20); 00269 coordRc->Draw(); 00270 00271 myCanvas->cd(4); 00272 gPad->SetLogy(0); 00273 coordMc->SetMarkerColor(2); 00274 coordMc->SetMarkerStyle(20); 00275 coordMc->Draw("same"); 00276 00277 if(iev>200) chain->Finish(); // This should call the Finish() method in ALL makers, 00278 // comment it out if you want to keep the objects 00279 // available at the command line after running 00280 // the macro. 00281 00282 // To look at the ntuple after the macro has executed: 00283 // f1 = new TFile("TrackMapNtuple.root"); //This opens the file, and loads the Ntuple 00284 // TrackNtuple->Draw("px:pxrec") //Once loaded, the Ntuple is available by name. 00285 // To look at the Histograms once the Macro has executed: 00286 // TList* dList = chain->GetMaker("McAnalysis")->Histograms(); 00287 // TH2F* hitRes = dList->At(0); //or whatever index from 0 to 3 00288 } 00289
1.5.9