CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes | Private Attributes
HistoFillerReco< T > Class Template Reference

#include <EmDQMReco.h>

Public Member Functions

void fillHistos (edm::Handle< trigger::TriggerEventWithRefs > &triggerObj, const edm::Event &iEvent, unsigned int n, std::vector< reco::Particle > &sortedReco, bool plotReco, bool plotMonpath)
 
 HistoFillerReco (EmDQMReco *d)
 
 ~HistoFillerReco ()
 

Public Attributes

std::vector< edm::EDGetTokenT
< edm::AssociationMap
< edm::OneToValue< T, float > > > > 
isoNameTokens_
 

Private Attributes

EmDQMRecodqm
 

Detailed Description

template<class T>
class HistoFillerReco< T >

Definition at line 29 of file EmDQMReco.h.

Constructor & Destructor Documentation

template<class T>
HistoFillerReco< T >::HistoFillerReco ( EmDQMReco d)
inline

Definition at line 31 of file EmDQMReco.h.

31 : dqm(d){};
EmDQMReco * dqm
Definition: EmDQMReco.h:43
template<class T>
HistoFillerReco< T >::~HistoFillerReco ( )
inline

Definition at line 32 of file EmDQMReco.h.

32 {};

Member Function Documentation

template<class T >
void HistoFillerReco< T >::fillHistos ( edm::Handle< trigger::TriggerEventWithRefs > &  triggerObj,
const edm::Event iEvent,
unsigned int  n,
std::vector< reco::Particle > &  sortedReco,
bool  plotReco,
bool  plotMonpath 
)

Definition at line 778 of file EmDQMReco.cc.

References HLT_FULL_cff::DeltaR, HLT_FULL_cff::deltaR, HistoFillerReco< T >::dqm, runTauDisplay::dr, PVValHelper::eta, EmDQMReco::etahistiso, EmDQMReco::etahistisomatchreco, EmDQMReco::ethistiso, EmDQMReco::ethistisomatchreco, dqm::impl::MonitorElement::Fill(), edm::Event::getByToken(), EmDQMReco::histEtaIsoOfHltObjMatchToReco, EmDQMReco::histEtIsoOfHltObjMatchToReco, EmDQMReco::histHltObjMatchToReco, EmDQMReco::histMatchReco, EmDQMReco::histMatchRecoMonPath, EmDQMReco::histPhiIsoOfHltObjMatchToReco, mps_fire::i, HistoFillerReco< T >::isoNameTokens_, edm::HandleBase::isValid(), dqmiolumiharvest::j, dqmiodumpmetadata::n, EmDQMReco::numOfHLTCollectionLabels, phi, EmDQMReco::phiHistIso, EmDQMReco::phiHistIsoMatchReco, EmDQMReco::plotiso, EmDQMReco::recocut_, EmDQMReco::reqNum, EmDQMReco::standardHist, EmDQMReco::theHLTCollectionLabels, EmDQMReco::theHLTOutputTypes, EmDQMReco::totalmatchreco, EmDQMReco::totalreco, trigger::TriggerL1IsoEG, and trigger::TriggerL1NoIsoEG.

Referenced by EmDQMReco::analyze().

783  {
784  std::vector<edm::Ref<T>> recoecalcands;
785  if ((triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]) >= triggerObj->size())) { // only process if available
786  return;
787  }
788 
790  // Retrieve saved filter objects //
792  triggerObj->getObjects(
793  triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]), dqm->theHLTOutputTypes[n], recoecalcands);
794  // Danger: special case, L1 non-isolated
795  // needs to be merged with L1 iso
797  std::vector<edm::Ref<T>> isocands;
798  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]), trigger::TriggerL1IsoEG, isocands);
799  if (!isocands.empty()) {
800  for (unsigned int i = 0; i < isocands.size(); i++)
801  recoecalcands.push_back(isocands[i]);
802  }
803  } // END of if theHLTOutputTypes == 82
804 
805  if (recoecalcands.empty()) { // stop if no object passed the previous filter
806  return;
807  }
808 
809  if (recoecalcands.size() >= dqm->reqNum)
810  dqm->totalreco->Fill(n + 0.5);
811 
813  // check for validity //
814  // prevents crash in CMSSW_3_1_0_pre6 //
816  for (unsigned int j = 0; j < recoecalcands.size(); j++) {
817  if (!(recoecalcands.at(j).isAvailable())) {
818  edm::LogError("EmDQMReco") << "Event content inconsistent: TriggerEventWithRefs contains "
819  "invalid Refs"
820  << std::endl
821  << "invalid refs for: " << dqm->theHLTCollectionLabels[n].label();
822  return;
823  }
824  }
825 
827  // Loop over all HLT objects in this filter step, and //
828  // fill histograms. //
830  // bool foundAllMatches = false;
831  // unsigned int numOfHLTobjectsMatched = 0;
832  for (unsigned int i = 0; i < recoecalcands.size(); i++) {
833  dqm->standardHist[n]->fill(recoecalcands[i]->p4());
834 
836  // Plot isolation variables (show the not-yet-cut //
837  // isolation, i.e. associated to next filter) //
839  if (n + 1 < dqm->numOfHLTCollectionLabels) { // can't plot beyond last
840  if (dqm->plotiso[n + 1]) {
841  for (unsigned int j = 0; j < isoNameTokens_.size(); j++) {
843  iEvent.getByToken(isoNameTokens_.at(j), depMap);
844  if (depMap.isValid()) { // Map may not exist if only one candidate
845  // passes a double filter
846  typename edm::AssociationMap<edm::OneToValue<T, float>>::const_iterator mapi =
847  depMap->find(recoecalcands[i]);
848  if (mapi != depMap->end()) { // found candidate in isolation map!
849  dqm->etahistiso[n + 1]->Fill(recoecalcands[i]->eta(), mapi->val);
850  dqm->ethistiso[n + 1]->Fill(recoecalcands[i]->et(), mapi->val);
851  dqm->phiHistIso[n + 1]->Fill(recoecalcands[i]->phi(), mapi->val);
852  }
853  }
854  }
855  }
856  } // END of if n+1 < then the number of hlt collections
857  }
858 
860  // Loop over the Reconstructed Particles, and find the //
861  // closest HLT object match. //
863  if (plotReco == true) {
864  for (unsigned int i = 0; i < dqm->recocut_; i++) {
865  math::XYZVector currentRecoParticleMomentum = sortedReco[i].momentum();
866 
867  // float closestRecoDeltaR = 0.5;
868  float closestRecoDeltaR = 1000.;
869  int closestRecoEcalCandIndex = -1;
870  for (unsigned int j = 0; j < recoecalcands.size(); j++) {
871  float deltaR = DeltaR(recoecalcands[j]->momentum(), currentRecoParticleMomentum);
872 
873  if (deltaR < closestRecoDeltaR) {
874  closestRecoDeltaR = deltaR;
875  closestRecoEcalCandIndex = j;
876  }
877  }
878 
879  // If an HLT object was found within some delta-R
880  // of this reco particle, store it in a histogram
881  if (closestRecoEcalCandIndex >= 0) {
882  // histEtOfHltObjMatchToReco[n] ->Fill(
883  // recoecalcands[closestRecoEcalCandIndex]->et() );
884  // histEtaOfHltObjMatchToReco[n]->Fill(
885  // recoecalcands[closestRecoEcalCandIndex]->eta() );
886  // histPhiOfHltObjMatchToReco[n]->Fill(
887  // recoecalcands[closestRecoEcalCandIndex]->phi() );
888 
889  dqm->histHltObjMatchToReco[n]->fill(recoecalcands[closestRecoEcalCandIndex]->p4());
890 
891  // Also store isolation info
892  if (n + 1 < dqm->numOfHLTCollectionLabels) { // can't plot beyond last
893  if (dqm->plotiso[n + 1]) { // only plot if requested in config
894  for (unsigned int j = 0; j < isoNameTokens_.size(); j++) {
896  iEvent.getByToken(isoNameTokens_.at(j), depMap);
897  if (depMap.isValid()) { // Map may not exist if only one candidate
898  // passes a double filter
899  typename edm::AssociationMap<edm::OneToValue<T, float>>::const_iterator mapi =
900  depMap->find(recoecalcands[closestRecoEcalCandIndex]);
901  if (mapi != depMap->end()) { // found candidate in isolation map!
902  dqm->histEtaIsoOfHltObjMatchToReco[n + 1]->Fill(recoecalcands[closestRecoEcalCandIndex]->eta(),
903  mapi->val);
904  dqm->histEtIsoOfHltObjMatchToReco[n + 1]->Fill(recoecalcands[closestRecoEcalCandIndex]->et(),
905  mapi->val);
906  dqm->histPhiIsoOfHltObjMatchToReco[n + 1]->Fill(recoecalcands[closestRecoEcalCandIndex]->phi(),
907  mapi->val);
908  }
909  }
910  }
911  }
912  }
913  } // END of if closestEcalCandIndex >= 0
914  }
915 
917  // Fill reco matched objects into histograms //
919  unsigned int mtachedRecoParts = 0;
920  float minrecodist = 0.3;
921  if (n == 0)
922  minrecodist = 0.5; // low L1-resolution => allow wider matching
923  for (unsigned int i = 0; i < dqm->recocut_; i++) {
924  // match generator candidate
925  bool matchThis = false;
926  math::XYZVector candDir = sortedReco[i].momentum();
927  unsigned int closest = 0;
928  double closestDr = 1000.;
929  for (unsigned int trigOb = 0; trigOb < recoecalcands.size(); trigOb++) {
930  double dr = DeltaR(recoecalcands[trigOb]->momentum(), candDir);
931  if (dr < closestDr) {
932  closestDr = dr;
933  closest = trigOb;
934  }
935  if (closestDr > minrecodist) { // it's not really a "match" if it's that far away
936  closest = -1;
937  } else {
938  mtachedRecoParts++;
939  matchThis = true;
940  }
941  }
942  if (!matchThis)
943  continue; // only plot matched candidates
944  // fill coordinates of mc particle matching trigger object
945  // ethistmatchreco[n] ->Fill( sortedReco[i].et() );
946  // etahistmatchreco[n]->Fill( sortedReco[i].eta() );
947  // phiHistMatchReco[n]->Fill( sortedReco[i].phi() );
948  dqm->histMatchReco[n]->fill(sortedReco[i].p4());
949 
950  if (plotMonpath) {
951  // ethistmatchrecomonpath[n]->Fill( sortedReco[i].et() );
952  // etahistmatchrecomonpath[n]->Fill( sortedReco[i].eta() );
953  // phiHistMatchRecoMonPath[n]->Fill( sortedReco[i].phi() );
954  dqm->histMatchRecoMonPath[n]->fill(sortedReco[i].p4());
955  }
957  // Plot isolation variables (show the not-yet-cut //
958  // isolation, i.e. associated to next filter) //
960  if (n + 1 < dqm->numOfHLTCollectionLabels) { // can't plot beyond last
961  if (dqm->plotiso[n + 1]) { // only plot if requested in config
962  for (unsigned int j = 0; j < isoNameTokens_.size(); j++) {
964  iEvent.getByToken(isoNameTokens_.at(j), depMapReco);
965  if (depMapReco.isValid()) { // Map may not exist if only one
966  // candidate passes a double filter
967  typename edm::AssociationMap<edm::OneToValue<T, float>>::const_iterator mapi =
968  depMapReco->find(recoecalcands[closest]);
969  if (mapi != depMapReco->end()) { // found candidate in isolation map!
970  dqm->etahistisomatchreco[n + 1]->Fill(sortedReco[i].eta(), mapi->val);
971  dqm->ethistisomatchreco[n + 1]->Fill(sortedReco[i].et(), mapi->val);
972  dqm->phiHistIsoMatchReco[n + 1]->Fill(sortedReco[i].eta(), mapi->val);
973  }
974  }
975  }
976  }
977  } // END of if n+1 < then the number of hlt collections
978  }
979  // fill total reco matched efficiency
980  if (mtachedRecoParts >= dqm->reqNum)
981  dqm->totalmatchreco->Fill(n + 0.5);
982  }
983 }
std::vector< MonitorElement * > histEtIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:192
std::vector< std::unique_ptr< FourVectorMonitorElements > > histMatchReco
Definition: EmDQMReco.h:168
std::vector< std::unique_ptr< FourVectorMonitorElements > > standardHist
Definition: EmDQMReco.h:163
std::vector< MonitorElement * > etahistisomatchreco
Definition: EmDQMReco.h:188
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< MonitorElement * > etahistiso
Definition: EmDQMReco.h:184
std::vector< int > theHLTOutputTypes
Definition: EmDQMReco.h:107
std::vector< edm::EDGetTokenT< edm::AssociationMap< edm::OneToValue< T, float > > > > isoNameTokens_
Definition: EmDQMReco.h:40
Log< level::Error, false > LogError
std::vector< MonitorElement * > phiHistIsoMatchReco
Definition: EmDQMReco.h:190
void Fill(long long x)
std::vector< std::unique_ptr< FourVectorMonitorElements > > histMatchRecoMonPath
Definition: EmDQMReco.h:173
std::vector< MonitorElement * > ethistiso
Definition: EmDQMReco.h:185
unsigned int numOfHLTCollectionLabels
Definition: EmDQMReco.h:102
MonitorElement * totalreco
Definition: EmDQMReco.h:199
std::vector< std::unique_ptr< FourVectorMonitorElements > > histHltObjMatchToReco
Definition: EmDQMReco.h:178
EmDQMReco * dqm
Definition: EmDQMReco.h:43
MonitorElement * totalmatchreco
Definition: EmDQMReco.h:200
std::vector< MonitorElement * > histPhiIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:194
std::vector< MonitorElement * > phiHistIso
Definition: EmDQMReco.h:186
unsigned int recocut_
Definition: EmDQMReco.h:134
bool isValid() const
Definition: HandleBase.h:70
std::vector< bool > plotiso
Definition: EmDQMReco.h:108
unsigned int reqNum
Definition: EmDQMReco.h:119
std::vector< MonitorElement * > ethistisomatchreco
Definition: EmDQMReco.h:189
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQMReco.h:100
std::vector< MonitorElement * > histEtaIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:193

Member Data Documentation

template<class T>
EmDQMReco* HistoFillerReco< T >::dqm
private

Definition at line 43 of file EmDQMReco.h.

Referenced by HistoFillerReco< T >::fillHistos(), and HistoFiller< T >::fillHistos().

template<class T>
std::vector<edm::EDGetTokenT<edm::AssociationMap<edm::OneToValue<T, float> > > > HistoFillerReco< T >::isoNameTokens_

Definition at line 40 of file EmDQMReco.h.

Referenced by EmDQMReco::EmDQMReco(), and HistoFillerReco< T >::fillHistos().