]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliIsolationCut.cxx
hooks for PMD flow analysis
[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 //-Yaxian Mao (add the possibility for different IC method with different pt range, 01/10/2010)
27 //-Yaxian Mao (check the candidate particle is the leading particle or not at the same hemishere)
28
29 //////////////////////////////////////////////////////////////////////////////
30   
31   
32 // --- ROOT system --- 
33 //#include <Riostream.h>
34 #include <TLorentzVector.h>
35 #include <TObjArray.h>
36
37 // --- AliRoot system --- 
38 #include "AliIsolationCut.h" 
39 #include "AliAODPWG4ParticleCorrelation.h"
40 #include "AliAODTrack.h"
41 #include "AliVCluster.h"
42 #include "AliCaloTrackReader.h"
43 #include "AliMixedEvent.h"
44
45 ClassImp(AliIsolationCut)
46   
47 //____________________________________________________________________________
48   AliIsolationCut::AliIsolationCut() : 
49     TObject(),
50     fConeSize(0.),fPtThreshold(0.), fSumPtThreshold(0.), fPtFraction(0.), fICMethod(0),fPartInCone(0)
51  
52 {
53   //default ctor
54   
55   //Initialize parameters
56   InitParameters();
57
58 }
59
60 //____________________________________________________________________________
61 TString AliIsolationCut::GetICParametersList()
62 {
63   //Put data member values in string to keep in output container
64   
65   TString parList ; //this will be list of parameters used for this analysis.
66   const Int_t buffersize = 255;
67   char onePar[buffersize] ;
68   
69   snprintf(onePar,buffersize,"--- AliIsolationCut ---\n") ;
70   parList+=onePar ;     
71   snprintf(onePar,buffersize,"fConeSize: (isolation cone size) %1.2f\n",fConeSize) ;
72   parList+=onePar ;
73   snprintf(onePar,buffersize,"fPtThreshold =%1.2f (isolation pt threshold) \n",fPtThreshold) ;
74   parList+=onePar ;
75   snprintf(onePar,buffersize,"fPtFraction=%1.2f (isolation pt threshold fraction ) \n",fPtFraction) ;
76   parList+=onePar ;
77   snprintf(onePar,buffersize,"fICMethod=%d (isolation cut case) \n",fICMethod) ;
78   parList+=onePar ;
79   snprintf(onePar,buffersize,"fPartInCone=%d \n",fPartInCone) ;
80   parList+=onePar ;
81
82   return parList; 
83 }
84
85 //____________________________________________________________________________
86 void AliIsolationCut::InitParameters()
87 {
88   //Initialize the parameters of the analysis.
89   
90   fConeSize       = 0.4 ; 
91   fPtThreshold    = 1.  ; 
92   fSumPtThreshold = 0.5 ; 
93   fPtFraction     = 0.1 ; 
94   fPartInCone     = kNeutralAndCharged;
95   fICMethod       = kPtThresIC; // 0 pt threshol method, 1 cone pt sum method
96   
97 }
98
99 //__________________________________________________________________
100 void  AliIsolationCut::MakeIsolationCut(TObjArray * const plCTS,  TObjArray * const plNe, AliCaloTrackReader * const reader, 
101                                         const Bool_t bFillAOD, AliAODPWG4ParticleCorrelation  *pCandidate, 
102                                         const TString & aodArrayRefName,
103                                         Int_t & n, Int_t & nfrac, Float_t &coneptsum,  Bool_t  &isolated) const
104 {  
105   //Search in cone around a candidate particle if it is isolated 
106   Float_t phiC  = pCandidate->Phi() ;
107   Float_t etaC  = pCandidate->Eta() ;
108   Float_t ptC   = pCandidate->Pt() ;
109   Float_t pt    = -100. ;
110   Float_t eta   = -100. ;
111   Float_t phi   = -100. ;
112   Float_t rad   = -100. ;
113   
114   n         = 0 ;
115   nfrac     = 0 ;
116   coneptsum = 0.; 
117   isolated  = kFALSE;
118
119   //Initialize the array with refrences
120   TObjArray * refclusters = 0x0;
121   TObjArray * reftracks   = 0x0;
122   Int_t ntrackrefs   = 0;
123   Int_t nclusterrefs = 0;
124   //Check charged particles in cone.
125   if(plCTS && (fPartInCone==kOnlyCharged || fPartInCone==kNeutralAndCharged)){
126     TVector3 p3;
127     for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ ){
128       AliAODTrack* track = (AliAODTrack *)(plCTS->At(ipr)) ; 
129       //Do not count the candidate (pion, conversion photon) or the daughters of the candidate
130       if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1)) continue ;
131       p3.SetXYZ(track->Px(),track->Py(),track->Pz());
132       pt   = p3.Pt();
133       eta  = p3.Eta();
134       phi  = p3.Phi() ;
135       if(phi<0) phi+=TMath::TwoPi();
136       
137       //only loop the particle at the same side of candidate
138       if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
139       //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events
140       if(pt > ptC){
141         n         = -1;
142         nfrac     = -1;
143         coneptsum = -1;
144         isolated  = kFALSE;
145         if(bFillAOD && reftracks) {
146           reftracks->Clear(); 
147           delete reftracks;
148         }
149         return ;
150       }
151       //Check if there is any particle inside cone with pt larger than  fPtThreshold
152       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
153       
154       if(rad < fConeSize){
155         if(bFillAOD) {
156           ntrackrefs++;
157           if(ntrackrefs == 1){
158             reftracks = new TObjArray(0);
159             //reftracks->SetName(Form("Tracks%s",aodArrayRefName.Data()));
160             TString tempo(aodArrayRefName)  ; 
161             tempo += "Tracks" ; 
162             reftracks->SetName(tempo);
163             reftracks->SetOwner(kFALSE);
164           }
165           reftracks->Add(track);
166         }
167         //printf("charged in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
168         coneptsum+=pt;
169         if(pt > fPtThreshold )    n++;
170         if(pt > fPtFraction*ptC ) nfrac++;  
171       } // Inside cone
172     }// charged particle loop
173   }//Tracks
174   
175   //Check neutral particles in cone.  
176   if(plNe && (fPartInCone==kOnlyNeutral || fPartInCone==kNeutralAndCharged)){
177           
178     //Get vertex for photon momentum calculation
179     //Double_t vertex2[] = {0,0,0} ; //vertex second AOD input ;
180     //if(reader->GetDataType()!= AliCaloTrackReader::kMC) 
181     //{
182       //if(reader->GetSecondInputAODTree()) reader->GetSecondInputAODVertex(vertex2);
183     //}
184     TLorentzVector mom ;
185     for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){
186       AliVCluster * calo = (AliVCluster *)(plNe->At(ipr)) ;
187       
188       //Get the index where the cluster comes, to retrieve the corresponding vertex
189       Int_t evtIndex = 0 ; 
190       if (reader->GetMixedEvent()) {
191         evtIndex=reader->GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
192       }
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       
199       //Input from second AOD?
200       //Int_t input = 0;
201       //      if     (pCandidate->GetDetector() == "EMCAL" && reader->GetAODEMCALNormalInputEntries() <= ipr) input = 1 ;
202       //      else if(pCandidate->GetDetector() == "PHOS"  && reader->GetAODPHOSNormalInputEntries()  <= ipr) input = 1;
203       
204       //Get Momentum vector, 
205       //if     (input == 0) 
206       calo->GetMomentum(mom,reader->GetVertex(evtIndex)) ;//Assume that come from vertex in straight line
207       //else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line  
208       
209       pt   = mom.Pt();
210       eta  = mom.Eta();
211       phi  = mom.Phi() ;
212       if(phi<0) phi+=TMath::TwoPi();
213       //only loop the particle at the same side of candidate
214       
215       if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
216       //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events
217       if(pt > ptC){
218         n         = -1;
219         nfrac     = -1;
220         coneptsum = -1;
221         isolated  = kFALSE;
222         if(bFillAOD){
223           if(reftracks){  
224             reftracks  ->Clear();
225             delete reftracks;
226           }
227           if(refclusters){
228             refclusters->Clear(); 
229             delete refclusters;
230           }
231         }
232         return ;
233       }
234       
235       //Check if there is any particle inside cone with pt larger than  fPtThreshold
236       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
237       if(rad < fConeSize){
238         if(bFillAOD) {
239           nclusterrefs++;
240           if(nclusterrefs==1){
241             refclusters = new TObjArray(0);
242             //refclusters->SetName(Form("Clusters%s",aodArrayRefName.Data()));
243             TString tempo(aodArrayRefName)  ; 
244             tempo += "Clusters" ; 
245             refclusters->SetName(tempo);
246             refclusters->SetOwner(kFALSE);
247           }
248           refclusters->Add(calo);
249         }
250         //printf("neutral in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
251         coneptsum+=pt;
252         if(pt > fPtThreshold )     n++;
253         //if fPtFraction*ptC<fPtThreshold then consider the fPtThreshold directly
254         if(fPtFraction*ptC<fPtThreshold) {
255             if(pt>fPtThreshold)    nfrac++ ;
256         }
257         else {
258             if(pt>fPtFraction*ptC) nfrac++; 
259         }
260       }//in cone
261     }// neutral particle loop
262   }//neutrals
263
264   //printf("Isolation Cut: in cone with: pT>pTthres %d, pT > pTfrac*pTcandidate %d \n",n,nfrac);
265   
266   //Add reference arrays to AOD when filling AODs only
267   if(bFillAOD) {
268     if(refclusters)     pCandidate->AddObjArray(refclusters);
269     if(reftracks)         pCandidate->AddObjArray(reftracks);
270   }
271   //Check isolation, depending on method.
272   if( fICMethod == kPtThresIC){
273     if(n==0) isolated = kTRUE ;
274   }
275   else if( fICMethod == kSumPtIC){
276     if(coneptsum < fSumPtThreshold)
277       isolated  =  kTRUE ;
278   }
279   else if( fICMethod == kPtFracIC){
280     if(nfrac==0) isolated = kTRUE ;
281   }
282   else if( fICMethod == kSumPtFracIC){
283     //when the fPtFraction*ptC < fSumPtThreshold then consider the later case
284     if(coneptsum < fPtFraction*ptC && coneptsum < fSumPtThreshold) isolated  =  kTRUE ;
285   }
286   
287 }
288
289 //__________________________________________________________________
290 void AliIsolationCut::Print(const Option_t * opt) const
291 {
292   
293   //Print some relevant parameters set for the analysis
294   if(! opt)
295     return;
296   
297   printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;
298   
299   printf("IC method          =     %d\n", fICMethod) ; 
300   printf("Cone Size          =     %1.2f\n", fConeSize) ; 
301   printf("pT threshold       =     %2.1f\n", fPtThreshold) ;
302   printf("pT fraction        =     %3.1f\n", fPtFraction) ;
303   printf("particle type in cone =  %d\n",fPartInCone);
304   printf("    \n") ;
305   
306