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