2 //--------------------------------------------------
3 // Example macro to do analysis with the
4 // analysis classes in CaloTrackCorrelations
5 // Can be executed with Root and AliRoot
7 // Pay attention to the options and definitions
8 // set in the lines below
10 // Author : Gustavo Conesa Balbastre (INFN-LNF)
12 //-------------------------------------------------
13 enum anaModes {mLocal=0, mPROOF=1, mPlugin=2, mGRID=3};
14 //mLocal = 0: Analyze locally files in your computer
15 //mPROOF = 1: Analyze files on GRID with Plugin
16 //mPlugin = 2: Analyze files on GRID with Plugin
17 //mGRID = 3: Analyze files on GRID, jobs launched from aliensh
19 //---------------------------------------------------------------------------
20 // Settings to read locally several files, only for "mLocal" mode
21 // The different values are default, they can be set with environmental
22 // variables: INDIR, PATTERN, NFILES, respectivelly
24 char * kInDir = "/user/data/files/";
25 char * kPattern = ""; // Data are in files kInDir/kPattern+i
28 //---------------------------------------------------------------------------
29 // Dataset for proof analysis, mode=mPROOF
30 // char * kDataset = "/alice/vernet/PbPb_LHC10h_ESD";
32 char * kDatasetPROOF = "/alice/vernet/LHC11b_149646";
33 Int_t kDatasetNMaxFiles = 20;
34 TString ccin2p3UserName = "arbor" ;
35 TString alienUserName = "narbor" ;
37 //---------------------------------------------------------------------------
38 // Collection file for grid analysis
40 char * kXML = "collection.xml";
42 //---------------------------------------------------------------------------
43 //Scale histograms from file. Change to kTRUE when xsection file exists
44 //Put name of file containing xsection
45 //Put number of events per ESD file
46 //This is an specific case for normalization of Pythia files.
47 const char * kXSFileName = "pyxsec.root";
49 // container of xs if xs in file pyxsec_hist.root
53 //---------------------------------------------------------------------------
55 //Set some default values, but used values are set in the code!
57 Bool_t kMC = kFALSE; //With real data kMC = kFALSE
58 TString kInputData = "ESD"; //ESD, AOD, MC, deltaAOD
60 TString kCollision = "pp";
61 Bool_t outAOD = kFALSE; //Some tasks doesnt need it.
67 //________________________
68 void ana(Int_t mode=mGRID)
72 //--------------------------------------------------------------------
73 // Load analysis libraries
74 // Look at the method below,
75 // change whatever you need for your analysis case
76 // ------------------------------------------------------------------
79 //gSystem->ListLibraries();
81 //-------------------------------------------------------------------------------------------------
82 //Create chain from ESD and from cross sections files, look below for options.
83 //-------------------------------------------------------------------------------------------------
85 // Set kInputData and kTreeName looking to the kINDIR
89 // Check global analysis settings
91 CheckEnvironmentVariables();
93 printf("*********************************************\n");
94 printf("*** Input data < %s >, pass %s, tree < %s >, MC? < %d > ***\n",kInputData.Data(),kPass.Data(),kTreeName.Data(),kMC);
95 printf("*********************************************\n");
97 TChain * chain = new TChain(kTreeName) ;
98 TChain * chainxs = new TChain("Xsection") ;
99 CreateChain(mode, chain, chainxs);
102 printf("===== kMC %d, chainxs %p\n",kMC,chainxs);
106 //Get the cross section
107 Double_t xsection = 0;
111 Bool_t ok = GetAverageXsection(chainxs, xsection, ntrials, nfiles);
113 printf("n xs files %d",nfiles);
117 Int_t nEventsPerFile = chain->GetEntries() / nfiles;
119 Double_t trials = ntrials / nEventsPerFile ;
121 scale = xsection / trials;
123 printf("Get Cross section : nfiles %d, nevents %d, nevents per file %d \n",nfiles, chain->GetEntries(),nEventsPerFile);
124 printf(" ntrials %d, trials %2.2f, xs %2.2e, scale factor %2.2e\n", ntrials,trials,xsection,scale);
126 if(chainxs->GetEntries()!=chain->GetEntries()) printf("CAREFUL: Number of files in data chain %d, in cross section chain %d \n",
127 chainxs->GetEntries(),chain->GetEntries());
130 // comment out this line in case the simulation did not have the cross section files produced in the directory
131 if( scale <= 0 || !ok)
132 { printf( "STOP, cross section not available! nfiles %d \n", chainxs->GetEntries() ) ; return ; }
137 printf("*********************************************\n");
138 printf("number of entries # %lld, skipped %d\n", chain->GetEntries()) ;
139 printf("*********************************************\n");
143 printf("STOP, no chain available\n");
147 AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
149 //------------------------------------------
150 // Alien handler part
151 //------------------------------------------
152 AliAnalysisGrid *alienHandler=0x0;
155 // Create and configure the alien handler plugin
156 gROOT->LoadMacro("CreateAlienHandler.C");
157 alienHandler = CreateAlienHandler();
158 if (!alienHandler) return;
161 //--------------------------------------
162 // Make the analysis manager
163 //-------------------------------------
164 AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
165 //AliAnalysisManager::SetUseProgressBar(kTRUE);
166 //mgr->SetSkipTerminate(kTRUE);
167 //mgr->SetNSysInfo(1);
171 // Connect plugin to the analysis manager
172 mgr->SetGridHandler(alienHandler);
176 if((kMC || kInputData == "MC") && !kInputData.Contains("AOD"))
178 AliMCEventHandler* mcHandler = new AliMCEventHandler();
179 mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
180 mgr->SetMCtruthEventHandler(mcHandler);
181 if( kInputData == "MC")
183 cout<<"MC INPUT EVENT HANDLER"<<endl;
184 mgr->SetInputEventHandler(NULL);
189 // AOD output handler
190 if(kInputData!="deltaAOD" && outAOD)
192 cout<<"Init output handler"<<endl;
193 AliAODHandler* aodoutHandler = new AliAODHandler();
194 aodoutHandler->SetOutputFileName("aod.root");
195 ////aodoutHandler->SetCreateNonStandardAOD();
196 mgr->SetOutputEventHandler(aodoutHandler);
201 if(kInputData == "ESD")
204 AliESDInputHandler *esdHandler = new AliESDInputHandler();
205 esdHandler->SetReadFriends(kFALSE);
206 mgr->SetInputEventHandler(esdHandler);
207 cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
209 else if(kInputData.Contains("AOD"))
212 AliAODInputHandler *aodHandler = new AliAODInputHandler();
213 mgr->SetInputEventHandler(aodHandler);
214 if(kInputData == "deltaAOD") aodHandler->AddFriend("deltaAODCaloTrackCorr.root");
215 cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
218 //mgr->RegisterExternalFile("deltaAODCaloTrackCorr.root");
219 //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
221 TString outputFile = AliAnalysisManager::GetCommonFileName();
223 //-------------------------------------------------------------------------
224 // Define task, put here any other task that you want to use.
225 //-------------------------------------------------------------------------
228 if(kInputData=="ESD" && !kMC)
230 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
231 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC);
235 if(kCollision=="PbPb" && kInputData=="ESD")
237 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
238 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
241 if(kCollision=="PbPb")
243 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C");
244 AliVZEROEPSelectionTask * EPV0 = AddTaskVZEROEPSelection();
246 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
247 AliEPSelectionTask * EP = AddTaskEventplane();
250 // Simple event counting tasks
252 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros/AddTaskCounter.C");
254 AliAnalysisTask* count = AddTaskCounter("",kMC); // All, fill histo with cross section and trials if kMC is true
255 AliAnalysisTask* countmb = AddTaskCounter("MB"); // Min Bias
256 AliAnalysisTask* countany = AddTaskCounter("Any");
257 AliAnalysisTask* countint = AddTaskCounter("AnyINT");// Min Bias
261 AliAnalysisTaskCounter* countemg = AddTaskCounter("EMCEGA");
262 AliAnalysisTaskCounter* countemj = AddTaskCounter("EMCEJE");
263 if(kCollision=="PbPb")
265 AliAnalysisTaskCounter* countcen = AddTaskCounter("Central");
266 AliAnalysisTaskCounter* countsce = AddTaskCounter("SemiCentral");
267 AliAnalysisTaskCounter* countssce= AddTaskCounter("SemiOrCentral");
268 AliAnalysisTaskCounter* countphP = AddTaskCounter("PHOSPb");
272 AliAnalysisTaskCounter* countem1 = AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
273 AliAnalysisTaskCounter* countem7 = AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
274 AliAnalysisTaskCounter* countphp = AddTaskCounter("PHOS");
281 if(kInputData=="ESD"){
282 printf("* Configure photon conversion analysis in macro \n");
283 TString arguments = "-run-on-train -use-own-xyz -force-aod -mc-off ";
284 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
285 AliAnalysisTaskGammaConversion * taskGammaConversion =
286 ConfigGammaConversion(arguments,mgr->GetCommonInputContainer());
287 taskGammaConversion->SelectCollisionCandidates();
289 // Gamma Conversion AOD to AODPWG4Particle
290 AliAnalysisTaskGCPartToPWG4Part * taskGCToPC = new AliAnalysisTaskGCPartToPWG4Part("GCPartToPWG4Part");
291 taskGCToPC->SetGammaCutId("90035620401003321022000000090");
292 mgr->AddTask(taskGCToPC);
293 mgr->ConnectInput (taskGCToPC, 0, mgr->GetCommonInputContainer() );
294 mgr->ConnectOutput (taskGCToPC, 0, mgr->GetCommonOutputContainer());
298 Bool_t kPrint = kFALSE;
299 Bool_t deltaAOD = kFALSE;
300 gROOT->LoadMacro("AddTaskCaloTrackCorr.C"); // $ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros
301 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALClusterize.C"); // $ALICE_ROOT/PWGGA/EMCALTasks/macros
303 //gROOT->LoadMacro("$ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
304 //AliAnalysisTaskCaloTrackCorrelation * qatask = AddTaskCalorimeterQA(kInputData,kYear,kPrint,kMC);
306 //gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALTriggerQA.C");
307 //AliAnalysisTaskEMCALTriggerQA * qatrigtask = AddTaskEMCALTriggerQA();
309 // Calibration, bad map ...
311 Bool_t calibEE = kTRUE; // It is set automatically, but here we force to use it or not in any case
312 Bool_t calibTT = kTRUE; // It is set automatically, but here we force to use it or not in any case
313 if(kRun < 122195 || (kRun > 126437 && kRun < 136851) || kMC) calibTT=kFALSE ; // Recalibration parameters not available for LHC10a,b,c,e,f,g
314 Bool_t badMap = kTRUE; // It is set automatically, but here we force to use it or not in any case
318 printf("==================================== \n");
319 printf("CONFIGURE ANALYSIS FOR PP COLLISIONS \n");
320 printf("==================================== \n");
322 Bool_t mixing = kTRUE; // mixing in reader and hadron correlation, and pi0
324 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
325 Bool_t anTM = kTRUE; // Remove matched
326 Bool_t exo = kTRUE; // Remove exotic cells
327 Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
328 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
329 Int_t minEcell = 50; // 50 MeV (10 MeV used in reconstruction)
330 Int_t minEseed = 100; // 100 MeV
331 Int_t dTime = 0; // default, 250 ns
332 Int_t wTime = 30; // default 425 < T < 825 ns, careful if time calibration is on
333 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
334 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
337 TString clTrigger = "";
338 TString anTrigger = "EMC7";
348 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
349 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
350 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
352 //Analysis with clusterizer V1
354 TString arrayNameV1 = "";
356 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
357 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
358 calibEE,badMap,calibTT,clnonlin);
360 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
365 AliAnalysisTaskCaloTrackCorrelation *anav1trig = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
366 kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
367 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
370 AliAnalysisTaskCaloTrackCorrelation *anav1mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
371 kYear,kCollision,"AnyINT",arrayNameV1,mixing,reTM,anTM,
372 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
376 //Analysis with clusterizer V2
377 TString arrayNameV2 = "";
378 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
379 minEcell,minEseed,dTime,wTime,
380 calibEE,badMap,calibTT,clnonlin);
382 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
389 AliAnalysisTaskCaloTrackCorrelation *anav2tr = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
390 kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
391 -1,-1,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
395 AliAnalysisTaskCaloTrackCorrelation *anav2mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
396 kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
397 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
400 if(kCollision=="PbPb")
402 printf("====================================== \n");
403 printf("CONFIGURE ANALYSIS FOR PbPb COLLISIONS \n");
404 printf("====================================== \n");
405 Bool_t mixing = kTRUE;
407 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
408 Bool_t anTM = kTRUE; // Remove matched
409 Bool_t exo = kTRUE; // Remove exotic cells
410 Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
411 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
412 Int_t minEcell = 150; // 50 MeV (10 MeV used in reconstruction)
413 Int_t minEseed = 300; // 100 MeV
414 Int_t dTime = 0; // default, 250 ns
415 Int_t wTime = 0; // default 425 < T < 825 ns
416 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
417 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
420 TString clTrigger = "";
421 TString anTrigger = "EMCGA";
430 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
431 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
432 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
434 //Analysis with clusterizer V1
436 TString arrayNameV1 = "";
437 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
438 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
439 calibEE,badMap,calibTT,clnonlin);
441 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
445 AliAnalysisTaskCaloTrackCorrelation *anav1c = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
446 kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
447 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
448 AliAnalysisTaskCaloTrackCorrelation *anav1m = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
449 kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
450 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
451 AliAnalysisTaskCaloTrackCorrelation *anav1p = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
452 kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
453 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
456 //Analysis with clusterizer V2
458 TString arrayNameV2 = "";
459 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
460 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
461 calibEE,badMap,calibTT,clnonlin);
463 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
470 AliAnalysisTaskCaloTrackCorrelation *anav2cT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
471 kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
472 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
473 AliAnalysisTaskCaloTrackCorrelation *anav2mT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
474 kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
475 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
476 AliAnalysisTaskCaloTrackCorrelation *anav2pT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
477 kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
478 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
481 AliAnalysisTaskCaloTrackCorrelation *anav2cMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
482 kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
483 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
484 AliAnalysisTaskCaloTrackCorrelation *anav2mMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
485 kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
486 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
487 AliAnalysisTaskCaloTrackCorrelation *anav2pMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
488 kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
489 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
496 //-----------------------
498 //-----------------------
502 if (mode == mPlugin) mgr->StartAnalysis("grid");
503 else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
504 else mgr->StartAnalysis("local",chain);
506 cout <<" Analysis ended sucessfully "<< endl ;
510 //_____________________________
511 void LoadLibraries(Int_t mode)
514 if (mode == mPROOF) {
515 //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
516 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
517 TProof* proof = EnableAliRootForLAF("ccaplmaster",nPROOFWorkers.Data(),ccin2p3UserName.Data(),alienUserName.Data(),"",kFALSE,kTRUE,kTRUE,"OADB:ANALYSIS:ANALYSISalice:AOD:ESD:CORRFW:STEERBase:EMCALUtils:PHOSUtils:PWGCaloTrackCorrBase:PWGGACaloTrackCorrelations:PWGEMCAL:PWGGAEMCALTasks");
519 // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
521 // //proof->ClearPackages();
522 // proof->UploadPackage("STEERBase");
523 // proof->UploadPackage("ESD");
524 // proof->UploadPackage("AOD");
525 // proof->UploadPackage("ANALYSIS");
526 // proof->UploadPackage("OADB");
527 // proof->UploadPackage("ANALYSISalice");
528 // proof->UploadPackage("CORRFW");
529 // //proof->UploadPackage("JETAN");
530 // proof->UploadPackage("PHOSUtils");
531 // proof->UploadPackage("EMCALUtils");
532 // proof->UploadPackage("PWGCaloTrackCorrBase");
533 // proof->UploadPackage("PWGGACaloTrackCorrelations");
534 // proof->UploadPackage("PWGEMCAL");
535 // proof->UploadPackage("PWGGAEMCALTasks");
537 // proof->EnablePackage("STEERBase");
538 // proof->EnablePackage("ESD");
539 // proof->EnablePackage("AOD");
540 // proof->EnablePackage("ANALYSIS");
541 // proof->EnablePackage("OADB");
542 // proof->EnablePackage("ANALYSISalice");
543 // proof->EnablePackage("CORRFW");
544 // //proof->EnablePackage("JETAN");
545 // proof->EnablePackage("PHOSUtils");
546 // proof->EnablePackage("EMCALUtils");
547 // proof->EnablePackage("PWGCaloTrackCorrBase");
548 // proof->EnablePackage("PWGGACaloTrackCorrelations");
549 // proof->EnablePackage("PWGEMCAL");
550 // proof->EnablePackage("PWGGAEMCALTasks");
554 //--------------------------------------
555 // Load the needed libraries most of them already loaded by aliroot
556 //--------------------------------------
557 gSystem->Load("libTree");
558 gSystem->Load("libGeom");
559 gSystem->Load("libVMC");
560 gSystem->Load("libXMLIO");
561 gSystem->Load("libMatrix");
562 gSystem->Load("libPhysics");
563 gSystem->Load("libMinuit"); // Root + libraries to if reclusterization is done
565 gSystem->Load("libSTEERBase");
566 gSystem->Load("libGui"); // Root + libraries to if reclusterization is done
567 gSystem->Load("libCDB"); // Root + libraries to if reclusterization is done
568 gSystem->Load("libESD"); // Root + libraries to if reclusterization is done
569 gSystem->Load("libAOD");
570 gSystem->Load("libRAWDatabase"); // Root + libraries to if reclusterization is done
571 gSystem->Load("libProof");
572 gSystem->Load("libOADB");
573 gSystem->Load("libANALYSIS");
574 gSystem->Load("libSTEER"); // Root + libraries to if reclusterization is done
576 gSystem->Load("libRAWDatarec"); // Root + libraries to if reclusterization is done
577 gSystem->Load("libRAWDatasim"); // Root + libraries to if reclusterization is done
578 gSystem->Load("libVZERObase"); // Root + libraries to if reclusterization is done
579 gSystem->Load("libVZEROrec"); // Root + libraries to if reclusterization is done
581 gSystem->Load("libPHOSUtils");
583 gSystem->Load("libEMCALUtils");
584 //SetupPar("EMCALUtils");
585 gSystem->Load("libEMCALraw"); // Root + libraries to if reclusterization is done
586 gSystem->Load("libEMCALbase"); // Root + libraries to if reclusterization is done
587 gSystem->Load("libEMCALsim"); // Root + libraries to if reclusterization is done
588 gSystem->Load("libEMCALrec"); // Root + libraries to if reclusterization is done
589 //SetupPar("EMCALraw");
590 //SetupPar("EMCALbase");
591 //SetupPar("EMCALsim");
592 //SetupPar("EMCALrec");
594 gSystem->Load("libANALYSISalice");
595 gSystem->Load("libESDfilter");
597 gSystem->Load("libTender");
598 gSystem->Load("libTenderSupplies");
600 gSystem->Load("libCORRFW");
601 gSystem->Load("libPWGTools");
603 gSystem->Load("libPWGEMCAL");
604 gSystem->Load("libPWGGAEMCALTasks");
605 //SetupPar("PWGEMCAL");
606 //SetupPar("PWGGAEMCALTasks");
608 gSystem->Load("libPWGCaloTrackCorrBase");
609 gSystem->Load("libPWGGACaloTrackCorrelations");
610 //SetupPar("PWGCaloTrackCorrBase");
611 //SetupPar("PWGGACaloTrackCorrelations");
613 //gSystem->Load("libJETAN");
614 //gSystem->Load("FASTJETAN");
615 //gSystem->Load("PWGJE");
617 //gSystem->Load("libCORRFW");
618 //gSystem->Load("libPWGGAGammaConv");
619 //SetupPar("PWGGAGammaConv");
621 // needed for plugin?
622 gSystem->AddIncludePath("-I$ALICE_ROOT");
623 gSystem->AddIncludePath("-I./");
627 //_________________________________
628 void SetupPar(char* pararchivename)
630 //Load par files, create analysis libraries
631 //For testing, if par file already decompressed and modified
632 //classes then do not decompress.
634 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
635 TString parpar(Form("%s.par", pararchivename)) ;
637 if ( gSystem->AccessPathName(pararchivename) ) {
638 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
639 gROOT->ProcessLine(processline.Data());
642 TString ocwd = gSystem->WorkingDirectory();
643 gSystem->ChangeDirectory(pararchivename);
645 // check for BUILD.sh and execute
646 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
647 printf("*******************************\n");
648 printf("*** Building PAR archive ***\n");
649 cout<<pararchivename<<endl;
650 printf("*******************************\n");
652 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
653 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
657 // check for SETUP.C and execute
658 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
659 printf("*******************************\n");
660 printf("*** Setup PAR archive ***\n");
661 cout<<pararchivename<<endl;
662 printf("*******************************\n");
663 gROOT->Macro("PROOF-INF/SETUP.C");
666 gSystem->ChangeDirectory(ocwd.Data());
667 printf("Current dir: %s\n", ocwd.Data());
670 //______________________________________
671 void CheckInputData(const anaModes mode)
673 //Sets input data and tree
675 TString ocwd = gSystem->WorkingDirectory();
677 //---------------------------------------
678 //Local files analysis
679 //---------------------------------------
681 //If you want to add several ESD files sitting in a common directory INDIR
682 //Specify as environmental variables the directory (INDIR), the number of files
683 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
685 if(gSystem->Getenv("INDIR"))
686 kInDir = gSystem->Getenv("INDIR") ;
687 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
689 TString sindir(kInDir);
690 if (sindir.Contains("pass1")) kPass = "pass1";
691 else if(sindir.Contains("pass2")) kPass = "pass2";
692 else if(sindir.Contains("pass3")) kPass = "pass3";
694 if(gSystem->Getenv("PATTERN"))
695 kPattern = gSystem->Getenv("PATTERN") ;
696 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
698 cout<<"INDIR : "<<kInDir<<endl;
699 cout<<"NFILES : "<<kFile<<endl;
705 for (Int_t event = 0 ; event < kFile ; event++) {
706 sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
707 sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
708 sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
709 sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
711 TFile * fESD = TFile::Open(fileE) ;
712 TFile * fAOD = TFile::Open(fileA) ;
714 //Check if file exists and add it, if not skip it
717 kTreeName = "esdTree";
719 TFile * fG = TFile::Open(fileG);
720 if(fG) { kMC = kTRUE; fG->Close();}
724 TTree* esdTree = (TTree*)fESD->Get("esdTree");
725 AliESDEvent* esd = new AliESDEvent();
726 esd->ReadFromTree(esdTree);
727 esdTree->GetEvent(0);
728 kRun = esd->GetRunNumber();
734 kTreeName = "aodTree";
736 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
740 TTree* aodTree = (TTree*)fAOD->Get("aodTree");
741 AliAODEvent* aod = new AliAODEvent();
742 aod->ReadFromTree(aodTree);
743 aodTree->GetEvent(0);
744 kRun = aod->GetRunNumber();
747 else if(TFile::Open(fileEm))
749 kTreeName = "aodTree";
755 else if(TFile::Open(fileG))
764 if(fESD) fESD->Close();
765 if(fAOD) fAOD->Close();
767 }// local files analysis
769 //------------------------------
771 //-----------------------------
772 else if(mode == mGRID){
773 //Get colection file. It is specified by the environmental
776 if(gSystem->Getenv("XML") )
777 kXML = gSystem->Getenv("XML");
779 sprintf(kXML, "collection.xml") ;
781 if (!TFile::Open(kXML)) {
782 printf("No collection file with name -- %s -- was found\n",kXML);
785 else cout<<"XML file "<<kXML<<endl;
787 //Load necessary libraries and connect to the GRID
788 gSystem->Load("libNetx") ;
789 gSystem->Load("libRAliEn");
790 TGrid::Connect("alien://") ;
792 //Feed Grid with collection file
793 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
795 AliError(Form("%s not found", kXML)) ;
798 TGridResult* result = collection->GetGridResult("",0 ,0);
800 for (Int_t index = 0; index < result->GetEntries(); index++) {
801 TString alienURL = result->GetKey(index, "turl") ;
802 cout << "================== " << alienURL << endl ;
804 if (alienURL.Contains("pass1")) kPass = "pass1";
805 else if(alienURL.Contains("pass2")) kPass = "pass2";
806 else if(alienURL.Contains("pass3")) kPass = "pass3";
808 kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
809 printf("Run number from alien path = %d\n",kRun);
812 //Check if file exists and add it, if not skip it
813 if (alienURL.Contains("AliESDs.root"))
815 kTreeName = "esdTree";
817 alienURL.ReplaceAll("AliESDs.root","galice.root");
818 if(TFile::Open(alienURL)) kMC=kTRUE;
822 else if(alienURL.Contains("AliAOD.root"))
824 kTreeName = "aodTree";
826 fAOD = TFile::Open(alienURL);
827 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
831 else if(alienURL.Contains("embededAOD.root"))
833 kTreeName = "aodTree";
838 else if(alienURL.Contains("galice.root"))
847 //------------------------------
849 //-----------------------------
850 else if(mode == mPROOF){
852 TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
854 TIter iter(coll->GetList());
856 TFileInfo* fileInfo = 0;
857 while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
859 if (fileInfo->GetFirstUrl()) {
860 TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
861 cout << "================== " << ProofURL << endl ;
863 if (ProofURL.Contains("pass1")) kPass = "pass1";
864 else if(ProofURL.Contains("pass2")) kPass = "pass2";
865 else if(ProofURL.Contains("pass3")) kPass = "pass3";
867 kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
868 printf("Run number from alien path = %d\n",kRun);
871 //Check if file exists and add it, if not skip it
872 if (ProofURL.Contains("AliESDs.root"))
874 kTreeName = "esdTree";
876 alienURL.ReplaceAll("AliESDs.root","galice.root");
877 if(TFile::Open(ProofURL)) kMC=kTRUE;
882 else if(ProofURL.Contains("AliAOD.root"))
884 kTreeName = "aodTree";
886 fAOD = TFile::Open(ProofURL);
887 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
891 else if(ProofURL.Contains("embededAOD.root"))
893 kTreeName = "aodTree";
898 else if(ProofURL.Contains("galice.root"))
909 gSystem->ChangeDirectory(ocwd.Data());
913 //_____________________________________________________________________
914 void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
916 //Fills chain with data
917 TString ocwd = gSystem->WorkingDirectory();
919 if(kInputData == "AOD")
925 //---------------------------------------
926 // Local files analysis
927 //---------------------------------------
929 //If you want to add several ESD files sitting in a common directory INDIR
930 //Specify as environmental variables the directory (INDIR), the number of files
931 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
933 if(gSystem->Getenv("INDIR"))
934 kInDir = gSystem->Getenv("INDIR") ;
935 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
937 if(gSystem->Getenv("PATTERN"))
938 kPattern = gSystem->Getenv("PATTERN") ;
939 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
941 if(gSystem->Getenv("NFILES"))
942 kFile = atoi(gSystem->Getenv("NFILES")) ;
943 else cout<<"NFILES not set, use default: "<<kFile<<endl;
945 //Check if env variables are set and are correct
946 if ( kInDir && kFile) {
947 printf("Get %d files from directory %s\n",kFile,kInDir);
948 if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
949 printf("%s does not exist\n", kInDir) ;
953 //if(gSystem->Getenv("XSFILE"))
954 //kXSFileName = gSystem->Getenv("XSFILE") ;
955 //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
956 char * kGener = gSystem->Getenv("GENER");
958 cout<<"GENER "<<kGener<<endl;
959 if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
960 else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
961 else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
963 else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
965 if(kInputData=="AOD")
967 kXSFileName = "pyxsec_hists.root";
972 cout<<"INDIR : "<<kInDir <<endl;
973 cout<<"NFILES : "<<kFile <<endl;
974 cout<<"PATTERN : "<<kPattern <<endl;
975 cout<<"XSFILE : "<<kXSFileName<<endl;
978 if (kInputData == "ESD") datafile = "AliESDs.root" ;
979 else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
980 else if(kInputData == "MC") datafile = "galice.root" ;
982 //Loop on ESD/AOD/MC files, add them to chain
988 for (event = 0 ; event < kFile ; event++) {
989 sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
990 sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
992 //Check if file exists and add it, if not skip it
993 if ( fData = TFile::Open(file)) {
994 if ( fData->Get(kTreeName) ) {
995 printf("++++ Adding %s\n", file) ;
996 chain->AddFile(file);
998 if(kInputData != "AOD")
1000 chainxs->Add(filexs) ;
1004 TFile* fxsec = TFile::Open(filexs);
1007 TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
1015 TList *list = dynamic_cast<TList*>(key->ReadObj());
1023 Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
1024 Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
1027 xsArr->SetAt(xsection,event);
1028 trArr->SetAt(ntrials,event);
1030 printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, event);
1031 //chainxs->Add(tree);
1041 printf("---- Skipping %s\n", file) ;
1047 TString input = "AliESDs.root" ;
1048 cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
1049 chain->AddFile(input);
1052 }// local files analysis
1054 //------------------------------
1056 //------------------------------
1057 else if(mode == mGRID){
1058 //Get colection file. It is specified by the environmental
1061 //Feed Grid with collection file
1062 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
1064 AliError(Form("%s not found", kXML)) ;
1068 TGridResult* result = collection->GetGridResult("",0 ,0);
1070 // Makes the ESD chain
1071 printf("*** Getting the Chain ***\n");
1072 for (Int_t index = 0; index < result->GetEntries(); index++) {
1073 TString alienURL = result->GetKey(index, "turl") ;
1074 cout << "================== " << alienURL << endl ;
1075 chain->Add(alienURL) ;
1077 if(kInputData != "AOD")
1079 alienURL.ReplaceAll("AliESDs.root",kXSFileName);
1080 alienURL.ReplaceAll("AliAOD.root",kXSFileName);
1081 chainxs->Add(alienURL) ;
1085 alienURL.ReplaceAll("AliESDs.root","pyxsec_hists.root");
1086 alienURL.ReplaceAll("AliAOD.root", "pyxsec_hists.root");
1087 TFile* fxsec = TFile::Open(alienURL);
1090 TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
1098 TList *list = dynamic_cast<TList*>(key->ReadObj());
1106 Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
1107 Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
1110 xsArr->SetAt(xsection,event);
1111 trArr->SetAt(ntrials,event);
1113 printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, event);
1121 //------------------------------
1123 //------------------------------
1124 else if (mode == mPROOF) {
1126 TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
1128 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
1129 chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
1130 printf("chain has %d entries\n",chain->GetEntries());
1133 gSystem->ChangeDirectory(ocwd.Data());
1137 //______________________________
1138 void CheckEnvironmentVariables()
1141 sprintf(kTrigger,"");
1143 Bool_t bRecalibrate = kFALSE;
1144 Bool_t bBadChannel = kFALSE;
1146 for (int i=0; i< gApplication->Argc();i++){
1150 printf("Arg %d: %s\n",i,gApplication->Argv(i));
1156 if (!(strcmp(gApplication->Argv(i),"--trigger")))
1157 sprintf(trigger,gApplication->Argv(i+1));
1159 if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
1160 bRecalibrate = atoi(gApplication->Argv(i+1));
1162 if (!(strcmp(gApplication->Argv(i),"--badchannel")))
1163 bBadChannel = atoi(gApplication->Argv(i+1));
1165 if (!(strcmp(gApplication->Argv(i),"--run"))){
1166 sRun = gApplication->Argv(i+1);
1167 if(sRun.Contains("LHC10")) {
1172 kRun = atoi(gApplication->Argv(i+1));
1174 else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
1180 if(!sRun.Contains("LHC10")){
1184 if( kRun >= 136851 ) kCollision = "PbPb";
1186 else if( kRun < 170600)
1189 if( kRun >= 166500 ) kCollision = "PbPb";
1198 if(kMC) sprintf(kTrigger,"");
1200 printf("*********************************************\n");
1201 //printf("*** Settings trigger %s, recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
1202 // kTrigger,bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
1203 printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
1204 printf("*********************************************\n");
1208 //______________________________________________________________________________
1209 Bool_t GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr, Int_t & n)
1211 // Read the PYTHIA statistics from the file pyxsec.root created by
1212 // the function WriteXsection():
1213 // integrated cross section (xsection) and
1214 // the number of Pyevent() calls (ntrials)
1215 // and calculate the weight per one event xsection/ntrials
1216 // The spectrum calculated by a user should be
1217 // multiplied by this weight, something like this:
1218 // TH1F *userSpectrum ... // book and fill the spectrum
1219 // userSpectrum->Scale(weight)
1221 // Yuri Kharlov 19 June 2007
1222 // Gustavo Conesa 15 April 2008
1223 // Add recovery of xs from pyxsec_hists.root file 15/jan/2015
1225 Double_t xsection = 0 ;
1226 UInt_t ntrials = 0 ;
1232 if( kInputData != "AOD" && tree))
1234 nfiles = tree->GetEntries() ;
1236 tree->SetBranchAddress("xsection",&xsection);
1237 tree->SetBranchAddress("ntrials" ,&ntrials );
1238 for(Int_t i = 0; i < nfiles; i++)
1247 cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
1250 else if( kInputData == "AOD" && xsArr))
1252 nfiles = xsArr->GetSize();
1254 for(Int_t i = 0; i < nfiles; i++)
1256 if(xsArr->GetAt(i) > 0)
1258 xs += xsArr->GetAt(i) ;
1259 ntr += trArr->GetAt(i) ;
1262 cout << "xsection " <<xsArr->GetAt(i)<<" ntrials "<<trArr->GetAt(i)<<endl;
1269 cout << "-----------------------------------------------------------------"<<endl;
1270 cout << "Average of "<< n <<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
1271 cout << "-----------------------------------------------------------------"<<endl;