ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/src/Electron.cc
Revision: 1.2
Committed: Fri Aug 8 11:17:13 2008 UTC (16 years, 9 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: MITHEP_2_0_x
Changes since 1.1: +86 -1 lines
Log Message:
Add object ID variables into the Electron and Muons. Add functions to compute track and ecal isolation to electrons

File Contents

# Content
1 // $Id: $
2
3 #include "MitAna/DataTree/interface/Electron.h"
4
5 Double_t mithep::Electron::ComputeTrackIsolation( Double_t extRadius, Double_t intRadius,
6 Double_t ptLow, Double_t maxVtxZDist, Collection<Track> *tracks) {
7
8 //Computes the Track Isolation: Summed Transverse Momentum of all tracks inside an
9 //annulus around the electron seed track.
10
11 int counter;
12 double ptSum =0.;
13
14 const Track *electronTrack = this->Trk() ;
15 ThreeVector *electronTrackMomentum = new ThreeVector(electronTrack->Mom().X(),electronTrack->Mom().Y(),electronTrack->Mom().Z());
16
17 for (UInt_t i=0; i<tracks->GetEntries();i++) {
18 ThreeVector *tmpTrackMomentum = new ThreeVector(tracks->At(i)->Mom().X(),tracks->At(i)->Mom().Y(),tracks->At(i)->Mom().Z());
19 double tmpPt = tracks->At(i)->Pt();
20 double deltaZ = fabs(electronTrack->Z0() - tracks->At(i)->Z0());
21
22 //ignore the track if it is below the pt threshold
23 if (tmpPt < ptLow)
24 continue;
25 //ingore the track if it is too far away in Z
26 if (deltaZ > maxVtxZDist)
27 continue;
28
29 double dphi = (fabs(tmpTrackMomentum->Phi() - electronTrackMomentum->Phi()) > TMath::Pi())?(fabs(tmpTrackMomentum->Phi() - electronTrackMomentum->Phi()) - 2*TMath::Pi()):(fabs(tmpTrackMomentum->Phi() - electronTrackMomentum->Phi()));
30 double deta = fabs(tmpTrackMomentum->Eta() - electronTrackMomentum->Eta());
31 double dr = TMath::Sqrt(dphi*dphi + deta*deta);
32
33 //add the track pt if it is inside the annulus
34 if ( dr < extRadius &&
35 dr >= intRadius ) {
36 ++counter ;
37 ptSum += tmpPt;
38 }
39 }
40 return ptSum;
41 }
42
43 Double_t mithep::Electron::ComputeEcalIsolation( Double_t coneSize, Double_t etLow, Collection<BasicCluster> *basicClusters) {
44
45 //Computes the Ecal Isolation: Summed Transverse Energy of all Basic Clusters inside a
46 //cone around the electron, excluding those that are inside the electron super cluster.
47
48 double ecalIsol=0.;
49 ThreeVector *SClusterPosition = new ThreeVector (this->SCluster()->X(),this->SCluster()->Y(),this->SCluster()->Z());
50
51 const BasicCluster *basicCluster= 0;
52 for (UInt_t i=0; i<basicClusters->GetEntries();i++) {
53 basicCluster = basicClusters->At(i);
54 double basicClusterChi2 = basicCluster->ChiSq();
55 double basicClusterEnergy = basicCluster->Energy();
56 double basicClusterEta = basicCluster->Eta();
57 double basicClusterEt = basicClusterEnergy*sin(2*atan(exp(basicClusterEta)));
58
59 if (basicClusterEt > etLow && basicClusterChi2 < 30.) {
60 bool inSuperCluster = false;
61
62 // loop over the basic clusters of the supercluster
63 // to make sure that the basic cluster is not inside
64 // the super cluster. We exclude those.
65 for (UInt_t j=0; j<this->SCluster()->ClusterSize(); j++) {
66 const BasicCluster *tempBasicClusterInSuperCluster = this->SCluster()->Cluster(j);
67 if (tempBasicClusterInSuperCluster == basicCluster) {
68 inSuperCluster = true;
69 }
70 }
71
72 if (!inSuperCluster) {
73 ThreeVector *basicClusterPosition = new ThreeVector(basicCluster->X(),
74 basicCluster->Y(),
75 basicCluster->Z());
76 double dphi = (fabs(SClusterPosition->Phi() - basicClusterPosition->Phi()) > TMath::Pi())?(fabs(SClusterPosition->Phi() - basicClusterPosition->Phi()) - 2*TMath::Pi()):(fabs(SClusterPosition->Phi() - basicClusterPosition->Phi()));
77 double deta = fabs(SClusterPosition->Eta() - basicClusterPosition->Eta());
78 double dr = TMath::Sqrt(dphi*dphi + deta*deta);
79 if(dr < coneSize) {
80 ecalIsol += basicClusterEt;
81 }
82 }
83 }
84 }
85 return ecalIsol;
86 }
87
88 ClassImp(mithep::Electron)
89
90