]>
Commit | Line | Data |
---|---|---|
77203477 | 1 | // Steer TRD QA train for Reconstruction (Clusterizer, Tracking and PID). |
2 | // | |
3 | // Usage: | |
e15179be | 4 | // run.C(tasks, files) |
77203477 | 5 | // tasks : "ALL" or one/more of the following: |
6 | // "EFF" : TRD Tracking Efficiency | |
7 | // "EFFC" : TRD Tracking Efficiency Combined (barrel + stand alone) - only in case of simulations | |
c792ca2e | 8 | // "MULT" : TRD single track selection |
77203477 | 9 | // "RES" : TRD tracking Resolution |
5198d8c6 | 10 | // "CLRES": clusters Resolution |
ba2773d0 | 11 | // "CAL" : TRD calibration |
56bb0e8e | 12 | // "ALGN" : TRD alignment |
77203477 | 13 | // "PID" : TRD PID - pion efficiency |
14 | // "PIDR" : TRD PID - reference data | |
2b468513 | 15 | // "DET" : Basic TRD Detector checks |
28efdace | 16 | // "NOFR" : Data set does not have AliESDfriends.root |
4b8f8a35 | 17 | // "NOMC" : Data set does not have Monte Carlo Informations (real data), so all tasks which rely |
18 | // on MC information are switched off | |
2c0cf367 | 19 | // |
20 | // In compiled mode : | |
21 | // Don't forget to load first the libraries | |
9f669d31 | 22 | // gSystem->Load("libMemStat.so") |
23 | // gSystem->Load("libMemStatGui.so") | |
24 | // gSystem->Load("libANALYSIS.so") | |
25 | // gSystem->Load("libANALYSISalice.so") | |
26 | // gSystem->Load("libTRDqaRec.so") | |
27 | // gSystem->Load("libPWG1.so"); | |
e15179be | 28 | // gSystem->Load("libNetx.so") ; |
29 | // gSystem->Load("libRAliEn.so"); | |
2c0cf367 | 30 | // |
77203477 | 31 | // Authors: |
32 | // Alex Bercuci (A.Bercuci@gsi.de) | |
33 | // Markus Fasel (m.Fasel@gsi.de) | |
34 | ||
ddd1a033 | 35 | #if ! defined (__CINT__) || defined (__MAKECINT__) |
36 | //#ifndef __CINT__ | |
8cc0ed91 | 37 | #include <Riostream.h> |
38 | ||
819f5b0f | 39 | #include "TStopwatch.h" |
40 | #include "TMemStat.h" | |
41 | #include "TMemStatViewerGUI.h" | |
42 | ||
43 | #include "TROOT.h" | |
b94feda9 | 44 | #include "TClass.h" |
819f5b0f | 45 | #include "TSystem.h" |
8cc0ed91 | 46 | #include "TError.h" |
819f5b0f | 47 | #include "TChain.h" |
e15179be | 48 | #include "TGrid.h" |
49 | #include "TAlienCollection.h" | |
50 | #include "TGridCollection.h" | |
51 | #include "TGridResult.h" | |
af735a05 | 52 | #include "TGeoGlobalMagField.h" |
819f5b0f | 53 | |
f7a1cc68 | 54 | #include "AliMagF.h" |
8cc0ed91 | 55 | #include "AliTracker.h" |
819f5b0f | 56 | #include "AliLog.h" |
57 | #include "AliCDBManager.h" | |
566aca47 | 58 | #include "AliGRPManager.h" |
e15179be | 59 | #include "AliGeomManager.h" |
819f5b0f | 60 | #include "AliAnalysisManager.h" |
61 | #include "AliAnalysisDataContainer.h" | |
8cc0ed91 | 62 | #include "AliMCEventHandler.h" |
63 | #include "AliESDInputHandler.h" | |
819f5b0f | 64 | |
8cc0ed91 | 65 | #include "TRD/AliTRDtrackerV1.h" |
66 | #include "TRD/AliTRDcalibDB.h" | |
6da3eee3 | 67 | |
ddd1a033 | 68 | #include "TRD/qaRec/macros/AliTRDperformanceTrain.h" |
6da3eee3 | 69 | #include "TRD/qaRec/macros/AddTRDcheckESD.C" |
70 | #include "TRD/qaRec/macros/AddTRDinfoGen.C" | |
71 | #include "TRD/qaRec/macros/AddTRDcheckDET.C" | |
72 | #include "TRD/qaRec/macros/AddTRDefficiency.C" | |
73 | #include "TRD/qaRec/macros/AddTRDresolution.C" | |
74 | #include "TRD/qaRec/macros/AddTRDcheckPID.C" | |
75 | ||
a12a3391 | 76 | #include "PWG1/macros/AddPerformanceTask.C" |
819f5b0f | 77 | #endif |
78 | ||
4e6e97a5 | 79 | #include "../../TRD/qaRec/macros/AliTRDperformanceTrain.h" |
80 | #include "../../PWG1/macros/AddPerformanceTask.h" | |
6da3eee3 | 81 | |
3d86166d | 82 | |
819f5b0f | 83 | Bool_t MEM = kFALSE; |
8cc0ed91 | 84 | |
e15179be | 85 | TChain* MakeChainLST(const char* filename = 0x0); |
86 | TChain* MakeChainXML(const char* filename = 0x0); | |
b94feda9 | 87 | void run(Char_t *trd="ALL", Char_t *tpc="ALL", const Char_t *files=0x0, Long64_t nev=1234567890, Long64_t first = 0) |
77203477 | 88 | { |
819f5b0f | 89 | TMemStat *mem = 0x0; |
8cc0ed91 | 90 | if(MEM){ |
91 | gSystem->Load("libMemStat.so"); | |
92 | gSystem->Load("libMemStatGui.so"); | |
93 | mem = new TMemStat("new, gnubuildin"); | |
94 | mem->AddStamp("Start"); | |
95 | } | |
814ecea4 | 96 | TStopwatch timer; |
97 | timer.Start(); | |
814ecea4 | 98 | |
873458ab | 99 | |
100 | ||
101 | // VERY GENERAL SETTINGS | |
b94feda9 | 102 | AliLog::SetGlobalLogLevel(AliLog::kError); |
107fde80 | 103 | if(gSystem->Load("libANALYSIS.so")<0) return; |
873458ab | 104 | if(gSystem->Load("libANALYSISalice.so")<0) return; |
105 | ||
4e6e97a5 | 106 | Bool_t fHasMCdata = 1;//HasReadMCData(trd); |
a12a3391 | 107 | //Bool_t fHasFriends = HasReadFriendData(trd); |
77203477 | 108 | |
873458ab | 109 | // INITIALIZATION OF RUNNING ENVIRONMENT |
af735a05 | 110 | //TODO We should use the GRP if available similar to AliReconstruction::InitGRP()! |
6bc4a8f4 | 111 | // initialize OCDB manager |
112 | AliCDBManager *cdbManager = AliCDBManager::Instance(); | |
162637e4 | 113 | cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
de886cac | 114 | cdbManager->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd())); |
6bc4a8f4 | 115 | cdbManager->SetRun(0); |
116 | cdbManager->SetCacheFlag(kFALSE); | |
566aca47 | 117 | // initialize magnetic field from the GRP manager. |
118 | AliGRPManager grpMan; | |
119 | grpMan.ReadGRPEntry(); | |
120 | grpMan.SetMagField(); | |
121 | //AliRunInfo *runInfo = grpMan.GetRunInfo(); | |
122 | AliGeomManager::LoadGeometry(); | |
5198d8c6 | 123 | |
8cc0ed91 | 124 | |
e15179be | 125 | // DEFINE DATA CHAIN |
126 | TChain *chain = 0x0; | |
127 | if(!files) chain = MakeChainLST(); | |
128 | else{ | |
129 | TString fn(files); | |
130 | if(fn.EndsWith("xml")) chain = MakeChainXML(files); | |
131 | else chain = MakeChainLST(files); | |
132 | } | |
133 | if(!chain) return; | |
814ecea4 | 134 | chain->SetBranchStatus("*FMD*",0); |
135 | chain->SetBranchStatus("*Calo*",0); | |
136 | chain->SetBranchStatus("Tracks", 1); | |
137 | chain->SetBranchStatus("ESDfriend*",1); | |
138 | chain->Lookup(); | |
139 | chain->GetListOfFiles()->Print(); | |
140 | printf("\n ----> CHAIN HAS %d ENTRIES <----\n\n", (Int_t)chain->GetEntries()); | |
814ecea4 | 141 | |
873458ab | 142 | |
143 | // BUILD ANALYSIS MANAGER | |
b94feda9 | 144 | AliAnalysisManager *mgr = new AliAnalysisManager("Post Reconstruction Calibration/QA"); |
8cc0ed91 | 145 | AliVEventHandler *esdH = 0x0, *mcH = 0x0; |
146 | mgr->SetInputEventHandler(esdH = new AliESDInputHandler); | |
147 | if(fHasMCdata) mgr->SetMCtruthEventHandler(mcH = new AliMCEventHandler()); | |
814ecea4 | 148 | //mgr->SetDebugLevel(10); |
149 | ||
b94feda9 | 150 | |
873458ab | 151 | |
b94feda9 | 152 | /////////////////////////////////////////////////////////// |
153 | /////////////// TRD /////////// | |
154 | /////////////////////////////////////////////////////////// | |
873458ab | 155 | // TRD specific library |
156 | if(gSystem->Load("libTRDqaRec.so")<0) return; | |
873458ab | 157 | // TRD data containers |
98233fc0 | 158 | AliAnalysisDataContainer *ci[] = {0x0, 0x0, 0x0}; |
873458ab | 159 | |
873458ab | 160 | |
6da3eee3 | 161 | // initialize TRD settings |
162 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
163 | AliTRDtrackerV1::SetNTimeBins(cal->GetNumberOfTimeBins()); | |
164 | ||
165 | // plug (set of) TRD wagons in the train | |
166 | if(trd){ | |
167 | for(Int_t it=0; it<NTRDQATASKS; it++){ | |
168 | if(gROOT->LoadMacro(Form("$ALICE_ROOT/TRD/qaRec/macros/Add%s.C+", TString(fgkTRDtaskClassName[it])(3,20).Data()))) { | |
169 | Error("run.C", Form("Error loading %s task.", fgkTRDtaskClassName[it])); | |
170 | return; | |
171 | } | |
172 | ||
173 | switch(it){ | |
174 | case kCheckESD: | |
175 | AddTRDcheckESD(mgr); break; | |
176 | case kInfoGen: | |
177 | AddTRDinfoGen(mgr, trd, 0x0, ci); break; | |
178 | case kCheckDET: | |
179 | AddTRDcheckDET(mgr, trd, ci); break; | |
180 | case kEfficiency: | |
181 | AddTRDefficiency(mgr, trd, ci); break; | |
182 | case kResolution: | |
183 | AddTRDresolution(mgr, trd, ci); break; | |
184 | case kCheckPID: | |
185 | AddTRDcheckPID(mgr, trd, ci); break; | |
186 | default: | |
187 | Warning("run.C", Form("No performance task registered at slot %d.", it)); | |
188 | } | |
e15179be | 189 | } |
2b468513 | 190 | } |
b94feda9 | 191 | |
873458ab | 192 | /////////////////////////////////////////////////////////// |
193 | /////////////// TPC /////////// | |
194 | /////////////////////////////////////////////////////////// | |
b94feda9 | 195 | if(gSystem->Load("libPWG1.so")<0) return; |
b94feda9 | 196 | |
873458ab | 197 | // BUILD STEERING TASK FOR TPC |
6da3eee3 | 198 | if(tpc){ |
873458ab | 199 | if(gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddPerformanceTask.C+")) { |
200 | Error("run.C", "Error loading AliPerformanceTask task."); | |
201 | return; | |
202 | } | |
6da3eee3 | 203 | AddPerformanceTask(mgr, tpc); |
b94feda9 | 204 | } |
205 | ||
b94feda9 | 206 | if (!mgr->InitAnalysis()) return; |
873458ab | 207 | // verbosity |
208 | printf("\n\tRUNNING TRAIN FOR TASKS:\n"); | |
209 | mgr->GetTasks()->ls(); | |
d85cd79c | 210 | //mgr->PrintStatus(); |
819f5b0f | 211 | |
b94feda9 | 212 | mgr->StartAnalysis("local", chain, nev, first); |
814ecea4 | 213 | |
214 | timer.Stop(); | |
819f5b0f | 215 | timer.Print(); |
216 | ||
2c0cf367 | 217 | cal->Terminate(); |
af735a05 | 218 | TGeoGlobalMagField::Instance()->SetField(NULL); |
8cc0ed91 | 219 | delete cdbManager; |
d12237d6 | 220 | |
873458ab | 221 | // verbosity |
222 | printf("\n\tCLEANING UP TRAIN:\n"); | |
223 | mgr->GetTasks()->Delete(); | |
b94feda9 | 224 | |
8cc0ed91 | 225 | if(mcH) delete mcH; |
226 | delete esdH; | |
227 | delete mgr; | |
228 | delete chain; | |
819f5b0f | 229 | if(MEM) delete mem; |
230 | if(MEM) TMemStatViewerGUI::ShowGUI(); | |
814ecea4 | 231 | } |
8cc0ed91 | 232 | |
e15179be | 233 | //____________________________________________ |
234 | TChain* MakeChainLST(const char* filename) | |
8cc0ed91 | 235 | { |
236 | // Create the chain | |
237 | TChain* chain = new TChain("esdTree"); | |
238 | ||
239 | if(!filename){ | |
240 | chain->Add(Form("%s/AliESDs.root", gSystem->pwd())); | |
241 | return chain; | |
242 | } | |
243 | ||
244 | ||
245 | // read ESD files from the input list. | |
246 | ifstream in; | |
247 | in.open(filename); | |
248 | TString esdfile; | |
e15179be | 249 | while(in.good()) { |
8cc0ed91 | 250 | in >> esdfile; |
251 | if (!esdfile.Contains("root")) continue; // protection | |
252 | chain->Add(esdfile.Data()); | |
253 | } | |
254 | ||
255 | in.close(); | |
256 | ||
257 | return chain; | |
258 | } | |
e15179be | 259 | |
260 | //____________________________________________ | |
261 | TChain* MakeChainXML(const char* xmlfile) | |
262 | { | |
263 | if (!TFile::Open(xmlfile)) { | |
264 | Error("MakeChainXML", Form("No file %s was found", xmlfile)); | |
265 | return 0x0; | |
266 | } | |
267 | ||
268 | if(gSystem->Load("libNetx.so")<0) return 0x0; | |
269 | if(gSystem->Load("libRAliEn.so")<0) return 0x0; | |
270 | TGrid::Connect("alien://") ; | |
271 | ||
272 | TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile); | |
273 | if (!collection) { | |
274 | Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ; | |
275 | return 0x0; | |
276 | } | |
277 | //collection->CheckIfOnline(); | |
278 | ||
279 | TGridResult* result = collection->GetGridResult("",0 ,0); | |
280 | if(!result->GetEntries()){ | |
281 | Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ; | |
282 | return 0x0; | |
283 | } | |
284 | // Makes the ESD chain | |
285 | TChain* chain = new TChain("esdTree"); | |
286 | for (Int_t idx = 0; idx < result->GetEntries(); idx++) { | |
287 | chain->Add(result->GetKey(idx, "turl")); | |
288 | } | |
289 | return chain; | |
290 | } |