]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/macros/Train/ProtonLambdaFemto/runBatch.C
6ce9cce1210c6b3919eae07dc8c91cc00796989c
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / macros / Train / ProtonLambdaFemto / runBatch.C
1 //_________________________________
2 // Femto analysis
3 //_________________________________
4
5 void runBatch() {
6   TStopwatch timer;
7   timer.Start();
8
9
10 //______ connect to Alien
11   printf("*** Connect to AliEn ***\n");
12   TGrid::Connect("alien://");
13
14
15   gSystem->Load("libProofPlayer");
16   gSystem->Load("libVMC");
17
18
19 //_______ Load libraries
20   gSystem->Load("libAOD");
21   gSystem->Load("libANALYSIS");
22   gSystem->Load("libANALYSISalice");
23
24    Bool_t useParFiles   = kFALSE;  
25    Bool_t useTenderPars = kFALSE;
26    Bool_t usePWGCFParFiles = kFALSE;
27    
28    Bool_t useMC = kFALSE;
29
30    TString format = "aod";
31    //format = "aod";
32    format.ToLower();
33
34 //______ Dynamic Path ______
35    if (usePWGCFParFiles) {
36    TString dynpath(".:");
37    dynpath += gSystem->GetDynamicPath();
38    gSystem->SetDynamicPath(dynpath);
39     //char dynpath[10000];
40     //sprintf(dynpath, ".:%s", gSystem->GetDynamicPath());
41     //gSystem->SetDynamicPath(dynpath);
42   }
43
44   // Use precompiled libraries for the analysis framework
45   if (useParFiles)
46     setupPar("STEERBase");
47           if (gSystem->Load("libSTEERBase")<0) {
48     cout << "Cannot load libSTEERBase.so . Exiting" << endl;
49     exit(0);
50   }
51   gSystem->Load("libVMC");
52
53   if (useParFiles)
54     setupPar("ESD");
55   if (gSystem->Load("libESD")<0) {
56     cout << "Cannot load libESD.so . Exiting" << endl;
57     exit(0);
58   }
59
60   if (useParFiles)
61     setupPar("AOD");
62   if (gSystem->Load("libAOD")<0) {
63     cout << "Cannot load libAOD.so . Exiting" << endl;
64     exit(0);
65   }
66
67   if (useParFiles)
68     setupPar("ANALYSIS");
69   if (gSystem->Load("libANALYSIS")<0) {
70     cout << "Cannot load libANALYSIS.so . Exiting" << endl;
71     exit(0);
72   }
73
74   if (useParFiles)
75     setupPar("ANALYSISalice");
76   if (gSystem->Load("libANALYSISalice")<0) {
77     cout << "Cannot load libANALYSISalice.so . Exiting" << endl;
78     exit(0);
79   }
80   
81
82   //____________________________________________________//
83   //_____________Setting up PWGCFAOD.par_________________//
84
85   // if (usePWGCFParFiles)
86   //   setupPar("PWGCFAOD");
87   // if (gSystem->Load("libPWGCFAOD")<0) {
88   //   cout << "Cannot load libPWGCFAOD.so . Exiting" << endl;
89   //   exit(0);
90   // }
91   //____________________________________________________//
92   //_____________Setting up PWGCFfemtoscopy.par__________//
93   if (usePWGCFParFiles)
94     setupPar("PWGCFfemtoscopy");
95   if (gSystem->Load("libPWGCFfemtoscopy")<0) {
96     cout << "Cannot load libPWGCFfemtoscopy.so . Exiting" << endl;
97     exit(0);
98   }
99   //____________________________________________________//
100   //_____________Setting up PWGCFfemtoscopyUser.par______//
101     if (usePWGCFParFiles)
102     setupPar("PWGCFfemtoscopyUser");
103   if (gSystem->Load("libPWGCFfemtoscopyUser")<0) {
104     cout << "Cannot load libPWGCFfemtoscopyUser.so . Exiting" << endl;
105     exit(0);
106     }
107
108
109
110    cout <<"_____GetDynamicPath______\n " <<gSystem->GetDynamicPath() <<endl;  
111
112
113 //____________ include path
114    gSystem->AddIncludePath(Form("-I\"%s/include\"", gSystem->Getenv("ALICE_ROOT")));
115    gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT")));
116
117
118
119
120   
121   //_________________________________________________ 
122   //_______Create chain for Alien data collection __________
123   
124    const char *collectionfile="wn.xml";
125   
126   //____________________________________________//
127   //Usage of event tags
128   // AliTagAnalysis *analysis = new AliTagAnalysis();
129   // TChain *chain = 0x0;
130   // chain = analysis->CreateChainFromCollection(collectionfile,"esdTree");
131
132   // gROOT->LoadMacro("./CreateESDChain.C");
133   // const char* chainlistfile = "./list.ESD.txt";
134   // chain = CreateESDChain(chainlistfile,500);
135
136   TChain *chain = new TChain("aodTree");
137   //chain->Add("../Data/LHC10h/AOD/139465/AliAOD.root");
138   ifstream *istr = new ifstream(collectionfile);
139
140   char fname[2000];
141   char pname[2000];
142   while (!istr->eof()) {
143     fname[0] = '\0';
144     (*istr) >> fname;
145     if (strlen(fname) > 10) {
146       sprintf(pname, "alien://%s", fname);
147       chain->Add(pname);
148     }
149     }
150   
151
152 /*
153 //__________________________________________________
154 //___________Create chain for Local data files ____________
155
156   gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
157   TChain* chain = CreateESDChain("files.txt", 2);
158 */
159
160
161
162   //___________ Analysis  __________________________
163
164   //______ Make the analysis manager
165   AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
166
167   //______ Set ESD InputHandler
168   AliAODInputHandler* aodH = new AliAODInputHandler;
169   mgr->SetInputEventHandler(aodH);
170
171   //AliESDInputHandler* esdH = new AliESDInputHandler;
172   //mgr->SetInputEventHandler(esdH);
173   
174   //______ Set MC EventHandler
175   //AliMCEventHandler *mcH = new AliMCEventHandler;
176   //mgr->SetMCtruthEventHandler(mcH);
177
178   //______ Set Print Debug Level
179   mgr->SetDebugLevel(0);  //0, 1, 2, 3 ...
180   
181   
182
183   //AddTaskPIDResponse
184   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
185   AliAnalysisTaskSE *pidresponse = AddTaskPIDResponse(kTRUE,kFALSE);
186
187                                                                            
188    //gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
189    //AliCentralitySelectionTask *centrality = AddTaskCentrality();
190
191   //________AddTaskFemto_______________
192     gROOT->LoadMacro("AddTaskFemto.C");
193   AliAnalysisTaskFemto *taskfemto = AddTaskFemto("ConfigFemtoAnalysis.C");
194   taskfemto->SelectCollisionCandidates(AliVEvent::kCentral|AliVEvent::kSemiCentral|AliVEvent::kMB);
195   //taskfemto->SelectCollisionCandidates(AliVEvent::kMB);
196
197   //____________________________________________//
198   // Run the analysis
199   if (!mgr->InitAnalysis()) return;
200   mgr->PrintStatus();
201   mgr->StartAnalysis("local",chain);
202
203   timer.Stop();
204   timer.Print();
205 }
206
207
208 //*********************************************
209 //____________________________________________
210 Int_t setupPar(const char* pararchivename) {
211   ///////////////////
212   // Setup PAR File//
213   ///////////////////
214   if (pararchivename) {
215     char processline[1024];
216     sprintf(processline,".! tar xvzf %s.par",pararchivename);
217     gROOT->ProcessLine(processline);
218     const char* ocwd = gSystem->WorkingDirectory();
219     gSystem->ChangeDirectory(pararchivename);
220
221     // check for BUILD.sh and execute
222     if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
223       printf("*******************************\n");
224       printf("*** Building PAR archive    ***\n");
225       printf("*******************************\n");
226
227       if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
228         Error("runProcess","Cannot Build the PAR Archive! - Abort!");
229         return -1;
230       }
231     }
232     // check for SETUP.C and execute
233     if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
234       printf("*******************************\n");
235       printf("*** Setup PAR archive       ***\n");
236       printf("*******************************\n");
237       gROOT->Macro("PROOF-INF/SETUP.C");
238     }
239     
240     gSystem->ChangeDirectory("../");
241   }
242
243   return 1;
244 }