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