2 //--------------------------------------------------
3 // Example macro to do analysis with the
4 // analysis classes in PWG4PartCorr
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, mGRID=3};
14 //mLocal = 0: Analyze locally files in your computer
15 //mGRID = 3: Analyze files on GRID
17 //---------------------------------------------------------------------------
18 //Settings to read locally several files, only for "mLocal" mode
19 //The different values are default, they can be set with environmental
20 //variables: INDIR, PATTERN, NFILES, respectivelly
22 char * kInDir = "/user/data/files/";
23 char * kPattern = ""; // Data are in files kInDir/kPattern+i
24 Int_t kFile = 1; // Number of files for local analysis
25 //---------------------------------------------------------------------------
26 //Collection file for grid analysis
27 char * kXML = "collection.xml";
28 //---------------------------------------------------------------------------
29 //Scale histograms from file. Change to kTRUE when xsection file exists
30 //Put name of file containing xsection
31 //Put number of events per ESD file
32 //This is an specific case for normalization of Pythia files.
33 const Bool_t kGetXSectionFromFileAndScale = kFALSE ;
34 const char * kXSFileName = "pyxsec.root";
36 //---------------------------------------------------------------------------
38 //Set some default values, but used values are set in the code!
40 Bool_t kMC = kFALSE; //With real data kMC = kFALSE
41 TString kInputData = "ESD"; //ESD, AOD, MC, deltaAOD
43 TString kCollision = "pp";
44 Bool_t outAOD = kTRUE; //Some tasks doesnt need it.
50 void ana(Int_t mode=mGRID)
54 //--------------------------------------------------------------------
55 // Load analysis libraries
56 // Look at the method below,
57 // change whatever you need for your analysis case
58 // ------------------------------------------------------------------
61 //gSystem->ListLibraries();
63 //-------------------------------------------------------------------------------------------------
64 //Create chain from ESD and from cross sections files, look below for options.
65 //-------------------------------------------------------------------------------------------------
67 // Set kInputData and kTreeName looking to the kINDIR
71 // Check global analysis settings
73 CheckEnvironmentVariables();
75 printf("*********************************************\n");
76 printf("*** Input data < %s >, pass %s, tree < %s >, MC? < %d > ***\n",kInputData.Data(),kPass.Data(),kTreeName.Data(),kMC);
77 printf("*********************************************\n");
79 TChain * chain = new TChain(kTreeName) ;
80 TChain * chainxs = new TChain("Xsection") ;
81 CreateChain(mode, chain, chainxs);
83 printf("*********************************************\n");
84 printf("number of entries # %lld, skipped %d\n", chain->GetEntries()) ;
85 printf("*********************************************\n");
88 printf("STOP, no chain available\n");
92 AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
94 //--------------------------------------
95 // Make the analysis manager
96 //-------------------------------------
97 AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
98 //AliAnalysisManager::SetUseProgressBar(kTRUE);
99 //mgr->SetSkipTerminate(kTRUE);
100 //mgr->SetNSysInfo(1);
103 if((kMC || kInputData == "MC") && !kInputData.Contains("AOD")){
104 AliMCEventHandler* mcHandler = new AliMCEventHandler();
105 mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
106 mgr->SetMCtruthEventHandler(mcHandler);
107 if( kInputData == "MC") {
108 cout<<"MC INPUT EVENT HANDLER"<<endl;
109 mgr->SetInputEventHandler(NULL);
113 // AOD output handler
114 if(kInputData!="deltaAOD" && outAOD){
115 cout<<"Init output handler"<<endl;
116 AliAODHandler* aodoutHandler = new AliAODHandler();
117 aodoutHandler->SetOutputFileName("aod.root");
118 ////aodoutHandler->SetCreateNonStandardAOD();
119 mgr->SetOutputEventHandler(aodoutHandler);
124 if(kInputData == "ESD"){
126 AliESDInputHandler *esdHandler = new AliESDInputHandler();
127 esdHandler->SetReadFriends(kFALSE);
128 mgr->SetInputEventHandler(esdHandler);
129 cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
131 else if(kInputData.Contains("AOD")){
133 AliAODInputHandler *aodHandler = new AliAODInputHandler();
134 mgr->SetInputEventHandler(aodHandler);
135 if(kInputData == "deltaAOD") aodHandler->AddFriend("deltaAODPartCorr.root");
136 cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
138 //mgr->RegisterExternalFile("deltaAODPartCorr.root");
139 //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
141 TString outputFile = AliAnalysisManager::GetCommonFileName();
143 //-------------------------------------------------------------------------
144 //Define task, put here any other task that you want to use.
145 //-------------------------------------------------------------------------
148 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
149 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC);
152 if(kCollision=="PbPb"){
153 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
154 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
155 taskCentrality->SetPass(2); // remember to set the pass you are processing!!!
158 // Simple event counting tasks
159 AddTaskCounter(""); // All
160 AddTaskCounter("MB"); // Min Bias
162 AddTaskCounter("INT7"); // Min Bias
163 AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
164 AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
165 AddTaskCounter("PHOS"); //
168 Bool_t kPrint = kFALSE;
169 Bool_t deltaAOD = kFALSE;
171 gROOT->LoadMacro("AddTaskPartCorr.C"); // $ALICE_ROOT/PWG4/macros
172 gROOT->LoadMacro("AddTaskEMCALClusterize.C"); // $ALICE_ROOT/PWG4/CaloCalib/macros
178 // QA analysis to compare after clusterization and track isolation-correlation analysis
179 AliAnalysisTaskParticleCorrelation *ana = AddTaskPartCorr(kInputData, "EMCAL", kPrint,kMC, deltaAOD, outputFile.Data(),
180 kYear,kRun,kCollision,"EMC7","");
186 Bool_t bTrackMatch = kTRUE;
187 Int_t minEcell = 50; // 50 MeV (10 MeV used in reconstruction)
188 Int_t minEseed = 100; // 100 MeV
189 Int_t dTime = 0; // default, 250 ns
190 Int_t wTime = 0; // default 425 < T < 825 ns
191 TString clTrigger = ""; // Do not select, do Min Bias and triggered
193 //Analysis with clusterizer V1
194 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(kMC,"V1",clTrigger,kRun,kPass, bTrackMatch,
195 minEcell,minEseed,dTime,wTime);
197 TString arrayNameV1(Form("V1_Ecell%d_Eseed%d_DT%d_WT%d",minEcell,minEseed, dTime,wTime));
198 printf("Name of clusterizer array: %s\n",arrayNameV1.Data());
203 AliAnalysisTaskParticleCorrelation *anav1tr = AddTaskPartCorr(kInputData, "EMCAL", kPrint,kMC, deltaAOD, outputFile.Data(),
204 kYear,kRun,kCollision,"EMC7",arrayNameV1);
206 AliAnalysisTaskParticleCorrelation *anav1mb = AddTaskPartCorr(kInputData, "EMCAL", kPrint,kMC, deltaAOD, outputFile.Data(),
207 kYear,kRun,kCollision,"INT7",arrayNameV1);
210 {// No trigger (should be MB, but for single particle productions it does not work)
212 AliAnalysisTaskParticleCorrelation *anav1 = AddTaskPartCorr(kInputData, "EMCAL", kPrint,kMC, deltaAOD, outputFile.Data(),
213 kYear,kRun,kCollision,"",arrayNameV1);
217 //Analysis with clusterizer V2
218 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(kMC,"V2",clTrigger,kRun,kPass, bTrackMatch,
219 minEcell,minEseed,dTime,wTime);
221 TString arrayNameV2(Form("V2_Ecell%d_Eseed%d_DT%d_WT%d",minEcell,minEseed, dTime,wTime));
222 printf("Name of clusterizer array: %s\n",arrayNameV2.Data());
227 AliAnalysisTaskParticleCorrelation *anav2tr = AddTaskPartCorr(kInputData, "EMCAL", kPrint,kMC, deltaAOD, outputFile.Data(),
228 kYear,kRun,kCollision,"EMC7",arrayNameV2);
230 AliAnalysisTaskParticleCorrelation *anav2mb = AddTaskPartCorr(kInputData, "EMCAL", kPrint,kMC, deltaAOD, outputFile.Data(),
231 kYear,kRun,kCollision,"INT7",arrayNameV2);
234 {// No trigger (should be MB, but for single particle productions it does not work)
235 AliAnalysisTaskParticleCorrelation *anav2 = AddTaskPartCorr(kInputData, "EMCAL", kPrint,kMC, deltaAOD, outputFile.Data(),
236 kYear,kRun,kCollision,"",arrayNameV2);
243 //Add here PHOS tender or whatever is needed
248 AliAnalysisTaskParticleCorrelation *anav1tr = AddTaskPartCorr(kInputData, "PHOS", kPrint,kMC, deltaAOD, outputFile.Data(),
249 kYear,kRun,kCollision,"PHOS",""); // Change to PHOS trigger
252 AliAnalysisTaskParticleCorrelation *anav1mb = AddTaskPartCorr(kInputData, "PHOS", kPrint,kMC, deltaAOD, outputFile.Data(),
253 kYear,kRun,kCollision,"INT7","");
259 AliAnalysisTaskParticleCorrelation *anav1mb = AddTaskPartCorr(kInputData, "PHOS", kPrint,kMC, deltaAOD, outputFile.Data(),
260 kYear,kRun,kCollision,"","");
266 //-----------------------
268 //-----------------------
271 mgr->StartAnalysis("local",chain);
273 cout <<" Analysis ended sucessfully "<< endl ;
278 //___________________
282 //--------------------------------------
283 // Load the needed libraries most of them already loaded by aliroot
284 //--------------------------------------
285 gSystem->Load("libTree.so");
286 gSystem->Load("libGeom.so");
287 gSystem->Load("libVMC.so");
288 gSystem->Load("libXMLIO.so");
289 gSystem->Load("libMatrix.so");
290 gSystem->Load("libPhysics.so");
291 gSystem->Load("libMinuit.so"); // Root + libraries to if reclusterization is done
293 gSystem->Load("libSTEERBase.so");
294 gSystem->Load("libGui.so"); // Root + libraries to if reclusterization is done
295 gSystem->Load("libCDB.so"); // Root + libraries to if reclusterization is done
296 gSystem->Load("libESD.so"); // Root + libraries to if reclusterization is done
297 gSystem->Load("libAOD.so");
298 gSystem->Load("libRAWDatabase.so"); // Root + libraries to if reclusterization is done
299 gSystem->Load("libProof.so");
300 gSystem->Load("libANALYSIS.so");
301 gSystem->Load("libSTEER.so"); // Root + libraries to if reclusterization is done
303 gSystem->Load("libRAWDatarec.so"); // Root + libraries to if reclusterization is done
304 gSystem->Load("libRAWDatasim.so"); // Root + libraries to if reclusterization is done
305 gSystem->Load("libVZERObase.so"); // Root + libraries to if reclusterization is done
306 gSystem->Load("libVZEROrec.so"); // Root + libraries to if reclusterization is done
308 gSystem->Load("libEMCALUtils");
309 //SetupPar("EMCALUtils");
310 gSystem->Load("libEMCALraw"); // Root + libraries to if reclusterization is done
311 gSystem->Load("libEMCALbase"); // Root + libraries to if reclusterization is done
312 gSystem->Load("libEMCALsim"); // Root + libraries to if reclusterization is done
313 gSystem->Load("libEMCALrec"); // Root + libraries to if reclusterization is done
314 //SetupPar("EMCALraw");
315 //SetupPar("EMCALbase");
316 //SetupPar("EMCALsim");
317 //SetupPar("EMCALrec");
319 gSystem->Load("libANALYSISalice.so");
320 //gSystem->Load("libTENDER.so");
321 //gSystem->Load("libTENDERSupplies.so");
323 gSystem->Load("libPHOSUtils");
324 gSystem->Load("libEMCALUtils");
325 gSystem->Load("libPWG4PartCorrBase");
326 gSystem->Load("libPWG4PartCorrDep");
327 gSystem->Load("libPWG4CaloCalib");
328 //SetupPar("PWG4PartCorrBase");
329 //SetupPar("PWG4PartCorrDep");
330 //SetupPar("PWG4CaloCalib");
333 void SetupPar(char* pararchivename)
335 //Load par files, create analysis libraries
336 //For testing, if par file already decompressed and modified
337 //classes then do not decompress.
339 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
340 TString parpar(Form("%s.par", pararchivename)) ;
342 if ( gSystem->AccessPathName(pararchivename) ) {
343 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
344 gROOT->ProcessLine(processline.Data());
347 TString ocwd = gSystem->WorkingDirectory();
348 gSystem->ChangeDirectory(pararchivename);
350 // check for BUILD.sh and execute
351 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
352 printf("*******************************\n");
353 printf("*** Building PAR archive ***\n");
354 cout<<pararchivename<<endl;
355 printf("*******************************\n");
357 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
358 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
362 // check for SETUP.C and execute
363 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
364 printf("*******************************\n");
365 printf("*** Setup PAR archive ***\n");
366 cout<<pararchivename<<endl;
367 printf("*******************************\n");
368 gROOT->Macro("PROOF-INF/SETUP.C");
371 gSystem->ChangeDirectory(ocwd.Data());
372 printf("Current dir: %s\n", ocwd.Data());
375 void CheckInputData(const anaModes mode){
376 //Sets input data and tree
378 TString ocwd = gSystem->WorkingDirectory();
380 //---------------------------------------
381 //Local files analysis
382 //---------------------------------------
384 //If you want to add several ESD files sitting in a common directory INDIR
385 //Specify as environmental variables the directory (INDIR), the number of files
386 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
388 if(gSystem->Getenv("INDIR"))
389 kInDir = gSystem->Getenv("INDIR") ;
390 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
392 TString sindir(kInDir);
393 if (sindir.Contains("pass1")) kPass = "pass1";
394 else if(sindir.Contains("pass2")) kPass = "pass2";
395 else if(sindir.Contains("pass3")) kPass = "pass3";
397 if(gSystem->Getenv("PATTERN"))
398 kPattern = gSystem->Getenv("PATTERN") ;
399 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
401 cout<<"INDIR : "<<kInDir<<endl;
402 cout<<"NFILES : "<<kFile<<endl;
408 for (Int_t event = 0 ; event < kFile ; event++) {
409 sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
410 sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
411 sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
412 sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
414 TFile * fESD = TFile::Open(fileE) ;
415 TFile * fAOD = TFile::Open(fileA) ;
417 //Check if file exists and add it, if not skip it
419 kTreeName ="esdTree";
421 TFile * fG = TFile::Open(fileG);
422 if(fG) { kMC = kTRUE; fG->Close();}
426 TTree* esdTree = (TTree*)fESD->Get("esdTree");
427 AliESDEvent* esd = new AliESDEvent();
428 esd->ReadFromTree(esdTree);
429 esdTree->GetEvent(0);
430 kRun = esd->GetRunNumber();
435 kTreeName ="aodTree";
437 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
441 TTree* aodTree = (TTree*)fAOD->Get("aodTree");
442 AliAODEvent* aod = new AliAODEvent();
443 aod->ReadFromTree(esdTree);
444 aodTree->GetEvent(0);
445 kRun = aod->GetRunNumber();
448 else if(TFile::Open(fileEm)){
449 kTreeName = "aodTree";
455 else if(TFile::Open(fileG)){
463 if(fESD) fESD->Close();
464 if(fAOD) fAOD->Close();
466 }// local files analysis
468 //------------------------------
470 //-----------------------------
471 else if(mode == mGRID){
472 //Get colection file. It is specified by the environmental
475 if(gSystem->Getenv("XML") )
476 kXML = gSystem->Getenv("XML");
478 sprintf(kXML, "collection.xml") ;
480 if (!TFile::Open(kXML)) {
481 printf("No collection file with name -- %s -- was found\n",kXML);
484 else cout<<"XML file "<<kXML<<endl;
486 //Load necessary libraries and connect to the GRID
487 gSystem->Load("libNetx.so") ;
488 gSystem->Load("libRAliEn.so");
489 TGrid::Connect("alien://") ;
491 //Feed Grid with collection file
492 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
494 AliError(Form("%s not found", kXML)) ;
497 TGridResult* result = collection->GetGridResult("",0 ,0);
499 for (Int_t index = 0; index < result->GetEntries(); index++) {
500 TString alienURL = result->GetKey(index, "turl") ;
501 cout << "================== " << alienURL << endl ;
503 if (alienURL.Contains("pass1")) kPass = "pass1";
504 else if(alienURL.Contains("pass2")) kPass = "pass2";
505 else if(alienURL.Contains("pass3")) kPass = "pass3";
508 //Check if file exists and add it, if not skip it
509 if (alienURL.Contains("AliESDs.root")) {
510 kTreeName ="esdTree";
512 alienURL.ReplaceAll("AliESDs.root","galice.root");
513 if(TFile::Open(alienURL)) kMC=kTRUE;
516 kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
517 printf("Run number from alien path = %d\n",kRun);
521 else if(alienURL.Contains("AliAOD.root")){
522 kTreeName ="aodTree";
524 fAOD = TFile::Open(alienURL);
525 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
529 else if(alienURL.Contains("embededAOD.root")){
530 kTreeName ="aodTree";
535 else if(alienURL.Contains("galice.root")){
544 gSystem->ChangeDirectory(ocwd.Data());
548 //_____________________________________________________________________
549 void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
551 //Fills chain with data
552 TString ocwd = gSystem->WorkingDirectory();
554 //---------------------------------------
555 //Local files analysis
556 //---------------------------------------
558 //If you want to add several ESD files sitting in a common directory INDIR
559 //Specify as environmental variables the directory (INDIR), the number of files
560 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
562 if(gSystem->Getenv("INDIR"))
563 kInDir = gSystem->Getenv("INDIR") ;
564 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
566 if(gSystem->Getenv("PATTERN"))
567 kPattern = gSystem->Getenv("PATTERN") ;
568 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
570 if(gSystem->Getenv("NFILES"))
571 kFile = atoi(gSystem->Getenv("NFILES")) ;
572 else cout<<"NFILES not set, use default: "<<kFile<<endl;
574 //Check if env variables are set and are correct
575 if ( kInDir && kFile) {
576 printf("Get %d files from directory %s\n",kFile,kInDir);
577 if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
578 printf("%s does not exist\n", kInDir) ;
582 //if(gSystem->Getenv("XSFILE"))
583 //kXSFileName = gSystem->Getenv("XSFILE") ;
584 //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
585 char * kGener = gSystem->Getenv("GENER");
587 cout<<"GENER "<<kGener<<endl;
588 if(!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
589 else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
590 else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
592 else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
594 cout<<"INDIR : "<<kInDir<<endl;
595 cout<<"NFILES : "<<kFile<<endl;
596 cout<<"PATTERN : " <<kPattern<<endl;
597 cout<<"XSFILE : "<<kXSFileName<<endl;
600 if(kInputData == "ESD") datafile = "AliESDs.root" ;
601 else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;//////////
602 else if(kInputData == "MC") datafile = "galice.root" ;
604 //Loop on ESD/AOD/MC files, add them to chain
610 for (event = 0 ; event < kFile ; event++) {
611 sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
612 sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
614 //Check if file exists and add it, if not skip it
615 if ( fData = TFile::Open(file)) {
616 if ( fData->Get(kTreeName) ) {
617 printf("++++ Adding %s\n", file) ;
618 chain->AddFile(file);
619 chainxs->Add(filexs) ;
623 printf("---- Skipping %s\n", file) ;
629 TString input = "AliESDs.root" ;
630 cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
631 chain->AddFile(input);
634 }// local files analysis
636 //------------------------------
638 //-----------------------------
639 else if(mode == mGRID){
640 //Get colection file. It is specified by the environmental
643 //Feed Grid with collection file
644 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
646 AliError(Form("%s not found", kXML)) ;
649 TGridResult* result = collection->GetGridResult("",0 ,0);
651 // Makes the ESD chain
652 printf("*** Getting the Chain ***\n");
653 for (Int_t index = 0; index < result->GetEntries(); index++) {
654 TString alienURL = result->GetKey(index, "turl") ;
655 cout << "================== " << alienURL << endl ;
656 chain->Add(alienURL) ;
657 alienURL.ReplaceAll("AliESDs.root",kXSFileName);
658 chainxs->Add(alienURL) ;
662 gSystem->ChangeDirectory(ocwd.Data());
666 //_________________________________________________________________
667 void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)
669 // Read the PYTHIA statistics from the file pyxsec.root created by
670 // the function WriteXsection():
671 // integrated cross section (xsection) and
672 // the number of Pyevent() calls (ntrials)
673 // and calculate the weight per one event xsection/ntrials
674 // The spectrum calculated by a user should be
675 // multiplied by this weight, something like this:
676 // TH1F *userSpectrum ... // book and fill the spectrum
677 // userSpectrum->Scale(weight)
679 // Yuri Kharlov 19 June 2007
680 // Gustavo Conesa 15 April 2008
681 Double_t xsection = 0;
686 Int_t nfiles = tree->GetEntries() ;
687 if (tree && nfiles > 0) {
688 tree->SetBranchAddress("xsection",&xsection);
689 tree->SetBranchAddress("ntrials",&ntrials);
690 for(Int_t i = 0; i < nfiles; i++){
694 cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
699 cout << "-----------------------------------------------------------------"<<endl;
700 cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
701 cout << "-----------------------------------------------------------------"<<endl;
703 else cout << " >>>> Empty tree !!!! <<<<< "<<endl;
708 //______________________________
709 void CheckEnvironmentVariables()
712 sprintf(kTrigger,"");
714 Bool_t bRecalibrate = kFALSE;
715 Bool_t bBadChannel = kFALSE;
717 for (int i=0; i< gApplication->Argc();i++){
721 printf("Arg %d: %s\n",i,gApplication->Argv(i));
727 if (!(strcmp(gApplication->Argv(i),"--trigger")))
728 sprintf(trigger,gApplication->Argv(i+1));
730 if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
731 bRecalibrate = atoi(gApplication->Argv(i+1));
733 if (!(strcmp(gApplication->Argv(i),"--badchannel")))
734 bBadChannel = atoi(gApplication->Argv(i+1));
736 if (!(strcmp(gApplication->Argv(i),"--run"))){
737 sRun = gApplication->Argv(i+1);
738 if(sRun.Contains("LHC10")) {
743 kRun = atoi(gApplication->Argv(i+1));
745 else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
751 if(!sRun.Contains("LHC10")){
752 if ( kRun < 140000) {
754 if( kRun >= 136851 ) kCollision = "PbPb";
761 if(kMC) sprintf(kTrigger,"");
763 printf("*********************************************\n");
764 //printf("*** Settings trigger %s, recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
765 // kTrigger,bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
766 printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
767 printf("*********************************************\n");
771 //_____________________________________________________________
772 void AddTaskCounter(const TString trigger = "MB")
775 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
777 AliAnalysisTaskCounter * counter = new AliAnalysisTaskCounter(Form("Counter%s",trigger.Data()));
778 if(kRun > 140000 && kRun < 146900) counter ->RejectFastCluster();
779 if (kCollision=="pp" ) counter->SetZVertexCut(50.); //Open cut
780 else if(kCollision=="PbPb") counter->SetZVertexCut(10.); //Centrality defined in this range.
783 printf("counter trigger EMC7\n");
784 counter->SelectCollisionCandidates(AliVEvent::kEMC7);
786 else if (trigger=="INT7"){
787 printf("counter trigger INT7\n");
788 counter->SelectCollisionCandidates(AliVEvent::kINT7);
791 printf("counter trigger EMC1\n");
792 counter->SelectCollisionCandidates(AliVEvent::kEMC1);
794 else if(trigger=="MB"){
795 printf("counter trigger MB\n");
796 counter->SelectCollisionCandidates(AliVEvent::kMB);
798 else if(trigger=="PHOS"){
799 printf("counter trigger PHOS\n");
800 counter->SelectCollisionCandidates(AliVEvent::kPHI7);
803 TString outputFile = AliAnalysisManager::GetCommonFileName();
804 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
806 AliAnalysisDataContainer *coutput =
807 mgr->CreateContainer(Form("Counter%s",trigger.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outputFile.Data());
808 mgr->AddTask(counter);
809 mgr->ConnectInput (counter, 0, cinput1);
810 mgr->ConnectOutput (counter, 1, coutput);