]>
Commit | Line | Data |
---|---|---|
1ee39b3a | 1 | // Steer TRD QA train for Reconstruction (Clusterizer, Tracking and PID). |
2 | // | |
3 | // Usage: | |
e9d62bd2 | 4 | // run.C(optList, files, nev, first, runNo, ocdb_uri, grp_uri) |
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 | |
16 | // "DET" : Basic TRD Detector checks | |
e9d62bd2 | 17 | // ****** SPECIAL OPTIONS ********** |
1ee39b3a | 18 | // "NOFR" : Data set does not have AliESDfriends.root |
e9d62bd2 | 19 | // "NOMC" : Data set does not have Monte Carlo Informations (default have MC), |
1ee39b3a | 20 | // |
e9d62bd2 | 21 | // files : the list of ESD files to be processed [default AliESds.root from cwd] |
22 | // nev : number of events to be processed [default all] | |
23 | // first : first event to process [default 0] | |
24 | // runNo : run number [default 0] | |
25 | // ocdb_uri : OCDB location [default local, $ALICE_ROOT]. In case of AliEn the syntax should be of the form | |
26 | // alien://folder=/alice/data/2010/OCDB?user=username?cacheF=yourDirectory?cacheS=yourSize | |
27 | // grp_uri : GRP/GRP/Data location [default cwd]. In case of AliEn the syntax should be of the form | |
28 | // alien://folder=/alice/data/2010/OCDB?user=username?cacheF=yourDirectory?cacheS=yourSize | |
1ee39b3a | 29 | // In compiled mode : |
30 | // Don't forget to load first the libraries | |
31 | // gSystem->Load("libMemStat.so") | |
32 | // gSystem->Load("libMemStatGui.so") | |
33 | // gSystem->Load("libANALYSIS.so") | |
34 | // gSystem->Load("libANALYSISalice.so") | |
e9d62bd2 | 35 | // gSystem->Load("libTENDER.so"); |
1ee39b3a | 36 | // gSystem->Load("libPWG1.so"); |
37 | // gSystem->Load("libNetx.so") ; | |
38 | // gSystem->Load("libRAliEn.so"); | |
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 | ||
52 | #include "TROOT.h" | |
53 | #include "TClass.h" | |
54 | #include "TSystem.h" | |
55 | #include "TError.h" | |
56 | #include "TChain.h" | |
57 | #include "TGrid.h" | |
58 | #include "TAlienCollection.h" | |
59 | #include "TGridCollection.h" | |
60 | #include "TGridResult.h" | |
61 | #include "TGeoGlobalMagField.h" | |
62 | ||
63 | #include "AliMagF.h" | |
64 | #include "AliTracker.h" | |
65 | #include "AliLog.h" | |
66 | #include "AliCDBManager.h" | |
67 | #include "AliGRPManager.h" | |
68 | #include "AliGeomManager.h" | |
69 | #include "AliAnalysisManager.h" | |
70 | #include "AliAnalysisDataContainer.h" | |
71 | #include "AliMCEventHandler.h" | |
72 | #include "AliESDInputHandler.h" | |
73 | ||
74 | #include "TRD/AliTRDtrackerV1.h" | |
75 | #include "TRD/AliTRDcalibDB.h" | |
76 | ||
d4f4bb29 | 77 | #include "PWG1/TRD/macros/AliTRDperformanceTrain.h" |
78 | #include "PWG1/TRD/macros/AddTRDcheckESD.C" | |
79 | #include "PWG1/TRD/macros/AddTRDinfoGen.C" | |
80 | #include "PWG1/TRD/macros/AddTRDcheckDET.C" | |
81 | #include "PWG1/TRD/macros/AddTRDefficiency.C" | |
82 | #include "PWG1/TRD/macros/AddTRDresolution.C" | |
83 | #include "PWG1/TRD/macros/AddTRDcheckPID.C" | |
1ee39b3a | 84 | |
1ee39b3a | 85 | #endif |
86 | ||
d4f4bb29 | 87 | #include "macros/AliTRDperformanceTrain.h" |
1ee39b3a | 88 | |
89 | ||
90 | Bool_t MEM = kFALSE; | |
91 | ||
92 | TChain* MakeChainLST(const char* filename = 0x0); | |
93 | TChain* MakeChainXML(const char* filename = 0x0); | |
523a3d00 | 94 | void run(Char_t *optList="ALL", const Char_t *files=0x0, Long64_t nev=1234567890, Long64_t first = 0, Int_t runNo=0, const Char_t *ocdb_uri="local://$ALICE_ROOT/OCDB", const Char_t *grp_uri=Form("local://%s", gSystem->pwd())) |
1ee39b3a | 95 | { |
96 | TMemStat *mem = 0x0; | |
97 | if(MEM){ | |
5bb83ff3 | 98 | if(gSystem->Load("libMemStat.so")<0) return; |
99 | if(gSystem->Load("libMemStatGui.so")<0) return; | |
1ee39b3a | 100 | mem = new TMemStat("new, gnubuildin"); |
101 | mem->AddStamp("Start"); | |
102 | } | |
103 | TStopwatch timer; | |
104 | timer.Start(); | |
105 | ||
1ee39b3a | 106 | // VERY GENERAL SETTINGS |
e9d62bd2 | 107 | //AliLog::SetGlobalLogLevel(AliLog::kError); |
1ee39b3a | 108 | if(gSystem->Load("libANALYSIS.so")<0) return; |
109 | if(gSystem->Load("libANALYSISalice.so")<0) return; | |
c732f879 | 110 | if(gSystem->Load("libTENDER.so")<0) return; |
d4f4bb29 | 111 | if(gSystem->Load("libPWG1.so")<0) return; |
1ee39b3a | 112 | |
523a3d00 | 113 | Bool_t fHasMCdata = HasReadMCData(optList); |
114 | Bool_t fHasFriends = HasReadFriendData(optList); | |
1ee39b3a | 115 | |
116 | // INITIALIZATION OF RUNNING ENVIRONMENT | |
1ee39b3a | 117 | // initialize OCDB manager |
118 | AliCDBManager *cdbManager = AliCDBManager::Instance(); | |
523a3d00 | 119 | cdbManager->SetDefaultStorage(ocdb_uri); |
120 | if(!cdbManager->IsDefaultStorageSet()){ | |
121 | Error("run.C", "Error setting OCDB."); | |
122 | return; | |
123 | } | |
124 | cdbManager->SetRun(runNo); | |
125 | cdbManager->SetSpecificStorage("GRP/GRP/Data", grp_uri); | |
1ee39b3a | 126 | cdbManager->SetCacheFlag(kFALSE); |
127 | // initialize magnetic field from the GRP manager. | |
128 | AliGRPManager grpMan; | |
523a3d00 | 129 | if(!grpMan.ReadGRPEntry()) return; |
130 | if(!grpMan.SetMagField()) return; | |
1ee39b3a | 131 | //AliRunInfo *runInfo = grpMan.GetRunInfo(); |
132 | AliGeomManager::LoadGeometry(); | |
133 | ||
1ee39b3a | 134 | // DEFINE DATA CHAIN |
135 | TChain *chain = 0x0; | |
136 | if(!files) chain = MakeChainLST(); | |
137 | else{ | |
138 | TString fn(files); | |
139 | if(fn.EndsWith("xml")) chain = MakeChainXML(files); | |
140 | else chain = MakeChainLST(files); | |
141 | } | |
142 | if(!chain) return; | |
1ee39b3a | 143 | chain->Lookup(); |
144 | chain->GetListOfFiles()->Print(); | |
f2e89a4c | 145 | Int_t nfound=(Int_t)chain->GetEntries(); |
146 | printf("\tENTRIES FOUND [%d] REQUESTED [%d]\n", nfound, nev>nfound?nfound:nev); | |
1ee39b3a | 147 | |
148 | ||
149 | // BUILD ANALYSIS MANAGER | |
5bb83ff3 | 150 | AliAnalysisManager *mgr = new AliAnalysisManager("TRD Reconstruction Performance & Calibration"); |
265a93da | 151 | AliESDInputHandlerRP *esdH(NULL); |
152 | mgr->SetInputEventHandler(esdH = new AliESDInputHandlerRP); | |
153 | esdH->SetReadFriends(kTRUE); | |
154 | esdH->SetActiveBranches("ESDfriend"); | |
155 | AliMCEventHandler *mcH(NULL); | |
1ee39b3a | 156 | if(fHasMCdata) mgr->SetMCtruthEventHandler(mcH = new AliMCEventHandler()); |
157 | //mgr->SetDebugLevel(10); | |
158 | ||
d4f4bb29 | 159 | gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTrainPerformanceTRD.C"); |
c3ebe2ae | 160 | if(!AddTrainPerformanceTRD(optList)) { |
d4f4bb29 | 161 | Error("run.C", "Error loading TRD train."); |
162 | return; | |
1ee39b3a | 163 | } |
164 | ||
165 | if (!mgr->InitAnalysis()) return; | |
166 | // verbosity | |
5bb83ff3 | 167 | printf("\tRUNNING TRAIN FOR TASKS:\n"); |
168 | TObjArray *taskList=mgr->GetTasks(); | |
169 | for(Int_t itask=0; itask<taskList->GetEntries(); itask++){ | |
170 | AliAnalysisTask *task=(AliAnalysisTask*)taskList->At(itask); | |
171 | printf(" %s [%s]\n", task->GetName(), task->GetTitle()); | |
172 | } | |
b91fdd71 | 173 | //mgr->PrintStatus(); |
1ee39b3a | 174 | mgr->StartAnalysis("local", chain, nev, first); |
175 | ||
176 | timer.Stop(); | |
177 | timer.Print(); | |
178 | ||
1ee39b3a | 179 | delete cdbManager; |
180 | ||
181 | // verbosity | |
5bb83ff3 | 182 | printf("\tCLEANING TASK LIST:\n"); |
1ee39b3a | 183 | mgr->GetTasks()->Delete(); |
184 | ||
185 | if(mcH) delete mcH; | |
186 | delete esdH; | |
1ee39b3a | 187 | delete chain; |
188 | if(MEM) delete mem; | |
189 | if(MEM) TMemStatViewerGUI::ShowGUI(); | |
190 | } | |
191 | ||
192 | //____________________________________________ | |
193 | TChain* MakeChainLST(const char* filename) | |
194 | { | |
195 | // Create the chain | |
196 | TChain* chain = new TChain("esdTree"); | |
197 | ||
198 | if(!filename){ | |
199 | chain->Add(Form("%s/AliESDs.root", gSystem->pwd())); | |
200 | return chain; | |
201 | } | |
202 | ||
203 | ||
204 | // read ESD files from the input list. | |
205 | ifstream in; | |
206 | in.open(filename); | |
207 | TString esdfile; | |
208 | while(in.good()) { | |
209 | in >> esdfile; | |
210 | if (!esdfile.Contains("root")) continue; // protection | |
211 | chain->Add(esdfile.Data()); | |
212 | } | |
213 | ||
214 | in.close(); | |
215 | ||
216 | return chain; | |
217 | } | |
218 | ||
219 | //____________________________________________ | |
220 | TChain* MakeChainXML(const char* xmlfile) | |
221 | { | |
222 | if (!TFile::Open(xmlfile)) { | |
223 | Error("MakeChainXML", Form("No file %s was found", xmlfile)); | |
224 | return 0x0; | |
225 | } | |
226 | ||
227 | if(gSystem->Load("libNetx.so")<0) return 0x0; | |
228 | if(gSystem->Load("libRAliEn.so")<0) return 0x0; | |
229 | TGrid::Connect("alien://") ; | |
230 | ||
231 | TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile); | |
232 | if (!collection) { | |
233 | Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ; | |
234 | return 0x0; | |
235 | } | |
236 | //collection->CheckIfOnline(); | |
237 | ||
238 | TGridResult* result = collection->GetGridResult("",0 ,0); | |
239 | if(!result->GetEntries()){ | |
240 | Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ; | |
241 | return 0x0; | |
242 | } | |
243 | // Makes the ESD chain | |
244 | TChain* chain = new TChain("esdTree"); | |
245 | for (Int_t idx = 0; idx < result->GetEntries(); idx++) { | |
246 | chain->Add(result->GetKey(idx, "turl")); | |
247 | } | |
248 | return chain; | |
249 | } |