1 |
paus |
1.30 |
// $Id: FillerPhotons.cc,v 1.29 2012/04/20 16:07:43 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 |
paus |
1.30 |
#include "RecoEgamma/EgammaTools/interface/ggPFPhotons.h"
|
14 |
|
|
#include "RecoEgamma/EgammaTools/interface/ggPFClusters.h"
|
15 |
|
|
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
|
16 |
|
|
#include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
|
17 |
|
|
#include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
|
18 |
|
|
#include "Geometry/Records/interface/CaloGeometryRecord.h"
|
19 |
|
|
#include "FWCore/Framework/interface/ESHandle.h"
|
20 |
|
|
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
|
21 |
bendavid |
1.24 |
#include "TSystem.h"
|
22 |
bendavid |
1.1 |
|
23 |
|
|
using namespace std;
|
24 |
|
|
using namespace edm;
|
25 |
|
|
using namespace mithep;
|
26 |
|
|
|
27 |
paus |
1.27 |
//---------------------------------------------------------------------------------------------------
|
28 |
loizides |
1.12 |
FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, const char *name, bool active) :
|
29 |
paus |
1.30 |
BaseFiller (cfg,name,active),
|
30 |
paus |
1.27 |
edmName_ (Conf().getUntrackedParameter<string>("edmName","photons")),
|
31 |
|
|
mitName_ (Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
|
32 |
|
|
conversionMapName_ (Conf().getUntrackedParameter<string>("conversionMapName","")),
|
33 |
paus |
1.30 |
oneLegConversionMapName_ (Conf().getUntrackedParameter<string>("oneLegConversionMapName","")),
|
34 |
bendavid |
1.9 |
barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
|
35 |
|
|
endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
|
36 |
paus |
1.30 |
pfSuperClusterMapName_ (Conf().getUntrackedParameter<string>("pfSuperClusterMapName","")),
|
37 |
|
|
pfClusterMapName_ (Conf().getUntrackedParameter<string>("pfClusterMapName","")),
|
38 |
|
|
pfCandMapName_ (Conf().getUntrackedParameter<string>("pfCandMapName","")),
|
39 |
paus |
1.27 |
phIDCutBasedTightName_ (Conf().getUntrackedParameter<string>("phIDCutBasedTightName",
|
40 |
|
|
"PhotonIDProd:PhotonCutBasedIDTight")),
|
41 |
|
|
phIDCutBasedLooseName_ (Conf().getUntrackedParameter<string>("phIDCutBasedLooseName",
|
42 |
|
|
"PhotonIDProd:PhotonCutBasedIDLoose")),
|
43 |
|
|
photons_ (new mithep::PhotonArr(16)),
|
44 |
|
|
conversionMap_ (0),
|
45 |
paus |
1.30 |
oneLegConversionMap_ (0),
|
46 |
paus |
1.27 |
barrelSuperClusterMap_ (0),
|
47 |
bendavid |
1.29 |
endcapSuperClusterMap_ (0),
|
48 |
paus |
1.30 |
pfSuperClusterMap_ (0),
|
49 |
|
|
pfClusterMap_ (0),
|
50 |
|
|
pfCandMap_ (0)
|
51 |
bendavid |
1.1 |
{
|
52 |
loizides |
1.2 |
// Constructor.
|
53 |
bendavid |
1.1 |
}
|
54 |
|
|
|
55 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
56 |
bendavid |
1.1 |
FillerPhotons::~FillerPhotons()
|
57 |
|
|
{
|
58 |
loizides |
1.2 |
// Destructor.
|
59 |
loizides |
1.3 |
|
60 |
|
|
delete photons_;
|
61 |
bendavid |
1.1 |
}
|
62 |
|
|
|
63 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
64 |
bendavid |
1.19 |
void FillerPhotons::BookDataBlock(TreeWriter &tws)
|
65 |
bendavid |
1.1 |
{
|
66 |
loizides |
1.7 |
// Add photon branch to tree and get the map.
|
67 |
loizides |
1.2 |
|
68 |
loizides |
1.13 |
tws.AddBranch(mitName_,&photons_);
|
69 |
|
|
OS()->add<mithep::PhotonArr>(photons_,mitName_);
|
70 |
loizides |
1.7 |
|
71 |
loizides |
1.13 |
if (!conversionMapName_.empty()) {
|
72 |
paus |
1.30 |
conversionMap_ = OS()->get<ConversionDecayMap>(conversionMapName_);
|
73 |
loizides |
1.13 |
if (conversionMap_)
|
74 |
|
|
AddBranchDep(mitName_,conversionMap_->GetBrName());
|
75 |
|
|
}
|
76 |
|
|
if (!barrelSuperClusterMapName_.empty()) {
|
77 |
|
|
barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_);
|
78 |
|
|
if (barrelSuperClusterMap_)
|
79 |
|
|
AddBranchDep(mitName_,barrelSuperClusterMap_->GetBrName());
|
80 |
|
|
}
|
81 |
|
|
if (!endcapSuperClusterMapName_.empty()) {
|
82 |
|
|
endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_);
|
83 |
|
|
if (endcapSuperClusterMap_)
|
84 |
|
|
AddBranchDep(mitName_,endcapSuperClusterMap_->GetBrName());
|
85 |
|
|
}
|
86 |
bendavid |
1.29 |
if (!pfSuperClusterMapName_.empty()) {
|
87 |
|
|
pfSuperClusterMap_ = OS()->get<SuperClusterMap>(pfSuperClusterMapName_);
|
88 |
|
|
if (pfSuperClusterMap_)
|
89 |
|
|
AddBranchDep(mitName_,pfSuperClusterMap_->GetBrName());
|
90 |
|
|
}
|
91 |
paus |
1.30 |
if (!pfClusterMapName_.empty()) {
|
92 |
|
|
pfClusterMap_ = OS()->get<BasicClusterMap>(pfClusterMapName_);
|
93 |
|
|
if (pfClusterMap_)
|
94 |
|
|
AddBranchDep(mitName_,pfClusterMap_->GetBrName());
|
95 |
|
|
}
|
96 |
|
|
if (!pfCandMapName_.empty()) {
|
97 |
|
|
pfCandMap_ = OS()->get<PFCandidateMap>(pfCandMapName_);
|
98 |
|
|
if (pfCandMap_)
|
99 |
|
|
AddBranchDep(mitName_,pfCandMap_->GetBrName());
|
100 |
|
|
}
|
101 |
bendavid |
1.1 |
}
|
102 |
|
|
|
103 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
104 |
bendavid |
1.1 |
void FillerPhotons::FillDataBlock(const edm::Event &event,
|
105 |
loizides |
1.13 |
const edm::EventSetup &setup)
|
106 |
bendavid |
1.1 |
{
|
107 |
loizides |
1.2 |
// Fill photon array.
|
108 |
bendavid |
1.1 |
|
109 |
paus |
1.28 |
//if (!ecorr_.IsInitialized())
|
110 |
|
|
// ecorr_.Initialize(setup,std::string(TString("gbrph.root")));
|
111 |
bendavid |
1.25 |
|
112 |
bendavid |
1.11 |
photons_->Delete();
|
113 |
loizides |
1.4 |
|
114 |
loizides |
1.13 |
// get photon collection
|
115 |
loizides |
1.4 |
Handle<reco::PhotonCollection> hPhotonProduct;
|
116 |
|
|
GetProduct(edmName_, hPhotonProduct, event);
|
117 |
|
|
const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
|
118 |
bendavid |
1.1 |
|
119 |
paus |
1.30 |
//pf photon stuff
|
120 |
|
|
edm::Handle<EcalRecHitCollection> pEBRecHits;
|
121 |
|
|
event.getByLabel("reducedEcalRecHitsEB", pEBRecHits );
|
122 |
|
|
edm::Handle<EcalRecHitCollection> pEERecHits;
|
123 |
|
|
event.getByLabel( "reducedEcalRecHitsEE", pEERecHits );
|
124 |
|
|
|
125 |
|
|
edm::ESHandle<CaloGeometry> pGeometry;
|
126 |
|
|
setup.get<CaloGeometryRecord>().get(pGeometry);
|
127 |
|
|
|
128 |
|
|
const CaloSubdetectorGeometry *geometryEB = pGeometry->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
|
129 |
|
|
const CaloSubdetectorGeometry *geometryEE = pGeometry->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
|
130 |
|
|
|
131 |
|
|
ggPFClusters pfclusters(pEBRecHits, pEERecHits, geometryEB, geometryEE);
|
132 |
|
|
|
133 |
|
|
Handle<reco::PFCandidateCollection> pPFCands;
|
134 |
|
|
event.getByLabel("particleFlow", pPFCands);
|
135 |
|
|
|
136 |
bendavid |
1.15 |
// handles to get the photon ID information
|
137 |
|
|
Handle<edm::ValueMap<bool> > phidLooseMap;
|
138 |
bendavid |
1.29 |
if (!phIDCutBasedLooseName_.empty())
|
139 |
|
|
GetProduct(phIDCutBasedLooseName_, phidLooseMap, event);
|
140 |
|
|
|
141 |
bendavid |
1.15 |
Handle<edm::ValueMap<bool> > phidTightMap;
|
142 |
bendavid |
1.29 |
if (!phIDCutBasedTightName_.empty())
|
143 |
|
|
GetProduct(phIDCutBasedTightName_, phidTightMap, event);
|
144 |
bendavid |
1.15 |
|
145 |
loizides |
1.2 |
for (reco::PhotonCollection::const_iterator iP = inPhotons.begin();
|
146 |
|
|
iP != inPhotons.end(); ++iP) {
|
147 |
paus |
1.27 |
|
148 |
sixie |
1.10 |
int photonIndex = iP - inPhotons.begin();
|
149 |
bendavid |
1.15 |
reco::PhotonRef phRef(hPhotonProduct, photonIndex);
|
150 |
sixie |
1.10 |
|
151 |
loizides |
1.5 |
mithep::Photon *outPhoton = photons_->Allocate();
|
152 |
bendavid |
1.15 |
new (outPhoton) mithep::Photon(iP->px(),iP->py(),iP->pz(),iP->energy());
|
153 |
|
|
outPhoton->SetIsConverted(iP->hasConversionTracks());
|
154 |
|
|
outPhoton->SetR9(iP->r9());
|
155 |
|
|
outPhoton->SetHadOverEm(iP->hadronicOverEm());
|
156 |
|
|
outPhoton->SetHasPixelSeed(iP->hasPixelSeed());
|
157 |
bendavid |
1.16 |
|
158 |
bendavid |
1.21 |
// shower shape variables
|
159 |
|
|
outPhoton->SetHcalDepth1OverEcal(iP->hadronicDepth1OverEm());
|
160 |
|
|
outPhoton->SetHcalDepth2OverEcal(iP->hadronicDepth2OverEm());
|
161 |
|
|
outPhoton->SetMaxEnergyXtal(iP->maxEnergyXtal());
|
162 |
|
|
outPhoton->SetE15(iP->e1x5());
|
163 |
|
|
outPhoton->SetE25(iP->e2x5());
|
164 |
|
|
outPhoton->SetE33(iP->e3x3());
|
165 |
|
|
outPhoton->SetE55(iP->e5x5());
|
166 |
|
|
outPhoton->SetCovEtaEta(iP->sigmaEtaEta());
|
167 |
|
|
outPhoton->SetCoviEtaiEta(iP->sigmaIetaIeta());
|
168 |
bendavid |
1.29 |
outPhoton->SetHadOverEmTow(iP->hadTowOverEm());
|
169 |
bendavid |
1.21 |
|
170 |
bendavid |
1.16 |
//isolation variables for dR=0.3
|
171 |
|
|
outPhoton->SetEcalRecHitIsoDr03(iP->ecalRecHitSumEtConeDR03());
|
172 |
|
|
outPhoton->SetHcalTowerSumEtDr03(iP->hcalTowerSumEtConeDR03());
|
173 |
|
|
outPhoton->SetHcalDepth1TowerSumEtDr03(iP->hcalDepth1TowerSumEtConeDR03());
|
174 |
|
|
outPhoton->SetHcalDepth2TowerSumEtDr03(iP->hcalDepth2TowerSumEtConeDR03());
|
175 |
|
|
outPhoton->SetSolidConeTrkIsoDr03(iP->trkSumPtSolidConeDR03());
|
176 |
|
|
outPhoton->SetHollowConeTrkIsoDr03(iP->trkSumPtHollowConeDR03());
|
177 |
|
|
outPhoton->SetSolidConeNTrkDr03(iP->nTrkSolidConeDR03());
|
178 |
|
|
outPhoton->SetHollowConeNTrkDr03(iP->nTrkHollowConeDR03());
|
179 |
bendavid |
1.29 |
outPhoton->SetHCalIsoTowDr03(iP->hcalTowerSumEtConeDR03() + (iP->hadronicOverEm() - iP->hadTowOverEm())*iP->superCluster()->energy()/cosh(iP->superCluster()->eta()));
|
180 |
|
|
|
181 |
bendavid |
1.16 |
//isolation variables for dR=0.4
|
182 |
|
|
outPhoton->SetEcalRecHitIsoDr04(iP->ecalRecHitSumEtConeDR04());
|
183 |
|
|
outPhoton->SetHcalTowerSumEtDr04(iP->hcalTowerSumEtConeDR04());
|
184 |
|
|
outPhoton->SetHcalDepth1TowerSumEtDr04(iP->hcalDepth1TowerSumEtConeDR04());
|
185 |
|
|
outPhoton->SetHcalDepth2TowerSumEtDr04(iP->hcalDepth2TowerSumEtConeDR04());
|
186 |
|
|
outPhoton->SetSolidConeTrkIsoDr04(iP->trkSumPtSolidConeDR04());
|
187 |
|
|
outPhoton->SetHollowConeTrkIsoDr04(iP->trkSumPtHollowConeDR04());
|
188 |
|
|
outPhoton->SetSolidConeNTrkDr04(iP->nTrkSolidConeDR04());
|
189 |
|
|
outPhoton->SetHollowConeNTrkDr04(iP->nTrkHollowConeDR04());
|
190 |
bendavid |
1.29 |
outPhoton->SetHCalIsoTowDr04(iP->hcalTowerSumEtConeDR04() + (iP->hadronicOverEm() - iP->hadTowOverEm())*iP->superCluster()->energy()/cosh(iP->superCluster()->eta()));
|
191 |
|
|
|
192 |
bendavid |
1.23 |
//pflow isolation
|
193 |
|
|
outPhoton->SetPFChargedHadronIso(iP->chargedHadronIso());
|
194 |
|
|
outPhoton->SetPFChargedHadronIso(iP->neutralHadronIso());
|
195 |
|
|
outPhoton->SetPFChargedHadronIso(iP->photonIso());
|
196 |
|
|
|
197 |
bendavid |
1.16 |
//fiducial and quality flags
|
198 |
|
|
outPhoton->SetIsEB(iP->isEB());
|
199 |
|
|
outPhoton->SetIsEE(iP->isEE());
|
200 |
bendavid |
1.15 |
outPhoton->SetIsEBGap(iP->isEBGap());
|
201 |
|
|
outPhoton->SetIsEEGap(iP->isEEGap());
|
202 |
|
|
outPhoton->SetIsEBEEGap(iP->isEBEEGap());
|
203 |
loizides |
1.17 |
//deprecated, identical to supercluster preselection in 3_1_X, so set to true
|
204 |
|
|
outPhoton->SetIsLooseEM(true); //deprecated
|
205 |
bendavid |
1.29 |
if (!phIDCutBasedLooseName_.empty()) outPhoton->SetIsLoosePhoton((*phidLooseMap)[phRef]);
|
206 |
|
|
if (!phIDCutBasedTightName_.empty()) outPhoton->SetIsTightPhoton((*phidTightMap)[phRef]);
|
207 |
sixie |
1.10 |
|
208 |
bendavid |
1.22 |
//calo position
|
209 |
|
|
outPhoton->SetCaloPosXYZ(iP->caloPosition().x(),iP->caloPosition().y(),iP->caloPosition().z());
|
210 |
bendavid |
1.29 |
|
211 |
loizides |
1.13 |
// make links to conversions
|
212 |
paus |
1.30 |
if (conversionMap_) {
|
213 |
|
|
const reco::ConversionRefVector &conversionRefs = iP->conversions();
|
214 |
|
|
for (reco::ConversionRefVector::const_iterator conversionRef =
|
215 |
|
|
conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
|
216 |
|
|
outPhoton->AddConversionD(conversionMap_->GetMit(*conversionRef));
|
217 |
|
|
}
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
// make links to conversions (single leg)
|
221 |
|
|
if (oneLegConversionMap_) {
|
222 |
|
|
const reco::ConversionRefVector &conversionRefs = iP->conversionsOneLeg();
|
223 |
bendavid |
1.15 |
for (reco::ConversionRefVector::const_iterator conversionRef =
|
224 |
loizides |
1.2 |
conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
|
225 |
paus |
1.30 |
outPhoton->AddConversionS(oneLegConversionMap_->GetMit(*conversionRef));
|
226 |
loizides |
1.2 |
}
|
227 |
|
|
}
|
228 |
loizides |
1.13 |
|
229 |
|
|
// make link to supercluster
|
230 |
bendavid |
1.20 |
if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && iP->superCluster().isNonnull()) {
|
231 |
paus |
1.27 |
if (barrelSuperClusterMap_->HasMit(iP->superCluster()))
|
232 |
bendavid |
1.15 |
outPhoton->SetSuperCluster(barrelSuperClusterMap_->GetMit(iP->superCluster()));
|
233 |
paus |
1.27 |
else
|
234 |
bendavid |
1.15 |
outPhoton->SetSuperCluster(endcapSuperClusterMap_->GetMit(iP->superCluster()));
|
235 |
bendavid |
1.20 |
}
|
236 |
bendavid |
1.29 |
|
237 |
paus |
1.30 |
// make link to pf supercluster
|
238 |
bendavid |
1.29 |
if (pfSuperClusterMap_ && iP->pfSuperCluster().isNonnull()) {
|
239 |
paus |
1.30 |
outPhoton->SetPFSuperCluster(pfSuperClusterMap_->GetMit(iP->pfSuperCluster()));
|
240 |
|
|
//horrible stuff: mark PF superclusters with fraction of energy that overlaps with egamma supercluster
|
241 |
|
|
if (pfClusterMap_ && iP->superCluster().isNonnull()) {
|
242 |
|
|
for (reco::CaloCluster_iterator pfcit = iP->pfSuperCluster()->clustersBegin();
|
243 |
|
|
pfcit!=iP->pfSuperCluster()->clustersEnd(); ++pfcit) {
|
244 |
|
|
float eoverlap = pfclusters.getPFSuperclusterOverlap(**pfcit,*iP->superCluster() );
|
245 |
|
|
const_cast<mithep::BasicCluster*>(pfClusterMap_->GetMit(*pfcit))->SetMatchedEnergy(eoverlap);
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
bendavid |
1.29 |
}
|
249 |
bendavid |
1.24 |
|
250 |
paus |
1.30 |
//horrible stuff: make links to PFCandidates to try and recover pflow clustering when pflow id failed...
|
251 |
|
|
if (pfCandMap_ && iP->superCluster().isNonnull()) {
|
252 |
|
|
std::vector<PFCandidatePtr> inmust;
|
253 |
|
|
std::vector<PFCandidatePtr> outmust;
|
254 |
|
|
std::pair<double,double> scsize = ggPFPhotons::SuperClusterSize(*iP->superCluster(),
|
255 |
|
|
pEBRecHits,
|
256 |
|
|
pEERecHits,
|
257 |
|
|
geometryEB,
|
258 |
|
|
geometryEE);
|
259 |
|
|
ggPFPhotons::recoPhotonClusterLink(*iP->superCluster(),
|
260 |
|
|
inmust,
|
261 |
|
|
outmust,
|
262 |
|
|
pPFCands,
|
263 |
|
|
scsize.first,
|
264 |
|
|
scsize.second);
|
265 |
|
|
|
266 |
|
|
for (std::vector<PFCandidatePtr>::const_iterator pfit = inmust.begin(); pfit!=inmust.end(); ++pfit)
|
267 |
|
|
outPhoton->AddPFPhotonInMustache(pfCandMap_->GetMit(*pfit));
|
268 |
|
|
for (std::vector<PFCandidatePtr>::const_iterator pfit = outmust.begin(); pfit!=outmust.end(); ++pfit)
|
269 |
|
|
outPhoton->AddPFPhotonOutOfMustache(pfCandMap_->GetMit(*pfit));
|
270 |
|
|
}
|
271 |
paus |
1.28 |
|
272 |
paus |
1.30 |
////regression energy corrections
|
273 |
|
|
//std::pair<double,double> cor = ecorr_.CorrectedEnergyWithError(*iP);
|
274 |
|
|
//outPhoton->SetEnergyRegr(cor.first);
|
275 |
|
|
//outPhoton->SetEnergyErrRegr(cor.second);
|
276 |
bendavid |
1.1 |
}
|
277 |
|
|
photons_->Trim();
|
278 |
|
|
}
|