TENDER becomes Tender, removing .so
[u/mrichter/AliRoot.git] / PWGGA / CaloTrackCorrelations / macros / ana.C
CommitLineData
d92b41ad 1/* $Id: $ */
d92b41ad 2//--------------------------------------------------
3// Example macro to do analysis with the
745913ae 4// analysis classes in CaloTrackCorrelations
d92b41ad 5// Can be executed with Root and AliRoot
6//
7// Pay attention to the options and definitions
8// set in the lines below
9//
10// Author : Gustavo Conesa Balbastre (INFN-LNF)
11//
12//-------------------------------------------------
3c867778 13enum anaModes {mLocal=0, mPROOF=1, mPlugin=2, mGRID=3};
2244659d 14//mLocal = 0: Analyze locally files in your computer
3c867778 15//mPROOF = 1: Analyze files on GRID with Plugin
16//mPlugin = 2: Analyze files on GRID with Plugin
17//mGRID = 3: Analyze files on GRID, jobs launched from aliensh
d92b41ad 18
19//---------------------------------------------------------------------------
3c867778 20// Settings to read locally several files, only for "mLocal" mode
21// The different values are default, they can be set with environmental
22// variables: INDIR, PATTERN, NFILES, respectivelly
54769bc0 23
3c867778 24char * kInDir = "/user/data/files/";
3e0577a2 25char * kPattern = ""; // Data are in files kInDir/kPattern+i
ac0610dc 26Int_t kFile = 2;
3c867778 27
d92b41ad 28//---------------------------------------------------------------------------
3c867778 29// Dataset for proof analysis, mode=mPROOF
30// char * kDataset = "/alice/vernet/PbPb_LHC10h_ESD";
31
32char * kDatasetPROOF = "/alice/vernet/LHC11b_149646";
3c867778 33Int_t kDatasetNMaxFiles = 20;
34TString ccin2p3UserName = "arbor" ;
35TString alienUserName = "narbor" ;
36
37//---------------------------------------------------------------------------
38// Collection file for grid analysis
39
d92b41ad 40char * kXML = "collection.xml";
3c867778 41
d92b41ad 42//---------------------------------------------------------------------------
43//Scale histograms from file. Change to kTRUE when xsection file exists
44//Put name of file containing xsection
45//Put number of events per ESD file
46//This is an specific case for normalization of Pythia files.
d92b41ad 47const char * kXSFileName = "pyxsec.root";
54769bc0 48
d92b41ad 49//---------------------------------------------------------------------------
50
193828fd 51//Set some default values, but used values are set in the code!
52
3c867778 53Bool_t kMC = kFALSE; //With real data kMC = kFALSE
193828fd 54TString kInputData = "ESD"; //ESD, AOD, MC, deltaAOD
3c867778 55Int_t kYear = 2011;
193828fd 56TString kCollision = "pp";
dc028d0b 57Bool_t outAOD = kFALSE; //Some tasks doesnt need it.
2244659d 58TString kTreeName;
3c867778 59TString kPass = "";
193828fd 60char kTrigger[1024];
3c867778 61Int_t kRun = 0;
7175a03a 62
3c867778 63//________________________
193828fd 64void ana(Int_t mode=mGRID)
d92b41ad 65{
66 // Main
cd54ca47 67
d92b41ad 68 //--------------------------------------------------------------------
69 // Load analysis libraries
70 // Look at the method below,
71 // change whatever you need for your analysis case
72 // ------------------------------------------------------------------
193828fd 73
3c867778 74 LoadLibraries(mode) ;
193828fd 75 //gSystem->ListLibraries();
2244659d 76
d92b41ad 77 //-------------------------------------------------------------------------------------------------
78 //Create chain from ESD and from cross sections files, look below for options.
c8fe2783 79 //-------------------------------------------------------------------------------------------------
54769bc0 80
193828fd 81 // Set kInputData and kTreeName looking to the kINDIR
cd54ca47 82
193828fd 83 CheckInputData(mode);
cd54ca47 84
193828fd 85 // Check global analysis settings
cd54ca47 86
193828fd 87 CheckEnvironmentVariables();
88
89 printf("*********************************************\n");
90 printf("*** Input data < %s >, pass %s, tree < %s >, MC? < %d > ***\n",kInputData.Data(),kPass.Data(),kTreeName.Data(),kMC);
91 printf("*********************************************\n");
2244659d 92
193828fd 93 TChain * chain = new TChain(kTreeName) ;
d92b41ad 94 TChain * chainxs = new TChain("Xsection") ;
193828fd 95 CreateChain(mode, chain, chainxs);
54769bc0 96
ac0610dc 97 Double_t scale = -1;
98 printf("===== kMC %d, chainxs %p\n",kMC,chainxs);
99 if(kMC && chainxs && chainxs->GetEntries() > 0)
100 {
101 Int_t nfiles = chainxs->GetEntries();
102
103 //Get the cross section
104 Double_t xsection = 0;
105 Float_t ntrials = 0;
106
107 GetAverageXsection(chainxs, xsection, ntrials);
108
1806f9c0 109 Int_t nEventsPerFile = chain->GetEntries() / nfiles;
110
111 Double_t trials = ntrials / nEventsPerFile ;
112
113 scale = xsection/trials;
114
115 printf("Get Cross section : nfiles %d, nevents %d, nevents per file %d \n",nfiles, chain->GetEntries(),nEventsPerFile);
116 printf(" ntrials %d, trials %2.2f, xs %2.2e, scale factor %2.2e\n", ntrials,trials,xsection,scale);
ac0610dc 117
ac0610dc 118 }
119
193828fd 120 printf("*********************************************\n");
121 printf("number of entries # %lld, skipped %d\n", chain->GetEntries()) ;
122 printf("*********************************************\n");
123
3c867778 124 if(!chain)
125 {
193828fd 126 printf("STOP, no chain available\n");
127 return;
128 }
129
130 AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
cd54ca47 131
15882d9f 132 //------------------------------------------
133 // Alien handler part
134 //------------------------------------------
135 AliAnalysisGrid *alienHandler=0x0;
3c867778 136 if(mode==mPlugin)
137 {
15882d9f 138 // Create and configure the alien handler plugin
139 gROOT->LoadMacro("CreateAlienHandler.C");
140 alienHandler = CreateAlienHandler();
141 if (!alienHandler) return;
142 }
143
193828fd 144 //--------------------------------------
145 // Make the analysis manager
146 //-------------------------------------
147 AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
148 //AliAnalysisManager::SetUseProgressBar(kTRUE);
149 //mgr->SetSkipTerminate(kTRUE);
150 //mgr->SetNSysInfo(1);
151
3c867778 152 if(mode==mPlugin)
153 {
15882d9f 154 // Connect plugin to the analysis manager
155 mgr->SetGridHandler(alienHandler);
156 }
157
193828fd 158 // MC handler
3c867778 159 if((kMC || kInputData == "MC") && !kInputData.Contains("AOD"))
160 {
193828fd 161 AliMCEventHandler* mcHandler = new AliMCEventHandler();
162 mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
163 mgr->SetMCtruthEventHandler(mcHandler);
3c867778 164 if( kInputData == "MC")
165 {
193828fd 166 cout<<"MC INPUT EVENT HANDLER"<<endl;
167 mgr->SetInputEventHandler(NULL);
d92b41ad 168 }
193828fd 169 }
170
745913ae 171
193828fd 172 // AOD output handler
3c867778 173 if(kInputData!="deltaAOD" && outAOD)
174 {
193828fd 175 cout<<"Init output handler"<<endl;
176 AliAODHandler* aodoutHandler = new AliAODHandler();
177 aodoutHandler->SetOutputFileName("aod.root");
178 ////aodoutHandler->SetCreateNonStandardAOD();
179 mgr->SetOutputEventHandler(aodoutHandler);
180 }
181
182 //input
183
3c867778 184 if(kInputData == "ESD")
185 {
193828fd 186 // ESD handler
187 AliESDInputHandler *esdHandler = new AliESDInputHandler();
188 esdHandler->SetReadFriends(kFALSE);
189 mgr->SetInputEventHandler(esdHandler);
190 cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
191 }
3c867778 192 else if(kInputData.Contains("AOD"))
193 {
193828fd 194 // AOD handler
195 AliAODInputHandler *aodHandler = new AliAODInputHandler();
196 mgr->SetInputEventHandler(aodHandler);
745913ae 197 if(kInputData == "deltaAOD") aodHandler->AddFriend("deltaAODCaloTrackCorr.root");
193828fd 198 cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
199 }
023e6936 200
745913ae 201 //mgr->RegisterExternalFile("deltaAODCaloTrackCorr.root");
193828fd 202 //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
203
204 TString outputFile = AliAnalysisManager::GetCommonFileName();
205
206 //-------------------------------------------------------------------------
531f682d 207 // Define task, put here any other task that you want to use.
193828fd 208 //-------------------------------------------------------------------------
209
210 // Physics selection
e9de0d57 211 if(kInputData=="ESD")
212 {
213 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
214 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC);
215 }
193828fd 216
217 // Centrality
740c3286 218 if(kCollision=="PbPb" && kInputData=="ESD")
3c867778 219 {
2c18833a 220 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
221 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
2c18833a 222 }
193828fd 223
740c3286 224 if(kCollision=="PbPb")
225 {
226 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C");
227 AliVZEROEPSelectionTask * EPV0 = AddTaskVZEROEPSelection();
228
229 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
230 AliEPSelectionTask * EP = AddTaskEventplane();
231 }
232
193828fd 233 // Simple event counting tasks
740c3286 234
235 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros/AddTaskCounter.C");
236
3240657f 237 AliAnalysisTask* count = AddTaskCounter(""); // All
740c3286 238 AliAnalysisTask* countmb = AddTaskCounter("MB"); // Min Bias
3240657f 239 AliAnalysisTask* countany = AddTaskCounter("Any");
240 AliAnalysisTask* countint = AddTaskCounter("AnyINT");// Min Bias
241
3c867778 242 if(!kMC)
243 {
740c3286 244 AliAnalysisTaskCounter* countemg = AddTaskCounter("EMCEGA");
245 AliAnalysisTaskCounter* countemj = AddTaskCounter("EMCEJE");
531f682d 246 if(kCollision=="PbPb")
247 {
740c3286 248 AliAnalysisTaskCounter* countcen = AddTaskCounter("Central");
249 AliAnalysisTaskCounter* countsce = AddTaskCounter("SemiCentral");
250 AliAnalysisTaskCounter* countssce= AddTaskCounter("SemiOrCentral");
251 AliAnalysisTaskCounter* countphP = AddTaskCounter("PHOSPb");
531f682d 252 }
740c3286 253 else
254 {
255 AliAnalysisTaskCounter* countem1 = AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
256 AliAnalysisTaskCounter* countem7 = AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
257 AliAnalysisTaskCounter* countphp = AddTaskCounter("PHOS");
258 }
259 }
745913ae 260 // -----------------
261 // Photon conversion
262 // -----------------
263/*
264 if(kInputData=="ESD"){
265 printf("* Configure photon conversion analysis in macro \n");
266 TString arguments = "-run-on-train -use-own-xyz -force-aod -mc-off ";
531f682d 267 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
745913ae 268 AliAnalysisTaskGammaConversion * taskGammaConversion =
269 ConfigGammaConversion(arguments,mgr->GetCommonInputContainer());
270 taskGammaConversion->SelectCollisionCandidates();
271
272 // Gamma Conversion AOD to AODPWG4Particle
273 AliAnalysisTaskGCPartToPWG4Part * taskGCToPC = new AliAnalysisTaskGCPartToPWG4Part("GCPartToPWG4Part");
274 taskGCToPC->SetGammaCutId("90035620401003321022000000090");
275 mgr->AddTask(taskGCToPC);
276 mgr->ConnectInput (taskGCToPC, 0, mgr->GetCommonInputContainer() );
277 mgr->ConnectOutput (taskGCToPC, 0, mgr->GetCommonOutputContainer());
278 }
279*/
3c867778 280
193828fd 281 Bool_t kPrint = kFALSE;
282 Bool_t deltaAOD = kFALSE;
5fdef45d 283 gROOT->LoadMacro("AddTaskCaloTrackCorr.C"); // $ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros
531f682d 284 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALClusterize.C"); // $ALICE_ROOT/PWGGA/EMCALTasks/macros
15882d9f 285
ac0610dc 286 //gROOT->LoadMacro("$ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
287 //AliAnalysisTaskCaloTrackCorrelation * qatask = AddTaskCalorimeterQA(kInputData,kYear,kPrint,kMC);
193828fd 288
dc028d0b 289 //gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALTriggerQA.C");
290 //AliAnalysisTaskEMCALTriggerQA * qatrigtask = AddTaskEMCALTriggerQA();
291
023e6936 292 // Calibration, bad map ...
293
1806f9c0 294 Bool_t calibEE = kTRUE; // It is set automatically, but here we force to use it or not in any case
295 Bool_t calibTT = kTRUE; // It is set automatically, but here we force to use it or not in any case
ac0610dc 296 if(kRun < 122195 || (kRun > 126437 && kRun < 136851) || kMC) calibTT=kFALSE ; // Recalibration parameters not available for LHC10a,b,c,e,f,g
1806f9c0 297 Bool_t badMap = kTRUE; // It is set automatically, but here we force to use it or not in any case
023e6936 298
531f682d 299 if(kCollision=="pp")
193828fd 300 {
531f682d 301 printf("==================================== \n");
302 printf("CONFIGURE ANALYSIS FOR PP COLLISIONS \n");
303 printf("==================================== \n");
cd54ca47 304
740c3286 305 Bool_t mixing = kTRUE; // mixing in reader and hadron correlation, and pi0
531f682d 306 Bool_t clTM = kTRUE;
307 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
308 Bool_t anTM = kTRUE; // Remove matched
309 Bool_t exo = kTRUE; // Remove exotic cells
e9de0d57 310 Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
531f682d 311 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
312 Int_t minEcell = 50; // 50 MeV (10 MeV used in reconstruction)
313 Int_t minEseed = 100; // 100 MeV
314 Int_t dTime = 0; // default, 250 ns
ac0610dc 315 Int_t wTime = 30; // default 425 < T < 825 ns, careful if time calibration is on
d7d24d99 316 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
317 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
318
023e6936 319 //Trigger
ac0610dc 320 TString clTrigger = "";
023e6936 321 TString anTrigger = "EMC7";
ac0610dc 322
531f682d 323 if(kMC)
324 {
ac0610dc 325 clTrigger = "";
326 anTrigger = "";
6c4dd754 327 dTime = 0;
328 wTime = 0;
531f682d 329 }
54769bc0 330
531f682d 331 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
332 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
333 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
cd54ca47 334
531f682d 335 //Analysis with clusterizer V1
3c867778 336
531f682d 337 TString arrayNameV1 = "";
ac0610dc 338
dc028d0b 339 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
d7d24d99 340 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
e9de0d57 341 calibEE,badMap,calibTT,clnonlin);
54769bc0 342
531f682d 343 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
344
ac0610dc 345 if(!kMC)
346 {
347
348 AliAnalysisTaskCaloTrackCorrelation *anav1trig = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 349 kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
ec551ef4 350 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
ac0610dc 351 }
352
353 AliAnalysisTaskCaloTrackCorrelation *anav1mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 354 kYear,kCollision,"AnyINT",arrayNameV1,mixing,reTM,anTM,
ec551ef4 355 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
ac0610dc 356
357
531f682d 358
359 //Analysis with clusterizer V2
360 TString arrayNameV2 = "";
dc028d0b 361 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
ac0610dc 362 minEcell,minEseed,dTime,wTime,
e9de0d57 363 calibEE,badMap,calibTT,clnonlin);
ac0610dc 364
531f682d 365 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
366
367 hadron = kFALSE;
ac0610dc 368 if(!kMC)
369 {
370
371
372 AliAnalysisTaskCaloTrackCorrelation *anav2tr = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 373 kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
ec551ef4 374 -1,-1,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
ac0610dc 375 }
376
377
378 AliAnalysisTaskCaloTrackCorrelation *anav2mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 379 kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
ec551ef4 380 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
531f682d 381 }
ac0610dc 382
531f682d 383 if(kCollision=="PbPb")
3c867778 384 {
531f682d 385 printf("====================================== \n");
386 printf("CONFIGURE ANALYSIS FOR PbPb COLLISIONS \n");
387 printf("====================================== \n");
740c3286 388 Bool_t mixing = kTRUE;
531f682d 389 Bool_t clTM = kTRUE;
390 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
391 Bool_t anTM = kTRUE; // Remove matched
392 Bool_t exo = kTRUE; // Remove exotic cells
e9de0d57 393 Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
531f682d 394 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
dc028d0b 395 Int_t minEcell = 150; // 50 MeV (10 MeV used in reconstruction)
396 Int_t minEseed = 300; // 100 MeV
531f682d 397 Int_t dTime = 0; // default, 250 ns
398 Int_t wTime = 0; // default 425 < T < 825 ns
d7d24d99 399 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
400 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
ac0610dc 401
023e6936 402 // Trigger
ac0610dc 403 TString clTrigger = "";
531f682d 404 TString anTrigger = "EMCGA";
405 if(kMC)
406 {
407 clTrigger = "";
408 anTrigger = "";
6c4dd754 409 dTime = 0;
410 wTime = 0;
531f682d 411 }
3c867778 412
531f682d 413 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
414 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
415 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
3c867778 416
531f682d 417 //Analysis with clusterizer V1
3c867778 418
531f682d 419 TString arrayNameV1 = "";
dc028d0b 420 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
d7d24d99 421 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
e9de0d57 422 calibEE,badMap,calibTT,clnonlin);
3c867778 423
531f682d 424 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
425
dc028d0b 426 if(!kMC)
427 {
428 AliAnalysisTaskCaloTrackCorrelation *anav1c = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 429 kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
ec551ef4 430 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
dc028d0b 431 AliAnalysisTaskCaloTrackCorrelation *anav1m = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 432 kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
ec551ef4 433 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
dc028d0b 434 AliAnalysisTaskCaloTrackCorrelation *anav1p = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 435 kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
ec551ef4 436 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
dc028d0b 437 }
ac0610dc 438
531f682d 439 //Analysis with clusterizer V2
ac0610dc 440
531f682d 441 TString arrayNameV2 = "";
dc028d0b 442 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
d7d24d99 443 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
e9de0d57 444 calibEE,badMap,calibTT,clnonlin);
531f682d 445
446 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
447
448 hadron = kFALSE;
449
ac0610dc 450 if(!kMC)
451 {
452
453 AliAnalysisTaskCaloTrackCorrelation *anav2cT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 454 kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
ec551ef4 455 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
ac0610dc 456 AliAnalysisTaskCaloTrackCorrelation *anav2mT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 457 kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
ec551ef4 458 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
ac0610dc 459 AliAnalysisTaskCaloTrackCorrelation *anav2pT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 460 kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
ec551ef4 461 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
ac0610dc 462 }
463
464 AliAnalysisTaskCaloTrackCorrelation *anav2cMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 465 kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
ec551ef4 466 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
ac0610dc 467 AliAnalysisTaskCaloTrackCorrelation *anav2mMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 468 kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
ec551ef4 469 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
ac0610dc 470 AliAnalysisTaskCaloTrackCorrelation *anav2pMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
740c3286 471 kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
ec551ef4 472 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
ac0610dc 473
474
531f682d 475 }
476
ac0610dc 477
478
193828fd 479 //-----------------------
480 // Run the analysis
481 //-----------------------
482 mgr->InitAnalysis();
483 mgr->PrintStatus();
193828fd 484
3c867778 485 if (mode == mPlugin) mgr->StartAnalysis("grid");
486 else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
487 else mgr->StartAnalysis("local",chain);
193828fd 488
3c867778 489 cout <<" Analysis ended sucessfully "<< endl ;
d92b41ad 490
491}
492
3c867778 493//_____________________________
494void LoadLibraries(Int_t mode)
193828fd 495{
d92b41ad 496
3c867778 497 if (mode == mPROOF) {
498 //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
499 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
dce3a2ba 500 TProof* proof = EnableAliRootForLAF("ccaplmaster",nPROOFWorkers.Data(),ccin2p3UserName.Data(),alienUserName.Data(),"",kFALSE,kTRUE,kTRUE,"OADB:ANALYSIS:ANALYSISalice:AOD:ESD:CORRFW:STEERBase:EMCALUtils:PHOSUtils:PWGCaloTrackCorrBase:PWGGACaloTrackCorrelations:PWGEMCAL:PWGGAEMCALTasks");
3c867778 501
502 // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
503
504 // //proof->ClearPackages();
505 // proof->UploadPackage("STEERBase");
506 // proof->UploadPackage("ESD");
507 // proof->UploadPackage("AOD");
508 // proof->UploadPackage("ANALYSIS");
509 // proof->UploadPackage("OADB");
510 // proof->UploadPackage("ANALYSISalice");
511 // proof->UploadPackage("CORRFW");
512 // //proof->UploadPackage("JETAN");
513 // proof->UploadPackage("PHOSUtils");
514 // proof->UploadPackage("EMCALUtils");
531f682d 515 // proof->UploadPackage("PWGCaloTrackCorrBase");
5fdef45d 516 // proof->UploadPackage("PWGGACaloTrackCorrelations");
dce3a2ba 517 // proof->UploadPackage("PWGEMCAL");
5fdef45d 518 // proof->UploadPackage("PWGGAEMCALTasks");
3c867778 519
520 // proof->EnablePackage("STEERBase");
521 // proof->EnablePackage("ESD");
522 // proof->EnablePackage("AOD");
523 // proof->EnablePackage("ANALYSIS");
524 // proof->EnablePackage("OADB");
525 // proof->EnablePackage("ANALYSISalice");
526 // proof->EnablePackage("CORRFW");
527 // //proof->EnablePackage("JETAN");
528 // proof->EnablePackage("PHOSUtils");
529 // proof->EnablePackage("EMCALUtils");
531f682d 530 // proof->EnablePackage("PWGCaloTrackCorrBase");
5fdef45d 531 // proof->EnablePackage("PWGGACaloTrackCorrelations");
dce3a2ba 532 // proof->EnablePackage("PWGEMCAL");
5fdef45d 533 // proof->EnablePackage("PWGGAEMCALTasks");
3c867778 534 return;
535 }
536
d92b41ad 537 //--------------------------------------
538 // Load the needed libraries most of them already loaded by aliroot
539 //--------------------------------------
230b7aff 540 gSystem->Load("libTree");
541 gSystem->Load("libGeom");
542 gSystem->Load("libVMC");
543 gSystem->Load("libXMLIO");
544 gSystem->Load("libMatrix");
545 gSystem->Load("libPhysics");
546 gSystem->Load("libMinuit"); // Root + libraries to if reclusterization is done
547
548 gSystem->Load("libSTEERBase");
549 gSystem->Load("libGui"); // Root + libraries to if reclusterization is done
550 gSystem->Load("libCDB"); // Root + libraries to if reclusterization is done
551 gSystem->Load("libESD"); // Root + libraries to if reclusterization is done
552 gSystem->Load("libAOD");
553 gSystem->Load("libRAWDatabase"); // Root + libraries to if reclusterization is done
554 gSystem->Load("libProof");
531f682d 555 gSystem->Load("libOADB");
230b7aff 556 gSystem->Load("libANALYSIS");
557 gSystem->Load("libSTEER"); // Root + libraries to if reclusterization is done
193828fd 558
230b7aff 559 gSystem->Load("libRAWDatarec"); // Root + libraries to if reclusterization is done
560 gSystem->Load("libRAWDatasim"); // Root + libraries to if reclusterization is done
561 gSystem->Load("libVZERObase"); // Root + libraries to if reclusterization is done
562 gSystem->Load("libVZEROrec"); // Root + libraries to if reclusterization is done
35006d47 563
564 gSystem->Load("libPHOSUtils");
565
193828fd 566 gSystem->Load("libEMCALUtils");
567 //SetupPar("EMCALUtils");
568 gSystem->Load("libEMCALraw"); // Root + libraries to if reclusterization is done
569 gSystem->Load("libEMCALbase"); // Root + libraries to if reclusterization is done
570 gSystem->Load("libEMCALsim"); // Root + libraries to if reclusterization is done
571 gSystem->Load("libEMCALrec"); // Root + libraries to if reclusterization is done
572 //SetupPar("EMCALraw");
573 //SetupPar("EMCALbase");
574 //SetupPar("EMCALsim");
575 //SetupPar("EMCALrec");
576
230b7aff 577 gSystem->Load("libANALYSISalice");
578 gSystem->Load("libESDfilter");
35006d47 579
230b7aff 580 gSystem->Load("libTender");
581 gSystem->Load("libTenderSupplies");
35006d47 582
69a70c5d 583 gSystem->Load("libCORRFW");
584 gSystem->Load("libPWGTools");
35006d47 585
dce3a2ba 586 gSystem->Load("libPWGEMCAL");
5fdef45d 587 gSystem->Load("libPWGGAEMCALTasks");
dce3a2ba 588 //SetupPar("PWGEMCAL");
5fdef45d 589 //SetupPar("PWGGAEMCALTasks");
15882d9f 590
35006d47 591 gSystem->Load("libPWGCaloTrackCorrBase");
592 gSystem->Load("libPWGGACaloTrackCorrelations");
593 //SetupPar("PWGCaloTrackCorrBase");
594 //SetupPar("PWGGACaloTrackCorrelations");
531f682d 595
15882d9f 596 //gSystem->Load("libJETAN");
597 //gSystem->Load("FASTJETAN");
5fdef45d 598 //gSystem->Load("PWGJE");
745913ae 599
230b7aff 600 //gSystem->Load("libCORRFW");
601 //gSystem->Load("libPWGGAGammaConv");
5fdef45d 602 //SetupPar("PWGGAGammaConv");
15882d9f 603
604 // needed for plugin?
605 gSystem->AddIncludePath("-I$ALICE_ROOT");
606 gSystem->AddIncludePath("-I./");
607
d92b41ad 608}
609
3c867778 610//_________________________________
d92b41ad 611void SetupPar(char* pararchivename)
612{
613 //Load par files, create analysis libraries
614 //For testing, if par file already decompressed and modified
615 //classes then do not decompress.
193828fd 616
d92b41ad 617 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
618 TString parpar(Form("%s.par", pararchivename)) ;
193828fd 619
d92b41ad 620 if ( gSystem->AccessPathName(pararchivename) ) {
621 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
622 gROOT->ProcessLine(processline.Data());
623 }
624
625 TString ocwd = gSystem->WorkingDirectory();
626 gSystem->ChangeDirectory(pararchivename);
627
628 // check for BUILD.sh and execute
629 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
630 printf("*******************************\n");
631 printf("*** Building PAR archive ***\n");
632 cout<<pararchivename<<endl;
633 printf("*******************************\n");
634
635 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
636 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
637 return -1;
638 }
639 }
640 // check for SETUP.C and execute
641 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
642 printf("*******************************\n");
643 printf("*** Setup PAR archive ***\n");
644 cout<<pararchivename<<endl;
645 printf("*******************************\n");
646 gROOT->Macro("PROOF-INF/SETUP.C");
647 }
648
649 gSystem->ChangeDirectory(ocwd.Data());
650 printf("Current dir: %s\n", ocwd.Data());
651}
652
3c867778 653//______________________________________
654void CheckInputData(const anaModes mode)
655{
193828fd 656 //Sets input data and tree
657
658 TString ocwd = gSystem->WorkingDirectory();
659
660 //---------------------------------------
661 //Local files analysis
662 //---------------------------------------
663 if(mode == mLocal){
664 //If you want to add several ESD files sitting in a common directory INDIR
665 //Specify as environmental variables the directory (INDIR), the number of files
666 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
cd54ca47 667
193828fd 668 if(gSystem->Getenv("INDIR"))
669 kInDir = gSystem->Getenv("INDIR") ;
670 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
671
672 TString sindir(kInDir);
673 if (sindir.Contains("pass1")) kPass = "pass1";
674 else if(sindir.Contains("pass2")) kPass = "pass2";
675 else if(sindir.Contains("pass3")) kPass = "pass3";
676
677 if(gSystem->Getenv("PATTERN"))
678 kPattern = gSystem->Getenv("PATTERN") ;
679 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
680
681 cout<<"INDIR : "<<kInDir<<endl;
682 cout<<"NFILES : "<<kFile<<endl;
683
684 char fileE[120] ;
685 char fileA[120] ;
686 char fileG[120] ;
687 char fileEm[120] ;
688 for (Int_t event = 0 ; event < kFile ; event++) {
3c867778 689 sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
690 sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
691 sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
193828fd 692 sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
693
5eef1db1 694 TFile * fESD = TFile::Open(fileE) ;
695 TFile * fAOD = TFile::Open(fileA) ;
696
193828fd 697 //Check if file exists and add it, if not skip it
3c867778 698 if (fESD)
699 {
700 kTreeName = "esdTree";
193828fd 701 kInputData = "ESD";
5eef1db1 702 TFile * fG = TFile::Open(fileG);
703 if(fG) { kMC = kTRUE; fG->Close();}
704 else kMC = kFALSE;
705
706 // Get run number
707 TTree* esdTree = (TTree*)fESD->Get("esdTree");
708 AliESDEvent* esd = new AliESDEvent();
709 esd->ReadFromTree(esdTree);
710 esdTree->GetEvent(0);
711 kRun = esd->GetRunNumber();
712
193828fd 713 return;
714 }
3c867778 715 else if(fAOD)
716 {
717 kTreeName = "aodTree";
193828fd 718 kInputData = "AOD";
719 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
720 else kMC = kFALSE;
5eef1db1 721
722 // Get run number
723 TTree* aodTree = (TTree*)fAOD->Get("aodTree");
724 AliAODEvent* aod = new AliAODEvent();
0fb69ade 725 aod->ReadFromTree(aodTree);
5eef1db1 726 aodTree->GetEvent(0);
727 kRun = aod->GetRunNumber();
193828fd 728 return;
729 }
3c867778 730 else if(TFile::Open(fileEm))
731 {
5eef1db1 732 kTreeName = "aodTree";
193828fd 733 kInputData = "AOD";
5eef1db1 734 kMC = kTRUE;
735
193828fd 736 return;
737 }
3c867778 738 else if(TFile::Open(fileG))
739 {
5eef1db1 740 kTreeName = "TE";
193828fd 741 kInputData = "MC";
5eef1db1 742 kMC = kTRUE;
193828fd 743 return;
744 }
745 }
746
5eef1db1 747 if(fESD) fESD->Close();
748 if(fAOD) fAOD->Close();
749
193828fd 750 }// local files analysis
751
752 //------------------------------
753 //GRID xml files
754 //-----------------------------
755 else if(mode == mGRID){
756 //Get colection file. It is specified by the environmental
757 //variable XML
758
759 if(gSystem->Getenv("XML") )
760 kXML = gSystem->Getenv("XML");
761 else
762 sprintf(kXML, "collection.xml") ;
763
764 if (!TFile::Open(kXML)) {
765 printf("No collection file with name -- %s -- was found\n",kXML);
766 return ;
767 }
768 else cout<<"XML file "<<kXML<<endl;
769
770 //Load necessary libraries and connect to the GRID
230b7aff 771 gSystem->Load("libNetx") ;
772 gSystem->Load("libRAliEn");
193828fd 773 TGrid::Connect("alien://") ;
774
775 //Feed Grid with collection file
776 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
777 if (! collection) {
778 AliError(Form("%s not found", kXML)) ;
779 return kFALSE ;
780 }
781 TGridResult* result = collection->GetGridResult("",0 ,0);
782
783 for (Int_t index = 0; index < result->GetEntries(); index++) {
784 TString alienURL = result->GetKey(index, "turl") ;
785 cout << "================== " << alienURL << endl ;
786
787 if (alienURL.Contains("pass1")) kPass = "pass1";
788 else if(alienURL.Contains("pass2")) kPass = "pass2";
789 else if(alienURL.Contains("pass3")) kPass = "pass3";
790
3c867778 791 kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
792 printf("Run number from alien path = %d\n",kRun);
793
193828fd 794 TFile * fAOD = 0 ;
795 //Check if file exists and add it, if not skip it
3c867778 796 if (alienURL.Contains("AliESDs.root"))
797 {
798 kTreeName = "esdTree";
193828fd 799 kInputData = "ESD";
800 alienURL.ReplaceAll("AliESDs.root","galice.root");
801 if(TFile::Open(alienURL)) kMC=kTRUE;
802 else kMC = kFALSE;
193828fd 803 return;
804 }
3c867778 805 else if(alienURL.Contains("AliAOD.root"))
806 {
807 kTreeName = "aodTree";
193828fd 808 kInputData = "AOD";
809 fAOD = TFile::Open(alienURL);
810 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
811 else kMC = kFALSE;
812 return;
813 }
3c867778 814 else if(alienURL.Contains("embededAOD.root"))
815 {
816 kTreeName = "aodTree";
193828fd 817 kInputData = "AOD";
818 kMC=kTRUE;
819 return;
820 }
3c867778 821 else if(alienURL.Contains("galice.root"))
822 {
823 kTreeName = "TE";
193828fd 824 kInputData = "MC";
825 kMC=kTRUE;
826 return;
827 }
828 }
829 }// xml analysis
3c867778 830 //------------------------------
831 //PROOF files
832 //-----------------------------
833 else if(mode == mPROOF){
834
835 TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
836
837 TIter iter(coll->GetList());
838
839 TFileInfo* fileInfo = 0;
840 while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
841 {
842 if (fileInfo->GetFirstUrl()) {
843 TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
844 cout << "================== " << ProofURL << endl ;
845
846 if (ProofURL.Contains("pass1")) kPass = "pass1";
847 else if(ProofURL.Contains("pass2")) kPass = "pass2";
848 else if(ProofURL.Contains("pass3")) kPass = "pass3";
849
850 kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
851 printf("Run number from alien path = %d\n",kRun);
852
853 TFile * fAOD = 0 ;
854 //Check if file exists and add it, if not skip it
855 if (ProofURL.Contains("AliESDs.root"))
856 {
857 kTreeName = "esdTree";
858 kInputData = "ESD";
859 alienURL.ReplaceAll("AliESDs.root","galice.root");
860 if(TFile::Open(ProofURL)) kMC=kTRUE;
861 else kMC = kFALSE;
862
863 return;
864 }
865 else if(ProofURL.Contains("AliAOD.root"))
866 {
867 kTreeName = "aodTree";
868 kInputData = "AOD";
869 fAOD = TFile::Open(ProofURL);
870 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
871 else kMC = kFALSE;
872 return;
873 }
874 else if(ProofURL.Contains("embededAOD.root"))
875 {
876 kTreeName = "aodTree";
877 kInputData = "AOD";
878 kMC=kTRUE;
879 return;
880 }
881 else if(ProofURL.Contains("galice.root"))
882 {
883 kTreeName = "TE";
884 kInputData = "MC";
885 kMC=kTRUE;
886 return;
887 }
888 }
889 }
890 }// proof analysis
193828fd 891
892 gSystem->ChangeDirectory(ocwd.Data());
893
894}
d92b41ad 895
193828fd 896//_____________________________________________________________________
897void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
898{
d92b41ad 899 //Fills chain with data
900 TString ocwd = gSystem->WorkingDirectory();
901
d92b41ad 902 //---------------------------------------
3c867778 903 // Local files analysis
d92b41ad 904 //---------------------------------------
2244659d 905 if(mode == mLocal){
d92b41ad 906 //If you want to add several ESD files sitting in a common directory INDIR
907 //Specify as environmental variables the directory (INDIR), the number of files
c8fe2783 908 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
193828fd 909
d92b41ad 910 if(gSystem->Getenv("INDIR"))
911 kInDir = gSystem->Getenv("INDIR") ;
912 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
913
914 if(gSystem->Getenv("PATTERN"))
915 kPattern = gSystem->Getenv("PATTERN") ;
916 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
917
c8fe2783 918 if(gSystem->Getenv("NFILES"))
919 kFile = atoi(gSystem->Getenv("NFILES")) ;
920 else cout<<"NFILES not set, use default: "<<kFile<<endl;
d92b41ad 921
922 //Check if env variables are set and are correct
c8fe2783 923 if ( kInDir && kFile) {
924 printf("Get %d files from directory %s\n",kFile,kInDir);
d92b41ad 925 if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
193828fd 926 printf("%s does not exist\n", kInDir) ;
927 return ;
d92b41ad 928 }
193828fd 929
c8fe2783 930 //if(gSystem->Getenv("XSFILE"))
931 //kXSFileName = gSystem->Getenv("XSFILE") ;
932 //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
933 char * kGener = gSystem->Getenv("GENER");
934 if(kGener) {
193828fd 935 cout<<"GENER "<<kGener<<endl;
3c867778 936 if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
193828fd 937 else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
938 else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
c8fe2783 939 }
940 else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
193828fd 941
3c867778 942 cout<<"INDIR : "<<kInDir <<endl;
943 cout<<"NFILES : "<<kFile <<endl;
944 cout<<"PATTERN : "<<kPattern <<endl;
c8fe2783 945 cout<<"XSFILE : "<<kXSFileName<<endl;
193828fd 946
7175a03a 947 TString datafile="";
3c867778 948 if (kInputData == "ESD") datafile = "AliESDs.root" ;
949 else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
950 else if(kInputData == "MC") datafile = "galice.root" ;
7175a03a 951
5eef1db1 952 //Loop on ESD/AOD/MC files, add them to chain
d92b41ad 953 Int_t event =0;
954 Int_t skipped=0 ;
955 char file[120] ;
956 char filexs[120] ;
957
c8fe2783 958 for (event = 0 ; event < kFile ; event++) {
3c867778 959 sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
193828fd 960 sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
5eef1db1 961 TFile * fData = 0 ;
193828fd 962 //Check if file exists and add it, if not skip it
5eef1db1 963 if ( fData = TFile::Open(file)) {
964 if ( fData->Get(kTreeName) ) {
193828fd 965 printf("++++ Adding %s\n", file) ;
966 chain->AddFile(file);
967 chainxs->Add(filexs) ;
968 }
969 }
970 else {
971 printf("---- Skipping %s\n", file) ;
972 skipped++ ;
973 }
d92b41ad 974 }
d92b41ad 975 }
976 else {
977 TString input = "AliESDs.root" ;
978 cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
979 chain->AddFile(input);
980 }
981
982 }// local files analysis
983
984 //------------------------------
3c867778 985 // GRID xml files
986 //------------------------------
d92b41ad 987 else if(mode == mGRID){
988 //Get colection file. It is specified by the environmental
989 //variable XML
d92b41ad 990
d92b41ad 991 //Feed Grid with collection file
d92b41ad 992 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
993 if (! collection) {
994 AliError(Form("%s not found", kXML)) ;
995 return kFALSE ;
996 }
3c867778 997
d92b41ad 998 TGridResult* result = collection->GetGridResult("",0 ,0);
193828fd 999
d92b41ad 1000 // Makes the ESD chain
1001 printf("*** Getting the Chain ***\n");
1002 for (Int_t index = 0; index < result->GetEntries(); index++) {
1003 TString alienURL = result->GetKey(index, "turl") ;
1004 cout << "================== " << alienURL << endl ;
1005 chain->Add(alienURL) ;
1006 alienURL.ReplaceAll("AliESDs.root",kXSFileName);
1007 chainxs->Add(alienURL) ;
1008 }
1009 }// xml analysis
1010
3c867778 1011 //------------------------------
1012 // PROOF
1013 //------------------------------
1014 else if (mode == mPROOF) {
1015
1016 TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
1017
1018 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
1019 chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
1020 printf("chain has %d entries\n",chain->GetEntries());
1021 }
1022
d92b41ad 1023 gSystem->ChangeDirectory(ocwd.Data());
193828fd 1024
d92b41ad 1025}
1026
193828fd 1027//______________________________
1028void CheckEnvironmentVariables()
1029{
1030
cd54ca47 1031 sprintf(kTrigger,"");
193828fd 1032
cd54ca47 1033 Bool_t bRecalibrate = kFALSE;
1034 Bool_t bBadChannel = kFALSE;
193828fd 1035
cd54ca47 1036 for (int i=0; i< gApplication->Argc();i++){
1037
1038#ifdef VERBOSEARGS
1039
1040 printf("Arg %d: %s\n",i,gApplication->Argv(i));
1041
193828fd 1042#endif
cd54ca47 1043
2c18833a 1044 TString sRun = "";
1045
cd54ca47 1046 if (!(strcmp(gApplication->Argv(i),"--trigger")))
1047 sprintf(trigger,gApplication->Argv(i+1));
193828fd 1048
1049 if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
1050 bRecalibrate = atoi(gApplication->Argv(i+1));
cd54ca47 1051
1052 if (!(strcmp(gApplication->Argv(i),"--badchannel")))
1053 bBadChannel = atoi(gApplication->Argv(i+1));
1054
1055 if (!(strcmp(gApplication->Argv(i),"--run"))){
2c18833a 1056 sRun = gApplication->Argv(i+1);
cd54ca47 1057 if(sRun.Contains("LHC10")) {
1058 kYear = 2010;
1059 }
1060 else {
1061 if(kRun <=0){
1062 kRun = atoi(gApplication->Argv(i+1));
1063 }
1064 else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
1065 }//numeric run
1066 }//--run available
1067
1068 }// args loop
1069
193828fd 1070 if(!sRun.Contains("LHC10")){
531f682d 1071 if ( kRun < 140000)
1072 {
193828fd 1073 kYear = 2010;
1074 if( kRun >= 136851 ) kCollision = "PbPb";
1075 }
531f682d 1076 else if( kRun < 170600)
1077 {
193828fd 1078 kYear = 2011;
531f682d 1079 if( kRun >= 166500 ) kCollision = "PbPb";
1080 }
1081 else
1082 {
1083 kYear = 2012;
1084
193828fd 1085 }
1086 }
1087
cd54ca47 1088 if(kMC) sprintf(kTrigger,"");
1089
1090 printf("*********************************************\n");
1091 //printf("*** Settings trigger %s, recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
1092 // kTrigger,bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
1093 printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
1094 printf("*********************************************\n");
1095
193828fd 1096}
1097
ac0610dc 1098//_________________________________________________________________
1099void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)
1100{
1101 // Read the PYTHIA statistics from the file pyxsec.root created by
1102 // the function WriteXsection():
1103 // integrated cross section (xsection) and
1104 // the number of Pyevent() calls (ntrials)
1105 // and calculate the weight per one event xsection/ntrials
1106 // The spectrum calculated by a user should be
1107 // multiplied by this weight, something like this:
1108 // TH1F *userSpectrum ... // book and fill the spectrum
1109 // userSpectrum->Scale(weight)
1110 //
1111 // Yuri Kharlov 19 June 2007
1112 // Gustavo Conesa 15 April 2008
1113 Double_t xsection = 0;
1114 UInt_t ntrials = 0;
1115 xs = 0;
1116 ntr = 0;
1117
1118 Int_t nfiles = tree->GetEntries() ;
1119 if (tree && nfiles > 0) {
1120 tree->SetBranchAddress("xsection",&xsection);
1121 tree->SetBranchAddress("ntrials" ,&ntrials );
1122 for(Int_t i = 0; i < nfiles; i++){
1123 tree->GetEntry(i);
1124 xs += xsection ;
1125 ntr += ntrials ;
1126 cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
1127 }
1128
1129 xs = xs / nfiles;
1130 ntr = ntr / nfiles;
1131 cout << "-----------------------------------------------------------------"<<endl;
1132 cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
1133 cout << "-----------------------------------------------------------------"<<endl;
1134 }
1135 else cout << " >>>> Empty tree !!!! <<<<< "<<endl;
1136
1137}
193828fd 1138