ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPhotons.cc
Revision: 1.17
Committed: Mon Jul 20 03:19:24 2009 UTC (15 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_011, Mit_010a, Mit_010
Changes since 1.16: +7 -4 lines
Log Message:
Cleanup

File Contents

# User Rev Content
1 loizides 1.17 // $Id: FillerPhotons.cc,v 1.16 2009/06/25 17:05:17 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 bendavid 1.1
14     using namespace std;
15     using namespace edm;
16     using namespace mithep;
17    
18 loizides 1.2 //--------------------------------------------------------------------------------------------------
19 loizides 1.12 FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, const char *name, bool active) :
20     BaseFiller(cfg,name,active),
21 bendavid 1.1 edmName_(Conf().getUntrackedParameter<string>("edmName","photons")),
22     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
23 loizides 1.7 conversionMapName_(Conf().getUntrackedParameter<string>("conversionMapName","")),
24 bendavid 1.9 barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
25     endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
26 loizides 1.17 phIDCutBasedTightName_(Conf().getUntrackedParameter<string>("phIDCutBasedTightName",
27     "PhotonIDProd:PhotonCutBasedIDTight")),
28     phIDCutBasedLooseName_(Conf().getUntrackedParameter<string>("phIDCutBasedLooseName",
29     "PhotonIDProd:PhotonCutBasedIDLoose")),
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 loizides 1.13 tws.AddBranch(mitName_,&photons_);
52     OS()->add<mithep::PhotonArr>(photons_,mitName_);
53 loizides 1.7
54 loizides 1.13 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 bendavid 1.1 }
70    
71 loizides 1.2 //--------------------------------------------------------------------------------------------------
72 bendavid 1.1 void FillerPhotons::FillDataBlock(const edm::Event &event,
73 loizides 1.13 const edm::EventSetup &setup)
74 bendavid 1.1 {
75 loizides 1.2 // Fill photon array.
76 bendavid 1.1
77 bendavid 1.11 photons_->Delete();
78 loizides 1.4
79 loizides 1.13 // get photon collection
80 loizides 1.4 Handle<reco::PhotonCollection> hPhotonProduct;
81     GetProduct(edmName_, hPhotonProduct, event);
82     const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
83 bendavid 1.1
84 bendavid 1.15 // 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 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 bendavid 1.15 reco::PhotonRef phRef(hPhotonProduct, photonIndex);
95 sixie 1.10
96 loizides 1.5 mithep::Photon *outPhoton = photons_->Allocate();
97 bendavid 1.15 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 bendavid 1.16
103     //isolation variables for dR=0.3
104     outPhoton->SetEcalRecHitIsoDr03(iP->ecalRecHitSumEtConeDR03());
105     outPhoton->SetHcalTowerSumEtDr03(iP->hcalTowerSumEtConeDR03());
106     outPhoton->SetHcalDepth1TowerSumEtDr03(iP->hcalDepth1TowerSumEtConeDR03());
107     outPhoton->SetHcalDepth2TowerSumEtDr03(iP->hcalDepth2TowerSumEtConeDR03());
108     outPhoton->SetSolidConeTrkIsoDr03(iP->trkSumPtSolidConeDR03());
109     outPhoton->SetHollowConeTrkIsoDr03(iP->trkSumPtHollowConeDR03());
110     outPhoton->SetSolidConeNTrkDr03(iP->nTrkSolidConeDR03());
111     outPhoton->SetHollowConeNTrkDr03(iP->nTrkHollowConeDR03());
112    
113     //isolation variables for dR=0.4
114     outPhoton->SetEcalRecHitIsoDr04(iP->ecalRecHitSumEtConeDR04());
115     outPhoton->SetHcalTowerSumEtDr04(iP->hcalTowerSumEtConeDR04());
116     outPhoton->SetHcalDepth1TowerSumEtDr04(iP->hcalDepth1TowerSumEtConeDR04());
117     outPhoton->SetHcalDepth2TowerSumEtDr04(iP->hcalDepth2TowerSumEtConeDR04());
118     outPhoton->SetSolidConeTrkIsoDr04(iP->trkSumPtSolidConeDR04());
119     outPhoton->SetHollowConeTrkIsoDr04(iP->trkSumPtHollowConeDR04());
120     outPhoton->SetSolidConeNTrkDr04(iP->nTrkSolidConeDR04());
121     outPhoton->SetHollowConeNTrkDr04(iP->nTrkHollowConeDR04());
122    
123     //fiducial and quality flags
124     outPhoton->SetIsEB(iP->isEB());
125     outPhoton->SetIsEE(iP->isEE());
126 bendavid 1.15 outPhoton->SetIsEBGap(iP->isEBGap());
127     outPhoton->SetIsEEGap(iP->isEEGap());
128     outPhoton->SetIsEBEEGap(iP->isEBEEGap());
129 loizides 1.17 //deprecated, identical to supercluster preselection in 3_1_X, so set to true
130     outPhoton->SetIsLooseEM(true); //deprecated
131 bendavid 1.15 outPhoton->SetIsLoosePhoton((*phidLooseMap)[phRef]);
132     outPhoton->SetIsTightPhoton((*phidTightMap)[phRef]);
133 sixie 1.10
134 loizides 1.13 // make links to conversions
135 bendavid 1.15 if (iP->hasConversionTracks() && conversionMap_) {
136     reco::ConversionRefVector conversionRefs = iP->conversions();
137     for (reco::ConversionRefVector::const_iterator conversionRef =
138 loizides 1.2 conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
139     outPhoton->AddConversion(conversionMap_->GetMit(*conversionRef));
140     }
141     }
142 loizides 1.13
143     // make link to supercluster
144 bendavid 1.15 if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && iP->superCluster().isNonnull())
145     if(barrelSuperClusterMap_->HasMit(iP->superCluster())) {
146     outPhoton->SetSuperCluster(barrelSuperClusterMap_->GetMit(iP->superCluster()));
147 bendavid 1.9 } else {
148 bendavid 1.15 outPhoton->SetSuperCluster(endcapSuperClusterMap_->GetMit(iP->superCluster()));
149 bendavid 1.9 }
150 bendavid 1.1 }
151     photons_->Trim();
152     }