CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
PatPhotonSimpleAnalyzer Class Reference

#include <RecoEgamma/PhotonIdentification/test/PatPhotonSimpleAnalyzer.cc>

Inheritance diagram for PatPhotonSimpleAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  struct_recPhoton
 

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 PatPhotonSimpleAnalyzer (const edm::ParameterSet &)
 
 ~PatPhotonSimpleAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool createPhotonTTree_
 
TH1F * h_ebeeGap_
 
TH1F * h_ebgap_
 
TH1F * h_eeGap_
 
TH1F * h_hadoverem_
 
TH1F * h_isoEcalRecHit_
 
TH1F * h_isoHcalRecHit_
 
TH1F * h_nPassingPho_
 
TH1F * h_nPho_
 
TH1F * h_ntrk_hollow_
 
TH1F * h_ntrk_solid_
 
TH1F * h_photonEt_
 
TH1F * h_photonEta_
 
TH1F * h_photonInAnyGap_
 
TH1F * h_photonPhi_
 
TH1F * h_photonScEt_
 
TH1F * h_photonScEta_
 
TH1F * h_photonScEtaWidth_
 
TH1F * h_photonScPhi_
 
TH1F * h_r9_
 
TH1F * h_trk_pt_hollow_
 
TH1F * h_trk_pt_solid_
 
double maxPhotonAbsEta_
 
double maxPhotonHoverE_
 
double minPhotonAbsEta_
 
double minPhotonEt_
 
double minPhotonR9_
 
std::string outputFile_
 
struct_recPhoton recPhoton
 
TFile * rootFile_
 
TTree * tree_PhotonAll_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: Generate various histograms for cuts and important photon ID parameters using a data sample of photons in QCD events.

Implementation: <Notes on="" implementation>="">

Description: Analyzer to make a load of histograms for the improvement of the PhotonID object

Implementation: \

Author
: J. Stilley, A. Askew May 2008

Definition at line 37 of file PatPhotonSimpleAnalyzer.h.

Constructor & Destructor Documentation

PatPhotonSimpleAnalyzer::PatPhotonSimpleAnalyzer ( const edm::ParameterSet ps)
explicit

Definition at line 44 of file PatPhotonSimpleAnalyzer.cc.

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

45 {
46  // Read Parameters from configuration file
47 
48  // output filename
49  outputFile_ = ps.getParameter<std::string>("outputFile");
50  // Read variables that must be passed to allow a
51  // supercluster to be placed in histograms as a photon.
52  minPhotonEt_ = ps.getParameter<double>("minPhotonEt");
53  minPhotonAbsEta_ = ps.getParameter<double>("minPhotonAbsEta");
54  maxPhotonAbsEta_ = ps.getParameter<double>("maxPhotonAbsEta");
55  minPhotonR9_ = ps.getParameter<double>("minPhotonR9");
56  maxPhotonHoverE_ = ps.getParameter<double>("maxPhotonHoverE");
57 
58  // Read variable to that decidedes whether
59  // a TTree of photons is created or not
60  createPhotonTTree_ = ps.getParameter<bool>("createPhotonTTree");
61 
62  // open output file to store histograms
63  rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE");
64 }
T getParameter(std::string const &) const
PatPhotonSimpleAnalyzer::~PatPhotonSimpleAnalyzer ( )

Definition at line 69 of file PatPhotonSimpleAnalyzer.cc.

70 {
71 
72 // do anything here that needs to be done at desctruction time
73 // (e.g. close files, deallocate resources etc.)
74 
75  delete rootFile_;
76 
77 }

Member Function Documentation

void PatPhotonSimpleAnalyzer::analyze ( const edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 130 of file PatPhotonSimpleAnalyzer.cc.

References pat::Photon::ecalIso(), reco::Photon::ecalRecHitSumEtConeDR04(), reco::LeafCandidate::et(), reco::LeafCandidate::eta(), HcalObjRepresent::Fill(), edm::Event::getByLabel(), reco::Photon::hadronicOverEm(), pat::Photon::hcalIso(), reco::Photon::hcalTowerSumEtConeDR04(), i, reco::Photon::isEB(), reco::Photon::isEBEEGap(), reco::Photon::isEBGap(), reco::Photon::isEE(), reco::Photon::isEEGap(), reco::Photon::nTrkHollowConeDR04(), reco::Photon::nTrkSolidConeDR04(), reco::LeafCandidate::phi(), interactiveExample::photons, reco::Photon::r9(), pat::Photon::superCluster(), pat::Photon::trackIso(), reco::Photon::trkSumPtHollowConeDR04(), and reco::Photon::trkSumPtSolidConeDR04().

131 {
132 
133  using namespace std;
134  using namespace edm;
135 
136  // Grab pat::Photon
137  Handle< View<pat::Photon> > photonHandle;
138  evt.getByLabel("selectedLayer1Photons", photonHandle);
139  View<pat::Photon> photons = *photonHandle;
140 
141  int photonCounter = 0;
142 
143  for (int i=0; i<int(photons.size()); i++)
144  {
145 
146  pat::Photon currentPhoton = photons.at(i);
147 
148  float photonEt = currentPhoton.et();
149  float superClusterEt = (currentPhoton.superCluster()->energy())/(cosh(currentPhoton.superCluster()->position().eta()));
150 
151  // Only store photon candidates (SuperClusters) that pass some simple cuts
152  bool passCuts = ( photonEt > minPhotonEt_ ) &&
153  ( fabs(currentPhoton.eta()) > minPhotonAbsEta_ ) &&
154  ( fabs(currentPhoton.eta()) < maxPhotonAbsEta_ ) &&
155  ( currentPhoton.r9() > minPhotonR9_ ) &&
156  ( currentPhoton.hadronicOverEm() < maxPhotonHoverE_ ) ;
157 
158  if ( passCuts )
159  {
161  // fill histograms //
163  // PhotonID Variables
164  h_isoEcalRecHit_->Fill(currentPhoton.ecalRecHitSumEtConeDR04());
165  h_isoHcalRecHit_->Fill(currentPhoton.hcalTowerSumEtConeDR04());
166  h_trk_pt_solid_ ->Fill(currentPhoton.trkSumPtSolidConeDR04());
167  h_trk_pt_hollow_->Fill(currentPhoton.trkSumPtHollowConeDR04());
168  h_ntrk_solid_-> Fill(currentPhoton.nTrkSolidConeDR04());
169  h_ntrk_hollow_-> Fill(currentPhoton.nTrkHollowConeDR04());
170  h_ebgap_-> Fill(currentPhoton.isEBGap());
171  h_eeGap_-> Fill(currentPhoton.isEEGap());
172  h_ebeeGap_-> Fill(currentPhoton.isEBEEGap());
173  h_r9_-> Fill(currentPhoton.r9());
174 
175  // Photon Variables
176  h_photonEt_-> Fill(photonEt);
177  h_photonEta_-> Fill(currentPhoton.eta());
178  h_photonPhi_-> Fill(currentPhoton.phi());
179  h_hadoverem_-> Fill(currentPhoton.hadronicOverEm());
180 
181  // Photon's SuperCluster Variables
182  // eta is with respect to detector (not physics) vertex,
183  // thus Et and eta are different from photon.
184  h_photonScEt_-> Fill(superClusterEt);
185  h_photonScEta_-> Fill(currentPhoton.superCluster()->position().eta());
186  h_photonScPhi_-> Fill(currentPhoton.superCluster()->position().phi());
187  h_photonScEtaWidth_->Fill(currentPhoton.superCluster()->etaWidth());
188 
189  // It passed photon cuts, mark it
190  h_nPassingPho_->Fill(1.0);
191 
193  // fill TTree (optional) //
195  if ( createPhotonTTree_ ) {
200  recPhoton.nTrkSolidCone = currentPhoton.nTrkSolidConeDR04();
201  recPhoton.nTrkHollowCone = currentPhoton.nTrkHollowConeDR04();
202  recPhoton.isEBGap = currentPhoton.isEBGap();
203  recPhoton.isEEGap = currentPhoton.isEEGap();
204  recPhoton.isEBEEGap = currentPhoton.isEBEEGap();
205  recPhoton.r9 = currentPhoton.r9();
206  recPhoton.et = currentPhoton.et();
207  recPhoton.eta = currentPhoton.eta();
208  recPhoton.phi = currentPhoton.phi();
209  recPhoton.hadronicOverEm = currentPhoton.hadronicOverEm();
210  recPhoton.ecalIso = currentPhoton.ecalIso();
211  recPhoton.hcalIso = currentPhoton.hcalIso();
212  recPhoton.trackIso = currentPhoton.trackIso();
213 
214  // Fill the tree (this records all the recPhoton.* since
215  // tree_PhotonAll_ was set to point at that.
216  tree_PhotonAll_->Fill();
217  }
218 
219  // Record whether it was near any module gap.
220  // Very convoluted at the moment.
221  bool inAnyGap = currentPhoton.isEBEEGap() || (currentPhoton.isEB()&&currentPhoton.isEBGap()) || (currentPhoton.isEE()&&currentPhoton.isEEGap());
222  if (inAnyGap) {
223  h_photonInAnyGap_->Fill(1.0);
224  } else {
225  h_photonInAnyGap_->Fill(0.0);
226  }
227 
228  photonCounter++;
229  }
230  else
231  {
232  // This didn't pass photon cuts, mark it
233  h_nPassingPho_->Fill(0.0);
234  }
235 
236  } // End Loop over photons
237  h_nPho_->Fill(photonCounter);
238 
239 }
int i
Definition: DBlmapReader.cc:9
float hcalTowerSumEtConeDR04() const
Hcal isolation sum.
Definition: Photon.h:356
Analysis-level Photon class.
Definition: Photon.h:47
reco::SuperClusterRef superCluster() const
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
float trackIso() const
Definition: Photon.h:116
bool isEE() const
Definition: Photon.h:122
virtual double et() const
transverse energy
bool isEBGap() const
true if photon is in EB, and inside the boundaries in super crystals/modules
Definition: Photon.h:124
float trkSumPtSolidConeDR04() const
Definition: Photon.h:368
bool isEBEEGap() const
true if photon is in boundary between EB and EE
Definition: Photon.h:132
float ecalRecHitSumEtConeDR04() const
Definition: Photon.h:354
float hcalIso() const
Definition: Photon.h:122
virtual double eta() const
momentum pseudorapidity
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int nTrkHollowConeDR04() const
Definition: Photon.h:374
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
Definition: Photon.h:171
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
bool isEEGap() const
true if photon is in EE, and inside the boundaries in supercrystal/D
Definition: Photon.h:128
float ecalIso() const
Definition: Photon.h:119
int nTrkSolidConeDR04() const
Definition: Photon.h:372
bool isEB() const
Definition: Photon.h:120
float trkSumPtHollowConeDR04() const
Definition: Photon.h:370
float r9() const
Definition: Photon.h:195
virtual double phi() const
momentum azimuthal angle
void PatPhotonSimpleAnalyzer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 83 of file PatPhotonSimpleAnalyzer.cc.

References Pi.

84 {
85 
86  // go to *OUR* rootfile
87  rootFile_->cd();
88 
89  // Book Histograms
90  // PhotonID Histograms
91  h_isoEcalRecHit_ = new TH1F("photonEcalIso", "Ecal Rec Hit Isolation", 100, 0, 100);
92  h_isoHcalRecHit_ = new TH1F("photonHcalIso", "Hcal Rec Hit Isolation", 100, 0, 100);
93  h_trk_pt_solid_ = new TH1F("photonTrackSolidIso", "Sum of track pT in a cone of #DeltaR" , 100, 0, 100);
94  h_trk_pt_hollow_ = new TH1F("photonTrackHollowIso", "Sum of track pT in a hollow cone" , 100, 0, 100);
95  h_ntrk_solid_ = new TH1F("photonTrackCountSolid", "Number of tracks in a cone of #DeltaR", 100, 0, 100);
96  h_ntrk_hollow_ = new TH1F("photonTrackCountHollow", "Number of tracks in a hollow cone", 100, 0, 100);
97  h_ebgap_ = new TH1F("photonInEBgap", "Ecal Barrel gap flag", 2, -0.5, 1.5);
98  h_eeGap_ = new TH1F("photonInEEgap", "Ecal Endcap gap flag", 2, -0.5, 1.5);
99  h_ebeeGap_ = new TH1F("photonInEEgap", "Ecal Barrel/Endcap gap flag", 2, -0.5, 1.5);
100  h_r9_ = new TH1F("photonR9", "R9 = E(3x3) / E(SuperCluster)", 300, 0, 3);
101 
102  // Photon Histograms
103  h_photonEt_ = new TH1F("photonEt", "Photon E_{T}", 200, 0, 200);
104  h_photonEta_ = new TH1F("photonEta", "Photon #eta", 200, -4, 4);
105  h_photonPhi_ = new TH1F("photonPhi", "Photon #phi", 200, -1.*TMath::Pi(), TMath::Pi());
106  h_hadoverem_ = new TH1F("photonHoverE", "Hadronic over EM", 200, 0, 1);
107 
108  // Photon's SuperCluster Histograms
109  h_photonScEt_ = new TH1F("photonScEt", "Photon SuperCluster E_{T}", 200, 0, 200);
110  h_photonScEta_ = new TH1F("photonScEta", "Photon #eta", 200, -4, 4);
111  h_photonScPhi_ = new TH1F("photonScPhi", "Photon #phi", 200, -1.*TMath::Pi(), TMath::Pi());
112  h_photonScEtaWidth_ = new TH1F("photonScEtaWidth","#eta-width", 100, 0, .1);
113 
114  // Composite or Other Histograms
115  h_photonInAnyGap_ = new TH1F("photonInAnyGap", "Photon in any gap flag", 2, -0.5, 1.5);
116  h_nPassingPho_ = new TH1F("photonPassingCount", "Total number photons (0=NotPassing, 1=Passing)", 2, -0.5, 1.5);
117  h_nPho_ = new TH1F("photonCount", "Number of photons passing cuts in event", 10, 0, 10);
118 
119  // Create a TTree of photons if set to 'True' in config file
120  if ( createPhotonTTree_ ) {
121  tree_PhotonAll_ = new TTree("TreePhotonAll", "Reconstructed Photon");
122  tree_PhotonAll_->Branch("recPhoton", &recPhoton.isolationEcalRecHit, "isolationEcalRecHit/F:isolationHcalRecHit:isolationSolidTrkCone:isolationHollowTrkCone:nTrkSolidCone:nTrkHollowCone:isEBGap:isEEGap:isEBEEGap:r9:et:eta:phi:hadronicOverEm:ecalIso:hcalIso:trackIso");
123  }
124 }
const double Pi
void PatPhotonSimpleAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 245 of file PatPhotonSimpleAnalyzer.cc.

246 {
247 
248  // go to *OUR* root file and store histograms
249  rootFile_->cd();
250 
251  // PhotonID Histograms
252  h_isoEcalRecHit_->Write();
253  h_isoHcalRecHit_->Write();
254  h_trk_pt_solid_-> Write();
255  h_trk_pt_hollow_->Write();
256  h_ntrk_solid_-> Write();
257  h_ntrk_hollow_-> Write();
258  h_ebgap_-> Write();
259  h_eeGap_-> Write();
260  h_ebeeGap_-> Write();
261  h_r9_-> Write();
262 
263  // Photon Histograms
264  h_photonEt_-> Write();
265  h_photonEta_-> Write();
266  h_photonPhi_-> Write();
267  h_hadoverem_-> Write();
268 
269  // Photon's SuperCluster Histograms
270  h_photonScEt_-> Write();
271  h_photonScEta_-> Write();
272  h_photonScPhi_-> Write();
273  h_photonScEtaWidth_->Write();
274 
275  // Composite or Other Histograms
276  h_photonInAnyGap_->Write();
277  h_nPassingPho_-> Write();
278  h_nPho_-> Write();
279 
280  // Write the root file (really writes the TTree)
281  rootFile_->Write();
282  rootFile_->Close();
283 
284 }

Member Data Documentation

bool PatPhotonSimpleAnalyzer::createPhotonTTree_
private

Definition at line 54 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_ebeeGap_
private

Definition at line 94 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_ebgap_
private

Definition at line 92 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_eeGap_
private

Definition at line 93 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_hadoverem_
private

Definition at line 101 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_isoEcalRecHit_
private

Definition at line 86 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_isoHcalRecHit_
private

Definition at line 87 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_nPassingPho_
private

Definition at line 111 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_nPho_
private

Definition at line 112 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_ntrk_hollow_
private

Definition at line 91 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_ntrk_solid_
private

Definition at line 90 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_photonEt_
private

Definition at line 98 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_photonEta_
private

Definition at line 99 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_photonInAnyGap_
private

Definition at line 110 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_photonPhi_
private

Definition at line 100 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_photonScEt_
private

Definition at line 104 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_photonScEta_
private

Definition at line 105 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_photonScEtaWidth_
private

Definition at line 107 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_photonScPhi_
private

Definition at line 106 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_r9_
private

Definition at line 95 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_trk_pt_hollow_
private

Definition at line 89 of file PatPhotonSimpleAnalyzer.h.

TH1F* PatPhotonSimpleAnalyzer::h_trk_pt_solid_
private

Definition at line 88 of file PatPhotonSimpleAnalyzer.h.

double PatPhotonSimpleAnalyzer::maxPhotonAbsEta_
private

Definition at line 51 of file PatPhotonSimpleAnalyzer.h.

double PatPhotonSimpleAnalyzer::maxPhotonHoverE_
private

Definition at line 53 of file PatPhotonSimpleAnalyzer.h.

double PatPhotonSimpleAnalyzer::minPhotonAbsEta_
private

Definition at line 50 of file PatPhotonSimpleAnalyzer.h.

double PatPhotonSimpleAnalyzer::minPhotonEt_
private

Definition at line 49 of file PatPhotonSimpleAnalyzer.h.

double PatPhotonSimpleAnalyzer::minPhotonR9_
private

Definition at line 52 of file PatPhotonSimpleAnalyzer.h.

std::string PatPhotonSimpleAnalyzer::outputFile_
private

Definition at line 48 of file PatPhotonSimpleAnalyzer.h.

struct_recPhoton PatPhotonSimpleAnalyzer::recPhoton
private

Definition at line 78 of file PatPhotonSimpleAnalyzer.h.

TFile* PatPhotonSimpleAnalyzer::rootFile_
private

Definition at line 81 of file PatPhotonSimpleAnalyzer.h.

TTree* PatPhotonSimpleAnalyzer::tree_PhotonAll_
private

Definition at line 115 of file PatPhotonSimpleAnalyzer.h.