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