ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPhotons.cc
Revision: 1.26
Committed: Wed Oct 12 13:26:58 2011 UTC (13 years, 6 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025
Branch point for: Mit_025c_branch
Changes since 1.25: +2 -2 lines
Log Message:
fixing the path

File Contents

# User Rev Content
1 ceballos 1.26 // $Id: FillerPhotons.cc,v 1.25 2011/10/09 23:28:48 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.25 #include "HiggsAnalysis/HiggsToGammaGamma/interface/PhotonFix.h"
14 bendavid 1.24 #include "TSystem.h"
15 bendavid 1.1
16     using namespace std;
17     using namespace edm;
18     using namespace mithep;
19    
20 loizides 1.2 //--------------------------------------------------------------------------------------------------
21 loizides 1.12 FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, const char *name, bool active) :
22     BaseFiller(cfg,name,active),
23 bendavid 1.1 edmName_(Conf().getUntrackedParameter<string>("edmName","photons")),
24     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
25 loizides 1.7 conversionMapName_(Conf().getUntrackedParameter<string>("conversionMapName","")),
26 bendavid 1.9 barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
27     endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
28 loizides 1.17 phIDCutBasedTightName_(Conf().getUntrackedParameter<string>("phIDCutBasedTightName",
29     "PhotonIDProd:PhotonCutBasedIDTight")),
30     phIDCutBasedLooseName_(Conf().getUntrackedParameter<string>("phIDCutBasedLooseName",
31     "PhotonIDProd:PhotonCutBasedIDLoose")),
32 bendavid 1.25 enablePhotonFix_(Conf().getUntrackedParameter<bool>("enablePhotonFix")),
33 loizides 1.5 photons_(new mithep::PhotonArr(16)),
34 bendavid 1.9 conversionMap_(0),
35     barrelSuperClusterMap_(0),
36     endcapSuperClusterMap_(0)
37 bendavid 1.1 {
38 loizides 1.2 // Constructor.
39 bendavid 1.25 if (enablePhotonFix_) {
40     PhotonFix::initialiseParameters(Conf());
41     }
42    
43 bendavid 1.1 }
44    
45 loizides 1.2 //--------------------------------------------------------------------------------------------------
46 bendavid 1.1 FillerPhotons::~FillerPhotons()
47     {
48 loizides 1.2 // Destructor.
49 loizides 1.3
50     delete photons_;
51 bendavid 1.1 }
52    
53 loizides 1.2 //--------------------------------------------------------------------------------------------------
54 bendavid 1.19 void FillerPhotons::BookDataBlock(TreeWriter &tws)
55 bendavid 1.1 {
56 loizides 1.7 // Add photon branch to tree and get the map.
57 loizides 1.2
58 loizides 1.13 tws.AddBranch(mitName_,&photons_);
59     OS()->add<mithep::PhotonArr>(photons_,mitName_);
60 loizides 1.7
61 loizides 1.13 if (!conversionMapName_.empty()) {
62     conversionMap_ = OS()->get<ConversionMap>(conversionMapName_);
63     if (conversionMap_)
64     AddBranchDep(mitName_,conversionMap_->GetBrName());
65     }
66     if (!barrelSuperClusterMapName_.empty()) {
67     barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_);
68     if (barrelSuperClusterMap_)
69     AddBranchDep(mitName_,barrelSuperClusterMap_->GetBrName());
70     }
71     if (!endcapSuperClusterMapName_.empty()) {
72     endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_);
73     if (endcapSuperClusterMap_)
74     AddBranchDep(mitName_,endcapSuperClusterMap_->GetBrName());
75     }
76 bendavid 1.1 }
77    
78 loizides 1.2 //--------------------------------------------------------------------------------------------------
79 bendavid 1.1 void FillerPhotons::FillDataBlock(const edm::Event &event,
80 loizides 1.13 const edm::EventSetup &setup)
81 bendavid 1.1 {
82 loizides 1.2 // Fill photon array.
83 bendavid 1.1
84 ceballos 1.26 if (!ecorr_.IsInitialized()) ecorr_.Initialize(setup,std::string(TString("gbrph.root")));
85 bendavid 1.25 if (enablePhotonFix_) PhotonFix::initialiseGeometry(setup);
86    
87 bendavid 1.11 photons_->Delete();
88 loizides 1.4
89 loizides 1.13 // get photon collection
90 loizides 1.4 Handle<reco::PhotonCollection> hPhotonProduct;
91     GetProduct(edmName_, hPhotonProduct, event);
92     const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
93 bendavid 1.1
94 bendavid 1.15 // handles to get the photon ID information
95     Handle<edm::ValueMap<bool> > phidLooseMap;
96     GetProduct(phIDCutBasedLooseName_, phidLooseMap, event);
97     Handle<edm::ValueMap<bool> > phidTightMap;
98     GetProduct(phIDCutBasedTightName_, phidTightMap, event);
99    
100 loizides 1.2 for (reco::PhotonCollection::const_iterator iP = inPhotons.begin();
101     iP != inPhotons.end(); ++iP) {
102    
103 sixie 1.10 int photonIndex = iP - inPhotons.begin();
104 bendavid 1.15 reco::PhotonRef phRef(hPhotonProduct, photonIndex);
105 sixie 1.10
106 loizides 1.5 mithep::Photon *outPhoton = photons_->Allocate();
107 bendavid 1.15 new (outPhoton) mithep::Photon(iP->px(),iP->py(),iP->pz(),iP->energy());
108     outPhoton->SetIsConverted(iP->hasConversionTracks());
109     outPhoton->SetR9(iP->r9());
110     outPhoton->SetHadOverEm(iP->hadronicOverEm());
111     outPhoton->SetHasPixelSeed(iP->hasPixelSeed());
112 bendavid 1.16
113 bendavid 1.21 // shower shape variables
114     outPhoton->SetHcalDepth1OverEcal(iP->hadronicDepth1OverEm());
115     outPhoton->SetHcalDepth2OverEcal(iP->hadronicDepth2OverEm());
116     outPhoton->SetMaxEnergyXtal(iP->maxEnergyXtal());
117     outPhoton->SetE15(iP->e1x5());
118     outPhoton->SetE25(iP->e2x5());
119     outPhoton->SetE33(iP->e3x3());
120     outPhoton->SetE55(iP->e5x5());
121     outPhoton->SetCovEtaEta(iP->sigmaEtaEta());
122     outPhoton->SetCoviEtaiEta(iP->sigmaIetaIeta());
123    
124 bendavid 1.16 //isolation variables for dR=0.3
125     outPhoton->SetEcalRecHitIsoDr03(iP->ecalRecHitSumEtConeDR03());
126     outPhoton->SetHcalTowerSumEtDr03(iP->hcalTowerSumEtConeDR03());
127     outPhoton->SetHcalDepth1TowerSumEtDr03(iP->hcalDepth1TowerSumEtConeDR03());
128     outPhoton->SetHcalDepth2TowerSumEtDr03(iP->hcalDepth2TowerSumEtConeDR03());
129     outPhoton->SetSolidConeTrkIsoDr03(iP->trkSumPtSolidConeDR03());
130     outPhoton->SetHollowConeTrkIsoDr03(iP->trkSumPtHollowConeDR03());
131     outPhoton->SetSolidConeNTrkDr03(iP->nTrkSolidConeDR03());
132     outPhoton->SetHollowConeNTrkDr03(iP->nTrkHollowConeDR03());
133    
134     //isolation variables for dR=0.4
135     outPhoton->SetEcalRecHitIsoDr04(iP->ecalRecHitSumEtConeDR04());
136     outPhoton->SetHcalTowerSumEtDr04(iP->hcalTowerSumEtConeDR04());
137     outPhoton->SetHcalDepth1TowerSumEtDr04(iP->hcalDepth1TowerSumEtConeDR04());
138     outPhoton->SetHcalDepth2TowerSumEtDr04(iP->hcalDepth2TowerSumEtConeDR04());
139     outPhoton->SetSolidConeTrkIsoDr04(iP->trkSumPtSolidConeDR04());
140     outPhoton->SetHollowConeTrkIsoDr04(iP->trkSumPtHollowConeDR04());
141     outPhoton->SetSolidConeNTrkDr04(iP->nTrkSolidConeDR04());
142     outPhoton->SetHollowConeNTrkDr04(iP->nTrkHollowConeDR04());
143    
144 bendavid 1.23 //pflow isolation
145     outPhoton->SetPFChargedHadronIso(iP->chargedHadronIso());
146     outPhoton->SetPFChargedHadronIso(iP->neutralHadronIso());
147     outPhoton->SetPFChargedHadronIso(iP->photonIso());
148    
149 bendavid 1.16 //fiducial and quality flags
150     outPhoton->SetIsEB(iP->isEB());
151     outPhoton->SetIsEE(iP->isEE());
152 bendavid 1.15 outPhoton->SetIsEBGap(iP->isEBGap());
153     outPhoton->SetIsEEGap(iP->isEEGap());
154     outPhoton->SetIsEBEEGap(iP->isEBEEGap());
155 loizides 1.17 //deprecated, identical to supercluster preselection in 3_1_X, so set to true
156     outPhoton->SetIsLooseEM(true); //deprecated
157 bendavid 1.15 outPhoton->SetIsLoosePhoton((*phidLooseMap)[phRef]);
158     outPhoton->SetIsTightPhoton((*phidTightMap)[phRef]);
159 sixie 1.10
160 bendavid 1.22 //calo position
161     outPhoton->SetCaloPosXYZ(iP->caloPosition().x(),iP->caloPosition().y(),iP->caloPosition().z());
162    
163 loizides 1.13 // make links to conversions
164 bendavid 1.15 if (iP->hasConversionTracks() && conversionMap_) {
165     reco::ConversionRefVector conversionRefs = iP->conversions();
166     for (reco::ConversionRefVector::const_iterator conversionRef =
167 loizides 1.2 conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
168     outPhoton->AddConversion(conversionMap_->GetMit(*conversionRef));
169     }
170     }
171 loizides 1.13
172     // make link to supercluster
173 bendavid 1.20 if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && iP->superCluster().isNonnull()) {
174 bendavid 1.15 if(barrelSuperClusterMap_->HasMit(iP->superCluster())) {
175     outPhoton->SetSuperCluster(barrelSuperClusterMap_->GetMit(iP->superCluster()));
176 bendavid 1.9 } else {
177 bendavid 1.15 outPhoton->SetSuperCluster(endcapSuperClusterMap_->GetMit(iP->superCluster()));
178 bendavid 1.9 }
179 bendavid 1.20 }
180 bendavid 1.24
181     //regression energy corrections
182     std::pair<double,double> cor = ecorr_.CorrectedEnergyWithError(*iP);
183     outPhoton->SetEnergyRegr(cor.first);
184     outPhoton->SetEnergyErrRegr(cor.second);
185    
186 bendavid 1.25 //photonfix energy corrections
187     if (enablePhotonFix_) {
188     PhotonFix pfix(*iP);
189     outPhoton->SetEnergyPhoFix(pfix.fixedEnergy());
190     outPhoton->SetEnergyErrPhoFix(pfix.sigmaEnergy());
191     }
192    
193    
194 bendavid 1.1 }
195     photons_->Trim();
196     }