1 |
sixie |
1.10 |
// $Id: FillerPhotons.cc,v 1.9 2008/09/14 03:24:01 bendavid Exp $
|
2 |
bendavid |
1.1 |
|
3 |
loizides |
1.2 |
#include "MitProd/TreeFiller/interface/FillerPhotons.h"
|
4 |
bendavid |
1.1 |
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
6 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
7 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
8 |
|
|
#include "DataFormats/EgammaCandidates/interface/Photon.h"
|
9 |
|
|
#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
|
10 |
sixie |
1.10 |
#include "DataFormats/EgammaCandidates/interface/PhotonIDFwd.h"
|
11 |
|
|
#include "DataFormats/EgammaCandidates/interface/PhotonID.h"
|
12 |
|
|
#include "DataFormats/EgammaCandidates/interface/PhotonIDAssociation.h"
|
13 |
bendavid |
1.1 |
#include "DataFormats/EgammaCandidates/interface/Conversion.h"
|
14 |
|
|
#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
|
15 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
16 |
|
|
|
17 |
|
|
using namespace std;
|
18 |
|
|
using namespace edm;
|
19 |
|
|
using namespace mithep;
|
20 |
|
|
|
21 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
22 |
loizides |
1.7 |
FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, bool active) :
|
23 |
loizides |
1.5 |
BaseFiller(cfg,"Photons",active),
|
24 |
bendavid |
1.1 |
edmName_(Conf().getUntrackedParameter<string>("edmName","photons")),
|
25 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
|
26 |
sixie |
1.10 |
photonIDName_(Conf().getUntrackedParameter<string>("photonIDName","PhotonIDProd:PhotonAssociatedID")),
|
27 |
loizides |
1.7 |
conversionMapName_(Conf().getUntrackedParameter<string>("conversionMapName","")),
|
28 |
bendavid |
1.9 |
barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
|
29 |
|
|
endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
|
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.1 |
void FillerPhotons::BookDataBlock(TreeWriter &tws)
|
48 |
|
|
{
|
49 |
loizides |
1.7 |
// Add photon branch to tree and get the map.
|
50 |
loizides |
1.2 |
|
51 |
bendavid |
1.1 |
tws.AddBranch(mitName_.c_str(),&photons_);
|
52 |
loizides |
1.7 |
|
53 |
bendavid |
1.9 |
if (!conversionMapName_.empty())
|
54 |
|
|
conversionMap_ = OS()->get<ConversionMap>(conversionMapName_.c_str());
|
55 |
|
|
if (!barrelSuperClusterMapName_.empty())
|
56 |
|
|
barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_.c_str());
|
57 |
|
|
if (!endcapSuperClusterMapName_.empty())
|
58 |
|
|
endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_.c_str());
|
59 |
bendavid |
1.1 |
}
|
60 |
|
|
|
61 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
62 |
bendavid |
1.1 |
void FillerPhotons::FillDataBlock(const edm::Event &event,
|
63 |
|
|
const edm::EventSetup &setup)
|
64 |
|
|
{
|
65 |
loizides |
1.2 |
// Fill photon array.
|
66 |
bendavid |
1.1 |
|
67 |
|
|
photons_->Reset();
|
68 |
loizides |
1.4 |
|
69 |
sixie |
1.10 |
//get photon collection
|
70 |
loizides |
1.4 |
Handle<reco::PhotonCollection> hPhotonProduct;
|
71 |
|
|
GetProduct(edmName_, hPhotonProduct, event);
|
72 |
|
|
const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
|
73 |
bendavid |
1.1 |
|
74 |
sixie |
1.10 |
//get associated PhotonID objects
|
75 |
|
|
Handle<reco::PhotonIDAssociationCollection> photonIDMapColl;
|
76 |
|
|
GetProduct(photonIDName_, photonIDMapColl, event);
|
77 |
|
|
const reco::PhotonIDAssociationCollection *photonIDMap = photonIDMapColl.product();
|
78 |
|
|
|
79 |
loizides |
1.2 |
for (reco::PhotonCollection::const_iterator iP = inPhotons.begin();
|
80 |
|
|
iP != inPhotons.end(); ++iP) {
|
81 |
|
|
|
82 |
sixie |
1.10 |
int photonIndex = iP - inPhotons.begin();
|
83 |
|
|
edm::Ref<reco::PhotonCollection> photonref(hPhotonProduct, photonIndex);
|
84 |
|
|
reco::PhotonIDAssociationCollection::const_iterator photonIter = photonIDMap->find(photonref);
|
85 |
|
|
const reco::PhotonIDRef &phID = photonIter->val;
|
86 |
|
|
const reco::PhotonRef &photon = photonIter->key;
|
87 |
|
|
|
88 |
loizides |
1.5 |
mithep::Photon *outPhoton = photons_->Allocate();
|
89 |
sixie |
1.10 |
new (outPhoton) mithep::Photon(photon->px(),photon->py(),photon->pz(),photon->energy());
|
90 |
|
|
outPhoton->SetIsConverted(photon->isConverted());
|
91 |
|
|
outPhoton->SetR9(phID->r9());
|
92 |
|
|
outPhoton->SetHadOverEm(photon->hadronicOverEm());
|
93 |
|
|
outPhoton->SetHasPixelSeed(photon->hasPixelSeed());
|
94 |
|
|
outPhoton->SetEcalRecHitIso(phID->isolationEcalRecHit());
|
95 |
|
|
outPhoton->SetHcalRecHitIso(phID->isolationHcalRecHit());
|
96 |
|
|
outPhoton->SetSolidConeTrkIso(phID->isolationSolidTrkCone());
|
97 |
|
|
outPhoton->SetHollowConeTrkIso(phID->isolationHollowTrkCone());
|
98 |
|
|
outPhoton->SetSolidConeNTrk(phID->nTrkSolidCone());
|
99 |
|
|
outPhoton->SetHollowConeNTrk(phID->nTrkHollowCone());
|
100 |
|
|
outPhoton->SetIsEBGap(phID->isEBGap());
|
101 |
|
|
outPhoton->SetIsEEGap(phID->isEEGap());
|
102 |
|
|
outPhoton->SetIsEBEEGap(phID->isEBEEGap());
|
103 |
|
|
outPhoton->SetIsLooseEM(phID->isLooseEM());
|
104 |
|
|
outPhoton->SetIsLoosePhoton(phID->isLoosePhoton());
|
105 |
|
|
outPhoton->SetIsTightPhoton(phID->isTightPhoton());
|
106 |
|
|
|
107 |
bendavid |
1.9 |
//make links to conversions
|
108 |
sixie |
1.10 |
if (photon->isConverted() && conversionMap_) {
|
109 |
|
|
std::vector<reco::ConversionRef> conversionRefs = photon->conversions();
|
110 |
loizides |
1.2 |
for (std::vector<reco::ConversionRef>::const_iterator conversionRef =
|
111 |
|
|
conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
|
112 |
|
|
outPhoton->AddConversion(conversionMap_->GetMit(*conversionRef));
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
bendavid |
1.9 |
//make link to supercluster
|
116 |
sixie |
1.10 |
if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && photon->superCluster().isNonnull())
|
117 |
|
|
if(barrelSuperClusterMap_->HasMit(photon->superCluster())) {
|
118 |
|
|
outPhoton->SetSuperCluster(barrelSuperClusterMap_->GetMit(photon->superCluster()));
|
119 |
bendavid |
1.9 |
} else {
|
120 |
sixie |
1.10 |
outPhoton->SetSuperCluster(endcapSuperClusterMap_->GetMit(photon->superCluster()));
|
121 |
bendavid |
1.9 |
}
|
122 |
bendavid |
1.1 |
}
|
123 |
loizides |
1.2 |
|
124 |
bendavid |
1.1 |
photons_->Trim();
|
125 |
|
|
}
|