ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPhotons.cc
Revision: 1.21
Committed: Sun Sep 19 23:47:15 2010 UTC (14 years, 7 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e
Changes since 1.20: +12 -1 lines
Log Message:
add shower shape variables to photon

File Contents

# Content
1 // $Id: FillerPhotons.cc,v 1.20 2010/06/25 15:16:35 bendavid Exp $
2
3 #include "MitProd/TreeFiller/interface/FillerPhotons.h"
4 #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 #include "MitAna/DataTree/interface/PhotonCol.h"
12 #include "MitProd/ObjectService/interface/ObjectService.h"
13
14 using namespace std;
15 using namespace edm;
16 using namespace mithep;
17
18 //--------------------------------------------------------------------------------------------------
19 FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, const char *name, bool active) :
20 BaseFiller(cfg,name,active),
21 edmName_(Conf().getUntrackedParameter<string>("edmName","photons")),
22 mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
23 conversionMapName_(Conf().getUntrackedParameter<string>("conversionMapName","")),
24 barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
25 endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
26 phIDCutBasedTightName_(Conf().getUntrackedParameter<string>("phIDCutBasedTightName",
27 "PhotonIDProd:PhotonCutBasedIDTight")),
28 phIDCutBasedLooseName_(Conf().getUntrackedParameter<string>("phIDCutBasedLooseName",
29 "PhotonIDProd:PhotonCutBasedIDLoose")),
30 photons_(new mithep::PhotonArr(16)),
31 conversionMap_(0),
32 barrelSuperClusterMap_(0),
33 endcapSuperClusterMap_(0)
34 {
35 // Constructor.
36 }
37
38 //--------------------------------------------------------------------------------------------------
39 FillerPhotons::~FillerPhotons()
40 {
41 // Destructor.
42
43 delete photons_;
44 }
45
46 //--------------------------------------------------------------------------------------------------
47 void FillerPhotons::BookDataBlock(TreeWriter &tws)
48 {
49 // Add photon branch to tree and get the map.
50
51 tws.AddBranch(mitName_,&photons_);
52 OS()->add<mithep::PhotonArr>(photons_,mitName_);
53
54 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 }
70
71 //--------------------------------------------------------------------------------------------------
72 void FillerPhotons::FillDataBlock(const edm::Event &event,
73 const edm::EventSetup &setup)
74 {
75 // Fill photon array.
76
77 photons_->Delete();
78
79 // get photon collection
80 Handle<reco::PhotonCollection> hPhotonProduct;
81 GetProduct(edmName_, hPhotonProduct, event);
82 const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
83
84 // 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 for (reco::PhotonCollection::const_iterator iP = inPhotons.begin();
91 iP != inPhotons.end(); ++iP) {
92
93 int photonIndex = iP - inPhotons.begin();
94 reco::PhotonRef phRef(hPhotonProduct, photonIndex);
95
96 mithep::Photon *outPhoton = photons_->Allocate();
97 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
103 // 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 //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 //fiducial and quality flags
135 outPhoton->SetIsEB(iP->isEB());
136 outPhoton->SetIsEE(iP->isEE());
137 outPhoton->SetIsEBGap(iP->isEBGap());
138 outPhoton->SetIsEEGap(iP->isEEGap());
139 outPhoton->SetIsEBEEGap(iP->isEBEEGap());
140 //deprecated, identical to supercluster preselection in 3_1_X, so set to true
141 outPhoton->SetIsLooseEM(true); //deprecated
142 outPhoton->SetIsLoosePhoton((*phidLooseMap)[phRef]);
143 outPhoton->SetIsTightPhoton((*phidTightMap)[phRef]);
144
145 // make links to conversions
146 if (iP->hasConversionTracks() && conversionMap_) {
147 reco::ConversionRefVector conversionRefs = iP->conversions();
148 for (reco::ConversionRefVector::const_iterator conversionRef =
149 conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
150 outPhoton->AddConversion(conversionMap_->GetMit(*conversionRef));
151 }
152 }
153
154 // make link to supercluster
155 if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && iP->superCluster().isNonnull()) {
156 if(barrelSuperClusterMap_->HasMit(iP->superCluster())) {
157 outPhoton->SetSuperCluster(barrelSuperClusterMap_->GetMit(iP->superCluster()));
158 } else {
159 outPhoton->SetSuperCluster(endcapSuperClusterMap_->GetMit(iP->superCluster()));
160 }
161 }
162 }
163 photons_->Trim();
164 }