]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/CaloTrackCorrelations/macros/ana.C
pass unfolding parameters to clusterizer, overwritten previously by wrong settings
[u/mrichter/AliRoot.git] / PWGGA / CaloTrackCorrelations / macros / ana.C
1 /* $Id:  $ */
2 //--------------------------------------------------
3 // Example macro to do analysis with the 
4 // analysis classes in CaloTrackCorrelations
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 //-------------------------------------------------
13 enum anaModes {mLocal=0, mPROOF=1, mPlugin=2, mGRID=3};
14 //mLocal    = 0: Analyze locally files in your computer
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
18
19 //---------------------------------------------------------------------------
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
23
24 char * kInDir   = "/user/data/files/"; 
25 char * kPattern = ""; // Data are in files kInDir/kPattern+i 
26 Int_t  kFile    = 3; 
27
28 //---------------------------------------------------------------------------
29 // Dataset for proof analysis, mode=mPROOF
30 // char * kDataset = "/alice/vernet/PbPb_LHC10h_ESD";
31
32 char *  kDatasetPROOF     = "/alice/vernet/LHC11b_149646";
33 //char *  kDatasetPROOF     = "/alice/vernet/LHC11b10a_AOD046";//LHC11d_AOD076
34 Int_t   kDatasetNMaxFiles = 20;
35 TString ccin2p3UserName   = "arbor" ;
36 TString alienUserName     = "narbor" ;
37
38 //---------------------------------------------------------------------------
39 // Collection file for grid analysis
40
41 char * kXML = "collection.xml";
42
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.
48 const Bool_t kGetXSectionFromFileAndScale = kFALSE ;
49 const char * kXSFileName = "pyxsec.root";
50
51 //---------------------------------------------------------------------------
52
53 //Set some default values, but used values are set in the code!
54
55 Bool_t  kMC        = kFALSE; //With real data kMC = kFALSE
56 TString kInputData = "ESD"; //ESD, AOD, MC, deltaAOD
57 Int_t   kYear      = 2011;
58 TString kCollision = "pp";
59 Bool_t  outAOD     = kTRUE; //Some tasks doesnt need it.
60 TString kTreeName;
61 TString kPass      = "";
62 char    kTrigger[1024];
63 Int_t   kRun       = 0;
64
65 //________________________
66 void ana(Int_t mode=mGRID)
67 {
68   // Main
69   
70   //--------------------------------------------------------------------
71   // Load analysis libraries
72   // Look at the method below, 
73   // change whatever you need for your analysis case
74   // ------------------------------------------------------------------
75   
76   LoadLibraries(mode) ;
77   //gSystem->ListLibraries();
78   
79   //-------------------------------------------------------------------------------------------------
80   //Create chain from ESD and from cross sections files, look below for options.
81   //-------------------------------------------------------------------------------------------------
82   
83   // Set kInputData and kTreeName looking to the kINDIR
84   
85   CheckInputData(mode);
86   
87   // Check global analysis settings  
88   
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");
94   
95   TChain * chain   = new TChain(kTreeName) ;
96   TChain * chainxs = new TChain("Xsection") ;
97   CreateChain(mode, chain, chainxs); 
98   
99   printf("*********************************************\n");
100   printf("number of entries # %lld, skipped %d\n", chain->GetEntries()) ;       
101   printf("*********************************************\n");
102   
103   if(!chain)
104   { 
105     printf("STOP, no chain available\n"); 
106     return;
107   }
108   
109   AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
110   
111   //------------------------------------------
112   //  Alien handler part
113   //------------------------------------------
114   AliAnalysisGrid *alienHandler=0x0;
115   if(mode==mPlugin)
116   {
117     // Create and configure the alien handler plugin
118     gROOT->LoadMacro("CreateAlienHandler.C");
119     alienHandler = CreateAlienHandler();
120     if (!alienHandler) return;
121   }  
122   
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   
131   if(mode==mPlugin)
132   {
133     // Connect plugin to the analysis manager
134     mgr->SetGridHandler(alienHandler);
135   }
136   
137   // MC handler
138   if((kMC || kInputData == "MC") && !kInputData.Contains("AOD"))
139   {
140     AliMCEventHandler* mcHandler = new AliMCEventHandler();
141     mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
142     mgr->SetMCtruthEventHandler(mcHandler);
143     if( kInputData == "MC") 
144     {
145       cout<<"MC INPUT EVENT HANDLER"<<endl;
146       mgr->SetInputEventHandler(NULL);
147     }
148   }
149   
150   
151   // AOD output handler
152   if(kInputData!="deltaAOD" && outAOD)
153   {
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   
163   if(kInputData == "ESD")
164   {
165     // ESD handler
166     AliESDInputHandler *esdHandler = new AliESDInputHandler();
167     esdHandler->SetReadFriends(kFALSE);
168     mgr->SetInputEventHandler(esdHandler);
169     cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
170   }
171   else if(kInputData.Contains("AOD"))
172   {
173     // AOD handler
174     AliAODInputHandler *aodHandler = new AliAODInputHandler();
175     mgr->SetInputEventHandler(aodHandler);
176     if(kInputData == "deltaAOD") aodHandler->AddFriend("deltaAODCaloTrackCorr.root");
177     cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
178   }
179   
180   //mgr->RegisterExternalFile("deltaAODCaloTrackCorr.root");
181   //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
182   
183   TString outputFile = AliAnalysisManager::GetCommonFileName(); 
184   
185   //-------------------------------------------------------------------------
186   // Define task, put here any other task that you want to use.
187   //-------------------------------------------------------------------------
188   
189   // Physics selection
190   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); 
191   AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC); 
192   
193   // Centrality
194   if(kCollision=="PbPb")
195   {
196     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
197     AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
198   }
199   
200   // Simple event counting tasks
201   AddTaskCounter("");   // All
202   //AddTaskCounter("MB"); // Min Bias
203   AddTaskCounter("Any"); 
204   AddTaskCounter("AnyINT");// Min Bias
205
206   if(!kMC)
207   {
208     AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
209     AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV 
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
220   }
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 ";
229     gROOT->LoadMacro("$ALICE_ROOT/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
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 */  
242   
243   Bool_t kPrint   = kFALSE;
244   Bool_t deltaAOD = kFALSE;
245   gROOT->LoadMacro("AddTaskCaloTrackCorr.C");   // $ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros
246   gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALClusterize.C"); // $ALICE_ROOT/PWGGA/EMCALTasks/macros  
247   
248  // gROOT->LoadMacro("$ALICE_ROOT/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");  
249  // AliAnalysisTaskCaloTrackCorrelation * qatask = AddTaskCalorimeterQA(kInputData,kYear,kPrint,kMC); 
250   
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   
258   if(kCollision=="pp")
259   {
260     printf("==================================== \n");
261     printf("CONFIGURE ANALYSIS FOR PP COLLISIONS \n");
262     printf("==================================== \n");
263     
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
272     Int_t   wTime     = 0;      // default 425 < T < 825 ns, careful if time calibration is on
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
276     
277     //Trigger
278     TString clTrigger   = "EMC7";   
279     TString anTrigger   = "EMC7";  
280     TString anTriggerPH = "PHS";   
281     if(kMC) 
282     {
283       clTrigger = "";
284       anTrigger = "";
285       anTriggerPH = ""; 
286     }
287     
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    
291     
292     //Analysis with clusterizer V1
293     
294     TString arrayNameV1 = "";
295     AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(kMC,exo,"V1",arrayNameV1,clTrigger, clTM,
296                                                                    minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
297                                                                    calibEE,badMap,calibTT,annonlin);    
298     
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, 
303                                                                         -1,-1, qa, hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
304     
305     //Analysis with clusterizer V2
306     TString arrayNameV2 = "";
307     AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(kMC,exo,"V2",arrayNameV2,clTrigger, clTM,
308                                                                    minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
309                                                                    calibEE,badMap,calibTT,annonlin);    
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, 
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
324   }
325
326   if(kCollision=="PbPb")
327   {
328     printf("====================================== \n");
329     printf("CONFIGURE ANALYSIS FOR PbPb COLLISIONS \n");
330     printf("====================================== \n");
331     
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
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
344     // Trigger
345     TString clTrigger = "EMCGA"; 
346     TString anTrigger = "EMCGA";  
347     if(kMC) 
348     {
349       clTrigger = "";
350       anTrigger = "";
351     }
352     
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    
356     
357     //Analysis with clusterizer V1
358     
359     TString arrayNameV1 = "";
360     AliAnalysisTaskEMCALClusterize * clv1 = AddTaskEMCALClusterize(kMC,exo,"V1",arrayNameV1,clTrigger, clTM,
361                                                                    minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
362                                                                    calibEE,badMap,calibTT,annonlin);    
363     
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, 
369                                                                          0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
370     AliAnalysisTaskCaloTrackCorrelation *anav1m   = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(), 
371                                                                         kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
372                                                                          20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
373     AliAnalysisTaskCaloTrackCorrelation *anav1p   = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC,  selectEvents, exo, annonlin, outputFile.Data(), 
374                                                                         kYear,kCollision,anTrigger,arrayNameV1,reTM,anTM,
375                                                                          60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
376   
377     //Analysis with clusterizer V2
378
379     TString arrayNameV2 = "";
380     AliAnalysisTaskEMCALClusterize * clv2 = AddTaskEMCALClusterize(kMC,exo,"V2",arrayNameV2,clTrigger, clTM,
381                                                                    minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
382                                                                    calibEE,badMap,calibTT,annonlin);        
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, 
390                                                                          0,20,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
391     AliAnalysisTaskCaloTrackCorrelation *anav2m   = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(), 
392                                                                          kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
393                                                                          20,40,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
394     AliAnalysisTaskCaloTrackCorrelation *anav2p   = AddTaskCaloTrackCorr(kInputData, "EMCAL", kMC, selectEvents, exo, annonlin, outputFile.Data(), 
395                                                                          kYear,kCollision,anTrigger,arrayNameV2,reTM,anTM,
396                                                                          60,80,qa,hadron,calibEE,badMap,calibTT,deltaAOD,kPrint);
397   }
398   
399   //-----------------------
400   // Run the analysis
401   //-----------------------    
402   mgr->InitAnalysis();
403   mgr->PrintStatus();
404   
405   if      (mode == mPlugin) mgr->StartAnalysis("grid");
406   else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
407   else                      mgr->StartAnalysis("local",chain);
408   
409   cout <<" Analysis ended sucessfully "<< endl ;
410   
411 }
412
413 //_____________________________
414 void  LoadLibraries(Int_t mode)
415 {
416   
417   if (mode == mPROOF) {
418     //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
419     gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
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");
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");
435     //     proof->UploadPackage("PWGCaloTrackCorrBase");
436     //     proof->UploadPackage("PWGGACaloTrackCorrelations");
437     //     proof->UploadPackage("PWGGAEMCALTasks");
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");
449     //     proof->EnablePackage("PWGCaloTrackCorrBase");
450     //     proof->EnablePackage("PWGGACaloTrackCorrelations");
451     //     proof->EnablePackage("PWGGAEMCALTasks");
452     return;
453   }  
454   
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");
462   gSystem->Load("libMatrix.so");
463   gSystem->Load("libPhysics.so");
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"); 
473   gSystem->Load("libOADB");
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");
499   gSystem->Load("libPWGCaloTrackCorrBase");
500   gSystem->Load("libPWGGACaloTrackCorrelations");
501   gSystem->Load("libPWGGAEMCALTasks");
502   //SetupPar("PWGCaloTrackCorrBase");
503   //SetupPar("PWGGACaloTrackCorrelations");
504   //SetupPar("PWGGAEMCALTasks");
505   
506  
507   //gSystem->Load("libJETAN");
508   //gSystem->Load("FASTJETAN");
509   //gSystem->Load("PWGJE");
510
511   //gSystem->Load("libCORRFW.so");
512   //gSystem->Load("libPWGGAGammaConv.so"); 
513   //SetupPar("PWGGAGammaConv"); 
514   
515   // needed for plugin?
516   gSystem->AddIncludePath("-I$ALICE_ROOT");
517   gSystem->AddIncludePath("-I./");     
518   
519 }
520
521 //_________________________________
522 void 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.
527   
528   TString cdir(Form("%s", gSystem->WorkingDirectory() )) ; 
529   TString parpar(Form("%s.par", pararchivename)) ; 
530   
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
564 //______________________________________
565 void CheckInputData(const anaModes mode)
566 {
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)
578     
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++) {
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) ; 
603       sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ; 
604       
605       TFile * fESD = TFile::Open(fileE) ; 
606       TFile * fAOD = TFile::Open(fileA) ; 
607       
608       //Check if file exists and add it, if not skip it
609       if (fESD) 
610       {
611         kTreeName  = "esdTree";
612         kInputData = "ESD";
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         
624         return;
625       }
626       else if(fAOD)
627       {
628         kTreeName  = "aodTree";
629         kInputData = "AOD";
630         if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
631         else kMC = kFALSE;
632         
633         // Get run number
634         TTree* aodTree = (TTree*)fAOD->Get("aodTree");
635         AliAODEvent* aod = new AliAODEvent();
636         aod->ReadFromTree(aodTree);
637         aodTree->GetEvent(0);
638         kRun = aod->GetRunNumber();
639         return;
640       }
641       else if(TFile::Open(fileEm))
642       {
643         kTreeName  = "aodTree";
644         kInputData = "AOD";
645         kMC        = kTRUE;
646         
647         return;
648       }
649       else if(TFile::Open(fileG))
650       {
651         kTreeName  = "TE";
652         kInputData = "MC";
653         kMC        = kTRUE;
654         return;
655       }
656     }
657     
658     if(fESD) fESD->Close();
659     if(fAOD) fAOD->Close();
660     
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       
702       kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
703       printf("Run number from alien path = %d\n",kRun);
704       
705       TFile * fAOD = 0 ; 
706       //Check if file exists and add it, if not skip it
707       if (alienURL.Contains("AliESDs.root"))  
708       {
709         kTreeName  = "esdTree";
710         kInputData = "ESD";
711         alienURL.ReplaceAll("AliESDs.root","galice.root");
712         if(TFile::Open(alienURL)) kMC=kTRUE;
713         else kMC = kFALSE;
714         return;
715       }
716       else if(alienURL.Contains("AliAOD.root"))
717       {
718         kTreeName  = "aodTree";
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       }
725       else if(alienURL.Contains("embededAOD.root"))
726       {
727         kTreeName  = "aodTree";
728         kInputData = "AOD";
729         kMC=kTRUE;
730         return;
731       }
732       else if(alienURL.Contains("galice.root"))
733       {
734         kTreeName  = "TE";
735         kInputData = "MC";
736         kMC=kTRUE;
737         return;
738       } 
739     }
740   }// xml analysis
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
802   
803   gSystem->ChangeDirectory(ocwd.Data());
804   
805 }
806
807 //_____________________________________________________________________
808 void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
809 {
810   //Fills chain with data
811   TString ocwd = gSystem->WorkingDirectory();
812   
813   //---------------------------------------
814   // Local files analysis
815   //---------------------------------------
816   if(mode == mLocal){    
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 
819     //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
820     
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     
829     if(gSystem->Getenv("NFILES"))
830       kFile = atoi(gSystem->Getenv("NFILES")) ;
831     else cout<<"NFILES not set, use default: "<<kFile<<endl;
832     
833     //Check if env variables are set and are correct
834     if ( kInDir  && kFile) {
835       printf("Get %d files from directory %s\n",kFile,kInDir);
836       if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
837         printf("%s does not exist\n", kInDir) ;
838         return ;
839       }
840       
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) {
846         cout<<"GENER "<<kGener<<endl;
847         if     (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
848         else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
849         else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
850       }
851       else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
852       
853       cout<<"INDIR   : "<<kInDir     <<endl;
854       cout<<"NFILES  : "<<kFile      <<endl;
855       cout<<"PATTERN : "<<kPattern   <<endl;
856       cout<<"XSFILE  : "<<kXSFileName<<endl;
857       
858       TString datafile="";
859       if     (kInputData == "ESD")        datafile = "AliESDs.root" ;
860       else if(kInputData.Contains("AOD")) datafile = "AliAOD.root"  ;
861       else if(kInputData == "MC")         datafile = "galice.root"  ;
862       
863       //Loop on ESD/AOD/MC files, add them to chain
864       Int_t event =0;
865       Int_t skipped=0 ; 
866       char file[120] ;
867       char filexs[120] ;
868       
869       for (event = 0 ; event < kFile ; event++) {
870         sprintf(file,   "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ; 
871         sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ; 
872         TFile * fData = 0 ; 
873         //Check if file exists and add it, if not skip it
874         if ( fData = TFile::Open(file)) {
875           if ( fData->Get(kTreeName) ) { 
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         }
885       }
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   //------------------------------
896   // GRID xml files
897   //------------------------------
898   else if(mode == mGRID){
899     //Get colection file. It is specified by the environmental
900     //variable XML
901     
902     //Feed Grid with collection file
903     TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
904     if (! collection) {
905       AliError(Form("%s not found", kXML)) ; 
906       return kFALSE ; 
907     }
908     
909     TGridResult* result = collection->GetGridResult("",0 ,0);
910     
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   
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   
934   gSystem->ChangeDirectory(ocwd.Data());
935   
936 }
937
938 //_________________________________________________________________
939 void 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()  ;
959   if (tree && nfiles > 0) 
960   {
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
980 //______________________________
981 void CheckEnvironmentVariables()
982 {
983   
984   sprintf(kTrigger,"");
985   
986   Bool_t bRecalibrate = kFALSE;
987   Bool_t bBadChannel = kFALSE;
988   
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     
995 #endif
996     
997     TString sRun = "";
998     
999     if (!(strcmp(gApplication->Argv(i),"--trigger")))
1000       sprintf(trigger,gApplication->Argv(i+1));
1001     
1002     if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
1003       bRecalibrate = atoi(gApplication->Argv(i+1));
1004     
1005     if (!(strcmp(gApplication->Argv(i),"--badchannel")))
1006       bBadChannel = atoi(gApplication->Argv(i+1));
1007     
1008     if (!(strcmp(gApplication->Argv(i),"--run"))){
1009       sRun = gApplication->Argv(i+1);
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   
1023   if(!sRun.Contains("LHC10")){
1024     if     ( kRun < 140000) 
1025     {
1026       kYear = 2010;
1027       if( kRun >= 136851 ) kCollision = "PbPb";
1028     }
1029     else if( kRun < 170600)
1030     {
1031       kYear = 2011;
1032       if( kRun >= 166500 ) kCollision = "PbPb";
1033     }
1034     else 
1035     {
1036       kYear = 2012;
1037
1038     }
1039   }
1040   
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   
1049 }
1050
1051 //_______________________________________________
1052 void 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   
1062   if(trigger=="EMC7")
1063   {
1064     printf("counter trigger EMC7\n");
1065     counter->SelectCollisionCandidates(AliVEvent::kEMC7);
1066   }
1067   else if (trigger=="INT7")
1068   {
1069     printf("counter trigger INT7\n");
1070     counter->SelectCollisionCandidates(AliVEvent::kINT7);
1071   }
1072   if(trigger=="EMC1")
1073   {
1074     printf("counter trigger EMC1\n");
1075     counter->SelectCollisionCandidates(AliVEvent::kEMC1);
1076   }
1077   else if(trigger=="MB")
1078   {
1079     printf("counter trigger MB\n");
1080     counter->SelectCollisionCandidates(AliVEvent::kMB);
1081   }
1082   else if(trigger=="PHOS")
1083   {
1084     printf("counter trigger PHOS\n");
1085     counter->SelectCollisionCandidates(AliVEvent::kPHI7);
1086   }
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   
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);
1133   
1134 }
1135
1136
1137
1138
1139