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