ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerElectrons.cc
Revision: 1.11
Committed: Fri Aug 8 11:21:08 2008 UTC (16 years, 8 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: MITHEP_2_0_x
Changes since 1.10: +126 -12 lines
Log Message:
Add SuperCluster links to electron Filler. Add basic cluster and supercluster association maps. Add new electron and Muon ID variables. Add correct default names to the config file. BuildFile had to be modified to include Egamma objects for the electron Fillers.

File Contents

# User Rev Content
1 sixie 1.11 // $Id: FillerElectrons.cc,v 1.10 2008/07/31 12:34:04 loizides Exp $
2 loizides 1.1
3     #include "MitProd/TreeFiller/interface/FillerElectrons.h"
4     #include "FWCore/MessageLogger/interface/MessageLogger.h"
5     #include "DataFormats/Common/interface/Handle.h"
6     #include "DataFormats/TrackReco/interface/Track.h"
7     #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
8     #include "DataFormats/TrackReco/interface/TrackFwd.h"
9 sixie 1.11 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
10     #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
11     #include "DataFormats/EgammaReco/interface/ClusterShape.h"
12     #include "DataFormats/EgammaReco/interface/BasicClusterShapeAssociation.h"
13     #include "RecoEgamma/EgammaIsolationAlgos/interface/ElectronTkIsolation.h"
14     #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaEcalIsolation.h"
15 loizides 1.1 #include "MitAna/DataTree/interface/Track.h"
16     #include "MitAna/DataTree/interface/Names.h"
17    
18     using namespace std;
19     using namespace edm;
20     using namespace mithep;
21    
22 loizides 1.5 //--------------------------------------------------------------------------------------------------
23 loizides 1.10 FillerElectrons::FillerElectrons(const edm::ParameterSet &cfg, bool active) :
24 loizides 1.8 BaseFiller(cfg,"Electrons",active),
25 loizides 1.1 edmName_(Conf().getUntrackedParameter<string>("edmName","pixelMatchGsfElectrons")),
26     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkElectronBrn)),
27 loizides 1.10 gsfTrackMapName_(Conf().getUntrackedParameter<string>("gsfTrackMapName","")),
28     trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
29 sixie 1.11 superClusterMapName_(Conf().getUntrackedParameter<string>("superClusterMapName", "")),
30 loizides 1.8 electrons_(new mithep::ElectronArr(16)),
31 sixie 1.11
32 loizides 1.10 gsfTrackMap_(0),
33 sixie 1.11 trackerTrackMap_(0),
34     superClusterMap_(0)
35 loizides 1.1 {
36     // Constructor.
37     }
38    
39 loizides 1.5 //--------------------------------------------------------------------------------------------------
40 loizides 1.1 FillerElectrons::~FillerElectrons()
41     {
42     // Destructor.
43 loizides 1.6
44     delete electrons_;
45 loizides 1.1 }
46    
47 loizides 1.5 //--------------------------------------------------------------------------------------------------
48 loizides 1.1 void FillerElectrons::BookDataBlock(TreeWriter &tws)
49     {
50 loizides 1.10 // Add electron branch to our tree and get our maps.
51 loizides 1.1
52     tws.AddBranch(mitName_.c_str(),&electrons_);
53 loizides 1.10
54     if (!gsfTrackMapName_.empty())
55     gsfTrackMap_ = OS()->get<GsfTrackMap>(gsfTrackMapName_.c_str());
56     if (!trackerTrackMapName_.empty())
57 sixie 1.11 trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_.c_str());
58     if (!superClusterMapName_.empty())
59     superClusterMap_ = OS()->get<SuperClusterMap>(superClusterMapName_.c_str());
60    
61 loizides 1.1 }
62    
63 loizides 1.5 //--------------------------------------------------------------------------------------------------
64 sixie 1.11 void FillerElectrons::FillDataBlock(const edm::Event &event, const edm::EventSetup &setup)
65 loizides 1.1 {
66     // Fill electrons from edm collection into our collection.
67    
68     electrons_->Reset();
69    
70 sixie 1.11 Handle<reco::GsfElectronCollection> hElectronProduct;
71 loizides 1.7 GetProduct(edmName_, hElectronProduct, event);
72 loizides 1.1
73 sixie 1.11 const reco::GsfElectronCollection inElectrons = *(hElectronProduct.product());
74    
75    
76     //get association of clusters to their shapes for EcalBarrel
77     edm::Handle<reco::BasicClusterShapeAssociationCollection> barrelClShpHandle ;
78     try {
79     event.getByLabel ("hybridSuperClusters","hybridShapeAssoc", barrelClShpHandle);
80     }
81     catch ( cms::Exception& ex ) {
82     printf("Can't get ECAL barrel Cluster Shape Collection\n");
83     }
84     const reco::BasicClusterShapeAssociationCollection& barrelClShpMap = *barrelClShpHandle ;
85 loizides 1.1
86 sixie 1.11 //get the association of the clusters to their shapes for EcalEndcap
87     edm::Handle<reco::BasicClusterShapeAssociationCollection> endcapClShpHandle ;
88     try {
89     event.getByLabel ("islandBasicClusters","islandEndcapShapeAssoc", endcapClShpHandle);
90     }
91     catch ( cms::Exception& ex ) {
92     printf("Can't get ECAL endcap Cluster Shape Collection\n");
93     }
94     const reco::BasicClusterShapeAssociationCollection& endcapClShpMap = *endcapClShpHandle ;
95    
96     //loop over electrons
97     for (reco::GsfElectronCollection::const_iterator iM = inElectrons.begin();
98 loizides 1.1 iM != inElectrons.end(); ++iM) {
99 loizides 1.8 mithep::Electron *outElectron = electrons_->AddNew();
100 sixie 1.11
101     outElectron->SetESuperClusterOverP( iM->eSuperClusterOverP() ) ;
102     outElectron->SetESeedClusterOverPout( iM->eSeedClusterOverPout() ) ;
103     outElectron->SetDeltaEtaSuperClusterTrackAtVtx( iM->deltaEtaSuperClusterTrackAtVtx() ) ;
104     outElectron->SetDeltaEtaSeedClusterTrackAtCalo( iM->deltaEtaSeedClusterTrackAtCalo() ) ;
105     outElectron->SetDeltaPhiSuperClusterTrackAtVtx( iM->deltaPhiSuperClusterTrackAtVtx() ) ;
106     outElectron->SetDeltaPhiSeedClusterTrackAtCalo( iM->deltaPhiSeedClusterTrackAtCalo() ) ;
107     outElectron->SetHadronicOverEm( iM->hadronicOverEm() ) ;
108     outElectron->SetIsEnergyScaleCorrected( iM->isEnergyScaleCorrected() ) ;
109     outElectron->SetIsMomentumCorrected( iM->isMomentumCorrected() ) ;
110     outElectron->SetNumberOfClusters( iM->numberOfClusters() ) ;
111     outElectron->SetClassification( iM->classification() ) ;
112     outElectron->SetSuperClusterPx( iM->px() );
113     outElectron->SetSuperClusterPy( iM->py() );
114     outElectron->SetSuperClusterPz( iM->pz() );
115     outElectron->SetSuperClusterE( iM->energy() );
116    
117     //initialize
118     outElectron->SetE33( -999.0 ) ;
119     outElectron->SetE55( -999.0 ) ;
120     outElectron->SetCovEtaEta( -999.0 ) ;
121     outElectron->SetCovEtaPhi( -999.0 ) ;
122     outElectron->SetCovPhiPhi( -999.0 ) ;
123     bool hasBarrel=true ;
124     bool hasEndcap=true ;
125    
126     reco::SuperClusterRef sclusRef = iM->get<reco::SuperClusterRef> () ;
127     reco::BasicClusterShapeAssociationCollection::const_iterator seedShpItr ;
128     //find the cluster shape object associated with the electron supercluster
129     seedShpItr = barrelClShpMap.find (sclusRef->seed()) ;
130     if ( seedShpItr==barrelClShpMap.end()) {
131     hasBarrel=false ;
132     seedShpItr=endcapClShpMap.find (sclusRef->seed()) ;
133     if ( seedShpItr==endcapClShpMap.end() ) hasEndcap=false;
134     }
135     if (hasBarrel || hasEndcap) {
136     //fill shape variables
137     const reco::ClusterShapeRef& sClShape = seedShpItr->val;
138     outElectron->SetE33 (sClShape->e3x3() );
139     outElectron->SetE55 (sClShape->e5x5() );
140     outElectron->SetCovEtaEta (sClShape->covEtaEta());
141     outElectron->SetCovEtaPhi (sClShape->covEtaPhi());
142     outElectron->SetCovPhiPhi (sClShape->covPhiPhi());
143     }
144    
145     //Compute Isolations
146     //Get the barrel basicClusters
147     edm::Handle<reco::BasicClusterCollection> barrelBasicClusterHandle;
148     event.getByLabel("hybridSuperClusters", barrelBasicClusterHandle);
149     const reco::BasicClusterCollection* barrelBasicClusters = barrelBasicClusterHandle.product();
150    
151     //Get the endcap basicClusters
152     edm::Handle<reco::BasicClusterCollection> endcapBasicClusterHandle;
153     event.getByLabel("islandBasicClusters", "islandEndcapBasicClusters", endcapBasicClusterHandle);
154     const reco::BasicClusterCollection* endcapBasicClusters = endcapBasicClusterHandle.product();
155    
156     //Get the superClusters
157     edm::Handle<reco::SuperClusterCollection> superClusterHandle;
158     event.getByLabel("hybridSuperClusters", superClusterHandle);
159     const reco::SuperClusterCollection* superClusters = superClusterHandle.product();
160    
161     //compute ECAL isolation
162     double extRadius = 0.3;
163     double etLow = 0.0;
164     EgammaEcalIsolation myEcalIsolation(extRadius,etLow,barrelBasicClusters,superClusters);
165     double ecalIsoValue = myEcalIsolation.getEcalEtSum(&(*iM));
166    
167     //Compute Track Isolation
168     edm::Handle<reco::TrackCollection> tracks;
169     event.getByLabel("generalTracks",tracks);
170     const reco::TrackCollection* trackCollection = tracks.product();
171     extRadius = 0.2;
172     double intRadius = 0.02;
173     double maxVtxDist = 0.1;
174     double ptMin = 1.5;
175     ElectronTkIsolation myTkIsolation (extRadius,intRadius,ptMin,maxVtxDist,trackCollection) ;
176     double trackIsoValue = myTkIsolation.getPtTracks(&(*iM));
177    
178     //Fill the isolation values
179     outElectron->SetCaloIsolation( ecalIsoValue ) ;
180     outElectron->SetTrackIsolation( trackIsoValue ) ;
181    
182     //Make proper links to Tracks and Super Clusters
183 loizides 1.1 if (gsfTrackMap_ && iM->gsfTrack().isNonnull())
184 loizides 1.9 outElectron->SetGsfTrk(gsfTrackMap_->GetMit(iM->gsfTrack()));
185 loizides 1.1 if (trackerTrackMap_ && iM->track().isNonnull())
186 loizides 1.9 outElectron->SetTrackerTrk(trackerTrackMap_->GetMit(iM->track()));
187 sixie 1.11 if (superClusterMap_ && iM->superCluster().isNonnull())
188     outElectron->SetSuperCluster(superClusterMap_->GetMit(iM->superCluster()));
189 loizides 1.1 }
190     electrons_->Trim();
191     }