1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 /* $Id: AliAnaPhoton.cxx 28688 2008-09-11 15:04:07Z gconesab $ */
17 //_________________________________________________________________________
19 // Class cloned from AliAnaPhoton, main aim is shower shape studies
23 //-- Author: Jocelyn Mlynarz (WSU) and Gustavo Conesa (LPSC-CNRS)
24 //////////////////////////////////////////////////////////////////////////////
27 // --- ROOT system ---
30 #include <TClonesArray.h>
31 //#include <TObjString.h>
32 #include <Riostream.h>
33 #include "TParticle.h"
36 // --- Analysis system ---
37 #include "AliAnaShowerParameter.h"
38 #include "AliCaloTrackReader.h"
40 #include "AliCaloPID.h"
41 #include "AliMCAnalysisUtils.h"
42 #include "AliFiducialCut.h"
43 #include "AliAODCaloCluster.h"
44 #include "AliAODMCParticle.h"
45 #include "AliAnalysisManager.h"
46 #include "AliAnalysisTaskParticleCorrelation.h"
47 #include "AliAODEvent.h"
50 ClassImp(AliAnaShowerParameter)
52 //____________________________________________________________________________
53 AliAnaShowerParameter::AliAnaShowerParameter() :
54 AliAnaPartCorrBaseClass(), fCalorimeter(""), fNCellsCutMin(0),
55 fNCellsCutMax(0), fLambdaCut(0), fTimeCutMin(-1), fTimeCutMax(9999999),
56 fhNClusters(0), fhNCellCluster(0), fhEtaPhiPtCluster(0),
61 fhLambdaPtPhoton(0), fhLambdaPtPi0(0), fhLambdaPtPion(0), fhPtTruthPi0(0)
66 //Initialize parameters
71 //____________________________________________________________________________
72 AliAnaShowerParameter::~AliAnaShowerParameter()
78 //________________________________________________________________________
79 TObjString * AliAnaShowerParameter::GetAnalysisCuts()
81 //Save parameters used for analysis
82 TString parList ; //this will be list of parameters used for this analysis.
83 const Int_t buffersize = 255;
84 char onePar[buffersize] ;
86 snprintf(onePar,buffersize,"--- AliAnaShowerParameter ---\n") ;
88 snprintf(onePar,buffersize,"Calorimeter: %s\n",fCalorimeter.Data()) ;
90 snprintf(onePar,buffersize,"fNCellsCutMin: (Cut in the minimum number of cells) %e\n",fNCellsCutMin) ;
92 snprintf(onePar,buffersize,"fNCellsCutMax: (Cut in the maximum number of cells) %e\n",fNCellsCutMax) ;
94 snprintf(onePar,buffersize,"fLambdaCut: (Cut in the minimum lambda) %e\n",fLambdaCut) ;
97 //Get parameters set in base class.
98 parList += GetBaseParametersList() ;
100 //Get parameters set in PID class.
101 parList += GetCaloPID()->GetPIDParametersList() ;
103 //Get parameters set in FiducialCut class (not available yet)
104 //parlist += GetFidCut()->GetFidCutParametersList()
106 return new TObjString(parList) ;
110 //________________________________________________________________________
111 TList * AliAnaShowerParameter::GetCreateOutputObjects()
113 // Create histograms to be saved in output file and
114 // store them in outputContainer
115 TList * outputContainer = new TList() ;
116 outputContainer->SetName("PhotonHistos") ;
118 Int_t nptbins = GetHistoPtBins();
119 Int_t nphibins = GetHistoPhiBins();
120 Int_t netabins = GetHistoEtaBins();
121 Float_t ptmax = GetHistoPtMax();
122 Float_t phimax = GetHistoPhiMax();
123 Float_t etamax = GetHistoEtaMax();
124 Float_t ptmin = GetHistoPtMin();
125 Float_t phimin = GetHistoPhiMin();
126 Float_t etamin = GetHistoEtaMin();
128 //General non-MC Cluster histograms
129 fhNClusters = new TH1F ("hNClusters","NClusters",21,-0.5,20.5);
130 fhNClusters->SetXTitle("N_{Clusters}");
131 outputContainer->Add(fhNClusters) ;
133 fhNCellCluster = new TH2F ("hNCellCluster","Number of cell per cluster",nptbins,ptmin,ptmax,21,-0.5,20.5);
134 fhNCellCluster->SetYTitle("N_{Cells}");
135 fhNCellCluster->SetXTitle("p_{T}");
136 outputContainer->Add(fhNCellCluster) ;
138 fhEtaPhiPtCluster = new TH3F
139 ("hEtaPhiPtCluster","#phi_{Cluster} and #eta_{Cluster}",nptbins,ptmin,ptmax,nphibins,phimin,phimax,netabins,etamin,etamax);
140 fhEtaPhiPtCluster->SetZTitle("#eta");
141 fhEtaPhiPtCluster->SetYTitle("#phi");
142 fhEtaPhiPtCluster->SetXTitle("pT_{Cluster} (GeV/c)");
143 outputContainer->Add(fhEtaPhiPtCluster) ;
145 fhLambdaPtCluster = new TH2F
146 ("hLambdaCluster","#lambda_{Cluster}",nptbins,ptmin,ptmax,300,0,3);
147 fhLambdaPtCluster->SetYTitle("#lambda_{0}^{2}");
148 fhLambdaPtCluster->SetXTitle("p_{T Cluster} (GeV/c)");
149 outputContainer->Add(fhLambdaPtCluster) ;
153 fhLambdaPtPhoton = new TH2F
154 ("hLambdaPtPhoton","#lambda_{#gamma}",nptbins,ptmin,ptmax,200,0,2);
155 fhLambdaPtPhoton->SetYTitle("#lambda_{0}^{2}");
156 fhLambdaPtPhoton->SetXTitle("pT_{#gamma, Reco} (GeV)");
157 outputContainer->Add(fhLambdaPtPhoton) ;
159 fhLambdaPtPi0 = new TH2F
160 ("hLambdaPtPi0","#lambda_{#pi^{0}}",nptbins,ptmin,ptmax,200,0,2);
161 fhLambdaPtPi0->SetYTitle("#lambda_{0}^{2}");
162 fhLambdaPtPi0->SetXTitle("pT_{#pi^{0}, Reco} (GeV)");
163 outputContainer->Add(fhLambdaPtPi0) ;
165 fhLambdaPtPion = new TH2F
166 ("hLambdaPtPion","#lambda_{#pi^{+}}",nptbins,ptmin,ptmax,200,0,2);
167 fhLambdaPtPion->SetYTitle("#lambda_{0}^{2}");
168 fhLambdaPtPion->SetXTitle("pT_{#pi^{+}, Reco} (GeV)");
169 outputContainer->Add(fhLambdaPtPion) ;
171 fhPtTruthPi0 = new TH1D("hPtTruthPi0","#pi^{0} MC truth pT",nptbins,ptmin,ptmax) ;
172 fhPtTruthPi0->SetXTitle("pT_{#pi^{0}, Reco} (GeV)");
173 outputContainer->Add(fhPtTruthPi0) ;
177 return outputContainer ;
181 //____________________________________________________________________________
182 void AliAnaShowerParameter::Init()
187 if(fCalorimeter == "PHOS" && !GetReader()->IsPHOSSwitchedOn() && NewOutputAOD()){
188 printf("AliAnaShowerParameter::Init() - !!STOP: You want to use PHOS in analysis but it is not read!! \n!!Check the configuration file!!\n");
191 else if(fCalorimeter == "EMCAL" && !GetReader()->IsEMCALSwitchedOn() && NewOutputAOD()){
192 printf("AliAnaShowerParameter::Init() - !!STOP: You want to use EMCAL in analysis but it is not read!! \n!!Check the configuration file!!\n");
198 //____________________________________________________________________________
199 void AliAnaShowerParameter::InitParameters()
202 //Initialize the parameters of the analysis.
203 AddToHistogramsName("AnaLambda_");
205 fCalorimeter = "EMCAL" ;
208 fTimeCutMax = 9999999;
215 //__________________________________________________________________
216 void AliAnaShowerParameter::MakeAnalysisFillHistograms()
219 //Do analysis and fill histograms
220 if ( GetDebug() > 0) printf("AliAnaShowerParameter::MakeAnalysisFillHistograms() - Starting analysis.\n");
222 // Access MC information in stack if requested, check that it exists.
223 AliStack * stack = 0x0;
224 TClonesArray * mcparticles0 = 0x0;
225 Int_t NClusters = 0 ;
226 TLorentzVector momCluster ;
228 //Check if the stack is available when analysing MC data.
231 if(GetReader()->ReadStack()){
232 stack = GetMCStack() ;
234 printf("AliAnaShowerParameter::MakeAnalysisFillHistograms() - Stack not available, is the MC handler called? STOP\n");
239 else if(GetReader()->ReadAODMCParticles()){
241 //Get the list of MC particles
242 mcparticles0 = GetReader()->GetAODMCParticles(0);
243 if(!mcparticles0 && GetDebug() > 0) {
244 printf("AliAnaShowerParameter::MakeAnalysisFillHistograms() - Standard MCParticles not available !\n");
248 //Loop on stored AOD photons
250 TClonesArray * clustArray = 0x0 ;
251 clustArray = GetAODCaloClusters() ;
252 NClusters = clustArray->GetEntriesFast() ;
253 fhNClusters->Fill(NClusters) ;
255 if(GetDebug() > 0) printf("AliAnaShowerParameter::MakeAnalysisFillHistograms() - aod branch entries %d\n", NClusters);
257 for(Int_t iCluster = 0 ; iCluster < NClusters ; iCluster++){
260 AliAODCaloCluster * caloCluster = (AliAODCaloCluster*) (clustArray->At(iCluster)) ;
261 caloCluster->GetMomentum(momCluster,GetVertex(0)) ;
262 AliAODPWG4Particle * aodCluster = new AliAODPWG4Particle(momCluster) ;
263 Int_t labelCluster = caloCluster->GetLabel() ;
264 aodCluster->SetLabel(labelCluster) ;;
265 aodCluster->SetInputFileIndex(input) ;
266 aodCluster->SetCaloLabel(caloCluster->GetID(),-1) ;
267 aodCluster->SetDetector(fCalorimeter) ;
268 aodCluster->SetTag(GetMCAnalysisUtils()->CheckOrigin(caloCluster->GetLabels(),caloCluster->GetNLabels(),GetReader(), aodCluster->GetInputFileIndex())) ;
270 if (GetDebug() > 3) printf("AliAnaShowerParameter::MakeAnalysisFillHistograms() - Cluster particle label = %d\n",labelCluster) ;
272 //Fill Cluster histograms
273 Float_t ptcluster = aodCluster->Pt() ;
274 Float_t phicluster = aodCluster->Phi() ;
275 Float_t etacluster = aodCluster->Eta() ;
276 Float_t lambdaMainCluster = caloCluster->GetM02() ;
277 Int_t iNumCell = caloCluster->GetNCells() ;
279 if (iNumCell>=fNCellsCutMin&&iNumCell<=fNCellsCutMax&&lambdaMainCluster>=fLambdaCut){
281 //Fill the basic non-MC information about the cluster.
282 fhNCellCluster->Fill(ptcluster,iNumCell) ;
283 fhEtaPhiPtCluster->Fill(ptcluster,phicluster,etacluster) ;
284 fhLambdaPtCluster->Fill(ptcluster,lambdaMainCluster) ;
286 //Play with the MC data if available
289 //Get the tag from AliMCAnalysisUtils for PID
290 Int_t tag = aodCluster->GetTag();
291 if (GetDebug() > 3) printf("AliAnaShowerParameter::MakeAnalysisFillHistograms() - Cluster particle tag= %d\n",tag) ;
292 if ( aodCluster->GetLabel() < 0){
294 printf("AliAnaShowerParameter::MakeAnalysisFillHistograms() - Label is -1; problem in the MC ESD? ");
298 //Check if the tag matches one of the different particle types and fill the corresponding histograms
299 if( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPhoton)&&!(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPi0))) {
300 fhLambdaPtPhoton->Fill(ptcluster,lambdaMainCluster) ;
303 if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPi0)) {
304 fhLambdaPtPi0->Fill(ptcluster,lambdaMainCluster) ;
306 if( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPion)) {
307 fhLambdaPtPion->Fill(ptcluster,lambdaMainCluster) ;
310 // Access MC information in stack if requested, check that it exists.
311 Int_t label = aodCluster->GetLabel();
313 printf("AliAnaShowerParameter::MakeAnalysisFillHistograms() *** bad label ***: label %d \n", label);
320 Float_t fPtGener = 0 ;
321 if(IsDataMC() && stack){
322 TParticle* pGener = stack->Particle(0) ;
323 fPtGener = pGener->Pt() ;
330 //__________________________________________________________________
331 void AliAnaShowerParameter::Print(const Option_t * opt) const
333 //Print some relevant parameters set for the analysis
338 printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
339 AliAnaPartCorrBaseClass::Print(" ");
340 printf("Calorimeter = %s\n", fCalorimeter.Data()) ;
341 printf("Min number of cells in cluster is > %f \n", fNCellsCutMin);
342 printf("Max number of cells in cluster is > %f \n", fNCellsCutMax);
343 printf("Min lambda of cluster is > %f \n", fLambdaCut);