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 895 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().

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