CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 47 of file EmDQM.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file EmDQM.h.

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

Definition at line 50 of file EmDQM.h.

50 {};

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 HLT_FULL_cff::DeltaR, HLT_FULL_cff::deltaR, HistoFillerReco< T >::dqm, runTauDisplay::dr, PVValHelper::eta, mps_fire::i, dqmiolumiharvest::j, dqmiodumpmetadata::n, PVValHelper::phi, EmDQMReco::theHLTCollectionLabels, EmDQMReco::theHLTOutputTypes, trigger::TriggerL1IsoEG, and trigger::TriggerL1NoIsoEG.

Referenced by EmDQM::analyze().

916  {
917  std::vector<edm::Ref<T>> recoecalcands;
918  if ((triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]) >= triggerObj->size())) { // only process if available
920  accepted = false;
921  return;
922  }
923 
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
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 }
std::vector< std::vector< MonitorElement * > > etaphihists
Definition: EmDQM.h:208
std::vector< MonitorElement * > totalmatchs
Definition: EmDQM.h:213
bool noPhiPlots_
Definition: EmDQM.h:116
std::vector< std::vector< MonitorElement * > > etahistmatchs
Definition: EmDQM.h:202
std::vector< std::vector< MonitorElement * > > histEtaPhiOfHltObjMatchToGens
Definition: EmDQM.h:210
std::set< std::string > hltCollectionLabelsFound
Definition: EmDQM.h:189
std::vector< std::vector< MonitorElement * > > histPhiOfHltObjMatchToGens
Definition: EmDQM.h:207
Log< level::Error, false > LogError
std::vector< std::vector< MonitorElement * > > phihists
Definition: EmDQM.h:200
static const unsigned OUTPUT_ERRORS
Definition: EmDQM.h:245
EmDQM * dqm
Definition: EmDQM.h:62
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQM.h:158
std::vector< unsigned int > nCandCuts
Definition: EmDQM.h:166
std::vector< MonitorElement * > totals
Definition: EmDQM.h:212
std::set< std::string > hltCollectionLabelsMissed
Definition: EmDQM.h:193
std::vector< std::vector< MonitorElement * > > ethistmatchs
Definition: EmDQM.h:204
std::vector< std::vector< MonitorElement * > > etaphihistmatchs
Definition: EmDQM.h:209
std::vector< std::vector< MonitorElement * > > histEtaOfHltObjMatchToGens
Definition: EmDQM.h:206
std::vector< std::vector< MonitorElement * > > phihistmatchs
Definition: EmDQM.h:203
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
bool mcMatchedOnly_
Definition: EmDQM.h:115
std::vector< std::vector< MonitorElement * > > histEtOfHltObjMatchToGens
Definition: EmDQM.h:205
unsigned int verbosity_
Definition: EmDQM.h:101
std::vector< int > theHLTOutputTypes
Definition: EmDQM.h:162
unsigned int minEtForEtaEffPlot_
Definition: EmDQM.h:113
std::vector< std::vector< MonitorElement * > > etahists
Definition: EmDQM.h:199
std::vector< std::vector< MonitorElement * > > ethists
Definition: EmDQM.h:201

Member Data Documentation

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

Definition at line 62 of file EmDQM.h.