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 48 of file EmDQM.h.

Constructor & Destructor Documentation

◆ HistoFiller()

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

Definition at line 50 of file EmDQM.h.

50 : dqm(d){};

◆ ~HistoFiller()

template<class T>
HistoFiller< T >::~HistoFiller ( )
inline

Definition at line 51 of file EmDQM.h.

51 {};

Member Function Documentation

◆ fillHistos()

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.

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 }

Referenced by EmDQM::analyze().

Member Data Documentation

◆ dqm

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

Definition at line 63 of file EmDQM.h.

mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
trigger::TriggerL1IsoEG
Definition: TriggerTypeDefs.h:32
trigger::TriggerEventWithRefs::getObjects
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type
Definition: TriggerEventWithRefs.h:329
HistoFiller::dqm
EmDQM * dqm
Definition: EmDQM.h:63
PVValHelper::eta
Definition: PVValidationHelpers.h:69
trigger::TriggerEventWithRefs::filterIndex
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
Definition: TriggerEventWithRefs.h:188
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
trigger::TriggerEventWithRefs::size
size_type size() const
number of filters
Definition: TriggerEventWithRefs.h:180
DDAxes::phi
trigger::TriggerL1NoIsoEG
Definition: TriggerTypeDefs.h:31
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
ztail.d
d
Definition: ztail.py:151
dqm
Definition: DQMStore.h:18
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66