CMS 3D CMS Logo

Public Member Functions | Private Attributes

ggPFPhotonAnalyzer Class Reference

#include <ggPFPhotonAnalyzer.h>

Inheritance diagram for ggPFPhotonAnalyzer:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &es)
virtual void beginRun (const edm::Run &r, const edm::EventSetup &c)
virtual void endJob ()
 ggPFPhotonAnalyzer (const edm::ParameterSet &iConfig)
 ~ggPFPhotonAnalyzer ()

Private Attributes

edm::InputTag beamSpotCollection_
edm::InputTag ebReducedRecHitCollection_
edm::InputTag eeReducedRecHitCollection_
edm::InputTag esRecHitCollection_
const CaloSubdetectorGeometrygeomBar_
const CaloSubdetectorGeometrygeomEnd_
int hasSLConv_
int isConv_
int isMatch_
float MustE_
float MustEOut_
TTree * pf
TTree * pfclus
float PFClusRMS_
float PFClusRMSMust_
float PFdEta_
float PFdPhi_
edm::InputTag PFElectronTag_
const GBRForestPFLCBarrel_
const GBRForestPFLCEndcap_
float PFLowCE_
edm::InputTag pfPartTag_
float PFPhoECorr_
edm::InputTag PFPhotonTag_
float PFPS1_
float PFPS2_
float recoPFEnergy_
edm::InputTag recoPhotonTag_
float SCRawE_
TFile * tf1
float VtxZ_
float VtxZErr_

Detailed Description

Definition at line 23 of file ggPFPhotonAnalyzer.h.


Constructor & Destructor Documentation

ggPFPhotonAnalyzer::ggPFPhotonAnalyzer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 5 of file ggPFPhotonAnalyzer.cc.

References beamSpotCollection_, ebReducedRecHitCollection_, eeReducedRecHitCollection_, esRecHitCollection_, edm::ParameterSet::getParameter(), hasSLConv_, isConv_, isMatch_, MustE_, MustEOut_, pf, pfclus, PFClusRMS_, PFClusRMSMust_, PFdEta_, PFdPhi_, PFElectronTag_, PFLCBarrel_, PFLCEndcap_, PFLowCE_, pfPartTag_, PFPhoECorr_, PFPhotonTag_, PFPS1_, PFPS2_, recoPFEnergy_, recoPhotonTag_, SCRawE_, tf1, VtxZ_, and VtxZErr_.

                                                                    {
  PFPhotonTag_=iConfig.getParameter<InputTag>("PFPhotons");
  PFElectronTag_=iConfig.getParameter<InputTag>("PFElectrons");
  
  recoPhotonTag_=iConfig.getParameter<InputTag>("Photons");
  ebReducedRecHitCollection_=iConfig.getParameter<InputTag>("ebReducedRecHitCollection");
  eeReducedRecHitCollection_=iConfig.getParameter<InputTag>("eeReducedRecHitCollection");
  esRecHitCollection_=iConfig.getParameter<InputTag>("esRecHitCollection");
  beamSpotCollection_ =iConfig.getParameter<InputTag>("BeamSpotCollection");
  pfPartTag_=iConfig.getParameter<InputTag>("PFParticles");
  TFile *fgbr1 = new TFile("/afs/cern.ch/work/r/rpatel/public/TMVARegressionBarrelLC.root","READ");
  TFile *fgbr2 = new TFile("/afs/cern.ch/work/r/rpatel/public/TMVARegressionEndCapLC.root","READ");
  PFLCBarrel_=(const GBRForest*)fgbr1->Get("PFLCorrEB");
  PFLCEndcap_=(const GBRForest*)fgbr2->Get("PFLCorrEE");
  tf1=new TFile("PF_test.root", "RECREATE");
  pf=new TTree("pf", "PFPhotons");
  pfclus=new TTree("pflcus", "PFClusters");
  pf->Branch("isConv", &isConv_, "isConv/I");
  pf->Branch("hasSLConv", &hasSLConv_, "hasSLConv/I");
  pf->Branch("isMatch", &isMatch_, "isMatch/I");
  pf->Branch("PFPS1", &PFPS1_, "PFPS1/F");
  pf->Branch("PFPS2", &PFPS2_, "PFPS2/F");
  pf->Branch("MustE", &MustE_, "MustE/F");
  pf->Branch("MustEOut", &MustEOut_, "MustEOut/F");
  pf->Branch("PFLowCE", &PFLowCE_, "PFLowCE/F"); 
  pf->Branch("PFdEta", &PFdEta_, "PFdEta/F");
  pf->Branch("PFdPhi", &PFdPhi_, "PFdPhi/F"); 
  pf->Branch("PFClusRMS", &PFClusRMS_, "PFClusRMS/F"); 
  pf->Branch("PFClusRMSMust", &PFClusRMSMust_, "PFClusRMSMust/F"); 
  pf->Branch("VtxZ", &VtxZ_, "VtxZ/F"); 
  pf->Branch("VtxZErr", &VtxZErr_, "VtxZErr/F"); 
  pf->Branch("PFPhoECorr", &PFPhoECorr_, "PFPhoECorr/F"); 
  pf->Branch("recoPFEnergy", &recoPFEnergy_, "recoPFEnergy/F"); 
  pf->Branch("SCRawE", &SCRawE_, "SCRawE");
}
ggPFPhotonAnalyzer::~ggPFPhotonAnalyzer ( )

Definition at line 41 of file ggPFPhotonAnalyzer.cc.

{}

Member Function Documentation

void ggPFPhotonAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup es 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 48 of file ggPFPhotonAnalyzer.cc.

References beamSpotCollection_, ebReducedRecHitCollection_, DetId::Ecal, eeReducedRecHitCollection_, relval_parameters_module::energy, esRecHitCollection_, ggPFPhotons::fillPFClusters(), geomBar_, geomEnd_, edm::EventSetup::get(), edm::Event::getByLabel(), ggPFPhotons::getPFPhoECorr(), ggPFPhotons::hasSLConv(), hasSLConv_, i, ggPFPhotons::isConv(), isConv_, isMatch_, ggPFPhotons::MatchPFReco(), ggPFPhotons::MustE(), MustE_, ggPFPhotons::MustEOut(), MustEOut_, pf, PFClusRMS_, ggPFPhotons::PFClusRMSMust(), PFClusRMSMust_, ggPFPhotons::PFClusRMSTot(), ggPFPhotons::PFClusters(), ggPFPhotons::PFdEta(), PFdEta_, ggPFPhotons::PFdPhi(), PFdPhi_, PFElectronTag_, PFLCBarrel_, PFLCEndcap_, PFLowCE_, ggPFPhotons::PFLowE(), pfPartTag_, PFPhoECorr_, PFPhotonTag_, ggPFPhotons::PFPS1(), PFPS1_, ggPFPhotons::PFPS2(), PFPS2_, ggPFPhotons::PhotonPFCandMatch(), recoPFEnergy_, recoPhotonTag_, SCRawE_, ggPFPhotons::SLPoint(), VtxZ_, and VtxZErr_.

                                                                               {
  Handle<reco::PhotonCollection> PFPhotons;
  Handle<reco::PhotonCollection> recoPhotons;
  Handle<reco::GsfElectronCollection> PFElectrons;
  Handle<reco::PFCandidateCollection>PFParticles;
  PhotonCollection::const_iterator iPfPho;
  PhotonCollection::const_iterator iPho;
  iEvent.getByLabel(PFPhotonTag_, PFPhotons);
  iEvent.getByLabel(recoPhotonTag_, recoPhotons);
  iEvent.getByLabel(PFElectronTag_,PFElectrons);
  iEvent.getByLabel(pfPartTag_,PFParticles);
  //for PFPhoton Constructor:
  edm::ESHandle<CaloGeometry> pG;
  es.get<CaloGeometryRecord>().get(pG);
  geomBar_=pG->getSubdetectorGeometry(DetId::Ecal,1);
  geomEnd_=pG->getSubdetectorGeometry(DetId::Ecal,2);
  edm::Handle<BeamSpot> beamSpotHandle;
  edm::Handle<EcalRecHitCollection> EBReducedRecHits;
  edm::Handle<EcalRecHitCollection> EEReducedRecHits;
  edm::Handle<EcalRecHitCollection> ESRecHits; 
  iEvent.getByLabel(beamSpotCollection_    , beamSpotHandle);
  iEvent.getByLabel(ebReducedRecHitCollection_, EBReducedRecHits);
  iEvent.getByLabel(eeReducedRecHitCollection_, EEReducedRecHits);
  iEvent.getByLabel(esRecHitCollection_       , ESRecHits);
  iEvent.getByLabel(beamSpotCollection_,beamSpotHandle);
  EcalClusterLazyTools lazyToolEcal(iEvent, es, ebReducedRecHitCollection_, eeReducedRecHitCollection_);
  for(reco::PhotonCollection::const_iterator iPho = recoPhotons->begin(); iPho!=recoPhotons->end(); ++iPho) {
    recoPFEnergy_=0;
        
    ggPFPhotons ggPFPhoton(*iPho, PFPhotons,
                           PFElectrons,
                          PFParticles,
                           EBReducedRecHits,
                           EEReducedRecHits,
                           ESRecHits,
                           geomBar_,
                           geomEnd_,
                           beamSpotHandle
                           );
    if(ggPFPhoton.MatchPFReco()){
      isMatch_=1;
      
      std::pair<float, float>VertexZ=ggPFPhoton.SLPoint();
      VtxZ_=VertexZ.first;
      VtxZErr_=VertexZ.second;
      
      if(ggPFPhoton.isConv()){
        isConv_=1;
      }
      else isConv_=0;
      if(ggPFPhoton.hasSLConv()){
        hasSLConv_=1;
      }
      else hasSLConv_=0;
      
      ggPFPhoton.fillPFClusters();
      PFPS1_=ggPFPhoton.PFPS1();
      PFPS2_=ggPFPhoton.PFPS2();
      MustE_=ggPFPhoton.MustE();
      MustEOut_=ggPFPhoton.MustEOut();
      PFLowCE_=ggPFPhoton.PFLowE();
      PFdEta_=ggPFPhoton.PFdEta();
      PFdPhi_=ggPFPhoton.PFdPhi();
      PFClusRMS_=ggPFPhoton.PFClusRMSTot();
      PFClusRMSMust_=ggPFPhoton.PFClusRMSMust();
      std::vector<reco::CaloCluster>PFC=ggPFPhoton.PFClusters();
      PFPhoECorr_=ggPFPhoton.getPFPhoECorr(PFC, PFLCBarrel_, PFLCEndcap_);
    }
    else{
      isMatch_=0;
      std::vector<reco::CaloCluster>PFC;
      std::vector<reco::PFCandidatePtr>insideBox;
      std::vector<DetId>MatchedRH;
      ggPFPhoton.PhotonPFCandMatch(*(iPho->superCluster()), insideBox,PFParticles,PFC, MatchedRH);  
      recoPFEnergy_=0;
      //cout<<"Inside Box "<<insideBox.size()<<endl;
      for(unsigned int i=0; i<PFC.size(); ++i)recoPFEnergy_=recoPFEnergy_+PFC[i].energy();
      SCRawE_=iPho->superCluster()->rawEnergy();
      //cout<<"PF reconstructed E "<<recoPFEnergy_<<"SC Raw E "<<(*iPho).superCluster()->rawEnergy()<<endl;
      PFPS1_=ggPFPhoton.PFPS1();
      PFPS2_=ggPFPhoton.PFPS2();
      MustE_=ggPFPhoton.MustE();
      MustEOut_=ggPFPhoton.MustEOut();
      PFLowCE_=ggPFPhoton.PFLowE();
      PFdEta_=ggPFPhoton.PFdEta();
      PFdPhi_=ggPFPhoton.PFdPhi();
      PFClusRMS_=ggPFPhoton.PFClusRMSTot();
      PFClusRMSMust_=ggPFPhoton.PFClusRMSMust();
    }
    pf->Fill();
  }
  
}
void ggPFPhotonAnalyzer::beginRun ( const edm::Run r,
const edm::EventSetup c 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 43 of file ggPFPhotonAnalyzer.cc.

                                                                          {
  
  
}
void ggPFPhotonAnalyzer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 143 of file ggPFPhotonAnalyzer.cc.

References pf, and tf1.

                               {
  tf1->cd();
  pf->Write();
  tf1->Write();
  tf1->Close();

}

Member Data Documentation

Definition at line 43 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 40 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 41 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 42 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 44 of file ggPFPhotonAnalyzer.h.

Referenced by analyze().

Definition at line 45 of file ggPFPhotonAnalyzer.h.

Referenced by analyze().

Definition at line 52 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 51 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 53 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

float ggPFPhotonAnalyzer::MustE_ [private]

Definition at line 56 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 57 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

TTree* ggPFPhotonAnalyzer::pf [private]

Definition at line 49 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), endJob(), and ggPFPhotonAnalyzer().

TTree* ggPFPhotonAnalyzer::pfclus [private]

Definition at line 50 of file ggPFPhotonAnalyzer.h.

Referenced by ggPFPhotonAnalyzer().

Definition at line 61 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 62 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

float ggPFPhotonAnalyzer::PFdEta_ [private]

Definition at line 59 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

float ggPFPhotonAnalyzer::PFdPhi_ [private]

Definition at line 60 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 38 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 46 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 47 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 58 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 39 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 65 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 36 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

float ggPFPhotonAnalyzer::PFPS1_ [private]

Definition at line 54 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

float ggPFPhotonAnalyzer::PFPS2_ [private]

Definition at line 55 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 66 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 37 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

float ggPFPhotonAnalyzer::SCRawE_ [private]

Definition at line 67 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

TFile* ggPFPhotonAnalyzer::tf1 [private]

Definition at line 48 of file ggPFPhotonAnalyzer.h.

Referenced by endJob(), and ggPFPhotonAnalyzer().

float ggPFPhotonAnalyzer::VtxZ_ [private]

Definition at line 63 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().

Definition at line 64 of file ggPFPhotonAnalyzer.h.

Referenced by analyze(), and ggPFPhotonAnalyzer().