CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 30 of file EmDQMReco.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file EmDQMReco.h.

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

Definition at line 33 of file EmDQMReco.h.

33 {};

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

References deltaR(), HistoFillerReco< T >::dqm, eta(), EmDQMReco::etahistiso, EmDQMReco::etahistisomatchreco, EmDQMReco::ethistiso, EmDQMReco::ethistisomatchreco, MonitorElement::Fill(), edm::Event::getByToken(), EmDQMReco::histEtaIsoOfHltObjMatchToReco, EmDQMReco::histEtIsoOfHltObjMatchToReco, EmDQMReco::histHltObjMatchToReco, EmDQMReco::histMatchReco, EmDQMReco::histMatchRecoMonPath, EmDQMReco::histPhiIsoOfHltObjMatchToReco, i, HistoFillerReco< T >::isoNameTokens_, edm::HandleBase::isValid(), j, n, EmDQMReco::numOfHLTCollectionLabels, p4, 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().

728 {
729  std::vector<edm::Ref<T> > recoecalcands;
730  if ( ( triggerObj->filterIndex(dqm->theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if available
731  return;
732  }
733 
735  // Retrieve saved filter objects //
737  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),dqm->theHLTOutputTypes[n],recoecalcands);
738  //Danger: special case, L1 non-isolated
739  // needs to be merged with L1 iso
741  std::vector<edm::Ref<T> > isocands;
742  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),trigger::TriggerL1IsoEG,isocands);
743  if (isocands.size()>0)
744  {
745  for (unsigned int i=0; i < isocands.size(); i++)
746  recoecalcands.push_back(isocands[i]);
747  }
748  } // END of if theHLTOutputTypes == 82
749 
750 
751  if (recoecalcands.size() < 1){ // stop if no object passed the previous filter
752  return;
753  }
754 
755 
756  if (recoecalcands.size() >= dqm->reqNum )
757  dqm->totalreco->Fill(n+0.5);
758 
759 
761  // check for validity //
762  // prevents crash in CMSSW_3_1_0_pre6 //
764  for (unsigned int j=0; j<recoecalcands.size(); j++){
765  if(!( recoecalcands.at(j).isAvailable())){
766  edm::LogError("EmDQMReco") << "Event content inconsistent: TriggerEventWithRefs contains invalid Refs" << std::endl << "invalid refs for: " << dqm->theHLTCollectionLabels[n].label();
767  return;
768  }
769  }
770 
772  // Loop over all HLT objects in this filter step, and //
773  // fill histograms. //
775  // bool foundAllMatches = false;
776  // unsigned int numOfHLTobjectsMatched = 0;
777  for (unsigned int i=0; i<recoecalcands.size(); i++) {
778 
779  dqm->standardHist[n].fill(recoecalcands[i]->p4());
780 
782  // Plot isolation variables (show the not-yet-cut //
783  // isolation, i.e. associated to next filter) //
785  if ( n+1 < dqm->numOfHLTCollectionLabels ) { // can't plot beyond last
786  if (dqm->plotiso[n+1]) {
787  for (unsigned int j = 0 ; j < isoNameTokens_.size() ;j++ ){
789  iEvent.getByToken(isoNameTokens_.at(j),depMap);
790  if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
791  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[i]);
792  if (mapi!=depMap->end()){ // found candidate in isolation map!
793  dqm->etahistiso[n+1]->Fill(recoecalcands[i]->eta(),mapi->val);
794  dqm->ethistiso[n+1]->Fill(recoecalcands[i]->et() ,mapi->val);
795  dqm->phiHistIso[n+1]->Fill(recoecalcands[i]->phi(),mapi->val);
796  }
797  }
798  }
799  }
800  } // END of if n+1 < then the number of hlt collections
801  }
802 
804  // Loop over the Reconstructed Particles, and find the //
805  // closest HLT object match. //
807  if (plotReco == true) {
808  for (unsigned int i=0; i < dqm->recocut_; i++) {
809  math::XYZVector currentRecoParticleMomentum = sortedReco[i].momentum();
810 
811  // float closestRecoDeltaR = 0.5;
812  float closestRecoDeltaR = 1000.;
813  int closestRecoEcalCandIndex = -1;
814  for (unsigned int j=0; j<recoecalcands.size(); j++) {
815  float deltaR = DeltaR(recoecalcands[j]->momentum(),currentRecoParticleMomentum);
816 
817  if (deltaR < closestRecoDeltaR) {
818  closestRecoDeltaR = deltaR;
819  closestRecoEcalCandIndex = j;
820  }
821  }
822 
823  // If an HLT object was found within some delta-R
824  // of this reco particle, store it in a histogram
825  if ( closestRecoEcalCandIndex >= 0 ) {
826 // histEtOfHltObjMatchToReco[n] ->Fill( recoecalcands[closestRecoEcalCandIndex]->et() );
827 // histEtaOfHltObjMatchToReco[n]->Fill( recoecalcands[closestRecoEcalCandIndex]->eta() );
828 // histPhiOfHltObjMatchToReco[n]->Fill( recoecalcands[closestRecoEcalCandIndex]->phi() );
829 
830  dqm->histHltObjMatchToReco[n].fill(recoecalcands[closestRecoEcalCandIndex]->p4());
831 
832  // Also store isolation info
833  if (n+1 < dqm->numOfHLTCollectionLabels){ // can't plot beyond last
834  if (dqm->plotiso[n+1] ){ // only plot if requested in config
835  for (unsigned int j = 0 ; j < isoNameTokens_.size() ;j++ ){
837  iEvent.getByToken(isoNameTokens_.at(j),depMap);
838  if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
839  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[closestRecoEcalCandIndex]);
840  if (mapi!=depMap->end()) { // found candidate in isolation map!
841  dqm->histEtaIsoOfHltObjMatchToReco[n+1]->Fill( recoecalcands[closestRecoEcalCandIndex]->eta(),mapi->val);
842  dqm->histEtIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->et(), mapi->val);
843  dqm->histPhiIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->phi(), mapi->val);
844  }
845  }
846  }
847  }
848  }
849  } // END of if closestEcalCandIndex >= 0
850  }
851 
853  // Fill reco matched objects into histograms //
855  unsigned int mtachedRecoParts = 0;
856  float minrecodist=0.3;
857  if(n==0) minrecodist=0.5; //low L1-resolution => allow wider matching
858  for(unsigned int i =0; i < dqm->recocut_; i++){
859  //match generator candidate
860  bool matchThis= false;
861  math::XYZVector candDir=sortedReco[i].momentum();
862  unsigned int closest = 0;
863  double closestDr = 1000.;
864  for(unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); trigOb++){
865  double dr = DeltaR(recoecalcands[trigOb]->momentum(),candDir);
866  if (dr < closestDr) {
867  closestDr = dr;
868  closest = trigOb;
869  }
870  if (closestDr > minrecodist) { // it's not really a "match" if it's that far away
871  closest = -1;
872  } else {
873  mtachedRecoParts++;
874  matchThis = true;
875  }
876  }
877  if ( !matchThis ) continue; // only plot matched candidates
878  // fill coordinates of mc particle matching trigger object
879 // ethistmatchreco[n] ->Fill( sortedReco[i].et() );
880 // etahistmatchreco[n]->Fill( sortedReco[i].eta() );
881 // phiHistMatchReco[n]->Fill( sortedReco[i].phi() );
882  dqm->histMatchReco[n].fill(sortedReco[i].p4());
883 
884  if (plotMonpath) {
885 // ethistmatchrecomonpath[n]->Fill( sortedReco[i].et() );
886 // etahistmatchrecomonpath[n]->Fill( sortedReco[i].eta() );
887 // phiHistMatchRecoMonPath[n]->Fill( sortedReco[i].phi() );
888  dqm->histMatchRecoMonPath[n].fill(sortedReco[i].p4());
889 
890  }
892  // Plot isolation variables (show the not-yet-cut //
893  // isolation, i.e. associated to next filter) //
895  if (n+1 < dqm->numOfHLTCollectionLabels){ // can't plot beyond last
896  if (dqm->plotiso[n+1] ){ // only plot if requested in config
897  for (unsigned int j = 0 ; j < isoNameTokens_.size() ;j++ ){
899  iEvent.getByToken(isoNameTokens_.at(j),depMapReco);
900  if (depMapReco.isValid()){ //Map may not exist if only one candidate passes a double filter
901  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMapReco->find(recoecalcands[closest]);
902  if (mapi!=depMapReco->end()){ // found candidate in isolation map!
903  dqm->etahistisomatchreco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
904  dqm->ethistisomatchreco[n+1]->Fill(sortedReco[i].et(),mapi->val);
905  dqm->phiHistIsoMatchReco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
906  }
907  }
908  }
909  }
910  } // END of if n+1 < then the number of hlt collections
911  }
912  // fill total reco matched efficiency
913  if (mtachedRecoParts >= dqm->reqNum )
914  dqm-> totalmatchreco->Fill(n+0.5);
915  }
916 
917 }
int i
Definition: DBlmapReader.cc:9
boost::ptr_vector< FourVectorMonitorElements > standardHist
Definition: EmDQMReco.h:163
Definition: deltaR.h:79
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
boost::ptr_vector< FourVectorMonitorElements > histMatchReco
Definition: EmDQMReco.h:168
std::vector< MonitorElement * > histEtIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:193
std::vector< int > theHLTOutputTypes
Definition: EmDQMReco.h:107
T eta() const
std::vector< MonitorElement * > phiHistIso
Definition: EmDQMReco.h:187
std::vector< MonitorElement * > histEtaIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:194
void Fill(long long x)
boost::ptr_vector< FourVectorMonitorElements > histMatchRecoMonPath
Definition: EmDQMReco.h:173
unsigned int numOfHLTCollectionLabels
Definition: EmDQMReco.h:102
double p4[4]
Definition: TauolaWrapper.h:92
MonitorElement * totalreco
Definition: EmDQMReco.h:200
EmDQMReco * dqm
Definition: EmDQMReco.h:39
int j
Definition: DBlmapReader.cc:9
unsigned int recocut_
Definition: EmDQMReco.h:134
std::vector< MonitorElement * > ethistisomatchreco
Definition: EmDQMReco.h:190
bool isValid() const
Definition: HandleBase.h:76
std::vector< bool > plotiso
Definition: EmDQMReco.h:108
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
unsigned int reqNum
Definition: EmDQMReco.h:119
std::vector< MonitorElement * > etahistiso
Definition: EmDQMReco.h:185
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
std::vector< MonitorElement * > etahistisomatchreco
Definition: EmDQMReco.h:189
std::vector< edm::EDGetTokenT< edm::AssociationMap< edm::OneToValue< T, float > > > > isoNameTokens_
Definition: EmDQMReco.h:36
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQMReco.h:100
boost::ptr_vector< FourVectorMonitorElements > histHltObjMatchToReco
Definition: EmDQMReco.h:179
std::vector< MonitorElement * > ethistiso
Definition: EmDQMReco.h:186
std::vector< MonitorElement * > phiHistIsoMatchReco
Definition: EmDQMReco.h:191
std::vector< MonitorElement * > histPhiIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:195
Definition: DDAxes.h:10

Member Data Documentation

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

Definition at line 36 of file EmDQMReco.h.

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