]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/muon/AnalysisTrigChEff.C
Fixing warnings in AliAnalysisTaskTrigChEff compilation (Diego)
[u/mrichter/AliRoot.git] / PWG3 / muon / AnalysisTrigChEff.C
1 //--------------------------------------------------------------------------
2 // Base macro for submitting trigger chamber efficiency determination.
3 // 
4 // In case it is not run with full aliroot, it needs to have in the working directory:
5 //  - STEERBase.par
6 //  - ESD.par
7 //  - AOD.par
8 //  - ANALYSIS.par
9 //  - ANALYSISalice.par
10 // 
11 // The macro reads ESDs and outputs file:
12 // - MUON.TriggerEfficiencyMap.root
13 //
14 // To display the trigger chamber efficiency:
15 // > aliroot
16 // > AliMUONTriggerEfficiencyCells effCells("MUON.TriggerEfficiencyMap.root")
17 // > effCells.DisplayEfficiency()
18 //--------------------------------------------------------------------------
19
20 enum anaModes {kMlocal, kMgridLocal, kMgrid};
21 TString modeName[3] = {"local", "local", "grid"};
22 const TString kDefaultLocalInputDir="$ALICE_ROOT/MUON/test_out.100";
23 const TString kDefaultXmlFile="wn.xml";
24
25 void AnalysisTrigChEff(Int_t mode=kMlocal)
26 {
27 // Example of running analysis train
28   TStopwatch timer;
29   timer.Start();
30
31   gSystem->Load("libTree.so");
32   gSystem->Load("libGeom.so");
33   gSystem->Load("libVMC.so");
34   gSystem->Load("libPhysics.so");
35
36   // Common packages
37   SetupPar("STEERBase");
38   SetupPar("ESD");
39   SetupPar("AOD");
40   SetupPar("ANALYSIS");
41   SetupPar("ANALYSISalice");
42
43   // Analysis using standard AliRoot libraries
44   gSystem->Load("libSTEERBase.so");
45   gSystem->Load("libESD.so");
46   gSystem->Load("libAOD.so");
47   gSystem->Load("libANALYSIS.so");
48   gSystem->Load("libANALYSISalice.so");
49
50   
51   // A task can be compiled dynamically with AClic
52   gROOT->ProcessLine(".L AliAnalysisTaskTrigChEff.cxx+");
53
54   //
55   // Connect to alien
56   //
57   if(mode==kMgridLocal || mode==kMgrid)
58     TGrid::Connect("alien://"); 
59
60   //
61   // Create the chain
62   //
63   TChain* chain = CreateChain(mode);
64
65   TString outFileName("MUON.TriggerEfficiencyMap.root");
66   //
67   //
68   // Make the analysis manager
69   AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train", "A test setup for the analysis train");
70   // ESD input handler
71   AliESDInputHandler *esdHandler = new AliESDInputHandler();
72   //esdHandler->SetInactiveBranches("FMD CaloCluster");
73   // Monte Carlo handler
74   //AliMCEventHandler* mcHandler = new AliMCEventHandler();
75
76   mgr->SetInputEventHandler(esdHandler);
77   //mgr->SetMCtruthEventHandler(mcHandler);
78   
79   // Trigger chamber efficiency analysis
80   AliAnalysisTaskTrigChEff* taskTrigChEff = new AliAnalysisTaskTrigChEff("TaskTrigChEff");
81   mgr->AddTask(taskTrigChEff);
82   
83   // Create containers for input/output
84   // Top container for ESD input 
85   AliAnalysisDataContainer *cin_esd = mgr->CreateContainer("cESD",TChain::Class(), 
86                                                            AliAnalysisManager::kInputContainer);
87
88   // Output histograms list for single muons analysis
89   AliAnalysisDataContainer *cout_trigChEff = mgr->CreateContainer("triggerChamberEff", TList::Class(),
90                                                                  AliAnalysisManager::kOutputContainer, outFileName.Data());
91
92   mgr->ConnectInput  (taskTrigChEff, 0, cin_esd);
93   mgr->ConnectOutput (taskTrigChEff, 0, cout_trigChEff);
94
95   //
96   // Run the analysis
97   //
98   if (mgr->InitAnalysis()) {
99     mgr->PrintStatus();
100     mgr->StartAnalysis(modeName[mode].Data(), chain);
101   }
102   timer.Stop();
103   timer.Print();
104 }
105
106 //______________________________________________________________________________
107 TChain* CreateChain(Int_t mode)
108 {
109   printf("*******************************\n");
110   printf("*** Getting the Chain       ***\n");
111   printf("*******************************\n");
112   TChain *chain = 0x0;
113   if(mode==kMgridLocal || mode==kMgrid){
114     AliTagAnalysis *analysis = new AliTagAnalysis();
115     chain = analysis->GetChainFromCollection(kDefaultXmlFile.Data(),"esdTree");
116   }
117   else{
118     chain = new TChain("esdTree");
119     TString inFileName("AliESDs.root");
120     inFileName.Prepend(Form("%s/",kDefaultLocalInputDir.Data()));
121     chain->Add(inFileName.Data());
122   }
123   if (chain) chain->ls();
124   return chain;
125 }
126
127 //______________________________________________________________________________
128 void SetupPar(char* pararchivename)
129 {
130   if (pararchivename) {
131     char processline[1024];
132     sprintf(processline,".! tar xvzf %s.par",pararchivename);
133     gROOT->ProcessLine(processline);
134     const char* ocwd = gSystem->WorkingDirectory();
135     gSystem->ChangeDirectory(pararchivename);
136     printf("Current directory = %s\n",gSystem->pwd());
137
138     // check for BUILD.sh and execute
139     if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
140       printf("*******************************\n");
141       printf("*** Building PAR archive    ***\n");
142       printf("*******************************\n");
143
144       if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
145         Error("runProcess","Cannot Build the PAR Archive! - Abort!");
146         return -1;
147       }
148     }
149     // check for SETUP.C and execute
150     if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
151       printf("*******************************\n");
152       printf("*** Setup PAR archive       ***\n");
153       printf("*******************************\n");
154       gROOT->Macro("PROOF-INF/SETUP.C");
155     }
156         
157     gSystem->ChangeDirectory("../");
158   } 
159 }