AliPhysics  vAN-20151014 (f894c76)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
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";
38 Int_t kDatasetNMaxFiles = 20;
39 TString ccin2p3UserName = "arbor" ;
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;
56 TArrayI* trArr;
57 
58 //---------------------------------------------------------------------------
59 
60 // Set some default values, but used values are set in the code!
61 
62 Bool_t kMC = kFALSE;
63 TString kInputData = "ESD";
64 Int_t kYear = 2011;
65 TString kCollision = "pp";
66 Bool_t outAOD = kFALSE;
67 TString kTreeName;
68 TString kPass = "";
69 char kTrigger[1024];
70 Int_t kRun = 0;
71 
72 //___________________________
85 //___________________________
86 void ana(Int_t mode=mGRID)
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
246  if(kCollision=="PbPb" && kInputData=="ESD")
247  {
248  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
249  AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
250  }
251 
252  if(kCollision=="PbPb")
253  {
254  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C");
255  AliVZEROEPSelectionTask * EPV0 = AddTaskVZEROEPSelection();
256 
257  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
258  AliEPSelectionTask * EP = AddTaskEventplane();
259  }
260 
261  // Simple event counting tasks
262 
263  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/AddTaskCounter.C");
264 
265  AliAnalysisTask* count = AddTaskCounter("",kMC); // All, fill histo with cross section and trials if kMC is true
266  AliAnalysisTask* countmb = AddTaskCounter("MB"); // Min Bias
267  AliAnalysisTask* countany = AddTaskCounter("Any");
268  AliAnalysisTask* countint = AddTaskCounter("AnyINT");// Min Bias
269 
270  if(!kMC)
271  {
272  AliAnalysisTaskCounter* countemg = AddTaskCounter("EMCEGA");
273  AliAnalysisTaskCounter* countemj = AddTaskCounter("EMCEJE");
274  if(kCollision=="PbPb")
275  {
276  AliAnalysisTaskCounter* countcen = AddTaskCounter("Central");
277  AliAnalysisTaskCounter* countsce = AddTaskCounter("SemiCentral");
278  AliAnalysisTaskCounter* countssce= AddTaskCounter("SemiOrCentral");
279  AliAnalysisTaskCounter* countphP = AddTaskCounter("PHOSPb");
280  }
281  else
282  {
283  AliAnalysisTaskCounter* countem1 = AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
284  AliAnalysisTaskCounter* countem7 = AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
285  AliAnalysisTaskCounter* countphp = AddTaskCounter("PHOS");
286  }
287  }
288  // -----------------
289  // Photon conversion
290  // -----------------
291 /*
292  if(kInputData=="ESD"){
293  printf("* Configure photon conversion analysis in macro \n");
294  TString arguments = "-run-on-train -use-own-xyz -force-aod -mc-off ";
295  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
296  AliAnalysisTaskGammaConversion * taskGammaConversion =
297  ConfigGammaConversion(arguments,mgr->GetCommonInputContainer());
298  taskGammaConversion->SelectCollisionCandidates();
299 
300  // Gamma Conversion AOD to AODPWG4Particle
301  AliAnalysisTaskGCPartToPWG4Part * taskGCToPC = new AliAnalysisTaskGCPartToPWG4Part("GCPartToPWG4Part");
302  taskGCToPC->SetGammaCutId("90035620401003321022000000090");
303  mgr->AddTask(taskGCToPC);
304  mgr->ConnectInput (taskGCToPC, 0, mgr->GetCommonInputContainer() );
305  mgr->ConnectOutput (taskGCToPC, 0, mgr->GetCommonOutputContainer());
306  }
307 */
308 
309  Bool_t kPrint = kFALSE;
310  Bool_t deltaAOD = kFALSE;
311  gROOT->LoadMacro("AddTaskCaloTrackCorr.C"); // $ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros
312  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/AddTaskEMCALClusterize.C");
313 
314  //gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
315  //AliAnalysisTaskCaloTrackCorrelation * qatask = AddTaskCalorimeterQA(kInputData,kYear,kPrint,kMC);
316 
317  //gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/AddTaskEMCALTriggerQA.C");
318  //AliAnalysisTaskEMCALTriggerQA * qatrigtask = AddTaskEMCALTriggerQA();
319 
320  // Calibration, bad map ...
321 
322  Bool_t calibEE = kTRUE; // It is set automatically, but here we force to use it or not in any case
323  Bool_t calibTT = kTRUE; // It is set automatically, but here we force to use it or not in any case
324  if(kRun < 122195 || (kRun > 126437 && kRun < 136851) || kMC) calibTT=kFALSE ; // Recalibration parameters not available for LHC10a,b,c,e,f,g
325  Bool_t badMap = kTRUE; // It is set automatically, but here we force to use it or not in any case
326 
327  if(kCollision=="pp")
328  {
329  printf("==================================== \n");
330  printf("CONFIGURE ANALYSIS FOR PP COLLISIONS \n");
331  printf("==================================== \n");
332 
333  Bool_t mixing = kTRUE; // mixing in reader and hadron correlation, and pi0
334  Bool_t clTM = kTRUE;
335  Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
336  Bool_t anTM = kTRUE; // Remove matched
337  Bool_t exo = kTRUE; // Remove exotic cells
338  Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
339  Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
340  Int_t minEcell = 50; // 50 MeV (10 MeV used in reconstruction)
341  Int_t minEseed = 100; // 100 MeV
342  Int_t dTime = 0; // default, 250 ns
343  Int_t wTime = 30; // default 425 < T < 825 ns, careful if time calibration is on
344  Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
345  Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
346 
347  //Trigger
348  TString clTrigger = "";
349  TString anTrigger = "EMC7";
350 
351  if(kMC)
352  {
353  clTrigger = "";
354  anTrigger = "";
355  dTime = 0;
356  wTime = 0;
357  }
358 
359  Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
360  Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
361  Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
362 
363  //Analysis with clusterizer V1
364 
365  TString arrayNameV1 = "";
366 
367  AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
368  minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
369  calibEE,badMap,calibTT,clnonlin);
370 
371  printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
372 
373  if(!kMC)
374  {
375 
376  AliAnalysisTaskCaloTrackCorrelation *anav1trig = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
377  kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
378  -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
379  }
380 
381  AliAnalysisTaskCaloTrackCorrelation *anav1mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
382  kYear,kCollision,"AnyINT",arrayNameV1,mixing,reTM,anTM,
383  -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
384 
385 
386 
387  //Analysis with clusterizer V2
388  TString arrayNameV2 = "";
389  AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
390  minEcell,minEseed,dTime,wTime,
391  calibEE,badMap,calibTT,clnonlin);
392 
393  printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
394 
395  hadron = kFALSE;
396  if(!kMC)
397  {
398 
399 
400  AliAnalysisTaskCaloTrackCorrelation *anav2tr = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
401  kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
402  -1,-1,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
403  }
404 
405 
406  AliAnalysisTaskCaloTrackCorrelation *anav2mb = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
407  kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
408  -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
409  }
410 
411  if(kCollision=="PbPb")
412  {
413  printf("====================================== \n");
414  printf("CONFIGURE ANALYSIS FOR PbPb COLLISIONS \n");
415  printf("====================================== \n");
416  Bool_t mixing = kTRUE;
417  Bool_t clTM = kTRUE;
418  Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
419  Bool_t anTM = kTRUE; // Remove matched
420  Bool_t exo = kTRUE; // Remove exotic cells
421  Bool_t clnonlin = kTRUE; // Apply non linearity (clusterization)
422  Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
423  Int_t minEcell = 150; // 50 MeV (10 MeV used in reconstruction)
424  Int_t minEseed = 300; // 100 MeV
425  Int_t dTime = 0; // default, 250 ns
426  Int_t wTime = 0; // default 425 < T < 825 ns
427  Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
428  Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
429 
430  // Trigger
431  TString clTrigger = "";
432  TString anTrigger = "EMCGA";
433  if(kMC)
434  {
435  clTrigger = "";
436  anTrigger = "";
437  dTime = 0;
438  wTime = 0;
439  }
440 
441  Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
442  Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
443  Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
444 
445  //Analysis with clusterizer V1
446 
447  TString arrayNameV1 = "";
448  AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(arrayNameV1,outAOD,kMC,exo,"V1",clTrigger, clTM,
449  minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
450  calibEE,badMap,calibTT,clnonlin);
451 
452  printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
453 
454  if(!kMC)
455  {
456  AliAnalysisTaskCaloTrackCorrelation *anav1c = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
457  kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
458  0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
459  AliAnalysisTaskCaloTrackCorrelation *anav1m = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
460  kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
461  20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
462  AliAnalysisTaskCaloTrackCorrelation *anav1p = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
463  kYear,kCollision,anTrigger,arrayNameV1,mixing,reTM,anTM,
464  60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
465  }
466 
467  //Analysis with clusterizer V2
468 
469  TString arrayNameV2 = "";
470  AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(arrayNameV2,outAOD,kMC,exo,"V2",clTrigger, clTM,
471  minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
472  calibEE,badMap,calibTT,clnonlin);
473 
474  printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
475 
476  hadron = kFALSE;
477 
478  if(!kMC)
479  {
480 
481  AliAnalysisTaskCaloTrackCorrelation *anav2cT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
482  kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
483  0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
484  AliAnalysisTaskCaloTrackCorrelation *anav2mT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
485  kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
486  20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
487  AliAnalysisTaskCaloTrackCorrelation *anav2pT = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
488  kYear,kCollision,anTrigger,arrayNameV2,mixing,reTM,anTM,
489  60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
490  }
491 
492  AliAnalysisTaskCaloTrackCorrelation *anav2cMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
493  kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
494  0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
495  AliAnalysisTaskCaloTrackCorrelation *anav2mMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
496  kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
497  20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
498  AliAnalysisTaskCaloTrackCorrelation *anav2pMB = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
499  kYear,kCollision,"AnyINT",arrayNameV2,mixing,reTM,anTM,
500  60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint,scale,kRun);
501 
502 
503  }
504 
505  //-----------------------
506  // Run the analysis
507  //-----------------------
508  mgr->InitAnalysis();
509  mgr->PrintStatus();
510 
511  if (mode == mPlugin) mgr->StartAnalysis("grid");
512  else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
513  else mgr->StartAnalysis("local",chain);
514 
515  cout <<" Analysis ended sucessfully "<< endl ;
516 }
517 
518 //_____________________________
520 //_____________________________
521 void LoadLibraries(Int_t mode)
522 {
523  if (mode == mPROOF)
524  {
525  //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
526  gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
527  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");
528 
529  // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
530 
531  // //proof->ClearPackages();
532  // proof->UploadPackage("STEERBase");
533  // proof->UploadPackage("ESD");
534  // proof->UploadPackage("AOD");
535  // proof->UploadPackage("ANALYSIS");
536  // proof->UploadPackage("OADB");
537  // proof->UploadPackage("ANALYSISalice");
538  // proof->UploadPackage("CORRFW");
539  // //proof->UploadPackage("JETAN");
540  // proof->UploadPackage("PHOSUtils");
541  // proof->UploadPackage("EMCALUtils");
542  // proof->UploadPackage("PWGCaloTrackCorrBase");
543  // proof->UploadPackage("PWGGACaloTrackCorrelations");
544  // proof->UploadPackage("PWGPPEMCAL");
545 
546  // proof->EnablePackage("STEERBase");
547  // proof->EnablePackage("ESD");
548  // proof->EnablePackage("AOD");
549  // proof->EnablePackage("ANALYSIS");
550  // proof->EnablePackage("OADB");
551  // proof->EnablePackage("ANALYSISalice");
552  // proof->EnablePackage("CORRFW");
553  // //proof->EnablePackage("JETAN");
554  // proof->EnablePackage("PHOSUtils");
555  // proof->EnablePackage("EMCALUtils");
556  // proof->EnablePackage("PWGCaloTrackCorrBase");
557  // proof->EnablePackage("PWGGACaloTrackCorrelations");
558  // proof->EnablePackage("PWGPPEMCAL");
559  return;
560  }
561 
562  //--------------------------------------
563  // Load the needed libraries most of them already loaded by aliroot
564  //--------------------------------------
565  gSystem->Load("libTree");
566  gSystem->Load("libGeom");
567  gSystem->Load("libVMC");
568  gSystem->Load("libXMLIO");
569  gSystem->Load("libMatrix");
570  gSystem->Load("libPhysics");
571  gSystem->Load("libMinuit"); // Root + libraries to if reclusterization is done
572 
573  gSystem->Load("libSTEERBase");
574  gSystem->Load("libGui"); // Root + libraries to if reclusterization is done
575  gSystem->Load("libCDB"); // Root + libraries to if reclusterization is done
576  gSystem->Load("libESD"); // Root + libraries to if reclusterization is done
577  gSystem->Load("libAOD");
578  gSystem->Load("libRAWDatabase"); // Root + libraries to if reclusterization is done
579  gSystem->Load("libProof");
580  gSystem->Load("libOADB");
581  gSystem->Load("libANALYSIS");
582  gSystem->Load("libSTEER"); // Root + libraries to if reclusterization is done
583 
584  gSystem->Load("libRAWDatarec"); // Root + libraries to if reclusterization is done
585  gSystem->Load("libRAWDatasim"); // Root + libraries to if reclusterization is done
586  gSystem->Load("libVZERObase"); // Root + libraries to if reclusterization is done
587  gSystem->Load("libVZEROrec"); // Root + libraries to if reclusterization is done
588 
589  gSystem->Load("libPHOSUtils");
590 
591  gSystem->Load("libEMCALUtils");
592  //SetupPar("EMCALUtils");
593  gSystem->Load("libEMCALraw"); // Root + libraries to if reclusterization is done
594  gSystem->Load("libEMCALbase"); // Root + libraries to if reclusterization is done
595  gSystem->Load("libEMCALsim"); // Root + libraries to if reclusterization is done
596  gSystem->Load("libEMCALrec"); // Root + libraries to if reclusterization is done
597  //SetupPar("EMCALraw");
598  //SetupPar("EMCALbase");
599  //SetupPar("EMCALsim");
600  //SetupPar("EMCALrec");
601 
602  gSystem->Load("libANALYSISalice");
603  gSystem->Load("libESDfilter");
604 
605  gSystem->Load("libTender");
606  gSystem->Load("libTenderSupplies");
607 
608  gSystem->Load("libCORRFW");
609  gSystem->Load("libPWGTools");
610 
611  gSystem->Load("libPWGPPEMCAL");
612  //SetupPar("PWGPPEMCAL");
613 
614  gSystem->Load("libPWGCaloTrackCorrBase");
615  gSystem->Load("libPWGGACaloTrackCorrelations");
616  //SetupPar("PWGCaloTrackCorrBase");
617  //SetupPar("PWGGACaloTrackCorrelations");
618 
619  //gSystem->Load("libJETAN");
620  //gSystem->Load("FASTJETAN");
621  //gSystem->Load("PWGJE");
622 
623  //gSystem->Load("libCORRFW");
624  //gSystem->Load("libPWGGAGammaConv");
625  //SetupPar("PWGGAGammaConv");
626 
627  // needed for plugin?
628  gSystem->AddIncludePath("-I$ALICE_ROOT");
629  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
630  gSystem->AddIncludePath("-I./");
631 }
632 
633 //_________________________________
637 //_________________________________
638 void SetupPar(char* pararchivename)
639 {
640  TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
641 
642  TString parpar(Form("%s.par", pararchivename)) ;
643 
644  if ( gSystem->AccessPathName(pararchivename) )
645  {
646  TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
647  gROOT->ProcessLine(processline.Data());
648  }
649 
650  TString ocwd = gSystem->WorkingDirectory();
651  gSystem->ChangeDirectory(pararchivename);
652 
653  // check for BUILD.sh and execute
654  if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh"))
655  {
656  printf("*******************************\n");
657  printf("*** Building PAR archive ***\n");
658  cout<<pararchivename<<endl;
659  printf("*******************************\n");
660 
661  if (gSystem->Exec("PROOF-INF/BUILD.sh"))
662  {
663  Error("runProcess","Cannot Build the PAR Archive! - Abort!");
664  return -1;
665  }
666  }
667  // check for SETUP.C and execute
668  if (!gSystem->AccessPathName("PROOF-INF/SETUP.C"))
669  {
670  printf("*******************************\n");
671  printf("*** Setup PAR archive ***\n");
672  cout<<pararchivename<<endl;
673  printf("*******************************\n");
674  gROOT->Macro("PROOF-INF/SETUP.C");
675  }
676 
677  gSystem->ChangeDirectory(ocwd.Data());
678  printf("Current dir: %s\n", ocwd.Data());
679 }
680 
681 //______________________________________
683 //______________________________________
685 {
686  TString ocwd = gSystem->WorkingDirectory();
687 
688  //---------------------------------------
689  // Local files analysis
690  //---------------------------------------
691  if(mode == mLocal){
692  //If you want to add several ESD files sitting in a common directory INDIR
693  //Specify as environmental variables the directory (INDIR), the number of files
694  //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
695 
696  if(gSystem->Getenv("INDIR"))
697  kInDir = gSystem->Getenv("INDIR") ;
698  else cout<<"INDIR not set, use default: "<<kInDir<<endl;
699 
700  TString sindir(kInDir);
701  if (sindir.Contains("pass1")) kPass = "pass1";
702  else if(sindir.Contains("pass2")) kPass = "pass2";
703  else if(sindir.Contains("pass3")) kPass = "pass3";
704 
705  if(gSystem->Getenv("PATTERN"))
706  kPattern = gSystem->Getenv("PATTERN") ;
707  else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
708 
709  cout<<"INDIR : "<<kInDir<<endl;
710  cout<<"NFILES : "<<kFile<<endl;
711 
712  char fileE[120] ;
713  char fileA[120] ;
714  char fileG[120] ;
715  char fileEm[120] ;
716  for (Int_t event = 0 ; event < kFile ; event++) {
717  sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
718  sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
719  sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
720  sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
721 
722  TFile * fESD = TFile::Open(fileE) ;
723  TFile * fAOD = TFile::Open(fileA) ;
724 
725  //Check if file exists and add it, if not skip it
726  if (fESD)
727  {
728  kTreeName = "esdTree";
729  kInputData = "ESD";
730  TFile * fG = TFile::Open(fileG);
731  if(fG) { kMC = kTRUE; fG->Close();}
732  else kMC = kFALSE;
733 
734  // Get run number
735  TTree* esdTree = (TTree*)fESD->Get("esdTree");
736  AliESDEvent* esd = new AliESDEvent();
737  esd->ReadFromTree(esdTree);
738  esdTree->GetEvent(0);
739  kRun = esd->GetRunNumber();
740 
741  return;
742  }
743  else if(fAOD)
744  {
745  kTreeName = "aodTree";
746  kInputData = "AOD";
747  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
748  else kMC = kFALSE;
749 
750  // Get run number
751  TTree* aodTree = (TTree*)fAOD->Get("aodTree");
752  AliAODEvent* aod = new AliAODEvent();
753  aod->ReadFromTree(aodTree);
754  aodTree->GetEvent(0);
755  kRun = aod->GetRunNumber();
756  return;
757  }
758  else if(TFile::Open(fileEm))
759  {
760  kTreeName = "aodTree";
761  kInputData = "AOD";
762  kMC = kTRUE;
763 
764  return;
765  }
766  else if(TFile::Open(fileG))
767  {
768  kTreeName = "TE";
769  kInputData = "MC";
770  kMC = kTRUE;
771  return;
772  }
773  }
774 
775  if(fESD) fESD->Close();
776  if(fAOD) fAOD->Close();
777 
778  }// local files analysis
779 
780  //------------------------------
781  //GRID xml files
782  //-----------------------------
783  else if(mode == mGRID){
784  //Get colection file. It is specified by the environmental
785  //variable XML
786 
787  if(gSystem->Getenv("XML") )
788  kXML = gSystem->Getenv("XML");
789  else
790  sprintf(kXML, "collection.xml") ;
791 
792  if (!TFile::Open(kXML)) {
793  printf("No collection file with name -- %s -- was found\n",kXML);
794  return ;
795  }
796  else cout<<"XML file "<<kXML<<endl;
797 
798  //Load necessary libraries and connect to the GRID
799  gSystem->Load("libNetx") ;
800  gSystem->Load("libRAliEn");
801  TGrid::Connect("alien://") ;
802 
803  //Feed Grid with collection file
804  TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
805  if (! collection) {
806  AliError(Form("%s not found", kXML)) ;
807  return kFALSE ;
808  }
809  TGridResult* result = collection->GetGridResult("",0 ,0);
810 
811  for (Int_t index = 0; index < result->GetEntries(); index++) {
812  TString alienURL = result->GetKey(index, "turl") ;
813  cout << "================== " << alienURL << endl ;
814 
815  if (alienURL.Contains("pass1")) kPass = "pass1";
816  else if(alienURL.Contains("pass2")) kPass = "pass2";
817  else if(alienURL.Contains("pass3")) kPass = "pass3";
818 
819  kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
820  printf("Run number from alien path = %d\n",kRun);
821 
822  TFile * fAOD = 0 ;
823  //Check if file exists and add it, if not skip it
824  if (alienURL.Contains("AliESDs.root"))
825  {
826  kTreeName = "esdTree";
827  kInputData = "ESD";
828  alienURL.ReplaceAll("AliESDs.root","galice.root");
829  if(TFile::Open(alienURL)) kMC=kTRUE;
830  else kMC = kFALSE;
831  return;
832  }
833  else if(alienURL.Contains("AliAOD.root"))
834  {
835  kTreeName = "aodTree";
836  kInputData = "AOD";
837  fAOD = TFile::Open(alienURL);
838  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
839  else kMC = kFALSE;
840  return;
841  }
842  else if(alienURL.Contains("embededAOD.root"))
843  {
844  kTreeName = "aodTree";
845  kInputData = "AOD";
846  kMC=kTRUE;
847  return;
848  }
849  else if(alienURL.Contains("galice.root"))
850  {
851  kTreeName = "TE";
852  kInputData = "MC";
853  kMC=kTRUE;
854  return;
855  }
856  }
857  }// xml analysis
858  //------------------------------
859  //PROOF files
860  //-----------------------------
861  else if(mode == mPROOF){
862 
863  TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
864 
865  TIter iter(coll->GetList());
866 
867  TFileInfo* fileInfo = 0;
868  while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
869  {
870  if (fileInfo->GetFirstUrl()) {
871  TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
872  cout << "================== " << ProofURL << endl ;
873 
874  if (ProofURL.Contains("pass1")) kPass = "pass1";
875  else if(ProofURL.Contains("pass2")) kPass = "pass2";
876  else if(ProofURL.Contains("pass3")) kPass = "pass3";
877 
878  kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
879  printf("Run number from alien path = %d\n",kRun);
880 
881  TFile * fAOD = 0 ;
882  //Check if file exists and add it, if not skip it
883  if (ProofURL.Contains("AliESDs.root"))
884  {
885  kTreeName = "esdTree";
886  kInputData = "ESD";
887  alienURL.ReplaceAll("AliESDs.root","galice.root");
888  if(TFile::Open(ProofURL)) kMC=kTRUE;
889  else kMC = kFALSE;
890 
891  return;
892  }
893  else if(ProofURL.Contains("AliAOD.root"))
894  {
895  kTreeName = "aodTree";
896  kInputData = "AOD";
897  fAOD = TFile::Open(ProofURL);
898  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
899  else kMC = kFALSE;
900  return;
901  }
902  else if(ProofURL.Contains("embededAOD.root"))
903  {
904  kTreeName = "aodTree";
905  kInputData = "AOD";
906  kMC=kTRUE;
907  return;
908  }
909  else if(ProofURL.Contains("galice.root"))
910  {
911  kTreeName = "TE";
912  kInputData = "MC";
913  kMC=kTRUE;
914  return;
915  }
916  }
917  }
918  }// proof analysis
919 
920  gSystem->ChangeDirectory(ocwd.Data());
921 }
922 
923 //_____________________________________________________________________
925 //_____________________________________________________________________
926 void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
927 {
928  TString ocwd = gSystem->WorkingDirectory();
929 
930  if(kInputData == "AOD")
931  {
932  xsArr = new TArrayF;
933  trArr = new TArrayI;
934  }
935 
936  //---------------------------------------
937  // Local files analysis
938  //---------------------------------------
939  if(mode == mLocal)
940  {
941  //If you want to add several ESD files sitting in a common directory INDIR
942  //Specify as environmental variables the directory (INDIR), the number of files
943  //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
944 
945  if(gSystem->Getenv("INDIR"))
946  kInDir = gSystem->Getenv("INDIR") ;
947  else cout<<"INDIR not set, use default: "<<kInDir<<endl;
948 
949  if(gSystem->Getenv("PATTERN"))
950  kPattern = gSystem->Getenv("PATTERN") ;
951  else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
952 
953  if(gSystem->Getenv("NFILES"))
954  kFile = atoi(gSystem->Getenv("NFILES")) ;
955  else cout<<"NFILES not set, use default: "<<kFile<<endl;
956 
957  //Check if env variables are set and are correct
958  if ( kInDir && kFile)
959  {
960  printf("Get %d files from directory %s\n",kFile,kInDir);
961  if ( ! gSystem->cd(kInDir) )
962  {//check if ESDs directory exist
963  printf("%s does not exist\n", kInDir) ;
964  return ;
965  }
966 
967  //if(gSystem->Getenv("XSFILE"))
968  //kXSFileName = gSystem->Getenv("XSFILE") ;
969  //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
970  char * kGener = gSystem->Getenv("GENER");
971  if(kGener)
972  {
973  cout<<"GENER "<<kGener<<endl;
974  if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
975  else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
976  else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
977  }
978  else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
979 
980  if(kInputData=="AOD")
981  {
982  kXSFileName = "pyxsec_hists.root";
983  xsArr->Set(kFile);
984  trArr->Set(kFile);
985  }
986 
987  cout<<"INDIR : "<<kInDir <<endl;
988  cout<<"NFILES : "<<kFile <<endl;
989  cout<<"PATTERN : "<<kPattern <<endl;
990  cout<<"XSFILE : "<<kXSFileName<<endl;
991 
992  TString datafile="";
993  if (kInputData == "ESD") datafile = "AliESDs.root" ;
994  else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
995  else if(kInputData == "MC") datafile = "galice.root" ;
996 
997  // Loop on ESD/AOD/MC files, add them to chain
998  Int_t event =0;
999  Int_t skipped=0 ;
1000  char file[120] ;
1001  char filexs[120] ;
1002 
1003  for (event = 0 ; event < kFile ; event++) {
1004  sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
1005  sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
1006  TFile * fData = 0 ;
1007  // Check if file exists and add it, if not skip it
1008  if ( fData = TFile::Open(file))
1009  {
1010  if ( fData->Get(kTreeName) )
1011  {
1012  printf("++++ Adding %s\n", file) ;
1013  chain->AddFile(file);
1014 
1015  if(kInputData != "AOD")
1016  {
1017  chainxs->Add(filexs) ;
1018  }
1019  else
1020  {
1021  TFile* fxsec = TFile::Open(filexs);
1022  if(fxsec)
1023  {
1024  TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
1025  if(!key)
1026  {
1027  fxsec->Close();
1028  printf("No key!");
1029  continue;
1030  }
1031 
1032  TList *list = dynamic_cast<TList*>(key->ReadObj());
1033  if(!list)
1034  {
1035  fxsec->Close();
1036  printf("No list!");
1037  continue;
1038  }
1039 
1040  Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
1041  Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
1042  fxsec->Close();
1043 
1044  xsArr->SetAt(xsection,event);
1045  trArr->SetAt(ntrials,event);
1046 
1047  printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, event);
1048  //chainxs->Add(tree);
1049  //fileTMP->Close();
1050  } // fxsec exists
1051  } // xs in AODs
1052 
1053  }
1054  }
1055  else
1056  {
1057  printf("---- Skipping %s\n", file) ;
1058  skipped++ ;
1059  }
1060  }
1061  }
1062  else {
1063  TString input = "AliESDs.root" ;
1064  cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
1065  chain->AddFile(input);
1066  }
1067 
1068  }// local files analysis
1069 
1070  //------------------------------
1071  // GRID xml files
1072  //------------------------------
1073  else if(mode == mGRID)
1074  {
1075  //Get colection file. It is specified by the environmental
1076  //variable XML
1077 
1078  //Feed Grid with collection file
1079  TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
1080  if (! collection) {
1081  AliError(Form("%s not found", kXML)) ;
1082  return kFALSE ;
1083  }
1084 
1085  TGridResult* result = collection->GetGridResult("",0 ,0);
1086 
1087  // Makes the ESD chain
1088  printf("*** Getting the Chain ***\n");
1089  for (Int_t index = 0; index < result->GetEntries(); index++) {
1090  TString alienURL = result->GetKey(index, "turl") ;
1091  cout << "================== " << alienURL << endl ;
1092  chain->Add(alienURL) ;
1093 
1094  if(kInputData != "AOD")
1095  {
1096  alienURL.ReplaceAll("AliESDs.root",kXSFileName);
1097  alienURL.ReplaceAll("AliAOD.root",kXSFileName);
1098  chainxs->Add(alienURL) ;
1099  }
1100  else
1101  {
1102  alienURL.ReplaceAll("AliESDs.root","pyxsec_hists.root");
1103  alienURL.ReplaceAll("AliAOD.root", "pyxsec_hists.root");
1104  TFile* fxsec = TFile::Open(alienURL);
1105  if(fxsec)
1106  {
1107  TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
1108  if(!key)
1109  {
1110  fxsec->Close();
1111  printf("No key!");
1112  continue;
1113  }
1114 
1115  TList *list = dynamic_cast<TList*>(key->ReadObj());
1116  if(!list)
1117  {
1118  fxsec->Close();
1119  printf("No list!");
1120  continue;
1121  }
1122 
1123  Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
1124  Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
1125  fxsec->Close();
1126 
1127  xsArr->SetAt(xsection,event);
1128  trArr->SetAt(ntrials,event);
1129 
1130  printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, event);
1131 
1132  } // fxsec exists
1133  } // xs in AODs
1134  }
1135  }// xml analysis
1136 
1137  //------------------------------
1138  // PROOF
1139  //------------------------------
1140  else if (mode == mPROOF)
1141  {
1142  TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
1143 
1144  gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
1145  chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
1146  printf("chain has %d entries\n",chain->GetEntries());
1147  }
1148 
1149  gSystem->ChangeDirectory(ocwd.Data());
1150 }
1151 
1152 //______________________________
1156 //______________________________
1158 {
1159  sprintf(kTrigger,"");
1160 
1161  Bool_t bRecalibrate = kFALSE;
1162  Bool_t bBadChannel = kFALSE;
1163 
1164  for (int i=0; i< gApplication->Argc();i++){
1165 
1166 #ifdef VERBOSEARGS
1167 
1168  printf("Arg %d: %s\n",i,gApplication->Argv(i));
1169 
1170 #endif
1171 
1172  TString sRun = "";
1173 
1174  if (!(strcmp(gApplication->Argv(i),"--trigger")))
1175  sprintf(trigger,gApplication->Argv(i+1));
1176 
1177  if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
1178  bRecalibrate = atoi(gApplication->Argv(i+1));
1179 
1180  if (!(strcmp(gApplication->Argv(i),"--badchannel")))
1181  bBadChannel = atoi(gApplication->Argv(i+1));
1182 
1183  if (!(strcmp(gApplication->Argv(i),"--run")))
1184  {
1185  sRun = gApplication->Argv(i+1);
1186  if(sRun.Contains("LHC10")) {
1187  kYear = 2010;
1188  }
1189  else {
1190  if(kRun <=0){
1191  kRun = atoi(gApplication->Argv(i+1));
1192  }
1193  else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
1194  }//numeric run
1195  }//--run available
1196 
1197  }// args loop
1198 
1199  if(!sRun.Contains("LHC10"))
1200  {
1201  if ( kRun < 140000)
1202  {
1203  kYear = 2010;
1204  if( kRun >= 136851 ) kCollision = "PbPb";
1205  }
1206  else if( kRun < 170600)
1207  {
1208  kYear = 2011;
1209  if( kRun >= 166500 ) kCollision = "PbPb";
1210  }
1211  else if( kRun < 200000 )
1212  {
1213  kYear = 2012;
1214  if( kRun >= 194000 ) kCollision = "pPb";
1215  }
1216  else
1217  {
1218  kYear = 2015;
1219  }
1220  }
1221 
1222  if(kMC) sprintf(kTrigger,"");
1223 
1224  printf("*********************************************\n");
1225  //printf("*** Settings trigger %s, recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
1226  // kTrigger,bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
1227  printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
1228  printf("*********************************************\n");
1229 
1230 }
1231 
1232 //______________________________________________________________________________
1246 //______________________________________________________________________________
1247 Bool_t GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr, Int_t & n)
1248 {
1249  Double_t xsection = 0 ;
1250  UInt_t ntrials = 0 ;
1251  Int_t nfiles = 0 ;
1252 
1253  xs = 0;
1254  ntr = 0;
1255  n = 0;
1256  if( kInputData != "AOD" && tree))
1257  {
1258  nfiles = tree->GetEntries() ;
1259 
1260  tree->SetBranchAddress("xsection",&xsection);
1261  tree->SetBranchAddress("ntrials" ,&ntrials );
1262  for(Int_t i = 0; i < nfiles; i++)
1263  {
1264  tree->GetEntry(i);
1265  if(xsection > 0)
1266  {
1267  xs += xsection ;
1268  ntr += ntrials ;
1269  n++;
1270  }
1271  cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
1272  } // loop
1273  }
1274  else if( kInputData == "AOD" && xsArr))
1275  {
1276  nfiles = xsArr->GetSize();
1277 
1278  for(Int_t i = 0; i < nfiles; i++)
1279  {
1280  if(xsArr->GetAt(i) > 0)
1281  {
1282  xs += xsArr->GetAt(i) ;
1283  ntr += trArr->GetAt(i) ;
1284  n++;
1285  }
1286  cout << "xsection " <<xsArr->GetAt(i)<<" ntrials "<<trArr->GetAt(i)<<endl;
1287  } // loop
1288  }
1289  else return kFALSE;
1290 
1291  xs = xs / n;
1292  ntr = ntr / n;
1293  cout << "-----------------------------------------------------------------"<<endl;
1294  cout << "Average of "<< n <<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
1295  cout << "-----------------------------------------------------------------"<<endl;
1296 
1297  return kTRUE;
1298 }
1299 
1300 
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
Bool_t GetAverageXsection(TTree *tree, Double_t &xs, Float_t &ntr, Int_t &n)
Definition: ana.C:1247
void LoadLibraries(Int_t mode)
Load analysis libraries.
Definition: ana.C:521
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:926
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
AliAnalysisAlien * CreateAlienHandler()
Definition: MakeTrend.C:48
Int_t kYear
ESD, AOD, MC, deltaAOD.
Definition: ana.C:64
TArrayI * trArr
Definition: ana.C:56
void CheckEnvironmentVariables()
Definition: ana.C:1157
char * kInDir
Definition: ana.C:29
TString kTreeName
Some tasks doesnt need it.
Definition: ana.C:67
void CheckInputData(const anaModes mode)
Sets input data and tree strings.
Definition: ana.C:684
AliAnalysisTaskCounter * AddTaskCounter(const TString trigger="", Bool_t xsOn=kFALSE)
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:638
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
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