]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliIsolationCut.cxx
1)AliCaloPID: Posibility to recalculate PID bayesian in EMCAL
[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 "AliAODCaloCluster.h"
38
39 ClassImp(AliIsolationCut)
40   
41 //____________________________________________________________________________
42   AliIsolationCut::AliIsolationCut() : 
43     TObject(),
44     fConeSize(0.),fPtThreshold(0.), fPtFraction(0.), fICMethod(0)
45  
46 {
47   //default ctor
48   
49   //Initialize parameters
50   InitParameters();
51
52 }
53
54 //____________________________________________________________________________
55 AliIsolationCut::AliIsolationCut(const AliIsolationCut & g) : 
56   TObject(g),
57   fConeSize(g.fConeSize),
58   fPtThreshold(g.fPtThreshold),
59   fPtFraction(g.fPtFraction), 
60   fICMethod(g.fICMethod)
61 {
62   // cpy ctor
63   
64 }
65
66 //_________________________________________________________________________
67 AliIsolationCut & AliIsolationCut::operator = (const AliIsolationCut & source)
68 {
69   // assignment operator
70   
71   if(&source == this) return *this;
72   
73   fConeSize = source.fConeSize ;
74   fPtThreshold = source.fPtThreshold ; 
75   fICMethod = source.fICMethod ;
76   fPtFraction = source.fPtFraction ;
77
78   return *this;
79   
80 }
81
82 //____________________________________________________________________________
83 TString AliIsolationCut::GetICParametersList()
84 {
85   //Put data member values in string to keep in output container
86   
87   TString parList ; //this will be list of parameters used for this analysis.
88   char onePar[255] ;
89   
90   sprintf(onePar,"--- AliIsolationCut ---\n") ;
91   parList+=onePar ;     
92   sprintf(onePar,"fConeSize: (isolation cone size) %1.2f\n",fConeSize) ;
93   parList+=onePar ;
94   sprintf(onePar,"fPtThreshold =%1.2f (isolation pt threshold) \n",fPtThreshold) ;
95   parList+=onePar ;
96   sprintf(onePar,"fPtFraction=%1.2f (isolation pt threshold fraction ) \n",fPtFraction) ;
97   parList+=onePar ;
98   sprintf(onePar,"fICMethod=%d (isolation cut case) \n",fICMethod) ;
99   parList+=onePar ;
100   
101   return parList; 
102 }
103
104 //____________________________________________________________________________
105 void AliIsolationCut::InitParameters()
106 {
107   //Initialize the parameters of the analysis.
108   
109   fConeSize             = 0.4 ; 
110   fPtThreshold         = 1. ; 
111   fPtFraction        = 0.1 ; 
112   
113   fICMethod = kPtThresIC; // 0 pt threshol method, 1 cone pt sum method
114   
115 }
116
117 //__________________________________________________________________
118 void  AliIsolationCut::MakeIsolationCut(TObjArray * plCTS,  TObjArray * plNe, Double_t * vertex, 
119                                         const Bool_t fillAOD, AliAODPWG4ParticleCorrelation  *pCandidate, 
120                                         const TString aodArrayRefName,
121                                         Int_t & n, Int_t & nfrac, Float_t &coneptsum,  Bool_t  &isolated) const
122 {  
123   //Search in cone around a candidate particle if it is isolated 
124   Float_t phiC  = pCandidate->Phi() ;
125   Float_t etaC = pCandidate->Eta() ;
126   Float_t ptC = pCandidate->Pt() ;
127   Float_t pt     = -100. ;
128   Float_t eta   = -100.  ;
129   Float_t phi    = -100.  ;
130   Float_t rad   = -100 ;
131   n = 0 ;
132   coneptsum = 0.; 
133   isolated = kFALSE;
134
135   //Initialize the array with refrences
136   TObjArray * refclusters = 0x0;
137   TObjArray * reftracks    =0x0;
138
139   if(fillAOD) {
140     refclusters = new TObjArray;
141     reftracks    = new TObjArray;
142   }
143
144   //Check charged particles in cone.
145   if(plCTS){
146     TVector3 p3;
147     for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ ){
148       AliAODTrack* track = (AliAODTrack *)(plCTS->At(ipr)) ; 
149       //Do not count the candidate (pion, conversion photon) or the daughters of the candidate
150       if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1)) continue ;
151       p3.SetXYZ(track->Px(),track->Py(),track->Pz());
152       pt   = p3.Pt();
153       eta  = p3.Eta();
154       phi  = p3.Phi() ;
155       if(phi<0) phi+=TMath::TwoPi();
156       
157       //Check if there is any particle inside cone with pt larger than  fPtThreshold
158       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
159       
160       if(rad < fConeSize){
161         if(fillAOD) {
162           reftracks->Add(track);
163         }
164         //printf("charged in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
165         coneptsum+=pt;
166         if(pt > fPtThreshold ) n++;
167         if(pt > fPtFraction*ptC ) nfrac++;  
168       }
169     }// charged particle loop
170   }//Tracks
171   
172   //Check neutral particles in cone.  
173   if(plNe){
174     TLorentzVector mom ;
175     for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){
176       AliAODCaloCluster * calo = (AliAODCaloCluster *)(plNe->At(ipr)) ;
177       
178       //Do not count the candidate (photon or pi0) or the daughters of the candidate
179       if(calo->GetID() == pCandidate->GetCaloLabel(0) || calo->GetID() == pCandidate->GetCaloLabel(1)) continue ;      //Skip matched clusters with tracks
180       
181       if(calo->GetNTracksMatched() > 0) continue ; 
182       
183       calo->GetMomentum(mom,vertex);//Assume that come from vertex in straight line
184       pt   = mom.Pt();
185       eta  = mom.Eta();
186       phi  = mom.Phi() ;
187       if(phi<0) phi+=TMath::TwoPi();
188       
189       //Check if there is any particle inside cone with pt larger than  fPtThreshold
190       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
191       if(rad < fConeSize){
192         if(fillAOD) {
193           refclusters->Add(calo);
194         }
195         //printf("neutral in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
196         coneptsum+=pt;
197         if(pt > fPtThreshold ) n++;
198         if(pt > fPtFraction*ptC ) nfrac++;
199       }//in cone
200     }// neutral particle loop
201   }//neutrals
202   
203   //printf("Isolation Cut: in cone with: pT>pTthres %d, pT > pTfrac*pTcandidate %d \n",n,nfrac);
204   
205   //Add reference arrays to AOD when filling AODs only
206   if(fillAOD) {
207         if(refclusters->GetEntriesFast() > 0){ 
208                 refclusters->SetName(aodArrayRefName+"Clusters");
209                 pCandidate->AddObjArray(refclusters);
210         }
211         if(reftracks->GetEntriesFast()   > 0){
212                 reftracks->SetName(aodArrayRefName+"Tracks");
213                 pCandidate->AddObjArray(reftracks);
214         } 
215   }
216
217   //Check isolation, depending on method.
218   if( fICMethod == kPtThresIC){
219     if(n==0) isolated = kTRUE ;
220   }
221   else if( fICMethod == kSumPtIC){
222     if(coneptsum < fPtThreshold)
223       isolated  =  kTRUE ;
224   }
225   else if( fICMethod == kPtFracIC){
226     if(nfrac==0) isolated = kTRUE ;
227   }
228   else if( fICMethod == kSumPtFracIC){
229     if(coneptsum < fPtFraction*ptC)
230       isolated  =  kTRUE ;
231   }
232 }
233
234 //__________________________________________________________________
235 void AliIsolationCut::Print(const Option_t * opt) const
236 {
237   
238   //Print some relevant parameters set for the analysis
239   if(! opt)
240     return;
241   
242   printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;
243   
244   printf("IC method          =     %d\n", fICMethod) ; 
245   printf("Cone Size          =     %1.2f\n", fConeSize) ; 
246   printf("pT threshold       =     %2.1f\n", fPtThreshold) ;
247   printf("pT fraction        =     %3.1f\n", fPtFraction) ;
248
249   printf("    \n") ;
250   
251