]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliIsolationCut.cxx
AliCaloTrackReader:
[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     = kOnlyCharged;
95   fICMethod       = kSumPtFracIC; // 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, Bool_t &leading) const
104 {  
105   //Search in cone around a candidate particle if it is isolated 
106   Float_t phiC  = pCandidate->Phi() ;
107   if(phiC<0) phiC+=TMath::TwoPi();
108   Float_t etaC  = pCandidate->Eta() ;
109   Float_t ptC   = pCandidate->Pt() ;
110   Float_t pt    = -100. ;
111   Float_t eta   = -100. ;
112   Float_t phi   = -100. ;
113   Float_t rad   = -100. ;
114   
115   n         = 0 ;
116   nfrac     = 0 ;
117   coneptsum = 0.; 
118   isolated  = kFALSE;
119   leading   = kTRUE;
120
121   //Initialize the array with refrences
122   TObjArray * refclusters = 0x0;
123   TObjArray * reftracks   = 0x0;
124   Int_t ntrackrefs   = 0;
125   Int_t nclusterrefs = 0;
126   //Check charged particles in cone.
127   if(plCTS && (fPartInCone==kOnlyCharged || fPartInCone==kNeutralAndCharged)){
128     TVector3 p3;
129     for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ ){
130       AliAODTrack* track = (AliAODTrack *)(plCTS->At(ipr)) ; 
131       //Do not count the candidate (pion, conversion photon) or the daughters of the candidate
132       if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1) 
133       || track->GetID() == pCandidate->GetTrackLabel(2) || track->GetID() == pCandidate->GetTrackLabel(3) 
134          ) continue ;
135       p3.SetXYZ(track->Px(),track->Py(),track->Pz());
136       pt   = p3.Pt();
137       eta  = p3.Eta();
138       phi  = p3.Phi() ;
139       if(phi<0) phi+=TMath::TwoPi();
140       
141       //only loop the particle at the same side of candidate
142       if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
143       //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events
144       if(pt > ptC){
145         n         = -1;
146         nfrac     = -1;
147         coneptsum = -1;
148         isolated  = kFALSE;
149         leading   = kFALSE;
150         if(bFillAOD && reftracks) {
151           reftracks->Clear(); 
152           delete reftracks;
153         }
154         return ;
155       }
156       //Check if there is any particle inside cone with pt larger than  fPtThreshold
157       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
158       
159       if(rad < fConeSize){
160         if(bFillAOD) {
161           ntrackrefs++;
162           if(ntrackrefs == 1){
163             reftracks = new TObjArray(0);
164             //reftracks->SetName(Form("Tracks%s",aodArrayRefName.Data()));
165             TString tempo(aodArrayRefName)  ; 
166             tempo += "Tracks" ; 
167             reftracks->SetName(tempo);
168             reftracks->SetOwner(kFALSE);
169           }
170           reftracks->Add(track);
171         }
172         //printf("charged in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
173         coneptsum+=pt;
174         if(pt > fPtThreshold )    n++;
175         if(pt > fPtFraction*ptC ) nfrac++;  
176       } // Inside cone
177     }// charged particle loop
178   }//Tracks
179   
180   //Check neutral particles in cone.  
181   if(plNe && (fPartInCone==kOnlyNeutral || fPartInCone==kNeutralAndCharged)){
182           
183     //Get vertex for photon momentum calculation
184     //Double_t vertex2[] = {0,0,0} ; //vertex second AOD input ;
185     //if(reader->GetDataType()!= AliCaloTrackReader::kMC) 
186     //{
187       //if(reader->GetSecondInputAODTree()) reader->GetSecondInputAODVertex(vertex2);
188     //}
189     TLorentzVector mom ;
190     for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){
191       AliVCluster * calo = (AliVCluster *)(plNe->At(ipr)) ;
192       
193       //Get the index where the cluster comes, to retrieve the corresponding vertex
194       Int_t evtIndex = 0 ; 
195       if (reader->GetMixedEvent()) {
196         evtIndex=reader->GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
197       }
198       
199       //Do not count the candidate (photon or pi0) or the daughters of the candidate
200       if(calo->GetID() == pCandidate->GetCaloLabel(0) || calo->GetID() == pCandidate->GetCaloLabel(1)) continue ;      //Skip matched clusters with tracks
201       
202       if(calo->GetNTracksMatched() > 0) continue ; 
203       
204       //Input from second AOD?
205       //Int_t input = 0;
206       //      if     (pCandidate->GetDetector() == "EMCAL" && reader->GetAODEMCALNormalInputEntries() <= ipr) input = 1 ;
207       //      else if(pCandidate->GetDetector() == "PHOS"  && reader->GetAODPHOSNormalInputEntries()  <= ipr) input = 1;
208       
209       //Get Momentum vector, 
210       //if     (input == 0) 
211       calo->GetMomentum(mom,reader->GetVertex(evtIndex)) ;//Assume that come from vertex in straight line
212       //else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line  
213       
214       pt   = mom.Pt();
215       eta  = mom.Eta();
216       phi  = mom.Phi() ;
217       if(phi<0) phi+=TMath::TwoPi();
218       //only loop the particle at the same side of candidate
219       
220       if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
221       //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events
222       if(pt > ptC){
223         n         = -1;
224         nfrac     = -1;
225         coneptsum = -1;
226         isolated  = kFALSE;
227         leading = kFALSE;
228         if(bFillAOD){
229           if(reftracks){  
230             reftracks  ->Clear();
231             delete reftracks;
232           }
233           if(refclusters){
234             refclusters->Clear(); 
235             delete refclusters;
236           }
237         }
238         return ;
239       }
240       
241       //Check if there is any particle inside cone with pt larger than  fPtThreshold
242       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
243       if(rad < fConeSize){
244         if(bFillAOD) {
245           nclusterrefs++;
246           if(nclusterrefs==1){
247             refclusters = new TObjArray(0);
248             //refclusters->SetName(Form("Clusters%s",aodArrayRefName.Data()));
249             TString tempo(aodArrayRefName)  ; 
250             tempo += "Clusters" ; 
251             refclusters->SetName(tempo);
252             refclusters->SetOwner(kFALSE);
253           }
254           refclusters->Add(calo);
255         }
256         //printf("neutral in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
257         coneptsum+=pt;
258         if(pt > fPtThreshold )     n++;
259         //if fPtFraction*ptC<fPtThreshold then consider the fPtThreshold directly
260         if(fPtFraction*ptC<fPtThreshold) {
261             if(pt>fPtThreshold)    nfrac++ ;
262         }
263         else {
264             if(pt>fPtFraction*ptC) nfrac++; 
265         }
266       }//in cone
267     }// neutral particle loop
268   }//neutrals
269
270   //printf("Isolation Cut: in cone with: pT>pTthres %d, pT > pTfrac*pTcandidate %d \n",n,nfrac);
271   
272   //Add reference arrays to AOD when filling AODs only
273   if(bFillAOD) {
274     if(refclusters)     pCandidate->AddObjArray(refclusters);
275     if(reftracks)         pCandidate->AddObjArray(reftracks);
276   }
277   //Check isolation, depending on method.
278   if( fICMethod == kPtThresIC){
279     if(n==0) isolated = kTRUE ;
280   }
281   else if( fICMethod == kSumPtIC){
282     if(coneptsum < fSumPtThreshold)
283       isolated  =  kTRUE ;
284   }
285   else if( fICMethod == kPtFracIC){
286     if(nfrac==0) isolated = kTRUE ;
287   }
288   else if( fICMethod == kSumPtFracIC){
289     //when the fPtFraction*ptC < fSumPtThreshold then consider the later case
290     if(fPtFraction*ptC < fSumPtThreshold  && coneptsum < fSumPtThreshold) isolated  =  kTRUE ;
291     if(fPtFraction*ptC > fSumPtThreshold  && coneptsum < fPtFraction*ptC) isolated  =  kTRUE ;
292   }
293   
294 }
295
296 //__________________________________________________________________
297 void AliIsolationCut::Print(const Option_t * opt) const
298 {
299   
300   //Print some relevant parameters set for the analysis
301   if(! opt)
302     return;
303   
304   printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;
305   
306   printf("IC method          =     %d\n", fICMethod) ; 
307   printf("Cone Size          =     %1.2f\n", fConeSize) ; 
308   printf("pT threshold       =     %2.1f\n", fPtThreshold) ;
309   printf("pT fraction        =     %3.1f\n", fPtFraction) ;
310   printf("particle type in cone =  %d\n",fPartInCone);
311   printf("    \n") ;
312   
313