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