CMS 3D CMS Logo

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 30 of file EmDQMReco.h.

Constructor & Destructor Documentation

◆ HistoFillerReco()

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

Definition at line 32 of file EmDQMReco.h.

32 : dqm(d){};

◆ ~HistoFillerReco()

template<class T>
HistoFillerReco< T >::~HistoFillerReco ( )
inline

Definition at line 33 of file EmDQMReco.h.

33 {};

Member Function Documentation

◆ fillHistos()

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.

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
796  if (dqm->theHLTOutputTypes[n] == trigger::TriggerL1NoIsoEG) {
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 }

Referenced by EmDQMReco::analyze().

Member Data Documentation

◆ dqm

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

Definition at line 44 of file EmDQMReco.h.

◆ isoNameTokens_

template<class T>
std::vector<edm::EDGetTokenT<edm::AssociationMap<edm::OneToValue<T, float> > > > HistoFillerReco< T >::isoNameTokens_
mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
trigger::TriggerL1IsoEG
Definition: TriggerTypeDefs.h:32
trigger::TriggerEventWithRefs::getObjects
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type
Definition: TriggerEventWithRefs.h:399
edm::Handle
Definition: AssociativeIterator.h:50
HistoFillerReco::isoNameTokens_
std::vector< edm::EDGetTokenT< edm::AssociationMap< edm::OneToValue< T, float > > > > isoNameTokens_
Definition: EmDQMReco.h:41
PVValHelper::eta
Definition: PVValidationHelpers.h:69
trigger::TriggerEventWithRefs::filterIndex
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
Definition: TriggerEventWithRefs.h:223
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
edm::LogError
Definition: MessageLogger.h:183
edm::AssociationMap
Definition: AssociationMap.h:48
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
iEvent
int iEvent
Definition: GenABIO.cc:224
p4
double p4[4]
Definition: TauolaWrapper.h:92
HistoFillerReco::dqm
EmDQMReco * dqm
Definition: EmDQMReco.h:44
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
trigger::TriggerEventWithRefs::size
size_type size() const
number of filters
Definition: TriggerEventWithRefs.h:215
DDAxes::phi
trigger::TriggerL1NoIsoEG
Definition: TriggerTypeDefs.h:31
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
ztail.d
d
Definition: ztail.py:151
dqm
Definition: DQMStore.h:18
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70