LUTs mapping symnames and original global matrices removed from AliGeomManager, which...
[u/mrichter/AliRoot.git] / PWG2 / runAODAnalysisExample.C
1 void produceAOD()
2 {
3     gSystem->Load("libTree.so");
4     gSystem->Load("libGeom.so");
5     gSystem->Load("libVMC.so");
6     gSystem->Load("libXMLIO.so");
7     SetupPar("STEERBase");
8 //    gSystem->Load("STEERBase/libSTEERBase.so");
9     SetupPar("ESD");
10 //    gSystem->Load("ESD/libESD.so");
11     SetupPar("AOD");
12 //    gSystem->Load("AOD/libAOD.so");
13     SetupPar("ANALYSIS");
14 //    gSystem->Load("ANALYSIS/libANALYSIS.so");
15     SetupPar("PWG0base");
16     // Make the analysis manager
17     //
18     // Chain from CAF
19     gROOT->LoadMacro("CreateESDChain.C");
20 //     TChain* chain = CreateESDChain("ESD1503X_v1.txt", 10);
21     TChain* chain = CreateESDChain("/mnt/data/alice/pbpb_therminator/central.2/", 885);
22
23     AliAODHandler* aodHandler   = new AliAODHandler();
24     aodHandler->SetOutputFileName("aod.root");
25     AliESDInputHandler *esdHandler = new AliESDInputHandler();
26     esdHandler->SetInactiveBranches("FMD CaloCluster");
27     
28     AliMCEventHandler* mcHandler = new AliMCEventHandler();
29
30     AliAnalysisManager *mgr  = new AliAnalysisManager("esd to aod to histos", "testing aod analysis");
31     mgr->SetInputEventHandler(esdHandler);
32     mgr->SetOutputEventHandler(aodHandler);
33     mgr->SetMCtruthEventHandler(mcHandler);
34     mgr->SetDebugLevel(10);
35     AliLog::EnableDebug(kTRUE);
36     AliLog::SetGlobalLogLevel(2);
37
38
39     // Set of cuts
40     // 
41     // standard
42     AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose");
43     esdTrackCutsL->SetMinNClustersTPC(50);
44     esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
45     esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
46     esdTrackCutsL->SetRequireTPCRefit(kTRUE);
47     esdTrackCutsL->SetMinNsigmaToVertex(3);
48     esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);
49     esdTrackCutsL->SetAcceptKingDaughters(kFALSE);
50     //
51     // hard
52     AliESDtrackCuts* esdTrackCutsH = new AliESDtrackCuts("AliESDtrackCuts", "Hard");
53     esdTrackCutsH->SetMinNClustersTPC(100);
54     esdTrackCutsH->SetMaxChi2PerClusterTPC(2.0);
55     esdTrackCutsH->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
56     esdTrackCutsH->SetRequireTPCRefit(kTRUE);
57     esdTrackCutsH->SetMinNsigmaToVertex(2);
58     esdTrackCutsH->SetRequireSigmaToVertex(kTRUE);
59     esdTrackCutsH->SetAcceptKingDaughters(kFALSE);
60     //
61     AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
62     trackFilter->AddCuts(esdTrackCutsL);
63     trackFilter->AddCuts(esdTrackCutsH);
64     //
65     AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
66     esdfilter->SetTrackFilter(trackFilter);
67     esdfilter->SetDebugLevel(10);
68     mgr->AddTask(esdfilter);
69
70     // Create containers for input/output
71     // Top ESD container
72     AliAnalysisDataContainer *cin_esd = mgr->CreateContainer("cchain",TChain::Class(), 
73                                                              AliAnalysisManager::kInputContainer);
74
75     // Output AOD container
76     AliAnalysisDataContainer *cout_aod = mgr->CreateContainer("tree", TTree::Class(),
77                                                               AliAnalysisManager::kOutputContainer, "default");
78
79     mgr->ConnectInput  (esdfilter,  0, cin_esd  );
80     mgr->ConnectOutput (esdfilter,  0, cout_aod );
81    //
82     // Run the analysis
83     //    
84     mgr->InitAnalysis();
85     mgr->PrintStatus();
86     mgr->StartAnalysis("local",chain);
87     delete mgr;
88 }
89
90 void runPWG2()
91 {
92     gSystem->Load("libTree.so");
93     gSystem->Load("libGeom.so");
94     gSystem->Load("libVMC.so");
95     gSystem->Load("libXMLIO.so");
96     SetupPar("STEERBase");
97 //    gSystem->Load("STEERBase/libSTEERBase.so");
98     SetupPar("ESD");
99 //    gSystem->Load("ESD/libESD.so");
100     SetupPar("AOD");
101 //    gSystem->Load("AOD/libAOD.so");
102     SetupPar("ANALYSIS");
103 //    gSystem->Load("ANALYSIS/libANALYSIS.so");
104     SetupPar("PWG0base");
105 //    gSystem->Load("PWG0base/libPWG0base.so");
106 //    SetupPar("TASKFILTER");
107 //    gSystem->Load("TASKFILTER/libTASKFILTER.so");
108 //    gSystem->Load("JETAN/libJETAN.so");
109   SetupPar("PWG2spectra");
110   gROOT->ProcessLine(".L $ALICE_ROOT/PWG2/AliAnalysisTaskProtons.cxx++g");
111    //
112 //    if (gApplication) gApplication->InitializeGraphics();
113     // Create the chain
114     //
115     // Chain from aod.root
116      TChain* chain = new TChain("aodTree");
117      chain->Add("aod.root");
118  //   TChain* chain = CreateESDChain("ESD12001.txt", 2);  
119     // Chain from local files
120 //    gROOT->LoadMacro("CreateLocalChain.C");
121 //    TChain* chain = CreateLocalChain();  
122     // Chain from ALIEN files
123 //    TGrid::Connect("alien://"); 
124 //    gROOT->LoadMacro("CreateChain.C");
125 //    TChain* chain = CreateChain("global.xml");  
126
127     //
128     // Make the analysis manager
129     //
130     AliAODInputHandler *aodHandler = new AliAODInputHandler();
131
132     AliAnalysisManager *mgr  = new AliAnalysisManager("esd to aod to histos", "testing aod analysis");
133     mgr->SetInputEventHandler(aodHandler);
134     mgr->SetDebugLevel(10);
135     AliLog::EnableDebug(kTRUE);
136     AliLog::SetGlobalLogLevel(2);
137
138
139    //
140   //____________________________________________//
141   // 1st Proton task
142   AliAnalysisTaskProtons *taskproton = new AliAnalysisTaskProtons("TaskProtons");
143   taskproton->SetType("AOD");
144   TFile *f = TFile::Open("$ALICE_ROOT/PWG2/data/PriorProbabilities.root ");
145   TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
146   TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
147   TF1 *fitPions = (TF1 *)f->Get("fitPions");
148   TF1 *fitKaons = (TF1 *)f->Get("fitKaons");
149   TF1 *fitProtons = (TF1 *)f->Get("fitProtons");
150   taskproton->SetPriorProbabilityFunctions(fitElectrons,
151                                       fitMuons,
152                                       fitPions,
153                                       fitKaons,
154                                       fitProtons);
155   mgr->AddTask(taskproton);
156     // Create containers for input/output
157     // Top AOD container
158     AliAnalysisDataContainer *cin_aod = mgr->CreateContainer("cchain",TChain::Class(), 
159                                                              AliAnalysisManager::kInputContainer);
160
161     // Output histogram container
162     AliAnalysisDataContainer *cout_hist = mgr->CreateContainer("protonhistos", TList::Class(),AliAnalysisManager::kOutputContainer,"protonhistos.root");
163
164     mgr->ConnectInput(taskproton,0,cin_aod);
165     mgr->ConnectOutput(taskproton,0,cout_hist);
166    //
167     // Run the analysis
168     //    
169     mgr->InitAnalysis();
170     mgr->PrintStatus();
171     mgr->StartAnalysis("local",chain);
172 }
173
174 void SetupPar(char* pararchivename)
175 {
176     if (pararchivename) {
177         char processline[1024];
178         sprintf(processline,".! tar xvzf %s.par",pararchivename);
179         gROOT->ProcessLine(processline);
180         TString ocwd = gSystem->WorkingDirectory();
181         gSystem->ChangeDirectory(pararchivename);
182         
183         // check for BUILD.sh and execute
184         if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
185             printf("*******************************\n");
186             printf("*** Building PAR archive    ***\n");
187             printf("*******************************\n");
188             
189             if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
190                 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
191                 return -1;
192             }
193         }
194         // check for SETUP.C and execute
195         if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
196             printf("*******************************\n");
197             printf("*** Setup PAR archive       ***\n");
198             printf("*******************************\n");
199             gROOT->Macro("PROOF-INF/SETUP.C");
200         }
201         
202         gSystem->ChangeDirectory(ocwd.Data());
203    printf("Current dir: %s\n", ocwd.Data());
204     } 
205 }