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 = kTRUE; //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 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
212 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC);
215 if(kCollision=="PbPb")
217 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
218 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
222 // Simple event counting tasks
223 AddTaskCounter(""); // All
224 //AddTaskCounter("MB"); // Min Bias
225 AddTaskCounter("Any");
226 AddTaskCounter("AnyINT");// Min Bias
230 AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
231 AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
232 AddTaskCounter("EMCEGA");
233 AddTaskCounter("EMCEJE");
234 if(kCollision=="PbPb")
236 AddTaskCounter("Central");
237 AddTaskCounter("SemiCentral");
238 AddTaskCounter("PHOSPb");
240 else AddTaskCounter("PHOS");
248 if(kInputData=="ESD"){
249 printf("* Configure photon conversion analysis in macro \n");
250 TString arguments = "-run-on-train -use-own-xyz -force-aod -mc-off ";
251 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
252 AliAnalysisTaskGammaConversion * taskGammaConversion =
253 ConfigGammaConversion(arguments,mgr->GetCommonInputContainer());
254 taskGammaConversion->SelectCollisionCandidates();
256 // Gamma Conversion AOD to AODPWG4Particle
257 AliAnalysisTaskGCPartToPWG4Part * taskGCToPC = new AliAnalysisTaskGCPartToPWG4Part("GCPartToPWG4Part");
258 taskGCToPC->SetGammaCutId("90035620401003321022000000090");
259 mgr->AddTask(taskGCToPC);
260 mgr->ConnectInput (taskGCToPC, 0, mgr->GetCommonInputContainer() );
261 mgr->ConnectOutput (taskGCToPC, 0, mgr->GetCommonOutputContainer());
265 Bool_t kPrint = kFALSE;
266 Bool_t deltaAOD = kFALSE;
267 gROOT->LoadMacro("AddTaskCaloTrackCorr.C"); // $ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros
268 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALClusterize.C"); // $ALICE_ROOT/PWGGA/EMCALTasks/macros
270 //gROOT->LoadMacro("$ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
271 //AliAnalysisTaskCaloTrackCorrelation * qatask = AddTaskCalorimeterQA(kInputData,kYear,kPrint,kMC);
273 // Calibration, bad map ...
275 Bool_t calibEE = kTRUE; // It is set automatically, but here we force to use it or not in any case
276 Bool_t calibTT = kTRUE; // It is set automatically, but here we force to use it or not in any case
277 if(kRun < 122195 || (kRun > 126437 && kRun < 136851) || kMC) calibTT=kFALSE ; // Recalibration parameters not available for LHC10a,b,c,e,f,g
278 Bool_t badMap = kTRUE; // It is set automatically, but here we force to use it or not in any case
282 printf("==================================== \n");
283 printf("CONFIGURE ANALYSIS FOR PP COLLISIONS \n");
284 printf("==================================== \n");
287 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
288 Bool_t anTM = kTRUE; // Remove matched
289 Bool_t exo = kTRUE; // Remove exotic cells
290 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
291 Int_t minEcell = 50; // 50 MeV (10 MeV used in reconstruction)
292 Int_t minEseed = 100; // 100 MeV
293 Int_t dTime = 0; // default, 250 ns
294 Int_t wTime = 30; // default 425 < T < 825 ns, careful if time calibration is on
295 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
296 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
299 TString clTrigger = "";
300 TString anTrigger = "EMC7";
310 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
311 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
312 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
314 //Analysis with clusterizer V1
316 TString arrayNameV1 = "";
318 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(kMC,exo,"V1",arrayNameV1,clTrigger, clTM,
319 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
320 calibEE,badMap,calibTT,annonlin);
322 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
327 AliAnalysisTaskCaloTrackCorrelation *anav1trig = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
328 kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
329 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale);
332 AliAnalysisTaskCaloTrackCorrelation *anav1mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
333 kYear,kCollision,"AnyINT",arrayNameV1,reTM,anTM,
334 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale);
338 //Analysis with clusterizer V2
339 TString arrayNameV2 = "";
340 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(kMC,exo,"V2",arrayNameV2,clTrigger, clTM,
341 minEcell,minEseed,dTime,wTime,
342 calibEE,badMap,calibTT,annonlin);
344 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
351 AliAnalysisTaskCaloTrackCorrelation *anav2tr = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
352 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
353 -1,-1,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale);
357 AliAnalysisTaskCaloTrackCorrelation *anav2mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
358 kYear,kCollision,"AnyINT",arrayNameV2,reTM,anTM,
359 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale);
362 if(kCollision=="PbPb")
364 printf("====================================== \n");
365 printf("CONFIGURE ANALYSIS FOR PbPb COLLISIONS \n");
366 printf("====================================== \n");
369 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
370 Bool_t anTM = kTRUE; // Remove matched
371 Bool_t exo = kTRUE; // Remove exotic cells
372 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
373 Int_t minEcell = 100; // 50 MeV (10 MeV used in reconstruction)
374 Int_t minEseed = 200; // 100 MeV
375 Int_t dTime = 0; // default, 250 ns
376 Int_t wTime = 0; // default 425 < T < 825 ns
377 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
378 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
381 TString clTrigger = "";
382 TString anTrigger = "EMCGA";
391 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
392 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
393 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
395 //Analysis with clusterizer V1
397 TString arrayNameV1 = "";
398 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(kMC,exo,"V1",arrayNameV1,clTrigger, clTM,
399 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
400 calibEE,badMap,calibTT,annonlin);
402 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
406 // AliAnalysisTaskCaloTrackCorrelation *anav1c = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
407 // kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
408 // 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
409 // AliAnalysisTaskCaloTrackCorrelation *anav1m = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
410 // kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
411 // 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
412 // AliAnalysisTaskCaloTrackCorrelation *anav1p = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
413 // kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
414 // 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
417 //Analysis with clusterizer V2
419 TString arrayNameV2 = "";
420 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(kMC,exo,"V2",arrayNameV2,clTrigger, clTM,
421 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
422 calibEE,badMap,calibTT,annonlin);
424 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
431 AliAnalysisTaskCaloTrackCorrelation *anav2cT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
432 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
433 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
434 AliAnalysisTaskCaloTrackCorrelation *anav2mT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
435 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
436 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
437 AliAnalysisTaskCaloTrackCorrelation *anav2pT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
438 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
439 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
442 AliAnalysisTaskCaloTrackCorrelation *anav2cMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
443 kYear,kCollision,"AnyINT",arrayNameV2,reTM,anTM,
444 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
445 AliAnalysisTaskCaloTrackCorrelation *anav2mMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
446 kYear,kCollision,"AnyINT",arrayNameV2,reTM,anTM,
447 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
448 AliAnalysisTaskCaloTrackCorrelation *anav2pMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
449 kYear,kCollision,"AnyINT",arrayNameV2,reTM,anTM,
450 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
457 //-----------------------
459 //-----------------------
463 if (mode == mPlugin) mgr->StartAnalysis("grid");
464 else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
465 else mgr->StartAnalysis("local",chain);
467 cout <<" Analysis ended sucessfully "<< endl ;
471 //_____________________________
472 void LoadLibraries(Int_t mode)
475 if (mode == mPROOF) {
476 //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
477 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
478 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");
480 // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
482 // //proof->ClearPackages();
483 // proof->UploadPackage("STEERBase");
484 // proof->UploadPackage("ESD");
485 // proof->UploadPackage("AOD");
486 // proof->UploadPackage("ANALYSIS");
487 // proof->UploadPackage("OADB");
488 // proof->UploadPackage("ANALYSISalice");
489 // proof->UploadPackage("CORRFW");
490 // //proof->UploadPackage("JETAN");
491 // proof->UploadPackage("PHOSUtils");
492 // proof->UploadPackage("EMCALUtils");
493 // proof->UploadPackage("PWGCaloTrackCorrBase");
494 // proof->UploadPackage("PWGGACaloTrackCorrelations");
495 // proof->UploadPackage("PWGGAEMCALTasks");
497 // proof->EnablePackage("STEERBase");
498 // proof->EnablePackage("ESD");
499 // proof->EnablePackage("AOD");
500 // proof->EnablePackage("ANALYSIS");
501 // proof->EnablePackage("OADB");
502 // proof->EnablePackage("ANALYSISalice");
503 // proof->EnablePackage("CORRFW");
504 // //proof->EnablePackage("JETAN");
505 // proof->EnablePackage("PHOSUtils");
506 // proof->EnablePackage("EMCALUtils");
507 // proof->EnablePackage("PWGCaloTrackCorrBase");
508 // proof->EnablePackage("PWGGACaloTrackCorrelations");
509 // proof->EnablePackage("PWGGAEMCALTasks");
513 //--------------------------------------
514 // Load the needed libraries most of them already loaded by aliroot
515 //--------------------------------------
516 gSystem->Load("libTree.so");
517 gSystem->Load("libGeom.so");
518 gSystem->Load("libVMC.so");
519 gSystem->Load("libXMLIO.so");
520 gSystem->Load("libMatrix.so");
521 gSystem->Load("libPhysics.so");
522 gSystem->Load("libMinuit.so"); // Root + libraries to if reclusterization is done
524 gSystem->Load("libSTEERBase.so");
525 gSystem->Load("libGui.so"); // Root + libraries to if reclusterization is done
526 gSystem->Load("libCDB.so"); // Root + libraries to if reclusterization is done
527 gSystem->Load("libESD.so"); // Root + libraries to if reclusterization is done
528 gSystem->Load("libAOD.so");
529 gSystem->Load("libRAWDatabase.so"); // Root + libraries to if reclusterization is done
530 gSystem->Load("libProof.so");
531 gSystem->Load("libOADB");
532 gSystem->Load("libANALYSIS.so");
533 gSystem->Load("libSTEER.so"); // Root + libraries to if reclusterization is done
535 gSystem->Load("libRAWDatarec.so"); // Root + libraries to if reclusterization is done
536 gSystem->Load("libRAWDatasim.so"); // Root + libraries to if reclusterization is done
537 gSystem->Load("libVZERObase.so"); // Root + libraries to if reclusterization is done
538 gSystem->Load("libVZEROrec.so"); // Root + libraries to if reclusterization is done
540 gSystem->Load("libEMCALUtils");
541 //SetupPar("EMCALUtils");
542 gSystem->Load("libEMCALraw"); // Root + libraries to if reclusterization is done
543 gSystem->Load("libEMCALbase"); // Root + libraries to if reclusterization is done
544 gSystem->Load("libEMCALsim"); // Root + libraries to if reclusterization is done
545 gSystem->Load("libEMCALrec"); // Root + libraries to if reclusterization is done
546 //SetupPar("EMCALraw");
547 //SetupPar("EMCALbase");
548 //SetupPar("EMCALsim");
549 //SetupPar("EMCALrec");
551 gSystem->Load("libANALYSISalice.so");
552 //gSystem->Load("libTENDER.so");
553 //gSystem->Load("libTENDERSupplies.so");
555 gSystem->Load("libPHOSUtils");
556 gSystem->Load("libEMCALUtils");
557 gSystem->Load("libPWGCaloTrackCorrBase");
558 gSystem->Load("libPWGGACaloTrackCorrelations");
559 gSystem->Load("libPWGGAEMCALTasks");
560 //SetupPar("PWGCaloTrackCorrBase");
561 //SetupPar("PWGGACaloTrackCorrelations");
562 //SetupPar("PWGGAEMCALTasks");
565 //gSystem->Load("libJETAN");
566 //gSystem->Load("FASTJETAN");
567 //gSystem->Load("PWGJE");
569 //gSystem->Load("libCORRFW.so");
570 //gSystem->Load("libPWGGAGammaConv.so");
571 //SetupPar("PWGGAGammaConv");
573 // needed for plugin?
574 gSystem->AddIncludePath("-I$ALICE_ROOT");
575 gSystem->AddIncludePath("-I./");
579 //_________________________________
580 void SetupPar(char* pararchivename)
582 //Load par files, create analysis libraries
583 //For testing, if par file already decompressed and modified
584 //classes then do not decompress.
586 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
587 TString parpar(Form("%s.par", pararchivename)) ;
589 if ( gSystem->AccessPathName(pararchivename) ) {
590 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
591 gROOT->ProcessLine(processline.Data());
594 TString ocwd = gSystem->WorkingDirectory();
595 gSystem->ChangeDirectory(pararchivename);
597 // check for BUILD.sh and execute
598 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
599 printf("*******************************\n");
600 printf("*** Building PAR archive ***\n");
601 cout<<pararchivename<<endl;
602 printf("*******************************\n");
604 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
605 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
609 // check for SETUP.C and execute
610 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
611 printf("*******************************\n");
612 printf("*** Setup PAR archive ***\n");
613 cout<<pararchivename<<endl;
614 printf("*******************************\n");
615 gROOT->Macro("PROOF-INF/SETUP.C");
618 gSystem->ChangeDirectory(ocwd.Data());
619 printf("Current dir: %s\n", ocwd.Data());
622 //______________________________________
623 void CheckInputData(const anaModes mode)
625 //Sets input data and tree
627 TString ocwd = gSystem->WorkingDirectory();
629 //---------------------------------------
630 //Local files analysis
631 //---------------------------------------
633 //If you want to add several ESD files sitting in a common directory INDIR
634 //Specify as environmental variables the directory (INDIR), the number of files
635 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
637 if(gSystem->Getenv("INDIR"))
638 kInDir = gSystem->Getenv("INDIR") ;
639 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
641 TString sindir(kInDir);
642 if (sindir.Contains("pass1")) kPass = "pass1";
643 else if(sindir.Contains("pass2")) kPass = "pass2";
644 else if(sindir.Contains("pass3")) kPass = "pass3";
646 if(gSystem->Getenv("PATTERN"))
647 kPattern = gSystem->Getenv("PATTERN") ;
648 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
650 cout<<"INDIR : "<<kInDir<<endl;
651 cout<<"NFILES : "<<kFile<<endl;
657 for (Int_t event = 0 ; event < kFile ; event++) {
658 sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
659 sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
660 sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
661 sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
663 TFile * fESD = TFile::Open(fileE) ;
664 TFile * fAOD = TFile::Open(fileA) ;
666 //Check if file exists and add it, if not skip it
669 kTreeName = "esdTree";
671 TFile * fG = TFile::Open(fileG);
672 if(fG) { kMC = kTRUE; fG->Close();}
676 TTree* esdTree = (TTree*)fESD->Get("esdTree");
677 AliESDEvent* esd = new AliESDEvent();
678 esd->ReadFromTree(esdTree);
679 esdTree->GetEvent(0);
680 kRun = esd->GetRunNumber();
686 kTreeName = "aodTree";
688 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
692 TTree* aodTree = (TTree*)fAOD->Get("aodTree");
693 AliAODEvent* aod = new AliAODEvent();
694 aod->ReadFromTree(aodTree);
695 aodTree->GetEvent(0);
696 kRun = aod->GetRunNumber();
699 else if(TFile::Open(fileEm))
701 kTreeName = "aodTree";
707 else if(TFile::Open(fileG))
716 if(fESD) fESD->Close();
717 if(fAOD) fAOD->Close();
719 }// local files analysis
721 //------------------------------
723 //-----------------------------
724 else if(mode == mGRID){
725 //Get colection file. It is specified by the environmental
728 if(gSystem->Getenv("XML") )
729 kXML = gSystem->Getenv("XML");
731 sprintf(kXML, "collection.xml") ;
733 if (!TFile::Open(kXML)) {
734 printf("No collection file with name -- %s -- was found\n",kXML);
737 else cout<<"XML file "<<kXML<<endl;
739 //Load necessary libraries and connect to the GRID
740 gSystem->Load("libNetx.so") ;
741 gSystem->Load("libRAliEn.so");
742 TGrid::Connect("alien://") ;
744 //Feed Grid with collection file
745 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
747 AliError(Form("%s not found", kXML)) ;
750 TGridResult* result = collection->GetGridResult("",0 ,0);
752 for (Int_t index = 0; index < result->GetEntries(); index++) {
753 TString alienURL = result->GetKey(index, "turl") ;
754 cout << "================== " << alienURL << endl ;
756 if (alienURL.Contains("pass1")) kPass = "pass1";
757 else if(alienURL.Contains("pass2")) kPass = "pass2";
758 else if(alienURL.Contains("pass3")) kPass = "pass3";
760 kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
761 printf("Run number from alien path = %d\n",kRun);
764 //Check if file exists and add it, if not skip it
765 if (alienURL.Contains("AliESDs.root"))
767 kTreeName = "esdTree";
769 alienURL.ReplaceAll("AliESDs.root","galice.root");
770 if(TFile::Open(alienURL)) kMC=kTRUE;
774 else if(alienURL.Contains("AliAOD.root"))
776 kTreeName = "aodTree";
778 fAOD = TFile::Open(alienURL);
779 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
783 else if(alienURL.Contains("embededAOD.root"))
785 kTreeName = "aodTree";
790 else if(alienURL.Contains("galice.root"))
799 //------------------------------
801 //-----------------------------
802 else if(mode == mPROOF){
804 TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
806 TIter iter(coll->GetList());
808 TFileInfo* fileInfo = 0;
809 while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
811 if (fileInfo->GetFirstUrl()) {
812 TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
813 cout << "================== " << ProofURL << endl ;
815 if (ProofURL.Contains("pass1")) kPass = "pass1";
816 else if(ProofURL.Contains("pass2")) kPass = "pass2";
817 else if(ProofURL.Contains("pass3")) kPass = "pass3";
819 kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
820 printf("Run number from alien path = %d\n",kRun);
823 //Check if file exists and add it, if not skip it
824 if (ProofURL.Contains("AliESDs.root"))
826 kTreeName = "esdTree";
828 alienURL.ReplaceAll("AliESDs.root","galice.root");
829 if(TFile::Open(ProofURL)) kMC=kTRUE;
834 else if(ProofURL.Contains("AliAOD.root"))
836 kTreeName = "aodTree";
838 fAOD = TFile::Open(ProofURL);
839 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
843 else if(ProofURL.Contains("embededAOD.root"))
845 kTreeName = "aodTree";
850 else if(ProofURL.Contains("galice.root"))
861 gSystem->ChangeDirectory(ocwd.Data());
865 //_____________________________________________________________________
866 void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
868 //Fills chain with data
869 TString ocwd = gSystem->WorkingDirectory();
871 //---------------------------------------
872 // Local files analysis
873 //---------------------------------------
875 //If you want to add several ESD files sitting in a common directory INDIR
876 //Specify as environmental variables the directory (INDIR), the number of files
877 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
879 if(gSystem->Getenv("INDIR"))
880 kInDir = gSystem->Getenv("INDIR") ;
881 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
883 if(gSystem->Getenv("PATTERN"))
884 kPattern = gSystem->Getenv("PATTERN") ;
885 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
887 if(gSystem->Getenv("NFILES"))
888 kFile = atoi(gSystem->Getenv("NFILES")) ;
889 else cout<<"NFILES not set, use default: "<<kFile<<endl;
891 //Check if env variables are set and are correct
892 if ( kInDir && kFile) {
893 printf("Get %d files from directory %s\n",kFile,kInDir);
894 if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
895 printf("%s does not exist\n", kInDir) ;
899 //if(gSystem->Getenv("XSFILE"))
900 //kXSFileName = gSystem->Getenv("XSFILE") ;
901 //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
902 char * kGener = gSystem->Getenv("GENER");
904 cout<<"GENER "<<kGener<<endl;
905 if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
906 else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
907 else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
909 else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
911 cout<<"INDIR : "<<kInDir <<endl;
912 cout<<"NFILES : "<<kFile <<endl;
913 cout<<"PATTERN : "<<kPattern <<endl;
914 cout<<"XSFILE : "<<kXSFileName<<endl;
917 if (kInputData == "ESD") datafile = "AliESDs.root" ;
918 else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
919 else if(kInputData == "MC") datafile = "galice.root" ;
921 //Loop on ESD/AOD/MC files, add them to chain
927 for (event = 0 ; event < kFile ; event++) {
928 sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
929 sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
931 //Check if file exists and add it, if not skip it
932 if ( fData = TFile::Open(file)) {
933 if ( fData->Get(kTreeName) ) {
934 printf("++++ Adding %s\n", file) ;
935 chain->AddFile(file);
936 chainxs->Add(filexs) ;
940 printf("---- Skipping %s\n", file) ;
946 TString input = "AliESDs.root" ;
947 cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
948 chain->AddFile(input);
951 }// local files analysis
953 //------------------------------
955 //------------------------------
956 else if(mode == mGRID){
957 //Get colection file. It is specified by the environmental
960 //Feed Grid with collection file
961 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
963 AliError(Form("%s not found", kXML)) ;
967 TGridResult* result = collection->GetGridResult("",0 ,0);
969 // Makes the ESD chain
970 printf("*** Getting the Chain ***\n");
971 for (Int_t index = 0; index < result->GetEntries(); index++) {
972 TString alienURL = result->GetKey(index, "turl") ;
973 cout << "================== " << alienURL << endl ;
974 chain->Add(alienURL) ;
975 alienURL.ReplaceAll("AliESDs.root",kXSFileName);
976 chainxs->Add(alienURL) ;
980 //------------------------------
982 //------------------------------
983 else if (mode == mPROOF) {
985 TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
987 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
988 chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
989 printf("chain has %d entries\n",chain->GetEntries());
992 gSystem->ChangeDirectory(ocwd.Data());
996 //_________________________________________________________________
997 void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)
999 // Read the PYTHIA statistics from the file pyxsec.root created by
1000 // the function WriteXsection():
1001 // integrated cross section (xsection) and
1002 // the number of Pyevent() calls (ntrials)
1003 // and calculate the weight per one event xsection/ntrials
1004 // The spectrum calculated by a user should be
1005 // multiplied by this weight, something like this:
1006 // TH1F *userSpectrum ... // book and fill the spectrum
1007 // userSpectrum->Scale(weight)
1009 // Yuri Kharlov 19 June 2007
1010 // Gustavo Conesa 15 April 2008
1011 Double_t xsection = 0;
1016 Int_t nfiles = tree->GetEntries() ;
1017 if (tree && nfiles > 0)
1019 tree->SetBranchAddress("xsection",&xsection);
1020 tree->SetBranchAddress("ntrials",&ntrials);
1021 for(Int_t i = 0; i < nfiles; i++){
1025 cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
1030 cout << "-----------------------------------------------------------------"<<endl;
1031 cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
1032 cout << "-----------------------------------------------------------------"<<endl;
1034 else cout << " >>>> Empty tree !!!! <<<<< "<<endl;
1038 //______________________________
1039 void CheckEnvironmentVariables()
1042 sprintf(kTrigger,"");
1044 Bool_t bRecalibrate = kFALSE;
1045 Bool_t bBadChannel = kFALSE;
1047 for (int i=0; i< gApplication->Argc();i++){
1051 printf("Arg %d: %s\n",i,gApplication->Argv(i));
1057 if (!(strcmp(gApplication->Argv(i),"--trigger")))
1058 sprintf(trigger,gApplication->Argv(i+1));
1060 if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
1061 bRecalibrate = atoi(gApplication->Argv(i+1));
1063 if (!(strcmp(gApplication->Argv(i),"--badchannel")))
1064 bBadChannel = atoi(gApplication->Argv(i+1));
1066 if (!(strcmp(gApplication->Argv(i),"--run"))){
1067 sRun = gApplication->Argv(i+1);
1068 if(sRun.Contains("LHC10")) {
1073 kRun = atoi(gApplication->Argv(i+1));
1075 else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
1081 if(!sRun.Contains("LHC10")){
1085 if( kRun >= 136851 ) kCollision = "PbPb";
1087 else if( kRun < 170600)
1090 if( kRun >= 166500 ) kCollision = "PbPb";
1099 if(kMC) sprintf(kTrigger,"");
1101 printf("*********************************************\n");
1102 //printf("*** Settings trigger %s, recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
1103 // kTrigger,bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
1104 printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
1105 printf("*********************************************\n");
1109 //_______________________________________________
1110 void AddTaskCounter(const TString trigger = "MB")
1113 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1115 AliAnalysisTaskCounter * counter = new AliAnalysisTaskCounter(Form("Counter%s",trigger.Data()));
1116 if(kRun > 140000 && kRun < 146900) counter ->RejectFastCluster();
1117 if (kCollision=="pp" ) counter->SetZVertexCut(10.); //Open cut
1118 else if(kCollision=="PbPb") counter->SetZVertexCut(10.); //Centrality defined in this range.
1122 printf("counter trigger EMC7\n");
1123 counter->SelectCollisionCandidates(AliVEvent::kEMC7);
1125 else if (trigger=="INT7")
1127 printf("counter trigger INT7\n");
1128 counter->SelectCollisionCandidates(AliVEvent::kINT7);
1132 printf("counter trigger EMC1\n");
1133 counter->SelectCollisionCandidates(AliVEvent::kEMC1);
1135 else if(trigger=="MB")
1137 printf("counter trigger MB\n");
1138 counter->SelectCollisionCandidates(AliVEvent::kMB);
1140 else if(trigger=="PHOS")
1142 printf("counter trigger PHOS\n");
1143 counter->SelectCollisionCandidates(AliVEvent::kPHI7);
1145 else if(trigger=="PHOSPb")
1147 printf("counter trigger PHOSPb\n");
1148 counter->SelectCollisionCandidates(AliVEvent::kPHOSPb);
1150 else if(trigger=="AnyINT")
1152 printf("counter trigger AnyINT\n");
1153 counter->SelectCollisionCandidates(AliVEvent::kAnyINT);
1155 else if(trigger=="INT")
1157 printf("counter trigger AnyINT\n");
1158 counter->SelectCollisionCandidates(AliVEvent::kAny);
1160 else if(trigger=="EMCEGA")
1162 printf("counter trigger EMC Gamma\n");
1163 counter->SelectCollisionCandidates(AliVEvent::kEMCEGA);
1165 else if(trigger=="EMCEJE")
1167 printf("counter trigger EMC Jet\n");
1168 counter->SelectCollisionCandidates(AliVEvent::kEMCEJE);
1170 else if(trigger=="Central")
1172 printf("counter trigger Central\n");
1173 counter->SelectCollisionCandidates(AliVEvent::kCentral);
1175 else if(trigger=="SemiCentral")
1177 printf("counter trigger SemiCentral\n");
1178 counter->SelectCollisionCandidates(AliVEvent::kSemiCentral);
1183 TString outputFile = AliAnalysisManager::GetCommonFileName();
1184 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
1186 AliAnalysisDataContainer *coutput =
1187 mgr->CreateContainer(Form("Counter%s",trigger.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outputFile.Data());
1188 mgr->AddTask(counter);
1189 mgr->ConnectInput (counter, 0, cinput1);
1190 mgr->ConnectOutput (counter, 1, coutput);
1195 //_________________________________________________________________
1196 void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)
1198 // Read the PYTHIA statistics from the file pyxsec.root created by
1199 // the function WriteXsection():
1200 // integrated cross section (xsection) and
1201 // the number of Pyevent() calls (ntrials)
1202 // and calculate the weight per one event xsection/ntrials
1203 // The spectrum calculated by a user should be
1204 // multiplied by this weight, something like this:
1205 // TH1F *userSpectrum ... // book and fill the spectrum
1206 // userSpectrum->Scale(weight)
1208 // Yuri Kharlov 19 June 2007
1209 // Gustavo Conesa 15 April 2008
1210 Double_t xsection = 0;
1215 Int_t nfiles = tree->GetEntries() ;
1216 if (tree && nfiles > 0) {
1217 tree->SetBranchAddress("xsection",&xsection);
1218 tree->SetBranchAddress("ntrials" ,&ntrials );
1219 for(Int_t i = 0; i < nfiles; i++){
1223 cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
1228 cout << "-----------------------------------------------------------------"<<endl;
1229 cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
1230 cout << "-----------------------------------------------------------------"<<endl;
1232 else cout << " >>>> Empty tree !!!! <<<<< "<<endl;