ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/IsolationTools.cc
Revision: 1.2
Committed: Tue Feb 17 06:49:28 2009 UTC (16 years, 2 months ago) by phedex
Content type: text/plain
Branch: MAIN
Changes since 1.1: +8 -16 lines
Log Message:
fix a memory leak in the track iso and ecal iso

File Contents

# User Rev Content
1 phedex 1.2 // $Id: IsolationTools.cc,v 1.1 2008/10/15 06:02:05 loizides Exp $
2 loizides 1.1
3     #include "MitPhysics/Utils/interface/IsolationTools.h"
4     #include "MitCommon/MathTools/interface/MathUtils.h"
5    
6     using namespace mithep;
7    
8     //--------------------------------------------------------------------------------------------------
9     Double_t IsolationTools::TrackIsolation(const Track *p, Double_t extRadius, Double_t intRadius,
10     Double_t ptLow, Double_t maxVtxZDist,
11 phedex 1.2 const Collection<Track> *tracks)
12 loizides 1.1 {
13     //Computes the Track Isolation: Summed Transverse Momentum of all tracks inside an
14     //annulus around the electron seed track.
15    
16     Double_t ptSum =0.;
17     for (UInt_t i=0; i<tracks->GetEntries();i++) {
18     Double_t tmpPt = tracks->At(i)->Pt();
19     Double_t deltaZ = fabs(p->Z0() - tracks->At(i)->Z0());
20    
21     //ignore the track if it is below the pt threshold
22     if (tmpPt < ptLow)
23     continue;
24     //ingore the track if it is too far away in Z
25     if (deltaZ > maxVtxZDist)
26     continue;
27    
28 phedex 1.2 Double_t dr = MathUtils::DeltaR(p->Phi(),p->Eta(),tracks->At(i)->Phi(), tracks->At(i)->Eta());
29 loizides 1.1 //add the track pt if it is inside the annulus
30     if ( dr < extRadius &&
31     dr >= intRadius ) {
32     ptSum += tmpPt;
33     }
34     }
35     return ptSum;
36     }
37    
38     //--------------------------------------------------------------------------------------------------
39     Double_t IsolationTools::EcalIsolation(const SuperCluster *sc, Double_t coneSize, Double_t etLow,
40 phedex 1.2 const Collection<BasicCluster> *basicClusters)
41 loizides 1.1 {
42     //Computes the Ecal Isolation: Summed Transverse Energy of all Basic Clusters inside a
43     //cone around the electron, excluding those that are inside the electron super cluster.
44    
45     Double_t ecalIsol=0.;
46     const BasicCluster *basicCluster= 0;
47     for (UInt_t i=0; i<basicClusters->GetEntries();i++) {
48     basicCluster = basicClusters->At(i);
49     Double_t basicClusterChi2 = basicCluster->ChiSq();
50     Double_t basicClusterEnergy = basicCluster->Energy();
51     Double_t basicClusterEta = basicCluster->Eta();
52     Double_t basicClusterEt = basicClusterEnergy*sin(2*atan(exp(basicClusterEta)));
53    
54     if (basicClusterEt > etLow && basicClusterChi2 < 30. && basicCluster->AlgoId()==0) {
55     bool inSuperCluster = false;
56    
57     // loop over the basic clusters of the supercluster
58     // to make sure that the basic cluster is not inside
59     // the super cluster. We exclude those.
60     for (UInt_t j=0; j<sc->ClusterSize(); j++) {
61     const BasicCluster *tempBasicClusterInSuperCluster = sc->Cluster(j);
62     if (tempBasicClusterInSuperCluster == basicCluster) {
63     inSuperCluster = true;
64     }
65     }
66    
67     if (!inSuperCluster) {
68 phedex 1.2 Double_t dr = MathUtils::DeltaR(sc->Phi(), sc->Eta(),
69     basicCluster->Phi(),basicCluster->Eta());
70 loizides 1.1 if(dr < coneSize) {
71     ecalIsol += basicClusterEt;
72     }
73     }
74     }
75     }
76     return ecalIsol;
77     }
78    
79     //--------------------------------------------------------------------------------------------------
80     Double_t IsolationTools::CaloTowerHadIsolation(const ThreeVector *p, Double_t extRadius,
81     Double_t intRadius, Double_t etLow,
82 phedex 1.2 const Collection<CaloTower> *caloTowers)
83 loizides 1.1 {
84     //Computes the CaloTower Had Et Isolation: Summed Hadronic Transverse Energy of all Calo Towers
85     //inside an annulus around the electron super cluster position.
86    
87     Double_t sumEt = 0;
88     for (UInt_t i=0; i<caloTowers->GetEntries();i++) {
89     Double_t caloTowerEt = caloTowers->At(i)->HadEt();
90     Double_t dr = MathUtils::DeltaR(caloTowers->At(i)->Phi(), caloTowers->At(i)->Eta(),
91     p->Phi(), p->Eta());
92     if (dr < extRadius && dr > intRadius && caloTowerEt > etLow) {
93     sumEt += caloTowerEt;
94     }
95     }
96     return sumEt;
97     }
98    
99     //--------------------------------------------------------------------------------------------------
100     Double_t IsolationTools::CaloTowerEmIsolation(const ThreeVector *p, Double_t extRadius,
101     Double_t intRadius, Double_t etLow,
102 phedex 1.2 const Collection<CaloTower> *caloTowers)
103 loizides 1.1 {
104     //Computes the CaloTower Em Et Isolation: Summed Hadronic Transverse Energy of all Calo Towers
105     //inside an annulus around the electron super cluster position.
106    
107     Double_t sumEt = 0;
108     for (UInt_t i=0; i<caloTowers->GetEntries();i++) {
109     Double_t caloTowerEt = caloTowers->At(i)->EmEt();
110     Double_t dr = MathUtils::DeltaR(caloTowers->At(i)->Phi(), caloTowers->At(i)->Eta(),
111     p->Phi(), p->Eta());
112     if (dr < extRadius && dr > intRadius && caloTowerEt > etLow) {
113     sumEt += caloTowerEt;
114     }
115     }
116     return sumEt;
117     }