#include <RecoEgamma/PhotonIdentification/test/PhotonIDSimpleAnalyzer.cc>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob (edm::EventSetup const &) |
virtual void | endJob () |
PhotonIDSimpleAnalyzer (const edm::ParameterSet &) | |
~PhotonIDSimpleAnalyzer () | |
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_ |
Classes | |
struct | struct_recPhoton |
Description: Analyzer to make a load of histograms for the improvement of the PhotonID object.
Implementation: <Notes on="" implementation>="">
Implementation: \
Definition at line 37 of file PhotonIDSimpleAnalyzer.h.
PhotonIDSimpleAnalyzer::PhotonIDSimpleAnalyzer | ( | const edm::ParameterSet & | ps | ) | [explicit] |
Definition at line 62 of file PhotonIDSimpleAnalyzer.cc.
References createPhotonTTree_, edm::ParameterSet::getParameter(), maxPhotonAbsEta_, maxPhotonHoverE_, minPhotonAbsEta_, minPhotonEt_, minPhotonR9_, outputFile_, and rootFile_.
00063 { 00064 // Read Parameters from configuration file 00065 00066 // output filename 00067 outputFile_ = ps.getParameter<std::string>("outputFile"); 00068 // Read variables that must be passed to allow a 00069 // supercluster to be placed in histograms as a photon. 00070 minPhotonEt_ = ps.getParameter<double>("minPhotonEt"); 00071 minPhotonAbsEta_ = ps.getParameter<double>("minPhotonAbsEta"); 00072 maxPhotonAbsEta_ = ps.getParameter<double>("maxPhotonAbsEta"); 00073 minPhotonR9_ = ps.getParameter<double>("minPhotonR9"); 00074 maxPhotonHoverE_ = ps.getParameter<double>("maxPhotonHoverE"); 00075 00076 // Read variable to that decidedes whether 00077 // a TTree of photons is created or not 00078 createPhotonTTree_ = ps.getParameter<bool>("createPhotonTTree"); 00079 00080 // open output file to store histograms 00081 rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE"); 00082 }
PhotonIDSimpleAnalyzer::~PhotonIDSimpleAnalyzer | ( | ) |
Definition at line 87 of file PhotonIDSimpleAnalyzer.cc.
References rootFile_.
00088 { 00089 00090 // do anything here that needs to be done at desctruction time 00091 // (e.g. close files, deallocate resources etc.) 00092 00093 delete rootFile_; 00094 00095 }
void PhotonIDSimpleAnalyzer::analyze | ( | const edm::Event & | evt, | |
const edm::EventSetup & | es | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 148 of file PhotonIDSimpleAnalyzer.cc.
References createPhotonTTree_, PhotonIDSimpleAnalyzer::struct_recPhoton::et, PhotonIDSimpleAnalyzer::struct_recPhoton::eta, edm::AssociationMap< Tag >::find(), edm::Event::getByLabel(), h_ebeeGap_, h_ebgap_, h_eeGap_, h_hadoverem_, h_isoEcalRecHit_, h_isoHcalRecHit_, h_nPassingPho_, h_nPho_, h_ntrk_hollow_, h_ntrk_solid_, h_photonEt_, h_photonEta_, h_photonInAnyGap_, h_photonPhi_, h_photonScEt_, h_photonScEta_, h_photonScEtaWidth_, h_photonScPhi_, h_r9_, h_trk_pt_hollow_, h_trk_pt_solid_, PhotonIDSimpleAnalyzer::struct_recPhoton::hadronicOverEm, i, int, PhotonIDSimpleAnalyzer::struct_recPhoton::isEBEEGap, PhotonIDSimpleAnalyzer::struct_recPhoton::isEBGap, PhotonIDSimpleAnalyzer::struct_recPhoton::isEEGap, PhotonIDSimpleAnalyzer::struct_recPhoton::isolationEcalRecHit, PhotonIDSimpleAnalyzer::struct_recPhoton::isolationHcalRecHit, PhotonIDSimpleAnalyzer::struct_recPhoton::isolationHollowTrkCone, PhotonIDSimpleAnalyzer::struct_recPhoton::isolationSolidTrkCone, maxPhotonAbsEta_, maxPhotonHoverE_, minPhotonAbsEta_, minPhotonEt_, minPhotonR9_, PhotonIDSimpleAnalyzer::struct_recPhoton::nTrkHollowCone, PhotonIDSimpleAnalyzer::struct_recPhoton::nTrkSolidCone, PhotonIDSimpleAnalyzer::struct_recPhoton::phi, photons_cfi::photons, r9, PhotonIDSimpleAnalyzer::struct_recPhoton::r9, recPhoton, std, and tree_PhotonAll_.
00149 { 00150 00151 using namespace std; 00152 using namespace edm; 00153 00154 // grab photons 00155 Handle<reco::PhotonCollection> photonColl; 00156 evt.getByLabel("photons", "", photonColl); 00157 00158 // grab PhotonId objects 00159 Handle<reco::PhotonIDAssociationCollection> photonIDMapColl; 00160 evt.getByLabel("PhotonIDProd", "PhotonAssociatedID", photonIDMapColl); 00161 00162 // create reference to the object types we are interested in 00163 const reco::PhotonCollection *photons = photonColl.product(); 00164 const reco::PhotonIDAssociationCollection *phoMap = photonIDMapColl.product(); 00165 00166 int photonCounter = 0; 00167 00168 for (int i=0; i<int(photons->size()); i++) 00169 { 00170 00171 edm::Ref<reco::PhotonCollection> photonref(photonColl, i); 00172 reco::PhotonIDAssociationCollection::const_iterator photonIter = phoMap->find(photonref); 00173 const reco::PhotonIDRef &phtn = photonIter->val; 00174 const reco::PhotonRef &pho = photonIter->key; 00175 00176 float photonEt = pho->et(); 00177 float superClusterEt = (pho->superCluster()->energy())/(cosh(pho->superCluster()->position().eta())); 00178 00179 // Only store photon candidates (SuperClusters) that pass some simple cuts 00180 bool passCuts = ( photonEt > minPhotonEt_ ) && 00181 ( fabs(pho->eta()) > minPhotonAbsEta_ ) && 00182 ( fabs(pho->eta()) < maxPhotonAbsEta_ ) && 00183 ( (phtn)->r9() > minPhotonR9_ ) && 00184 ( pho->hadronicOverEm() < maxPhotonHoverE_ ) ; 00185 00186 if ( passCuts ) 00187 { 00189 // fill histograms // 00191 // PhotonID Variables 00192 h_isoEcalRecHit_->Fill((phtn)->isolationEcalRecHit()); 00193 h_isoHcalRecHit_->Fill((phtn)->isolationHcalRecHit()); 00194 h_trk_pt_solid_ ->Fill((phtn)->isolationSolidTrkCone()); 00195 h_trk_pt_hollow_->Fill((phtn)->isolationHollowTrkCone()); 00196 h_ntrk_solid_-> Fill((phtn)->nTrkSolidCone()); 00197 h_ntrk_hollow_-> Fill((phtn)->nTrkHollowCone()); 00198 h_ebgap_-> Fill((phtn)->isEBGap()); 00199 h_eeGap_-> Fill((phtn)->isEEGap()); 00200 h_ebeeGap_-> Fill((phtn)->isEBEEGap()); 00201 h_r9_-> Fill((phtn)->r9()); 00202 00203 // Photon Variables 00204 h_photonEt_-> Fill(photonEt); 00205 h_photonEta_-> Fill(pho->eta()); 00206 h_photonPhi_-> Fill(pho->phi()); 00207 h_hadoverem_-> Fill(pho->hadronicOverEm()); 00208 00209 // Photon's SuperCluster Variables 00210 // eta is with respect to detector (not physics) vertex, 00211 // thus Et and eta are different from photon. 00212 h_photonScEt_-> Fill(superClusterEt); 00213 h_photonScEta_-> Fill(pho->superCluster()->position().eta()); 00214 h_photonScPhi_-> Fill(pho->superCluster()->position().phi()); 00215 h_photonScEtaWidth_->Fill(pho->superCluster()->etaWidth()); 00216 00217 // It passed photon cuts, mark it 00218 h_nPassingPho_->Fill(1.0); 00219 00221 // fill TTree (optional) // 00223 if ( createPhotonTTree_ ) { 00224 recPhoton.isolationEcalRecHit = (phtn)->isolationEcalRecHit(); 00225 recPhoton.isolationHcalRecHit = (phtn)->isolationHcalRecHit(); 00226 recPhoton.isolationSolidTrkCone = (phtn)->isolationSolidTrkCone(); 00227 recPhoton.isolationHollowTrkCone = (phtn)->isolationHollowTrkCone(); 00228 recPhoton.nTrkSolidCone = (phtn)->nTrkSolidCone(); 00229 recPhoton.nTrkHollowCone = (phtn)->nTrkHollowCone(); 00230 recPhoton.isEBGap = (phtn)->isEBGap(); 00231 recPhoton.isEEGap = (phtn)->isEEGap(); 00232 recPhoton.isEBEEGap = (phtn)->isEBEEGap(); 00233 recPhoton.r9 = (phtn)->r9(); 00234 recPhoton.et = pho->et(); 00235 recPhoton.eta = pho->eta(); 00236 recPhoton.phi = pho->phi(); 00237 recPhoton.hadronicOverEm = pho->hadronicOverEm(); 00238 00239 // Fill the tree (this records all the recPhoton.* since 00240 // tree_PhotonAll_ was set to point at that. 00241 tree_PhotonAll_->Fill(); 00242 } 00243 00244 // Record whether it was near any module gap. 00245 // Very convoluted at the moment. 00246 bool inAnyGap = (phtn)->isEBEEGap() || ((phtn)->isEBPho()&&(phtn)->isEBGap()) || ((phtn)->isEEPho()&&(phtn)->isEEGap()); 00247 if (inAnyGap) { 00248 h_photonInAnyGap_->Fill(1.0); 00249 } else { 00250 h_photonInAnyGap_->Fill(0.0); 00251 } 00252 00253 photonCounter++; 00254 } 00255 else 00256 { 00257 // This didn't pass photon cuts, mark it 00258 h_nPassingPho_->Fill(0.0); 00259 } 00260 00261 } // End Loop over photons 00262 h_nPho_->Fill(photonCounter); 00263 00264 }
void PhotonIDSimpleAnalyzer::beginJob | ( | edm::EventSetup const & | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 101 of file PhotonIDSimpleAnalyzer.cc.
References createPhotonTTree_, h_ebeeGap_, h_ebgap_, h_eeGap_, h_hadoverem_, h_isoEcalRecHit_, h_isoHcalRecHit_, h_nPassingPho_, h_nPho_, h_ntrk_hollow_, h_ntrk_solid_, h_photonEt_, h_photonEta_, h_photonInAnyGap_, h_photonPhi_, h_photonScEt_, h_photonScEta_, h_photonScEtaWidth_, h_photonScPhi_, h_r9_, h_trk_pt_hollow_, h_trk_pt_solid_, PhotonIDSimpleAnalyzer::struct_recPhoton::isolationEcalRecHit, Pi, recPhoton, rootFile_, and tree_PhotonAll_.
00102 { 00103 00104 // go to *OUR* rootfile 00105 rootFile_->cd(); 00106 00107 // Book Histograms 00108 // PhotonID Histograms 00109 h_isoEcalRecHit_ = new TH1F("photonEcalIso", "Ecal Rec Hit Isolation", 300, 0, 300); 00110 h_isoHcalRecHit_ = new TH1F("photonHcalIso", "Hcal Rec Hit Isolation", 300, 0, 300); 00111 h_trk_pt_solid_ = new TH1F("photonTrackSolidIso", "Sum of track pT in a cone of #DeltaR" , 300, 0, 300); 00112 h_trk_pt_hollow_ = new TH1F("photonTrackHollowIso", "Sum of track pT in a hollow cone" , 300, 0, 300); 00113 h_ntrk_solid_ = new TH1F("photonTrackCountSolid", "Number of tracks in a cone of #DeltaR", 100, 0, 100); 00114 h_ntrk_hollow_ = new TH1F("photonTrackCountHollow", "Number of tracks in a hollow cone", 100, 0, 100); 00115 h_ebgap_ = new TH1F("photonInEBgap", "Ecal Barrel gap flag", 2, -0.5, 1.5); 00116 h_eeGap_ = new TH1F("photonInEEgap", "Ecal Endcap gap flag", 2, -0.5, 1.5); 00117 h_ebeeGap_ = new TH1F("photonInEEgap", "Ecal Barrel/Endcap gap flag", 2, -0.5, 1.5); 00118 h_r9_ = new TH1F("photonR9", "R9 = E(3x3) / E(SuperCluster)", 300, 0, 3); 00119 00120 // Photon Histograms 00121 h_photonEt_ = new TH1F("photonEt", "Photon E_{T}", 200, 0, 200); 00122 h_photonEta_ = new TH1F("photonEta", "Photon #eta", 800, -4, 4); 00123 h_photonPhi_ = new TH1F("photonPhi", "Photon #phi", 628, -1.*TMath::Pi(), TMath::Pi()); 00124 h_hadoverem_ = new TH1F("photonHoverE", "Hadronic over EM", 200, 0, 1); 00125 00126 // Photon's SuperCluster Histograms 00127 h_photonScEt_ = new TH1F("photonScEt", "Photon SuperCluster E_{T}", 200, 0, 200); 00128 h_photonScEta_ = new TH1F("photonScEta", "Photon #eta", 800, -4, 4); 00129 h_photonScPhi_ = new TH1F("photonScPhi", "Photon #phi",628, -1.*TMath::Pi(), TMath::Pi()); 00130 h_photonScEtaWidth_ = new TH1F("photonScEtaWidth","#eta-width", 100, 0, .1); 00131 00132 // Composite or Other Histograms 00133 h_photonInAnyGap_ = new TH1F("photonInAnyGap", "Photon in any gap flag", 2, -0.5, 1.5); 00134 h_nPassingPho_ = new TH1F("photonPassingCount", "Total number photons (0=NotPassing, 1=Passing)", 2, -0.5, 1.5); 00135 h_nPho_ = new TH1F("photonCount", "Number of photons passing cuts in event", 10, 0, 10); 00136 00137 // Create a TTree of photons if set to 'True' in config file 00138 if ( createPhotonTTree_ ) { 00139 tree_PhotonAll_ = new TTree("TreePhotonAll", "Reconstructed Photon"); 00140 tree_PhotonAll_->Branch("recPhoton", &recPhoton.isolationEcalRecHit, "isolationEcalRecHit/F:isolationHcalRecHit:isolationSolidTrkCone:isolationHollowTrkCone:nTrkSolidCone:nTrkHollowCone:isEBGap:isEEGap:isEBEEGap:r9:et:eta:phi:hadronicOverEm"); 00141 } 00142 }
Reimplemented from edm::EDAnalyzer.
Definition at line 270 of file PhotonIDSimpleAnalyzer.cc.
References h_ebeeGap_, h_ebgap_, h_eeGap_, h_hadoverem_, h_isoEcalRecHit_, h_isoHcalRecHit_, h_nPassingPho_, h_nPho_, h_ntrk_hollow_, h_ntrk_solid_, h_photonEt_, h_photonEta_, h_photonInAnyGap_, h_photonPhi_, h_photonScEt_, h_photonScEta_, h_photonScEtaWidth_, h_photonScPhi_, h_r9_, h_trk_pt_hollow_, h_trk_pt_solid_, and rootFile_.
00271 { 00272 00273 // go to *OUR* root file and store histograms 00274 rootFile_->cd(); 00275 00276 // PhotonID Histograms 00277 h_isoEcalRecHit_->Write(); 00278 h_isoHcalRecHit_->Write(); 00279 h_trk_pt_solid_-> Write(); 00280 h_trk_pt_hollow_->Write(); 00281 h_ntrk_solid_-> Write(); 00282 h_ntrk_hollow_-> Write(); 00283 h_ebgap_-> Write(); 00284 h_eeGap_-> Write(); 00285 h_ebeeGap_-> Write(); 00286 h_r9_-> Write(); 00287 00288 // Photon Histograms 00289 h_photonEt_-> Write(); 00290 h_photonEta_-> Write(); 00291 h_photonPhi_-> Write(); 00292 h_hadoverem_-> Write(); 00293 00294 // Photon's SuperCluster Histograms 00295 h_photonScEt_-> Write(); 00296 h_photonScEta_-> Write(); 00297 h_photonScPhi_-> Write(); 00298 h_photonScEtaWidth_->Write(); 00299 00300 // Composite or Other Histograms 00301 h_photonInAnyGap_->Write(); 00302 h_nPassingPho_-> Write(); 00303 h_nPho_-> Write(); 00304 00305 // Write the root file (really writes the TTree) 00306 rootFile_->Write(); 00307 rootFile_->Close(); 00308 00309 }
Definition at line 54 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and PhotonIDSimpleAnalyzer().
TH1F* PhotonIDSimpleAnalyzer::h_ebeeGap_ [private] |
Definition at line 91 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_ebgap_ [private] |
Definition at line 89 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_eeGap_ [private] |
Definition at line 90 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_hadoverem_ [private] |
Definition at line 98 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_isoEcalRecHit_ [private] |
Definition at line 83 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_isoHcalRecHit_ [private] |
Definition at line 84 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_nPassingPho_ [private] |
Definition at line 108 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_nPho_ [private] |
Definition at line 109 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_ntrk_hollow_ [private] |
Definition at line 88 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_ntrk_solid_ [private] |
Definition at line 87 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_photonEt_ [private] |
Definition at line 95 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_photonEta_ [private] |
Definition at line 96 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_photonInAnyGap_ [private] |
Definition at line 107 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_photonPhi_ [private] |
Definition at line 97 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_photonScEt_ [private] |
Definition at line 101 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_photonScEta_ [private] |
Definition at line 102 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_photonScEtaWidth_ [private] |
Definition at line 104 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_photonScPhi_ [private] |
Definition at line 103 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_r9_ [private] |
Definition at line 92 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_trk_pt_hollow_ [private] |
Definition at line 86 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
TH1F* PhotonIDSimpleAnalyzer::h_trk_pt_solid_ [private] |
Definition at line 85 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
double PhotonIDSimpleAnalyzer::maxPhotonAbsEta_ [private] |
Definition at line 51 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), and PhotonIDSimpleAnalyzer().
double PhotonIDSimpleAnalyzer::maxPhotonHoverE_ [private] |
Definition at line 53 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), and PhotonIDSimpleAnalyzer().
double PhotonIDSimpleAnalyzer::minPhotonAbsEta_ [private] |
Definition at line 50 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), and PhotonIDSimpleAnalyzer().
double PhotonIDSimpleAnalyzer::minPhotonEt_ [private] |
Definition at line 49 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), and PhotonIDSimpleAnalyzer().
double PhotonIDSimpleAnalyzer::minPhotonR9_ [private] |
Definition at line 52 of file PhotonIDSimpleAnalyzer.h.
Referenced by analyze(), and PhotonIDSimpleAnalyzer().
std::string PhotonIDSimpleAnalyzer::outputFile_ [private] |
TFile* PhotonIDSimpleAnalyzer::rootFile_ [private] |
Definition at line 78 of file PhotonIDSimpleAnalyzer.h.
Referenced by beginJob(), endJob(), PhotonIDSimpleAnalyzer(), and ~PhotonIDSimpleAnalyzer().
TTree* PhotonIDSimpleAnalyzer::tree_PhotonAll_ [private] |