00001 #include "Validation/RecoMET/interface/METTester.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "FWCore/PluginManager/interface/ModuleDef.h"
00019 #include "FWCore/Framework/interface/MakerMacros.h"
00020
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 #include "FWCore/ServiceRegistry/interface/Service.h"
00023
00024 #include "FWCore/Framework/interface/Event.h"
00025 #include "DataFormats/Common/interface/Handle.h"
00026
00027 #include "FWCore/Framework/interface/ESHandle.h"
00028
00029 #include "DataFormats/METReco/interface/CaloMET.h"
00030 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00031 #include "DataFormats/METReco/interface/GenMET.h"
00032 #include "DataFormats/METReco/interface/GenMETCollection.h"
00033 #include "DataFormats/METReco/interface/MET.h"
00034 #include "DataFormats/METReco/interface/METCollection.h"
00035
00036 #include <vector>
00037 #include <utility>
00038 #include <ostream>
00039 #include <fstream>
00040 #include <iostream>
00041 #include <algorithm>
00042 #include <cmath>
00043 #include <memory>
00044 #include "DQMServices/Core/interface/DQMStore.h"
00045
00046 METTester::METTester(const edm::ParameterSet& iConfig)
00047 {
00048
00049
00050 inputMETLabel_ = iConfig.getParameter<edm::InputTag>("InputMETLabel");
00051 METType_ = iConfig.getUntrackedParameter<std::string>("METType");
00052
00053
00054
00055
00056
00057 }
00058
00059 void METTester::beginJob(const edm::EventSetup& iSetup)
00060 {
00061
00062
00063 dbe_ = edm::Service<DQMStore>().operator->();
00064
00065 if (dbe_) {
00066 TString dirName = "RecoMETV/METTask/MET/";
00067 TString label(inputMETLabel_.label());
00068 dirName += label;
00069 dbe_->setCurrentFolder((string)dirName);
00070
00071 if (METType_ == "CaloMET")
00072 {
00073
00074 me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
00075 me["hCaloMEx"] = dbe_->book1D("METTask_CaloMEx","METTask_CaloMEx",4001,-1000,1001);
00076 me["hCaloMEy"] = dbe_->book1D("METTask_CaloMEy","METTask_CaloMEy",4001,-1000,1001);
00077 me["hCaloEz"] = dbe_->book1D("METTask_CaloEz","METTask_CaloEz",2001,-500,501);
00078 me["hCaloMETSig"] = dbe_->book1D("METTask_CaloMETSig","METTask_CaloMETSig",51,0,51);
00079 me["hCaloMET"] = dbe_->book1D("METTask_CaloMET","METTask_CaloMET",2001,0,2001);
00080 me["hCaloMETPhi"] = dbe_->book1D("METTask_CaloMETPhi","METTask_CaloMETPhi",80,-4,4);
00081 me["hCaloSumET"] = dbe_->book1D("METTask_CaloSumET","METTask_CaloSumET",10001,0,10001);
00082 me["hCaloMaxEtInEmTowers"] = dbe_->book1D("METTask_CaloMaxEtInEmTowers","METTask_CaloMaxEtInEmTowers",4001,0,4001);
00083 me["hCaloMaxEtInHadTowers"] = dbe_->book1D("METTask_CaloMaxEtInHadTowers","METTask_CaloMaxEtInHadTowers",4001,0,4001);
00084 me["hCaloEtFractionHadronic"] = dbe_->book1D("METTask_CaloEtFractionHadronic","METTask_CaloEtFractionHadronic",100,0,1);
00085 me["hCaloEmEtFraction"] = dbe_->book1D("METTask_CaloEmEtFraction","METTask_CaloEmEtFraction",100,0,1);
00086 me["hCaloHadEtInHB"] = dbe_->book1D("METTask_CaloHadEtInHB","METTask_CaloHadEtInHB",8001,0,8001);
00087 me["hCaloHadEtInHO"] = dbe_->book1D("METTask_CaloHadEtInHO","METTask_CaloHadEtInHO",4001,0,4001);
00088 me["hCaloHadEtInHE"] = dbe_->book1D("METTask_CaloHadEtInHE","METTask_CaloHadEtInHE",4001,0,4001);
00089 me["hCaloHadEtInHF"] = dbe_->book1D("METTask_CaloHadEtInHF","METTask_CaloHadEtInHF",4001,0,4001);
00090 me["hCaloHadEtInEB"] = dbe_->book1D("METTask_CaloHadEtInEB","METTask_CaloHadEtInEB",8001,0,8001);
00091 me["hCaloHadEtInEE"] = dbe_->book1D("METTask_CaloHadEtInEE","METTask_CaloHadEtInEE",4001,0,4001);
00092 me["hCaloEmEtInHF"] = dbe_->book1D("METTask_CaloEmEtInHF","METTask_CaloEmEtInHF",4001,0,4001);
00093 me["hCaloEmEtInEE"] = dbe_->book1D("METTask_CaloEmEtInEE","METTask_CaloEmEtInEE",4001,0,4001);
00094 me["hCaloEmEtInEB"] = dbe_->book1D("METTask_CaloEmEtInEB","METTask_CaloEmEtInEB",8001,0,8001);
00095 }
00096
00097 else if (METType_ == "GenMET")
00098 {
00099
00100 me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
00101 me["hGenMEx"] = dbe_->book1D("METTask_GenMEx","METTask_GenMEx",4001,-1000,1001);
00102 me["hGenMEy"] = dbe_->book1D("METTask_GenMEy","METTask_GenMEy",4001,-1000,1001);
00103 me["hGenEz"] = dbe_->book1D("METTask_GenEz","METTask_GenEz",2001,-500,501);
00104 me["hGenMETSig"] = dbe_->book1D("METTask_GenMETSig","METTask_GenMETSig",51,0,51);
00105 me["hGenMET"] = dbe_->book1D("METTask_GenMET","METTask_GenMET",2001,0,2001);
00106 me["hGenMETPhi"] = dbe_->book1D("METTask_GenMETPhi","METTask_GenMETPhi",80,-4,4);
00107 me["hGenSumET"] = dbe_->book1D("METTask_GenSumET","METTask_GenSumET",10001,0,10001);
00108 me["hGenEmEnergy"] = dbe_->book1D("METTask_GenEmEnergy","METTask_GenEmEnergy",4001,0,4001);
00109 me["hGenHadEnergy"] = dbe_->book1D("METTask_GenHadEnergy","METTask_GenHadEnergy",4001,0,4001);
00110 me["hGenInvisibleEnergy"] = dbe_->book1D("METTask_GenInvisibleEnergy","METTask_GenInvisibleEnergy",4001,0,4001);
00111 me["hGenAuxiliaryEnergy"] = dbe_->book1D("METTask_GenAuxiliaryEnergy","METTask_GenAuxiliaryEnergy",4001,0,4001);
00112 }
00113 else if (METType_ == "MET")
00114 {
00115
00116 me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
00117 me["hMEx"] = dbe_->book1D("METTask_MEx","METTask_MEx",2001,-500,501);
00118 me["hMEy"] = dbe_->book1D("METTask_MEy","METTask_MEy",2001,-500,501);
00119 me["hEz"] = dbe_->book1D("METTask_Ez","METTask_Ez",2001,-500,501);
00120 me["hMETSig"] = dbe_->book1D("METTask_METSig","METTask_METSig",51,0,51);
00121 me["hMET"] = dbe_->book1D("METTask_MET","METTask_MET",2001,0,2001);
00122 me["hMETPhi"] = dbe_->book1D("METTask_METPhi","METTask_METPhi",80,-4,4);
00123 me["hSumET"] = dbe_->book1D("METTask_SumET","METTask_SumET",4001,0,4001);
00124 }
00125
00126 else
00127 {
00128 edm::LogInfo("OutputInfo") << " METType not correctly specified!'";
00129 }
00130 }
00131 }
00132
00133 void METTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00134 {
00135
00136 if (METType_ == "CaloMET")
00137 {
00138 const CaloMET *calomet;
00139
00140 edm::Handle<CaloMETCollection> calo;
00141 iEvent.getByLabel(inputMETLabel_, calo);
00142 if (!calo.isValid()) {
00143 edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task";
00144 edm::LogInfo("OutputInfo") << " MET Task cannot continue...!";
00145 return;
00146 } else {
00147 const CaloMETCollection *calometcol = calo.product();
00148 calomet = &(calometcol->front());
00149 }
00150
00151
00152 double caloSumET = calomet->sumEt();
00153 double caloMETSig = calomet->mEtSig();
00154 double caloEz = calomet->e_longitudinal();
00155 double caloMET = calomet->pt();
00156 double caloMEx = calomet->px();
00157 double caloMEy = calomet->py();
00158 double caloMETPhi = calomet->phi();
00159 double caloMaxEtInEMTowers = calomet->maxEtInEmTowers();
00160 double caloMaxEtInHadTowers = calomet->maxEtInHadTowers();
00161 double caloEtFractionHadronic = calomet->etFractionHadronic();
00162 double caloEmEtFraction = calomet->emEtFraction();
00163 double caloHadEtInHB = calomet->hadEtInHB();
00164 double caloHadEtInHO = calomet->hadEtInHO();
00165 double caloHadEtInHE = calomet->hadEtInHE();
00166 double caloHadEtInHF = calomet->hadEtInHF();
00167 double caloEmEtInEB = calomet->emEtInEB();
00168 double caloEmEtInEE = calomet->emEtInEE();
00169 double caloEmEtInHF = calomet->emEtInHF();
00170
00171 edm::LogInfo("OutputInfo") << caloMET << " " << caloSumET << endl;
00172
00173 me["hCaloMEx"]->Fill(caloMEx);
00174 me["hCaloMEy"]->Fill(caloMEy);
00175 me["hCaloMET"]->Fill(caloMET);
00176 me["hCaloMETPhi"]->Fill(caloMETPhi);
00177 me["hCaloSumET"]->Fill(caloSumET);
00178 me["hCaloMETSig"]->Fill(caloMETSig);
00179 me["hCaloEz"]->Fill(caloEz);
00180 me["hCaloMaxEtInEmTowers"]->Fill(caloMaxEtInEMTowers);
00181 me["hCaloMaxEtInHadTowers"]->Fill(caloMaxEtInHadTowers);
00182 me["hCaloEtFractionHadronic"]->Fill(caloEtFractionHadronic);
00183 me["hCaloEmEtFraction"]->Fill(caloEmEtFraction);
00184 me["hCaloHadEtInHB"]->Fill(caloHadEtInHB);
00185 me["hCaloHadEtInHO"]->Fill(caloHadEtInHO);
00186 me["hCaloHadEtInHE"]->Fill(caloHadEtInHE);
00187 me["hCaloHadEtInHF"]->Fill(caloHadEtInHF);
00188 me["hCaloEmEtInEB"]->Fill(caloEmEtInEB);
00189 me["hCaloEmEtInEE"]->Fill(caloEmEtInEE);
00190 me["hCaloEmEtInHF"]->Fill(caloEmEtInHF);
00191 }
00192
00193 else if (METType_ == "GenMET")
00194 {
00195 const GenMET *genmet;
00196
00197 edm::Handle<GenMETCollection> gen;
00198 iEvent.getByLabel(inputMETLabel_, gen);
00199 if (!gen.isValid()) {
00200 edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task";
00201 edm::LogInfo("OutputInfo") << " MET Task cannot continue...!";
00202 return;
00203 } else {
00204 const GenMETCollection *genmetcol = gen.product();
00205 genmet = &(genmetcol->front());
00206 }
00207
00208
00209
00210 double genSumET = genmet->sumEt();
00211 double genMETSig = genmet->mEtSig();
00212 double genEz = genmet->e_longitudinal();
00213 double genMET = genmet->pt();
00214 double genMEx = genmet->px();
00215 double genMEy = genmet->py();
00216 double genMETPhi = genmet->phi();
00217 double genEmEnergy = genmet->emEnergy();
00218 double genHadEnergy = genmet->hadEnergy();
00219 double genInvisibleEnergy= genmet->invisibleEnergy();
00220 double genAuxiliaryEnergy= genmet->auxiliaryEnergy();
00221
00222 me["hNevents"]->Fill(0);
00223 me["hGenMEx"]->Fill(genMEx);
00224 me["hGenMEy"]->Fill(genMEy);
00225 me["hGenMET"]->Fill(genMET);
00226 me["hGenMETPhi"]->Fill(genMETPhi);
00227 me["hGenSumET"]->Fill(genSumET);
00228 me["hGenMETSig"]->Fill(genMETSig);
00229 me["hGenEz"]->Fill(genEz);
00230 me["hGenEmEnergy"]->Fill(genEmEnergy);
00231 me["hGenHadEnergy"]->Fill(genHadEnergy);
00232 me["hGenInvisibleEnergy"]->Fill(genInvisibleEnergy);
00233 me["hGenAuxiliaryEnergy"]->Fill(genAuxiliaryEnergy);
00234 }
00235
00236 else if (METType_ == "MET")
00237 {
00238 const MET *met;
00239
00240 edm::Handle<METCollection> hmetcol;
00241 iEvent.getByLabel(inputMETLabel_, hmetcol);
00242 if (!hmetcol.isValid()) {
00243 edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task";
00244 edm::LogInfo("OutputInfo") << " MET Task cannot continue...!";
00245 return;
00246 } else {
00247 const METCollection *metcol = hmetcol.product();
00248 met = &(metcol->front());
00249 }
00250
00251
00252 double SumET = met->sumEt();
00253 double METSig = met->mEtSig();
00254 double Ez = met->e_longitudinal();
00255 double MET = met->pt();
00256 double MEx = met->px();
00257 double MEy = met->py();
00258 double METPhi = met->phi();
00259
00260 me["hMEx"]->Fill(MEx);
00261 me["hMEy"]->Fill(MEy);
00262 me["hMET"]->Fill(MET);
00263 me["hMETPhi"]->Fill(METPhi);
00264 me["hSumET"]->Fill(SumET);
00265 me["hMETSig"]->Fill(METSig);
00266 me["hEz"]->Fill(Ez);
00267 }
00268
00269
00270 }
00271
00272 void METTester::endJob()
00273 {
00274
00275
00276
00277
00278
00279 }