00001
00002
00003
00004
00005
00014
00015
00016
00017
00018
00019
00020
00022
00024 #include "RecoEgamma/PhotonIdentification/plugins/PhotonIDSimpleAnalyzer.h"
00025
00027
00029 #include "DataFormats/EgammaCandidates/interface/PhotonIDFwd.h"
00030 #include "DataFormats/EgammaCandidates/interface/PhotonID.h"
00031 #include "DataFormats/EgammaCandidates/interface/PhotonIDAssociation.h"
00032 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00033 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00034 #include "DataFormats/JetReco/interface/CaloJet.h"
00035 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00036 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00037 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00038 #include "DataFormats/DetId/interface/DetId.h"
00039 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00040 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00041 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00042 #include "Geometry/CaloTopology/interface/EcalBarrelTopology.h"
00043 #include "FWCore/Framework/interface/ESHandle.h"
00044 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00045 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00046 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00047 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00049
00051 #include "TH1F.h"
00052 #include "TH2F.h"
00053 #include "TFile.h"
00054 #include "TMath.h"
00055 #include "TTree.h"
00056
00057 using namespace std;
00058
00060
00062 PhotonIDSimpleAnalyzer::PhotonIDSimpleAnalyzer(const edm::ParameterSet& ps)
00063 {
00064
00065
00066
00067 outputFile_ = ps.getParameter<std::string>("outputFile");
00068
00069
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
00077
00078 createPhotonTTree_ = ps.getParameter<bool>("createPhotonTTree");
00079
00080
00081 rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE");
00082 }
00083
00085
00087 PhotonIDSimpleAnalyzer::~PhotonIDSimpleAnalyzer()
00088 {
00089
00090
00091
00092
00093 delete rootFile_;
00094
00095 }
00096
00098
00100 void
00101 PhotonIDSimpleAnalyzer::beginJob(edm::EventSetup const&)
00102 {
00103
00104
00105 rootFile_->cd();
00106
00107
00108
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
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
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
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
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 }
00143
00145
00147 void
00148 PhotonIDSimpleAnalyzer::analyze(const edm::Event& evt, const edm::EventSetup& es)
00149 {
00150
00151 using namespace std;
00152 using namespace edm;
00153
00154
00155 Handle<reco::PhotonCollection> photonColl;
00156 evt.getByLabel("photons", "", photonColl);
00157
00158
00159 Handle<reco::PhotonIDAssociationCollection> photonIDMapColl;
00160 evt.getByLabel("PhotonIDProd", "PhotonAssociatedID", photonIDMapColl);
00161
00162
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
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
00191
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
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
00210
00211
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
00218 h_nPassingPho_->Fill(1.0);
00219
00221
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
00240
00241 tree_PhotonAll_->Fill();
00242 }
00243
00244
00245
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
00258 h_nPassingPho_->Fill(0.0);
00259 }
00260
00261 }
00262 h_nPho_->Fill(photonCounter);
00263
00264 }
00265
00267
00269 void
00270 PhotonIDSimpleAnalyzer::endJob()
00271 {
00272
00273
00274 rootFile_->cd();
00275
00276
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
00289 h_photonEt_-> Write();
00290 h_photonEta_-> Write();
00291 h_photonPhi_-> Write();
00292 h_hadoverem_-> Write();
00293
00294
00295 h_photonScEt_-> Write();
00296 h_photonScEta_-> Write();
00297 h_photonScPhi_-> Write();
00298 h_photonScEtaWidth_->Write();
00299
00300
00301 h_photonInAnyGap_->Write();
00302 h_nPassingPho_-> Write();
00303 h_nPho_-> Write();
00304
00305
00306 rootFile_->Write();
00307 rootFile_->Close();
00308
00309 }
00310
00311
00312