CMS 3D CMS Logo

Classes | Public Member Functions | Private Attributes

PatPhotonSimpleAnalyzer Class Reference

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

Inheritance diagram for PatPhotonSimpleAnalyzer:
edm::EDAnalyzer

List of all members.

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 ()

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_

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.

{
  // Read Parameters from configuration file

  // output filename
  outputFile_   = ps.getParameter<std::string>("outputFile");
  // Read variables that must be passed to allow a
  //  supercluster to be placed in histograms as a photon.
  minPhotonEt_     = ps.getParameter<double>("minPhotonEt");
  minPhotonAbsEta_ = ps.getParameter<double>("minPhotonAbsEta");
  maxPhotonAbsEta_ = ps.getParameter<double>("maxPhotonAbsEta");
  minPhotonR9_     = ps.getParameter<double>("minPhotonR9");
  maxPhotonHoverE_ = ps.getParameter<double>("maxPhotonHoverE");

  // Read variable to that decidedes whether
  // a TTree of photons is created or not
  createPhotonTTree_ = ps.getParameter<bool>("createPhotonTTree");

  // open output file to store histograms
  rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE");
}
PatPhotonSimpleAnalyzer::~PatPhotonSimpleAnalyzer ( )

Definition at line 69 of file PatPhotonSimpleAnalyzer.cc.

{

// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)

  delete rootFile_;

}

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().

{

  using namespace std;
  using namespace edm;

  // Grab pat::Photon
  Handle< View<pat::Photon> >  photonHandle;
  evt.getByLabel("selectedLayer1Photons", photonHandle);
  View<pat::Photon> photons = *photonHandle;

  int photonCounter = 0;

  for (int i=0; i<int(photons.size()); i++)
  {

    pat::Photon currentPhoton = photons.at(i);

    float photonEt       = currentPhoton.et();
    float superClusterEt = (currentPhoton.superCluster()->energy())/(cosh(currentPhoton.superCluster()->position().eta()));

    // Only store photon candidates (SuperClusters) that pass some simple cuts
    bool passCuts = (              photonEt > minPhotonEt_     ) &&
                    (      fabs(currentPhoton.eta()) > minPhotonAbsEta_ ) &&
                    (      fabs(currentPhoton.eta()) < maxPhotonAbsEta_ ) &&
                    (          currentPhoton.r9() > minPhotonR9_     ) &&
                    ( currentPhoton.hadronicOverEm() < maxPhotonHoverE_ ) ;

    if ( passCuts )
    {
      //                fill histograms                    //
      // PhotonID Variables
      h_isoEcalRecHit_->Fill(currentPhoton.ecalRecHitSumEtConeDR04());
      h_isoHcalRecHit_->Fill(currentPhoton.hcalTowerSumEtConeDR04());
      h_trk_pt_solid_ ->Fill(currentPhoton.trkSumPtSolidConeDR04());
      h_trk_pt_hollow_->Fill(currentPhoton.trkSumPtHollowConeDR04());
      h_ntrk_solid_->   Fill(currentPhoton.nTrkSolidConeDR04());
      h_ntrk_hollow_->  Fill(currentPhoton.nTrkHollowConeDR04());
      h_ebgap_->        Fill(currentPhoton.isEBGap());
      h_eeGap_->        Fill(currentPhoton.isEEGap());
      h_ebeeGap_->      Fill(currentPhoton.isEBEEGap());
      h_r9_->           Fill(currentPhoton.r9());

      // Photon Variables
      h_photonEt_->  Fill(photonEt);
      h_photonEta_-> Fill(currentPhoton.eta());
      h_photonPhi_-> Fill(currentPhoton.phi());
      h_hadoverem_-> Fill(currentPhoton.hadronicOverEm());

      // Photon's SuperCluster Variables
      // eta is with respect to detector (not physics) vertex,
      // thus Et and eta are different from photon.
      h_photonScEt_->      Fill(superClusterEt);
      h_photonScEta_->     Fill(currentPhoton.superCluster()->position().eta());
      h_photonScPhi_->     Fill(currentPhoton.superCluster()->position().phi());
      h_photonScEtaWidth_->Fill(currentPhoton.superCluster()->etaWidth());

      // It passed photon cuts, mark it
      h_nPassingPho_->Fill(1.0);

      //                fill TTree (optional)              //
      if ( createPhotonTTree_ ) {
        recPhoton.isolationEcalRecHit    = currentPhoton.ecalRecHitSumEtConeDR04();
        recPhoton.isolationHcalRecHit    = currentPhoton.hcalTowerSumEtConeDR04();
        recPhoton.isolationSolidTrkCone  = currentPhoton.trkSumPtSolidConeDR04();
        recPhoton.isolationHollowTrkCone = currentPhoton.trkSumPtHollowConeDR04();
        recPhoton.nTrkSolidCone          = currentPhoton.nTrkSolidConeDR04();
        recPhoton.nTrkHollowCone         = currentPhoton.nTrkHollowConeDR04();
        recPhoton.isEBGap                = currentPhoton.isEBGap();
        recPhoton.isEEGap                = currentPhoton.isEEGap();
        recPhoton.isEBEEGap              = currentPhoton.isEBEEGap();
        recPhoton.r9                     = currentPhoton.r9();
        recPhoton.et                     = currentPhoton.et();
        recPhoton.eta                    = currentPhoton.eta();
        recPhoton.phi                    = currentPhoton.phi();
        recPhoton.hadronicOverEm         = currentPhoton.hadronicOverEm();
        recPhoton.ecalIso                = currentPhoton.ecalIso();
        recPhoton.hcalIso                = currentPhoton.hcalIso();
        recPhoton.trackIso               = currentPhoton.trackIso();

        // Fill the tree (this records all the recPhoton.* since
        // tree_PhotonAll_ was set to point at that.
        tree_PhotonAll_->Fill();
      }

      // Record whether it was near any module gap.
      // Very convoluted at the moment.
      bool inAnyGap = currentPhoton.isEBEEGap() || (currentPhoton.isEB()&&currentPhoton.isEBGap()) || (currentPhoton.isEE()&&currentPhoton.isEEGap());
      if (inAnyGap) {
        h_photonInAnyGap_->Fill(1.0);
      } else {
        h_photonInAnyGap_->Fill(0.0);
      }

      photonCounter++;
    }
    else
    {
      // This didn't pass photon cuts, mark it
      h_nPassingPho_->Fill(0.0);
    }

  } // End Loop over photons
  h_nPho_->Fill(photonCounter);

}
void PatPhotonSimpleAnalyzer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 83 of file PatPhotonSimpleAnalyzer.cc.

References Pi.

{

  // go to *OUR* rootfile
  rootFile_->cd();

  // Book Histograms
  // PhotonID Histograms
  h_isoEcalRecHit_ = new TH1F("photonEcalIso",          "Ecal Rec Hit Isolation", 100, 0, 100);
  h_isoHcalRecHit_ = new TH1F("photonHcalIso",          "Hcal Rec Hit Isolation", 100, 0, 100);
  h_trk_pt_solid_  = new TH1F("photonTrackSolidIso",    "Sum of track pT in a cone of #DeltaR" , 100, 0, 100);
  h_trk_pt_hollow_ = new TH1F("photonTrackHollowIso",   "Sum of track pT in a hollow cone" ,     100, 0, 100);
  h_ntrk_solid_    = new TH1F("photonTrackCountSolid",  "Number of tracks in a cone of #DeltaR", 100, 0, 100);
  h_ntrk_hollow_   = new TH1F("photonTrackCountHollow", "Number of tracks in a hollow cone",     100, 0, 100);
  h_ebgap_         = new TH1F("photonInEBgap",          "Ecal Barrel gap flag",  2, -0.5, 1.5);
  h_eeGap_         = new TH1F("photonInEEgap",          "Ecal Endcap gap flag",  2, -0.5, 1.5);
  h_ebeeGap_       = new TH1F("photonInEEgap",          "Ecal Barrel/Endcap gap flag",  2, -0.5, 1.5);
  h_r9_            = new TH1F("photonR9",               "R9 = E(3x3) / E(SuperCluster)", 300, 0, 3);

  // Photon Histograms
  h_photonEt_      = new TH1F("photonEt",     "Photon E_{T}",  200,  0, 200);
  h_photonEta_     = new TH1F("photonEta",    "Photon #eta",   200, -4,   4);
  h_photonPhi_     = new TH1F("photonPhi",    "Photon #phi",   200, -1.*TMath::Pi(), TMath::Pi());
  h_hadoverem_     = new TH1F("photonHoverE", "Hadronic over EM", 200, 0, 1);

  // Photon's SuperCluster Histograms
  h_photonScEt_       = new TH1F("photonScEt",  "Photon SuperCluster E_{T}", 200,  0, 200);
  h_photonScEta_      = new TH1F("photonScEta", "Photon #eta",               200, -4,   4);
  h_photonScPhi_      = new TH1F("photonScPhi", "Photon #phi", 200, -1.*TMath::Pi(), TMath::Pi());
  h_photonScEtaWidth_ = new TH1F("photonScEtaWidth","#eta-width",            100,  0,  .1);

  // Composite or Other Histograms
  h_photonInAnyGap_   = new TH1F("photonInAnyGap",     "Photon in any gap flag",  2, -0.5, 1.5);
  h_nPassingPho_      = new TH1F("photonPassingCount", "Total number photons (0=NotPassing, 1=Passing)", 2, -0.5, 1.5);
  h_nPho_             = new TH1F("photonCount",        "Number of photons passing cuts in event",  10,  0,  10);

  // Create a TTree of photons if set to 'True' in config file
  if ( createPhotonTTree_ ) {
    tree_PhotonAll_     = new TTree("TreePhotonAll", "Reconstructed Photon");
    tree_PhotonAll_->Branch("recPhoton", &recPhoton.isolationEcalRecHit, "isolationEcalRecHit/F:isolationHcalRecHit:isolationSolidTrkCone:isolationHollowTrkCone:nTrkSolidCone:nTrkHollowCone:isEBGap:isEEGap:isEBEEGap:r9:et:eta:phi:hadronicOverEm:ecalIso:hcalIso:trackIso");
  }
}
void PatPhotonSimpleAnalyzer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 245 of file PatPhotonSimpleAnalyzer.cc.

{

  // go to *OUR* root file and store histograms
  rootFile_->cd();

  // PhotonID Histograms
  h_isoEcalRecHit_->Write();
  h_isoHcalRecHit_->Write();
  h_trk_pt_solid_-> Write();
  h_trk_pt_hollow_->Write();
  h_ntrk_solid_->   Write();
  h_ntrk_hollow_->  Write();
  h_ebgap_->     Write();
  h_eeGap_->     Write();
  h_ebeeGap_->   Write();
  h_r9_->        Write();

  // Photon Histograms
  h_photonEt_->  Write();
  h_photonEta_-> Write();
  h_photonPhi_-> Write();
  h_hadoverem_-> Write();

  // Photon's SuperCluster Histograms
  h_photonScEt_->      Write();
  h_photonScEta_->     Write();
  h_photonScPhi_->     Write();
  h_photonScEtaWidth_->Write();

  // Composite or Other Histograms
  h_photonInAnyGap_->Write();
  h_nPassingPho_->   Write();
  h_nPho_->          Write();

  // Write the root file (really writes the TTree)
  rootFile_->Write();
  rootFile_->Close();

}

Member Data Documentation

Definition at line 54 of file PatPhotonSimpleAnalyzer.h.

Definition at line 94 of file PatPhotonSimpleAnalyzer.h.

Definition at line 92 of file PatPhotonSimpleAnalyzer.h.

Definition at line 93 of file PatPhotonSimpleAnalyzer.h.

Definition at line 101 of file PatPhotonSimpleAnalyzer.h.

Definition at line 86 of file PatPhotonSimpleAnalyzer.h.

Definition at line 87 of file PatPhotonSimpleAnalyzer.h.

Definition at line 111 of file PatPhotonSimpleAnalyzer.h.

Definition at line 112 of file PatPhotonSimpleAnalyzer.h.

Definition at line 91 of file PatPhotonSimpleAnalyzer.h.

Definition at line 90 of file PatPhotonSimpleAnalyzer.h.

Definition at line 98 of file PatPhotonSimpleAnalyzer.h.

Definition at line 99 of file PatPhotonSimpleAnalyzer.h.

Definition at line 110 of file PatPhotonSimpleAnalyzer.h.

Definition at line 100 of file PatPhotonSimpleAnalyzer.h.

Definition at line 104 of file PatPhotonSimpleAnalyzer.h.

Definition at line 105 of file PatPhotonSimpleAnalyzer.h.

Definition at line 107 of file PatPhotonSimpleAnalyzer.h.

Definition at line 106 of file PatPhotonSimpleAnalyzer.h.

Definition at line 95 of file PatPhotonSimpleAnalyzer.h.

Definition at line 89 of file PatPhotonSimpleAnalyzer.h.

Definition at line 88 of file PatPhotonSimpleAnalyzer.h.

Definition at line 51 of file PatPhotonSimpleAnalyzer.h.

Definition at line 53 of file PatPhotonSimpleAnalyzer.h.

Definition at line 50 of file PatPhotonSimpleAnalyzer.h.

Definition at line 49 of file PatPhotonSimpleAnalyzer.h.

Definition at line 52 of file PatPhotonSimpleAnalyzer.h.

std::string PatPhotonSimpleAnalyzer::outputFile_ [private]

Definition at line 48 of file PatPhotonSimpleAnalyzer.h.

Definition at line 78 of file PatPhotonSimpleAnalyzer.h.

Definition at line 81 of file PatPhotonSimpleAnalyzer.h.

Definition at line 115 of file PatPhotonSimpleAnalyzer.h.