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