Make friends available after the AliAnalysisManager::Init() phase
[u/mrichter/AliRoot.git] / PWGGA / CaloTrackCorrelations / macros / ana.C
CommitLineData
d92b41ad 1/* $Id: $ */
d92b41ad 2//--------------------------------------------------
3// Example macro to do analysis with the
745913ae 4// analysis classes in CaloTrackCorrelations
d92b41ad 5// Can be executed with Root and AliRoot
6//
7// Pay attention to the options and definitions
8// set in the lines below
9//
10// Author : Gustavo Conesa Balbastre (INFN-LNF)
11//
12//-------------------------------------------------
3c867778 13enum anaModes {mLocal=0, mPROOF=1, mPlugin=2, mGRID=3};
2244659d 14//mLocal = 0: Analyze locally files in your computer
3c867778 15//mPROOF = 1: Analyze files on GRID with Plugin
16//mPlugin = 2: Analyze files on GRID with Plugin
17//mGRID = 3: Analyze files on GRID, jobs launched from aliensh
d92b41ad 18
19//---------------------------------------------------------------------------
3c867778 20// Settings to read locally several files, only for "mLocal" mode
21// The different values are default, they can be set with environmental
22// variables: INDIR, PATTERN, NFILES, respectivelly
54769bc0 23
3c867778 24char * kInDir = "/user/data/files/";
3e0577a2 25char * kPattern = ""; // Data are in files kInDir/kPattern+i
531f682d 26Int_t kFile = 3;
3c867778 27
d92b41ad 28//---------------------------------------------------------------------------
3c867778 29// Dataset for proof analysis, mode=mPROOF
30// char * kDataset = "/alice/vernet/PbPb_LHC10h_ESD";
31
32char * kDatasetPROOF = "/alice/vernet/LHC11b_149646";
33//char * kDatasetPROOF = "/alice/vernet/LHC11b10a_AOD046";//LHC11d_AOD076
34Int_t kDatasetNMaxFiles = 20;
35TString ccin2p3UserName = "arbor" ;
36TString alienUserName = "narbor" ;
37
38//---------------------------------------------------------------------------
39// Collection file for grid analysis
40
d92b41ad 41char * kXML = "collection.xml";
3c867778 42
d92b41ad 43//---------------------------------------------------------------------------
44//Scale histograms from file. Change to kTRUE when xsection file exists
45//Put name of file containing xsection
46//Put number of events per ESD file
47//This is an specific case for normalization of Pythia files.
48const Bool_t kGetXSectionFromFileAndScale = kFALSE ;
49const char * kXSFileName = "pyxsec.root";
54769bc0 50
d92b41ad 51//---------------------------------------------------------------------------
52
193828fd 53//Set some default values, but used values are set in the code!
54
3c867778 55Bool_t kMC = kFALSE; //With real data kMC = kFALSE
193828fd 56TString kInputData = "ESD"; //ESD, AOD, MC, deltaAOD
3c867778 57Int_t kYear = 2011;
193828fd 58TString kCollision = "pp";
3c867778 59Bool_t outAOD = kTRUE; //Some tasks doesnt need it.
2244659d 60TString kTreeName;
3c867778 61TString kPass = "";
193828fd 62char kTrigger[1024];
3c867778 63Int_t kRun = 0;
7175a03a 64
3c867778 65//________________________
193828fd 66void ana(Int_t mode=mGRID)
d92b41ad 67{
68 // Main
cd54ca47 69
d92b41ad 70 //--------------------------------------------------------------------
71 // Load analysis libraries
72 // Look at the method below,
73 // change whatever you need for your analysis case
74 // ------------------------------------------------------------------
193828fd 75
3c867778 76 LoadLibraries(mode) ;
193828fd 77 //gSystem->ListLibraries();
2244659d 78
d92b41ad 79 //-------------------------------------------------------------------------------------------------
80 //Create chain from ESD and from cross sections files, look below for options.
c8fe2783 81 //-------------------------------------------------------------------------------------------------
54769bc0 82
193828fd 83 // Set kInputData and kTreeName looking to the kINDIR
cd54ca47 84
193828fd 85 CheckInputData(mode);
cd54ca47 86
193828fd 87 // Check global analysis settings
cd54ca47 88
193828fd 89 CheckEnvironmentVariables();
90
91 printf("*********************************************\n");
92 printf("*** Input data < %s >, pass %s, tree < %s >, MC? < %d > ***\n",kInputData.Data(),kPass.Data(),kTreeName.Data(),kMC);
93 printf("*********************************************\n");
2244659d 94
193828fd 95 TChain * chain = new TChain(kTreeName) ;
d92b41ad 96 TChain * chainxs = new TChain("Xsection") ;
193828fd 97 CreateChain(mode, chain, chainxs);
54769bc0 98
193828fd 99 printf("*********************************************\n");
100 printf("number of entries # %lld, skipped %d\n", chain->GetEntries()) ;
101 printf("*********************************************\n");
102
3c867778 103 if(!chain)
104 {
193828fd 105 printf("STOP, no chain available\n");
106 return;
107 }
108
109 AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
cd54ca47 110
15882d9f 111 //------------------------------------------
112 // Alien handler part
113 //------------------------------------------
114 AliAnalysisGrid *alienHandler=0x0;
3c867778 115 if(mode==mPlugin)
116 {
15882d9f 117 // Create and configure the alien handler plugin
118 gROOT->LoadMacro("CreateAlienHandler.C");
119 alienHandler = CreateAlienHandler();
120 if (!alienHandler) return;
121 }
122
193828fd 123 //--------------------------------------
124 // Make the analysis manager
125 //-------------------------------------
126 AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
127 //AliAnalysisManager::SetUseProgressBar(kTRUE);
128 //mgr->SetSkipTerminate(kTRUE);
129 //mgr->SetNSysInfo(1);
130
3c867778 131 if(mode==mPlugin)
132 {
15882d9f 133 // Connect plugin to the analysis manager
134 mgr->SetGridHandler(alienHandler);
135 }
136
193828fd 137 // MC handler
3c867778 138 if((kMC || kInputData == "MC") && !kInputData.Contains("AOD"))
139 {
193828fd 140 AliMCEventHandler* mcHandler = new AliMCEventHandler();
141 mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
142 mgr->SetMCtruthEventHandler(mcHandler);
3c867778 143 if( kInputData == "MC")
144 {
193828fd 145 cout<<"MC INPUT EVENT HANDLER"<<endl;
146 mgr->SetInputEventHandler(NULL);
d92b41ad 147 }
193828fd 148 }
149
745913ae 150
193828fd 151 // AOD output handler
3c867778 152 if(kInputData!="deltaAOD" && outAOD)
153 {
193828fd 154 cout<<"Init output handler"<<endl;
155 AliAODHandler* aodoutHandler = new AliAODHandler();
156 aodoutHandler->SetOutputFileName("aod.root");
157 ////aodoutHandler->SetCreateNonStandardAOD();
158 mgr->SetOutputEventHandler(aodoutHandler);
159 }
160
161 //input
162
3c867778 163 if(kInputData == "ESD")
164 {
193828fd 165 // ESD handler
166 AliESDInputHandler *esdHandler = new AliESDInputHandler();
167 esdHandler->SetReadFriends(kFALSE);
168 mgr->SetInputEventHandler(esdHandler);
169 cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
170 }
3c867778 171 else if(kInputData.Contains("AOD"))
172 {
193828fd 173 // AOD handler
174 AliAODInputHandler *aodHandler = new AliAODInputHandler();
175 mgr->SetInputEventHandler(aodHandler);
745913ae 176 if(kInputData == "deltaAOD") aodHandler->AddFriend("deltaAODCaloTrackCorr.root");
193828fd 177 cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
178 }
023e6936 179
745913ae 180 //mgr->RegisterExternalFile("deltaAODCaloTrackCorr.root");
193828fd 181 //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
182
183 TString outputFile = AliAnalysisManager::GetCommonFileName();
184
185 //-------------------------------------------------------------------------
531f682d 186 // Define task, put here any other task that you want to use.
193828fd 187 //-------------------------------------------------------------------------
188
189 // Physics selection
190 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
191 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC);
192
193 // Centrality
3c867778 194 if(kCollision=="PbPb")
195 {
2c18833a 196 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
197 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
2c18833a 198 }
193828fd 199
200 // Simple event counting tasks
201 AddTaskCounter(""); // All
745913ae 202 //AddTaskCounter("MB"); // Min Bias
531f682d 203 AddTaskCounter("Any");
204 AddTaskCounter("AnyINT");// Min Bias
205
3c867778 206 if(!kMC)
207 {
531f682d 208 AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
193828fd 209 AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
531f682d 210 AddTaskCounter("EMCEGA");
211 AddTaskCounter("EMCEJE");
212 if(kCollision=="PbPb")
213 {
214 AddTaskCounter("Central");
215 AddTaskCounter("SemiCentral");
216 AddTaskCounter("PHOSPb");
217 }
218 else AddTaskCounter("PHOS");
219
193828fd 220 }
745913ae 221
222 // -----------------
223 // Photon conversion
224 // -----------------
225/*
226 if(kInputData=="ESD"){
227 printf("* Configure photon conversion analysis in macro \n");
228 TString arguments = "-run-on-train -use-own-xyz -force-aod -mc-off ";
531f682d 229 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
745913ae 230 AliAnalysisTaskGammaConversion * taskGammaConversion =
231 ConfigGammaConversion(arguments,mgr->GetCommonInputContainer());
232 taskGammaConversion->SelectCollisionCandidates();
233
234 // Gamma Conversion AOD to AODPWG4Particle
235 AliAnalysisTaskGCPartToPWG4Part * taskGCToPC = new AliAnalysisTaskGCPartToPWG4Part("GCPartToPWG4Part");
236 taskGCToPC->SetGammaCutId("90035620401003321022000000090");
237 mgr->AddTask(taskGCToPC);
238 mgr->ConnectInput (taskGCToPC, 0, mgr->GetCommonInputContainer() );
239 mgr->ConnectOutput (taskGCToPC, 0, mgr->GetCommonOutputContainer());
240 }
241*/
3c867778 242
193828fd 243 Bool_t kPrint = kFALSE;
244 Bool_t deltaAOD = kFALSE;
5fdef45d 245 gROOT->LoadMacro("AddTaskCaloTrackCorr.C"); // $ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros
531f682d 246 gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALClusterize.C"); // $ALICE_ROOT/PWGGA/EMCALTasks/macros
15882d9f 247
531f682d 248 // gROOT->LoadMacro("$ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
249 // AliAnalysisTaskCaloTrackCorrelation * qatask = AddTaskCalorimeterQA(kInputData,kYear,kPrint,kMC);
193828fd 250
023e6936 251 // Calibration, bad map ...
252
253 Bool_t calibEE = kTRUE; // It is set automatically, but here we force to use ir or not in any case
254 Bool_t calibTT = kTRUE; // It is set automatically, but here we force to use ir or not in any case
255 if(kRun < 122195 || (kRun > 126437 && kRun < 136851)) calibTT=kFALSE ; // Recalibration parameters not available for LHC10a,b,c,e,f,g
256 Bool_t badMap = kTRUE; // It is set automatically, but here we force to use ir or not in any case
257
531f682d 258 if(kCollision=="pp")
193828fd 259 {
531f682d 260 printf("==================================== \n");
261 printf("CONFIGURE ANALYSIS FOR PP COLLISIONS \n");
262 printf("==================================== \n");
cd54ca47 263
531f682d 264 Bool_t clTM = kTRUE;
265 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
266 Bool_t anTM = kTRUE; // Remove matched
267 Bool_t exo = kTRUE; // Remove exotic cells
268 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
269 Int_t minEcell = 50; // 50 MeV (10 MeV used in reconstruction)
270 Int_t minEseed = 100; // 100 MeV
271 Int_t dTime = 0; // default, 250 ns
023e6936 272 Int_t wTime = 0; // default 425 < T < 825 ns, careful if time calibration is on
d7d24d99 273 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
274 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
275
023e6936 276
277 //Trigger
278 TString clTrigger = "EMC7";
279 TString anTrigger = "EMC7";
280 TString anTriggerPH = "PHS";
531f682d 281 if(kMC)
282 {
283 clTrigger = "";
284 anTrigger = "";
023e6936 285 anTriggerPH = "";
531f682d 286 }
54769bc0 287
531f682d 288 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
289 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
290 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
cd54ca47 291
531f682d 292 //Analysis with clusterizer V1
3c867778 293
531f682d 294 TString arrayNameV1 = "";
295 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(kMC,exo,"V1",arrayNameV1,clTrigger, clTM,
d7d24d99 296 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
73d0c410 297 calibEE,badMap,calibTT,annonlin);
54769bc0 298
531f682d 299 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
300
301 AliAnalysisTaskCaloTrackCorrelation *anav1 = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
302 kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
023e6936 303 -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
531f682d 304
305 //Analysis with clusterizer V2
306 TString arrayNameV2 = "";
307 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(kMC,exo,"V2",arrayNameV2,clTrigger, clTM,
d7d24d99 308 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
73d0c410 309 calibEE,badMap,calibTT,annonlin);
531f682d 310
311 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
312
313 hadron = kFALSE;
314 AliAnalysisTaskCaloTrackCorrelation *anav2 = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
315 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
023e6936 316 -1,-1,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
317
318 // PHOS
319
320 //AliAnalysisTaskCaloTrackCorrelation *anaPH = AddTaskCaloTrackCorr(kInputData, "PHOS", kMC, selectEvents, kFALSE, kFALSE, outputFile.Data(),
321 // kYear,kCollision,anTriggerPH,"",kFALSE,kFALSE,
322 // -1,-1, qa, kFALSE,kFALSE,kFALSE,kFALSE,deltaAOD,kPrint);
323
531f682d 324 }
023e6936 325
531f682d 326 if(kCollision=="PbPb")
3c867778 327 {
531f682d 328 printf("====================================== \n");
329 printf("CONFIGURE ANALYSIS FOR PbPb COLLISIONS \n");
330 printf("====================================== \n");
3c867778 331
531f682d 332 Bool_t clTM = kTRUE;
333 Bool_t reTM = kFALSE; // Recalculate matches if not already done in clusterizer
334 Bool_t anTM = kTRUE; // Remove matched
335 Bool_t exo = kTRUE; // Remove exotic cells
336 Bool_t annonlin = kFALSE; // Apply non linearity (analysis)
337 Int_t minEcell = 100; // 50 MeV (10 MeV used in reconstruction)
338 Int_t minEseed = 200; // 100 MeV
339 Int_t dTime = 0; // default, 250 ns
340 Int_t wTime = 0; // default 425 < T < 825 ns
d7d24d99 341 Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
342 Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
343
023e6936 344 // Trigger
531f682d 345 TString clTrigger = "EMCGA";
346 TString anTrigger = "EMCGA";
347 if(kMC)
348 {
349 clTrigger = "";
350 anTrigger = "";
351 }
3c867778 352
531f682d 353 Bool_t selectEvents = kFALSE; // Select events depending on V0, pile-up and vertex quality
354 Bool_t qa = kTRUE; // Do besides calorimeter QA analysis
355 Bool_t hadron = kTRUE; // Do besides charged track correlations analysis
3c867778 356
531f682d 357 //Analysis with clusterizer V1
3c867778 358
531f682d 359 TString arrayNameV1 = "";
360 AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(kMC,exo,"V1",arrayNameV1,clTrigger, clTM,
d7d24d99 361 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
73d0c410 362 calibEE,badMap,calibTT,annonlin);
3c867778 363
531f682d 364
365 printf("Name of clusterizer1 array: %s\n",arrayNameV1.Data());
366
367 AliAnalysisTaskCaloTrackCorrelation *anav1c = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
368 kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
023e6936 369 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
531f682d 370 AliAnalysisTaskCaloTrackCorrelation *anav1m = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
371 kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
023e6936 372 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
531f682d 373 AliAnalysisTaskCaloTrackCorrelation *anav1p = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
374 kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
023e6936 375 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
531f682d 376
377 //Analysis with clusterizer V2
745913ae 378
531f682d 379 TString arrayNameV2 = "";
380 AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(kMC,exo,"V2",arrayNameV2,clTrigger, clTM,
d7d24d99 381 minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
73d0c410 382 calibEE,badMap,calibTT,annonlin);
531f682d 383
384 printf("Name of clusterizer2 array: %s\n",arrayNameV2.Data());
385
386 hadron = kFALSE;
387
388 AliAnalysisTaskCaloTrackCorrelation *anav2c = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
389 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
023e6936 390 0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
531f682d 391 AliAnalysisTaskCaloTrackCorrelation *anav2m = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
392 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
023e6936 393 20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
531f682d 394 AliAnalysisTaskCaloTrackCorrelation *anav2p = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(),
395 kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
023e6936 396 60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
531f682d 397 }
398
193828fd 399 //-----------------------
400 // Run the analysis
401 //-----------------------
402 mgr->InitAnalysis();
403 mgr->PrintStatus();
193828fd 404
3c867778 405 if (mode == mPlugin) mgr->StartAnalysis("grid");
406 else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
407 else mgr->StartAnalysis("local",chain);
193828fd 408
3c867778 409 cout <<" Analysis ended sucessfully "<< endl ;
d92b41ad 410
411}
412
3c867778 413//_____________________________
414void LoadLibraries(Int_t mode)
193828fd 415{
d92b41ad 416
3c867778 417 if (mode == mPROOF) {
418 //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
419 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
5fdef45d 420 TProof* proof = EnableAliRootForLAF("ccaplmaster",nPROOFWorkers.Data(),ccin2p3UserName.Data(),alienUserName.Data(),"",kFALSE,kTRUE,kTRUE,"OADB:ANALYSIS:ANALYSISalice:AOD:ESD:CORRFW:STEERBase:EMCALUtils:PHOSUtils:PWGCaloTrackCorrBase:PWGGACaloTrackCorrelations:PWGGAEMCALTasks");
3c867778 421
422 // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
423
424 // //proof->ClearPackages();
425 // proof->UploadPackage("STEERBase");
426 // proof->UploadPackage("ESD");
427 // proof->UploadPackage("AOD");
428 // proof->UploadPackage("ANALYSIS");
429 // proof->UploadPackage("OADB");
430 // proof->UploadPackage("ANALYSISalice");
431 // proof->UploadPackage("CORRFW");
432 // //proof->UploadPackage("JETAN");
433 // proof->UploadPackage("PHOSUtils");
434 // proof->UploadPackage("EMCALUtils");
531f682d 435 // proof->UploadPackage("PWGCaloTrackCorrBase");
5fdef45d 436 // proof->UploadPackage("PWGGACaloTrackCorrelations");
437 // proof->UploadPackage("PWGGAEMCALTasks");
3c867778 438
439 // proof->EnablePackage("STEERBase");
440 // proof->EnablePackage("ESD");
441 // proof->EnablePackage("AOD");
442 // proof->EnablePackage("ANALYSIS");
443 // proof->EnablePackage("OADB");
444 // proof->EnablePackage("ANALYSISalice");
445 // proof->EnablePackage("CORRFW");
446 // //proof->EnablePackage("JETAN");
447 // proof->EnablePackage("PHOSUtils");
448 // proof->EnablePackage("EMCALUtils");
531f682d 449 // proof->EnablePackage("PWGCaloTrackCorrBase");
5fdef45d 450 // proof->EnablePackage("PWGGACaloTrackCorrelations");
451 // proof->EnablePackage("PWGGAEMCALTasks");
3c867778 452 return;
453 }
454
d92b41ad 455 //--------------------------------------
456 // Load the needed libraries most of them already loaded by aliroot
457 //--------------------------------------
458 gSystem->Load("libTree.so");
459 gSystem->Load("libGeom.so");
460 gSystem->Load("libVMC.so");
461 gSystem->Load("libXMLIO.so");
54769bc0 462 gSystem->Load("libMatrix.so");
463 gSystem->Load("libPhysics.so");
193828fd 464 gSystem->Load("libMinuit.so"); // Root + libraries to if reclusterization is done
465
466 gSystem->Load("libSTEERBase.so");
467 gSystem->Load("libGui.so"); // Root + libraries to if reclusterization is done
468 gSystem->Load("libCDB.so"); // Root + libraries to if reclusterization is done
469 gSystem->Load("libESD.so"); // Root + libraries to if reclusterization is done
470 gSystem->Load("libAOD.so");
471 gSystem->Load("libRAWDatabase.so"); // Root + libraries to if reclusterization is done
472 gSystem->Load("libProof.so");
531f682d 473 gSystem->Load("libOADB");
193828fd 474 gSystem->Load("libANALYSIS.so");
475 gSystem->Load("libSTEER.so"); // Root + libraries to if reclusterization is done
476
477 gSystem->Load("libRAWDatarec.so"); // Root + libraries to if reclusterization is done
478 gSystem->Load("libRAWDatasim.so"); // Root + libraries to if reclusterization is done
479 gSystem->Load("libVZERObase.so"); // Root + libraries to if reclusterization is done
480 gSystem->Load("libVZEROrec.so"); // Root + libraries to if reclusterization is done
481
482 gSystem->Load("libEMCALUtils");
483 //SetupPar("EMCALUtils");
484 gSystem->Load("libEMCALraw"); // Root + libraries to if reclusterization is done
485 gSystem->Load("libEMCALbase"); // Root + libraries to if reclusterization is done
486 gSystem->Load("libEMCALsim"); // Root + libraries to if reclusterization is done
487 gSystem->Load("libEMCALrec"); // Root + libraries to if reclusterization is done
488 //SetupPar("EMCALraw");
489 //SetupPar("EMCALbase");
490 //SetupPar("EMCALsim");
491 //SetupPar("EMCALrec");
492
493 gSystem->Load("libANALYSISalice.so");
494 //gSystem->Load("libTENDER.so");
495 //gSystem->Load("libTENDERSupplies.so");
496
497 gSystem->Load("libPHOSUtils");
498 gSystem->Load("libEMCALUtils");
372e67a3 499 gSystem->Load("libPWGCaloTrackCorrBase");
500 gSystem->Load("libPWGGACaloTrackCorrelations");
5fdef45d 501 gSystem->Load("libPWGGAEMCALTasks");
372e67a3 502 //SetupPar("PWGCaloTrackCorrBase");
503 //SetupPar("PWGGACaloTrackCorrelations");
5fdef45d 504 //SetupPar("PWGGAEMCALTasks");
15882d9f 505
531f682d 506
15882d9f 507 //gSystem->Load("libJETAN");
508 //gSystem->Load("FASTJETAN");
5fdef45d 509 //gSystem->Load("PWGJE");
745913ae 510
531f682d 511 //gSystem->Load("libCORRFW.so");
512 //gSystem->Load("libPWGGAGammaConv.so");
5fdef45d 513 //SetupPar("PWGGAGammaConv");
15882d9f 514
515 // needed for plugin?
516 gSystem->AddIncludePath("-I$ALICE_ROOT");
517 gSystem->AddIncludePath("-I./");
518
d92b41ad 519}
520
3c867778 521//_________________________________
d92b41ad 522void SetupPar(char* pararchivename)
523{
524 //Load par files, create analysis libraries
525 //For testing, if par file already decompressed and modified
526 //classes then do not decompress.
193828fd 527
d92b41ad 528 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
529 TString parpar(Form("%s.par", pararchivename)) ;
193828fd 530
d92b41ad 531 if ( gSystem->AccessPathName(pararchivename) ) {
532 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
533 gROOT->ProcessLine(processline.Data());
534 }
535
536 TString ocwd = gSystem->WorkingDirectory();
537 gSystem->ChangeDirectory(pararchivename);
538
539 // check for BUILD.sh and execute
540 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
541 printf("*******************************\n");
542 printf("*** Building PAR archive ***\n");
543 cout<<pararchivename<<endl;
544 printf("*******************************\n");
545
546 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
547 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
548 return -1;
549 }
550 }
551 // check for SETUP.C and execute
552 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
553 printf("*******************************\n");
554 printf("*** Setup PAR archive ***\n");
555 cout<<pararchivename<<endl;
556 printf("*******************************\n");
557 gROOT->Macro("PROOF-INF/SETUP.C");
558 }
559
560 gSystem->ChangeDirectory(ocwd.Data());
561 printf("Current dir: %s\n", ocwd.Data());
562}
563
3c867778 564//______________________________________
565void CheckInputData(const anaModes mode)
566{
193828fd 567 //Sets input data and tree
568
569 TString ocwd = gSystem->WorkingDirectory();
570
571 //---------------------------------------
572 //Local files analysis
573 //---------------------------------------
574 if(mode == mLocal){
575 //If you want to add several ESD files sitting in a common directory INDIR
576 //Specify as environmental variables the directory (INDIR), the number of files
577 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
cd54ca47 578
193828fd 579 if(gSystem->Getenv("INDIR"))
580 kInDir = gSystem->Getenv("INDIR") ;
581 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
582
583 TString sindir(kInDir);
584 if (sindir.Contains("pass1")) kPass = "pass1";
585 else if(sindir.Contains("pass2")) kPass = "pass2";
586 else if(sindir.Contains("pass3")) kPass = "pass3";
587
588 if(gSystem->Getenv("PATTERN"))
589 kPattern = gSystem->Getenv("PATTERN") ;
590 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
591
592 cout<<"INDIR : "<<kInDir<<endl;
593 cout<<"NFILES : "<<kFile<<endl;
594
595 char fileE[120] ;
596 char fileA[120] ;
597 char fileG[120] ;
598 char fileEm[120] ;
599 for (Int_t event = 0 ; event < kFile ; event++) {
3c867778 600 sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
601 sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
602 sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
193828fd 603 sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
604
5eef1db1 605 TFile * fESD = TFile::Open(fileE) ;
606 TFile * fAOD = TFile::Open(fileA) ;
607
193828fd 608 //Check if file exists and add it, if not skip it
3c867778 609 if (fESD)
610 {
611 kTreeName = "esdTree";
193828fd 612 kInputData = "ESD";
5eef1db1 613 TFile * fG = TFile::Open(fileG);
614 if(fG) { kMC = kTRUE; fG->Close();}
615 else kMC = kFALSE;
616
617 // Get run number
618 TTree* esdTree = (TTree*)fESD->Get("esdTree");
619 AliESDEvent* esd = new AliESDEvent();
620 esd->ReadFromTree(esdTree);
621 esdTree->GetEvent(0);
622 kRun = esd->GetRunNumber();
623
193828fd 624 return;
625 }
3c867778 626 else if(fAOD)
627 {
628 kTreeName = "aodTree";
193828fd 629 kInputData = "AOD";
630 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
631 else kMC = kFALSE;
5eef1db1 632
633 // Get run number
634 TTree* aodTree = (TTree*)fAOD->Get("aodTree");
635 AliAODEvent* aod = new AliAODEvent();
0fb69ade 636 aod->ReadFromTree(aodTree);
5eef1db1 637 aodTree->GetEvent(0);
638 kRun = aod->GetRunNumber();
193828fd 639 return;
640 }
3c867778 641 else if(TFile::Open(fileEm))
642 {
5eef1db1 643 kTreeName = "aodTree";
193828fd 644 kInputData = "AOD";
5eef1db1 645 kMC = kTRUE;
646
193828fd 647 return;
648 }
3c867778 649 else if(TFile::Open(fileG))
650 {
5eef1db1 651 kTreeName = "TE";
193828fd 652 kInputData = "MC";
5eef1db1 653 kMC = kTRUE;
193828fd 654 return;
655 }
656 }
657
5eef1db1 658 if(fESD) fESD->Close();
659 if(fAOD) fAOD->Close();
660
193828fd 661 }// local files analysis
662
663 //------------------------------
664 //GRID xml files
665 //-----------------------------
666 else if(mode == mGRID){
667 //Get colection file. It is specified by the environmental
668 //variable XML
669
670 if(gSystem->Getenv("XML") )
671 kXML = gSystem->Getenv("XML");
672 else
673 sprintf(kXML, "collection.xml") ;
674
675 if (!TFile::Open(kXML)) {
676 printf("No collection file with name -- %s -- was found\n",kXML);
677 return ;
678 }
679 else cout<<"XML file "<<kXML<<endl;
680
681 //Load necessary libraries and connect to the GRID
682 gSystem->Load("libNetx.so") ;
683 gSystem->Load("libRAliEn.so");
684 TGrid::Connect("alien://") ;
685
686 //Feed Grid with collection file
687 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
688 if (! collection) {
689 AliError(Form("%s not found", kXML)) ;
690 return kFALSE ;
691 }
692 TGridResult* result = collection->GetGridResult("",0 ,0);
693
694 for (Int_t index = 0; index < result->GetEntries(); index++) {
695 TString alienURL = result->GetKey(index, "turl") ;
696 cout << "================== " << alienURL << endl ;
697
698 if (alienURL.Contains("pass1")) kPass = "pass1";
699 else if(alienURL.Contains("pass2")) kPass = "pass2";
700 else if(alienURL.Contains("pass3")) kPass = "pass3";
701
3c867778 702 kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
703 printf("Run number from alien path = %d\n",kRun);
704
193828fd 705 TFile * fAOD = 0 ;
706 //Check if file exists and add it, if not skip it
3c867778 707 if (alienURL.Contains("AliESDs.root"))
708 {
709 kTreeName = "esdTree";
193828fd 710 kInputData = "ESD";
711 alienURL.ReplaceAll("AliESDs.root","galice.root");
712 if(TFile::Open(alienURL)) kMC=kTRUE;
713 else kMC = kFALSE;
193828fd 714 return;
715 }
3c867778 716 else if(alienURL.Contains("AliAOD.root"))
717 {
718 kTreeName = "aodTree";
193828fd 719 kInputData = "AOD";
720 fAOD = TFile::Open(alienURL);
721 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
722 else kMC = kFALSE;
723 return;
724 }
3c867778 725 else if(alienURL.Contains("embededAOD.root"))
726 {
727 kTreeName = "aodTree";
193828fd 728 kInputData = "AOD";
729 kMC=kTRUE;
730 return;
731 }
3c867778 732 else if(alienURL.Contains("galice.root"))
733 {
734 kTreeName = "TE";
193828fd 735 kInputData = "MC";
736 kMC=kTRUE;
737 return;
738 }
739 }
740 }// xml analysis
3c867778 741 //------------------------------
742 //PROOF files
743 //-----------------------------
744 else if(mode == mPROOF){
745
746 TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
747
748 TIter iter(coll->GetList());
749
750 TFileInfo* fileInfo = 0;
751 while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
752 {
753 if (fileInfo->GetFirstUrl()) {
754 TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
755 cout << "================== " << ProofURL << endl ;
756
757 if (ProofURL.Contains("pass1")) kPass = "pass1";
758 else if(ProofURL.Contains("pass2")) kPass = "pass2";
759 else if(ProofURL.Contains("pass3")) kPass = "pass3";
760
761 kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
762 printf("Run number from alien path = %d\n",kRun);
763
764 TFile * fAOD = 0 ;
765 //Check if file exists and add it, if not skip it
766 if (ProofURL.Contains("AliESDs.root"))
767 {
768 kTreeName = "esdTree";
769 kInputData = "ESD";
770 alienURL.ReplaceAll("AliESDs.root","galice.root");
771 if(TFile::Open(ProofURL)) kMC=kTRUE;
772 else kMC = kFALSE;
773
774 return;
775 }
776 else if(ProofURL.Contains("AliAOD.root"))
777 {
778 kTreeName = "aodTree";
779 kInputData = "AOD";
780 fAOD = TFile::Open(ProofURL);
781 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
782 else kMC = kFALSE;
783 return;
784 }
785 else if(ProofURL.Contains("embededAOD.root"))
786 {
787 kTreeName = "aodTree";
788 kInputData = "AOD";
789 kMC=kTRUE;
790 return;
791 }
792 else if(ProofURL.Contains("galice.root"))
793 {
794 kTreeName = "TE";
795 kInputData = "MC";
796 kMC=kTRUE;
797 return;
798 }
799 }
800 }
801 }// proof analysis
193828fd 802
803 gSystem->ChangeDirectory(ocwd.Data());
804
805}
d92b41ad 806
193828fd 807//_____________________________________________________________________
808void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
809{
d92b41ad 810 //Fills chain with data
811 TString ocwd = gSystem->WorkingDirectory();
812
d92b41ad 813 //---------------------------------------
3c867778 814 // Local files analysis
d92b41ad 815 //---------------------------------------
2244659d 816 if(mode == mLocal){
d92b41ad 817 //If you want to add several ESD files sitting in a common directory INDIR
818 //Specify as environmental variables the directory (INDIR), the number of files
c8fe2783 819 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
193828fd 820
d92b41ad 821 if(gSystem->Getenv("INDIR"))
822 kInDir = gSystem->Getenv("INDIR") ;
823 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
824
825 if(gSystem->Getenv("PATTERN"))
826 kPattern = gSystem->Getenv("PATTERN") ;
827 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
828
c8fe2783 829 if(gSystem->Getenv("NFILES"))
830 kFile = atoi(gSystem->Getenv("NFILES")) ;
831 else cout<<"NFILES not set, use default: "<<kFile<<endl;
d92b41ad 832
833 //Check if env variables are set and are correct
c8fe2783 834 if ( kInDir && kFile) {
835 printf("Get %d files from directory %s\n",kFile,kInDir);
d92b41ad 836 if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
193828fd 837 printf("%s does not exist\n", kInDir) ;
838 return ;
d92b41ad 839 }
193828fd 840
c8fe2783 841 //if(gSystem->Getenv("XSFILE"))
842 //kXSFileName = gSystem->Getenv("XSFILE") ;
843 //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
844 char * kGener = gSystem->Getenv("GENER");
845 if(kGener) {
193828fd 846 cout<<"GENER "<<kGener<<endl;
3c867778 847 if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
193828fd 848 else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
849 else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
c8fe2783 850 }
851 else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
193828fd 852
3c867778 853 cout<<"INDIR : "<<kInDir <<endl;
854 cout<<"NFILES : "<<kFile <<endl;
855 cout<<"PATTERN : "<<kPattern <<endl;
c8fe2783 856 cout<<"XSFILE : "<<kXSFileName<<endl;
193828fd 857
7175a03a 858 TString datafile="";
3c867778 859 if (kInputData == "ESD") datafile = "AliESDs.root" ;
860 else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
861 else if(kInputData == "MC") datafile = "galice.root" ;
7175a03a 862
5eef1db1 863 //Loop on ESD/AOD/MC files, add them to chain
d92b41ad 864 Int_t event =0;
865 Int_t skipped=0 ;
866 char file[120] ;
867 char filexs[120] ;
868
c8fe2783 869 for (event = 0 ; event < kFile ; event++) {
3c867778 870 sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
193828fd 871 sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
5eef1db1 872 TFile * fData = 0 ;
193828fd 873 //Check if file exists and add it, if not skip it
5eef1db1 874 if ( fData = TFile::Open(file)) {
875 if ( fData->Get(kTreeName) ) {
193828fd 876 printf("++++ Adding %s\n", file) ;
877 chain->AddFile(file);
878 chainxs->Add(filexs) ;
879 }
880 }
881 else {
882 printf("---- Skipping %s\n", file) ;
883 skipped++ ;
884 }
d92b41ad 885 }
d92b41ad 886 }
887 else {
888 TString input = "AliESDs.root" ;
889 cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
890 chain->AddFile(input);
891 }
892
893 }// local files analysis
894
895 //------------------------------
3c867778 896 // GRID xml files
897 //------------------------------
d92b41ad 898 else if(mode == mGRID){
899 //Get colection file. It is specified by the environmental
900 //variable XML
d92b41ad 901
d92b41ad 902 //Feed Grid with collection file
d92b41ad 903 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
904 if (! collection) {
905 AliError(Form("%s not found", kXML)) ;
906 return kFALSE ;
907 }
3c867778 908
d92b41ad 909 TGridResult* result = collection->GetGridResult("",0 ,0);
193828fd 910
d92b41ad 911 // Makes the ESD chain
912 printf("*** Getting the Chain ***\n");
913 for (Int_t index = 0; index < result->GetEntries(); index++) {
914 TString alienURL = result->GetKey(index, "turl") ;
915 cout << "================== " << alienURL << endl ;
916 chain->Add(alienURL) ;
917 alienURL.ReplaceAll("AliESDs.root",kXSFileName);
918 chainxs->Add(alienURL) ;
919 }
920 }// xml analysis
921
3c867778 922 //------------------------------
923 // PROOF
924 //------------------------------
925 else if (mode == mPROOF) {
926
927 TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
928
929 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
930 chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
931 printf("chain has %d entries\n",chain->GetEntries());
932 }
933
d92b41ad 934 gSystem->ChangeDirectory(ocwd.Data());
193828fd 935
d92b41ad 936}
937
193828fd 938//_________________________________________________________________
d92b41ad 939void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)
940{
941 // Read the PYTHIA statistics from the file pyxsec.root created by
942 // the function WriteXsection():
943 // integrated cross section (xsection) and
944 // the number of Pyevent() calls (ntrials)
945 // and calculate the weight per one event xsection/ntrials
946 // The spectrum calculated by a user should be
947 // multiplied by this weight, something like this:
948 // TH1F *userSpectrum ... // book and fill the spectrum
949 // userSpectrum->Scale(weight)
950 //
951 // Yuri Kharlov 19 June 2007
952 // Gustavo Conesa 15 April 2008
953 Double_t xsection = 0;
954 UInt_t ntrials = 0;
955 xs = 0;
956 ntr = 0;
957
958 Int_t nfiles = tree->GetEntries() ;
3c867778 959 if (tree && nfiles > 0)
960 {
d92b41ad 961 tree->SetBranchAddress("xsection",&xsection);
962 tree->SetBranchAddress("ntrials",&ntrials);
963 for(Int_t i = 0; i < nfiles; i++){
964 tree->GetEntry(i);
965 xs += xsection ;
966 ntr += ntrials ;
967 cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
968 }
969
970 xs = xs / nfiles;
971 ntr = ntr / nfiles;
972 cout << "-----------------------------------------------------------------"<<endl;
973 cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
974 cout << "-----------------------------------------------------------------"<<endl;
975 }
976 else cout << " >>>> Empty tree !!!! <<<<< "<<endl;
977
978}
979
193828fd 980//______________________________
981void CheckEnvironmentVariables()
982{
983
cd54ca47 984 sprintf(kTrigger,"");
193828fd 985
cd54ca47 986 Bool_t bRecalibrate = kFALSE;
987 Bool_t bBadChannel = kFALSE;
193828fd 988
cd54ca47 989 for (int i=0; i< gApplication->Argc();i++){
990
991#ifdef VERBOSEARGS
992
993 printf("Arg %d: %s\n",i,gApplication->Argv(i));
994
193828fd 995#endif
cd54ca47 996
2c18833a 997 TString sRun = "";
998
cd54ca47 999 if (!(strcmp(gApplication->Argv(i),"--trigger")))
1000 sprintf(trigger,gApplication->Argv(i+1));
193828fd 1001
1002 if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
1003 bRecalibrate = atoi(gApplication->Argv(i+1));
cd54ca47 1004
1005 if (!(strcmp(gApplication->Argv(i),"--badchannel")))
1006 bBadChannel = atoi(gApplication->Argv(i+1));
1007
1008 if (!(strcmp(gApplication->Argv(i),"--run"))){
2c18833a 1009 sRun = gApplication->Argv(i+1);
cd54ca47 1010 if(sRun.Contains("LHC10")) {
1011 kYear = 2010;
1012 }
1013 else {
1014 if(kRun <=0){
1015 kRun = atoi(gApplication->Argv(i+1));
1016 }
1017 else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
1018 }//numeric run
1019 }//--run available
1020
1021 }// args loop
1022
193828fd 1023 if(!sRun.Contains("LHC10")){
531f682d 1024 if ( kRun < 140000)
1025 {
193828fd 1026 kYear = 2010;
1027 if( kRun >= 136851 ) kCollision = "PbPb";
1028 }
531f682d 1029 else if( kRun < 170600)
1030 {
193828fd 1031 kYear = 2011;
531f682d 1032 if( kRun >= 166500 ) kCollision = "PbPb";
1033 }
1034 else
1035 {
1036 kYear = 2012;
1037
193828fd 1038 }
1039 }
1040
cd54ca47 1041 if(kMC) sprintf(kTrigger,"");
1042
1043 printf("*********************************************\n");
1044 //printf("*** Settings trigger %s, recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
1045 // kTrigger,bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
1046 printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
1047 printf("*********************************************\n");
1048
193828fd 1049}
1050
3c867778 1051//_______________________________________________
193828fd 1052void AddTaskCounter(const TString trigger = "MB")
1053{
1054
1055 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1056
1057 AliAnalysisTaskCounter * counter = new AliAnalysisTaskCounter(Form("Counter%s",trigger.Data()));
1058 if(kRun > 140000 && kRun < 146900) counter ->RejectFastCluster();
1059 if (kCollision=="pp" ) counter->SetZVertexCut(50.); //Open cut
1060 else if(kCollision=="PbPb") counter->SetZVertexCut(10.); //Centrality defined in this range.
1061
3c867778 1062 if(trigger=="EMC7")
1063 {
193828fd 1064 printf("counter trigger EMC7\n");
1065 counter->SelectCollisionCandidates(AliVEvent::kEMC7);
1066 }
3c867778 1067 else if (trigger=="INT7")
1068 {
193828fd 1069 printf("counter trigger INT7\n");
1070 counter->SelectCollisionCandidates(AliVEvent::kINT7);
1071 }
3c867778 1072 if(trigger=="EMC1")
1073 {
193828fd 1074 printf("counter trigger EMC1\n");
1075 counter->SelectCollisionCandidates(AliVEvent::kEMC1);
1076 }
3c867778 1077 else if(trigger=="MB")
1078 {
193828fd 1079 printf("counter trigger MB\n");
1080 counter->SelectCollisionCandidates(AliVEvent::kMB);
1081 }
3c867778 1082 else if(trigger=="PHOS")
1083 {
cd54ca47 1084 printf("counter trigger PHOS\n");
1085 counter->SelectCollisionCandidates(AliVEvent::kPHI7);
1086 }
531f682d 1087 else if(trigger=="PHOSPb")
1088 {
1089 printf("counter trigger PHOSPb\n");
1090 counter->SelectCollisionCandidates(AliVEvent::kPHOSPb);
1091 }
1092 else if(trigger=="AnyINT")
1093 {
1094 printf("counter trigger AnyINT\n");
1095 counter->SelectCollisionCandidates(AliVEvent::kAnyINT);
1096 }
1097 else if(trigger=="INT")
1098 {
1099 printf("counter trigger AnyINT\n");
1100 counter->SelectCollisionCandidates(AliVEvent::kAny);
1101 }
1102 else if(trigger=="EMCEGA")
1103 {
1104 printf("counter trigger EMC Gamma\n");
1105 counter->SelectCollisionCandidates(AliVEvent::kEMCEGA);
1106 }
1107 else if(trigger=="EMCEJE")
1108 {
1109 printf("counter trigger EMC Jet\n");
1110 counter->SelectCollisionCandidates(AliVEvent::kEMCEJE);
1111 }
1112 else if(trigger=="Central")
1113 {
1114 printf("counter trigger Central\n");
1115 counter->SelectCollisionCandidates(AliVEvent::kCentral);
1116 }
1117 else if(trigger=="SemiCentral")
1118 {
1119 printf("counter trigger SemiCentral\n");
1120 counter->SelectCollisionCandidates(AliVEvent::kSemiCentral);
1121 }
1122
1123
193828fd 1124
1125 TString outputFile = AliAnalysisManager::GetCommonFileName();
1126 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
1127
1128 AliAnalysisDataContainer *coutput =
1129 mgr->CreateContainer(Form("Counter%s",trigger.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outputFile.Data());
1130 mgr->AddTask(counter);
1131 mgr->ConnectInput (counter, 0, cinput1);
1132 mgr->ConnectOutput (counter, 1, coutput);
cd54ca47 1133
193828fd 1134}
1135
1136
1137
1138
d92b41ad 1139