CMS 3D CMS Logo

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

References deltaR(), HLT_25ns14e33_v1_cff::DeltaR, HistoFillerReco< T >::dqm, eta(), i, j, gen::n, phi, EmDQMReco::theHLTCollectionLabels, EmDQMReco::theHLTOutputTypes, trigger::TriggerL1IsoEG, and trigger::TriggerL1NoIsoEG.

Referenced by EmDQM::analyze().

864 {
865  std::vector<edm::Ref<T> > recoecalcands;
866  if ( ( triggerObj->filterIndex(dqm->theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if available
868  accepted = false;
869  return;
870  }
871 
873 
875  // Retrieve saved filter objects //
877  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),dqm->theHLTOutputTypes[n],recoecalcands);
878  //Danger: special case, L1 non-isolated
879  // needs to be merged with L1 iso
881  std::vector<edm::Ref<T> > isocands;
882  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),trigger::TriggerL1IsoEG,isocands);
883  if (isocands.size()>0)
884  {
885  for (unsigned int i=0; i < isocands.size(); i++)
886  recoecalcands.push_back(isocands[i]);
887  }
888  } // END of if theHLTOutputTypes == 82
889 
890 
891  if (recoecalcands.size() < 1){ // stop if no object passed the previous filter
892  accepted = false;
893  return;
894  }
895 
896  //if (recoecalcands.size() >= reqNum )
897  if (recoecalcands.size() >= dqm->nCandCuts.at(n) && !dqm->mcMatchedOnly_)
898  dqm->totals.at(vPos)->Fill(n+0.5);
899 
901  // check for validity //
902  // prevents crash in CMSSW_3_1_0_pre6 //
904  for (unsigned int j=0; j<recoecalcands.size(); j++){
905  if(!( recoecalcands.at(j).isAvailable())){
906  if (dqm->verbosity_ >= dqm->OUTPUT_ERRORS)
907  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.";
908  return;
909  }
910  }
911 
912  if (!dqm->mcMatchedOnly_) {
914  // Loop over the Generated Particles, and find the //
915  // closest HLT object match. //
917  //for (unsigned int i=0; i < gencut_; i++) {
918  for (unsigned int i=0; i < dqm->nCandCuts.at(n); i++) {
919  math::XYZVector currentGenParticleMomentum = sortedGen[i].momentum();
920 
921  float closestDeltaR = 0.5;
922  int closestEcalCandIndex = -1;
923  for (unsigned int j=0; j<recoecalcands.size(); j++) {
924  float deltaR = DeltaR(recoecalcands[j]->momentum(),currentGenParticleMomentum);
925 
926  if (deltaR < closestDeltaR) {
927  closestDeltaR = deltaR;
928  closestEcalCandIndex = j;
929  }
930  }
931 
932  // If an HLT object was found within some delta-R
933  // of this gen particle, store it in a histogram
934  if ( closestEcalCandIndex >= 0 ) {
935  dqm->histEtOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->et() );
936  dqm->histEtaOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->eta() );
937  if (!dqm->noPhiPlots_) dqm->histPhiOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->phi() );
938 
939  } // END of if closestEcalCandIndex >= 0
940  }
941 
943  // Loop over all HLT objects in this filter step, and //
944  // fill histograms. //
946  // bool foundAllMatches = false;
947  // unsigned int numOfHLTobjectsMatched = 0;
948  for (unsigned int i=0; i<recoecalcands.size(); i++) {
950  //float closestGenParticleDr = 99.0;
951  //for(unsigned int j =0; j < gencut_; j++) {
952  // math::XYZVector currentGenParticle = sortedGen[j].momentum();
953 
954  // double currentDeltaR = DeltaR(recoecalcands[i]->momentum(),currentGenParticle);
955  // if ( currentDeltaR < closestGenParticleDr ) {
956  // closestGenParticleDr = currentDeltaR;
957  // }
958  //}
960  //if ( !(fabs(closestGenParticleDr < 0.3)) ) continue;
961 
962  //numOfHLTobjectsMatched++;
963  //if (numOfHLTobjectsMatched >= gencut_) foundAllMatches=true;
964 
965  // Fill HLT object histograms
966  dqm->ethists.at(vPos).at(n) ->Fill(recoecalcands[i]->et() );
967  dqm->etahists.at(vPos).at(n)->Fill(recoecalcands[i]->eta() );
968  if (!dqm->noPhiPlots_) dqm->phihists.at(vPos).at(n)->Fill(recoecalcands[i]->phi() );
969 
970  }
971  }
972 
974  // Fill mc matched objects into histograms //
976  unsigned int matchedMcParts = 0;
977  float mindist=0.3;
978  if(n==0) mindist=0.5; //low L1-resolution => allow wider matching
979  for(unsigned int i =0; i < dqm->nCandCuts.at(n); ++i){
980  //match generator candidate
981  bool matchThis= false;
982  math::XYZVector candDir=sortedGen[i].momentum();
983  //unsigned int closest = 0;
984  double closestDr = 1000.;
985  for(unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); ++trigOb){
986  double dr = DeltaR(recoecalcands[trigOb]->momentum(),candDir);
987  if (dr < closestDr) {
988  closestDr = dr;
989  //closest = trigOb;
990  }
991  if (closestDr > mindist) { // it's not really a "match" if it's that far away
992  //closest = -1;
993  } else {
994  matchedMcParts++;
995  matchThis = true;
996  }
997  }
998  if ( !matchThis ) {
999  accepted = false;
1000  continue; // only plot matched candidates
1001  }
1002  // fill coordinates of mc particle matching trigger object
1003  dqm->ethistmatchs.at(vPos).at(n) ->Fill( sortedGen[i].et() );
1004  if (sortedGen[i].et() > dqm->minEtForEtaEffPlot_) {
1005  dqm->etahistmatchs.at(vPos).at(n)->Fill( sortedGen[i].eta() );
1006  if (!dqm->noPhiPlots_) dqm->phihistmatchs.at(vPos).at(n)->Fill( sortedGen[i].phi() );
1007  }
1008  }
1009  // fill total mc matched efficiency
1010 
1011  if (matchedMcParts >= dqm->nCandCuts.at(n) && accepted == true)
1012  dqm->totalmatchs.at(vPos)->Fill(n+0.5);
1013 }
std::vector< MonitorElement * > totals
Definition: EmDQM.h:207
int i
Definition: DBlmapReader.cc:9
std::vector< std::vector< MonitorElement * > > histEtOfHltObjMatchToGens
Definition: EmDQM.h:203
std::vector< std::vector< MonitorElement * > > phihists
Definition: EmDQM.h:198
bool noPhiPlots_
Definition: EmDQM.h:114
std::set< std::string > hltCollectionLabelsFound
Definition: EmDQM.h:186
std::vector< std::vector< MonitorElement * > > histPhiOfHltObjMatchToGens
Definition: EmDQM.h:205
T eta() const
std::vector< std::vector< MonitorElement * > > etahists
Definition: EmDQM.h:197
static const unsigned OUTPUT_ERRORS
Definition: EmDQM.h:239
EmDQM * dqm
Definition: EmDQM.h:60
std::vector< std::vector< MonitorElement * > > ethists
Definition: EmDQM.h:199
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQM.h:156
std::vector< std::vector< MonitorElement * > > ethistmatchs
Definition: EmDQM.h:202
std::vector< unsigned int > nCandCuts
Definition: EmDQM.h:164
std::set< std::string > hltCollectionLabelsMissed
Definition: EmDQM.h:190
std::vector< std::vector< MonitorElement * > > etahistmatchs
Definition: EmDQM.h:200
int j
Definition: DBlmapReader.cc:9
std::vector< std::vector< MonitorElement * > > phihistmatchs
Definition: EmDQM.h:201
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
std::vector< std::vector< MonitorElement * > > histEtaOfHltObjMatchToGens
Definition: EmDQM.h:204
std::vector< MonitorElement * > totalmatchs
Definition: EmDQM.h:208
bool mcMatchedOnly_
Definition: EmDQM.h:113
unsigned int verbosity_
Definition: EmDQM.h:102
std::vector< int > theHLTOutputTypes
Definition: EmDQM.h:160
unsigned int minEtForEtaEffPlot_
Definition: EmDQM.h:111
Definition: DDAxes.h:10

Member Data Documentation

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

Definition at line 60 of file EmDQM.h.