00001 #include <iostream>
00002
00003
00004 #include "Validation/RecoEgamma/interface/ConversionPostprocessing.h"
00005
00006
00007
00021 using namespace std;
00022
00023
00024 ConversionPostprocessing::ConversionPostprocessing(const edm::ParameterSet& pset)
00025 {
00026
00027 dbe_ = 0;
00028 dbe_ = edm::Service<DQMStore>().operator->();
00029 dbe_->setVerbose(0);
00030 parameters_ = pset;
00031
00032
00033 standAlone_ = pset.getParameter<bool>("standAlone");
00034 batch_ = pset.getParameter<bool>("batch");
00035 outputFileName_ = pset.getParameter<string>("OutputFileName");
00036 inputFileName_ = pset.getParameter<std::string>("InputFileName");
00037
00038
00039 etMin = parameters_.getParameter<double>("etMin");
00040 etMax = parameters_.getParameter<double>("etMax");
00041 etBin = parameters_.getParameter<int>("etBin");
00042
00043 etaMin = parameters_.getParameter<double>("etaMin");
00044 etaMax = parameters_.getParameter<double>("etaMax");
00045 etaBin = parameters_.getParameter<int>("etaBin");
00046 etaBin2 = parameters_.getParameter<int>("etaBin2");
00047
00048 phiMin = parameters_.getParameter<double>("phiMin");
00049 phiMax = parameters_.getParameter<double>("phiMax");
00050 phiBin = parameters_.getParameter<int>("phiBin");
00051
00052 rMin = parameters_.getParameter<double>("rMin");
00053 rMax = parameters_.getParameter<double>("rMax");
00054 rBin = parameters_.getParameter<int>("rBin");
00055
00056 zMin = parameters_.getParameter<double>("zMin");
00057 zMax = parameters_.getParameter<double>("zMax");
00058 zBin = parameters_.getParameter<int>("zBin");
00059
00060
00061
00062 }
00063
00064
00065
00066 ConversionPostprocessing::~ConversionPostprocessing()
00067 {}
00068
00069 void ConversionPostprocessing::beginJob()
00070 {
00071
00072 }
00073
00074 void ConversionPostprocessing::analyze(const edm::Event& e, const edm::EventSetup& esup)
00075 {}
00076
00077
00078 void ConversionPostprocessing::endJob() {
00079
00080 if(standAlone_) runPostprocessing();
00081
00082 }
00083
00084 void ConversionPostprocessing::endRun(const edm::Run& run, const edm::EventSetup& setup) {
00085
00086 if(!standAlone_) runPostprocessing();
00087
00088 }
00089
00090
00091
00092 void ConversionPostprocessing::runPostprocessing()
00093 {
00094
00095
00096
00097 std::string simInfoPathName = "EgammaV/ConversionValidator/SimulationInfo/";
00098 std::string convPathName = "EgammaV/ConversionValidator/ConversionInfo/";
00099 std::string effPathName = "EgammaV/ConversionValidator/EfficienciesAndFakeRate/";
00100
00101
00102 if(batch_) dbe_->open(inputFileName_);
00103
00104 dbe_->setCurrentFolder(effPathName);
00105
00106 std::string histname = "convEffVsEtaTwoTracks";
00107 convEffEtaTwoTracks_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
00108
00109 histname = "convEffVsPhiTwoTracks";
00110 convEffPhiTwoTracks_ = dbe_->book1D(histname,histname,phiBin,phiMin,phiMax);
00111
00112 histname = "convEffVsRTwoTracks";
00113 convEffRTwoTracks_ = dbe_->book1D(histname,histname,rBin,rMin, rMax);
00114
00115 histname = "convEffVsZTwoTracks";
00116 convEffZTwoTracks_ = dbe_->book1D(histname,histname,zBin,zMin,zMax);
00117
00118 histname = "convEffVsEtTwoTracks";
00119 convEffEtTwoTracks_ = dbe_->book1D(histname,histname,etBin,etMin, etMax);
00120
00121 histname = "convEffVsEtaTwoTracksAndVtxProbGT0";
00122 convEffEtaTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
00123 histname = "convEffVsEtaTwoTracksAndVtxProbGT0005";
00124 convEffEtaTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
00125 histname = "convEffVsRTwoTracksAndVtxProbGT0";
00126 convEffRTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname,histname,rBin,rMin,rMax);
00127 histname = "convEffVsRTwoTracksAndVtxProbGT0005";
00128 convEffRTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname,histname,rBin,rMin,rMax);
00129
00130
00131 histname = "convFakeRateVsEtaTwoTracks";
00132 convFakeRateEtaTwoTracks_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
00133 histname = "convFakeRateVsPhiTwoTracks";
00134 convFakeRatePhiTwoTracks_ = dbe_->book1D(histname,histname,phiBin,phiMin,phiMax);
00135 histname = "convFakeRateVsRTwoTracks";
00136 convFakeRateRTwoTracks_ = dbe_->book1D(histname,histname,rBin,rMin, rMax);
00137 histname = "convFakeRateVsZTwoTracks";
00138 convFakeRateZTwoTracks_ = dbe_->book1D(histname,histname,zBin,zMin,zMax);
00139 histname = "convFakeRateVsEtTwoTracks";
00140 convFakeRateEtTwoTracks_ = dbe_->book1D(histname,histname,etBin,etMin, etMax);
00141
00142
00143 dividePlots(dbe_->get(effPathName+"convEffVsEtaTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEta"),dbe_->get(simInfoPathName+"h_VisSimConvEta"),"effic");
00144 dividePlots(dbe_->get(effPathName+"convEffVsPhiTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksPhi"),dbe_->get(simInfoPathName+"h_VisSimConvPhi"),"effic");
00145 dividePlots(dbe_->get(effPathName+"convEffVsRTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksR"),dbe_->get(simInfoPathName+"h_VisSimConvR"),"effic");
00146 dividePlots(dbe_->get(effPathName+"convEffVsZTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksZ"),dbe_->get(simInfoPathName+"h_VisSimConvZ"),"effic");
00147 dividePlots(dbe_->get(effPathName+"convEffVsEtTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEt"),dbe_->get(simInfoPathName+"h_VisSimConvEt"),"effic");
00148 dividePlots(dbe_->get(effPathName+"convEffVsEtaTwoTracksAndVtxProbGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEtaAndVtxPGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEta"),"effic");
00149 dividePlots(dbe_->get(effPathName+"convEffVsEtaTwoTracksAndVtxProbGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEtaAndVtxPGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEta"),"effic");
00150 dividePlots(dbe_->get(effPathName+"convEffVsRTwoTracksAndVtxProbGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksRAndVtxPGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksR"),"effic");
00151 dividePlots(dbe_->get(effPathName+"convEffVsRTwoTracksAndVtxProbGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksRAndVtxPGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksR"),"effic");
00152
00153
00154
00155 dividePlots(dbe_->get(effPathName+"convFakeRateVsEtaTwoTracks"),dbe_->get(convPathName+"convEtaAss"),dbe_->get(convPathName+"convEta"),"fakerate");
00156 dividePlots(dbe_->get(effPathName+"convFakeRateVsPhiTwoTracks"),dbe_->get(convPathName+"convPhiAss"),dbe_->get(convPathName+"convPhi"),"fakerate");
00157 dividePlots(dbe_->get(effPathName+"convFakeRateVsRTwoTracks"),dbe_->get(convPathName+"convRAss"),dbe_->get(convPathName+"convR"),"fakerate");
00158 dividePlots(dbe_->get(effPathName+"convFakeRateVsZTwoTracks"),dbe_->get(convPathName+"convZAss"),dbe_->get(convPathName+"convZ"),"fakerate");
00159 dividePlots(dbe_->get(effPathName+"convFakeRateVsEtTwoTracks"),dbe_->get(convPathName+"convPtAss"),dbe_->get(convPathName+"convPt"),"fakerate");
00160
00161
00162
00163 if(standAlone_) dbe_->save(outputFileName_);
00164 else if(batch_) dbe_->save(inputFileName_);
00165 }
00166
00167
00168 void ConversionPostprocessing::endLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& setup)
00169 {
00170
00171
00172 }
00173
00174
00175
00176 void ConversionPostprocessing::dividePlots(MonitorElement* dividend, MonitorElement* numerator, MonitorElement* denominator, std::string type ){
00177 double value,err;
00178 for (int j=1; j<=numerator->getNbinsX(); j++){
00179
00180 if (denominator->getBinContent(j)!=0){
00181 if (type=="effic")
00182 value = ((double) numerator->getBinContent(j))/((double) denominator->getBinContent(j));
00183 else if (type=="fakerate")
00184 value = 1-((double) numerator->getBinContent(j))/((double) denominator->getBinContent(j));
00185 else return;
00186 err = sqrt( value*(1-value) / ((double) denominator->getBinContent(j)) );
00187 dividend->setBinContent(j, value);
00188 if ( err !=0 ) dividend->setBinError(j,err);
00189 }
00190 else {
00191 dividend->setBinContent(j, 0);
00192 dividend->setBinError(j,0);
00193 }
00194
00195 }
00196
00197
00198 }
00199
00200
00201 void ConversionPostprocessing::dividePlots(MonitorElement* dividend, MonitorElement* numerator, double denominator){
00202 double value,err;
00203
00204 for (int j=1; j<=numerator->getNbinsX(); j++){
00205 if (denominator!=0){
00206 value = ((double) numerator->getBinContent(j))/denominator;
00207 err = sqrt( value*(1-value) / denominator);
00208 dividend->setBinContent(j, value);
00209 dividend->setBinError(j,err);
00210 }
00211 else {
00212 dividend->setBinContent(j, 0);
00213 }
00214 }
00215
00216 }
00217