]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/AliIsolationCut.cxx
Macro that generates Zero MisAlignment in ACORDE Geometry
[u/mrichter/AliRoot.git] / PWG4 / 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 /* History of cvs commits:
18  *
19  * $Log$
20
21  *
22  *
23  */
24
25 //_________________________________________________________________________
26 // Class containing methods for the isolation cut. 
27 //
28 //
29 //*-- Author: Gustavo Conesa (LNF-INFN) 
30 //////////////////////////////////////////////////////////////////////////////
31   
32   
33 // --- ROOT system --- 
34 #include <Riostream.h>
35 #include <TLorentzVector.h>
36 #include <TSeqCollection.h>
37
38 // --- AliRoot system --- 
39 #include "AliIsolationCut.h" 
40 #include "AliLog.h"
41 #include "AliAODParticleCorrelation.h"
42 #include "AliAODTrack.h"
43 #include "AliAODCaloCluster.h"
44
45 ClassImp(AliIsolationCut)
46   
47 //____________________________________________________________________________
48   AliIsolationCut::AliIsolationCut() : 
49     TObject(),
50     fConeSize(0.),fPtThreshold(0.), fPtFraction(0.), fICMethod(0)
51  
52 {
53   //default ctor
54   
55   //Initialize parameters
56   InitParameters();
57
58 }
59
60 //____________________________________________________________________________
61 AliIsolationCut::AliIsolationCut(const AliIsolationCut & g) : 
62   TObject(g),
63   fConeSize(g.fConeSize),
64   fPtThreshold(g.fPtThreshold),
65   fPtFraction(g.fPtFraction), 
66   fICMethod(g.fICMethod)
67 {
68   // cpy ctor
69
70 }
71
72 //_________________________________________________________________________
73 AliIsolationCut & AliIsolationCut::operator = (const AliIsolationCut & source)
74 {
75   // assignment operator
76   
77   if(&source == this) return *this;
78    
79   fConeSize = source.fConeSize ;
80   fPtThreshold = source.fPtThreshold ; 
81   fICMethod = source.fICMethod ;
82   fPtFraction = source.fPtFraction ;
83
84   return *this;
85   
86 }
87
88
89
90
91   //____________________________________________________________________________
92 void AliIsolationCut::InitParameters()
93 {
94   //Initialize the parameters of the analysis.
95
96   fConeSize             = 0.4 ; 
97   fPtThreshold         = 1. ; 
98   fPtFraction        = 0.1 ; 
99
100   fICMethod = kPtThresIC; // 0 pt threshol method, 1 cone pt sum method
101
102 }
103
104 //__________________________________________________________________
105 void  AliIsolationCut::MakeIsolationCut(TSeqCollection * plCTS,  TSeqCollection * plNe, Double_t * vertex, 
106                                         const Bool_t fillAOD, AliAODParticleCorrelation  *pCandidate, 
107                                         const Int_t index1,  const Int_t index2, 
108                                         Int_t & n, Int_t & nfrac, Float_t &coneptsum,  Bool_t  &isolated) 
109 {  
110   //Search in cone around a candidate particle if it is isolated 
111   Float_t phiC  = pCandidate->Phi() ;
112   Float_t etaC = pCandidate->Eta() ;
113   Float_t ptC = pCandidate->Pt() ;
114   Float_t pt     = -100. ;
115   Float_t eta   = -100.  ;
116   Float_t phi    = -100.  ;
117   Float_t rad   = -100 ;
118
119   n = 0 ;
120   coneptsum = 0.; 
121   isolated = kFALSE;
122
123   //Check charged particles in cone.
124   if(plCTS){
125     TVector3 p3;
126     for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ ){
127       if(ipr == index1  || ipr == index2) continue ;//Do not count the candidate
128       AliAODTrack* track = dynamic_cast<AliAODTrack *>(plCTS->At(ipr)) ; 
129       p3.SetXYZ(track->Px(),track->Py(),track->Pz());
130       pt    = p3.Pt();
131       eta  = p3.Eta();
132       phi  = p3.Phi() ;
133       if(phi<0) phi+=TMath::TwoPi();
134       
135       //Check if there is any particle inside cone with pt larger than  fPtThreshold
136       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
137       
138       if(rad < fConeSize){
139         if(fillAOD) pCandidate->AddIsolationConeTrack(track);
140         //printf("charged in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
141         coneptsum+=pt;
142         if(pt > fPtThreshold ) n++;
143         if(pt > fPtFraction*ptC ) nfrac++;  
144       }
145     }// charged particle loop
146   }//Tracks
147
148   //Check neutral particles in cone.  
149   if(plNe){
150     TLorentzVector mom ;
151     for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){
152       if(ipr == index1  || ipr == index2) continue ;//Do not count the candidate
153       AliAODCaloCluster * calo = dynamic_cast< AliAODCaloCluster *>(plNe->At(ipr)) ;
154
155       //Skip matched clusters with tracks
156       if(calo->GetNTracksMatched() > 0) continue ; 
157       
158       calo->GetMomentum(mom,vertex);//Assume that come from vertex in straight line
159       pt    = mom.Pt();
160       eta  = mom.Eta();
161       phi  = mom.Phi() ;
162       if(phi<0) phi+=TMath::TwoPi();
163       
164       //Check if there is any particle inside cone with pt larger than  fPtThreshold
165       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
166       if(rad < fConeSize){
167         if(fillAOD) pCandidate->AddIsolationConeCluster(calo);
168         //printf("neutral in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
169         coneptsum+=pt;
170         if(pt > fPtThreshold ) n++;
171         if(pt > fPtFraction*ptC ) nfrac++;
172       }//in cone
173     }// neutral particle loop
174   }//neutrals
175
176   //printf("Isolation Cut: in cone with: pT>pTthres %d, pT > pTfrac*pTcandidate %d \n",n,nfrac);
177
178   //Check isolation, depending on method.
179   if( fICMethod == kPtThresIC){
180     if(n==0) isolated = kTRUE ;
181   }
182   else if( fICMethod == kSumPtIC){
183     if(coneptsum < fPtThreshold)
184       isolated  =  kTRUE ;
185   }
186   else if( fICMethod == kPtFracIC){
187     if(nfrac==0) isolated = kTRUE ;
188   }
189   else if( fICMethod == kSumPtFracIC){
190     if(coneptsum < fPtFraction*ptC)
191       isolated  =  kTRUE ;
192   }
193 }
194
195 //__________________________________________________________________
196 void AliIsolationCut::Print(const Option_t * opt) const
197 {
198   
199   //Print some relevant parameters set for the analysis
200   if(! opt)
201     return;
202   
203   printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;
204   
205   printf("IC method          =     %d\n", fICMethod) ; 
206   printf("Cone Size          =     %1.2f\n", fConeSize) ; 
207   printf("pT threshold       =     %2.1f\n", fPtThreshold) ;
208   printf("pT fraction        =     %3.1f\n", fPtFraction) ;
209
210   printf("    \n") ;
211   
212