]>
Commit | Line | Data |
---|---|---|
1cb2a06e | 1 | enum anaModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR}; |
2 | //mLocal: Analyze locally files in your computer using aliroot | |
3 | //mLocalPAR: Analyze locally files in your computer using root + PAR files | |
4 | //mPROOF: Analyze CAF files with PROOF | |
5 | //mGrid: Analyze files on Grid via AliEn plug-in and using precompiled FLOW libraries | |
6 | //mGridPAR: Analyze files on Grid via AliEn plug-in and using par files for FLOW package | |
7 | ||
8 | //Analysis modes | |
9 | const TString analysisMode = "TPC"; //"TPC", "Global" | |
10 | ||
11 | //Centrality stuff | |
12 | Int_t binfirst = 0; //where do we start numbering bins | |
13 | Int_t binlast = 8; //where do we stop numbering bins | |
14 | const Int_t numberOfCentralityBins = 9; | |
15 | //Float_t centralityArray[numberOfCentralityBins+1] = {0.,100.}; // in centrality percentile | |
16 | Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile | |
17 | const TString centralityEstimator = "V0M"; | |
18 | Double_t vertexZ = 10.; | |
19 | Int_t AODfilterBit = 128; | |
20 | ||
21 | //output file | |
22 | TString commonOutputFileName = "AnalysisResults"; | |
23 | ||
24 | //void runEffContTaskCentralityTrain(Int_t mode = mPROOF,Int_t nRuns = 600000, Bool_t DATA = kFALSE, | |
25 | //const Char_t* dataDir="/alice/sim/LHC11a10a_000138662_AOD048", Int_t offset=0) { //PbPbAOD | |
26 | //const Char_t* dataDir="/alice/sim/LHC11a10a_000139510", Int_t offset=0) { //PbPb ESD | |
27 | void runEffContTaskCentralityTrain(Int_t mode = mLocal, Bool_t DATA = kFALSE) { | |
28 | //void runEffContTaskCentralityTrain(const char* runListFileName = "listOfRuns.txt",Int_t mode = mGrid, Bool_t DATA = kFALSE) {` | |
29 | // Time: | |
30 | TStopwatch timer; | |
31 | timer.Start(); | |
32 | ||
33 | // Load needed libraries: | |
34 | LoadLibraries(mode); | |
35 | ||
36 | // Create and configure the AliEn plug-in: | |
37 | if(mode == mGrid || mode == mGridPAR) { | |
38 | gROOT->LoadMacro("CreateAlienHandler.C"); | |
39 | AliAnalysisGrid *alienHandler = CreateAlienHandler(runListFileName); | |
40 | if (!alienHandler) return; | |
41 | gROOT->LoadMacro("AliAnalysisTaskEffContBF.cxx++"); | |
42 | } | |
43 | // Chains: | |
44 | if(mode==mLocal || mode == mLocalPAR) { | |
45 | gROOT->LoadMacro("AliAnalysisTaskEffContBF.cxx++"); | |
46 | //TChain* chain = new TChain("esdTree"); | |
47 | //chain->Add("/project/alice/users/alisrm/AcceptanceFilter/MonteCarlo/Set1/AliESDs.root"); | |
48 | TChain* chain = new TChain("aodTree"); | |
49 | for (Int_t i=0;i<99; i++){ | |
50 | filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; | |
51 | filename += i; | |
52 | filename += "/AliAOD.root"; | |
53 | chain->Add(filename.Data()); | |
54 | } | |
55 | //chain->Add("/project/alice/users/alisrm/Efficiency_Contamination/AOD_LHC11a10a/AliAOD.root"); //si da | |
56 | //chain->Add("/project/alice/users/alisrm/Efficiency_Contamination/AOD_LHC10d2/AliAOD.root"); | |
57 | //chain->Add("/project/alice/users/pchrist/Data/2011/Set3/AliAOD.root"); //data | |
58 | } | |
59 | //Proof | |
60 | if(mode == mPROOF) { | |
61 | gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT"))); | |
62 | gProof->Load("AliAnalysisTaskEffContBF.cxx++"); | |
63 | } | |
64 | ||
65 | // Create analysis manager: | |
66 | AliAnalysisManager *mgr = new AliAnalysisManager("FluctuationsAnalysisManager"); | |
67 | // Connect plug-in to the analysis manager: | |
68 | if(mode == mGrid || mode == mGridPAR) { | |
69 | mgr->SetGridHandler(alienHandler); | |
70 | } | |
71 | ||
72 | AliVEventHandler* aodH = new AliAODInputHandler; //NUEVO | |
73 | mgr->SetInputEventHandler(aodH); //NUEVO | |
74 | ||
75 | //AliMCEventHandler *mc = new AliMCEventHandler(); | |
76 | //mc->SetReadTR(kFALSE); | |
77 | //mgr->SetMCtruthEventHandler(mc); | |
78 | ||
79 | // Task to check the offline trigger: | |
80 | //if(mode == mLocal || mode == mGrid || mode == mGridPAR) | |
63b6cbd0 | 81 | //gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C"); |
1cb2a06e | 82 | //AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection(!DATA); |
83 | //physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC(); | |
84 | // Enable debug printouts: | |
85 | //mgr->SetDebugLevel(2); | |
86 | ||
87 | //Add the centrality determination task | |
1c06a186 | 88 | /*gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C"); |
1cb2a06e | 89 | AliCentralitySelectionTask *centralityTask = AddTaskCentrality(); |
90 | centralityTask->SetMCInput();*/ //antes for ESD | |
91 | ||
92 | //centralityTask->SetPass(2); | |
93 | //AliCentralitySelectionTask *taskCentrality = AddTaskCentrality(); | |
94 | //taskCentrality->SelectCollisionCandidates(AliVEvent::kMB); | |
95 | ||
96 | // Load the analysis task: | |
97 | gROOT->LoadMacro("AddTaskBalanceEffCont.C"); | |
98 | //gROOT->LoadMacro("AddEfficiencyTaskCentralityTrain.C"); | |
99 | ||
100 | //for (Int_t i=binfirst; i<binlast+1; i++) { | |
101 | for (Int_t i = 0; i < numberOfCentralityBins; i++) { | |
102 | Float_t lowCentralityBinEdge = centralityArray[i]; | |
103 | Float_t highCentralityBinEdge = centralityArray[i+1]; | |
104 | Printf("\nWagon for centrality bin %i: %.0f-%.0f",i,lowCentralityBinEdge,highCentralityBinEdge); | |
105 | // AddEfficiencyTaskCentralityTrain(analysisMode.Data(),lowCentralityBinEdge, highCentralityBinEdge,commonOutputFileName); | |
106 | // AddTaskBalanceEfficiency(kUseHybrid,centralityEstimator, lowCentralityBinEdge, highCentralityBinEdge, vertexZ, AODfilterBit, commonOutputFileName); | |
107 | AddTaskBalanceEffCont(centralityEstimator, lowCentralityBinEdge, highCentralityBinEdge, vertexZ, AODfilterBit, commonOutputFileName); | |
108 | } // end of for (Int_t i=0; i<numberOfCentralityBins; i++) | |
109 | ||
110 | // Run the analysis: | |
111 | if(!mgr->InitAnalysis()){return;} | |
112 | mgr->PrintStatus(); | |
113 | if(mode == mLocal || mode == mLocalPAR) | |
114 | mgr->StartAnalysis("local",chain); | |
115 | else if(mode == mPROOF) | |
116 | mgr->StartAnalysis("proof",dataDir,nRuns,offset); | |
117 | else if(mode == mGrid || mode == mGridPAR) | |
118 | mgr->StartAnalysis("grid"); | |
119 | ||
120 | // Print real and CPU time used for analysis: | |
121 | timer.Stop(); | |
122 | timer.Print(); | |
123 | ||
124 | } // end of void runTaskFluctuations(...) | |
125 | ||
126 | //=============================================================// | |
127 | void LoadLibraries(const anaModes mode) { | |
128 | //-------------------------------------- | |
129 | // Load the needed libraries most of them already loaded by aliroot | |
130 | //-------------------------------------- | |
131 | gSystem->Load("libTree"); | |
132 | gSystem->Load("libGeom"); | |
133 | gSystem->Load("libVMC"); | |
134 | gSystem->Load("libXMLIO"); | |
135 | gSystem->Load("libPhysics"); | |
136 | ||
137 | //---------------------------------------------------------- | |
138 | // >>>>>>>>>>> Local mode <<<<<<<<<<<<<< | |
139 | //---------------------------------------------------------- | |
140 | if (mode==mLocal || mode==mGrid || mode == mGridPAR) { | |
141 | //-------------------------------------------------------- | |
142 | // If you want to use already compiled libraries | |
143 | // in the aliroot distribution | |
144 | //-------------------------------------------------------- | |
145 | gSystem->Load("libSTEERBase"); | |
146 | gSystem->Load("libESD"); | |
147 | gSystem->Load("libAOD"); | |
148 | gSystem->Load("libANALYSIS"); | |
149 | gSystem->Load("libANALYSISalice"); | |
150 | gSystem->Load("libCORRFW"); | |
151 | gSystem->Load("libPWGTools"); | |
152 | ||
153 | // Use AliRoot includes to compile our task | |
154 | gROOT->ProcessLine(".include $ALICE_ROOT/include"); | |
155 | } | |
156 | ||
157 | else if (mode == mLocalPAR) { | |
158 | //-------------------------------------------------------- | |
159 | //If you want to use root and par files from aliroot | |
160 | //-------------------------------------------------------- | |
161 | SetupPar("STEERBase"); | |
162 | SetupPar("ESD"); | |
163 | SetupPar("AOD"); | |
164 | SetupPar("ANALYSIS"); | |
165 | SetupPar("ANALYSISalice"); | |
166 | } | |
167 | ||
168 | //--------------------------------------------------------- | |
169 | // <<<<<<<<<< PROOF mode >>>>>>>>>>>> | |
170 | //--------------------------------------------------------- | |
171 | else if (mode==mPROOF) { | |
172 | // Connect to proof | |
173 | printf("*** Connect to PROOF ***\n"); | |
174 | gEnv->SetValue("XSec.GSI.DelegProxy","2"); | |
175 | // Put appropriate username here | |
176 | TProof::Open("alice-caf.cern.ch"); | |
177 | //TProof::Open("skaf.saske.sk"); | |
178 | //TProof::Open("prf000-iep-grid.saske.sk"); | |
179 | ||
180 | // gProof->EnablePackage("VO_ALICE@AliRoot::v5-04-06-AN"); | |
181 | gProof->EnablePackage("VO_ALICE@AliRoot::v5-04-44-AN"); | |
182 | ||
183 | TString extraLibs = ""; | |
184 | extraLibs += "CORRFW:PWGTools"; | |
185 | ||
186 | TList *list = new TList(); | |
187 | list->Add(new TNamed("ALIROOT_EXTRA_LIBS",extraLibs.Data())); | |
188 | ||
189 | //gProof->EnablePackage("VO_ALICE@AliRoot::v5-04-06-AN",list); | |
190 | gProof->EnablePackage("VO_ALICE@AliRoot::v5-04-44-AN"); | |
191 | } | |
192 | ||
193 | } // end of void LoadLibraries(const anaModes mode) | |
194 | ||
195 | //=============================================================================================== | |
196 | void SetupPar(char* pararchivename) { | |
197 | //Load par files, create analysis libraries | |
198 | //For testing, if par file already decompressed and modified | |
199 | //classes then do not decompress. | |
200 | ||
201 | TString cdir(Form("%s", gSystem->WorkingDirectory() )) ; | |
202 | TString parpar(Form("%s.par", pararchivename)) ; | |
203 | if ( gSystem->AccessPathName(parpar.Data()) ) { | |
204 | gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ; | |
205 | TString processline(Form(".! make %s", parpar.Data())) ; | |
206 | gROOT->ProcessLine(processline.Data()) ; | |
207 | gSystem->ChangeDirectory(cdir) ; | |
208 | processline = Form(".! mv /tmp/%s .", parpar.Data()) ; | |
209 | gROOT->ProcessLine(processline.Data()) ; | |
210 | } | |
211 | if ( gSystem->AccessPathName(pararchivename) ) { | |
212 | TString processline = Form(".! tar xvzf %s",parpar.Data()) ; | |
213 | gROOT->ProcessLine(processline.Data()); | |
214 | } | |
215 | ||
216 | TString ocwd = gSystem->WorkingDirectory(); | |
217 | gSystem->ChangeDirectory(pararchivename); | |
218 | ||
219 | // check for BUILD.sh and execute | |
220 | if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { | |
221 | printf("*******************************\n"); | |
222 | printf("*** Building PAR archive ***\n"); | |
223 | cout<<pararchivename<<endl; | |
224 | printf("*******************************\n"); | |
225 | if (gSystem->Exec("PROOF-INF/BUILD.sh")) { | |
226 | Error("runProcess","Cannot Build the PAR Archive! - Abort!"); | |
227 | return -1; | |
228 | } | |
229 | } | |
230 | // check for SETUP.C and execute | |
231 | if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { | |
232 | printf("*******************************\n"); | |
233 | printf("*** Setup PAR archive ***\n"); | |
234 | cout<<pararchivename<<endl; | |
235 | printf("*******************************\n"); | |
236 | gROOT->Macro("PROOF-INF/SETUP.C"); | |
237 | } | |
238 | ||
239 | gSystem->ChangeDirectory(ocwd.Data()); | |
240 | printf("Current dir: %s\n", ocwd.Data()); | |
241 | ||
242 | } // end of void SetupPar(char* pararchivename) | |
243 | ||
244 | //=============================================================================================== | |
245 | ||
246 | // Helper macros for creating chains | |
247 | // from: CreateESDChain.C,v 1.10 jgrosseo Exp | |
248 | ||
249 | TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset) | |
250 | { | |
251 | // creates chain of files in a given directory or file containing a list. | |
252 | // In case of directory the structure is expected as: | |
253 | // <aDataDir>/<dir0>/AliESDs.root | |
254 | // <aDataDir>/<dir1>/AliESDs.root | |
255 | // ... | |
256 | ||
257 | if (!aDataDir) | |
258 | return 0; | |
259 | ||
260 | Long_t id, size, flags, modtime; | |
261 | if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime)) | |
262 | { | |
263 | printf("%s not found.\n", aDataDir); | |
264 | return 0; | |
265 | } | |
266 | ||
267 | TChain* chain = new TChain("esdTree"); | |
268 | TChain* chaingAlice = 0; | |
269 | ||
270 | if (flags & 2) | |
271 | { | |
272 | TString execDir(gSystem->pwd()); | |
273 | TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir); | |
274 | TList* dirList = baseDir->GetListOfFiles(); | |
275 | Int_t nDirs = dirList->GetEntries(); | |
276 | gSystem->cd(execDir); | |
277 | ||
278 | Int_t count = 0; | |
279 | ||
280 | for (Int_t iDir=0; iDir<nDirs; ++iDir) | |
281 | { | |
282 | TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir); | |
283 | if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0) | |
284 | continue; | |
285 | ||
286 | if (offset > 0) | |
287 | { | |
288 | --offset; | |
289 | continue; | |
290 | } | |
291 | ||
292 | if (count++ == aRuns) | |
293 | break; | |
294 | ||
295 | TString presentDirName(aDataDir); | |
296 | presentDirName += "/"; | |
297 | presentDirName += presentDir->GetName(); | |
298 | chain->Add(presentDirName + "/AliESDs.root/esdTree"); | |
299 | // cerr<<presentDirName<<endl; | |
300 | } | |
301 | ||
302 | } | |
303 | else | |
304 | { | |
305 | // Open the input stream | |
306 | ifstream in; | |
307 | in.open(aDataDir); | |
308 | ||
309 | Int_t count = 0; | |
310 | ||
311 | // Read the input list of files and add them to the chain | |
312 | TString esdfile; | |
313 | while(in.good()) { | |
314 | in >> esdfile; | |
315 | if (!esdfile.Contains("root")) continue; // protection | |
316 | ||
317 | if (offset > 0) | |
318 | { | |
319 | --offset; | |
320 | continue; | |
321 | } | |
322 | ||
323 | if (count++ == aRuns) | |
324 | break; | |
325 | ||
326 | // add esd file | |
327 | chain->Add(esdfile); | |
328 | } | |
329 | ||
330 | in.close(); | |
331 | } | |
332 | ||
333 | return chain; | |
334 | ||
335 | } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset) | |
336 | ||
337 | //=============================================================================================== | |
338 | ||
339 | TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset) | |
340 | { | |
341 | // creates chain of files in a given directory or file containing a list. | |
342 | // In case of directory the structure is expected as: | |
343 | // <aDataDir>/<dir0>/AliAOD.root | |
344 | // <aDataDir>/<dir1>/AliAOD.root | |
345 | // ... | |
346 | ||
347 | if (!aDataDir) | |
348 | return 0; | |
349 | ||
350 | Long_t id, size, flags, modtime; | |
351 | if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime)) | |
352 | { | |
353 | printf("%s not found.\n", aDataDir); | |
354 | return 0; | |
355 | } | |
356 | ||
357 | TChain* chain = new TChain("aodTree"); | |
358 | TChain* chaingAlice = 0; | |
359 | ||
360 | if (flags & 2) | |
361 | { | |
362 | TString execDir(gSystem->pwd()); | |
363 | TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir); | |
364 | TList* dirList = baseDir->GetListOfFiles(); | |
365 | Int_t nDirs = dirList->GetEntries(); | |
366 | gSystem->cd(execDir); | |
367 | ||
368 | Int_t count = 0; | |
369 | ||
370 | for (Int_t iDir=0; iDir<nDirs; ++iDir) | |
371 | { | |
372 | TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir); | |
373 | if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0) | |
374 | continue; | |
375 | ||
376 | if (offset > 0) | |
377 | { | |
378 | --offset; | |
379 | continue; | |
380 | } | |
381 | ||
382 | if (count++ == aRuns) | |
383 | break; | |
384 | ||
385 | TString presentDirName(aDataDir); | |
386 | presentDirName += "/"; | |
387 | presentDirName += presentDir->GetName(); | |
388 | chain->Add(presentDirName + "/AliAOD.root/aodTree"); | |
389 | // cerr<<presentDirName<<endl; | |
390 | } | |
391 | ||
392 | } | |
393 | else | |
394 | { | |
395 | // Open the input stream | |
396 | ifstream in; | |
397 | in.open(aDataDir); | |
398 | ||
399 | Int_t count = 0; | |
400 | ||
401 | // Read the input list of files and add them to the chain | |
402 | TString aodfile; | |
403 | while(in.good()) { | |
404 | in >> aodfile; | |
405 | if (!aodfile.Contains("root")) continue; // protection | |
406 | ||
407 | if (offset > 0) | |
408 | { | |
409 | --offset; | |
410 | continue; | |
411 | } | |
412 | ||
413 | if (count++ == aRuns) | |
414 | break; | |
415 | ||
416 | // add aod file | |
417 | chain->Add(aodfile); | |
418 | } | |
419 | ||
420 | in.close(); | |
421 | } | |
422 | ||
423 | return chain; | |
424 | ||
425 | } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset) | |
426 |