AliPhysics  ced2227 (ced2227)
ana.C
Go to the documentation of this file.
1 
15 #if !defined(__CINT__) || defined(__MAKECINT__)
16 
17 #include <Riostream.h>
18 #include <TString.h>
19 #include <TFile.h>
20 #include <TChain.h>
21 #include <TROOT.h>
22 #include <TSystem.h>
23 #include <TApplication.h>
24 #include <TKey.h>
25 #include <TProfile.h>
26 #include <TH1F.h>
27 
28 #include "TGrid.h"
29 #include "TGridCollection.h"
30 #include "TAlienCollection.h"
31 #include "TGridResult.h"
32 //#include "TProof.h"
33 //#include "TFileCollection.h"
34 //#include "TFileInfo.h"
35 
36 #include "AliLog.h"
37 #include "AliAnalysisGrid.h"
38 #include "AliAnalysisManager.h"
39 #include "AliMCEventHandler.h"
40 #include "AliAnalysisTaskSE.h"
41 #include "AliESDEvent.h"
42 #include "AliAODEvent.h"
43 #include "AliESDInputHandler.h"
44 #include "AliAODInputHandler.h"
45 #include "AliAODHandler.h"
46 #include "AliPhysicsSelection.h"
47 #include "AliPhysicsSelectionTask.h"
48 #include "AliMultiInputEventHandler.h"
50 #include "AliAnalysisTaskCounter.h"
51 #include "AliAnalysisDataContainer.h"
52 
53 #include "TSystemDirectory.h"
54 #include "CreateESDChain.C"
55 
56 #include "AliPhysicsSelection.h"
57 #include "AliPhysicsSelectionTask.h"
58 #include "AddTaskPhysicsSelection.C"
59 
60 #include "AliCentralitySelectionTask.h"
61 #include "AliMultSelectionTask.h"
62 #include "AliVZEROEPSelectionTask.h"
63 #include "AliEPSelectionTask.h"
64 #include "AddTaskCentrality.C"
65 #include "AddTaskMultSelection.C"
66 #include "AddTaskVZEROEPSelection.C"
67 #include "AddTaskEventplane.C"
68 
69 //#include "CreateAlienHandler.C"
70 
71 #include "AliAnalysisTaskCounter.h"
72 #include "AddTaskCounter.C"
73 
75 #include "AddTaskEMCALClusterize.C"
76 #include "AliAnaCalorimeterQA.h"
77 #include "AddTaskCalorimeterQA.C"
78 #include "AddTaskCaloTrackCorr.C"
79 
80 #endif
81 
82 //---------------------------------------------------------------------------
85 {
86  mLocal = 0,
87  mPROOF = 1,
88  mPlugin = 2,
89  mGRID = 3
90 };
91 
92 //---------------------------------------------------------------------------
93 // Settings to read locally several files, only for "mLocal" mode
94 // The different values are default, they can be set with environmental
95 // variables: INDIR, PATTERN, NFILES, respectivelly
96 
97 char * kInDir = (char*)"/user/data/files/";
98 char * kPattern = (char*)"";
99 Int_t kFile = 2;
100 
101 //---------------------------------------------------------------------------
102 // Dataset for proof analysis, mode=mPROOF
103 // char * kDataset = "/alice/vernet/PbPb_LHC10h_ESD";
104 
105 char * kDatasetPROOF = (char*)"/alice/vernet/LHC11b_149646";
108 TString alienUserName = "narbor" ;
109 
110 //---------------------------------------------------------------------------
111 // Collection file for grid analysis
112 
113 char * kXML = (char*)"collection.xml";
114 
115 //---------------------------------------------------------------------------
116 // Scale histograms from file. Change to kTRUE when xsection file exists
117 // Put name of file containing xsection
118 // Put number of events per ESD file
119 // This is an specific case for normalization of Pythia files.
120 const char * kXSFileName = (char*)"pyxsec.root";
121 
122 // Container of xs if xs in file pyxsec_hist.root
123 TArrayF* xsArr;
125 
126 //---------------------------------------------------------------------------
127 // Set some default values, but used values are set in the code!
128 
129 Bool_t kMC = kFALSE;
131 Int_t kYear = 2011;
133 Bool_t outAOD = kFALSE;
136 char kTrigger[1024];
138 
139 //---------------------------------------------------------------------------
140 //
141 void LoadLibraries(Int_t /*mode*/);
142 void SetupPar(char* pararchivename);
143 void CheckInputData(const Int_t mode);
144 void CreateChain(const Int_t mode, TChain * chain, TChain * chainxs);
146 Bool_t GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr, Int_t & n);
147 
148 //___________________________
161 //___________________________
163 {
164  //--------------------------------------------------------------------
165  // Load analysis libraries
166 
168  //gSystem->ListLibraries();
169 
170  //-----------------------------------------------------------------------------
171  // Create chain from ESD and from cross sections files, look below for options.
172 
173  // Set kInputData and kTreeName looking to the kINDIR
174 
176 
177  // Check global analysis settings
178 
180 
181  printf("*********************************************\n");
182  printf("*** Input data < %s >, pass %s, tree < %s >, MC? < %d > ***\n",kInputData.Data(),kPass.Data(),kTreeName.Data(),kMC);
183  printf("*********************************************\n");
184 
185  TChain * chain = new TChain(kTreeName) ;
186  TChain * chainxs = new TChain("Xsection") ;
187  CreateChain(mode, chain, chainxs);
188 
189  Double_t scale = -1;
190  printf("===== kMC %d, chainxs %p\n",kMC,chainxs);
191 
192  if(kMC)
193  {
194  //Get the cross section
195  Double_t xsection = 0;
196  Float_t ntrials = 0;
197  Int_t nfiles = 0;
198 
199  Bool_t ok = GetAverageXsection(chainxs, xsection, ntrials, nfiles);
200 
201  printf("n xs files %d",nfiles);
202 
203  if(ok)
204  {
205  Int_t nEventsPerFile = chain->GetEntries() / nfiles;
206 
207  Double_t trials = ntrials / nEventsPerFile ;
208 
209  scale = xsection / trials;
210 
211  printf("Get Cross section : nfiles %d, nevents %lld, nevents per file %d \n",nfiles, chain->GetEntries(),nEventsPerFile);
212  printf(" ntrials %2.2f, trials %2.2f, xs %2.2e, scale factor %2.2e\n", ntrials,trials,xsection,scale);
213 
214  if(chainxs->GetEntries()!=chain->GetEntries()) printf("CAREFUL: Number of files in data chain %lld, in cross section chain %lld \n",
215  chainxs->GetEntries(),chain->GetEntries());
216  } // ok
217 
218  // comment out this line in case the simulation did not have the cross section files produced in the directory
219  if( scale <= 0 || !ok)
220  { printf( "STOP, cross section not available! nfiles %lld \n", chainxs->GetEntries() ) ; return ; }
221 
222  }
223 
224  printf("*********************************************\n");
225  printf("number of entries # %lld \n", chain->GetEntries()) ;
226  printf("*********************************************\n");
227 
228  if(!chain)
229  {
230  printf("STOP, no chain available\n");
231  return;
232  }
233 
234  AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
235 
236  //------------------------------------------
237  // Alien handler part
238  //------------------------------------------
239  AliAnalysisGrid *alienHandler=0x0;
240 // if(mode==mPlugin)
241 // {
242 // // Create and configure the alien handler plugin
243 // gROOT->LoadMacro("CreateAlienHandler.C");
244 // alienHandler = CreateAlienHandler();
245 // if (!alienHandler) return;
246 // }
247 
248  //--------------------------------------
249  // Make the analysis manager
250  //-------------------------------------
251  AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
252  //AliAnalysisManager::SetUseProgressBar(kTRUE);
253  //mgr->SetSkipTerminate(kTRUE);
254  //mgr->SetNSysInfo(1);
255 
256  if(mode==mPlugin)
257  {
258  // Connect plugin to the analysis manager
259  mgr->SetGridHandler(alienHandler);
260  }
261 
262  // MC handler
263  if((kMC || kInputData == "MC") && !kInputData.Contains("AOD"))
264  {
265  AliMCEventHandler* mcHandler = new AliMCEventHandler();
266  mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
267  mgr->SetMCtruthEventHandler(mcHandler);
268  if( kInputData == "MC")
269  {
270  cout<<"MC INPUT EVENT HANDLER"<<endl;
271  mgr->SetInputEventHandler(NULL);
272  }
273  }
274 
275 
276  // AOD output handler
277  if(kInputData!="deltaAOD" && outAOD)
278  {
279  cout<<"Init output handler"<<endl;
280  AliAODHandler* aodoutHandler = new AliAODHandler();
281  aodoutHandler->SetOutputFileName("aod.root");
283  mgr->SetOutputEventHandler(aodoutHandler);
284  }
285 
286  //input
287 
288  if(kInputData == "ESD")
289  {
290  // ESD handler
291  AliESDInputHandler *esdHandler = new AliESDInputHandler();
292  esdHandler->SetReadFriends(kFALSE);
293  mgr->SetInputEventHandler(esdHandler);
294  cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
295  }
296  else if(kInputData.Contains("AOD"))
297  {
298  // AOD handler
299  AliAODInputHandler *aodHandler = new AliAODInputHandler();
300  mgr->SetInputEventHandler(aodHandler);
301  if(kInputData == "deltaAOD") aodHandler->AddFriend((char*)"deltaAODCaloTrackCorr.root");
302  cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
303  }
304 
305  //mgr->RegisterExternalFile("deltaAODCaloTrackCorr.root");
306  //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
307 
308  TString outputFile = AliAnalysisManager::GetCommonFileName();
309 
310  //-------------------------------------------------------------------------
311  // Define task, put here any other task that you want to use.
312  //-------------------------------------------------------------------------
313 
314  // Physics selection
315  if(kInputData=="ESD" && !kMC)
316  {
317  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
318  AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC);
319  }
320 
321  // Centrality, valid for Run1, but superseeded by new task below
322  if(kCollision=="PbPb" && kInputData=="ESD" && kRun < 200000)
323  {
324  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
325  AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
326  }
327 
328  {
329  // New centrality/multiplicity selector
330  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/COMMON/MULTIPLICITY/macros/AddTaskMultSelection.C");
331  AliMultSelectionTask * task = AddTaskMultSelection(kFALSE); // user mode:
332 
333  //use the default calibration for runs which have not yet been calibrated
334  task->SetUseDefaultCalib(kTRUE); // data
335  task->SetUseDefaultMCCalib(kTRUE); // MC
336  }
337 
338  if(kCollision=="PbPb")
339  {
340  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C");
341  AliVZEROEPSelectionTask * EPV0 = AddTaskVZEROEPSelection();
342 
343  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
344  AliEPSelectionTask * EP = AddTaskEventplane();
345  }
346 
347 
348 
349  // Simple event counting tasks
350 
351  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/AddTaskCounter.C");
352 
353  AliAnalysisTaskCounter* count = AddTaskCounter("",kMC); // All, fill histo with cross section and trials if kMC is true
354  AliAnalysisTaskCounter* countmb = AddTaskCounter("MB"); // Min Bias
355  AliAnalysisTaskCounter* countany = AddTaskCounter("Any");
356  AliAnalysisTaskCounter* countint = AddTaskCounter("AnyINT");// Min Bias
357 
358  if(!kMC)
359  {
360  AliAnalysisTaskCounter* countemg = AddTaskCounter("EMCEGA");
361  AliAnalysisTaskCounter* countemj = AddTaskCounter("EMCEJE");
362  if(kCollision=="PbPb")
363  {
364  AliAnalysisTaskCounter* countcen = AddTaskCounter("Central");
365  AliAnalysisTaskCounter* countsce = AddTaskCounter("SemiCentral");
366  AliAnalysisTaskCounter* countssce= AddTaskCounter("SemiOrCentral");
367  AliAnalysisTaskCounter* countphP = AddTaskCounter("PHOSPb");
368  }
369  else
370  {
371  AliAnalysisTaskCounter* countem1 = AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
372  AliAnalysisTaskCounter* countem7 = AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
373  AliAnalysisTaskCounter* countphp = AddTaskCounter("PHOS");
374  }
375  }
376 
377 /*
378  // -----------------
379  // Photon conversion
380  // -----------------
381 
382  if(kInputData=="ESD"){
383  printf("* Configure photon conversion analysis in macro \n");
384  TString arguments = "-run-on-train -use-own-xyz -force-aod -mc-off ";
385  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
386  AliAnalysisTaskGammaConversion * taskGammaConversion =
387  ConfigGammaConversion(arguments,mgr->GetCommonInputContainer());
388  taskGammaConversion->SelectCollisionCandidates();
389 
390  // Gamma Conversion AOD to AODPWG4Particle
391  AliAnalysisTaskGCPartToPWG4Part * taskGCToPC = new AliAnalysisTaskGCPartToPWG4Part("GCPartToPWG4Part");
392  taskGCToPC->SetGammaCutId("90035620401003321022000000090");
393  mgr->AddTask(taskGCToPC);
394  mgr->ConnectInput (taskGCToPC, 0, mgr->GetCommonInputContainer() );
395  mgr->ConnectOutput (taskGCToPC, 0, mgr->GetCommonOutputContainer());
396  }
397 */
398 
399  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
401 
402  //gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/AddTaskEMCALTriggerQA.C");
403  //AliAnalysisTaskEMCALTriggerQA * qatrigtask = AddTaskEMCALTriggerQA();
404 
405 
406  Bool_t kPrint = kFALSE;
407  Bool_t deltaAOD = kFALSE;
408  // Calibration, bad map ...
409 
410  Bool_t calibEE = kTRUE; // It is set automatically, but here we force to use it or not in any case
411  Bool_t calibTT = kTRUE; // It is set automatically, but here we force to use it or not in any case
412  if(kRun < 122195 || (kRun > 126437 && kRun < 136851) || kMC) calibTT=kFALSE ; // Recalibration parameters not available for LHC10a,b,c,e,f,g
413  Bool_t badMap = kTRUE; // It is set automatically, but here we force to use it or not in any case
414 
415  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/AddTaskCaloTrackCorr.C");
416  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/AddTaskEMCALClusterize.C");
417 
418  if(kCollision=="pp")
419  {
420  printf("==================================== \n");
421  printf("CONFIGURE ANALYSIS FOR PP COLLISIONS \n");
422  printf("==================================== \n");
423 
424  Bool_t mixing = kTRUE; // mixing in reader and hadron correlation, and pi0
425  Bool_t clTM = kTRUE;
426  Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
427  Bool_t anTM = kTRUE; // Remove matched
428  Bool_t exo = kTRUE; // Remove exotic cells
429  Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
430  Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
431  Int_t minEcell = 50; // 50 MeV (10 MeV used in reconstruction)
432  Int_t minEseed = 100; // 100 MeV
433  Int_t dTime = 0; // default, 250 ns
434  Int_t wTime = 30; // default 425 < T < 825 ns, careful if time calibration is on
435  Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
436  Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
437 
438  //Trigger
439  TString clTrigger = "";
440  TString anTrigger = "EMC7";
441 
442  if(kMC)
443  {
444  clTrigger = "";
445  anTrigger = "";
446  dTime = 0;
447  wTime = 0;
448  }
449 
450  Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
451  Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
452  Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
453 
454  //Analysis with clusterizer V1
455 
456  TString arrayNameV1 = "";
457 
458  AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
459  minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
460  calibEE,badMap,calibTT,clnonlin);
461 
462  printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
463 //
464 // if(!kMC)
465 // {
466 //
467 // AliAnalysisTaskCaloTrackCorrelation *anav1trig = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
468 // kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
469 // -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
470 // }
471 //
472 // AliAnalysisTaskCaloTrackCorrelation *anav1mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
473 // kYear,kCollision,"AnyINT",arrayNameV1,mixing,reTM,anTM,
474 // -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
475 //
476 //
477 //
478 // //Analysis with clusterizer V2
479 // TString arrayNameV2 = "";
480 // AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
481 // minEcell,minEseed,dTime,wTime,
482 // calibEE,badMap,calibTT,clnonlin);
483 //
484 // printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
485 //
486 // hadron = kFALSE;
487 // if(!kMC)
488 // {
489 //
490 //
491 // AliAnalysisTaskCaloTrackCorrelation *anav2tr = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
492 // kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
493 // -1,-1,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
494 // }
495 //
496 //
497 // AliAnalysisTaskCaloTrackCorrelation *anav2mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
498 // kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
499 // -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
500  }
501 
502  if(kCollision=="PbPb")
503  {
504  printf("====================================== \n");
505  printf("CONFIGURE ANALYSIS FOR PbPb COLLISIONS \n");
506  printf("====================================== \n");
507  Bool_t mixing = kTRUE;
508  Bool_t clTM = kTRUE;
509  Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
510  Bool_t anTM = kTRUE; // Remove matched
511  Bool_t exo = kTRUE; // Remove exotic cells
512  Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
513  Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
514  Int_t minEcell = 150; // 50 MeV (10 MeV used in reconstruction)
515  Int_t minEseed = 300; // 100 MeV
516  Int_t dTime = 0; // default, 250 ns
517  Int_t wTime = 0; // default 425 < T < 825 ns
518  Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
519  Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
520 
521  // Trigger
522  TString clTrigger = "";
523  TString anTrigger = "EMCGA";
524  if(kMC)
525  {
526  clTrigger = "";
527  anTrigger = "";
528  dTime = 0;
529  wTime = 0;
530  }
531 
532  Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
533  Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
534  Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
535 
536  //Analysis with clusterizer V1
537 
538  TString arrayNameV1 = "";
539  AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
540  minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
541  calibEE,badMap,calibTT,clnonlin);
542 
543  printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
544 
545  if(!kMC)
546  {
547  AliAnalysisTaskCaloTrackCorrelation *anav1c = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
548  kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
549  0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
550  AliAnalysisTaskCaloTrackCorrelation *anav1m = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
551  kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
552  20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
553  AliAnalysisTaskCaloTrackCorrelation *anav1p = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
554  kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
555  60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
556  }
557 
558  //Analysis with clusterizer V2
559 
560  TString arrayNameV2 = "";
561  AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
562  minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
563  calibEE,badMap,calibTT,clnonlin);
564 
565  printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
566 
567  hadron = kFALSE;
568 
569  if(!kMC)
570  {
571 
572  AliAnalysisTaskCaloTrackCorrelation *anav2cT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
573  kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
574  0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
575  AliAnalysisTaskCaloTrackCorrelation *anav2mT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
576  kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
577  20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
578  AliAnalysisTaskCaloTrackCorrelation *anav2pT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
579  kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
580  60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
581  }
582 
583  AliAnalysisTaskCaloTrackCorrelation *anav2cMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
584  kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
585  0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
586  AliAnalysisTaskCaloTrackCorrelation *anav2mMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
587  kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
588  20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
589  AliAnalysisTaskCaloTrackCorrelation *anav2pMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
590  kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
591  60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
592 
593 
594  }
595 
596  //-----------------------
597  // Run the analysis
598  //-----------------------
599  mgr->InitAnalysis();
600  mgr->PrintStatus();
601 
602  if (mode == mPlugin) mgr->StartAnalysis("grid");
603  else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
604  else mgr->StartAnalysis("local",chain);
605 
606  cout <<" Analysis ended sucessfully "<< endl ;
607 }
608 
609 //_____________________________
611 //_____________________________
612 void LoadLibraries(Int_t /*mode*/)
613 {
614 // if (mode == mPROOF)
615 // {
616 // //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
617 // gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
618 // TProof* proof = EnableAliRootForLAF("ccaplmaster",nPROOFWorkers.Data(),ccin2p3UserName.Data(),alienUserName.Data(),"",kFALSE,kTRUE,kTRUE,"OADB:ANALYSIS:ANALYSISalice:AOD:ESD:CORRFW:STEERBase:EMCALUtils:PHOSUtils:PWGCaloTrackCorrBase:PWGGACaloTrackCorrelations:PWGPPEMCAL");
619 //
620 // // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
621 //
622 // // //proof->ClearPackages();
623 // // proof->UploadPackage("STEERBase");
624 // // proof->UploadPackage("ESD");
625 // // proof->UploadPackage("AOD");
626 // // proof->UploadPackage("ANALYSIS");
627 // // proof->UploadPackage("OADB");
628 // // proof->UploadPackage("ANALYSISalice");
629 // // proof->UploadPackage("CORRFW");
630 // // //proof->UploadPackage("JETAN");
631 // // proof->UploadPackage("PHOSUtils");
632 // // proof->UploadPackage("EMCALUtils");
633 // // proof->UploadPackage("PWGCaloTrackCorrBase");
634 // // proof->UploadPackage("PWGGACaloTrackCorrelations");
635 // // proof->UploadPackage("PWGPPEMCAL");
636 //
637 // // proof->EnablePackage("STEERBase");
638 // // proof->EnablePackage("ESD");
639 // // proof->EnablePackage("AOD");
640 // // proof->EnablePackage("ANALYSIS");
641 // // proof->EnablePackage("OADB");
642 // // proof->EnablePackage("ANALYSISalice");
643 // // proof->EnablePackage("CORRFW");
644 // // //proof->EnablePackage("JETAN");
645 // // proof->EnablePackage("PHOSUtils");
646 // // proof->EnablePackage("EMCALUtils");
647 // // proof->EnablePackage("PWGCaloTrackCorrBase");
648 // // proof->EnablePackage("PWGGACaloTrackCorrelations");
649 // // proof->EnablePackage("PWGPPEMCAL");
650 // return;
651 // }
652 
653  //--------------------------------------
654  // Load the needed libraries via par files if modified
655  //--------------------------------------
656  //SetupPar("EMCALUtils");
657  //SetupPar("EMCALraw");
658  //SetupPar("EMCALbase");
659  //SetupPar("EMCALsim");
660  //SetupPar("EMCALrec");
661 
662  //SetupPar("PWGPPEMCAL");
663 
664  //SetupPar("PWGCaloTrackCorrBase");
665  //SetupPar("PWGGACaloTrackCorrelations");
666 
667  //SetupPar("PWGGAGammaConv");
668 
669  // needed for plugin?
670  gSystem->AddIncludePath("-I$ALICE_ROOT");
671  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
672  gSystem->AddIncludePath("-I./");
673 }
674 
675 //_________________________________
679 //_________________________________
680 void SetupPar(char* pararchivename)
681 {
682  TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
683 
684  TString parpar(Form("%s.par", pararchivename)) ;
685 
686  if ( gSystem->AccessPathName(pararchivename) )
687  {
688  TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
689  gROOT->ProcessLine(processline.Data());
690  }
691 
692  TString ocwd = gSystem->WorkingDirectory();
693  gSystem->ChangeDirectory(pararchivename);
694 
695  // check for BUILD.sh and execute
696  if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh"))
697  {
698  printf("*******************************\n");
699  printf("*** Building PAR archive ***\n");
700  cout<<pararchivename<<endl;
701  printf("*******************************\n");
702 
703  if (gSystem->Exec("PROOF-INF/BUILD.sh"))
704  {
705  Error("runProcess","Cannot Build the PAR Archive! - Abort!");
706  return ;
707  }
708  }
709  // check for SETUP.C and execute
710  if (!gSystem->AccessPathName("PROOF-INF/SETUP.C"))
711  {
712  printf("*******************************\n");
713  printf("*** Setup PAR archive ***\n");
714  cout<<pararchivename<<endl;
715  printf("*******************************\n");
716  gROOT->Macro("PROOF-INF/SETUP.C");
717  }
718 
719  gSystem->ChangeDirectory(ocwd.Data());
720  printf("Current dir: %s\n", ocwd.Data());
721 }
722 
723 //______________________________________
725 //______________________________________
727 {
728  TString ocwd = gSystem->WorkingDirectory();
729 
730  //---------------------------------------
731  // Local files analysis
732  //---------------------------------------
733  if(mode == mLocal){
734  //If you want to add several ESD files sitting in a common directory INDIR
735  //Specify as environmental variables the directory (INDIR), the number of files
736  //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
737 
738  if(gSystem->Getenv("INDIR"))
739  kInDir = (char*)gSystem->Getenv("INDIR") ;
740  else cout<<"INDIR not set, use default: "<<kInDir<<endl;
741 
742  TString sindir(kInDir);
743  if (sindir.Contains("pass1")) kPass = "pass1";
744  else if(sindir.Contains("pass2")) kPass = "pass2";
745  else if(sindir.Contains("pass3")) kPass = "pass3";
746 
747  if(gSystem->Getenv("PATTERN"))
748  kPattern = (char*)gSystem->Getenv("PATTERN") ;
749  else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
750 
751  cout<<"INDIR : "<<kInDir<<endl;
752  cout<<"NFILES : "<<kFile<<endl;
753 
754  char fileE[120] ;
755  char fileA[120] ;
756  char fileG[120] ;
757  char fileEm[120] ;
758  for (Int_t event = 0 ; event < kFile ; event++) {
759  sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
760  sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
761  sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
762  sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
763 
764  TFile * fESD = TFile::Open(fileE) ;
765  TFile * fAOD = TFile::Open(fileA) ;
766 
767  //Check if file exists and add it, if not skip it
768  if (fESD)
769  {
770  kTreeName = "esdTree";
771  kInputData = "ESD";
772  TFile * fG = TFile::Open(fileG);
773  if(fG) { kMC = kTRUE; fG->Close();}
774  else kMC = kFALSE;
775 
776  // Get run number
777  TTree* esdTree = (TTree*)fESD->Get("esdTree");
778  AliESDEvent* esd = new AliESDEvent();
779  esd->ReadFromTree(esdTree);
780  esdTree->GetEvent(0);
781  kRun = esd->GetRunNumber();
782 
783  return;
784  }
785  else if(fAOD)
786  {
787  kTreeName = "aodTree";
788  kInputData = "AOD";
789  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
790  else kMC = kFALSE;
791 
792  // Get run number
793  TTree* aodTree = (TTree*)fAOD->Get("aodTree");
794  AliAODEvent* aod = new AliAODEvent();
795  aod->ReadFromTree(aodTree);
796  aodTree->GetEvent(0);
797  kRun = aod->GetRunNumber();
798  return;
799  }
800  else if(TFile::Open(fileEm))
801  {
802  kTreeName = "aodTree";
803  kInputData = "AOD";
804  kMC = kTRUE;
805 
806  return;
807  }
808  else if(TFile::Open(fileG))
809  {
810  kTreeName = "TE";
811  kInputData = "MC";
812  kMC = kTRUE;
813  return;
814  }
815 
816  if(fESD) fESD->Close();
817  if(fAOD) fAOD->Close();
818  }
819 
820  }// local files analysis
821 
822  //------------------------------
823  //GRID xml files
824  //-----------------------------
825  else if(mode == mGRID){
826  //Get colection file. It is specified by the environmental
827  //variable XML
828 
829  if(gSystem->Getenv("XML") )
830  kXML = (char*)gSystem->Getenv("XML");
831  else
832  sprintf(kXML, "collection.xml") ;
833 
834  if (!TFile::Open(kXML)) {
835  printf("No collection file with name -- %s -- was found\n",kXML);
836  return ;
837  }
838  else cout<<"XML file "<<kXML<<endl;
839 
840  //Load necessary libraries and connect to the GRID
841  gSystem->Load("libNetx") ;
842  gSystem->Load("libRAliEn");
843  TGrid::Connect("alien://") ;
844 
845  //Feed Grid with collection file
846  TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
847  if (! collection) {
848  printf("%s not found\n", kXML) ;
849  return ;
850  }
851  TGridResult* result = collection->GetGridResult("",0 ,0);
852 
853  for (Int_t index = 0; index < result->GetEntries(); index++) {
854  TString alienURL = result->GetKey(index, "turl") ;
855  cout << "================== " << alienURL << endl ;
856 
857  if (alienURL.Contains("pass1")) kPass = "pass1";
858  else if(alienURL.Contains("pass2")) kPass = "pass2";
859  else if(alienURL.Contains("pass3")) kPass = "pass3";
860 
861  kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
862  printf("Run number from alien path = %d\n",kRun);
863 
864  TFile * fAOD = 0 ;
865  //Check if file exists and add it, if not skip it
866  if (alienURL.Contains("AliESDs.root"))
867  {
868  kTreeName = "esdTree";
869  kInputData = "ESD";
870  alienURL.ReplaceAll("AliESDs.root","galice.root");
871  if(TFile::Open(alienURL)) kMC=kTRUE;
872  else kMC = kFALSE;
873  return;
874  }
875  else if(alienURL.Contains("AliAOD.root"))
876  {
877  kTreeName = "aodTree";
878  kInputData = "AOD";
879  fAOD = TFile::Open(alienURL);
880  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
881  else kMC = kFALSE;
882  return;
883  }
884  else if(alienURL.Contains("embededAOD.root"))
885  {
886  kTreeName = "aodTree";
887  kInputData = "AOD";
888  kMC=kTRUE;
889  return;
890  }
891  else if(alienURL.Contains("galice.root"))
892  {
893  kTreeName = "TE";
894  kInputData = "MC";
895  kMC=kTRUE;
896  return;
897  }
898  }
899  }// xml analysis
900  //------------------------------
901  //PROOF files
902  //-----------------------------
903 // else if(mode == mPROOF){
904 //
905 // TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
906 //
907 // TIter iter(coll->GetList());
908 //
909 // TFileInfo* fileInfo = 0;
910 // while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
911 // {
912 // if (fileInfo->GetFirstUrl()) {
913 // TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
914 // cout << "================== " << ProofURL << endl ;
915 //
916 // if (ProofURL.Contains("pass1")) kPass = "pass1";
917 // else if(ProofURL.Contains("pass2")) kPass = "pass2";
918 // else if(ProofURL.Contains("pass3")) kPass = "pass3";
919 //
920 // kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
921 // printf("Run number from alien path = %d\n",kRun);
922 //
923 // TFile * fAOD = 0 ;
924 // //Check if file exists and add it, if not skip it
925 // if (ProofURL.Contains("AliESDs.root"))
926 // {
927 // kTreeName = "esdTree";
928 // kInputData = "ESD";
929 // alienURL.ReplaceAll("AliESDs.root","galice.root");
930 // if(TFile::Open(ProofURL)) kMC=kTRUE;
931 // else kMC = kFALSE;
932 //
933 // return;
934 // }
935 // else if(ProofURL.Contains("AliAOD.root"))
936 // {
937 // kTreeName = "aodTree";
938 // kInputData = "AOD";
939 // fAOD = TFile::Open(ProofURL);
940 // if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
941 // else kMC = kFALSE;
942 // return;
943 // }
944 // else if(ProofURL.Contains("embededAOD.root"))
945 // {
946 // kTreeName = "aodTree";
947 // kInputData = "AOD";
948 // kMC=kTRUE;
949 // return;
950 // }
951 // else if(ProofURL.Contains("galice.root"))
952 // {
953 // kTreeName = "TE";
954 // kInputData = "MC";
955 // kMC=kTRUE;
956 // return;
957 // }
958 // }
959 // }
960 // }// proof analysis
961 
962  gSystem->ChangeDirectory(ocwd.Data());
963 }
964 
965 //_____________________________________________________________________
967 //_____________________________________________________________________
968 void CreateChain(const Int_t mode, TChain * chain, TChain * chainxs)
969 {
970  TString ocwd = gSystem->WorkingDirectory();
971 
972  if(kInputData == "AOD")
973  {
974  xsArr = new TArrayF;
975  trArr = new TArrayI;
976  }
977 
978  //---------------------------------------
979  // Local files analysis
980  //---------------------------------------
981  if(mode == mLocal)
982  {
983  //If you want to add several ESD files sitting in a common directory INDIR
984  //Specify as environmental variables the directory (INDIR), the number of files
985  //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
986 
987  if(gSystem->Getenv("INDIR"))
988  kInDir = (char*)gSystem->Getenv("INDIR") ;
989  else cout<<"INDIR not set, use default: "<<kInDir<<endl;
990 
991  if(gSystem->Getenv("PATTERN"))
992  kPattern = (char*)gSystem->Getenv("PATTERN") ;
993  else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
994 
995  if(gSystem->Getenv("NFILES"))
996  kFile = atoi(gSystem->Getenv("NFILES")) ;
997  else cout<<"NFILES not set, use default: "<<kFile<<endl;
998 
999  //Check if env variables are set and are correct
1000  if ( kInDir && kFile)
1001  {
1002  printf("Get %d files from directory %s\n",kFile,kInDir);
1003  if ( ! gSystem->cd(kInDir) )
1004  {//check if ESDs directory exist
1005  printf("%s does not exist\n", kInDir) ;
1006  return ;
1007  }
1008 
1009  //if(gSystem->Getenv("XSFILE"))
1010  //kXSFileName = gSystem->Getenv("XSFILE") ;
1011  //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
1012  char * kGener = (char*)gSystem->Getenv("GENER");
1013  if(kGener)
1014  {
1015  cout<<"GENER "<<kGener<<endl;
1016  if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
1017  else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
1018  else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
1019  }
1020  else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
1021 
1022  if(kInputData=="AOD")
1023  {
1024  kXSFileName = "pyxsec_hists.root";
1025  xsArr->Set(kFile);
1026  trArr->Set(kFile);
1027  }
1028 
1029  cout<<"INDIR : "<<kInDir <<endl;
1030  cout<<"NFILES : "<<kFile <<endl;
1031  cout<<"PATTERN : "<<kPattern <<endl;
1032  cout<<"XSFILE : "<<kXSFileName<<endl;
1033 
1034  TString datafile="";
1035  if (kInputData == "ESD") datafile = "AliESDs.root" ;
1036  else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
1037  else if(kInputData == "MC") datafile = "galice.root" ;
1038 
1039  // Loop on ESD/AOD/MC files, add them to chain
1040  Int_t event =0;
1041  Int_t skipped=0 ;
1042  char file[120] ;
1043  char filexs[120] ;
1044 
1045  for (event = 0 ; event < kFile ; event++) {
1046  sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
1047  sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
1048 
1049  TFile * fData = TFile::Open(file) ;
1050 
1051  // Check if file exists and add it, if not skip it
1052  if ( fData )
1053  {
1054  if ( fData->Get(kTreeName) )
1055  {
1056  printf("++++ Adding %s\n", file) ;
1057  chain->AddFile(file);
1058 
1059  if(kInputData != "AOD")
1060  {
1061  chainxs->Add(filexs) ;
1062  }
1063  else
1064  {
1065  TFile* fxsec = TFile::Open(filexs);
1066  if(fxsec)
1067  {
1068  TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
1069  if(!key)
1070  {
1071  fxsec->Close();
1072  printf("No key!");
1073  continue;
1074  }
1075 
1076  TList *list = dynamic_cast<TList*>(key->ReadObj());
1077  if(!list)
1078  {
1079  fxsec->Close();
1080  printf("No list!");
1081  continue;
1082  }
1083 
1084  Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
1085  Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
1086  fxsec->Close();
1087 
1088  xsArr->SetAt(xsection,event);
1089  trArr->SetAt(ntrials,event);
1090 
1091  printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, event);
1092  //chainxs->Add(tree);
1093  //fileTMP->Close();
1094  } // fxsec exists
1095  } // xs in AODs
1096 
1097  }
1098  }
1099  else
1100  {
1101  printf("---- Skipping %s\n", file) ;
1102  skipped++ ;
1103  }
1104  }
1105  }
1106  else {
1107  TString input = "AliESDs.root" ;
1108  cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
1109  chain->AddFile(input);
1110  }
1111 
1112  }// local files analysis
1113 
1114  //------------------------------
1115  // GRID xml files
1116  //------------------------------
1117  else if(mode == mGRID)
1118  {
1119  //Get colection file. It is specified by the environmental
1120  //variable XML
1121 
1122  //Feed Grid with collection file
1123  TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
1124  if (! collection) {
1125  printf("%s not found\n", kXML) ;
1126  return ;
1127  }
1128 
1129  TGridResult* result = collection->GetGridResult("",0 ,0);
1130 
1131  // Makes the ESD chain
1132  printf("*** Getting the Chain ***\n");
1133  for (Int_t index = 0; index < result->GetEntries(); index++) {
1134  TString alienURL = result->GetKey(index, "turl") ;
1135  cout << "================== " << alienURL << endl ;
1136  chain->Add(alienURL) ;
1137 
1138  if(kInputData != "AOD")
1139  {
1140  alienURL.ReplaceAll("AliESDs.root",kXSFileName);
1141  alienURL.ReplaceAll("AliAOD.root",kXSFileName);
1142  chainxs->Add(alienURL) ;
1143  }
1144  else
1145  {
1146  alienURL.ReplaceAll("AliESDs.root","pyxsec_hists.root");
1147  alienURL.ReplaceAll("AliAOD.root", "pyxsec_hists.root");
1148  TFile* fxsec = TFile::Open(alienURL);
1149  if(fxsec)
1150  {
1151  TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
1152  if(!key)
1153  {
1154  fxsec->Close();
1155  printf("No key!");
1156  continue;
1157  }
1158 
1159  TList *list = dynamic_cast<TList*>(key->ReadObj());
1160  if(!list)
1161  {
1162  fxsec->Close();
1163  printf("No list!");
1164  continue;
1165  }
1166 
1167  Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
1168  Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
1169  fxsec->Close();
1170 
1171  xsArr->SetAt(xsection,index);
1172  trArr->SetAt(ntrials,index);
1173 
1174  printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, index);
1175 
1176  } // fxsec exists
1177  } // xs in AODs
1178  }
1179  }// xml analysis
1180 
1181  //------------------------------
1182  // PROOF
1183  //------------------------------
1184 // else if (mode == mPROOF)
1185 // {
1186 // TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
1187 //
1188 // gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
1189 // chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
1190 // printf("chain has %d entries\n",chain->GetEntries());
1191 // }
1192 
1193  gSystem->ChangeDirectory(ocwd.Data());
1194 }
1195 
1196 //______________________________
1200 //______________________________
1202 {
1203  sprintf(kTrigger,"");
1204 
1205  Bool_t bRecalibrate = kFALSE;
1206  Bool_t bBadChannel = kFALSE;
1207 
1208  for (int i=0; i< gApplication->Argc();i++){
1209 
1210 #ifdef VERBOSEARGS
1211 
1212  printf("Arg %d: %s\n",i,gApplication->Argv(i));
1213 
1214 #endif
1215 
1216  TString sRun = "";
1217 
1218 // if (!(strcmp(gApplication->Argv(i),"--trigger")))
1219 // sprintf(trigger,gApplication->Argv(i+1));
1220 
1221  if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
1222  bRecalibrate = atoi(gApplication->Argv(i+1));
1223 
1224  if (!(strcmp(gApplication->Argv(i),"--badchannel")))
1225  bBadChannel = atoi(gApplication->Argv(i+1));
1226 
1227  if (!(strcmp(gApplication->Argv(i),"--run")))
1228  {
1229  sRun = gApplication->Argv(i+1);
1230  if(sRun.Contains("LHC10")) {
1231  kYear = 2010;
1232  }
1233  else {
1234  if(kRun <=0){
1235  kRun = atoi(gApplication->Argv(i+1));
1236  }
1237  else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
1238  }//numeric run
1239  }//--run available
1240 
1241  }// args loop
1242 
1243  if ( kRun < 140000)
1244  {
1245  kYear = 2010;
1246  if( kRun >= 136851 ) kCollision = "PbPb";
1247  }
1248  else if( kRun < 170600)
1249  {
1250  kYear = 2011;
1251  if( kRun >= 166500 ) kCollision = "PbPb";
1252  }
1253  else if( kRun < 200000 )
1254  {
1255  kYear = 2012;
1256  if( kRun >= 194000 ) kCollision = "pPb";
1257  }
1258  else if( kRun < 247000 )
1259  {
1260  kYear = 2015;
1261  if( kRun >= 244820 ) kCollision = "PbPb";
1262  }
1263  else
1264  {
1265  kYear = 2016;
1266  }
1267 
1268  if(kMC) sprintf(kTrigger,"");
1269 
1270  printf("*********************************************\n");
1271  //printf("*** Settings trigger %s, recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
1272  // kTrigger,bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
1273  printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
1274  printf("*********************************************\n");
1275 
1276 }
1277 
1278 //______________________________________________________________________________
1292 //______________________________________________________________________________
1294 {
1295  Double_t xsection = 0 ;
1296  UInt_t ntrials = 0 ;
1297  Int_t nfiles = 0 ;
1298 
1299  xs = 0;
1300  ntr = 0;
1301  n = 0;
1302  if( kInputData != "AOD" && tree )
1303  {
1304  nfiles = tree->GetEntries() ;
1305 
1306  tree->SetBranchAddress("xsection",&xsection);
1307  tree->SetBranchAddress("ntrials" ,&ntrials );
1308  for(Int_t i = 0; i < nfiles; i++)
1309  {
1310  tree->GetEntry(i);
1311  if(xsection > 0)
1312  {
1313  xs += xsection ;
1314  ntr += ntrials ;
1315  n++;
1316  }
1317  cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
1318  } // loop
1319  }
1320  else if( kInputData == "AOD" && xsArr )
1321  {
1322  nfiles = xsArr->GetSize();
1323 
1324  for(Int_t i = 0; i < nfiles; i++)
1325  {
1326  if(xsArr->GetAt(i) > 0)
1327  {
1328  xs += xsArr->GetAt(i) ;
1329  ntr += trArr->GetAt(i) ;
1330  n++;
1331  }
1332  cout << "xsection " <<xsArr->GetAt(i)<<" ntrials "<<trArr->GetAt(i)<<endl;
1333  } // loop
1334  }
1335  else return kFALSE;
1336 
1337  xs = xs / n;
1338  ntr = ntr / n;
1339  cout << "-----------------------------------------------------------------"<<endl;
1340  cout << "Average of "<< n <<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
1341  cout << "-----------------------------------------------------------------"<<endl;
1342 
1343  return kTRUE;
1344 }
1345 
1346 
Int_t kDatasetNMaxFiles
Definition: ana.C:106
TString alienUserName
Definition: ana.C:108
Analyze locally files in your computer.
Definition: ana.C:87
void ana(Int_t mode=mGRID)
Definition: ana.C:162
anaModes
Different analysis modes.
Definition: ana.C:84
double Double_t
Definition: External.C:58
Bool_t GetAverageXsection(TTree *tree, Double_t &xs, Float_t &ntr, Int_t &n)
Definition: ana.C:1293
char * kXML
Definition: ana.C:113
Count events with different selection criteria.
void CreateChain(const Int_t mode, TChain *chain, TChain *chainxs)
Fills chain with data files paths.
Definition: ana.C:968
TSystem * gSystem
char * kPattern
Global, path to data files.
Definition: ana.C:98
TArrayF * xsArr
Name of file with pT-hard cross sections.
Definition: ana.C:123
TString ccin2p3UserName
Definition: ana.C:107
TString kPass
Definition: ana.C:135
Bool_t kPrint
Print setted parameters when configuring.
TString kCollision
Definition: ana.C:132
Bool_t kMC
Definition: ana.C:129
Int_t kYear
ESD, AOD, MC, deltaAOD.
Definition: ana.C:131
TArrayI * trArr
Definition: ana.C:124
AliAnalysisTaskCaloTrackCorrelation * AddTaskCalorimeterQA(const char *suffix="default", Bool_t simulation=kFALSE, TString outputFile="", Int_t year=2015, Bool_t printSettings=kFALSE, Bool_t calibrate=kTRUE)
void CheckEnvironmentVariables()
Definition: ana.C:1201
char * kInDir
Definition: ana.C:97
TString kTreeName
Some tasks doesnt need it.
Definition: ana.C:134
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
AliAnalysisTaskCounter * AddTaskCounter(const TString trigger="", Bool_t xsOn=kFALSE)
Int_t kRun
Definition: ana.C:137
Bool_t outAOD
Definition: ana.C:133
Int_t mode
Definition: anaM.C:41
Analyze files on GRID with Plugin.
Definition: ana.C:89
Analyze files on GRID with Plugin.
Definition: ana.C:88
void CheckInputData(const Int_t mode)
Sets input data and tree strings.
Definition: ana.C:726
Example of configuration of CaloTrackCorrelation package.
void SetupPar(char *pararchivename)
Definition: ana.C:680
void LoadLibraries(Int_t)
Load analysis libraries.
Definition: ana.C:612
char kTrigger[1024]
Definition: ana.C:136
Main class conecting the CaloTrackCorrelations package and Analysis Frame.
TFile * file
TList with histograms for a given trigger.
const char * kXSFileName
Global name for the xml collection file with data on grid.
Definition: ana.C:120
AliAnalysisTaskCaloTrackCorrelation * AddTaskCaloTrackCorr(const TString data="", const TString calorimeter="EMCAL", const Bool_t simulation=kFALSE, const Bool_t eventsel=kFALSE, const Bool_t exotic=kTRUE, const Bool_t nonlin=kFALSE, TString outputfile="", const Int_t year=2010, const TString col="pp", const TString trigger="MB", const TString clustersArray="V1", const Bool_t mix=kTRUE, const Bool_t recaltm=kTRUE, const Bool_t tm=kTRUE, const Int_t minCen=-1, const Int_t maxCen=-1, const Bool_t qaan=kFALSE, const Bool_t hadronan=kFALSE, const Bool_t calibE=kTRUE, const Bool_t badmap=kTRUE, const Bool_t calibT=kTRUE, const Bool_t tender=kFALSE, const Bool_t outputAOD=kFALSE, const Bool_t printSettings=kFALSE, const Double_t scaleFactor=-1, const Int_t runNumber=-1)
Int_t kFile
Data are in files kInDir/kPattern+i.
Definition: ana.C:99
Configuration of EMCal re-clusterization analysis task.
bool Bool_t
Definition: External.C:53
Counting task configurations.
AliAnalysisTaskEMCALClusterize * AddTaskEMCALClusterize(TString &arrayName, const Bool_t bFillAOD=kFALSE, const Int_t bMC=kFALSE, const Bool_t exotic=kTRUE, const TString name="V1Unfold", const TString trigger="", const Int_t tm=1, const Int_t minEcell=50, const Int_t minEseed=100, const Int_t maxDeltaT=250, const Int_t timeWindow=1000, const Int_t minEUnf=15, const Int_t minFrac=1, const Bool_t bRecalE=kTRUE, const Bool_t bBad=kTRUE, const Bool_t bRecalT=kTRUE, const Bool_t bNonLine=kFALSE, const Int_t minCen=-1, const Int_t maxCen=-1, const Float_t clusterEnergyCutEvent=-1, const Int_t nRowDiff=1, const Int_t nColDiff=1, const Bool_t skipOrReject=kFALSE, const Int_t tCardMimic=0, const Bool_t cellUpd=kTRUE)
TString kInputData
With real data kMC = kFALSE.
Definition: ana.C:130
Reclusterize EMCal clusters, put them in a new branch for other following analysis.
char * kDatasetPROOF
Number of files to analyze in local mode.
Definition: ana.C:105
Definition: ana.C:86
Configuration of EMCal QA.