10 #include "TLorentzVector.h" 24 theGsfElectronCollection_(
27 consumes <
std::vector<
reco::
Photon> > (ps.getParameter <
edm::InputTag > (
"photonCollection"))),
29 theBSCollection_(consumes <
reco::
BeamSpot > (ps.getParameter <
edm::InputTag > (
"beamSpotCollection"))),
30 triggerEvent_(consumes <
trigger::TriggerEvent > (ps.getParameter <
edm::InputTag > (
"TriggerEvent"))),
31 triggerResults_(consumes <
edm::TriggerResults > (ps.getParameter <
edm::InputTag > (
"TriggerResults"))),
32 triggerFilter_(ps.getParameter <
edm::InputTag > (
"TriggerFilter")),
33 triggerPath_(ps.getParameter <
std::
string > (
"TriggerPath")),
34 histFolder_(ps.getParameter <
std::
string > (
"histFolder")),
35 efficiencyFolder_(histFolder_ +
"/efficiency_raw"),
36 stage2CaloLayer2EGammaToken_(
38 electronEfficiencyThresholds_(ps.getParameter <
std::vector<double> > (
"electronEfficiencyThresholds")),
39 electronEfficiencyBins_(ps.getParameter <
std::vector<double> > (
"electronEfficiencyBins")),
40 photonEfficiencyThresholds_(ps.getParameter <
std::vector<double> > (
"photonEfficiencyThresholds")),
41 photonEfficiencyBins_(ps.getParameter <
std::vector<double> > (
"photonEfficiencyBins")),
44 tagAndProbleInvariantMass_(-1.)
46 edm::LogInfo(
"L1TEGammaOffline") <<
"Constructor " <<
"L1TEGammaOffline::L1TEGammaOffline " << std::endl;
54 edm::LogInfo(
"L1TEGammaOffline") <<
"Destructor L1TEGammaOffline::~L1TEGammaOffline " << std::endl;
62 edm::LogInfo(
"L1TEGammaOffline") <<
"L1TEGammaOffline::beginRun" << std::endl;
70 edm::LogInfo(
"L1TEGammaOffline") <<
"L1TEGammaOffline::bookHistograms" << std::endl;
81 edm::LogInfo(
"L1TEGammaOffline") <<
"L1TEGammaOffline::beginLuminosityBlock" << std::endl;
89 edm::LogInfo(
"L1TEGammaOffline") <<
"L1TEGammaOffline::analyze" << std::endl;
94 edm::LogError(
"L1TEGammaOffline") <<
"invalid collection: vertex " << std::endl;
98 unsigned int nVertex = vertexHandle->size();
115 edm::LogError(
"L1TEGammaOffline") <<
"invalid collection: GSF electrons " << std::endl;
118 if (gsfElectrons->size() == 0) {
119 LogDebug(
"L1TEGammaOffline") <<
"empty collection: GSF electrons " << std::endl;
127 LogDebug(
"L1TEGammaOffline") <<
"Could not find a tag & probe pair" << std::endl;
134 double minDeltaR = 0.3;
136 bool foundMatch =
false;
138 int bunchCrossing = 0;
140 double currentDeltaR =
deltaR(
egamma->eta(),
egamma->phi(), probeElectron.eta(), probeElectron.phi());
141 if (currentDeltaR > minDeltaR) {
144 minDeltaR = currentDeltaR;
145 closestL1EGamma = *
egamma;
152 LogDebug(
"L1TEGammaOffline") <<
"Could not find a matching L1 EGamma " << std::endl;
156 double recoEt = probeElectron.et();
157 double recoEta = probeElectron.eta();
158 double recoPhi = probeElectron.phi();
160 double l1Et = closestL1EGamma.
et();
161 double l1Eta = closestL1EGamma.
eta();
162 double l1Phi = closestL1EGamma.
phi();
165 double outOfBounds = 9999;
166 double resolutionEt = recoEt > 0 ? (l1Et - recoEt) / recoEt : outOfBounds;
167 double resolutionEta =
std::abs(recoEta) > 0 ? (l1Eta - recoEta) / recoEta : outOfBounds;
168 double resolutionPhi =
std::abs(recoPhi) > 0 ? (l1Phi - recoPhi) / recoPhi : outOfBounds;
193 if (l1Et > threshold) {
216 if (l1Et > threshold) {
244 bool foundBoth(
false);
245 auto nElectrons = electrons->size();
249 for (
auto tagElectron : *electrons) {
250 for (
auto probeElectron : *electrons) {
251 if (tagElectron.p4() == probeElectron.p4())
254 auto combined(tagElectron.p4() + probeElectron.p4());
255 auto tagAbsEta =
std::abs(tagElectron.eta());
256 auto probeAbsEta =
std::abs(probeElectron.eta());
259 bool isEBEEGap = tagElectron.isEBEEGap() || probeElectron.isEBEEGap();
260 bool passesEta = !isEBEEGap && tagAbsEta < 2.5 && probeAbsEta < 2.5;
261 bool passesCharge = tagElectron.charge() == -probeElectron.charge();
264 bool tagPassesMediumID =
passesMediumEleId(tagElectron) && tagElectron.et() > 30.;
266 bool passesInvariantMass = combined.M() > 60 && combined.M() < 120;
268 if (passesEta && passesInvariantMass && passesCharge && tagPassesMediumID && probePassesLooseID) {
290 const float ecal_energy_inverse = 1.0 / electron.
ecalEnergy();
292 const float eOverP =
std::abs(1.0 - eSCoverP) * ecal_energy_inverse;
294 if (electron.
isEB() && eOverP > 0.241)
296 if (electron.
isEE() && eOverP > 0.14)
325 const float ecal_energy_inverse = 1.0 / electron.
ecalEnergy();
327 const float eOverP =
std::abs(1.0 - eSCoverP) * ecal_energy_inverse;
329 if (electron.
isEB() && eOverP < 0.134)
331 if (electron.
isEE() && eOverP > 0.13)
362 edm::LogError(
"L1TEGammaOffline") <<
"invalid collection: reco::Photons " << std::endl;
370 if(photons->size() ==0){
371 LogDebug(
"L1TEGammaOffline") <<
"No photons found in event." << std::endl;
375 auto probePhoton = photons->at(0);
377 double minDeltaR = 0.3;
379 bool foundMatch =
false;
381 int bunchCrossing = 0;
383 double currentDeltaR =
deltaR(
egamma->eta(),
egamma->phi(), probePhoton.eta(), probePhoton.phi());
384 if (currentDeltaR > minDeltaR) {
387 minDeltaR = currentDeltaR;
388 closestL1EGamma = *
egamma;
395 LogDebug(
"L1TEGammaOffline") <<
"Could not find a matching L1 EGamma " << std::endl;
399 double recoEt = probePhoton.et();
400 double recoEta = probePhoton.eta();
401 double recoPhi = probePhoton.phi();
403 double l1Et = closestL1EGamma.
et();
404 double l1Eta = closestL1EGamma.
eta();
405 double l1Phi = closestL1EGamma.
phi();
408 double outOfBounds = 9999;
409 double resolutionEt = recoEt > 0 ? (l1Et - recoEt) / recoEt : outOfBounds;
410 double resolutionEta =
std::abs(recoEta) > 0 ? (l1Eta - recoEta) / recoEta : outOfBounds;
411 double resolutionPhi =
std::abs(recoPhi) > 0 ? (l1Phi - recoPhi) / recoPhi : outOfBounds;
436 if (l1Et > threshold) {
459 if (l1Et > threshold) {
472 edm::LogInfo(
"L1TEGammaOffline") <<
"L1TEGammaOffline::endLuminosityBlock" << std::endl;
480 edm::LogInfo(
"L1TEGammaOffline") <<
"L1TEGammaOffline::endRun" << std::endl;
490 h_nVertex_ = ibooker.
book1D(
"nVertex",
"Number of event vertices in collection", 40, -0.5, 39.5);
494 "L1 EGamma E_{T} vs GSF Electron E_{T} (EB); GSF Electron E_{T} (GeV); L1 EGamma E_{T} (GeV)", 300, 0, 300, 300,
497 "L1 EGamma E_{T} vs GSF Electron E_{T} (EE); GSF Electron E_{T} (GeV); L1 EGamma E_{T} (GeV)", 300, 0, 300, 300,
500 "L1 EGamma E_{T} vs GSF Electron E_{T} (EB+EE); GSF Electron E_{T} (GeV); L1 EGamma E_{T} (GeV)", 300, 0, 300,
504 "#phi_{electron}^{L1} vs #phi_{electron}^{offline} (EB); #phi_{electron}^{offline}; #phi_{electron}^{L1}", 100,
507 "#phi_{electron}^{L1} vs #phi_{electron}^{offline} (EE); #phi_{electron}^{offline}; #phi_{electron}^{L1}", 100,
510 "#phi_{electron}^{L1} vs #phi_{electron}^{offline} (EB+EE); #phi_{electron}^{offline}; #phi_{electron}^{L1}", 100,
514 "L1 EGamma #eta vs GSF Electron #eta; GSF Electron #eta; L1 EGamma #eta", 100, -3, 3, 100, -3, 3);
518 "electron ET resolution (EB); (L1 EGamma E_{T} - GSF Electron E_{T})/GSF Electron E_{T}; events", 50, -1, 1.5);
520 "electron ET resolution (EE); (L1 EGamma E_{T} - GSF Electron E_{T})/GSF Electron E_{T}; events", 50, -1, 1.5);
522 "electron ET resolution (EB+EE); (L1 EGamma E_{T} - GSF Electron E_{T})/GSF Electron E_{T}; events", 50, -1, 1.5);
525 ibooker.
book1D(
"resolutionElectronPhi_EB",
526 "#phi_{electron} resolution (EB); (#phi_{electron}^{L1} - #phi_{electron}^{offline})/#phi_{electron}^{offline}; events",
529 ibooker.
book1D(
"resolutionElectronPhi_EE",
530 "electron #phi resolution (EE); (#phi_{electron}^{L1} - #phi_{electron}^{offline})/#phi_{electron}^{offline}; events",
533 ibooker.
book1D(
"resolutionElectronPhi_EB_EE",
534 "electron #phi resolution (EB+EE); (#phi_{electron}^{L1} - #phi_{electron}^{offline})/#phi_{electron}^{offline}; events",
538 "electron #eta resolution (EB); (L1 EGamma #eta - GSF Electron #eta)/GSF Electron #eta; events", 120, -0.3, 0.3);
543 int nBins = electronBins.size() - 1;
544 float* electronBinArray = &(electronBins[0]);
549 "efficiencyElectronET_EB_threshold_" + str_threshold +
"_Num",
550 "electron efficiency (EB) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
552 "efficiencyElectronET_EE_threshold_" + str_threshold +
"_Num",
553 "electron efficiency (EE) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
555 "efficiencyElectronET_EB_EE_threshold_" + str_threshold +
"_Num",
556 "electron efficiency (EB+EE) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
559 "efficiencyElectronET_EB_threshold_" + str_threshold +
"_Den",
560 "electron efficiency (EB) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
562 "efficiencyElectronET_EE_threshold_" + str_threshold +
"_Den",
563 "electron efficiency (EE) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
565 "efficiencyElectronET_EB_EE_threshold_" + str_threshold +
"_Den",
566 "electron efficiency (EB+EE) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
577 "L1 EGamma E_{T} vs Photon E_{T} (EB); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)", 300, 0, 300, 300, 0, 300);
579 "L1 EGamma E_{T} vs Photon E_{T} (EE); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)", 300, 0, 300, 300, 0, 300);
581 "L1 EGamma E_{T} vs Photon E_{T} (EB+EE); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)", 300, 0, 300, 300, 0, 300);
584 "#phi_{photon}^{L1} vs #phi_{photon}^{offline} (EB); #phi_{photon}^{offline}; #phi_{photon}^{L1}", 100, -4, 4,
587 "#phi_{photon}^{L1} vs #phi_{photon}^{offline} (EE); #phi_{photon}^{offline}; #phi_{photon}^{L1}", 100, -4, 4,
590 "#phi_{photon}^{L1} vs #phi_{photon}^{offline} (EB+EE); #phi_{photon}^{offline}; #phi_{photon}^{L1}", 100, -4, 4,
594 "L1 EGamma #eta vs Photon #eta; Photon #eta; L1 EGamma #eta", 100, -3, 3, 100, -3, 3);
598 "photon ET resolution (EB); (L1 EGamma E_{T} - Photon E_{T})/ Photon E_{T}; events", 50, -1, 1.5);
600 "photon ET resolution (EE); (L1 EGamma E_{T} - Photon E_{T})/ Photon E_{T}; events", 50, -1, 1.5);
602 "photon ET resolution (EB+EE); (L1 EGamma E_{T} - Photon E_{T})/ Photon E_{T}; events", 50, -1, 1.5);
605 "#phi_{photon} resolution (EB); (#phi_{photon}^{L1} - #phi_{photon}^{offline})/#phi_{photon}^{offline}; events",
608 "photon #phi resolution (EE); (#phi_{photon}^{L1} - #phi_{photon}^{offline})/#phi_{photon}^{offline}; events",
611 "photon #phi resolution (EB+EE); (#phi_{photon}^{L1} - #phi_{photon}^{offline})/#phi_{photon}^{offline}; events",
615 "photon #eta resolution (EB); (L1 EGamma #eta - Photon #eta)/ Photon #eta; events", 120, -0.3, 0.3);
620 int nBins = photonBins.size() - 1;
621 float* photonBinArray = &(photonBins[0]);
626 "efficiencyPhotonET_EB_threshold_" + str_threshold +
"_Num",
627 "photon efficiency (EB) (numerator); Photon E_{T} (GeV); events", nBins, photonBinArray);
629 "efficiencyPhotonET_EE_threshold_" + str_threshold +
"_Num",
630 "photon efficiency (EE) (numerator); Photon E_{T} (GeV); events", nBins, photonBinArray);
632 "efficiencyPhotonET_EB_EE_threshold_" + str_threshold +
"_Num",
633 "photon efficiency (EB+EE) (numerator); Photon E_{T} (GeV); events", nBins, photonBinArray);
636 "efficiencyPhotonET_EB_threshold_" + str_threshold +
"_Den",
637 "photon efficiency (EB) (denominator); Photon E_{T} (GeV); events", nBins, photonBinArray);
639 "efficiencyPhotonET_EE_threshold_" + str_threshold +
"_Den",
640 "photon efficiency (EE) (denominator); Photon E_{T} (GeV); events", nBins, photonBinArray);
642 "efficiencyPhotonET_EB_EE_threshold_" + str_threshold +
"_Den",
643 "photon efficiency (EB+EE) (denominator); Photon E_{T} (GeV); events", nBins, photonBinArray);
BXVector< EGamma > EGammaBxCollection
const_iterator end(int bx) const
void bookElectronHistos(DQMStore::IBooker &)
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
void fillPhotons(edm::Event const &e, const unsigned int nVertex)
std::vector< double > electronEfficiencyBins_
MonitorElement * h_resolutionElectronPhi_EB_EE_
MonitorElement * h_L1EGammaPhivsElectronPhi_EE_
edm::EDGetTokenT< reco::GsfElectronCollection > theGsfElectronCollection_
MonitorElement * h_tagAndProbeMass_
std::map< double, MonitorElement * > h_efficiencyPhotonET_EE_total_
MonitorElement * h_L1EGammaETvsElectronET_EB_EE_
float eSuperClusterOverP() const
std::map< double, MonitorElement * > h_efficiencyPhotonET_EB_pass_
MonitorElement * h_L1EGammaPhivsPhotonPhi_EB_
bool passesMediumEleId(reco::GsfElectron const &electron) const
virtual double eta() const final
momentum pseudorapidity
MonitorElement * h_L1EGammaETvsPhotonET_EB_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< std::vector< reco::Photon > > thePhotonCollection_
#define DEFINE_FWK_MODULE(type)
std::map< double, MonitorElement * > h_efficiencyElectronET_EB_EE_pass_
MonitorElement * h_L1EGammaETvsPhotonET_EE_
void fillElectrons(edm::Event const &e, const unsigned int nVertex)
std::map< double, MonitorElement * > h_efficiencyPhotonET_EB_EE_total_
MonitorElement * h_resolutionPhotonET_EE_
void analyze(edm::Event const &e, edm::EventSetup const &eSetup)
std::vector< Vertex > VertexCollection
collection of Vertex objects
MonitorElement * h_resolutionElectronET_EB_
std::map< double, MonitorElement * > h_efficiencyElectronET_EB_total_
bool passesLooseEleId(reco::GsfElectron const &electron) const
void bookPhotonHistos(DQMStore::IBooker &)
L1TEGammaOffline(const edm::ParameterSet &ps)
MonitorElement * h_L1EGammaETvsElectronET_EB_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
MonitorElement * h_L1EGammaPhivsElectronPhi_EB_EE_
std::map< double, MonitorElement * > h_efficiencyPhotonET_EB_EE_pass_
MonitorElement * h_resolutionElectronET_EE_
virtual double phi() const final
momentum azimuthal angle
virtual double et() const final
transverse energy
float deltaEtaSuperClusterTrackAtVtx() const
float hadronicOverEm() const
std::vector< double > electronEfficiencyThresholds_
MonitorElement * h_L1EGammaPhivsPhotonPhi_EB_EE_
virtual ~L1TEGammaOffline()
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup)
float deltaPhiSuperClusterTrackAtVtx() const
MonitorElement * h_L1EGammaEtavsElectronEta_
MonitorElement * h_resolutionPhotonET_EB_
MonitorElement * book1D(Args &&...args)
edm::EDGetTokenT< l1t::EGammaBxCollection > stage2CaloLayer2EGammaToken_
MonitorElement * h_resolutionElectronEta_
Abs< T >::type abs(const T &t)
reco::GsfElectron tagElectron_
MonitorElement * h_resolutionPhotonEta_
float scSigmaIEtaIEta() const
MonitorElement * h_L1EGammaPhivsPhotonPhi_EE_
std::map< double, MonitorElement * > h_efficiencyElectronET_EE_total_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
double deltaR(double eta1, double eta2, double phi1, double phi2)
bool findTagAndProbePair(edm::Handle< reco::GsfElectronCollection > const &electrons)
void setCurrentFolder(const std::string &fullpath)
std::map< double, MonitorElement * > h_efficiencyPhotonET_EB_total_
std::string efficiencyFolder_
std::map< double, MonitorElement * > h_efficiencyElectronET_EE_pass_
reco::GsfElectron probeElectron_
MonitorElement * book2D(Args &&...args)
MonitorElement * h_resolutionPhotonPhi_EB_EE_
void fill2DWithinLimits(MonitorElement *mon, double valueX, double valueY, double weight=1.)
MonitorElement * h_resolutionElectronET_EB_EE_
std::map< double, MonitorElement * > h_efficiencyElectronET_EB_EE_total_
MonitorElement * h_resolutionElectronPhi_EB_
MonitorElement * h_nVertex_
void fillWithinLimits(MonitorElement *mon, double value, double weight=1.)
MonitorElement * h_resolutionPhotonPhi_EB_
std::vector< double > photonEfficiencyBins_
MonitorElement * h_L1EGammaETvsPhotonET_EB_EE_
MonitorElement * h_L1EGammaETvsElectronET_EE_
MonitorElement * h_resolutionElectronPhi_EE_
MonitorElement * h_L1EGammaEtavsPhotonEta_
MonitorElement * h_resolutionPhotonPhi_EE_
edm::EDGetTokenT< reco::VertexCollection > thePVCollection_
std::vector< double > photonEfficiencyThresholds_
std::map< double, MonitorElement * > h_efficiencyElectronET_EB_pass_
const_iterator begin(int bx) const
MonitorElement * h_L1EGammaPhivsElectronPhi_EB_
std::map< double, MonitorElement * > h_efficiencyPhotonET_EE_pass_
MonitorElement * h_resolutionPhotonET_EB_EE_
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup)