]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorr.C
MC reading in AOD not implemented yet in AliAnaCalorimeterQA, change the train wagon
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorr.C
1 AliAnalysisTaskParticleCorrelation *AddTaskPartCorr(TString data, TString calorimeter, Bool_t kUseKinematics = kFALSE, Bool_t kPrintSettings = 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("AddTaskPartCorr", "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("AddTaskPartCorr", "This task requires an input event handler");
17     return NULL;
18   }
19    TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
20    //cout<<"DATA TYPE :: "<<inputDataType<<endl;
21    // inputDataType: data managed by the input handler
22    // data: can be same as one managed by input handler, or the output AOD created by the filter. By default use AOD
23         
24    // Configure analysis
25    //===========================================================================
26   
27   //Reader
28   AliCaloTrackReader * reader = 0x0;
29   if(data=="AOD") reader = new AliCaloTrackAODReader();
30   else if(data=="ESD") reader = new AliCaloTrackESDReader();
31   else if(data=="MC" && dataType == "ESD") reader = new AliCaloTrackMCReader();
32   reader->SetDebug(-1);//10 for lots of messages
33   if(calorimeter == "EMCAL") reader->SwitchOnEMCALCells();
34   if(calorimeter == "PHOS")  reader->SwitchOnPHOSCells();
35   if(kUseKinematics){
36         if(inputDataType == "ESD"){
37                 reader->SwitchOnStack();          
38                 reader->SwitchOffAODMCParticles(); 
39         }
40         else if(inputDataType == "AOD"){
41                 reader->SwitchOffStack();          
42                 reader->SwitchOnAODMCParticles(); 
43         }
44   }
45         
46   //Min particle pT
47   reader->SetEMCALPtMin(0.2); 
48   reader->SetPHOSPtMin(0.2);
49   reader->SetCTSPtMin(0.2);
50   if(kPrintSettings) reader->Print("");
51   
52   // ##### Analysis algorithm settings ####
53
54   // --------------------
55   // --- Pi0 Analysis ---
56   // --------------------
57   
58   AliCaloPID * pid = new AliCaloPID();
59   pid->SetDispersionCut(1.5);
60   pid->SetTOFCut(5.e-9);
61   pid->SetDebug(-1);
62   if(kPrintSettings) pid->Print("");
63         
64   AliFidutialCut * fidCut = new AliFidutialCut();
65   fidCut->DoCTSFidutialCut(kFALSE) ;
66   fidCut->DoEMCALFidutialCut(kTRUE) ;
67   fidCut->DoPHOSFidutialCut(kTRUE) ;
68         
69   AliAnaCalorimeterQA *qa = new AliAnaCalorimeterQA();
70   qa->SetDebug(-1); //10 for lots of messages
71   qa->SetCalorimeter(calorimeter);
72   if(kUseKinematics && data!="AOD") qa->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
73   else  qa->SwitchOffDataMC() ;
74   qa->AddToHistogramsName(Form("AnaCaloQA_%s",calorimeter.Data()));
75   qa->SetFidutialCut(fidCut);
76   qa->SwitchOnFidutialCut();
77   if(kPrintSettings) qa->Print("");     
78         
79   AliFidutialCut * fidCut1stYear = new AliFidutialCut();
80   fidCut1stYear->DoCTSFidutialCut(kFALSE) ;
81   fidCut1stYear->DoEMCALFidutialCut(kTRUE) ;
82   fidCut1stYear->DoPHOSFidutialCut(kTRUE) ;
83   fidCut1stYear->SetSimpleEMCALFidutialCut(0.7,80.,120.);
84   fidCut1stYear->SetSimplePHOSFidutialCut(0.12,260.,320.);
85         
86   AliAnaPhoton *anaphoton1 = new AliAnaPhoton();
87   anaphoton1->SetDebug(-1); //10 for lots of messages
88   //anaphoton->SetMinPt(0.5);
89   anaphoton1->SetMinDistanceToBadChannel(2, 4, 5);
90   anaphoton1->SetCaloPID(pid);
91   anaphoton1->SetCalorimeter(calorimeter);
92   if(kUseKinematics) anaphoton1->SwitchOnDataMC() ;//Access MC stack and fill more histograms
93   else  anaphoton1->SwitchOffDataMC() ;
94   anaphoton1->SwitchOffCaloPID();
95   anaphoton1->SwitchOffCaloPIDRecalculation(); //recommended for EMCAL
96   anaphoton1->SwitchOnFidutialCut();
97   anaphoton1->SetFidutialCut(fidCut1stYear);
98   anaphoton1->SetOutputAODName(Form("PhotonsForIM%s",calorimeter.Data()));
99   if(kPrintSettings) anaphoton1->Print("");
100
101   AliAnaPi0 *anapi0 = new AliAnaPi0();
102   anapi0->SetDebug(-1);//10 for lots of messages
103   anapi0->SetInputAODName(Form("PhotonsForIM%s",calorimeter.Data()));
104   anapi0->SetCaloPID(pid);
105   anapi0->SetCalorimeter(calorimeter);
106   anapi0->SwitchOnFidutialCut();
107   anapi0->SwitchOffDataMC() ;//Access MC stack and fill more histograms
108   if(kPrintSettings) anapi0->Print("");
109   
110         
111   // -------------------------------------------------
112   // --- Photon Isolation and Correlation Analysis ---
113   // -------------------------------------------------
114   
115   AliAnaPhoton *anaphoton2 = new AliAnaPhoton();
116   anaphoton2->SetDebug(-1); //10 for lots of messages
117   anaphoton2->SetMinPt(5);
118   anaphoton2->SetCaloPID(pid);
119   anaphoton2->SetCalorimeter(calorimeter);
120   if(kUseKinematics) anaphoton2->SwitchOnDataMC() ;//Access MC stack and fill more histograms
121   else  anaphoton2->SwitchOffDataMC() ;
122   anaphoton2->SwitchOnCaloPID();
123   if(calorimeter == "EMCAL") anaphoton2->SwitchOnCaloPIDRecalculation();
124   anaphoton2->SwitchOffFidutialCut();
125   anaphoton2->SetOutputAODName(Form("DirectPhotons%s",calorimeter.Data()));
126   anaphoton2->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
127   anaphoton2->AddToHistogramsName("AnaPhotonCorr_");
128   if(kPrintSettings) anaphoton2->Print("");
129   // ### Isolation analysis ### 
130   
131   AliIsolationCut * ic = new AliIsolationCut();
132   ic->SetConeSize(0.5);
133   ic->SetPtThreshold(1.);
134   ic->SetICMethod(AliIsolationCut::kPtThresIC);
135   if(kPrintSettings) ic->Print("");
136   
137   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
138   anaisol->SetDebug(-1);
139   //anaisol->SetMinPt(5);
140   anaisol->SetInputAODName(Form("DirectPhotons%s",calorimeter.Data()));
141   anaisol->SetCalorimeter(calorimeter);
142   if(kUseKinematics) anaisol->SwitchOnDataMC() ;//Access MC stack and fill more histograms
143   else  anaisol->SwitchOffDataMC() ;
144   //Select clusters with no pair, if both clusters with pi0 mass
145   anaisol->SwitchOffInvariantMass();
146   //anaisol->SetNeutralMesonSelection(nms);
147   //Do isolation cut
148   anaisol->SetIsolationCut(ic); 
149   //Do or not do isolation with previously produced AODs.
150   //No effect if use of SwitchOnSeveralIsolation()
151   anaisol->SwitchOffReIsolation();
152   //Multiple IC
153   anaisol->SwitchOffSeveralIsolation() ;
154   if(kPrintSettings) anaisol->Print("");
155   
156   // ### Correlation with Jet Finder AOD output
157   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
158   anacorrjet->SetInputAODName(Form("DirectPhotons%s",calorimeter.Data()));
159   anacorrjet->SwitchOffFidutialCut();
160   anacorrjet->SetDebug(-1);
161   anacorrjet->SetConeSize(1);  
162   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
163   anacorrjet->SetPtThresholdInCone(0.2);
164   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
165   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
166   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
167   if(kPrintSettings) anacorrjet->Print("");
168   
169   // ### Correlation with hadrons
170   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
171   anacorrhadron->SetInputAODName(Form("DirectPhotons%s",calorimeter.Data()));
172   anacorrhadron->SetOutputAODName(Form("CorrelatedPi0s%s",calorimeter.Data()));
173   anacorrhadron->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
174   anacorrhadron->SetDebug(-1);
175   anacorrhadron->SwitchOffCaloPID();
176   anacorrhadron->SwitchOffFidutialCut();
177   anacorrhadron->SetPtCutRange(1,100);
178   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
179   anacorrhadron->SelectIsolated(kTRUE); // do correlation with isolated photons
180   if(calorimeter=="PHOS"){
181     //Correlate with particles in EMCAL
182     anacorrhadron->SwitchOnCaloPID();
183     anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
184   }
185   if(kPrintSettings) anacorrhadron->Print("");
186   
187   // #### Configure Maker ####
188   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
189   maker->SetReader(reader);//pointer to reader
190   maker->AddAnalysis(qa,0);
191   maker->AddAnalysis(anaphoton1,1);
192   maker->AddAnalysis(anapi0,2);
193   maker->AddAnalysis(anaphoton2,3);
194   maker->AddAnalysis(anaisol,4);
195   maker->AddAnalysis(anacorrjet,5);
196   maker->AddAnalysis(anacorrhadron,6);
197   maker->SetAnaDebug(-1)  ;
198   maker->SwitchOnHistogramsMaker()  ;
199   maker->SwitchOnAODsMaker()  ;
200   if(kPrintSettings) maker->Print("");
201   
202   printf("======================== \n");
203   printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
204   printf("======================== \n");
205   
206    // Create task
207    //===========================================================================
208   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
209   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
210   //task->SetDebugLevel(-1);
211   task->SetAnalysisMaker(maker);                                
212   mgr->AddTask(task);
213   
214   char name[128];
215   sprintf(name,"PartCorr_%s",calorimeter.Data());
216 cout<<"Name of task "<<name<<endl;
217   AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
218                                                            AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
219   
220   // Create ONLY the output containers for the data produced by the task.
221   // Get and connect other common input/output containers via the manager as below
222   //==============================================================================
223   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
224   // AOD output slot will be used in a different way in future
225   mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
226   mgr->ConnectOutput (task, 1, cout_pc);
227   
228   return task;
229 }
230
231