ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPhotons.cc
Revision: 1.23
Committed: Sun May 15 14:11:47 2011 UTC (13 years, 11 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_021, Mit_021pre2
Changes since 1.22: +6 -1 lines
Log Message:
fill pf iso variables for electron and photon

File Contents

# User Rev Content
1 bendavid 1.23 // $Id: FillerPhotons.cc,v 1.22 2011/03/13 22:15:09 bendavid Exp $
2 bendavid 1.1
3 loizides 1.2 #include "MitProd/TreeFiller/interface/FillerPhotons.h"
4 bendavid 1.1 #include "DataFormats/TrackReco/interface/Track.h"
5     #include "DataFormats/TrackReco/interface/TrackFwd.h"
6     #include "DataFormats/EgammaCandidates/interface/Photon.h"
7     #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
8     #include "DataFormats/EgammaCandidates/interface/Conversion.h"
9     #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
10     #include "MitAna/DataTree/interface/Names.h"
11 loizides 1.14 #include "MitAna/DataTree/interface/PhotonCol.h"
12     #include "MitProd/ObjectService/interface/ObjectService.h"
13 bendavid 1.1
14     using namespace std;
15     using namespace edm;
16     using namespace mithep;
17    
18 loizides 1.2 //--------------------------------------------------------------------------------------------------
19 loizides 1.12 FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, const char *name, bool active) :
20     BaseFiller(cfg,name,active),
21 bendavid 1.1 edmName_(Conf().getUntrackedParameter<string>("edmName","photons")),
22     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
23 loizides 1.7 conversionMapName_(Conf().getUntrackedParameter<string>("conversionMapName","")),
24 bendavid 1.9 barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
25     endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
26 loizides 1.17 phIDCutBasedTightName_(Conf().getUntrackedParameter<string>("phIDCutBasedTightName",
27     "PhotonIDProd:PhotonCutBasedIDTight")),
28     phIDCutBasedLooseName_(Conf().getUntrackedParameter<string>("phIDCutBasedLooseName",
29     "PhotonIDProd:PhotonCutBasedIDLoose")),
30 loizides 1.5 photons_(new mithep::PhotonArr(16)),
31 bendavid 1.9 conversionMap_(0),
32     barrelSuperClusterMap_(0),
33     endcapSuperClusterMap_(0)
34 bendavid 1.1 {
35 loizides 1.2 // Constructor.
36 bendavid 1.1 }
37    
38 loizides 1.2 //--------------------------------------------------------------------------------------------------
39 bendavid 1.1 FillerPhotons::~FillerPhotons()
40     {
41 loizides 1.2 // Destructor.
42 loizides 1.3
43     delete photons_;
44 bendavid 1.1 }
45    
46 loizides 1.2 //--------------------------------------------------------------------------------------------------
47 bendavid 1.19 void FillerPhotons::BookDataBlock(TreeWriter &tws)
48 bendavid 1.1 {
49 loizides 1.7 // Add photon branch to tree and get the map.
50 loizides 1.2
51 loizides 1.13 tws.AddBranch(mitName_,&photons_);
52     OS()->add<mithep::PhotonArr>(photons_,mitName_);
53 loizides 1.7
54 loizides 1.13 if (!conversionMapName_.empty()) {
55     conversionMap_ = OS()->get<ConversionMap>(conversionMapName_);
56     if (conversionMap_)
57     AddBranchDep(mitName_,conversionMap_->GetBrName());
58     }
59     if (!barrelSuperClusterMapName_.empty()) {
60     barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_);
61     if (barrelSuperClusterMap_)
62     AddBranchDep(mitName_,barrelSuperClusterMap_->GetBrName());
63     }
64     if (!endcapSuperClusterMapName_.empty()) {
65     endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_);
66     if (endcapSuperClusterMap_)
67     AddBranchDep(mitName_,endcapSuperClusterMap_->GetBrName());
68     }
69 bendavid 1.1 }
70    
71 loizides 1.2 //--------------------------------------------------------------------------------------------------
72 bendavid 1.1 void FillerPhotons::FillDataBlock(const edm::Event &event,
73 loizides 1.13 const edm::EventSetup &setup)
74 bendavid 1.1 {
75 loizides 1.2 // Fill photon array.
76 bendavid 1.1
77 bendavid 1.11 photons_->Delete();
78 loizides 1.4
79 loizides 1.13 // get photon collection
80 loizides 1.4 Handle<reco::PhotonCollection> hPhotonProduct;
81     GetProduct(edmName_, hPhotonProduct, event);
82     const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
83 bendavid 1.1
84 bendavid 1.15 // handles to get the photon ID information
85     Handle<edm::ValueMap<bool> > phidLooseMap;
86     GetProduct(phIDCutBasedLooseName_, phidLooseMap, event);
87     Handle<edm::ValueMap<bool> > phidTightMap;
88     GetProduct(phIDCutBasedTightName_, phidTightMap, event);
89    
90 loizides 1.2 for (reco::PhotonCollection::const_iterator iP = inPhotons.begin();
91     iP != inPhotons.end(); ++iP) {
92    
93 sixie 1.10 int photonIndex = iP - inPhotons.begin();
94 bendavid 1.15 reco::PhotonRef phRef(hPhotonProduct, photonIndex);
95 sixie 1.10
96 loizides 1.5 mithep::Photon *outPhoton = photons_->Allocate();
97 bendavid 1.15 new (outPhoton) mithep::Photon(iP->px(),iP->py(),iP->pz(),iP->energy());
98     outPhoton->SetIsConverted(iP->hasConversionTracks());
99     outPhoton->SetR9(iP->r9());
100     outPhoton->SetHadOverEm(iP->hadronicOverEm());
101     outPhoton->SetHasPixelSeed(iP->hasPixelSeed());
102 bendavid 1.16
103 bendavid 1.21 // shower shape variables
104     outPhoton->SetHcalDepth1OverEcal(iP->hadronicDepth1OverEm());
105     outPhoton->SetHcalDepth2OverEcal(iP->hadronicDepth2OverEm());
106     outPhoton->SetMaxEnergyXtal(iP->maxEnergyXtal());
107     outPhoton->SetE15(iP->e1x5());
108     outPhoton->SetE25(iP->e2x5());
109     outPhoton->SetE33(iP->e3x3());
110     outPhoton->SetE55(iP->e5x5());
111     outPhoton->SetCovEtaEta(iP->sigmaEtaEta());
112     outPhoton->SetCoviEtaiEta(iP->sigmaIetaIeta());
113    
114 bendavid 1.16 //isolation variables for dR=0.3
115     outPhoton->SetEcalRecHitIsoDr03(iP->ecalRecHitSumEtConeDR03());
116     outPhoton->SetHcalTowerSumEtDr03(iP->hcalTowerSumEtConeDR03());
117     outPhoton->SetHcalDepth1TowerSumEtDr03(iP->hcalDepth1TowerSumEtConeDR03());
118     outPhoton->SetHcalDepth2TowerSumEtDr03(iP->hcalDepth2TowerSumEtConeDR03());
119     outPhoton->SetSolidConeTrkIsoDr03(iP->trkSumPtSolidConeDR03());
120     outPhoton->SetHollowConeTrkIsoDr03(iP->trkSumPtHollowConeDR03());
121     outPhoton->SetSolidConeNTrkDr03(iP->nTrkSolidConeDR03());
122     outPhoton->SetHollowConeNTrkDr03(iP->nTrkHollowConeDR03());
123    
124     //isolation variables for dR=0.4
125     outPhoton->SetEcalRecHitIsoDr04(iP->ecalRecHitSumEtConeDR04());
126     outPhoton->SetHcalTowerSumEtDr04(iP->hcalTowerSumEtConeDR04());
127     outPhoton->SetHcalDepth1TowerSumEtDr04(iP->hcalDepth1TowerSumEtConeDR04());
128     outPhoton->SetHcalDepth2TowerSumEtDr04(iP->hcalDepth2TowerSumEtConeDR04());
129     outPhoton->SetSolidConeTrkIsoDr04(iP->trkSumPtSolidConeDR04());
130     outPhoton->SetHollowConeTrkIsoDr04(iP->trkSumPtHollowConeDR04());
131     outPhoton->SetSolidConeNTrkDr04(iP->nTrkSolidConeDR04());
132     outPhoton->SetHollowConeNTrkDr04(iP->nTrkHollowConeDR04());
133    
134 bendavid 1.23 //pflow isolation
135     outPhoton->SetPFChargedHadronIso(iP->chargedHadronIso());
136     outPhoton->SetPFChargedHadronIso(iP->neutralHadronIso());
137     outPhoton->SetPFChargedHadronIso(iP->photonIso());
138    
139 bendavid 1.16 //fiducial and quality flags
140     outPhoton->SetIsEB(iP->isEB());
141     outPhoton->SetIsEE(iP->isEE());
142 bendavid 1.15 outPhoton->SetIsEBGap(iP->isEBGap());
143     outPhoton->SetIsEEGap(iP->isEEGap());
144     outPhoton->SetIsEBEEGap(iP->isEBEEGap());
145 loizides 1.17 //deprecated, identical to supercluster preselection in 3_1_X, so set to true
146     outPhoton->SetIsLooseEM(true); //deprecated
147 bendavid 1.15 outPhoton->SetIsLoosePhoton((*phidLooseMap)[phRef]);
148     outPhoton->SetIsTightPhoton((*phidTightMap)[phRef]);
149 sixie 1.10
150 bendavid 1.22 //calo position
151     outPhoton->SetCaloPosXYZ(iP->caloPosition().x(),iP->caloPosition().y(),iP->caloPosition().z());
152    
153 loizides 1.13 // make links to conversions
154 bendavid 1.15 if (iP->hasConversionTracks() && conversionMap_) {
155     reco::ConversionRefVector conversionRefs = iP->conversions();
156     for (reco::ConversionRefVector::const_iterator conversionRef =
157 loizides 1.2 conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
158     outPhoton->AddConversion(conversionMap_->GetMit(*conversionRef));
159     }
160     }
161 loizides 1.13
162     // make link to supercluster
163 bendavid 1.20 if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && iP->superCluster().isNonnull()) {
164 bendavid 1.15 if(barrelSuperClusterMap_->HasMit(iP->superCluster())) {
165     outPhoton->SetSuperCluster(barrelSuperClusterMap_->GetMit(iP->superCluster()));
166 bendavid 1.9 } else {
167 bendavid 1.15 outPhoton->SetSuperCluster(endcapSuperClusterMap_->GetMit(iP->superCluster()));
168 bendavid 1.9 }
169 bendavid 1.20 }
170 bendavid 1.1 }
171     photons_->Trim();
172     }