CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HistoFiller< T > Class Template Reference

#include <EmDQM.h>

Public Member Functions

void fillHistos (edm::Handle< trigger::TriggerEventWithRefs > &, const edm::Event &, unsigned int, unsigned int, std::vector< reco::Particle > &, bool &)
 
 HistoFiller (EmDQM *d)
 
 ~HistoFiller ()
 

Private Attributes

EmDQMdqm
 

Detailed Description

template<class T>
class HistoFiller< T >

Definition at line 49 of file EmDQM.h.

Constructor & Destructor Documentation

template<class T>
HistoFiller< T >::HistoFiller ( EmDQM d)
inline

Definition at line 51 of file EmDQM.h.

51 : dqm(d){};
EmDQM * dqm
Definition: EmDQM.h:64
template<class T>
HistoFiller< T >::~HistoFiller ( )
inline

Definition at line 52 of file EmDQM.h.

52 {};

Member Function Documentation

template<class T >
void HistoFiller< T >::fillHistos ( edm::Handle< trigger::TriggerEventWithRefs > &  triggerObj,
const edm::Event iEvent,
unsigned int  vPos,
unsigned int  n,
std::vector< reco::Particle > &  sortedGen,
bool &  accepted 
)

If this HLT object did not have a gen particle match, go to next HLT object

Definition at line 911 of file EmDQM.cc.

References HiRegitMuonDetachedTripletStep_cff::DeltaR, boostedElectronIsolation_cff::deltaR, runTauDisplay::dr, stringResolutionProvider_cfi::et, PVValHelper::eta, trigger::TriggerEventWithRefs::filterIndex(), trigger::TriggerEventWithRefs::getObjects(), mps_fire::i, gen::n, phi, trigger::TriggerEventWithRefs::size(), trigger::TriggerL1IsoEG, and trigger::TriggerL1NoIsoEG.

Referenced by EmDQM::analyze(), and HistoFiller< l1extra::L1EmParticleCollection >::~HistoFiller().

916  {
917  std::vector<edm::Ref<T>> recoecalcands;
918  if ((triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]) >= triggerObj->size())) { // only process if available
919  dqm->hltCollectionLabelsMissed.insert(dqm->theHLTCollectionLabels[n].encode());
920  accepted = false;
921  return;
922  }
923 
924  dqm->hltCollectionLabelsFound.insert(dqm->theHLTCollectionLabels[n].encode());
925 
927  // Retrieve saved filter objects //
929  triggerObj->getObjects(
930  triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]), dqm->theHLTOutputTypes[n], recoecalcands);
931  // Danger: special case, L1 non-isolated
932  // needs to be merged with L1 iso
933  if (dqm->theHLTOutputTypes[n] == trigger::TriggerL1NoIsoEG) {
934  std::vector<edm::Ref<T>> isocands;
935  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]), trigger::TriggerL1IsoEG, isocands);
936  if (!isocands.empty()) {
937  for (unsigned int i = 0; i < isocands.size(); i++)
938  recoecalcands.push_back(isocands[i]);
939  }
940  } // END of if theHLTOutputTypes == 82
941 
942  if (recoecalcands.empty()) { // stop if no object passed the previous filter
943  accepted = false;
944  return;
945  }
946 
947  // if (recoecalcands.size() >= reqNum )
948  if (recoecalcands.size() >= dqm->nCandCuts.at(n) && !dqm->mcMatchedOnly_)
949  dqm->totals.at(vPos)->Fill(n + 0.5);
950 
952  // check for validity //
953  // prevents crash in CMSSW_3_1_0_pre6 //
955  for (unsigned int j = 0; j < recoecalcands.size(); j++) {
956  if (!(recoecalcands.at(j).isAvailable())) {
957  if (dqm->verbosity_ >= dqm->OUTPUT_ERRORS)
958  edm::LogError("EmDQMInvalidRefs") << "Event content inconsistent: TriggerEventWithRefs contains "
959  "invalid Refs. Invalid refs for: "
960  << dqm->theHLTCollectionLabels[n].label()
961  << ". The collection that this module uses may has been dropped in "
962  "the event.";
963  return;
964  }
965  }
966 
967  if (!dqm->mcMatchedOnly_) {
969  // Loop over the Generated Particles, and find the //
970  // closest HLT object match. //
972  // for (unsigned int i=0; i < gencut_; i++) {
973  for (unsigned int i = 0; i < dqm->nCandCuts.at(n); i++) {
974  math::XYZVector currentGenParticleMomentum = sortedGen[i].momentum();
975 
976  float closestDeltaR = 0.5;
977  int closestEcalCandIndex = -1;
978  for (unsigned int j = 0; j < recoecalcands.size(); j++) {
979  float deltaR = DeltaR(recoecalcands[j]->momentum(), currentGenParticleMomentum);
980 
981  if (deltaR < closestDeltaR) {
982  closestDeltaR = deltaR;
983  closestEcalCandIndex = j;
984  }
985  }
986 
987  // If an HLT object was found within some delta-R
988  // of this gen particle, store it in a histogram
989  if (closestEcalCandIndex >= 0) {
990  dqm->histEtOfHltObjMatchToGens.at(vPos).at(n)->Fill(recoecalcands[closestEcalCandIndex]->et());
991  dqm->histEtaOfHltObjMatchToGens.at(vPos).at(n)->Fill(recoecalcands[closestEcalCandIndex]->eta());
992  if (!dqm->noPhiPlots_)
993  dqm->histPhiOfHltObjMatchToGens.at(vPos).at(n)->Fill(recoecalcands[closestEcalCandIndex]->phi());
994  dqm->histEtaPhiOfHltObjMatchToGens.at(vPos).at(n)->Fill(recoecalcands[closestEcalCandIndex]->eta(),
995  recoecalcands[closestEcalCandIndex]->phi());
996  } // END of if closestEcalCandIndex >= 0
997  }
998 
1000  // Loop over all HLT objects in this filter step, and //
1001  // fill histograms. //
1003  // bool foundAllMatches = false;
1004  // unsigned int numOfHLTobjectsMatched = 0;
1005  for (unsigned int i = 0; i < recoecalcands.size(); i++) {
1007  // float closestGenParticleDr = 99.0;
1008  // for(unsigned int j =0; j < gencut_; j++) {
1009  // math::XYZVector currentGenParticle = sortedGen[j].momentum();
1010 
1011  // double currentDeltaR =
1012  // DeltaR(recoecalcands[i]->momentum(),currentGenParticle); if (
1013  // currentDeltaR < closestGenParticleDr ) {
1014  // closestGenParticleDr = currentDeltaR;
1015  // }
1016  //}
1019  // if ( !(fabs(closestGenParticleDr < 0.3)) ) continue;
1020 
1021  // numOfHLTobjectsMatched++;
1022  // if (numOfHLTobjectsMatched >= gencut_) foundAllMatches=true;
1023 
1024  // Fill HLT object histograms
1025  dqm->ethists.at(vPos).at(n)->Fill(recoecalcands[i]->et());
1026  dqm->etahists.at(vPos).at(n)->Fill(recoecalcands[i]->eta());
1027  if (!dqm->noPhiPlots_)
1028  dqm->phihists.at(vPos).at(n)->Fill(recoecalcands[i]->phi());
1029  dqm->etaphihists.at(vPos).at(n)->Fill(recoecalcands[i]->eta(), recoecalcands[i]->phi());
1030  }
1031  }
1032 
1034  // Fill mc matched objects into histograms //
1036  unsigned int matchedMcParts = 0;
1037  float mindist = 0.3;
1038  if (n == 0)
1039  mindist = 0.5; // low L1-resolution => allow wider matching
1040  for (unsigned int i = 0; i < dqm->nCandCuts.at(n); ++i) {
1041  // match generator candidate
1042  bool matchThis = false;
1043  math::XYZVector candDir = sortedGen[i].momentum();
1044  // unsigned int closest = 0;
1045  double closestDr = 1000.;
1046  for (unsigned int trigOb = 0; trigOb < recoecalcands.size(); ++trigOb) {
1047  double dr = DeltaR(recoecalcands[trigOb]->momentum(), candDir);
1048  if (dr < closestDr) {
1049  closestDr = dr;
1050  // closest = trigOb;
1051  }
1052  if (closestDr > mindist) { // it's not really a "match" if it's that far away
1053  // closest = -1;
1054  } else {
1055  matchedMcParts++;
1056  matchThis = true;
1057  }
1058  }
1059  if (!matchThis) {
1060  accepted = false;
1061  continue; // only plot matched candidates
1062  }
1063  // fill coordinates of mc particle matching trigger object
1064  dqm->ethistmatchs.at(vPos).at(n)->Fill(sortedGen[i].et());
1065  if (sortedGen[i].et() > dqm->minEtForEtaEffPlot_) {
1066  dqm->etahistmatchs.at(vPos).at(n)->Fill(sortedGen[i].eta());
1067  if (!dqm->noPhiPlots_)
1068  dqm->phihistmatchs.at(vPos).at(n)->Fill(sortedGen[i].phi());
1069  dqm->etaphihistmatchs.at(vPos).at(n)->Fill(sortedGen[i].eta(), sortedGen[i].phi());
1070  }
1071  }
1072  // fill total mc matched efficiency
1073 
1074  if (matchedMcParts >= dqm->nCandCuts.at(n) && accepted == true)
1075  dqm->totalmatchs.at(vPos)->Fill(n + 0.5);
1076 }
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type
bool accepted(std::vector< std::string_view > const &, std::string_view)
size_type size() const
number of filters
et
define resolution functions of each parameter

Member Data Documentation

template<class T>
EmDQM* HistoFiller< T >::dqm
private

Definition at line 64 of file EmDQM.h.