]>
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") | |
4070f709 | 33 | // gSystem->Load("libTender"); |
34 | // gSystem->Load("libCORRFW"); | |
35 | // gSystem->Load("libPWGPP"); | |
36 | // gSystem->Load("libPWGmuon"); | |
37 | // gSystem->Load("libNetx") ; | |
38 | // gSystem->Load("libRAliEn"); | |
1ee39b3a | 39 | // |
40 | // Authors: | |
41 | // Alex Bercuci (A.Bercuci@gsi.de) | |
42 | // Markus Fasel (m.Fasel@gsi.de) | |
43 | ||
44 | #if ! defined (__CINT__) || defined (__MAKECINT__) | |
45 | //#ifndef __CINT__ | |
46 | #include <Riostream.h> | |
47 | ||
48 | #include "TStopwatch.h" | |
49 | #include "TMemStat.h" | |
50 | #include "TMemStatViewerGUI.h" | |
51 | ||
33056e04 | 52 | #include "TGrid.h" |
1ee39b3a | 53 | #include "TROOT.h" |
54 | #include "TClass.h" | |
55 | #include "TSystem.h" | |
56 | #include "TError.h" | |
57 | #include "TChain.h" | |
58 | #include "TGrid.h" | |
59 | #include "TAlienCollection.h" | |
60 | #include "TGridCollection.h" | |
61 | #include "TGridResult.h" | |
62 | #include "TGeoGlobalMagField.h" | |
63 | ||
64 | #include "AliMagF.h" | |
65 | #include "AliTracker.h" | |
66 | #include "AliLog.h" | |
67 | #include "AliCDBManager.h" | |
68 | #include "AliGRPManager.h" | |
69 | #include "AliGeomManager.h" | |
70 | #include "AliAnalysisManager.h" | |
71 | #include "AliAnalysisDataContainer.h" | |
72 | #include "AliMCEventHandler.h" | |
73 | #include "AliESDInputHandler.h" | |
74 | ||
75 | #include "TRD/AliTRDtrackerV1.h" | |
76 | #include "TRD/AliTRDcalibDB.h" | |
77 | ||
2bfe5463 | 78 | #include "PWGPP/TRD/macros/AddTRDcheckESD.C" |
79 | #include "PWGPP/TRD/macros/AddTRDinfoGen.C" | |
80 | #include "PWGPP/TRD/macros/AddTRDcheckDET.C" | |
81 | #include "PWGPP/TRD/macros/AddTRDefficiency.C" | |
82 | #include "PWGPP/TRD/macros/AddTRDresolution.C" | |
83 | #include "PWGPP/TRD/macros/AddTRDcheckPID.C" | |
1ee39b3a | 84 | #endif |
85 | ||
1ee39b3a | 86 | Bool_t MEM = kFALSE; |
87 | ||
99535225 | 88 | TChain* MakeChainLST(const char* filename = NULL); |
89 | TChain* MakeChainXML(const char* filename = NULL); | |
90 | Bool_t UseMC(Char_t *opt); | |
91 | Bool_t UseFriends(Char_t *opt); | |
96387ba8 | 92 | void run(Char_t *optList="ALL", Int_t run=0, const Char_t *files=NULL, Long64_t nev=1234567890, Long64_t first = 0) |
1ee39b3a | 93 | { |
99535225 | 94 | TMemStat *mem = NULL; |
1ee39b3a | 95 | if(MEM){ |
5bb83ff3 | 96 | if(gSystem->Load("libMemStat.so")<0) return; |
97 | if(gSystem->Load("libMemStatGui.so")<0) return; | |
1ee39b3a | 98 | mem = new TMemStat("new, gnubuildin"); |
99 | mem->AddStamp("Start"); | |
100 | } | |
101 | TStopwatch timer; | |
102 | timer.Start(); | |
103 | ||
1ee39b3a | 104 | // VERY GENERAL SETTINGS |
e9d62bd2 | 105 | //AliLog::SetGlobalLogLevel(AliLog::kError); |
1ee39b3a | 106 | if(gSystem->Load("libANALYSIS.so")<0) return; |
107 | if(gSystem->Load("libANALYSISalice.so")<0) return; | |
af472fff | 108 | if(gSystem->Load("libTender.so")<0) return; |
f1b821e6 | 109 | if(gSystem->Load("libCORRFW.so")<0) return; |
2bfe5463 | 110 | if(gSystem->Load("libPWGPP.so")<0) return; |
96387ba8 | 111 | if(gSystem->Load("libPWGmuon.so")<0) return; |
1ee39b3a | 112 | |
99535225 | 113 | Bool_t fHasMCdata = UseMC(optList); |
114 | Bool_t fHasFriends = UseFriends(optList); | |
1ee39b3a | 115 | |
1ee39b3a | 116 | // DEFINE DATA CHAIN |
99535225 | 117 | TChain *chain = NULL; |
1ee39b3a | 118 | if(!files) chain = MakeChainLST(); |
119 | else{ | |
120 | TString fn(files); | |
121 | if(fn.EndsWith("xml")) chain = MakeChainXML(files); | |
122 | else chain = MakeChainLST(files); | |
123 | } | |
124 | if(!chain) return; | |
1ee39b3a | 125 | chain->Lookup(); |
126 | chain->GetListOfFiles()->Print(); | |
f2e89a4c | 127 | Int_t nfound=(Int_t)chain->GetEntries(); |
128 | printf("\tENTRIES FOUND [%d] REQUESTED [%d]\n", nfound, nev>nfound?nfound:nev); | |
1ee39b3a | 129 | |
130 | ||
131 | // BUILD ANALYSIS MANAGER | |
5bb83ff3 | 132 | AliAnalysisManager *mgr = new AliAnalysisManager("TRD Reconstruction Performance & Calibration"); |
265a93da | 133 | AliESDInputHandlerRP *esdH(NULL); |
134 | mgr->SetInputEventHandler(esdH = new AliESDInputHandlerRP); | |
99535225 | 135 | if(fHasFriends){ |
136 | esdH->SetReadFriends(kTRUE); | |
137 | esdH->SetActiveBranches("ESDfriend"); | |
138 | } | |
265a93da | 139 | AliMCEventHandler *mcH(NULL); |
1ee39b3a | 140 | if(fHasMCdata) mgr->SetMCtruthEventHandler(mcH = new AliMCEventHandler()); |
141 | //mgr->SetDebugLevel(10); | |
72f5dcbe | 142 | mgr->SetSkipTerminate(kTRUE); |
1ee39b3a | 143 | |
10a3ae98 | 144 | // add CDB task |
96387ba8 | 145 | if(run>=0){ |
146 | gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskCDBconnect.C"); | |
147 | AliTaskCDBconnect *taskCDB = AddTaskCDBconnect(); | |
148 | if (!taskCDB) return; | |
149 | taskCDB->SetRunNumber(run); | |
f1b821e6 | 150 | } else Warning("run.C", "OCDB connection via AliTRDinfoGen."); |
10a3ae98 | 151 | |
2bfe5463 | 152 | gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTrainPerformanceTRD.C"); |
c3ebe2ae | 153 | if(!AddTrainPerformanceTRD(optList)) { |
d4f4bb29 | 154 | Error("run.C", "Error loading TRD train."); |
155 | return; | |
1ee39b3a | 156 | } |
157 | ||
158 | if (!mgr->InitAnalysis()) return; | |
159 | // verbosity | |
5bb83ff3 | 160 | printf("\tRUNNING TRAIN FOR TASKS:\n"); |
161 | TObjArray *taskList=mgr->GetTasks(); | |
162 | for(Int_t itask=0; itask<taskList->GetEntries(); itask++){ | |
163 | AliAnalysisTask *task=(AliAnalysisTask*)taskList->At(itask); | |
164 | printf(" %s [%s]\n", task->GetName(), task->GetTitle()); | |
165 | } | |
b91fdd71 | 166 | //mgr->PrintStatus(); |
1ee39b3a | 167 | mgr->StartAnalysis("local", chain, nev, first); |
1ee39b3a | 168 | timer.Stop(); |
169 | timer.Print(); | |
170 | ||
1ee39b3a | 171 | // verbosity |
5bb83ff3 | 172 | printf("\tCLEANING TASK LIST:\n"); |
1ee39b3a | 173 | mgr->GetTasks()->Delete(); |
174 | ||
175 | if(mcH) delete mcH; | |
176 | delete esdH; | |
1ee39b3a | 177 | delete chain; |
178 | if(MEM) delete mem; | |
179 | if(MEM) TMemStatViewerGUI::ShowGUI(); | |
180 | } | |
181 | ||
182 | //____________________________________________ | |
183 | TChain* MakeChainLST(const char* filename) | |
184 | { | |
185 | // Create the chain | |
186 | TChain* chain = new TChain("esdTree"); | |
1ee39b3a | 187 | if(!filename){ |
188 | chain->Add(Form("%s/AliESDs.root", gSystem->pwd())); | |
189 | return chain; | |
190 | } | |
191 | ||
192 | ||
193 | // read ESD files from the input list. | |
33056e04 | 194 | FILE *fp(NULL); |
195 | if(!(fp = fopen(filename, "rt"))){ | |
196 | Error("run::MakeChainLST()", Form("Input list \"%s\" not readable", filename)); | |
197 | return NULL; | |
1ee39b3a | 198 | } |
33056e04 | 199 | TString esdFile; |
200 | while(esdFile.Gets(fp)){ | |
201 | if (!esdFile.Contains("root")) continue; // protection | |
202 | if(esdFile.BeginsWith("alien://") && !gGrid){ | |
203 | if(gSystem->Load("libNetx.so")<0) return NULL; | |
204 | if(gSystem->Load("libRAliEn.so")<0) return NULL; | |
205 | TGrid::Connect("alien://"); | |
206 | } | |
207 | chain->Add(esdFile.Data()); | |
208 | } | |
209 | fclose(fp); | |
1ee39b3a | 210 | |
211 | return chain; | |
212 | } | |
213 | ||
214 | //____________________________________________ | |
215 | TChain* MakeChainXML(const char* xmlfile) | |
216 | { | |
217 | if (!TFile::Open(xmlfile)) { | |
218 | Error("MakeChainXML", Form("No file %s was found", xmlfile)); | |
99535225 | 219 | return NULL; |
1ee39b3a | 220 | } |
221 | ||
99535225 | 222 | if(gSystem->Load("libNetx.so")<0) return NULL; |
223 | if(gSystem->Load("libRAliEn.so")<0) return NULL; | |
1ee39b3a | 224 | TGrid::Connect("alien://") ; |
225 | ||
226 | TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile); | |
227 | if (!collection) { | |
228 | Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ; | |
99535225 | 229 | return NULL; |
1ee39b3a | 230 | } |
231 | //collection->CheckIfOnline(); | |
232 | ||
233 | TGridResult* result = collection->GetGridResult("",0 ,0); | |
234 | if(!result->GetEntries()){ | |
235 | Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ; | |
99535225 | 236 | return NULL; |
1ee39b3a | 237 | } |
238 | // Makes the ESD chain | |
239 | TChain* chain = new TChain("esdTree"); | |
240 | for (Int_t idx = 0; idx < result->GetEntries(); idx++) { | |
241 | chain->Add(result->GetKey(idx, "turl")); | |
242 | } | |
243 | return chain; | |
244 | } | |
99535225 | 245 | |
246 | //______________________________________________________ | |
247 | Bool_t UseMC(Char_t *opt){ | |
248 | return !(Bool_t)strstr(opt, "NOMC"); | |
249 | } | |
250 | ||
251 | //____________________________________________ | |
252 | Bool_t UseFriends(Char_t *opt){ | |
253 | return !(Bool_t)strstr(opt, "NOFR"); | |
254 | } |