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

Constructor & Destructor Documentation

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

Definition at line 52 of file EmDQM.h.

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

Definition at line 53 of file EmDQM.h.

53 {};

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

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

Referenced by EmDQM::analyze().

873 {
874  std::vector<edm::Ref<T> > recoecalcands;
875  if ( ( triggerObj->filterIndex(dqm->theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if available
877  accepted = false;
878  return;
879  }
880 
882 
884  // Retrieve saved filter objects //
886  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),dqm->theHLTOutputTypes[n],recoecalcands);
887  //Danger: special case, L1 non-isolated
888  // needs to be merged with L1 iso
890  std::vector<edm::Ref<T> > isocands;
891  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),trigger::TriggerL1IsoEG,isocands);
892  if (isocands.size()>0)
893  {
894  for (unsigned int i=0; i < isocands.size(); i++)
895  recoecalcands.push_back(isocands[i]);
896  }
897  } // END of if theHLTOutputTypes == 82
898 
899 
900  if (recoecalcands.size() < 1){ // stop if no object passed the previous filter
901  accepted = false;
902  return;
903  }
904 
905  //if (recoecalcands.size() >= reqNum )
906  if (recoecalcands.size() >= dqm->nCandCuts.at(n) && !dqm->mcMatchedOnly_)
907  dqm->totals.at(vPos)->Fill(n+0.5);
908 
910  // check for validity //
911  // prevents crash in CMSSW_3_1_0_pre6 //
913  for (unsigned int j=0; j<recoecalcands.size(); j++){
914  if(!( recoecalcands.at(j).isAvailable())){
915  if (dqm->verbosity_ >= dqm->OUTPUT_ERRORS)
916  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.";
917  return;
918  }
919  }
920 
921  if (!dqm->mcMatchedOnly_) {
923  // Loop over the Generated Particles, and find the //
924  // closest HLT object match. //
926  //for (unsigned int i=0; i < gencut_; i++) {
927  for (unsigned int i=0; i < dqm->nCandCuts.at(n); i++) {
928  math::XYZVector currentGenParticleMomentum = sortedGen[i].momentum();
929 
930  float closestDeltaR = 0.5;
931  int closestEcalCandIndex = -1;
932  for (unsigned int j=0; j<recoecalcands.size(); j++) {
933  float deltaR = DeltaR(recoecalcands[j]->momentum(),currentGenParticleMomentum);
934 
935  if (deltaR < closestDeltaR) {
936  closestDeltaR = deltaR;
937  closestEcalCandIndex = j;
938  }
939  }
940 
941  // If an HLT object was found within some delta-R
942  // of this gen particle, store it in a histogram
943  if ( closestEcalCandIndex >= 0 ) {
944  dqm->histEtOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->et() );
945  dqm->histEtaOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->eta() );
946  if (!dqm->noPhiPlots_) dqm->histPhiOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->phi() );
947 
948  // commented out because uses data not included in HTLDEBUG and uses getByLabel
950  //if (n+1 < dqm->numOfHLTCollectionLabels){ // can't plot beyond last
951  // if (dqm->plotiso[n+1] ){ // only plot if requested in config
952  // for (unsigned int j = 0 ; j < dqm->isoNames[n+1].size() ;j++ ){
953  // edm::Handle<edm::AssociationMap<edm::OneToValue< T , float > > > depMap;
954  // iEvent.getByLabel(dqm->isoNames[n+1].at(j),depMap);
955  // if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
956  // typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[closestEcalCandIndex]);
957  // if (mapi!=depMap->end()) { // found candidate in isolation map!
958  // dqm->histEtaIsoOfHltObjMatchToGens.at(vPos).at(n+1)->Fill( recoecalcands[closestEcalCandIndex]->eta(),mapi->val);
959  // dqm->histPhiIsoOfHltObjMatchToGens.at(vPos).at(n+1)->Fill( recoecalcands[closestEcalCandIndex]->phi(),mapi->val);
960  // dqm->histEtIsoOfHltObjMatchToGens.at(vPos).at(n+1) ->Fill( recoecalcands[closestEcalCandIndex]->et(), mapi->val);
961  // }
962  // }
963  // }
964  // }
965  //}
966  } // END of if closestEcalCandIndex >= 0
967  }
968 
970  // Loop over all HLT objects in this filter step, and //
971  // fill histograms. //
973  // bool foundAllMatches = false;
974  // unsigned int numOfHLTobjectsMatched = 0;
975  for (unsigned int i=0; i<recoecalcands.size(); i++) {
977  //float closestGenParticleDr = 99.0;
978  //for(unsigned int j =0; j < gencut_; j++) {
979  // math::XYZVector currentGenParticle = sortedGen[j].momentum();
980 
981  // double currentDeltaR = DeltaR(recoecalcands[i]->momentum(),currentGenParticle);
982  // if ( currentDeltaR < closestGenParticleDr ) {
983  // closestGenParticleDr = currentDeltaR;
984  // }
985  //}
987  //if ( !(fabs(closestGenParticleDr < 0.3)) ) continue;
988 
989  //numOfHLTobjectsMatched++;
990  //if (numOfHLTobjectsMatched >= gencut_) foundAllMatches=true;
991 
992  // Fill HLT object histograms
993  dqm->ethists.at(vPos).at(n) ->Fill(recoecalcands[i]->et() );
994  dqm->etahists.at(vPos).at(n)->Fill(recoecalcands[i]->eta() );
995  if (!dqm->noPhiPlots_) dqm->phihists.at(vPos).at(n)->Fill(recoecalcands[i]->phi() );
996 
997  // commented out because uses data not included in HTLDEBUG and uses getByLabel
999  // Plot isolation variables (show the not-yet-cut //
1000  // isolation, i.e. associated to next filter) //
1002  //if ( n+1 < dqm->numOfHLTCollectionLabels ) { // can't plot beyond last
1003  // if (dqm->plotiso[n+1]) {
1004  // for (unsigned int j = 0 ; j < dqm->isoNames[n+1].size() ;j++ ){
1005  // edm::Handle<edm::AssociationMap<edm::OneToValue< T , float > > > depMap;
1006  // iEvent.getByLabel(dqm->isoNames[n+1].at(j),depMap);
1007  // if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
1008  // typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[i]);
1009  // if (mapi!=depMap->end()){ // found candidate in isolation map!
1010  // dqm->etahistisos.at(vPos).at(n+1)->Fill(recoecalcands[i]->eta(),mapi->val);
1011  // dqm->phihistisos.at(vPos).at(n+1)->Fill(recoecalcands[i]->phi(),mapi->val);
1012  // dqm->ethistisos.at(vPos).at(n+1)->Fill(recoecalcands[i]->et(),mapi->val);
1013  // }
1014  // }
1015  // }
1016  // }
1017  //} // END of if n+1 < then the number of hlt collections
1018  }
1019  }
1020 
1022  // Fill mc matched objects into histograms //
1024  unsigned int matchedMcParts = 0;
1025  float mindist=0.3;
1026  if(n==0) mindist=0.5; //low L1-resolution => allow wider matching
1027  for(unsigned int i =0; i < dqm->nCandCuts.at(n); ++i){
1028  //match generator candidate
1029  bool matchThis= false;
1030  math::XYZVector candDir=sortedGen[i].momentum();
1031  //unsigned int closest = 0;
1032  double closestDr = 1000.;
1033  for(unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); ++trigOb){
1034  double dr = DeltaR(recoecalcands[trigOb]->momentum(),candDir);
1035  if (dr < closestDr) {
1036  closestDr = dr;
1037  //closest = trigOb;
1038  }
1039  if (closestDr > mindist) { // it's not really a "match" if it's that far away
1040  //closest = -1;
1041  } else {
1042  matchedMcParts++;
1043  matchThis = true;
1044  }
1045  }
1046  if ( !matchThis ) {
1047  accepted = false;
1048  continue; // only plot matched candidates
1049  }
1050  // fill coordinates of mc particle matching trigger object
1051  dqm->ethistmatchs.at(vPos).at(n) ->Fill( sortedGen[i].et() );
1052  if (sortedGen[i].et() > dqm->minEtForEtaEffPlot_) {
1053  dqm->etahistmatchs.at(vPos).at(n)->Fill( sortedGen[i].eta() );
1054  if (!dqm->noPhiPlots_) dqm->phihistmatchs.at(vPos).at(n)->Fill( sortedGen[i].phi() );
1055  }
1056  // commented out because uses data not included in HTLDEBUG and uses getByLabel
1058  // Plot isolation variables (show the not-yet-cut //
1059  // isolation, i.e. associated to next filter) //
1061  //if (n+1 < dqm->numOfHLTCollectionLabels){ // can't plot beyond last
1062  // if (dqm->plotiso[n+1] ){ // only plot if requested in config
1063  // for (unsigned int j = 0 ; j < dqm->isoNames[n+1].size() ;j++ ){
1064  // edm::Handle<edm::AssociationMap<edm::OneToValue< T , float > > > depMap;
1065  // iEvent.getByLabel(dqm->isoNames[n+1].at(j),depMap);
1066  // if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
1067  // typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[closest]);
1068  // if (mapi!=depMap->end()){ // found candidate in isolation map!
1069  // // Only make efficiency plot using photons with some min Et
1070  // dqm->etahistisomatchs.at(vPos).at(n+1)->Fill(sortedGen[i].eta(),mapi->val);
1071  // dqm->phihistisomatchs.at(vPos).at(n+1)->Fill(sortedGen[i].phi(),mapi->val);
1072  // dqm->ethistisomatchs.at(vPos).at(n+1)->Fill(sortedGen[i].et(),mapi->val);
1073  // }
1074  // }
1075  // }
1076  // }
1077  //} // END of if n+1 < then the number of hlt collections
1078  }
1079  // fill total mc matched efficiency
1080 
1081  if (matchedMcParts >= dqm->nCandCuts.at(n) && accepted == true)
1082  dqm->totalmatchs.at(vPos)->Fill(n+0.5);
1083 }
std::vector< MonitorElement * > totals
Definition: EmDQM.h:216
int i
Definition: DBlmapReader.cc:9
std::vector< std::vector< MonitorElement * > > histEtOfHltObjMatchToGens
Definition: EmDQM.h:201
std::vector< std::vector< MonitorElement * > > phihists
Definition: EmDQM.h:196
Definition: deltaR.h:79
bool noPhiPlots_
Definition: EmDQM.h:113
std::set< std::string > hltCollectionLabelsFound
Definition: EmDQM.h:184
std::vector< std::vector< MonitorElement * > > histPhiOfHltObjMatchToGens
Definition: EmDQM.h:203
T eta() const
std::vector< std::vector< MonitorElement * > > etahists
Definition: EmDQM.h:195
static const unsigned OUTPUT_ERRORS
Definition: EmDQM.h:247
EmDQM * dqm
Definition: EmDQM.h:59
std::vector< std::vector< MonitorElement * > > ethists
Definition: EmDQM.h:197
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQM.h:154
std::vector< std::vector< MonitorElement * > > ethistmatchs
Definition: EmDQM.h:200
std::vector< unsigned int > nCandCuts
Definition: EmDQM.h:162
std::set< std::string > hltCollectionLabelsMissed
Definition: EmDQM.h:188
std::vector< std::vector< MonitorElement * > > etahistmatchs
Definition: EmDQM.h:198
int j
Definition: DBlmapReader.cc:9
std::vector< std::vector< MonitorElement * > > phihistmatchs
Definition: EmDQM.h:199
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:202
std::vector< MonitorElement * > totalmatchs
Definition: EmDQM.h:217
bool mcMatchedOnly_
Definition: EmDQM.h:112
unsigned int verbosity_
Definition: EmDQM.h:101
std::vector< int > theHLTOutputTypes
Definition: EmDQM.h:158
unsigned int minEtForEtaEffPlot_
Definition: EmDQM.h:110
Definition: DDAxes.h:10

Member Data Documentation

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

Definition at line 59 of file EmDQM.h.