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

Constructor & Destructor Documentation

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

Definition at line 53 of file EmDQM.h.

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

Definition at line 54 of file EmDQM.h.

54 {};

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 
)

Definition at line 887 of file EmDQM.cc.

References deltaR(), HiRegitMuonDetachedTripletStep_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().

888 {
889  std::vector<edm::Ref<T> > recoecalcands;
890  if ( ( triggerObj->filterIndex(dqm->theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if available
891  dqm->hltCollectionLabelsMissed.insert(dqm->theHLTCollectionLabels[n].encode());
892  accepted = false;
893  return;
894  }
895 
896  dqm->hltCollectionLabelsFound.insert(dqm->theHLTCollectionLabels[n].encode());
897 
899  // Retrieve saved filter objects //
901  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),dqm->theHLTOutputTypes[n],recoecalcands);
902  //Danger: special case, L1 non-isolated
903  // needs to be merged with L1 iso
904  if (dqm->theHLTOutputTypes[n] == trigger::TriggerL1NoIsoEG){
905  std::vector<edm::Ref<T> > isocands;
906  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),trigger::TriggerL1IsoEG,isocands);
907  if (!isocands.empty())
908  {
909  for (unsigned int i=0; i < isocands.size(); i++)
910  recoecalcands.push_back(isocands[i]);
911  }
912  } // END of if theHLTOutputTypes == 82
913 
914 
915  if (recoecalcands.empty()){ // stop if no object passed the previous filter
916  accepted = false;
917  return;
918  }
919 
920  //if (recoecalcands.size() >= reqNum )
921  if (recoecalcands.size() >= dqm->nCandCuts.at(n) && !dqm->mcMatchedOnly_)
922  dqm->totals.at(vPos)->Fill(n+0.5);
923 
925  // check for validity //
926  // prevents crash in CMSSW_3_1_0_pre6 //
928  for (unsigned int j=0; j<recoecalcands.size(); j++){
929  if(!( recoecalcands.at(j).isAvailable())){
930  if (dqm->verbosity_ >= dqm->OUTPUT_ERRORS)
931  edm::LogError("EmDQMInvalidRefs") << "Event content inconsistent: TriggerEventWithRefs contains invalid Refs. Invalid refs for: " << dqm->theHLTCollectionLabels[n].label() << ". The collection that this module uses may has been dropped in the event.";
932  return;
933  }
934  }
935 
936  if (!dqm->mcMatchedOnly_) {
938  // Loop over the Generated Particles, and find the //
939  // closest HLT object match. //
941  //for (unsigned int i=0; i < gencut_; i++) {
942  for (unsigned int i=0; i < dqm->nCandCuts.at(n); i++) {
943  math::XYZVector currentGenParticleMomentum = sortedGen[i].momentum();
944 
945  float closestDeltaR = 0.5;
946  int closestEcalCandIndex = -1;
947  for (unsigned int j=0; j<recoecalcands.size(); j++) {
948  float deltaR = DeltaR(recoecalcands[j]->momentum(),currentGenParticleMomentum);
949 
950  if (deltaR < closestDeltaR) {
951  closestDeltaR = deltaR;
952  closestEcalCandIndex = j;
953  }
954  }
955 
956  // If an HLT object was found within some delta-R
957  // of this gen particle, store it in a histogram
958  if ( closestEcalCandIndex >= 0 ) {
959  dqm->histEtOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->et() );
960  dqm->histEtaOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->eta() );
961  if (!dqm->noPhiPlots_) dqm->histPhiOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->phi() );
962  dqm->histEtaPhiOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->eta(),recoecalcands[closestEcalCandIndex]->phi());
963  } // END of if closestEcalCandIndex >= 0
964  }
965 
967  // Loop over all HLT objects in this filter step, and //
968  // fill histograms. //
970  // bool foundAllMatches = false;
971  // unsigned int numOfHLTobjectsMatched = 0;
972  for (unsigned int i=0; i<recoecalcands.size(); i++) {
974  //float closestGenParticleDr = 99.0;
975  //for(unsigned int j =0; j < gencut_; j++) {
976  // math::XYZVector currentGenParticle = sortedGen[j].momentum();
977 
978  // double currentDeltaR = DeltaR(recoecalcands[i]->momentum(),currentGenParticle);
979  // if ( currentDeltaR < closestGenParticleDr ) {
980  // closestGenParticleDr = currentDeltaR;
981  // }
982  //}
984  //if ( !(fabs(closestGenParticleDr < 0.3)) ) continue;
985 
986  //numOfHLTobjectsMatched++;
987  //if (numOfHLTobjectsMatched >= gencut_) foundAllMatches=true;
988 
989  // Fill HLT object histograms
990  dqm->ethists.at(vPos).at(n) ->Fill(recoecalcands[i]->et() );
991  dqm->etahists.at(vPos).at(n)->Fill(recoecalcands[i]->eta() );
992  if (!dqm->noPhiPlots_) dqm->phihists.at(vPos).at(n)->Fill(recoecalcands[i]->phi() );
993  dqm->etaphihists.at(vPos).at(n)->Fill(recoecalcands[i]->eta(),recoecalcands[i]->phi() );
994  }
995  }
996 
998  // Fill mc matched objects into histograms //
1000  unsigned int matchedMcParts = 0;
1001  float mindist=0.3;
1002  if(n==0) mindist=0.5; //low L1-resolution => allow wider matching
1003  for(unsigned int i =0; i < dqm->nCandCuts.at(n); ++i){
1004  //match generator candidate
1005  bool matchThis= false;
1006  math::XYZVector candDir=sortedGen[i].momentum();
1007  //unsigned int closest = 0;
1008  double closestDr = 1000.;
1009  for(unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); ++trigOb){
1010  double dr = DeltaR(recoecalcands[trigOb]->momentum(),candDir);
1011  if (dr < closestDr) {
1012  closestDr = dr;
1013  //closest = trigOb;
1014  }
1015  if (closestDr > mindist) { // it's not really a "match" if it's that far away
1016  //closest = -1;
1017  } else {
1018  matchedMcParts++;
1019  matchThis = true;
1020  }
1021  }
1022  if ( !matchThis ) {
1023  accepted = false;
1024  continue; // only plot matched candidates
1025  }
1026  // fill coordinates of mc particle matching trigger object
1027  dqm->ethistmatchs.at(vPos).at(n) ->Fill( sortedGen[i].et() );
1028  if (sortedGen[i].et() > dqm->minEtForEtaEffPlot_) {
1029  dqm->etahistmatchs.at(vPos).at(n)->Fill( sortedGen[i].eta() );
1030  if (!dqm->noPhiPlots_) dqm->phihistmatchs.at(vPos).at(n)->Fill( sortedGen[i].phi() );
1031  dqm->etaphihistmatchs.at(vPos).at(n)->Fill( sortedGen[i].eta(),sortedGen[i].phi() );
1032  }
1033  }
1034  // fill total mc matched efficiency
1035 
1036  if (matchedMcParts >= dqm->nCandCuts.at(n) && accepted == true)
1037  dqm->totalmatchs.at(vPos)->Fill(n+0.5);
1038 }
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
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
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 60 of file EmDQM.h.