]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliIsolationCut.cxx
AliAnaPi0: Added option to fill mass histograms with different cuts
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliIsolationCut.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is 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:  $ */
16
17 //_________________________________________________________________________
18 // Class containing methods for the isolation cut. 
19 // An AOD candidate (AliAODPWG4ParticleCorrelation type)
20 // is passed. Look in a cone around the candidate and study
21 // the hadronic activity inside to decide if the candidate is isolated
22 //
23 //
24 //*-- Author: Gustavo Conesa (LNF-INFN) 
25 //////////////////////////////////////////////////////////////////////////////
26   
27   
28 // --- ROOT system --- 
29 //#include <Riostream.h>
30 #include <TLorentzVector.h>
31 #include <TObjArray.h>
32
33 // --- AliRoot system --- 
34 #include "AliIsolationCut.h" 
35 #include "AliAODPWG4ParticleCorrelation.h"
36 #include "AliAODTrack.h"
37 #include "AliVCluster.h"
38 #include "AliCaloTrackReader.h"
39
40 ClassImp(AliIsolationCut)
41   
42 //____________________________________________________________________________
43   AliIsolationCut::AliIsolationCut() : 
44     TObject(),
45     fConeSize(0.),fPtThreshold(0.), fPtFraction(0.), fICMethod(0),fPartInCone(0)
46  
47 {
48   //default ctor
49   
50   //Initialize parameters
51   InitParameters();
52
53 }
54 /*
55 //____________________________________________________________________________
56 AliIsolationCut::AliIsolationCut(const AliIsolationCut & g) : 
57   TObject(g),
58   fConeSize(g.fConeSize),
59   fPtThreshold(g.fPtThreshold),
60   fPtFraction(g.fPtFraction), 
61   fICMethod(g.fICMethod)
62 {
63   // cpy ctor
64   
65 }
66
67 //_________________________________________________________________________
68 AliIsolationCut & AliIsolationCut::operator = (const AliIsolationCut & source)
69 {
70   // assignment operator
71   
72   if(&source == this) return *this;
73   
74   fConeSize = source.fConeSize ;
75   fPtThreshold = source.fPtThreshold ; 
76   fICMethod = source.fICMethod ;
77   fPtFraction = source.fPtFraction ;
78
79   return *this;
80   
81 }
82 */
83 //____________________________________________________________________________
84 TString AliIsolationCut::GetICParametersList()
85 {
86   //Put data member values in string to keep in output container
87   
88   TString parList ; //this will be list of parameters used for this analysis.
89   const Int_t buffersize = 255;
90   char onePar[buffersize] ;
91   
92   snprintf(onePar,buffersize,"--- AliIsolationCut ---\n") ;
93   parList+=onePar ;     
94   snprintf(onePar,buffersize,"fConeSize: (isolation cone size) %1.2f\n",fConeSize) ;
95   parList+=onePar ;
96   snprintf(onePar,buffersize,"fPtThreshold =%1.2f (isolation pt threshold) \n",fPtThreshold) ;
97   parList+=onePar ;
98   snprintf(onePar,buffersize,"fPtFraction=%1.2f (isolation pt threshold fraction ) \n",fPtFraction) ;
99   parList+=onePar ;
100   snprintf(onePar,buffersize,"fICMethod=%d (isolation cut case) \n",fICMethod) ;
101   parList+=onePar ;
102   snprintf(onePar,buffersize,"fPartInCone=%d \n",fPartInCone) ;
103   parList+=onePar ;
104
105   return parList; 
106 }
107
108 //____________________________________________________________________________
109 void AliIsolationCut::InitParameters()
110 {
111   //Initialize the parameters of the analysis.
112   
113   fConeSize    = 0.4 ; 
114   fPtThreshold = 1. ; 
115   fPtFraction  = 0.1 ; 
116   fPartInCone  = kNeutralAndCharged;
117   fICMethod    = kPtThresIC; // 0 pt threshol method, 1 cone pt sum method
118   
119 }
120
121 //__________________________________________________________________
122 void  AliIsolationCut::MakeIsolationCut(TObjArray * const plCTS,  TObjArray * const plNe, AliCaloTrackReader * const reader, 
123                                         const Bool_t fillAOD, AliAODPWG4ParticleCorrelation  *pCandidate, 
124                                         const TString aodArrayRefName,
125                                         Int_t & n, Int_t & nfrac, Float_t &coneptsum,  Bool_t  &isolated) const
126 {  
127   //Search in cone around a candidate particle if it is isolated 
128   Float_t phiC  = pCandidate->Phi() ;
129   Float_t etaC  = pCandidate->Eta() ;
130   Float_t ptC   = pCandidate->Pt() ;
131   Float_t pt    = -100. ;
132   Float_t eta   = -100.  ;
133   Float_t phi   = -100.  ;
134   Float_t rad   = -100 ;
135   n = 0 ;
136   coneptsum = 0.; 
137   isolated = kFALSE;
138   
139   //Initialize the array with refrences
140   TObjArray * refclusters = 0x0;
141   TObjArray * reftracks   = 0x0;
142   Int_t ntrackrefs   = 0;
143   Int_t nclusterrefs = 0;
144   
145   //Check charged particles in cone.
146   if(plCTS && (fPartInCone==kOnlyCharged || fPartInCone==kNeutralAndCharged)){
147     TVector3 p3;
148     for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ ){
149       AliAODTrack* track = (AliAODTrack *)(plCTS->At(ipr)) ; 
150       //Do not count the candidate (pion, conversion photon) or the daughters of the candidate
151       if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1)) continue ;
152       p3.SetXYZ(track->Px(),track->Py(),track->Pz());
153       pt   = p3.Pt();
154       eta  = p3.Eta();
155       phi  = p3.Phi() ;
156       if(phi<0) phi+=TMath::TwoPi();
157       
158       //Check if there is any particle inside cone with pt larger than  fPtThreshold
159       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
160       
161       if(rad < fConeSize){
162         if(fillAOD) {
163           ntrackrefs++;
164           if(ntrackrefs == 1){
165             reftracks = new TObjArray(0);
166             reftracks->SetName(aodArrayRefName+"Tracks");
167             reftracks->SetOwner(kFALSE);
168           }
169           reftracks->Add(track);
170         }
171         //printf("charged in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
172         coneptsum+=pt;
173         if(pt > fPtThreshold ) n++;
174         if(pt > fPtFraction*ptC ) nfrac++;  
175       }
176     }// charged particle loop
177   }//Tracks
178   
179   //Check neutral particles in cone.  
180   if(plNe && (fPartInCone==kOnlyNeutral || fPartInCone==kNeutralAndCharged)){
181           
182     //Get vertex for photon momentum calculation
183     Double_t vertex[]  = {0,0,0} ; //vertex ;
184     Double_t vertex2[] = {0,0,0} ; //vertex second AOD input ;
185     if(reader->GetDataType()!= AliCaloTrackReader::kMC) 
186     {
187       reader->GetVertex(vertex);
188       //if(reader->GetSecondInputAODTree()) reader->GetSecondInputAODVertex(vertex2);
189     }
190     TLorentzVector mom ;
191     for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){
192       AliVCluster * calo = (AliVCluster *)(plNe->At(ipr)) ;
193       
194       //Do not count the candidate (photon or pi0) or the daughters of the candidate
195       if(calo->GetID() == pCandidate->GetCaloLabel(0) || calo->GetID() == pCandidate->GetCaloLabel(1)) continue ;      //Skip matched clusters with tracks
196       
197       if(calo->GetNTracksMatched() > 0) continue ; 
198       //Input from second AOD?
199       Int_t input = 0;
200       //      if     (pCandidate->GetDetector() == "EMCAL" && reader->GetAODEMCALNormalInputEntries() <= ipr) input = 1 ;
201       //      else if(pCandidate->GetDetector() == "PHOS"  && reader->GetAODPHOSNormalInputEntries()  <= ipr) input = 1;
202       
203       //Get Momentum vector, 
204       if     (input == 0) calo->GetMomentum(mom,vertex) ;//Assume that come from vertex in straight line
205       else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line  
206       
207       pt   = mom.Pt();
208       eta  = mom.Eta();
209       phi  = mom.Phi() ;
210       if(phi<0) phi+=TMath::TwoPi();
211       
212       //Check if there is any particle inside cone with pt larger than  fPtThreshold
213       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
214       if(rad < fConeSize){
215         if(fillAOD) {
216           nclusterrefs++;
217           if(nclusterrefs==1){
218             refclusters = new TObjArray(0);
219             refclusters->SetName(aodArrayRefName+"Clusters");
220             refclusters->SetOwner(kFALSE);
221           }
222           refclusters->Add(calo);
223         }
224         //printf("neutral in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
225         coneptsum+=pt;
226         if(pt > fPtThreshold ) n++;
227         if(pt > fPtFraction*ptC ) nfrac++;
228       }//in cone
229     }// neutral particle loop
230   }//neutrals
231   
232   //printf("Isolation Cut: in cone with: pT>pTthres %d, pT > pTfrac*pTcandidate %d \n",n,nfrac);
233   
234   //Add reference arrays to AOD when filling AODs only
235   if(fillAOD) {
236     if(refclusters)     pCandidate->AddObjArray(refclusters);
237     if(reftracks)       pCandidate->AddObjArray(reftracks);
238   }
239   
240   //Check isolation, depending on method.
241   if( fICMethod == kPtThresIC){
242     if(n==0) isolated = kTRUE ;
243   }
244   else if( fICMethod == kSumPtIC){
245     if(coneptsum < fPtThreshold)
246       isolated  =  kTRUE ;
247   }
248   else if( fICMethod == kPtFracIC){
249     if(nfrac==0) isolated = kTRUE ;
250   }
251   else if( fICMethod == kSumPtFracIC){
252     if(coneptsum < fPtFraction*ptC)
253       isolated  =  kTRUE ;
254   }
255   
256   //if(refclusters) delete refclusters;
257   //if(reftracks)   delete reftracks;
258   
259 }
260
261 //__________________________________________________________________
262 void AliIsolationCut::Print(const Option_t * opt) const
263 {
264   
265   //Print some relevant parameters set for the analysis
266   if(! opt)
267     return;
268   
269   printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;
270   
271   printf("IC method          =     %d\n", fICMethod) ; 
272   printf("Cone Size          =     %1.2f\n", fConeSize) ; 
273   printf("pT threshold       =     %2.1f\n", fPtThreshold) ;
274   printf("pT fraction        =     %3.1f\n", fPtFraction) ;
275   printf("particle type in cone =  %d\n",fPartInCone);
276   printf("    \n") ;
277   
278