00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <memory>
00018
00019
00020 #include "FWCore/Framework/interface/Frameworkfwd.h"
00021 #include "FWCore/Framework/interface/EDAnalyzer.h"
00022
00023 #include "FWCore/Framework/interface/Event.h"
00024 #include "FWCore/Framework/interface/MakerMacros.h"
00025
00026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00027
00028 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00029 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00030
00031 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
00032 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
00033
00034 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
00035
00036 #include "DataFormats/EgammaCandidates/interface/PhotonPi0DiscriminatorAssociation.h"
00037
00038 #include "TFile.h"
00039 #include "TH1F.h"
00040
00041 using namespace std;
00042 using namespace reco;
00043 using namespace edm;
00044
00045
00046
00047
00048
00049 class SimplePi0DiscAnalyzer : public edm::EDAnalyzer {
00050 public:
00051 explicit SimplePi0DiscAnalyzer(const edm::ParameterSet&);
00052
00053 ~SimplePi0DiscAnalyzer();
00054
00055
00056 private:
00057
00058 virtual void beginJob(const edm::EventSetup&) ;
00059 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00060 virtual void endJob() ;
00061
00062
00063 string photonCollectionProducer_;
00064 string photonCorrCollectionProducer_;
00065 string uncorrectedPhotonCollection_;
00066 string correctedPhotonCollection_;
00067
00068 string outputFile_;
00069 TFile* rootFile_;
00070
00071 TH1F* hConv_ntracks_;
00072
00073 TH1F* hAll_nnout_Assoc_;
00074 TH1F* hAll_nnout_NoConv_Assoc_;
00075 TH1F* hBarrel_nnout_Assoc_;
00076 TH1F* hBarrel_nnout_NoConv_Assoc_;
00077 TH1F* hEndcNoPresh_nnout_Assoc_;
00078 TH1F* hEndcNoPresh_nnout_NoConv_Assoc_;
00079 TH1F* hEndcWithPresh_nnout_Assoc_;
00080 TH1F* hEndcWithPresh_nnout_NoConv_Assoc_;
00081
00082 };
00083
00084 SimplePi0DiscAnalyzer::SimplePi0DiscAnalyzer(const edm::ParameterSet& iConfig)
00085
00086 {
00087
00088 photonCollectionProducer_ = iConfig.getParameter<string>("phoProducer");
00089 photonCorrCollectionProducer_ = iConfig.getParameter<string>("corrPhoProducer");
00090 uncorrectedPhotonCollection_ = iConfig.getParameter<string>("uncorrectedPhotonCollection");
00091 correctedPhotonCollection_ = iConfig.getParameter<string>("correctedPhotonCollection");
00092
00093 outputFile_ = iConfig.getParameter<string>("outputFile");
00094
00095 rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE");
00096
00097 }
00098
00099 SimplePi0DiscAnalyzer::~SimplePi0DiscAnalyzer()
00100 {
00101 delete rootFile_;
00102
00103 }
00104
00105
00106
00107
00108
00109
00110 void
00111 SimplePi0DiscAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00112 {
00113 cout << endl;
00114 cout << " -------------- NEW EVENT : Run, Event = " << iEvent.id() << endl;
00115
00116
00117 Handle<ConversionCollection> convertedPhotonHandle;
00118 iEvent.getByLabel("conversions", "", convertedPhotonHandle);
00119 const reco::ConversionCollection phoCollection = *(convertedPhotonHandle.product());
00120
00121 cout << " ---> ConvertedPhotonCollection.size() = " << phoCollection.size() << endl;
00122
00123
00124 Handle<reco::PhotonCollection> correctedPhotonHandle;
00125 iEvent.getByLabel(photonCorrCollectionProducer_, correctedPhotonCollection_ , correctedPhotonHandle);
00126 const reco::PhotonCollection photons = *(correctedPhotonHandle.product());
00127
00128 cout <<"----> Photons size: "<< photons.size()<<endl;
00129
00130 edm::Handle<reco::PhotonPi0DiscriminatorAssociationMap> map;
00131 iEvent.getByLabel("piZeroDiscriminators","PhotonPi0DiscriminatorAssociationMap", map);
00132 reco::PhotonPi0DiscriminatorAssociationMap::const_iterator mapIter;
00133
00134 int PhoInd = 0;
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 }
00200
00201
00202 void SimplePi0DiscAnalyzer::beginJob(const edm::EventSetup&)
00203 {
00204 rootFile_->cd();
00205
00206 hConv_ntracks_ = new TH1F("nConvTracks","Number of tracks of converted Photons ",10,0.,10);
00207 hAll_nnout_Assoc_ = new TH1F("All_nnout_Assoc","NNout for All Photons(AssociationMap)",100,0.,1.);
00208 hAll_nnout_NoConv_Assoc_ = new TH1F("All_nnout_NoConv_Assoc","NNout for Unconverted Photons(AssociationMap)",100,0.,1.);
00209 hBarrel_nnout_Assoc_ = new TH1F("barrel_nnout_Assoc","NNout for Barrel Photons(AssociationMap)",100,0.,1.);
00210 hBarrel_nnout_NoConv_Assoc_ = new TH1F("barrel_nnout_NoConv_Assoc","NNout for Barrel Unconverted Photons(AssociationMap)",100,0.,1.);
00211 hEndcNoPresh_nnout_Assoc_ = new TH1F("endcNoPresh_nnout_Assoc","NNout for Endcap NoPresh Photons(AssociationMap)",100,0.,1.);
00212 hEndcNoPresh_nnout_NoConv_Assoc_ = new TH1F("endcNoPresh_nnout_NoConv_Assoc","NNout for Endcap Unconverted NoPresh Photons(AssociationMap)",100,0.,1.);
00213 hEndcWithPresh_nnout_Assoc_ = new TH1F("endcWithPresh_nnout_Assoc","NNout for Endcap WithPresh Photons(AssociationMap)",100,0.,1.);
00214 hEndcWithPresh_nnout_NoConv_Assoc_ = new TH1F("endcWithPresh_nnout_NoConv_Assoc","NNout for Endcap Unconverted WithPresh Photons(AssociationMap)",100,0.,1.);
00215
00216 }
00217
00218
00219 void
00220 SimplePi0DiscAnalyzer::endJob() {
00221 rootFile_->cd();
00222
00223 hConv_ntracks_->Write();
00224
00225 hAll_nnout_Assoc_->Write();
00226 hAll_nnout_NoConv_Assoc_->Write();
00227 hBarrel_nnout_Assoc_->Write();
00228 hBarrel_nnout_NoConv_Assoc_->Write();
00229 hEndcNoPresh_nnout_Assoc_->Write();
00230 hEndcNoPresh_nnout_NoConv_Assoc_->Write();
00231 hEndcWithPresh_nnout_Assoc_->Write();
00232 hEndcWithPresh_nnout_NoConv_Assoc_->Write();
00233
00234 rootFile_->Close();
00235
00236 }
00237
00238
00239 DEFINE_FWK_MODULE(SimplePi0DiscAnalyzer);