AliPhysics  vAN-20150425 (2dcf1b0)
 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/PWGGA/EMCALTasks/macros/AddTaskEMCALClusterize.C"); // $ALICE_PHYSICS/PWGGA/EMCALTasks/macros
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/PWGGA/EMCALTasks/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:PWGEMCAL:PWGGAEMCALTasks");
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("PWGEMCAL");
545  // proof->UploadPackage("PWGGAEMCALTasks");
546 
547  // proof->EnablePackage("STEERBase");
548  // proof->EnablePackage("ESD");
549  // proof->EnablePackage("AOD");
550  // proof->EnablePackage("ANALYSIS");
551  // proof->EnablePackage("OADB");
552  // proof->EnablePackage("ANALYSISalice");
553  // proof->EnablePackage("CORRFW");
554  // //proof->EnablePackage("JETAN");
555  // proof->EnablePackage("PHOSUtils");
556  // proof->EnablePackage("EMCALUtils");
557  // proof->EnablePackage("PWGCaloTrackCorrBase");
558  // proof->EnablePackage("PWGGACaloTrackCorrelations");
559  // proof->EnablePackage("PWGEMCAL");
560  // proof->EnablePackage("PWGGAEMCALTasks");
561  return;
562  }
563 
564  //--------------------------------------
565  // Load the needed libraries most of them already loaded by aliroot
566  //--------------------------------------
567  gSystem->Load("libTree");
568  gSystem->Load("libGeom");
569  gSystem->Load("libVMC");
570  gSystem->Load("libXMLIO");
571  gSystem->Load("libMatrix");
572  gSystem->Load("libPhysics");
573  gSystem->Load("libMinuit"); // Root + libraries to if reclusterization is done
574 
575  gSystem->Load("libSTEERBase");
576  gSystem->Load("libGui"); // Root + libraries to if reclusterization is done
577  gSystem->Load("libCDB"); // Root + libraries to if reclusterization is done
578  gSystem->Load("libESD"); // Root + libraries to if reclusterization is done
579  gSystem->Load("libAOD");
580  gSystem->Load("libRAWDatabase"); // Root + libraries to if reclusterization is done
581  gSystem->Load("libProof");
582  gSystem->Load("libOADB");
583  gSystem->Load("libANALYSIS");
584  gSystem->Load("libSTEER"); // Root + libraries to if reclusterization is done
585 
586  gSystem->Load("libRAWDatarec"); // Root + libraries to if reclusterization is done
587  gSystem->Load("libRAWDatasim"); // Root + libraries to if reclusterization is done
588  gSystem->Load("libVZERObase"); // Root + libraries to if reclusterization is done
589  gSystem->Load("libVZEROrec"); // Root + libraries to if reclusterization is done
590 
591  gSystem->Load("libPHOSUtils");
592 
593  gSystem->Load("libEMCALUtils");
594  //SetupPar("EMCALUtils");
595  gSystem->Load("libEMCALraw"); // Root + libraries to if reclusterization is done
596  gSystem->Load("libEMCALbase"); // Root + libraries to if reclusterization is done
597  gSystem->Load("libEMCALsim"); // Root + libraries to if reclusterization is done
598  gSystem->Load("libEMCALrec"); // Root + libraries to if reclusterization is done
599  //SetupPar("EMCALraw");
600  //SetupPar("EMCALbase");
601  //SetupPar("EMCALsim");
602  //SetupPar("EMCALrec");
603 
604  gSystem->Load("libANALYSISalice");
605  gSystem->Load("libESDfilter");
606 
607  gSystem->Load("libTender");
608  gSystem->Load("libTenderSupplies");
609 
610  gSystem->Load("libCORRFW");
611  gSystem->Load("libPWGTools");
612 
613  gSystem->Load("libPWGEMCAL");
614  gSystem->Load("libPWGGAEMCALTasks");
615  //SetupPar("PWGEMCAL");
616  //SetupPar("PWGGAEMCALTasks");
617 
618  gSystem->Load("libPWGCaloTrackCorrBase");
619  gSystem->Load("libPWGGACaloTrackCorrelations");
620  //SetupPar("PWGCaloTrackCorrBase");
621  //SetupPar("PWGGACaloTrackCorrelations");
622 
623  //gSystem->Load("libJETAN");
624  //gSystem->Load("FASTJETAN");
625  //gSystem->Load("PWGJE");
626 
627  //gSystem->Load("libCORRFW");
628  //gSystem->Load("libPWGGAGammaConv");
629  //SetupPar("PWGGAGammaConv");
630 
631  // needed for plugin?
632  gSystem->AddIncludePath("-I$ALICE_ROOT");
633  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
634  gSystem->AddIncludePath("-I./");
635 }
636 
637 //_________________________________
641 //_________________________________
642 void SetupPar(char* pararchivename)
643 {
644  TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
645 
646  TString parpar(Form("%s.par", pararchivename)) ;
647 
648  if ( gSystem->AccessPathName(pararchivename) )
649  {
650  TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
651  gROOT->ProcessLine(processline.Data());
652  }
653 
654  TString ocwd = gSystem->WorkingDirectory();
655  gSystem->ChangeDirectory(pararchivename);
656 
657  // check for BUILD.sh and execute
658  if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh"))
659  {
660  printf("*******************************\n");
661  printf("*** Building PAR archive ***\n");
662  cout<<pararchivename<<endl;
663  printf("*******************************\n");
664 
665  if (gSystem->Exec("PROOF-INF/BUILD.sh"))
666  {
667  Error("runProcess","Cannot Build the PAR Archive! - Abort!");
668  return -1;
669  }
670  }
671  // check for SETUP.C and execute
672  if (!gSystem->AccessPathName("PROOF-INF/SETUP.C"))
673  {
674  printf("*******************************\n");
675  printf("*** Setup PAR archive ***\n");
676  cout<<pararchivename<<endl;
677  printf("*******************************\n");
678  gROOT->Macro("PROOF-INF/SETUP.C");
679  }
680 
681  gSystem->ChangeDirectory(ocwd.Data());
682  printf("Current dir: %s\n", ocwd.Data());
683 }
684 
685 //______________________________________
687 //______________________________________
689 {
690  TString ocwd = gSystem->WorkingDirectory();
691 
692  //---------------------------------------
693  // Local files analysis
694  //---------------------------------------
695  if(mode == mLocal){
696  //If you want to add several ESD files sitting in a common directory INDIR
697  //Specify as environmental variables the directory (INDIR), the number of files
698  //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
699 
700  if(gSystem->Getenv("INDIR"))
701  kInDir = gSystem->Getenv("INDIR") ;
702  else cout<<"INDIR not set, use default: "<<kInDir<<endl;
703 
704  TString sindir(kInDir);
705  if (sindir.Contains("pass1")) kPass = "pass1";
706  else if(sindir.Contains("pass2")) kPass = "pass2";
707  else if(sindir.Contains("pass3")) kPass = "pass3";
708 
709  if(gSystem->Getenv("PATTERN"))
710  kPattern = gSystem->Getenv("PATTERN") ;
711  else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
712 
713  cout<<"INDIR : "<<kInDir<<endl;
714  cout<<"NFILES : "<<kFile<<endl;
715 
716  char fileE[120] ;
717  char fileA[120] ;
718  char fileG[120] ;
719  char fileEm[120] ;
720  for (Int_t event = 0 ; event < kFile ; event++) {
721  sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
722  sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
723  sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
724  sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
725 
726  TFile * fESD = TFile::Open(fileE) ;
727  TFile * fAOD = TFile::Open(fileA) ;
728 
729  //Check if file exists and add it, if not skip it
730  if (fESD)
731  {
732  kTreeName = "esdTree";
733  kInputData = "ESD";
734  TFile * fG = TFile::Open(fileG);
735  if(fG) { kMC = kTRUE; fG->Close();}
736  else kMC = kFALSE;
737 
738  // Get run number
739  TTree* esdTree = (TTree*)fESD->Get("esdTree");
740  AliESDEvent* esd = new AliESDEvent();
741  esd->ReadFromTree(esdTree);
742  esdTree->GetEvent(0);
743  kRun = esd->GetRunNumber();
744 
745  return;
746  }
747  else if(fAOD)
748  {
749  kTreeName = "aodTree";
750  kInputData = "AOD";
751  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
752  else kMC = kFALSE;
753 
754  // Get run number
755  TTree* aodTree = (TTree*)fAOD->Get("aodTree");
756  AliAODEvent* aod = new AliAODEvent();
757  aod->ReadFromTree(aodTree);
758  aodTree->GetEvent(0);
759  kRun = aod->GetRunNumber();
760  return;
761  }
762  else if(TFile::Open(fileEm))
763  {
764  kTreeName = "aodTree";
765  kInputData = "AOD";
766  kMC = kTRUE;
767 
768  return;
769  }
770  else if(TFile::Open(fileG))
771  {
772  kTreeName = "TE";
773  kInputData = "MC";
774  kMC = kTRUE;
775  return;
776  }
777  }
778 
779  if(fESD) fESD->Close();
780  if(fAOD) fAOD->Close();
781 
782  }// local files analysis
783 
784  //------------------------------
785  //GRID xml files
786  //-----------------------------
787  else if(mode == mGRID){
788  //Get colection file. It is specified by the environmental
789  //variable XML
790 
791  if(gSystem->Getenv("XML") )
792  kXML = gSystem->Getenv("XML");
793  else
794  sprintf(kXML, "collection.xml") ;
795 
796  if (!TFile::Open(kXML)) {
797  printf("No collection file with name -- %s -- was found\n",kXML);
798  return ;
799  }
800  else cout<<"XML file "<<kXML<<endl;
801 
802  //Load necessary libraries and connect to the GRID
803  gSystem->Load("libNetx") ;
804  gSystem->Load("libRAliEn");
805  TGrid::Connect("alien://") ;
806 
807  //Feed Grid with collection file
808  TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
809  if (! collection) {
810  AliError(Form("%s not found", kXML)) ;
811  return kFALSE ;
812  }
813  TGridResult* result = collection->GetGridResult("",0 ,0);
814 
815  for (Int_t index = 0; index < result->GetEntries(); index++) {
816  TString alienURL = result->GetKey(index, "turl") ;
817  cout << "================== " << alienURL << endl ;
818 
819  if (alienURL.Contains("pass1")) kPass = "pass1";
820  else if(alienURL.Contains("pass2")) kPass = "pass2";
821  else if(alienURL.Contains("pass3")) kPass = "pass3";
822 
823  kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
824  printf("Run number from alien path = %d\n",kRun);
825 
826  TFile * fAOD = 0 ;
827  //Check if file exists and add it, if not skip it
828  if (alienURL.Contains("AliESDs.root"))
829  {
830  kTreeName = "esdTree";
831  kInputData = "ESD";
832  alienURL.ReplaceAll("AliESDs.root","galice.root");
833  if(TFile::Open(alienURL)) kMC=kTRUE;
834  else kMC = kFALSE;
835  return;
836  }
837  else if(alienURL.Contains("AliAOD.root"))
838  {
839  kTreeName = "aodTree";
840  kInputData = "AOD";
841  fAOD = TFile::Open(alienURL);
842  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
843  else kMC = kFALSE;
844  return;
845  }
846  else if(alienURL.Contains("embededAOD.root"))
847  {
848  kTreeName = "aodTree";
849  kInputData = "AOD";
850  kMC=kTRUE;
851  return;
852  }
853  else if(alienURL.Contains("galice.root"))
854  {
855  kTreeName = "TE";
856  kInputData = "MC";
857  kMC=kTRUE;
858  return;
859  }
860  }
861  }// xml analysis
862  //------------------------------
863  //PROOF files
864  //-----------------------------
865  else if(mode == mPROOF){
866 
867  TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
868 
869  TIter iter(coll->GetList());
870 
871  TFileInfo* fileInfo = 0;
872  while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
873  {
874  if (fileInfo->GetFirstUrl()) {
875  TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
876  cout << "================== " << ProofURL << endl ;
877 
878  if (ProofURL.Contains("pass1")) kPass = "pass1";
879  else if(ProofURL.Contains("pass2")) kPass = "pass2";
880  else if(ProofURL.Contains("pass3")) kPass = "pass3";
881 
882  kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
883  printf("Run number from alien path = %d\n",kRun);
884 
885  TFile * fAOD = 0 ;
886  //Check if file exists and add it, if not skip it
887  if (ProofURL.Contains("AliESDs.root"))
888  {
889  kTreeName = "esdTree";
890  kInputData = "ESD";
891  alienURL.ReplaceAll("AliESDs.root","galice.root");
892  if(TFile::Open(ProofURL)) kMC=kTRUE;
893  else kMC = kFALSE;
894 
895  return;
896  }
897  else if(ProofURL.Contains("AliAOD.root"))
898  {
899  kTreeName = "aodTree";
900  kInputData = "AOD";
901  fAOD = TFile::Open(ProofURL);
902  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
903  else kMC = kFALSE;
904  return;
905  }
906  else if(ProofURL.Contains("embededAOD.root"))
907  {
908  kTreeName = "aodTree";
909  kInputData = "AOD";
910  kMC=kTRUE;
911  return;
912  }
913  else if(ProofURL.Contains("galice.root"))
914  {
915  kTreeName = "TE";
916  kInputData = "MC";
917  kMC=kTRUE;
918  return;
919  }
920  }
921  }
922  }// proof analysis
923 
924  gSystem->ChangeDirectory(ocwd.Data());
925 }
926 
927 //_____________________________________________________________________
929 //_____________________________________________________________________
930 void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
931 {
932  TString ocwd = gSystem->WorkingDirectory();
933 
934  if(kInputData == "AOD")
935  {
936  xsArr = new TArrayF;
937  trArr = new TArrayI;
938  }
939 
940  //---------------------------------------
941  // Local files analysis
942  //---------------------------------------
943  if(mode == mLocal)
944  {
945  //If you want to add several ESD files sitting in a common directory INDIR
946  //Specify as environmental variables the directory (INDIR), the number of files
947  //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
948 
949  if(gSystem->Getenv("INDIR"))
950  kInDir = gSystem->Getenv("INDIR") ;
951  else cout<<"INDIR not set, use default: "<<kInDir<<endl;
952 
953  if(gSystem->Getenv("PATTERN"))
954  kPattern = gSystem->Getenv("PATTERN") ;
955  else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
956 
957  if(gSystem->Getenv("NFILES"))
958  kFile = atoi(gSystem->Getenv("NFILES")) ;
959  else cout<<"NFILES not set, use default: "<<kFile<<endl;
960 
961  //Check if env variables are set and are correct
962  if ( kInDir && kFile)
963  {
964  printf("Get %d files from directory %s\n",kFile,kInDir);
965  if ( ! gSystem->cd(kInDir) )
966  {//check if ESDs directory exist
967  printf("%s does not exist\n", kInDir) ;
968  return ;
969  }
970 
971  //if(gSystem->Getenv("XSFILE"))
972  //kXSFileName = gSystem->Getenv("XSFILE") ;
973  //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
974  char * kGener = gSystem->Getenv("GENER");
975  if(kGener)
976  {
977  cout<<"GENER "<<kGener<<endl;
978  if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
979  else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
980  else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
981  }
982  else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
983 
984  if(kInputData=="AOD")
985  {
986  kXSFileName = "pyxsec_hists.root";
987  xsArr->Set(kFile);
988  trArr->Set(kFile);
989  }
990 
991  cout<<"INDIR : "<<kInDir <<endl;
992  cout<<"NFILES : "<<kFile <<endl;
993  cout<<"PATTERN : "<<kPattern <<endl;
994  cout<<"XSFILE : "<<kXSFileName<<endl;
995 
996  TString datafile="";
997  if (kInputData == "ESD") datafile = "AliESDs.root" ;
998  else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
999  else if(kInputData == "MC") datafile = "galice.root" ;
1000 
1001  // Loop on ESD/AOD/MC files, add them to chain
1002  Int_t event =0;
1003  Int_t skipped=0 ;
1004  char file[120] ;
1005  char filexs[120] ;
1006 
1007  for (event = 0 ; event < kFile ; event++) {
1008  sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
1009  sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
1010  TFile * fData = 0 ;
1011  // Check if file exists and add it, if not skip it
1012  if ( fData = TFile::Open(file))
1013  {
1014  if ( fData->Get(kTreeName) )
1015  {
1016  printf("++++ Adding %s\n", file) ;
1017  chain->AddFile(file);
1018 
1019  if(kInputData != "AOD")
1020  {
1021  chainxs->Add(filexs) ;
1022  }
1023  else
1024  {
1025  TFile* fxsec = TFile::Open(filexs);
1026  if(fxsec)
1027  {
1028  TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
1029  if(!key)
1030  {
1031  fxsec->Close();
1032  printf("No key!");
1033  continue;
1034  }
1035 
1036  TList *list = dynamic_cast<TList*>(key->ReadObj());
1037  if(!list)
1038  {
1039  fxsec->Close();
1040  printf("No list!");
1041  continue;
1042  }
1043 
1044  Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
1045  Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
1046  fxsec->Close();
1047 
1048  xsArr->SetAt(xsection,event);
1049  trArr->SetAt(ntrials,event);
1050 
1051  printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, event);
1052  //chainxs->Add(tree);
1053  //fileTMP->Close();
1054  } // fxsec exists
1055  } // xs in AODs
1056 
1057  }
1058  }
1059  else
1060  {
1061  printf("---- Skipping %s\n", file) ;
1062  skipped++ ;
1063  }
1064  }
1065  }
1066  else {
1067  TString input = "AliESDs.root" ;
1068  cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
1069  chain->AddFile(input);
1070  }
1071 
1072  }// local files analysis
1073 
1074  //------------------------------
1075  // GRID xml files
1076  //------------------------------
1077  else if(mode == mGRID)
1078  {
1079  //Get colection file. It is specified by the environmental
1080  //variable XML
1081 
1082  //Feed Grid with collection file
1083  TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
1084  if (! collection) {
1085  AliError(Form("%s not found", kXML)) ;
1086  return kFALSE ;
1087  }
1088 
1089  TGridResult* result = collection->GetGridResult("",0 ,0);
1090 
1091  // Makes the ESD chain
1092  printf("*** Getting the Chain ***\n");
1093  for (Int_t index = 0; index < result->GetEntries(); index++) {
1094  TString alienURL = result->GetKey(index, "turl") ;
1095  cout << "================== " << alienURL << endl ;
1096  chain->Add(alienURL) ;
1097 
1098  if(kInputData != "AOD")
1099  {
1100  alienURL.ReplaceAll("AliESDs.root",kXSFileName);
1101  alienURL.ReplaceAll("AliAOD.root",kXSFileName);
1102  chainxs->Add(alienURL) ;
1103  }
1104  else
1105  {
1106  alienURL.ReplaceAll("AliESDs.root","pyxsec_hists.root");
1107  alienURL.ReplaceAll("AliAOD.root", "pyxsec_hists.root");
1108  TFile* fxsec = TFile::Open(alienURL);
1109  if(fxsec)
1110  {
1111  TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
1112  if(!key)
1113  {
1114  fxsec->Close();
1115  printf("No key!");
1116  continue;
1117  }
1118 
1119  TList *list = dynamic_cast<TList*>(key->ReadObj());
1120  if(!list)
1121  {
1122  fxsec->Close();
1123  printf("No list!");
1124  continue;
1125  }
1126 
1127  Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
1128  Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
1129  fxsec->Close();
1130 
1131  xsArr->SetAt(xsection,event);
1132  trArr->SetAt(ntrials,event);
1133 
1134  printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, event);
1135 
1136  } // fxsec exists
1137  } // xs in AODs
1138  }
1139  }// xml analysis
1140 
1141  //------------------------------
1142  // PROOF
1143  //------------------------------
1144  else if (mode == mPROOF)
1145  {
1146  TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
1147 
1148  gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
1149  chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
1150  printf("chain has %d entries\n",chain->GetEntries());
1151  }
1152 
1153  gSystem->ChangeDirectory(ocwd.Data());
1154 }
1155 
1156 //______________________________
1160 //______________________________
1162 {
1163  sprintf(kTrigger,"");
1164 
1165  Bool_t bRecalibrate = kFALSE;
1166  Bool_t bBadChannel = kFALSE;
1167 
1168  for (int i=0; i< gApplication->Argc();i++){
1169 
1170 #ifdef VERBOSEARGS
1171 
1172  printf("Arg %d: %s\n",i,gApplication->Argv(i));
1173 
1174 #endif
1175 
1176  TString sRun = "";
1177 
1178  if (!(strcmp(gApplication->Argv(i),"--trigger")))
1179  sprintf(trigger,gApplication->Argv(i+1));
1180 
1181  if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
1182  bRecalibrate = atoi(gApplication->Argv(i+1));
1183 
1184  if (!(strcmp(gApplication->Argv(i),"--badchannel")))
1185  bBadChannel = atoi(gApplication->Argv(i+1));
1186 
1187  if (!(strcmp(gApplication->Argv(i),"--run")))
1188  {
1189  sRun = gApplication->Argv(i+1);
1190  if(sRun.Contains("LHC10")) {
1191  kYear = 2010;
1192  }
1193  else {
1194  if(kRun <=0){
1195  kRun = atoi(gApplication->Argv(i+1));
1196  }
1197  else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
1198  }//numeric run
1199  }//--run available
1200 
1201  }// args loop
1202 
1203  if(!sRun.Contains("LHC10"))
1204  {
1205  if ( kRun < 140000)
1206  {
1207  kYear = 2010;
1208  if( kRun >= 136851 ) kCollision = "PbPb";
1209  }
1210  else if( kRun < 170600)
1211  {
1212  kYear = 2011;
1213  if( kRun >= 166500 ) kCollision = "PbPb";
1214  }
1215  else
1216  {
1217  kYear = 2012;
1218 
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:930
Bool_t kPrint
Global variables to be accessed by the different methods.
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:1161
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:688
AliAnalysisTaskCounter * AddTaskCounter(const TString trigger="", Bool_t xsOn=kFALSE)
Int_t kRun
Definition: ana.C:70
Bool_t outAOD
Definition: ana.C:66
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:642
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
char * kDatasetPROOF
Number of files to analyze in local mode.
Definition: ana.C:37
Definition: ana.C:18