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

Constructor & Destructor Documentation

◆ HistoFillerReco()

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

Definition at line 30 of file EmDQMReco.h.

30 : dqm(d){};
EmDQMReco * dqm
Definition: EmDQMReco.h:42
d
Definition: ztail.py:151

◆ ~HistoFillerReco()

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

Definition at line 31 of file EmDQMReco.h.

31 {};

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 776 of file EmDQMReco.cc.

Referenced by EmDQMReco::analyze().

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

Member Data Documentation

◆ dqm

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

Definition at line 42 of file EmDQMReco.h.

◆ isoNameTokens_

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