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

# User Rev Content
1 loizides 1.14 // $Id: FillerPhotons.cc,v 1.13 2009/03/15 11:20:41 loizides 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 sixie 1.10 #include "DataFormats/EgammaCandidates/interface/PhotonIDFwd.h"
9     #include "DataFormats/EgammaCandidates/interface/PhotonID.h"
10     #include "DataFormats/EgammaCandidates/interface/PhotonIDAssociation.h"
11 bendavid 1.1 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
12     #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
13     #include "MitAna/DataTree/interface/Names.h"
14 loizides 1.14 #include "MitAna/DataTree/interface/PhotonCol.h"
15     #include "MitProd/ObjectService/interface/ObjectService.h"
16 bendavid 1.1
17     using namespace std;
18     using namespace edm;
19     using namespace mithep;
20    
21 loizides 1.2 //--------------------------------------------------------------------------------------------------
22 loizides 1.12 FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, const char *name, bool active) :
23     BaseFiller(cfg,name,active),
24 bendavid 1.1 edmName_(Conf().getUntrackedParameter<string>("edmName","photons")),
25     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
26 loizides 1.12 photonIDName_(Conf().getUntrackedParameter<string>("photonIDName",
27     "PhotonIDProd:PhotonAssociatedID")),
28 loizides 1.7 conversionMapName_(Conf().getUntrackedParameter<string>("conversionMapName","")),
29 bendavid 1.9 barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
30     endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
31 loizides 1.5 photons_(new mithep::PhotonArr(16)),
32 bendavid 1.9 conversionMap_(0),
33     barrelSuperClusterMap_(0),
34     endcapSuperClusterMap_(0)
35 bendavid 1.1 {
36 loizides 1.2 // Constructor.
37 bendavid 1.1 }
38    
39 loizides 1.2 //--------------------------------------------------------------------------------------------------
40 bendavid 1.1 FillerPhotons::~FillerPhotons()
41     {
42 loizides 1.2 // Destructor.
43 loizides 1.3
44     delete photons_;
45 bendavid 1.1 }
46    
47 loizides 1.2 //--------------------------------------------------------------------------------------------------
48 bendavid 1.1 void FillerPhotons::BookDataBlock(TreeWriter &tws)
49     {
50 loizides 1.7 // Add photon branch to tree and get the map.
51 loizides 1.2
52 loizides 1.13 tws.AddBranch(mitName_,&photons_);
53     OS()->add<mithep::PhotonArr>(photons_,mitName_);
54 loizides 1.7
55 loizides 1.13 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 bendavid 1.1 }
71    
72 loizides 1.2 //--------------------------------------------------------------------------------------------------
73 bendavid 1.1 void FillerPhotons::FillDataBlock(const edm::Event &event,
74 loizides 1.13 const edm::EventSetup &setup)
75 bendavid 1.1 {
76 loizides 1.2 // Fill photon array.
77 bendavid 1.1
78 bendavid 1.11 photons_->Delete();
79 loizides 1.4
80 loizides 1.13 // get photon collection
81 loizides 1.4 Handle<reco::PhotonCollection> hPhotonProduct;
82     GetProduct(edmName_, hPhotonProduct, event);
83     const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
84 bendavid 1.1
85 loizides 1.13 // get associated PhotonID objects
86 sixie 1.10 Handle<reco::PhotonIDAssociationCollection> photonIDMapColl;
87     GetProduct(photonIDName_, photonIDMapColl, event);
88     const reco::PhotonIDAssociationCollection *photonIDMap = photonIDMapColl.product();
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     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 loizides 1.5 mithep::Photon *outPhoton = photons_->Allocate();
100 sixie 1.10 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 loizides 1.13 // make links to conversions
119 sixie 1.10 if (photon->isConverted() && conversionMap_) {
120     std::vector<reco::ConversionRef> conversionRefs = photon->conversions();
121 loizides 1.2 for (std::vector<reco::ConversionRef>::const_iterator conversionRef =
122     conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
123     outPhoton->AddConversion(conversionMap_->GetMit(*conversionRef));
124     }
125     }
126 loizides 1.13
127     // make link to supercluster
128 sixie 1.10 if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && photon->superCluster().isNonnull())
129     if(barrelSuperClusterMap_->HasMit(photon->superCluster())) {
130     outPhoton->SetSuperCluster(barrelSuperClusterMap_->GetMit(photon->superCluster()));
131 bendavid 1.9 } else {
132 sixie 1.10 outPhoton->SetSuperCluster(endcapSuperClusterMap_->GetMit(photon->superCluster()));
133 bendavid 1.9 }
134 bendavid 1.1 }
135     photons_->Trim();
136     }