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 866 of file EmDQM.cc.

References deltaR(), HiRegitMuonDetachedTripletStep_cff::DeltaR, runTauDisplay::dr, stringResolutionProvider_cfi::et, stringResolutionProvider_cfi::eta, trigger::TriggerEventWithRefs::filterIndex(), trigger::TriggerEventWithRefs::getObjects(), i, j, gen::n, phi, trigger::TriggerEventWithRefs::size(), trigger::TriggerL1IsoEG, and trigger::TriggerL1NoIsoEG.

Referenced by EmDQM::analyze(), and HistoFiller< l1extra::L1EmParticleCollection >::~HistoFiller().

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