ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPhotons.cc
Revision: 1.14
Committed: Mon Jun 15 15:00:26 2009 UTC (15 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009c, Mit_009b
Changes since 1.13: +3 -3 lines
Log Message:
Added proper fwd defs plus split up complilation of MitAna/DataTree LinkDefs.

File Contents

# Content
1 // $Id: FillerPhotons.cc,v 1.13 2009/03/15 11:20:41 loizides 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/PhotonIDFwd.h"
9 #include "DataFormats/EgammaCandidates/interface/PhotonID.h"
10 #include "DataFormats/EgammaCandidates/interface/PhotonIDAssociation.h"
11 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
12 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
13 #include "MitAna/DataTree/interface/Names.h"
14 #include "MitAna/DataTree/interface/PhotonCol.h"
15 #include "MitProd/ObjectService/interface/ObjectService.h"
16
17 using namespace std;
18 using namespace edm;
19 using namespace mithep;
20
21 //--------------------------------------------------------------------------------------------------
22 FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, const char *name, bool active) :
23 BaseFiller(cfg,name,active),
24 edmName_(Conf().getUntrackedParameter<string>("edmName","photons")),
25 mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
26 photonIDName_(Conf().getUntrackedParameter<string>("photonIDName",
27 "PhotonIDProd:PhotonAssociatedID")),
28 conversionMapName_(Conf().getUntrackedParameter<string>("conversionMapName","")),
29 barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
30 endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
31 photons_(new mithep::PhotonArr(16)),
32 conversionMap_(0),
33 barrelSuperClusterMap_(0),
34 endcapSuperClusterMap_(0)
35 {
36 // Constructor.
37 }
38
39 //--------------------------------------------------------------------------------------------------
40 FillerPhotons::~FillerPhotons()
41 {
42 // Destructor.
43
44 delete photons_;
45 }
46
47 //--------------------------------------------------------------------------------------------------
48 void FillerPhotons::BookDataBlock(TreeWriter &tws)
49 {
50 // Add photon branch to tree and get the map.
51
52 tws.AddBranch(mitName_,&photons_);
53 OS()->add<mithep::PhotonArr>(photons_,mitName_);
54
55 if (!conversionMapName_.empty()) {
56 conversionMap_ = OS()->get<ConversionMap>(conversionMapName_);
57 if (conversionMap_)
58 AddBranchDep(mitName_,conversionMap_->GetBrName());
59 }
60 if (!barrelSuperClusterMapName_.empty()) {
61 barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_);
62 if (barrelSuperClusterMap_)
63 AddBranchDep(mitName_,barrelSuperClusterMap_->GetBrName());
64 }
65 if (!endcapSuperClusterMapName_.empty()) {
66 endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_);
67 if (endcapSuperClusterMap_)
68 AddBranchDep(mitName_,endcapSuperClusterMap_->GetBrName());
69 }
70 }
71
72 //--------------------------------------------------------------------------------------------------
73 void FillerPhotons::FillDataBlock(const edm::Event &event,
74 const edm::EventSetup &setup)
75 {
76 // Fill photon array.
77
78 photons_->Delete();
79
80 // get photon collection
81 Handle<reco::PhotonCollection> hPhotonProduct;
82 GetProduct(edmName_, hPhotonProduct, event);
83 const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
84
85 // get associated PhotonID objects
86 Handle<reco::PhotonIDAssociationCollection> photonIDMapColl;
87 GetProduct(photonIDName_, photonIDMapColl, event);
88 const reco::PhotonIDAssociationCollection *photonIDMap = photonIDMapColl.product();
89
90 for (reco::PhotonCollection::const_iterator iP = inPhotons.begin();
91 iP != inPhotons.end(); ++iP) {
92
93 int photonIndex = iP - inPhotons.begin();
94 edm::Ref<reco::PhotonCollection> photonref(hPhotonProduct, photonIndex);
95 reco::PhotonIDAssociationCollection::const_iterator photonIter = photonIDMap->find(photonref);
96 const reco::PhotonIDRef &phID = photonIter->val;
97 const reco::PhotonRef &photon = photonIter->key;
98
99 mithep::Photon *outPhoton = photons_->Allocate();
100 new (outPhoton) mithep::Photon(photon->px(),photon->py(),photon->pz(),photon->energy());
101 outPhoton->SetIsConverted(photon->isConverted());
102 outPhoton->SetR9(phID->r9());
103 outPhoton->SetHadOverEm(photon->hadronicOverEm());
104 outPhoton->SetHasPixelSeed(photon->hasPixelSeed());
105 outPhoton->SetEcalRecHitIso(phID->isolationEcalRecHit());
106 outPhoton->SetHcalRecHitIso(phID->isolationHcalRecHit());
107 outPhoton->SetSolidConeTrkIso(phID->isolationSolidTrkCone());
108 outPhoton->SetHollowConeTrkIso(phID->isolationHollowTrkCone());
109 outPhoton->SetSolidConeNTrk(phID->nTrkSolidCone());
110 outPhoton->SetHollowConeNTrk(phID->nTrkHollowCone());
111 outPhoton->SetIsEBGap(phID->isEBGap());
112 outPhoton->SetIsEEGap(phID->isEEGap());
113 outPhoton->SetIsEBEEGap(phID->isEBEEGap());
114 outPhoton->SetIsLooseEM(phID->isLooseEM());
115 outPhoton->SetIsLoosePhoton(phID->isLoosePhoton());
116 outPhoton->SetIsTightPhoton(phID->isTightPhoton());
117
118 // make links to conversions
119 if (photon->isConverted() && conversionMap_) {
120 std::vector<reco::ConversionRef> conversionRefs = photon->conversions();
121 for (std::vector<reco::ConversionRef>::const_iterator conversionRef =
122 conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
123 outPhoton->AddConversion(conversionMap_->GetMit(*conversionRef));
124 }
125 }
126
127 // make link to supercluster
128 if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && photon->superCluster().isNonnull())
129 if(barrelSuperClusterMap_->HasMit(photon->superCluster())) {
130 outPhoton->SetSuperCluster(barrelSuperClusterMap_->GetMit(photon->superCluster()));
131 } else {
132 outPhoton->SetSuperCluster(endcapSuperClusterMap_->GetMit(photon->superCluster()));
133 }
134 }
135 photons_->Trim();
136 }