]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPi0.C
Move the rejection of events with large z vertex from the analysis code to the reader...
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPi0.C
1 AliAnalysisTaskParticleCorrelation *AddTaskPi0(TString data, TString calorimeter, Bool_t kPrintSettings = kFALSE,Bool_t kSimulation = kFALSE, Bool_t outputAOD=kFALSE, Bool_t oldAOD=kFALSE)
2 {
3   // Creates a PartCorr task, configures it and adds it to the analysis manager.
4   
5   // Get the pointer to the existing analysis manager via the static access method.
6   //==============================================================================
7   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
8   if (!mgr) {
9     ::Error("AddTaskPi0", "No analysis manager to connect to.");
10     return NULL;
11   }  
12   
13   // Check the analysis type using the event handlers connected to the analysis manager.
14   //==============================================================================
15   if (!mgr->GetInputEventHandler()) {
16     ::Error("AddTaskPi0", "This task requires an input event handler");
17     return NULL;
18   }
19   TString inputDataType = "AOD";
20   if(!data.Contains("delta"))
21     inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
22   //cout<<"DATA TYPE :: "<<inputDataType<<endl;
23   // inputDataType: data managed by the input handler
24   // data: can be same as one managed by input handler, or the output AOD created by the filter. By default use AOD
25   
26   Bool_t kUseKinematics = kFALSE; 
27   if(kSimulation) { 
28     kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE; 
29     if (!kUseKinematics && data=="AOD" && inputDataType != "ESD") kUseKinematics = kTRUE; //AOD primary should be available ... 
30   } 
31   
32   cout<<"********* ACCESS KINE? "<<kUseKinematics<<endl;
33   
34   // Configure analysis
35   //===========================================================================
36   
37   // *** Reader ***
38   AliCaloTrackReader * reader = ;
39   if(data.Contains("AOD")) reader = new AliCaloTrackAODReader();
40   else if(data=="ESD") reader = new AliCaloTrackESDReader();
41   else if(data=="MC" && inputDataType == "ESD") reader = new AliCaloTrackMCReader();
42   reader->SetDebug(-1);//10 for lots of messages
43   reader->SwitchOnCTS();
44   //reader->SetDeltaAODFileName("");
45   //if(!kSimulation) reader->SetFiredTriggerClassName("CINT1B-ABCE-NOPF-ALL");
46   if(calorimeter == "EMCAL") {
47     reader->SwitchOnEMCALCells();  
48     reader->SwitchOnEMCAL();
49   }
50   if(calorimeter == "PHOS") { 
51     reader->SwitchOnPHOSCells();  
52     reader->SwitchOnPHOS();
53   }
54   
55   // for case data="deltaAOD", no need to fill the EMCAL/PHOS cluster lists
56   if(data.Contains("delta")){
57     reader->SwitchOffEMCAL();
58     reader->SwitchOffPHOS();
59     reader->SwitchOffEMCALCells(); 
60     reader->SwitchOffPHOSCells(); 
61   }
62   
63   if(kUseKinematics){
64     if(inputDataType == "ESD"){
65       reader->SwitchOnStack();          
66       reader->SwitchOffAODMCParticles(); 
67     }
68     else if(inputDataType == "AOD"){
69       reader->SwitchOffStack();          
70       reader->SwitchOnAODMCParticles(); 
71     }
72   }
73
74   //In case of AODs created only for calorimeters, and track information filtered
75   //CTS is off when calling this method
76   //reader->SwitchOnCaloFilterPatch();
77   
78   reader->SetZvertexCut(10.);
79   
80   //Min particle pT
81   reader->SetEMCALPtMin(0.1); 
82   reader->SetPHOSPtMin(0.);
83   reader->SetCTSPtMin(0.);
84   if(outputAOD)  reader->SwitchOnWriteDeltaAOD()  ;
85   if(oldAOD) reader->SwitchOnOldAODs();
86   if(kPrintSettings) reader->Print("");
87   
88   // *** Calorimeters Utils     ***
89   AliCalorimeterUtils *cu = new AliCalorimeterUtils;
90   // Remove clusters close to borders, at least max energy cell is 1 cell away 
91   cu->SetNumberOfCellsFromEMCALBorder(1);
92   cu->SetNumberOfCellsFromPHOSBorder(2);
93   
94   // Remove EMCAL hottest channels for first LHC10 periods      
95   //  cu->SwitchOnBadChannelsRemoval();
96   //  cu->SwitchOnDistToBadChannelRecalculation();
97
98 //   TFile * fbad = new TFile("BadChannels.root","read");
99 //   TH2I * hbad0 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod0");
100 //   TH2I * hbad1 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod1");
101 //   TH2I * hbad2 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod2");
102 //   TH2I * hbad3 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod3");
103 //   cu->SetEMCALChannelStatusMap(0,hbad0);
104 //   cu->SetEMCALChannelStatusMap(1,hbad1);
105 //   cu->SetEMCALChannelStatusMap(2,hbad2);
106 //   cu->SetEMCALChannelStatusMap(3,hbad3);
107   
108   
109   //Recalibration
110   //cu->SwitchOnRecalibration();
111   //TFile * f = new TFile("RecalibrationFactors.root","read");
112   //cu->SetEMCALChannelRecalibrationFactors(0,(TH2F*)f->Get("EMCALRecalFactors_SM0"));
113   //cu->SetEMCALChannelRecalibrationFactors(1,(TH2F*)f->Get("EMCALRecalFactors_SM1"));
114   //cu->SetEMCALChannelRecalibrationFactors(2,(TH2F*)f->Get("EMCALRecalFactors_SM2"));
115   //cu->SetEMCALChannelRecalibrationFactors(3,(TH2F*)f->Get("EMCALRecalFactors_SM3"));
116   //f->Close(); 
117   
118   cu->SetDebug(-1);
119   if(kPrintSettings) cu->Print("");
120   
121   
122   // ##### Analysis algorithm settings ####
123   
124   // -------------------------------------------------
125   // --- Photon/Pi0/Omega/Electron Analysis ---
126   // -------------------------------------------------
127   
128   AliAnaPhoton *anaphoton = new AliAnaPhoton();
129   anaphoton->SetDebug(-1); //10 for lots of messages
130   if(calorimeter == "PHOS"){
131     anaphoton->SetNCellCut(0);// At least 2 cells
132     anaphoton->SetMinPt(0.);
133     anaphoton->SetMinDistanceToBadChannel(2, 4, 5);
134   }
135   else {//EMCAL
136     //anaphoton->SetNCellCut(0);// At least 2 cells
137     anaphoton->SetMinPt(0.1); // no effect minium EMCAL cut.
138     if(!kUseKinematics) anaphoton->SetTimeCut(400,900);// Time window of [400-900] ns
139     anaphoton->SetMinDistanceToBadChannel(6, 12, 18);//For officially produced ESDs/AODs
140     //anaphoton->SetMinDistanceToBadChannel(1, 2, 3);//For filtered AODs, new releases.
141   }
142   anaphoton->SetCalorimeter(calorimeter);
143   if(kUseKinematics) anaphoton->SwitchOnDataMC() ;//Access MC stack and fill more histograms
144   else  anaphoton->SwitchOffDataMC() ;
145   anaphoton->SwitchOffCaloPID();
146   anaphoton->SwitchOffFiducialCut();
147   if(kSimulation){
148     anaphoton->SwitchOnFiducialCut();
149     AliFiducialCut * fidCut1stYear = anaphoton->GetFiducialCut();
150     fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
151     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
152     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
153     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
154     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
155   }
156   
157   if(!data.Contains("delta")) {
158     anaphoton->SetOutputAODName(Form("Photons%s",calorimeter.Data()));
159     anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
160   }
161   else anaphoton->SetInputAODName(Form("Photons%s",calorimeter.Data()));
162   anaphoton->AddToHistogramsName("AnaPhotonCorr_");
163   //Set Histograms bins and ranges
164   anaphoton->SetHistoPtRangeAndNBins(0, 100, 200) ;
165   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
166   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
167   if(kPrintSettings) anaphoton->Print("");
168   
169   // -----------------------------------
170   // --- Pi0 Invariant Mass Analysis ---
171   // -----------------------------------
172   
173   AliAnaPi0 *anapi0 = new AliAnaPi0();
174   anapi0->SetDebug(-1);//10 for lots of messages
175   anapi0->SetInputAODName(Form("Photons%s",calorimeter.Data()));
176   anapi0->SetCalorimeter(calorimeter);
177   
178   anapi0->SwitchOnMultipleCutAnalysis(); 
179   //anapi0->SetNPtCuts(2);
180   //anapi0->SetNAsymCuts(2);
181   //anapi0->SetNNCellCuts(2);
182   anapi0->SetNPIDBits(2);
183   
184   //anapi0->SetPtCutsAt(0,0.3); anapi0->SetPtCutsAt(1,0.5);
185   //anapi0->SetAsymCutsAt(0,0.1);anapi0->SetAsymCutsAt(1,0.5);
186   //anapi0->SetNCellCutsAt(0,1); anapi0->SetNCellCutsAt(1,2);
187   anapi0->SetPIDBitsAt(0,0); //No Cut
188   anapi0->SetPIDBitsAt(1,2); //Dispersion Cut
189
190   
191   if(kSimulation){
192     anapi0->SwitchOnFiducialCut();
193     AliFiducialCut * fidCut1stYear = anapi0->GetFiducialCut();
194     fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
195     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
196     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
197     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
198     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
199   }  
200         
201   //settings for pp collision mixing
202   anapi0->SwitchOnOwnMix(); //Off when mixing done with general mixing frame
203   anapi0->SetNCentrBin(1);
204   anapi0->SetNZvertBin(1);
205   anapi0->SetNRPBin(1);
206   anapi0->SetNMaxEvMix(10);
207   
208   if(kUseKinematics)anapi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
209   else              anapi0->SwitchOffDataMC() ;
210   if(calorimeter=="PHOS") anapi0->SetNumberOfModules(3); //PHOS first year
211   else  anapi0->SetNumberOfModules(4); //EMCAL first year
212   anapi0->SetHistoPtRangeAndNBins(0, 20, 200) ;
213   //anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
214   //anapi0->SetHistoEtaRangeAndNBins(-0.8, 0.8, 200) ;
215   anapi0->SetHistoMassRangeAndNBins(0., 0.9, 300) ;
216   anapi0->SetHistoAsymmetryRangeAndNBins(0., 1. , 100) ;
217   anapi0->SetHistoTrackMultiplicityRangeAndNBins(0, 200, 20); 
218
219   if(kPrintSettings) anapi0->Print("");
220
221   
222   
223   // #### Configure Maker ####
224   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
225   maker->SetReader(reader);//pointer to reader
226   maker->SetCaloUtils(cu); //pointer to calorimeter utils
227   Int_t n = 0;//Analysis number, order is important
228   // Particle selection analysis
229   maker->AddAnalysis(anaphoton,n++);
230   maker->AddAnalysis(anapi0,n++);
231   maker->SetAnaDebug(-1)  ;
232   maker->SwitchOnHistogramsMaker()  ;
233   if(data.Contains("delta")) maker->SwitchOffAODsMaker()  ;
234   else                       maker->SwitchOnAODsMaker()  ;
235         
236   if(kPrintSettings) maker->Print("");
237   
238   printf("======================== \n");
239   printf(" End Configuration of Pi0 analysis with detector %s \n",calorimeter.Data());
240   printf("======================== \n");
241   
242   // Create task
243   //===========================================================================
244   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
245   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
246   //task->SetDebugLevel(-1);
247   if(data=="ESD")task->SelectCollisionCandidates();
248   task->SetAnalysisMaker(maker);
249   //if(!kSimulation)task->SelectCollisionCandidates(); //AliPhysicsSelection has to be attached before.
250   mgr->AddTask(task);
251   
252   //Create containers
253   char name[128];
254   sprintf(name,"PartCorr_%s",calorimeter.Data());
255   cout<<"Name of task "<<name<<endl;
256   //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
257   //                                       AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
258   
259   TString outputfile = AliAnalysisManager::GetCommonFileName(); 
260   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()),  TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
261   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(calorimeter.Data(), TList::Class(), 
262                                                              AliAnalysisManager::kOutputContainer, 
263                                                              Form("%s:PartCorr",outputfile.Data()));
264         
265   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts",calorimeter.Data()), TList::Class(), 
266                                                              AliAnalysisManager::kParamContainer, 
267                                                              Form("%s:PartCorrCuts",outputfile.Data()));
268         
269   // Create ONLY the output containers for the data produced by the task.
270   // Get and connect other common input/output containers via the manager as below
271   //==============================================================================
272   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
273   // AOD output slot will be used in a different way in future
274   if(!data.Contains("delta")   && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
275   mgr->ConnectOutput (task, 1, cout_pc);
276   mgr->ConnectOutput (task, 2, cout_cuts);
277   
278   return task;
279 }
280
281