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
PhotonIDSimpleAnalyzer Class Reference

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

Inheritance diagram for PhotonIDSimpleAnalyzer:
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 ()
 
 PhotonIDSimpleAnalyzer (const edm::ParameterSet &)
 
 ~PhotonIDSimpleAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool createPhotonTTree_
 
TH1F * h_ebeeGap_
 
TH1F * h_ebetagap_
 
TH1F * h_ebphigap_
 
TH1F * h_eedeeGap_
 
TH1F * h_eeringGap_
 
TH1F * h_hadoverem_
 
TH1F * h_isoEcalRecHit_
 
TH1F * h_isoHcalRecHit_
 
TH1F * h_nPassEM_
 
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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 PhotonIDSimpleAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 65 of file PhotonIDSimpleAnalyzer.cc.

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

66 {
67  // Read Parameters from configuration file
68 
69  // output filename
70  outputFile_ = ps.getParameter<std::string>("outputFile");
71  // Read variables that must be passed to allow a
72  // supercluster to be placed in histograms as a photon.
73  minPhotonEt_ = ps.getParameter<double>("minPhotonEt");
74  minPhotonAbsEta_ = ps.getParameter<double>("minPhotonAbsEta");
75  maxPhotonAbsEta_ = ps.getParameter<double>("maxPhotonAbsEta");
76  minPhotonR9_ = ps.getParameter<double>("minPhotonR9");
77  maxPhotonHoverE_ = ps.getParameter<double>("maxPhotonHoverE");
78 
79  // Read variable to that decidedes whether
80  // a TTree of photons is created or not
81  createPhotonTTree_ = ps.getParameter<bool>("createPhotonTTree");
82 
83  // open output file to store histograms
84  rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE");
85 }
T getParameter(std::string const &) const
PhotonIDSimpleAnalyzer::~PhotonIDSimpleAnalyzer ( )

Definition at line 90 of file PhotonIDSimpleAnalyzer.cc.

91 {
92 
93 // do anything here that needs to be done at desctruction time
94 // (e.g. close files, deallocate resources etc.)
95 
96  delete rootFile_;
97 
98 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 154 of file PhotonIDSimpleAnalyzer.cc.

References HcalObjRepresent::Fill(), edm::Event::getByLabel(), and interactiveExample::photons.

155 {
156 
157  using namespace std;
158  using namespace edm;
159 
160  // grab photons
162  evt.getByLabel("photons", "", photonColl);
163 
164  Handle<edm::ValueMap<Bool_t> > loosePhotonQual;
165  evt.getByLabel("PhotonIDProd", "PhotonCutBasedIDLoose", loosePhotonQual);
166  Handle<edm::ValueMap<Bool_t> > looseEMQual;
167  evt.getByLabel("PhotonIDProd","PhotonCutBasedIDLooseEM",looseEMQual);
168  // grab PhotonId objects
169 // Handle<reco::PhotonIDAssociationCollection> photonIDMapColl;
170 // evt.getByLabel("PhotonIDProd", "PhotonAssociatedID", photonIDMapColl);
171 
172  // create reference to the object types we are interested in
173  const reco::PhotonCollection *photons = photonColl.product();
174  const edm::ValueMap<Bool_t> *phoMap = loosePhotonQual.product();
175  const edm::ValueMap<Bool_t> *lEMMap = looseEMQual.product();
176  int photonCounter = 0;
177  int idxpho=0;
178  reco::PhotonCollection::const_iterator pho;
179  for (pho = (*photons).begin(); pho!= (*photons).end(); pho++){
180 
181  edm::Ref<reco::PhotonCollection> photonref(photonColl, idxpho);
182  //reco::PhotonIDAssociationCollection::const_iterator photonIter = phoMap->find(photonref);
183  //const reco::PhotonIDRef &phtn = photonIter->val;
184  //const reco::PhotonRef &pho = photonIter->key;
185 
186  float photonEt = pho->et();
187  float superClusterEt = (pho->superCluster()->energy())/(cosh(pho->superCluster()->position().eta()));
188  Bool_t LoosePhotonQu = (*phoMap)[photonref];
189  h_nPassingPho_->Fill(LoosePhotonQu);
190  Bool_t LooseEMQu = (*lEMMap)[photonref];
191  h_nPassEM_->Fill(LooseEMQu);
192  // Only store photon candidates (SuperClusters) that pass some simple cuts
193  bool passCuts = ( photonEt > minPhotonEt_ ) &&
194  ( fabs(pho->eta()) > minPhotonAbsEta_ ) &&
195  ( fabs(pho->eta()) < maxPhotonAbsEta_ ) &&
196  ( pho->r9() > minPhotonR9_ ) &&
197  ( pho->hadronicOverEm() < maxPhotonHoverE_ ) ;
198 
199  if ( passCuts )
200  {
202  // fill histograms //
204  // PhotonID Variables
205  h_isoEcalRecHit_->Fill(pho->ecalRecHitSumEtConeDR04());
206  h_isoHcalRecHit_->Fill(pho->hcalTowerSumEtConeDR04());
207  h_trk_pt_solid_ ->Fill(pho->trkSumPtSolidConeDR04());
208  h_trk_pt_hollow_->Fill(pho->trkSumPtHollowConeDR04());
209  h_ntrk_solid_-> Fill(pho->nTrkSolidConeDR04());
210  h_ntrk_hollow_-> Fill(pho->nTrkHollowConeDR04());
211  h_ebetagap_-> Fill(pho->isEBEtaGap());
212  h_ebphigap_-> Fill(pho->isEBPhiGap());
213  h_eeringGap_-> Fill(pho->isEERingGap());
214  h_eedeeGap_-> Fill(pho->isEEDeeGap());
215  h_ebeeGap_-> Fill(pho->isEBEEGap());
216  h_r9_-> Fill(pho->r9());
217 
218  // Photon Variables
219  h_photonEt_-> Fill(photonEt);
220  h_photonEta_-> Fill(pho->eta());
221  h_photonPhi_-> Fill(pho->phi());
222  h_hadoverem_-> Fill(pho->hadronicOverEm());
223 
224  // Photon's SuperCluster Variables
225  // eta is with respect to detector (not physics) vertex,
226  // thus Et and eta are different from photon.
227  h_photonScEt_-> Fill(superClusterEt);
228  h_photonScEta_-> Fill(pho->superCluster()->position().eta());
229  h_photonScPhi_-> Fill(pho->superCluster()->position().phi());
230  h_photonScEtaWidth_->Fill(pho->superCluster()->etaWidth());
231 
232  // It passed photon cuts, mark it
233 
235  // fill TTree (optional) //
237  if ( createPhotonTTree_ ) {
238  recPhoton.isolationEcalRecHit = pho->ecalRecHitSumEtConeDR04();
239  recPhoton.isolationHcalRecHit = pho->hcalTowerSumEtConeDR04();
240  recPhoton.isolationSolidTrkCone = pho->trkSumPtSolidConeDR04();
241  recPhoton.isolationHollowTrkCone = pho->trkSumPtHollowConeDR04();
242  recPhoton.nTrkSolidCone = pho->nTrkSolidConeDR04();
243  recPhoton.nTrkHollowCone = pho->nTrkHollowConeDR04();
244  recPhoton.isEBEtaGap = pho->isEBEtaGap();
245  recPhoton.isEBPhiGap = pho->isEBPhiGap();
246  recPhoton.isEERingGap = pho->isEERingGap();
247  recPhoton.isEEDeeGap = pho->isEEDeeGap();
248  recPhoton.isEBEEGap = pho->isEBEEGap();
249  recPhoton.r9 = pho->r9();
250  recPhoton.et = pho->et();
251  recPhoton.eta = pho->eta();
252  recPhoton.phi = pho->phi();
253  recPhoton.hadronicOverEm = pho->hadronicOverEm();
254 
255  // Fill the tree (this records all the recPhoton.* since
256  // tree_PhotonAll_ was set to point at that.
257  tree_PhotonAll_->Fill();
258  }
259 
260  // Record whether it was near any module gap.
261  // Very convoluted at the moment.
262  bool inAnyGap = pho->isEBEEGap() || (pho->isEB()&&pho->isEBEtaGap()) ||(pho->isEB()&&pho->isEBPhiGap()) || (pho->isEE()&&pho->isEERingGap()) || (pho->isEE()&&pho->isEEDeeGap()) ;
263  if (inAnyGap) {
264  h_photonInAnyGap_->Fill(1.0);
265  } else {
266  h_photonInAnyGap_->Fill(0.0);
267  }
268 
269  photonCounter++;
270  }
271  else
272  {
273  // This didn't pass photon cuts, mark it
274 
275  }
276  idxpho++;
277  } // End Loop over photons
278  h_nPho_->Fill(photonCounter);
279 
280 }
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
void PhotonIDSimpleAnalyzer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 104 of file PhotonIDSimpleAnalyzer.cc.

References Pi.

105 {
106 
107  // go to *OUR* rootfile
108  rootFile_->cd();
109 
110  // Book Histograms
111  // PhotonID Histograms
112  h_isoEcalRecHit_ = new TH1F("photonEcalIso", "Ecal Rec Hit Isolation", 300, 0, 300);
113  h_isoHcalRecHit_ = new TH1F("photonHcalIso", "Hcal Rec Hit Isolation", 300, 0, 300);
114  h_trk_pt_solid_ = new TH1F("photonTrackSolidIso", "Sum of track pT in a cone of #DeltaR" , 300, 0, 300);
115  h_trk_pt_hollow_ = new TH1F("photonTrackHollowIso", "Sum of track pT in a hollow cone" , 300, 0, 300);
116  h_ntrk_solid_ = new TH1F("photonTrackCountSolid", "Number of tracks in a cone of #DeltaR", 100, 0, 100);
117  h_ntrk_hollow_ = new TH1F("photonTrackCountHollow", "Number of tracks in a hollow cone", 100, 0, 100);
118  h_ebetagap_ = new TH1F("photonInEBEtagap", "Ecal Barrel eta gap flag", 2, -0.5, 1.5);
119  h_ebphigap_ = new TH1F("photonInEBEtagap", "Ecal Barrel phi gap flag", 2, -0.5, 1.5);
120  h_eeringGap_ = new TH1F("photonInEERinggap", "Ecal Endcap ring gap flag", 2, -0.5, 1.5);
121  h_eedeeGap_ = new TH1F("photonInEEDeegap", "Ecal Endcap dee gap flag", 2, -0.5, 1.5);
122  h_ebeeGap_ = new TH1F("photonInEEgap", "Ecal Barrel/Endcap gap flag", 2, -0.5, 1.5);
123  h_r9_ = new TH1F("photonR9", "R9 = E(3x3) / E(SuperCluster)", 300, 0, 3);
124 
125  // Photon Histograms
126  h_photonEt_ = new TH1F("photonEt", "Photon E_{T}", 200, 0, 200);
127  h_photonEta_ = new TH1F("photonEta", "Photon #eta", 800, -4, 4);
128  h_photonPhi_ = new TH1F("photonPhi", "Photon #phi", 628, -1.*TMath::Pi(), TMath::Pi());
129  h_hadoverem_ = new TH1F("photonHoverE", "Hadronic over EM", 200, 0, 1);
130 
131  // Photon's SuperCluster Histograms
132  h_photonScEt_ = new TH1F("photonScEt", "Photon SuperCluster E_{T}", 200, 0, 200);
133  h_photonScEta_ = new TH1F("photonScEta", "Photon #eta", 800, -4, 4);
134  h_photonScPhi_ = new TH1F("photonScPhi", "Photon #phi",628, -1.*TMath::Pi(), TMath::Pi());
135  h_photonScEtaWidth_ = new TH1F("photonScEtaWidth","#eta-width", 100, 0, .1);
136 
137  // Composite or Other Histograms
138  h_photonInAnyGap_ = new TH1F("photonInAnyGap", "Photon in any gap flag", 2, -0.5, 1.5);
139  h_nPassingPho_ = new TH1F("photonLoosePhoton", "Total number photons (0=NotPassing, 1=Passing)", 2, -0.5, 1.5);
140  h_nPassEM_ = new TH1F("photonLooseEM", "Total number photons (0=NotPassing, 1=Passing)", 2, -0.5, 1.5);
141  h_nPho_ = new TH1F("photonCount", "Number of photons passing cuts in event", 10, 0, 10);
142 
143  // Create a TTree of photons if set to 'True' in config file
144  if ( createPhotonTTree_ ) {
145  tree_PhotonAll_ = new TTree("TreePhotonAll", "Reconstructed Photon");
146  tree_PhotonAll_->Branch("recPhoton", &recPhoton.isolationEcalRecHit, "isolationEcalRecHit/F:isolationHcalRecHit:isolationSolidTrkCone:isolationHollowTrkCone:nTrkSolidCone:nTrkHollowCone:isEBGap:isEEGap:isEBEEGap:r9:et:eta:phi:hadronicOverEm");
147  }
148 }
const double Pi
void PhotonIDSimpleAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 286 of file PhotonIDSimpleAnalyzer.cc.

287 {
288 
289  // go to *OUR* root file and store histograms
290  rootFile_->cd();
291 
292  // PhotonID Histograms
293  h_isoEcalRecHit_->Write();
294  h_isoHcalRecHit_->Write();
295  h_trk_pt_solid_-> Write();
296  h_trk_pt_hollow_->Write();
297  h_ntrk_solid_-> Write();
298  h_ntrk_hollow_-> Write();
299  h_ebetagap_-> Write();
300  h_ebphigap_-> Write();
301  h_eeringGap_-> Write();
302  h_eedeeGap_-> Write();
303  h_ebeeGap_-> Write();
304  h_r9_-> Write();
305 
306  // Photon Histograms
307  h_photonEt_-> Write();
308  h_photonEta_-> Write();
309  h_photonPhi_-> Write();
310  h_hadoverem_-> Write();
311 
312  // Photon's SuperCluster Histograms
313  h_photonScEt_-> Write();
314  h_photonScEta_-> Write();
315  h_photonScPhi_-> Write();
316  h_photonScEtaWidth_->Write();
317 
318  // Composite or Other Histograms
319  h_photonInAnyGap_->Write();
320  h_nPassingPho_-> Write();
321  h_nPassEM_-> Write();
322  h_nPho_-> Write();
323 
324  // Write the root file (really writes the TTree)
325  rootFile_->Write();
326  rootFile_->Close();
327 
328 }

Member Data Documentation

bool PhotonIDSimpleAnalyzer::createPhotonTTree_
private

Definition at line 54 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_ebeeGap_
private

Definition at line 95 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_ebetagap_
private

Definition at line 91 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_ebphigap_
private

Definition at line 92 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_eedeeGap_
private

Definition at line 94 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_eeringGap_
private

Definition at line 93 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_hadoverem_
private

Definition at line 102 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_isoEcalRecHit_
private

Definition at line 85 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_isoHcalRecHit_
private

Definition at line 86 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_nPassEM_
private

Definition at line 113 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_nPassingPho_
private

Definition at line 112 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_nPho_
private

Definition at line 114 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_ntrk_hollow_
private

Definition at line 90 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_ntrk_solid_
private

Definition at line 89 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_photonEt_
private

Definition at line 99 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_photonEta_
private

Definition at line 100 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_photonInAnyGap_
private

Definition at line 111 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_photonPhi_
private

Definition at line 101 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_photonScEt_
private

Definition at line 105 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_photonScEta_
private

Definition at line 106 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_photonScEtaWidth_
private

Definition at line 108 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_photonScPhi_
private

Definition at line 107 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_r9_
private

Definition at line 96 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_trk_pt_hollow_
private

Definition at line 88 of file PhotonIDSimpleAnalyzer.h.

TH1F* PhotonIDSimpleAnalyzer::h_trk_pt_solid_
private

Definition at line 87 of file PhotonIDSimpleAnalyzer.h.

double PhotonIDSimpleAnalyzer::maxPhotonAbsEta_
private

Definition at line 51 of file PhotonIDSimpleAnalyzer.h.

double PhotonIDSimpleAnalyzer::maxPhotonHoverE_
private

Definition at line 53 of file PhotonIDSimpleAnalyzer.h.

double PhotonIDSimpleAnalyzer::minPhotonAbsEta_
private

Definition at line 50 of file PhotonIDSimpleAnalyzer.h.

double PhotonIDSimpleAnalyzer::minPhotonEt_
private

Definition at line 49 of file PhotonIDSimpleAnalyzer.h.

double PhotonIDSimpleAnalyzer::minPhotonR9_
private

Definition at line 52 of file PhotonIDSimpleAnalyzer.h.

std::string PhotonIDSimpleAnalyzer::outputFile_
private

Definition at line 48 of file PhotonIDSimpleAnalyzer.h.

struct_recPhoton PhotonIDSimpleAnalyzer::recPhoton
private

Definition at line 77 of file PhotonIDSimpleAnalyzer.h.

TFile* PhotonIDSimpleAnalyzer::rootFile_
private

Definition at line 80 of file PhotonIDSimpleAnalyzer.h.

TTree* PhotonIDSimpleAnalyzer::tree_PhotonAll_
private

Definition at line 117 of file PhotonIDSimpleAnalyzer.h.