00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "RecoEgamma/Examples/plugins/SimplePi0DiscAnalyzer.h"
00022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00023 #include "FWCore/Framework/interface/EDAnalyzer.h"
00024 #include "FWCore/Framework/interface/Event.h"
00025 #include "FWCore/Framework/interface/MakerMacros.h"
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00028 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00029 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00030 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00031 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00032 #include "DataFormats/EgammaReco/interface/ElectronSeed.h"
00033 #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
00034 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00035 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00036
00037 #include "CLHEP/Units/PhysicalConstants.h"
00038 #include <iostream>
00039 #include "TMath.h"
00040 #include "TFile.h"
00041 #include "TH1F.h"
00042 #include "TH1I.h"
00043 #include "TH2F.h"
00044 #include "TProfile.h"
00045 #include "TTree.h"
00046 #include <iostream>
00047
00048 using namespace reco;
00049
00050 SimplePi0DiscAnalyzer::SimplePi0DiscAnalyzer(const edm::ParameterSet& conf)
00051 {
00052
00053 outputFile_ = conf.getParameter<std::string>("outputFile");
00054 rootFile_ = new TFile(outputFile_.c_str(),"RECREATE");
00055
00056
00057 photonCollectionProducer_ = conf.getParameter<std::string>("phoProducer");
00058 photonCollection_ = conf.getParameter<std::string>("photonCollection");
00059
00060
00061
00062 }
00063
00064 SimplePi0DiscAnalyzer::~SimplePi0DiscAnalyzer()
00065 {
00066
00067
00068
00069 rootFile_->Write();
00070 rootFile_->Close();
00071 }
00072
00073 void SimplePi0DiscAnalyzer::beginJob(){
00074
00075 rootFile_->cd();
00076 std::cout << "beginJob() -> Book the Histograms" << std::endl;
00077
00078 hConv_ntracks_ = new TH1F("nConvTracks","Number of tracks of converted Photons ",10,0.,10);
00079 hAll_nnout_Assoc_ = new TH1F("All_nnout_Assoc","NNout for All Photons(AssociationMap)",100,0.,1.);
00080 hAll_nnout_NoConv_Assoc_ = new TH1F("All_nnout_NoConv_Assoc","NNout for Unconverted Photons(AssociationMap)",100,0.,1.);
00081 hAll_nnout_NoConv_Assoc_R9_ = new TH1F("All_nnout_NoConv_Assoc_R9","NNout for Unconverted Photons with R9>0.93 (AssociationMap)",100,0.,1.);
00082 hBarrel_nnout_Assoc_ = new TH1F("barrel_nnout_Assoc","NNout for Barrel Photons(AssociationMap)",100,0.,1.);
00083 hBarrel_nnout_NoConv_Assoc_ = new TH1F("barrel_nnout_NoConv_Assoc","NNout for Barrel Unconverted Photons(AssociationMap)",100,0.,1.);
00084 hBarrel_nnout_NoConv_Assoc_R9_ = new TH1F("barrel_nnout_NoConv_Assoc_R9","NNout for Barrel Unconverted Photons with R9>0.93 (AssociationMap)",100,0.,1.);
00085 hEndcNoPresh_nnout_Assoc_ = new TH1F("endcNoPresh_nnout_Assoc","NNout for Endcap NoPresh Photons(AssociationMap)",100,0.,1.);
00086 hEndcNoPresh_nnout_NoConv_Assoc_ = new TH1F("endcNoPresh_nnout_NoConv_Assoc","NNout for Endcap Unconverted NoPresh Photons(AssociationMap)",100,0.,1.);
00087 hEndcNoPresh_nnout_NoConv_Assoc_R9_ = new TH1F("endcNoPresh_nnout_NoConv_Assoc_R9","NNout for Endcap Unconverted NoPresh Photons with R9>0.93 (AssociationMap)",100,0.,1.);
00088 hEndcWithPresh_nnout_Assoc_ = new TH1F("endcWithPresh_nnout_Assoc","NNout for Endcap WithPresh Photons(AssociationMap)",100,0.,1.);
00089 hEndcWithPresh_nnout_NoConv_Assoc_ = new TH1F("endcWithPresh_nnout_NoConv_Assoc","NNout for Endcap Unconverted WithPresh Photons(AssociationMap)",100,0.,1.);
00090 hEndcWithPresh_nnout_NoConv_Assoc_R9_ = new TH1F("endcWithPresh_nnout_NoConv_Assoc_R9","NNout for Endcap Unconverted WithPresh Photons with R9>0.93 (AssociationMap)",100,0.,1.);
00091
00092 }
00093
00094 void
00095 SimplePi0DiscAnalyzer::endJob(){
00096
00097 rootFile_->cd();
00098 std::cout << "endJob() -> Write the Histograms" << std::endl;
00099 hConv_ntracks_->Write();
00100
00101 hAll_nnout_Assoc_->Write();
00102 hAll_nnout_NoConv_Assoc_->Write();
00103 hAll_nnout_NoConv_Assoc_R9_->Write();
00104 hBarrel_nnout_Assoc_->Write();
00105 hBarrel_nnout_NoConv_Assoc_->Write();
00106 hBarrel_nnout_NoConv_Assoc_R9_->Write();
00107 hEndcNoPresh_nnout_Assoc_->Write();
00108 hEndcNoPresh_nnout_NoConv_Assoc_->Write();
00109 hEndcNoPresh_nnout_NoConv_Assoc_R9_->Write();
00110 hEndcWithPresh_nnout_Assoc_->Write();
00111 hEndcWithPresh_nnout_NoConv_Assoc_->Write();
00112 hEndcWithPresh_nnout_NoConv_Assoc_R9_->Write();
00113
00114 }
00115
00116 void
00117 SimplePi0DiscAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00118 {
00119 std::cout << std::endl;
00120 std::cout << " -------------- NEW EVENT : Run, Event = " << iEvent.id() << std::endl;
00121
00122 edm::Handle<reco::PhotonCollection> PhotonHandle;
00123 iEvent.getByLabel(photonCollectionProducer_, photonCollection_ , PhotonHandle);
00124 const reco::PhotonCollection photons = *(PhotonHandle.product());
00125
00126 std::cout <<"----> Photons size: "<< photons.size()<<std::endl;
00127
00128 edm::Handle<reco::PhotonPi0DiscriminatorAssociationMap> map;
00129 iEvent.getByLabel("piZeroDiscriminators","PhotonPi0DiscriminatorAssociationMap", map);
00130 reco::PhotonPi0DiscriminatorAssociationMap::const_iterator mapIter;
00131
00132 int PhoInd = 0;
00133
00134 for( reco::PhotonCollection::const_iterator iPho = photons.begin(); iPho != photons.end(); iPho++) {
00135
00136 reco::Photon localPho(*iPho);
00137
00138 float Photon_et = localPho.et(); float Photon_eta = localPho.eta();
00139 float Photon_phi = localPho.phi(); float Photon_r9 = localPho.r9();
00140 bool isPhotConv = localPho.hasConversionTracks();
00141 std::cout << "Photon Id = " << PhoInd
00142 << " with Et = " << Photon_et
00143 << " Eta = " << Photon_eta
00144 << " Phi = " << Photon_phi
00145 << " R9 = " << Photon_r9
00146 << " and conv_id = " << isPhotConv << std::endl;
00147
00148
00149 SuperClusterRef it_super = localPho.superCluster();
00150
00151
00152
00153 float nn = -10;
00154 mapIter = map->find(edm::Ref<reco::PhotonCollection>(PhotonHandle,PhoInd));
00155 if(mapIter!=map->end()) {
00156 nn = mapIter->val;
00157 }
00158 if(fabs(it_super->eta()) <= 1.442) {
00159 hBarrel_nnout_Assoc_->Fill(nn);
00160 hAll_nnout_Assoc_->Fill(nn);
00161 std::cout << "AssociationMap Barrel NN = " << nn << std::endl;
00162 if(!isPhotConv) {
00163 hBarrel_nnout_NoConv_Assoc_->Fill(nn);
00164 hAll_nnout_NoConv_Assoc_->Fill(nn);
00165 }
00166 if(Photon_r9>0.93) {
00167 hBarrel_nnout_NoConv_Assoc_R9_->Fill(nn);
00168 hAll_nnout_NoConv_Assoc_R9_->Fill(nn);
00169 }
00170 } else if( (fabs(it_super->eta()) >= 1.556 && fabs(it_super->eta()) < 1.65) || fabs(it_super->eta()) > 2.5) {
00171 hEndcNoPresh_nnout_Assoc_->Fill(nn);
00172 hAll_nnout_Assoc_->Fill(nn);
00173 std::cout << "AssociationMap EndcNoPresh NN = " << nn << std::endl;
00174 if(!isPhotConv) {
00175 hEndcNoPresh_nnout_NoConv_Assoc_->Fill(nn);
00176 hAll_nnout_NoConv_Assoc_->Fill(nn);
00177 }
00178 if(Photon_r9>0.93) {
00179 hEndcNoPresh_nnout_NoConv_Assoc_R9_->Fill(nn);
00180 hAll_nnout_NoConv_Assoc_R9_->Fill(nn);
00181 }
00182 } else if(fabs(it_super->eta()) >= 1.65 && fabs(it_super->eta()) <= 2.5 ) {
00183 hEndcWithPresh_nnout_Assoc_->Fill(nn);
00184 hAll_nnout_Assoc_->Fill(nn);
00185 std::cout << "AssociationMap EndcWithPresh NN = " << nn << std::endl;
00186 if(!isPhotConv) {
00187 hEndcWithPresh_nnout_NoConv_Assoc_->Fill(nn);
00188 hAll_nnout_NoConv_Assoc_->Fill(nn);
00189 }
00190 if(Photon_r9>0.93) {
00191 hEndcWithPresh_nnout_NoConv_Assoc_R9_->Fill(nn);
00192 hAll_nnout_NoConv_Assoc_R9_->Fill(nn);
00193 }
00194 }
00195
00196
00197 PhoInd++;
00198 }
00199
00200 }
00201
00202 DEFINE_FWK_MODULE(SimplePi0DiscAnalyzer);
00203