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 //---------------------------------------------------------------------------
51 //Set some default values, but used values are set in the code!
53 Bool_t kMC = kFALSE; //With real data kMC = kFALSE
54 TString kInputData = "ESD"; //ESD, AOD, MC, deltaAOD
56 TString kCollision = "pp";
57 Bool_t outAOD = kFALSE; //Some tasks doesnt need it.
63 //________________________
64 void ana(Int_t mode=mGRID)
68 //--------------------------------------------------------------------
69 // Load analysis libraries
70 // Look at the method below,
71 // change whatever you need for your analysis case
72 // ------------------------------------------------------------------
75 //gSystem->ListLibraries();
77 //-------------------------------------------------------------------------------------------------
78 //Create chain from ESD and from cross sections files, look below for options.
79 //-------------------------------------------------------------------------------------------------
81 // Set kInputData and kTreeName looking to the kINDIR
85 // Check global analysis settings
87 CheckEnvironmentVariables();
89 printf("*********************************************\n");
90 printf("*** Input data < %s >, pass %s, tree < %s >, MC? < %d > ***\n",kInputData.Data(),kPass.Data(),kTreeName.Data(),kMC);
91 printf("*********************************************\n");
93 TChain * chain = new TChain(kTreeName) ;
94 TChain * chainxs = new TChain("Xsection") ;
95 CreateChain(mode, chain, chainxs);
98 printf("===== kMC %d, chainxs %p\n",kMC,chainxs);
99 if(kMC && chainxs && chainxs->GetEntries() > 0)
101 Int_t nfiles = chainxs->GetEntries();
103 //Get the cross section
104 Double_t xsection = 0;
107 GetAverageXsection(chainxs, xsection, ntrials);
109 Int_t nEventsPerFile = chain->GetEntries() / nfiles;
111 Double_t trials = ntrials / nEventsPerFile ;
113 scale = xsection/trials;
115 printf("Get Cross section : nfiles %d, nevents %d, nevents per file %d \n",nfiles, chain->GetEntries(),nEventsPerFile);
116 printf(" ntrials %d, trials %2.2f, xs %2.2e, scale factor %2.2e\n", ntrials,trials,xsection,scale);
120 printf("*********************************************\n");
121 printf("number of entries # %lld, skipped %d\n", chain->GetEntries()) ;
122 printf("*********************************************\n");
126 printf("STOP, no chain available\n");
130 AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
132 //------------------------------------------
133 // Alien handler part
134 //------------------------------------------
135 AliAnalysisGrid *alienHandler=0x0;
138 // Create and configure the alien handler plugin
139 gROOT->LoadMacro("CreateAlienHandler.C");
140 alienHandler = CreateAlienHandler();
141 if (!alienHandler) return;
144 //--------------------------------------
145 // Make the analysis manager
146 //-------------------------------------
147 AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
148 //AliAnalysisManager::SetUseProgressBar(kTRUE);
149 //mgr->SetSkipTerminate(kTRUE);
150 //mgr->SetNSysInfo(1);
154 // Connect plugin to the analysis manager
155 mgr->SetGridHandler(alienHandler);
159 if((kMC || kInputData == "MC") && !kInputData.Contains("AOD"))
161 AliMCEventHandler* mcHandler = new AliMCEventHandler();
162 mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
163 mgr->SetMCtruthEventHandler(mcHandler);
164 if( kInputData == "MC")
166 cout<<"MC INPUT EVENT HANDLER"<<endl;
167 mgr->SetInputEventHandler(NULL);
172 // AOD output handler
173 if(kInputData!="deltaAOD" && outAOD)
175 cout<<"Init output handler"<<endl;
176 AliAODHandler* aodoutHandler = new AliAODHandler();
177 aodoutHandler->SetOutputFileName("aod.root");
178 ////aodoutHandler->SetCreateNonStandardAOD();
179 mgr->SetOutputEventHandler(aodoutHandler);
184 if(kInputData == "ESD")
187 AliESDInputHandler *esdHandler = new AliESDInputHandler();
188 esdHandler->SetReadFriends(kFALSE);
189 mgr->SetInputEventHandler(esdHandler);
190 cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
192 else if(kInputData.Contains("AOD"))
195 AliAODInputHandler *aodHandler = new AliAODInputHandler();
196 mgr->SetInputEventHandler(aodHandler);
197 if(kInputData == "deltaAOD") aodHandler->AddFriend("deltaAODCaloTrackCorr.root");
198 cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
201 //mgr->RegisterExternalFile("deltaAODCaloTrackCorr.root");
202 //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
204 TString outputFile = AliAnalysisManager::GetCommonFileName();
206 //-------------------------------------------------------------------------
207 // Define task, put here any other task that you want to use.
208 //-------------------------------------------------------------------------
211 if(kInputData=="ESD")
213 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
214 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC);
218 if(kCollision=="PbPb")
220 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
221 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
224 // Simple event counting tasks
225 AliAnalysisTask* count = AddTaskCounter(""); // All
226 //AliAnalysisTask* countmb = AddTaskCounter("MB"); // Min Bias
227 AliAnalysisTask* countany = AddTaskCounter("Any");
228 AliAnalysisTask* countint = AddTaskCounter("AnyINT");// Min Bias
232 AliAnalysisTask* countem1 = AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
233 AliAnalysisTask* countem7 = AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
234 AliAnalysisTask* countemg = AddTaskCounter("EMCEGA");
235 AliAnalysisTask* countemj = AddTaskCounter("EMCEJE");
236 if(kCollision=="PbPb")
238 AliAnalysisTask* countcen = AddTaskCounter("Central");
239 AliAnalysisTask* countsce = AddTaskCounter("SemiCentral");
240 AliAnalysisTask* countphP = AddTaskCounter("PHOSPb");
242 else AliAnalysisTask* countphp = AddTaskCounter("PHOS");
249 if(kInputData=="ESD"){
250 printf("* Configure photon conversion analysis in macro \n");
251 TString arguments = "-run-on-train -use-own-xyz -force-aod -mc-off ";
252 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
253 AliAnalysisTaskGammaConversion * taskGammaConversion =
254 ConfigGammaConversion(arguments,mgr->GetCommonInputContainer());
255 taskGammaConversion->SelectCollisionCandidates();
257 // Gamma Conversion AOD to AODPWG4Particle
258 AliAnalysisTaskGCPartToPWG4Part * taskGCToPC = new AliAnalysisTaskGCPartToPWG4Part("GCPartToPWG4Part");
259 taskGCToPC->SetGammaCutId("90035620401003321022000000090");
260 mgr->AddTask(taskGCToPC);
261 mgr->ConnectInput (taskGCToPC, 0, mgr->GetCommonInputContainer() );
262 mgr->ConnectOutput (taskGCToPC, 0, mgr->GetCommonOutputContainer());
266 Bool_t kPrint = kFALSE;
267 Bool_t deltaAOD = kFALSE;
268 gROOT->LoadMacro("AddTaskCaloTrackCorr.C"); // $ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros
269 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALClusterize.C"); // $ALICE_ROOT/PWGGA/EMCALTasks/macros
271 //gROOT->LoadMacro("$ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
272 //AliAnalysisTaskCaloTrackCorrelation * qatask = AddTaskCalorimeterQA(kInputData,kYear,kPrint,kMC);
274 //gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALTriggerQA.C");
275 //AliAnalysisTaskEMCALTriggerQA * qatrigtask = AddTaskEMCALTriggerQA();
277 // Calibration, bad map ...
279 Bool_t calibEE = kTRUE; // It is set automatically, but here we force to use it or not in any case
280 Bool_t calibTT = kTRUE; // It is set automatically, but here we force to use it or not in any case
281 if(kRun < 122195 || (kRun > 126437 && kRun < 136851) || kMC) calibTT=kFALSE ; // Recalibration parameters not available for LHC10a,b,c,e,f,g
282 Bool_t badMap = kTRUE; // It is set automatically, but here we force to use it or not in any case
286 printf("==================================== \n");
287 printf("CONFIGURE ANALYSIS FOR PP COLLISIONS \n");
288 printf("==================================== \n");
291 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
292 Bool_t anTM = kTRUE; // Remove matched
293 Bool_t exo = kTRUE; // Remove exotic cells
294 Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
295 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
296 Int_t minEcell = 50; // 50 MeV (10 MeV used in reconstruction)
297 Int_t minEseed = 100; // 100 MeV
298 Int_t dTime = 0; // default, 250 ns
299 Int_t wTime = 30; // default 425 < T < 825 ns, careful if time calibration is on
300 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
301 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
304 TString clTrigger = "";
305 TString anTrigger = "EMC7";
315 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
316 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
317 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
319 //Analysis with clusterizer V1
321 TString arrayNameV1 = "";
323 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
324 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
325 calibEE,badMap,calibTT,clnonlin);
327 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
332 AliAnalysisTaskCaloTrackCorrelation *anav1trig = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
333 kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
334 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale);
337 AliAnalysisTaskCaloTrackCorrelation *anav1mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
338 kYear,kCollision,"AnyINT",arrayNameV1,reTM,anTM,
339 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale);
343 //Analysis with clusterizer V2
344 TString arrayNameV2 = "";
345 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
346 minEcell,minEseed,dTime,wTime,
347 calibEE,badMap,calibTT,clnonlin);
349 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
356 AliAnalysisTaskCaloTrackCorrelation *anav2tr = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
357 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
358 -1,-1,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale);
362 AliAnalysisTaskCaloTrackCorrelation *anav2mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
363 kYear,kCollision,"AnyINT",arrayNameV2,reTM,anTM,
364 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale);
367 if(kCollision=="PbPb")
369 printf("====================================== \n");
370 printf("CONFIGURE ANALYSIS FOR PbPb COLLISIONS \n");
371 printf("====================================== \n");
374 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
375 Bool_t anTM = kTRUE; // Remove matched
376 Bool_t exo = kTRUE; // Remove exotic cells
377 Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
378 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
379 Int_t minEcell = 150; // 50 MeV (10 MeV used in reconstruction)
380 Int_t minEseed = 300; // 100 MeV
381 Int_t dTime = 0; // default, 250 ns
382 Int_t wTime = 0; // default 425 < T < 825 ns
383 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
384 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
387 TString clTrigger = "";
388 TString anTrigger = "EMCGA";
397 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
398 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
399 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
401 //Analysis with clusterizer V1
403 TString arrayNameV1 = "";
404 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
405 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
406 calibEE,badMap,calibTT,clnonlin);
408 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
412 AliAnalysisTaskCaloTrackCorrelation *anav1c = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
413 kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
414 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
415 AliAnalysisTaskCaloTrackCorrelation *anav1m = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
416 kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
417 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
418 AliAnalysisTaskCaloTrackCorrelation *anav1p = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
419 kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
420 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
423 //Analysis with clusterizer V2
425 TString arrayNameV2 = "";
426 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
427 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
428 calibEE,badMap,calibTT,clnonlin);
430 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
437 AliAnalysisTaskCaloTrackCorrelation *anav2cT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
438 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
439 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
440 AliAnalysisTaskCaloTrackCorrelation *anav2mT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
441 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
442 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
443 AliAnalysisTaskCaloTrackCorrelation *anav2pT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
444 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
445 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
448 AliAnalysisTaskCaloTrackCorrelation *anav2cMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
449 kYear,kCollision,"AnyINT",arrayNameV2,reTM,anTM,
450 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
451 AliAnalysisTaskCaloTrackCorrelation *anav2mMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
452 kYear,kCollision,"AnyINT",arrayNameV2,reTM,anTM,
453 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
454 AliAnalysisTaskCaloTrackCorrelation *anav2pMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
455 kYear,kCollision,"AnyINT",arrayNameV2,reTM,anTM,
456 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
463 //-----------------------
465 //-----------------------
469 if (mode == mPlugin) mgr->StartAnalysis("grid");
470 else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
471 else mgr->StartAnalysis("local",chain);
473 cout <<" Analysis ended sucessfully "<< endl ;
477 //_____________________________
478 void LoadLibraries(Int_t mode)
481 if (mode == mPROOF) {
482 //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
483 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
484 TProof* proof = EnableAliRootForLAF("ccaplmaster",nPROOFWorkers.Data(),ccin2p3UserName.Data(),alienUserName.Data(),"",kFALSE,kTRUE,kTRUE,"OADB:ANALYSIS:ANALYSISalice:AOD:ESD:CORRFW:STEERBase:EMCALUtils:PHOSUtils:PWGCaloTrackCorrBase:PWGGACaloTrackCorrelations:PWGGAEMCALTasks");
486 // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
488 // //proof->ClearPackages();
489 // proof->UploadPackage("STEERBase");
490 // proof->UploadPackage("ESD");
491 // proof->UploadPackage("AOD");
492 // proof->UploadPackage("ANALYSIS");
493 // proof->UploadPackage("OADB");
494 // proof->UploadPackage("ANALYSISalice");
495 // proof->UploadPackage("CORRFW");
496 // //proof->UploadPackage("JETAN");
497 // proof->UploadPackage("PHOSUtils");
498 // proof->UploadPackage("EMCALUtils");
499 // proof->UploadPackage("PWGCaloTrackCorrBase");
500 // proof->UploadPackage("PWGGACaloTrackCorrelations");
501 // proof->UploadPackage("PWGGAEMCALTasks");
503 // proof->EnablePackage("STEERBase");
504 // proof->EnablePackage("ESD");
505 // proof->EnablePackage("AOD");
506 // proof->EnablePackage("ANALYSIS");
507 // proof->EnablePackage("OADB");
508 // proof->EnablePackage("ANALYSISalice");
509 // proof->EnablePackage("CORRFW");
510 // //proof->EnablePackage("JETAN");
511 // proof->EnablePackage("PHOSUtils");
512 // proof->EnablePackage("EMCALUtils");
513 // proof->EnablePackage("PWGCaloTrackCorrBase");
514 // proof->EnablePackage("PWGGACaloTrackCorrelations");
515 // proof->EnablePackage("PWGGAEMCALTasks");
519 //--------------------------------------
520 // Load the needed libraries most of them already loaded by aliroot
521 //--------------------------------------
522 gSystem->Load("libTree.so");
523 gSystem->Load("libGeom.so");
524 gSystem->Load("libVMC.so");
525 gSystem->Load("libXMLIO.so");
526 gSystem->Load("libMatrix.so");
527 gSystem->Load("libPhysics.so");
528 gSystem->Load("libMinuit.so"); // Root + libraries to if reclusterization is done
530 gSystem->Load("libSTEERBase.so");
531 gSystem->Load("libGui.so"); // Root + libraries to if reclusterization is done
532 gSystem->Load("libCDB.so"); // Root + libraries to if reclusterization is done
533 gSystem->Load("libESD.so"); // Root + libraries to if reclusterization is done
534 gSystem->Load("libAOD.so");
535 gSystem->Load("libRAWDatabase.so"); // Root + libraries to if reclusterization is done
536 gSystem->Load("libProof.so");
537 gSystem->Load("libOADB");
538 gSystem->Load("libANALYSIS.so");
539 gSystem->Load("libSTEER.so"); // Root + libraries to if reclusterization is done
541 gSystem->Load("libRAWDatarec.so"); // Root + libraries to if reclusterization is done
542 gSystem->Load("libRAWDatasim.so"); // Root + libraries to if reclusterization is done
543 gSystem->Load("libVZERObase.so"); // Root + libraries to if reclusterization is done
544 gSystem->Load("libVZEROrec.so"); // Root + libraries to if reclusterization is done
546 gSystem->Load("libEMCALUtils");
547 //SetupPar("EMCALUtils");
548 gSystem->Load("libEMCALraw"); // Root + libraries to if reclusterization is done
549 gSystem->Load("libEMCALbase"); // Root + libraries to if reclusterization is done
550 gSystem->Load("libEMCALsim"); // Root + libraries to if reclusterization is done
551 gSystem->Load("libEMCALrec"); // Root + libraries to if reclusterization is done
552 //SetupPar("EMCALraw");
553 //SetupPar("EMCALbase");
554 //SetupPar("EMCALsim");
555 //SetupPar("EMCALrec");
557 gSystem->Load("libANALYSISalice.so");
558 //gSystem->Load("libTENDER.so");
559 //gSystem->Load("libTENDERSupplies.so");
561 gSystem->Load("libPHOSUtils");
562 gSystem->Load("libEMCALUtils");
563 gSystem->Load("libPWGCaloTrackCorrBase");
564 gSystem->Load("libPWGGACaloTrackCorrelations");
565 gSystem->Load("libPWGGAEMCALTasks");
566 //SetupPar("PWGCaloTrackCorrBase");
567 //SetupPar("PWGGACaloTrackCorrelations");
568 //SetupPar("PWGGAEMCALTasks");
571 //gSystem->Load("libJETAN");
572 //gSystem->Load("FASTJETAN");
573 //gSystem->Load("PWGJE");
575 //gSystem->Load("libCORRFW.so");
576 //gSystem->Load("libPWGGAGammaConv.so");
577 //SetupPar("PWGGAGammaConv");
579 // needed for plugin?
580 gSystem->AddIncludePath("-I$ALICE_ROOT");
581 gSystem->AddIncludePath("-I./");
585 //_________________________________
586 void SetupPar(char* pararchivename)
588 //Load par files, create analysis libraries
589 //For testing, if par file already decompressed and modified
590 //classes then do not decompress.
592 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
593 TString parpar(Form("%s.par", pararchivename)) ;
595 if ( gSystem->AccessPathName(pararchivename) ) {
596 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
597 gROOT->ProcessLine(processline.Data());
600 TString ocwd = gSystem->WorkingDirectory();
601 gSystem->ChangeDirectory(pararchivename);
603 // check for BUILD.sh and execute
604 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
605 printf("*******************************\n");
606 printf("*** Building PAR archive ***\n");
607 cout<<pararchivename<<endl;
608 printf("*******************************\n");
610 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
611 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
615 // check for SETUP.C and execute
616 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
617 printf("*******************************\n");
618 printf("*** Setup PAR archive ***\n");
619 cout<<pararchivename<<endl;
620 printf("*******************************\n");
621 gROOT->Macro("PROOF-INF/SETUP.C");
624 gSystem->ChangeDirectory(ocwd.Data());
625 printf("Current dir: %s\n", ocwd.Data());
628 //______________________________________
629 void CheckInputData(const anaModes mode)
631 //Sets input data and tree
633 TString ocwd = gSystem->WorkingDirectory();
635 //---------------------------------------
636 //Local files analysis
637 //---------------------------------------
639 //If you want to add several ESD files sitting in a common directory INDIR
640 //Specify as environmental variables the directory (INDIR), the number of files
641 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
643 if(gSystem->Getenv("INDIR"))
644 kInDir = gSystem->Getenv("INDIR") ;
645 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
647 TString sindir(kInDir);
648 if (sindir.Contains("pass1")) kPass = "pass1";
649 else if(sindir.Contains("pass2")) kPass = "pass2";
650 else if(sindir.Contains("pass3")) kPass = "pass3";
652 if(gSystem->Getenv("PATTERN"))
653 kPattern = gSystem->Getenv("PATTERN") ;
654 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
656 cout<<"INDIR : "<<kInDir<<endl;
657 cout<<"NFILES : "<<kFile<<endl;
663 for (Int_t event = 0 ; event < kFile ; event++) {
664 sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
665 sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
666 sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
667 sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
669 TFile * fESD = TFile::Open(fileE) ;
670 TFile * fAOD = TFile::Open(fileA) ;
672 //Check if file exists and add it, if not skip it
675 kTreeName = "esdTree";
677 TFile * fG = TFile::Open(fileG);
678 if(fG) { kMC = kTRUE; fG->Close();}
682 TTree* esdTree = (TTree*)fESD->Get("esdTree");
683 AliESDEvent* esd = new AliESDEvent();
684 esd->ReadFromTree(esdTree);
685 esdTree->GetEvent(0);
686 kRun = esd->GetRunNumber();
692 kTreeName = "aodTree";
694 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
698 TTree* aodTree = (TTree*)fAOD->Get("aodTree");
699 AliAODEvent* aod = new AliAODEvent();
700 aod->ReadFromTree(aodTree);
701 aodTree->GetEvent(0);
702 kRun = aod->GetRunNumber();
705 else if(TFile::Open(fileEm))
707 kTreeName = "aodTree";
713 else if(TFile::Open(fileG))
722 if(fESD) fESD->Close();
723 if(fAOD) fAOD->Close();
725 }// local files analysis
727 //------------------------------
729 //-----------------------------
730 else if(mode == mGRID){
731 //Get colection file. It is specified by the environmental
734 if(gSystem->Getenv("XML") )
735 kXML = gSystem->Getenv("XML");
737 sprintf(kXML, "collection.xml") ;
739 if (!TFile::Open(kXML)) {
740 printf("No collection file with name -- %s -- was found\n",kXML);
743 else cout<<"XML file "<<kXML<<endl;
745 //Load necessary libraries and connect to the GRID
746 gSystem->Load("libNetx.so") ;
747 gSystem->Load("libRAliEn.so");
748 TGrid::Connect("alien://") ;
750 //Feed Grid with collection file
751 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
753 AliError(Form("%s not found", kXML)) ;
756 TGridResult* result = collection->GetGridResult("",0 ,0);
758 for (Int_t index = 0; index < result->GetEntries(); index++) {
759 TString alienURL = result->GetKey(index, "turl") ;
760 cout << "================== " << alienURL << endl ;
762 if (alienURL.Contains("pass1")) kPass = "pass1";
763 else if(alienURL.Contains("pass2")) kPass = "pass2";
764 else if(alienURL.Contains("pass3")) kPass = "pass3";
766 kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
767 printf("Run number from alien path = %d\n",kRun);
770 //Check if file exists and add it, if not skip it
771 if (alienURL.Contains("AliESDs.root"))
773 kTreeName = "esdTree";
775 alienURL.ReplaceAll("AliESDs.root","galice.root");
776 if(TFile::Open(alienURL)) kMC=kTRUE;
780 else if(alienURL.Contains("AliAOD.root"))
782 kTreeName = "aodTree";
784 fAOD = TFile::Open(alienURL);
785 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
789 else if(alienURL.Contains("embededAOD.root"))
791 kTreeName = "aodTree";
796 else if(alienURL.Contains("galice.root"))
805 //------------------------------
807 //-----------------------------
808 else if(mode == mPROOF){
810 TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
812 TIter iter(coll->GetList());
814 TFileInfo* fileInfo = 0;
815 while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
817 if (fileInfo->GetFirstUrl()) {
818 TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
819 cout << "================== " << ProofURL << endl ;
821 if (ProofURL.Contains("pass1")) kPass = "pass1";
822 else if(ProofURL.Contains("pass2")) kPass = "pass2";
823 else if(ProofURL.Contains("pass3")) kPass = "pass3";
825 kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
826 printf("Run number from alien path = %d\n",kRun);
829 //Check if file exists and add it, if not skip it
830 if (ProofURL.Contains("AliESDs.root"))
832 kTreeName = "esdTree";
834 alienURL.ReplaceAll("AliESDs.root","galice.root");
835 if(TFile::Open(ProofURL)) kMC=kTRUE;
840 else if(ProofURL.Contains("AliAOD.root"))
842 kTreeName = "aodTree";
844 fAOD = TFile::Open(ProofURL);
845 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
849 else if(ProofURL.Contains("embededAOD.root"))
851 kTreeName = "aodTree";
856 else if(ProofURL.Contains("galice.root"))
867 gSystem->ChangeDirectory(ocwd.Data());
871 //_____________________________________________________________________
872 void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
874 //Fills chain with data
875 TString ocwd = gSystem->WorkingDirectory();
877 //---------------------------------------
878 // Local files analysis
879 //---------------------------------------
881 //If you want to add several ESD files sitting in a common directory INDIR
882 //Specify as environmental variables the directory (INDIR), the number of files
883 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
885 if(gSystem->Getenv("INDIR"))
886 kInDir = gSystem->Getenv("INDIR") ;
887 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
889 if(gSystem->Getenv("PATTERN"))
890 kPattern = gSystem->Getenv("PATTERN") ;
891 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
893 if(gSystem->Getenv("NFILES"))
894 kFile = atoi(gSystem->Getenv("NFILES")) ;
895 else cout<<"NFILES not set, use default: "<<kFile<<endl;
897 //Check if env variables are set and are correct
898 if ( kInDir && kFile) {
899 printf("Get %d files from directory %s\n",kFile,kInDir);
900 if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
901 printf("%s does not exist\n", kInDir) ;
905 //if(gSystem->Getenv("XSFILE"))
906 //kXSFileName = gSystem->Getenv("XSFILE") ;
907 //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
908 char * kGener = gSystem->Getenv("GENER");
910 cout<<"GENER "<<kGener<<endl;
911 if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
912 else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
913 else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
915 else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
917 cout<<"INDIR : "<<kInDir <<endl;
918 cout<<"NFILES : "<<kFile <<endl;
919 cout<<"PATTERN : "<<kPattern <<endl;
920 cout<<"XSFILE : "<<kXSFileName<<endl;
923 if (kInputData == "ESD") datafile = "AliESDs.root" ;
924 else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
925 else if(kInputData == "MC") datafile = "galice.root" ;
927 //Loop on ESD/AOD/MC files, add them to chain
933 for (event = 0 ; event < kFile ; event++) {
934 sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
935 sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
937 //Check if file exists and add it, if not skip it
938 if ( fData = TFile::Open(file)) {
939 if ( fData->Get(kTreeName) ) {
940 printf("++++ Adding %s\n", file) ;
941 chain->AddFile(file);
942 chainxs->Add(filexs) ;
946 printf("---- Skipping %s\n", file) ;
952 TString input = "AliESDs.root" ;
953 cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
954 chain->AddFile(input);
957 }// local files analysis
959 //------------------------------
961 //------------------------------
962 else if(mode == mGRID){
963 //Get colection file. It is specified by the environmental
966 //Feed Grid with collection file
967 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
969 AliError(Form("%s not found", kXML)) ;
973 TGridResult* result = collection->GetGridResult("",0 ,0);
975 // Makes the ESD chain
976 printf("*** Getting the Chain ***\n");
977 for (Int_t index = 0; index < result->GetEntries(); index++) {
978 TString alienURL = result->GetKey(index, "turl") ;
979 cout << "================== " << alienURL << endl ;
980 chain->Add(alienURL) ;
981 alienURL.ReplaceAll("AliESDs.root",kXSFileName);
982 chainxs->Add(alienURL) ;
986 //------------------------------
988 //------------------------------
989 else if (mode == mPROOF) {
991 TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
993 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
994 chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
995 printf("chain has %d entries\n",chain->GetEntries());
998 gSystem->ChangeDirectory(ocwd.Data());
1002 //______________________________
1003 void CheckEnvironmentVariables()
1006 sprintf(kTrigger,"");
1008 Bool_t bRecalibrate = kFALSE;
1009 Bool_t bBadChannel = kFALSE;
1011 for (int i=0; i< gApplication->Argc();i++){
1015 printf("Arg %d: %s\n",i,gApplication->Argv(i));
1021 if (!(strcmp(gApplication->Argv(i),"--trigger")))
1022 sprintf(trigger,gApplication->Argv(i+1));
1024 if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
1025 bRecalibrate = atoi(gApplication->Argv(i+1));
1027 if (!(strcmp(gApplication->Argv(i),"--badchannel")))
1028 bBadChannel = atoi(gApplication->Argv(i+1));
1030 if (!(strcmp(gApplication->Argv(i),"--run"))){
1031 sRun = gApplication->Argv(i+1);
1032 if(sRun.Contains("LHC10")) {
1037 kRun = atoi(gApplication->Argv(i+1));
1039 else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
1045 if(!sRun.Contains("LHC10")){
1049 if( kRun >= 136851 ) kCollision = "PbPb";
1051 else if( kRun < 170600)
1054 if( kRun >= 166500 ) kCollision = "PbPb";
1063 if(kMC) sprintf(kTrigger,"");
1065 printf("*********************************************\n");
1066 //printf("*** Settings trigger %s, recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
1067 // kTrigger,bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
1068 printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
1069 printf("*********************************************\n");
1073 //_________________________________________________________________
1074 void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)
1076 // Read the PYTHIA statistics from the file pyxsec.root created by
1077 // the function WriteXsection():
1078 // integrated cross section (xsection) and
1079 // the number of Pyevent() calls (ntrials)
1080 // and calculate the weight per one event xsection/ntrials
1081 // The spectrum calculated by a user should be
1082 // multiplied by this weight, something like this:
1083 // TH1F *userSpectrum ... // book and fill the spectrum
1084 // userSpectrum->Scale(weight)
1086 // Yuri Kharlov 19 June 2007
1087 // Gustavo Conesa 15 April 2008
1088 Double_t xsection = 0;
1093 Int_t nfiles = tree->GetEntries() ;
1094 if (tree && nfiles > 0) {
1095 tree->SetBranchAddress("xsection",&xsection);
1096 tree->SetBranchAddress("ntrials" ,&ntrials );
1097 for(Int_t i = 0; i < nfiles; i++){
1101 cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
1106 cout << "-----------------------------------------------------------------"<<endl;
1107 cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
1108 cout << "-----------------------------------------------------------------"<<endl;
1110 else cout << " >>>> Empty tree !!!! <<<<< "<<endl;