1 // Steer TRD QA train for Reconstruction (Clusterizer, Tracking and PID).
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)
6 // optList : "ALL" [default] or one/more of the following:
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 // "V0" : monitor V0 performance for use in TRD PID calibration
17 // "DET" : Basic TRD Detector checks
18 // ****** SPECIAL OPTIONS **********
19 // "NOFR" : Data set does not have AliESDfriends.root
20 // "NOMC" : Data set does not have Monte Carlo Informations (default have MC),
22 // run : run number [default 0]; if negative value is specified the OCDB connection is left to AddTRDinfoGen.C
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]
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")
33 // gSystem->Load("libTENDER.so");
34 // gSystem->Load("libCORRFW.so");
35 // gSystem->Load("libPWGPP.so");
36 // gSystem->Load("libPWGmuon.so");
37 // gSystem->Load("libNetx.so") ;
38 // gSystem->Load("libRAliEn.so");
41 // Alex Bercuci (A.Bercuci@gsi.de)
42 // Markus Fasel (m.Fasel@gsi.de)
44 #if ! defined (__CINT__) || defined (__MAKECINT__)
46 #include <Riostream.h>
48 #include "TStopwatch.h"
50 #include "TMemStatViewerGUI.h"
59 #include "TAlienCollection.h"
60 #include "TGridCollection.h"
61 #include "TGridResult.h"
62 #include "TGeoGlobalMagField.h"
65 #include "AliTracker.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"
75 #include "TRD/AliTRDtrackerV1.h"
76 #include "TRD/AliTRDcalibDB.h"
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"
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);
92 void run(Char_t *optList="ALL", Int_t run=0, const Char_t *files=NULL, Long64_t nev=1234567890, Long64_t first = 0)
96 if(gSystem->Load("libMemStat.so")<0) return;
97 if(gSystem->Load("libMemStatGui.so")<0) return;
98 mem = new TMemStat("new, gnubuildin");
99 mem->AddStamp("Start");
104 // VERY GENERAL SETTINGS
105 //AliLog::SetGlobalLogLevel(AliLog::kError);
106 if(gSystem->Load("libANALYSIS.so")<0) return;
107 if(gSystem->Load("libANALYSISalice.so")<0) return;
108 if(gSystem->Load("libTENDER.so")<0) return;
109 if(gSystem->Load("libCORRFW.so")<0) return;
110 if(gSystem->Load("libPWGPP.so")<0) return;
111 if(gSystem->Load("libPWGmuon.so")<0) return;
113 Bool_t fHasMCdata = UseMC(optList);
114 Bool_t fHasFriends = UseFriends(optList);
117 TChain *chain = NULL;
118 if(!files) chain = MakeChainLST();
121 if(fn.EndsWith("xml")) chain = MakeChainXML(files);
122 else chain = MakeChainLST(files);
126 chain->GetListOfFiles()->Print();
127 Int_t nfound=(Int_t)chain->GetEntries();
128 printf("\tENTRIES FOUND [%d] REQUESTED [%d]\n", nfound, nev>nfound?nfound:nev);
131 // BUILD ANALYSIS MANAGER
132 AliAnalysisManager *mgr = new AliAnalysisManager("TRD Reconstruction Performance & Calibration");
133 AliESDInputHandlerRP *esdH(NULL);
134 mgr->SetInputEventHandler(esdH = new AliESDInputHandlerRP);
136 esdH->SetReadFriends(kTRUE);
137 esdH->SetActiveBranches("ESDfriend");
139 AliMCEventHandler *mcH(NULL);
140 if(fHasMCdata) mgr->SetMCtruthEventHandler(mcH = new AliMCEventHandler());
141 //mgr->SetDebugLevel(10);
142 mgr->SetSkipTerminate(kTRUE);
146 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskCDBconnect.C");
147 AliTaskCDBconnect *taskCDB = AddTaskCDBconnect();
148 if (!taskCDB) return;
149 taskCDB->SetRunNumber(run);
150 } else Warning("run.C", "OCDB connection via AliTRDinfoGen.");
152 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTrainPerformanceTRD.C");
153 if(!AddTrainPerformanceTRD(optList)) {
154 Error("run.C", "Error loading TRD train.");
158 if (!mgr->InitAnalysis()) return;
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());
166 //mgr->PrintStatus();
167 mgr->StartAnalysis("local", chain, nev, first);
172 printf("\tCLEANING TASK LIST:\n");
173 mgr->GetTasks()->Delete();
179 if(MEM) TMemStatViewerGUI::ShowGUI();
182 //____________________________________________
183 TChain* MakeChainLST(const char* filename)
186 TChain* chain = new TChain("esdTree");
188 chain->Add(Form("%s/AliESDs.root", gSystem->pwd()));
193 // read ESD files from the input list.
195 if(!(fp = fopen(filename, "rt"))){
196 Error("run::MakeChainLST()", Form("Input list \"%s\" not readable", filename));
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://");
207 chain->Add(esdFile.Data());
214 //____________________________________________
215 TChain* MakeChainXML(const char* xmlfile)
217 if (!TFile::Open(xmlfile)) {
218 Error("MakeChainXML", Form("No file %s was found", xmlfile));
222 if(gSystem->Load("libNetx.so")<0) return NULL;
223 if(gSystem->Load("libRAliEn.so")<0) return NULL;
224 TGrid::Connect("alien://") ;
226 TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile);
228 Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ;
231 //collection->CheckIfOnline();
233 TGridResult* result = collection->GetGridResult("",0 ,0);
234 if(!result->GetEntries()){
235 Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ;
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"));
246 //______________________________________________________
247 Bool_t UseMC(Char_t *opt){
248 return !(Bool_t)strstr(opt, "NOMC");
251 //____________________________________________
252 Bool_t UseFriends(Char_t *opt){
253 return !(Bool_t)strstr(opt, "NOFR");