]>
Commit | Line | Data |
---|---|---|
1ee39b3a | 1 | // Steer TRD QA train for Reconstruction (Clusterizer, Tracking and PID). |
2 | // | |
96387ba8 | 3 | // Usage:Char_t *optList="ALL", Int_t run, const Char_t *files=NULL, Long64_t nev=1234567890, Long64_t first = 0 |
4 | // run.C(optList, run, files, nev, first) | |
e9d62bd2 | 5 | // |
6 | // optList : "ALL" [default] or one/more of the following: | |
1ee39b3a | 7 | // "EFF" : TRD Tracking Efficiency |
8 | // "EFFC" : TRD Tracking Efficiency Combined (barrel + stand alone) - only in case of simulations | |
9 | // "MULT" : TRD single track selection | |
10 | // "RES" : TRD tracking Resolution | |
11 | // "CLRES": clusters Resolution | |
12 | // "CAL" : TRD calibration | |
13 | // "ALGN" : TRD alignment | |
14 | // "PID" : TRD PID - pion efficiency | |
15 | // "PIDR" : TRD PID - reference data | |
45d01ff8 | 16 | // "V0" : monitor V0 performance for use in TRD PID calibration |
1ee39b3a | 17 | // "DET" : Basic TRD Detector checks |
e9d62bd2 | 18 | // ****** SPECIAL OPTIONS ********** |
1ee39b3a | 19 | // "NOFR" : Data set does not have AliESDfriends.root |
e9d62bd2 | 20 | // "NOMC" : Data set does not have Monte Carlo Informations (default have MC), |
1ee39b3a | 21 | // |
96387ba8 | 22 | // run : run number [default 0]; if negative value is specified the OCDB connection is left to AddTRDinfoGen.C |
e9d62bd2 | 23 | // files : the list of ESD files to be processed [default AliESds.root from cwd] |
24 | // nev : number of events to be processed [default all] | |
25 | // first : first event to process [default 0] | |
96387ba8 | 26 | // |
27 | // In compiled mode : | |
1ee39b3a | 28 | // Don't forget to load first the libraries |
29 | // gSystem->Load("libMemStat.so") | |
30 | // gSystem->Load("libMemStatGui.so") | |
31 | // gSystem->Load("libANALYSIS.so") | |
32 | // gSystem->Load("libANALYSISalice.so") | |
e9d62bd2 | 33 | // gSystem->Load("libTENDER.so"); |
2bfe5463 | 34 | // gSystem->Load("libPWGPP.so"); |
1ee39b3a | 35 | // gSystem->Load("libNetx.so") ; |
36 | // gSystem->Load("libRAliEn.so"); | |
37 | // | |
38 | // Authors: | |
39 | // Alex Bercuci (A.Bercuci@gsi.de) | |
40 | // Markus Fasel (m.Fasel@gsi.de) | |
41 | ||
42 | #if ! defined (__CINT__) || defined (__MAKECINT__) | |
43 | //#ifndef __CINT__ | |
44 | #include <Riostream.h> | |
45 | ||
46 | #include "TStopwatch.h" | |
47 | #include "TMemStat.h" | |
48 | #include "TMemStatViewerGUI.h" | |
49 | ||
50 | #include "TROOT.h" | |
51 | #include "TClass.h" | |
52 | #include "TSystem.h" | |
53 | #include "TError.h" | |
54 | #include "TChain.h" | |
55 | #include "TGrid.h" | |
56 | #include "TAlienCollection.h" | |
57 | #include "TGridCollection.h" | |
58 | #include "TGridResult.h" | |
59 | #include "TGeoGlobalMagField.h" | |
60 | ||
61 | #include "AliMagF.h" | |
62 | #include "AliTracker.h" | |
63 | #include "AliLog.h" | |
64 | #include "AliCDBManager.h" | |
65 | #include "AliGRPManager.h" | |
66 | #include "AliGeomManager.h" | |
67 | #include "AliAnalysisManager.h" | |
68 | #include "AliAnalysisDataContainer.h" | |
69 | #include "AliMCEventHandler.h" | |
70 | #include "AliESDInputHandler.h" | |
71 | ||
72 | #include "TRD/AliTRDtrackerV1.h" | |
73 | #include "TRD/AliTRDcalibDB.h" | |
74 | ||
2bfe5463 | 75 | #include "PWGPP/TRD/macros/AddTRDcheckESD.C" |
76 | #include "PWGPP/TRD/macros/AddTRDinfoGen.C" | |
77 | #include "PWGPP/TRD/macros/AddTRDcheckDET.C" | |
78 | #include "PWGPP/TRD/macros/AddTRDefficiency.C" | |
79 | #include "PWGPP/TRD/macros/AddTRDresolution.C" | |
80 | #include "PWGPP/TRD/macros/AddTRDcheckPID.C" | |
1ee39b3a | 81 | #endif |
82 | ||
1ee39b3a | 83 | Bool_t MEM = kFALSE; |
84 | ||
99535225 | 85 | TChain* MakeChainLST(const char* filename = NULL); |
86 | TChain* MakeChainXML(const char* filename = NULL); | |
87 | Bool_t UseMC(Char_t *opt); | |
88 | Bool_t UseFriends(Char_t *opt); | |
96387ba8 | 89 | void run(Char_t *optList="ALL", Int_t run=0, const Char_t *files=NULL, Long64_t nev=1234567890, Long64_t first = 0) |
1ee39b3a | 90 | { |
99535225 | 91 | TMemStat *mem = NULL; |
1ee39b3a | 92 | if(MEM){ |
5bb83ff3 | 93 | if(gSystem->Load("libMemStat.so")<0) return; |
94 | if(gSystem->Load("libMemStatGui.so")<0) return; | |
1ee39b3a | 95 | mem = new TMemStat("new, gnubuildin"); |
96 | mem->AddStamp("Start"); | |
97 | } | |
98 | TStopwatch timer; | |
99 | timer.Start(); | |
100 | ||
1ee39b3a | 101 | // VERY GENERAL SETTINGS |
e9d62bd2 | 102 | //AliLog::SetGlobalLogLevel(AliLog::kError); |
1ee39b3a | 103 | if(gSystem->Load("libANALYSIS.so")<0) return; |
104 | if(gSystem->Load("libANALYSISalice.so")<0) return; | |
c732f879 | 105 | if(gSystem->Load("libTENDER.so")<0) return; |
f1b821e6 | 106 | if(gSystem->Load("libCORRFW.so")<0) return; |
2bfe5463 | 107 | if(gSystem->Load("libPWGPP.so")<0) return; |
96387ba8 | 108 | if(gSystem->Load("libPWGmuon.so")<0) return; |
1ee39b3a | 109 | |
99535225 | 110 | Bool_t fHasMCdata = UseMC(optList); |
111 | Bool_t fHasFriends = UseFriends(optList); | |
1ee39b3a | 112 | |
1ee39b3a | 113 | // DEFINE DATA CHAIN |
99535225 | 114 | TChain *chain = NULL; |
1ee39b3a | 115 | if(!files) chain = MakeChainLST(); |
116 | else{ | |
117 | TString fn(files); | |
118 | if(fn.EndsWith("xml")) chain = MakeChainXML(files); | |
119 | else chain = MakeChainLST(files); | |
120 | } | |
121 | if(!chain) return; | |
1ee39b3a | 122 | chain->Lookup(); |
123 | chain->GetListOfFiles()->Print(); | |
f2e89a4c | 124 | Int_t nfound=(Int_t)chain->GetEntries(); |
125 | printf("\tENTRIES FOUND [%d] REQUESTED [%d]\n", nfound, nev>nfound?nfound:nev); | |
1ee39b3a | 126 | |
127 | ||
128 | // BUILD ANALYSIS MANAGER | |
5bb83ff3 | 129 | AliAnalysisManager *mgr = new AliAnalysisManager("TRD Reconstruction Performance & Calibration"); |
265a93da | 130 | AliESDInputHandlerRP *esdH(NULL); |
131 | mgr->SetInputEventHandler(esdH = new AliESDInputHandlerRP); | |
99535225 | 132 | if(fHasFriends){ |
133 | esdH->SetReadFriends(kTRUE); | |
134 | esdH->SetActiveBranches("ESDfriend"); | |
135 | } | |
265a93da | 136 | AliMCEventHandler *mcH(NULL); |
1ee39b3a | 137 | if(fHasMCdata) mgr->SetMCtruthEventHandler(mcH = new AliMCEventHandler()); |
138 | //mgr->SetDebugLevel(10); | |
72f5dcbe | 139 | mgr->SetSkipTerminate(kTRUE); |
1ee39b3a | 140 | |
10a3ae98 | 141 | // add CDB task |
96387ba8 | 142 | if(run>=0){ |
143 | gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskCDBconnect.C"); | |
144 | AliTaskCDBconnect *taskCDB = AddTaskCDBconnect(); | |
145 | if (!taskCDB) return; | |
146 | taskCDB->SetRunNumber(run); | |
f1b821e6 | 147 | } else Warning("run.C", "OCDB connection via AliTRDinfoGen."); |
10a3ae98 | 148 | |
2bfe5463 | 149 | gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTrainPerformanceTRD.C"); |
c3ebe2ae | 150 | if(!AddTrainPerformanceTRD(optList)) { |
d4f4bb29 | 151 | Error("run.C", "Error loading TRD train."); |
152 | return; | |
1ee39b3a | 153 | } |
154 | ||
155 | if (!mgr->InitAnalysis()) return; | |
156 | // verbosity | |
5bb83ff3 | 157 | printf("\tRUNNING TRAIN FOR TASKS:\n"); |
158 | TObjArray *taskList=mgr->GetTasks(); | |
159 | for(Int_t itask=0; itask<taskList->GetEntries(); itask++){ | |
160 | AliAnalysisTask *task=(AliAnalysisTask*)taskList->At(itask); | |
161 | printf(" %s [%s]\n", task->GetName(), task->GetTitle()); | |
162 | } | |
b91fdd71 | 163 | //mgr->PrintStatus(); |
1ee39b3a | 164 | mgr->StartAnalysis("local", chain, nev, first); |
1ee39b3a | 165 | timer.Stop(); |
166 | timer.Print(); | |
167 | ||
1ee39b3a | 168 | // verbosity |
5bb83ff3 | 169 | printf("\tCLEANING TASK LIST:\n"); |
1ee39b3a | 170 | mgr->GetTasks()->Delete(); |
171 | ||
172 | if(mcH) delete mcH; | |
173 | delete esdH; | |
1ee39b3a | 174 | delete chain; |
175 | if(MEM) delete mem; | |
176 | if(MEM) TMemStatViewerGUI::ShowGUI(); | |
177 | } | |
178 | ||
179 | //____________________________________________ | |
180 | TChain* MakeChainLST(const char* filename) | |
181 | { | |
182 | // Create the chain | |
183 | TChain* chain = new TChain("esdTree"); | |
184 | ||
185 | if(!filename){ | |
186 | chain->Add(Form("%s/AliESDs.root", gSystem->pwd())); | |
187 | return chain; | |
188 | } | |
189 | ||
190 | ||
191 | // read ESD files from the input list. | |
192 | ifstream in; | |
193 | in.open(filename); | |
194 | TString esdfile; | |
195 | while(in.good()) { | |
196 | in >> esdfile; | |
197 | if (!esdfile.Contains("root")) continue; // protection | |
198 | chain->Add(esdfile.Data()); | |
199 | } | |
200 | ||
201 | in.close(); | |
202 | ||
203 | return chain; | |
204 | } | |
205 | ||
206 | //____________________________________________ | |
207 | TChain* MakeChainXML(const char* xmlfile) | |
208 | { | |
209 | if (!TFile::Open(xmlfile)) { | |
210 | Error("MakeChainXML", Form("No file %s was found", xmlfile)); | |
99535225 | 211 | return NULL; |
1ee39b3a | 212 | } |
213 | ||
99535225 | 214 | if(gSystem->Load("libNetx.so")<0) return NULL; |
215 | if(gSystem->Load("libRAliEn.so")<0) return NULL; | |
1ee39b3a | 216 | TGrid::Connect("alien://") ; |
217 | ||
218 | TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile); | |
219 | if (!collection) { | |
220 | Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ; | |
99535225 | 221 | return NULL; |
1ee39b3a | 222 | } |
223 | //collection->CheckIfOnline(); | |
224 | ||
225 | TGridResult* result = collection->GetGridResult("",0 ,0); | |
226 | if(!result->GetEntries()){ | |
227 | Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ; | |
99535225 | 228 | return NULL; |
1ee39b3a | 229 | } |
230 | // Makes the ESD chain | |
231 | TChain* chain = new TChain("esdTree"); | |
232 | for (Int_t idx = 0; idx < result->GetEntries(); idx++) { | |
233 | chain->Add(result->GetKey(idx, "turl")); | |
234 | } | |
235 | return chain; | |
236 | } | |
99535225 | 237 | |
238 | //______________________________________________________ | |
239 | Bool_t UseMC(Char_t *opt){ | |
240 | return !(Bool_t)strstr(opt, "NOMC"); | |
241 | } | |
242 | ||
243 | //____________________________________________ | |
244 | Bool_t UseFriends(Char_t *opt){ | |
245 | return !(Bool_t)strstr(opt, "NOFR"); | |
246 | } |