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

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