ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/IsolationTools.cc
Revision: 1.5
Committed: Sat Feb 5 05:48:09 2011 UTC (14 years, 2 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.4: +99 -1 lines
Log Message:
isolation

File Contents

# User Rev Content
1 ceballos 1.5 // $Id: IsolationTools.cc,v 1.4 2009/07/20 04:55:33 loizides Exp $
2 loizides 1.1
3     #include "MitPhysics/Utils/interface/IsolationTools.h"
4     #include "MitCommon/MathTools/interface/MathUtils.h"
5    
6 loizides 1.4 ClassImp(mithep::IsolationTools)
7    
8 loizides 1.1 using namespace mithep;
9    
10     //--------------------------------------------------------------------------------------------------
11     Double_t IsolationTools::TrackIsolation(const Track *p, Double_t extRadius, Double_t intRadius,
12     Double_t ptLow, Double_t maxVtxZDist,
13 phedex 1.2 const Collection<Track> *tracks)
14 loizides 1.1 {
15     //Computes the Track Isolation: Summed Transverse Momentum of all tracks inside an
16     //annulus around the electron seed track.
17    
18     Double_t ptSum =0.;
19     for (UInt_t i=0; i<tracks->GetEntries();i++) {
20     Double_t tmpPt = tracks->At(i)->Pt();
21     Double_t deltaZ = fabs(p->Z0() - tracks->At(i)->Z0());
22    
23     //ignore the track if it is below the pt threshold
24     if (tmpPt < ptLow)
25     continue;
26     //ingore the track if it is too far away in Z
27     if (deltaZ > maxVtxZDist)
28     continue;
29    
30 phedex 1.2 Double_t dr = MathUtils::DeltaR(p->Phi(),p->Eta(),tracks->At(i)->Phi(), tracks->At(i)->Eta());
31 loizides 1.1 //add the track pt if it is inside the annulus
32     if ( dr < extRadius &&
33     dr >= intRadius ) {
34     ptSum += tmpPt;
35     }
36     }
37     return ptSum;
38     }
39    
40     //--------------------------------------------------------------------------------------------------
41     Double_t IsolationTools::EcalIsolation(const SuperCluster *sc, Double_t coneSize, Double_t etLow,
42 phedex 1.2 const Collection<BasicCluster> *basicClusters)
43 loizides 1.1 {
44     //Computes the Ecal Isolation: Summed Transverse Energy of all Basic Clusters inside a
45     //cone around the electron, excluding those that are inside the electron super cluster.
46    
47     Double_t ecalIsol=0.;
48     const BasicCluster *basicCluster= 0;
49     for (UInt_t i=0; i<basicClusters->GetEntries();i++) {
50     basicCluster = basicClusters->At(i);
51     Double_t basicClusterEnergy = basicCluster->Energy();
52     Double_t basicClusterEta = basicCluster->Eta();
53     Double_t basicClusterEt = basicClusterEnergy*sin(2*atan(exp(basicClusterEta)));
54    
55 bendavid 1.3 if (basicClusterEt > etLow) {
56 loizides 1.1 bool inSuperCluster = false;
57    
58     // loop over the basic clusters of the supercluster
59     // to make sure that the basic cluster is not inside
60     // the super cluster. We exclude those.
61     for (UInt_t j=0; j<sc->ClusterSize(); j++) {
62     const BasicCluster *tempBasicClusterInSuperCluster = sc->Cluster(j);
63     if (tempBasicClusterInSuperCluster == basicCluster) {
64     inSuperCluster = true;
65     }
66     }
67    
68     if (!inSuperCluster) {
69 phedex 1.2 Double_t dr = MathUtils::DeltaR(sc->Phi(), sc->Eta(),
70     basicCluster->Phi(),basicCluster->Eta());
71 loizides 1.1 if(dr < coneSize) {
72     ecalIsol += basicClusterEt;
73     }
74     }
75     }
76     }
77     return ecalIsol;
78     }
79    
80     //--------------------------------------------------------------------------------------------------
81     Double_t IsolationTools::CaloTowerHadIsolation(const ThreeVector *p, Double_t extRadius,
82     Double_t intRadius, Double_t etLow,
83 phedex 1.2 const Collection<CaloTower> *caloTowers)
84 loizides 1.1 {
85     //Computes the CaloTower Had Et Isolation: Summed Hadronic Transverse Energy of all Calo Towers
86     //inside an annulus around the electron super cluster position.
87    
88     Double_t sumEt = 0;
89     for (UInt_t i=0; i<caloTowers->GetEntries();i++) {
90     Double_t caloTowerEt = caloTowers->At(i)->HadEt();
91     Double_t dr = MathUtils::DeltaR(caloTowers->At(i)->Phi(), caloTowers->At(i)->Eta(),
92     p->Phi(), p->Eta());
93     if (dr < extRadius && dr > intRadius && caloTowerEt > etLow) {
94     sumEt += caloTowerEt;
95     }
96     }
97     return sumEt;
98     }
99    
100     //--------------------------------------------------------------------------------------------------
101     Double_t IsolationTools::CaloTowerEmIsolation(const ThreeVector *p, Double_t extRadius,
102     Double_t intRadius, Double_t etLow,
103 phedex 1.2 const Collection<CaloTower> *caloTowers)
104 loizides 1.1 {
105     //Computes the CaloTower Em Et Isolation: Summed Hadronic Transverse Energy of all Calo Towers
106     //inside an annulus around the electron super cluster position.
107    
108     Double_t sumEt = 0;
109     for (UInt_t i=0; i<caloTowers->GetEntries();i++) {
110     Double_t caloTowerEt = caloTowers->At(i)->EmEt();
111     Double_t dr = MathUtils::DeltaR(caloTowers->At(i)->Phi(), caloTowers->At(i)->Eta(),
112     p->Phi(), p->Eta());
113     if (dr < extRadius && dr > intRadius && caloTowerEt > etLow) {
114     sumEt += caloTowerEt;
115     }
116     }
117     return sumEt;
118     }
119 ceballos 1.5
120     //--------------------------------------------------------------------------------------------------
121     Double_t IsolationTools::PFMuonIsolation(const Muon *p, const Collection<PFCandidate> *PFCands,
122     const VertexCol *vertices, Double_t delta_z,
123     Double_t extRadius, Double_t intRadius, int isoType)
124     {
125     //Computes the PF Isolation: Summed Transverse Momentum of all PF candidates inside an
126     //annulus around the particle seed track.
127    
128     Double_t zLepton = 0.0;
129     if(p->BestTrk()) zLepton = p->BestTrk()->DzCorrected(*vertices->At(0));
130    
131     Double_t ptSum =0.;
132     for (UInt_t i=0; i<PFCands->GetEntries();i++) {
133     const PFCandidate *pf = PFCands->At(i);
134    
135     Bool_t isGoodType = kFALSE;
136     // all particles
137     if (isoType == 0) isGoodType = kTRUE;
138     // charged particles only
139     else if(isoType == 1 && pf->Charge() != 0) isGoodType = kTRUE;
140     // charged particles and gammas only
141     else if(isoType == 1 &&
142     (pf->Charge() != 0 || pf->PFType() == PFCandidate::eGamma)) isGoodType = kTRUE;
143    
144     if(isGoodType == kFALSE) continue;
145    
146     if(pf->TrackerTrk() && p->TrackerTrk() &&
147     pf->TrackerTrk() == p->TrackerTrk()) continue;
148    
149     Double_t deltaZ = 0.0;
150     if(pf->BestTrk()) {
151     deltaZ = TMath::Abs(pf->BestTrk()->DzCorrected(*vertices->At(0)) - zLepton);
152     }
153    
154     // ignore the pf candidate if it is too far away in Z
155     if (deltaZ > delta_z)
156     continue;
157    
158     Double_t dr = MathUtils::DeltaR(p->Mom(), pf->Mom());
159     // add the pf pt if it is inside the extRadius and outside the intRadius
160     if ( dr < extRadius &&
161     dr >= intRadius ) {
162     ptSum += pf->Pt();
163     }
164     }
165     return ptSum;
166     }
167     //--------------------------------------------------------------------------------------------------
168     Double_t IsolationTools::PFElectronIsolation(const Electron *p, const PFCandidateCol *PFCands,
169     const VertexCol *vertices, Double_t delta_z,
170     Double_t extRadius, Double_t intRadius, int isoType)
171     {
172     //Computes the PF Isolation: Summed Transverse Momentum of all PF candidates inside an
173     //annulus around the particle seed track.
174    
175     Double_t zLepton = 0.0;
176     if(p->BestTrk()) zLepton = p->BestTrk()->DzCorrected(*vertices->At(0));
177    
178     Double_t ptSum =0.;
179     for (UInt_t i=0; i<PFCands->GetEntries();i++) {
180     const PFCandidate *pf = PFCands->At(i);
181    
182     Bool_t isGoodType = kFALSE;
183     // all particles
184     if (isoType == 0) isGoodType = kTRUE;
185     // charged particles only
186     else if(isoType == 1 && pf->Charge() != 0) isGoodType = kTRUE;
187     // charged particles and gammas only
188     else if(isoType == 1 &&
189     (pf->Charge() != 0 || pf->PFType() == PFCandidate::eGamma)) isGoodType = kTRUE;
190    
191     if(isGoodType == kFALSE) continue;
192    
193     if(pf->TrackerTrk() && p->TrackerTrk() &&
194     pf->TrackerTrk() == p->TrackerTrk()) continue;
195    
196     if(pf->GsfTrk() && p->GsfTrk() &&
197     pf->GsfTrk() == p->GsfTrk()) continue;
198    
199     Double_t deltaZ = 0.0;
200     if(pf->BestTrk()) {
201     deltaZ = TMath::Abs(pf->BestTrk()->DzCorrected(*vertices->At(0)) - zLepton);
202     }
203    
204     // ignore the pf candidate if it is too far away in Z
205     if (deltaZ > delta_z)
206     continue;
207    
208     Double_t dr = MathUtils::DeltaR(p->Mom(), pf->Mom());
209     // add the pf pt if it is inside the extRadius and outside the intRadius
210     if ( dr < extRadius &&
211     dr >= intRadius ) {
212     ptSum += pf->Pt();
213     }
214     }
215     return ptSum;
216     }