CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ggPFPhotonAnalyzer.cc
Go to the documentation of this file.
6  PFPhotonTag_=iConfig.getParameter<InputTag>("PFPhotons");
7  PFElectronTag_=iConfig.getParameter<InputTag>("PFElectrons");
8 
9  recoPhotonTag_=iConfig.getParameter<InputTag>("Photons");
10  ebReducedRecHitCollection_=iConfig.getParameter<InputTag>("ebReducedRecHitCollection");
11  eeReducedRecHitCollection_=iConfig.getParameter<InputTag>("eeReducedRecHitCollection");
12  esRecHitCollection_=iConfig.getParameter<InputTag>("esRecHitCollection");
13  beamSpotCollection_ =iConfig.getParameter<InputTag>("BeamSpotCollection");
14  pfPartTag_=iConfig.getParameter<InputTag>("PFParticles");
15  TFile *fgbr1 = new TFile("/afs/cern.ch/work/r/rpatel/public/TMVARegressionBarrelLC.root","READ");
16  TFile *fgbr2 = new TFile("/afs/cern.ch/work/r/rpatel/public/TMVARegressionEndCapLC.root","READ");
17  PFLCBarrel_=(const GBRForest*)fgbr1->Get("PFLCorrEB");
18  PFLCEndcap_=(const GBRForest*)fgbr2->Get("PFLCorrEE");
19  tf1=new TFile("PF_test.root", "RECREATE");
20  pf=new TTree("pf", "PFPhotons");
21  pfclus=new TTree("pflcus", "PFClusters");
22  pf->Branch("isConv", &isConv_, "isConv/I");
23  pf->Branch("hasSLConv", &hasSLConv_, "hasSLConv/I");
24  pf->Branch("isMatch", &isMatch_, "isMatch/I");
25  pf->Branch("PFPS1", &PFPS1_, "PFPS1/F");
26  pf->Branch("PFPS2", &PFPS2_, "PFPS2/F");
27  pf->Branch("MustE", &MustE_, "MustE/F");
28  pf->Branch("MustEOut", &MustEOut_, "MustEOut/F");
29  pf->Branch("PFLowCE", &PFLowCE_, "PFLowCE/F");
30  pf->Branch("PFdEta", &PFdEta_, "PFdEta/F");
31  pf->Branch("PFdPhi", &PFdPhi_, "PFdPhi/F");
32  pf->Branch("PFClusRMS", &PFClusRMS_, "PFClusRMS/F");
33  pf->Branch("PFClusRMSMust", &PFClusRMSMust_, "PFClusRMSMust/F");
34  pf->Branch("VtxZ", &VtxZ_, "VtxZ/F");
35  pf->Branch("VtxZErr", &VtxZErr_, "VtxZErr/F");
36  pf->Branch("PFPhoECorr", &PFPhoECorr_, "PFPhoECorr/F");
37  pf->Branch("recoPFEnergy", &recoPFEnergy_, "recoPFEnergy/F");
38  pf->Branch("SCRawE", &SCRawE_, "SCRawE");
39 }
40 
42 
44 
45 
46 }
47 
53  PhotonCollection::const_iterator iPfPho;
54  PhotonCollection::const_iterator iPho;
55  iEvent.getByLabel(PFPhotonTag_, PFPhotons);
56  iEvent.getByLabel(recoPhotonTag_, recoPhotons);
57  iEvent.getByLabel(PFElectronTag_,PFElectrons);
58  iEvent.getByLabel(pfPartTag_,PFParticles);
59  //for PFPhoton Constructor:
61  es.get<CaloGeometryRecord>().get(pG);
62  geomBar_=pG->getSubdetectorGeometry(DetId::Ecal,1);
63  geomEnd_=pG->getSubdetectorGeometry(DetId::Ecal,2);
64  edm::Handle<BeamSpot> beamSpotHandle;
65  edm::Handle<EcalRecHitCollection> EBReducedRecHits;
66  edm::Handle<EcalRecHitCollection> EEReducedRecHits;
68  iEvent.getByLabel(beamSpotCollection_ , beamSpotHandle);
69  iEvent.getByLabel(ebReducedRecHitCollection_, EBReducedRecHits);
70  iEvent.getByLabel(eeReducedRecHitCollection_, EEReducedRecHits);
71  iEvent.getByLabel(esRecHitCollection_ , ESRecHits);
72  iEvent.getByLabel(beamSpotCollection_,beamSpotHandle);
74  for(reco::PhotonCollection::const_iterator iPho = recoPhotons->begin(); iPho!=recoPhotons->end(); ++iPho) {
75  recoPFEnergy_=0;
76 
77  ggPFPhotons ggPFPhoton(*iPho, PFPhotons,
78  PFElectrons,
79  PFParticles,
80  EBReducedRecHits,
81  EEReducedRecHits,
82  ESRecHits,
83  geomBar_,
84  geomEnd_,
85  beamSpotHandle
86  );
87  if(ggPFPhoton.MatchPFReco()){
88  isMatch_=1;
89 
90  std::pair<float, float>VertexZ=ggPFPhoton.SLPoint();
91  VtxZ_=VertexZ.first;
92  VtxZErr_=VertexZ.second;
93 
94  if(ggPFPhoton.isConv()){
95  isConv_=1;
96  }
97  else isConv_=0;
98  if(ggPFPhoton.hasSLConv()){
99  hasSLConv_=1;
100  }
101  else hasSLConv_=0;
102 
103  ggPFPhoton.fillPFClusters();
104  PFPS1_=ggPFPhoton.PFPS1();
105  PFPS2_=ggPFPhoton.PFPS2();
106  MustE_=ggPFPhoton.MustE();
107  MustEOut_=ggPFPhoton.MustEOut();
108  PFLowCE_=ggPFPhoton.PFLowE();
109  PFdEta_=ggPFPhoton.PFdEta();
110  PFdPhi_=ggPFPhoton.PFdPhi();
111  PFClusRMS_=ggPFPhoton.PFClusRMSTot();
112  PFClusRMSMust_=ggPFPhoton.PFClusRMSMust();
113  std::vector<reco::CaloCluster>PFC=ggPFPhoton.PFClusters();
115  }
116  else{
117  isMatch_=0;
118  std::vector<reco::CaloCluster>PFC;
119  std::vector<reco::PFCandidatePtr>insideBox;
120  std::vector<DetId>MatchedRH;
121  ggPFPhoton.PhotonPFCandMatch(*(iPho->superCluster()), insideBox,PFParticles,PFC, MatchedRH);
122  recoPFEnergy_=0;
123  //cout<<"Inside Box "<<insideBox.size()<<endl;
124  for(unsigned int i=0; i<PFC.size(); ++i)recoPFEnergy_=recoPFEnergy_+PFC[i].energy();
125  SCRawE_=iPho->superCluster()->rawEnergy();
126  //cout<<"PF reconstructed E "<<recoPFEnergy_<<"SC Raw E "<<(*iPho).superCluster()->rawEnergy()<<endl;
127  PFPS1_=ggPFPhoton.PFPS1();
128  PFPS2_=ggPFPhoton.PFPS2();
129  MustE_=ggPFPhoton.MustE();
130  MustEOut_=ggPFPhoton.MustEOut();
131  PFLowCE_=ggPFPhoton.PFLowE();
132  PFdEta_=ggPFPhoton.PFdEta();
133  PFdPhi_=ggPFPhoton.PFdPhi();
134  PFClusRMS_=ggPFPhoton.PFClusRMSTot();
135  PFClusRMSMust_=ggPFPhoton.PFClusRMSMust();
136  }
137  pf->Fill();
138  }
139 
140 }
141 
142 
144  tf1->cd();
145  pf->Write();
146  tf1->Write();
147  tf1->Close();
148 
149 }
150 
151 
153 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
double PFClusRMSMust()
Definition: ggPFPhotons.h:49
edm::InputTag esRecHitCollection_
double PFdPhi()
Definition: ggPFPhotons.h:47
double PFdEta()
Definition: ggPFPhotons.h:46
float MustE()
Definition: ggPFPhotons.h:42
void PhotonPFCandMatch(reco::SuperCluster sc, std::vector< reco::PFCandidatePtr > &insideBox, edm::Handle< PFCandidateCollection > &pfCandidates, vector< reco::CaloCluster > &PFClust, std::vector< DetId > &MatchedRH)
Definition: ggPFPhotons.cc:530
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const GBRForest * PFLCEndcap_
ggPFPhotonAnalyzer(const edm::ParameterSet &iConfig)
virtual void analyze(const edm::Event &, const edm::EventSetup &es)
bool hasSLConv()
Definition: ggPFPhotons.h:37
std::pair< float, float > SLPoint()
Definition: ggPFPhotons.cc:85
edm::InputTag ebReducedRecHitCollection_
std::vector< reco::CaloCluster > PFClusters()
Definition: ggPFPhotons.h:50
int iEvent
Definition: GenABIO.cc:243
void fillPFClusters()
Definition: ggPFPhotons.cc:100
edm::InputTag beamSpotCollection_
float MustEOut()
Definition: ggPFPhotons.h:43
edm::InputTag pfPartTag_
const CaloSubdetectorGeometry * geomEnd_
bool MatchPFReco()
Definition: ggPFPhotons.h:35
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::InputTag PFElectronTag_
edm::InputTag recoPhotonTag_
edm::InputTag eeReducedRecHitCollection_
float PFLowE()
Definition: ggPFPhotons.h:45
const T & get() const
Definition: EventSetup.h:55
const CaloSubdetectorGeometry * geomBar_
const GBRForest * PFLCBarrel_
bool isConv()
Definition: ggPFPhotons.h:36
edm::InputTag PFPhotonTag_
virtual void beginRun(const edm::Run &r, const edm::EventSetup &c)
double PFClusRMSTot()
Definition: ggPFPhotons.h:48
float PFPS1()
Definition: ggPFPhotons.h:40
float PFPS2()
Definition: ggPFPhotons.h:41
Definition: Run.h:33
double getPFPhoECorr(std::vector< reco::CaloCluster >PFClusters, const GBRForest *ReaderLCEB, const GBRForest *ReaderLCEE)
Definition: ggPFPhotons.cc:226