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

Constructor & Destructor Documentation

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

Definition at line 34 of file EmDQMReco.h.

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

Definition at line 35 of file EmDQMReco.h.

35 {};

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

References deltaR(), HLT_25ns10e33_v2_cff::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, gen::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().

700 {
701  std::vector<edm::Ref<T> > recoecalcands;
702  if ( ( triggerObj->filterIndex(dqm->theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if available
703  return;
704  }
705 
707  // Retrieve saved filter objects //
709  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),dqm->theHLTOutputTypes[n],recoecalcands);
710  //Danger: special case, L1 non-isolated
711  // needs to be merged with L1 iso
713  std::vector<edm::Ref<T> > isocands;
714  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),trigger::TriggerL1IsoEG,isocands);
715  if (isocands.size()>0)
716  {
717  for (unsigned int i=0; i < isocands.size(); i++)
718  recoecalcands.push_back(isocands[i]);
719  }
720  } // END of if theHLTOutputTypes == 82
721 
722 
723  if (recoecalcands.size() < 1){ // stop if no object passed the previous filter
724  return;
725  }
726 
727 
728  if (recoecalcands.size() >= dqm->reqNum )
729  dqm->totalreco->Fill(n+0.5);
730 
731 
733  // check for validity //
734  // prevents crash in CMSSW_3_1_0_pre6 //
736  for (unsigned int j=0; j<recoecalcands.size(); j++){
737  if(!( recoecalcands.at(j).isAvailable())){
738  edm::LogError("EmDQMReco") << "Event content inconsistent: TriggerEventWithRefs contains invalid Refs" << std::endl << "invalid refs for: " << dqm->theHLTCollectionLabels[n].label();
739  return;
740  }
741  }
742 
744  // Loop over all HLT objects in this filter step, and //
745  // fill histograms. //
747  // bool foundAllMatches = false;
748  // unsigned int numOfHLTobjectsMatched = 0;
749  for (unsigned int i=0; i<recoecalcands.size(); i++) {
750 
751  dqm->standardHist[n].fill(recoecalcands[i]->p4());
752 
754  // Plot isolation variables (show the not-yet-cut //
755  // isolation, i.e. associated to next filter) //
757  if ( n+1 < dqm->numOfHLTCollectionLabels ) { // can't plot beyond last
758  if (dqm->plotiso[n+1]) {
759  for (unsigned int j = 0 ; j < isoNameTokens_.size() ;j++ ){
761  iEvent.getByToken(isoNameTokens_.at(j),depMap);
762  if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
763  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[i]);
764  if (mapi!=depMap->end()){ // found candidate in isolation map!
765  dqm->etahistiso[n+1]->Fill(recoecalcands[i]->eta(),mapi->val);
766  dqm->ethistiso[n+1]->Fill(recoecalcands[i]->et() ,mapi->val);
767  dqm->phiHistIso[n+1]->Fill(recoecalcands[i]->phi(),mapi->val);
768  }
769  }
770  }
771  }
772  } // END of if n+1 < then the number of hlt collections
773  }
774 
776  // Loop over the Reconstructed Particles, and find the //
777  // closest HLT object match. //
779  if (plotReco == true) {
780  for (unsigned int i=0; i < dqm->recocut_; i++) {
781  math::XYZVector currentRecoParticleMomentum = sortedReco[i].momentum();
782 
783  // float closestRecoDeltaR = 0.5;
784  float closestRecoDeltaR = 1000.;
785  int closestRecoEcalCandIndex = -1;
786  for (unsigned int j=0; j<recoecalcands.size(); j++) {
787  float deltaR = DeltaR(recoecalcands[j]->momentum(),currentRecoParticleMomentum);
788 
789  if (deltaR < closestRecoDeltaR) {
790  closestRecoDeltaR = deltaR;
791  closestRecoEcalCandIndex = j;
792  }
793  }
794 
795  // If an HLT object was found within some delta-R
796  // of this reco particle, store it in a histogram
797  if ( closestRecoEcalCandIndex >= 0 ) {
798 // histEtOfHltObjMatchToReco[n] ->Fill( recoecalcands[closestRecoEcalCandIndex]->et() );
799 // histEtaOfHltObjMatchToReco[n]->Fill( recoecalcands[closestRecoEcalCandIndex]->eta() );
800 // histPhiOfHltObjMatchToReco[n]->Fill( recoecalcands[closestRecoEcalCandIndex]->phi() );
801 
802  dqm->histHltObjMatchToReco[n].fill(recoecalcands[closestRecoEcalCandIndex]->p4());
803 
804  // Also store isolation info
805  if (n+1 < dqm->numOfHLTCollectionLabels){ // can't plot beyond last
806  if (dqm->plotiso[n+1] ){ // only plot if requested in config
807  for (unsigned int j = 0 ; j < isoNameTokens_.size() ;j++ ){
809  iEvent.getByToken(isoNameTokens_.at(j),depMap);
810  if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
811  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[closestRecoEcalCandIndex]);
812  if (mapi!=depMap->end()) { // found candidate in isolation map!
813  dqm->histEtaIsoOfHltObjMatchToReco[n+1]->Fill( recoecalcands[closestRecoEcalCandIndex]->eta(),mapi->val);
814  dqm->histEtIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->et(), mapi->val);
815  dqm->histPhiIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->phi(), mapi->val);
816  }
817  }
818  }
819  }
820  }
821  } // END of if closestEcalCandIndex >= 0
822  }
823 
825  // Fill reco matched objects into histograms //
827  unsigned int mtachedRecoParts = 0;
828  float minrecodist=0.3;
829  if(n==0) minrecodist=0.5; //low L1-resolution => allow wider matching
830  for(unsigned int i =0; i < dqm->recocut_; i++){
831  //match generator candidate
832  bool matchThis= false;
833  math::XYZVector candDir=sortedReco[i].momentum();
834  unsigned int closest = 0;
835  double closestDr = 1000.;
836  for(unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); trigOb++){
837  double dr = DeltaR(recoecalcands[trigOb]->momentum(),candDir);
838  if (dr < closestDr) {
839  closestDr = dr;
840  closest = trigOb;
841  }
842  if (closestDr > minrecodist) { // it's not really a "match" if it's that far away
843  closest = -1;
844  } else {
845  mtachedRecoParts++;
846  matchThis = true;
847  }
848  }
849  if ( !matchThis ) continue; // only plot matched candidates
850  // fill coordinates of mc particle matching trigger object
851 // ethistmatchreco[n] ->Fill( sortedReco[i].et() );
852 // etahistmatchreco[n]->Fill( sortedReco[i].eta() );
853 // phiHistMatchReco[n]->Fill( sortedReco[i].phi() );
854  dqm->histMatchReco[n].fill(sortedReco[i].p4());
855 
856  if (plotMonpath) {
857 // ethistmatchrecomonpath[n]->Fill( sortedReco[i].et() );
858 // etahistmatchrecomonpath[n]->Fill( sortedReco[i].eta() );
859 // phiHistMatchRecoMonPath[n]->Fill( sortedReco[i].phi() );
860  dqm->histMatchRecoMonPath[n].fill(sortedReco[i].p4());
861 
862  }
864  // Plot isolation variables (show the not-yet-cut //
865  // isolation, i.e. associated to next filter) //
867  if (n+1 < dqm->numOfHLTCollectionLabels){ // can't plot beyond last
868  if (dqm->plotiso[n+1] ){ // only plot if requested in config
869  for (unsigned int j = 0 ; j < isoNameTokens_.size() ;j++ ){
871  iEvent.getByToken(isoNameTokens_.at(j),depMapReco);
872  if (depMapReco.isValid()){ //Map may not exist if only one candidate passes a double filter
873  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMapReco->find(recoecalcands[closest]);
874  if (mapi!=depMapReco->end()){ // found candidate in isolation map!
875  dqm->etahistisomatchreco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
876  dqm->ethistisomatchreco[n+1]->Fill(sortedReco[i].et(),mapi->val);
877  dqm->phiHistIsoMatchReco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
878  }
879  }
880  }
881  }
882  } // END of if n+1 < then the number of hlt collections
883  }
884  // fill total reco matched efficiency
885  if (mtachedRecoParts >= dqm->reqNum )
886  dqm-> totalmatchreco->Fill(n+0.5);
887  }
888 
889 }
int i
Definition: DBlmapReader.cc:9
boost::ptr_vector< FourVectorMonitorElements > standardHist
Definition: EmDQMReco.h:167
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
boost::ptr_vector< FourVectorMonitorElements > histMatchReco
Definition: EmDQMReco.h:172
std::vector< MonitorElement * > histEtIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:197
std::vector< int > theHLTOutputTypes
Definition: EmDQMReco.h:111
std::vector< MonitorElement * > phiHistIso
Definition: EmDQMReco.h:191
std::vector< MonitorElement * > histEtaIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:198
void Fill(long long x)
boost::ptr_vector< FourVectorMonitorElements > histMatchRecoMonPath
Definition: EmDQMReco.h:177
unsigned int numOfHLTCollectionLabels
Definition: EmDQMReco.h:106
double p4[4]
Definition: TauolaWrapper.h:92
MonitorElement * totalreco
Definition: EmDQMReco.h:204
EmDQMReco * dqm
Definition: EmDQMReco.h:41
int j
Definition: DBlmapReader.cc:9
unsigned int recocut_
Definition: EmDQMReco.h:138
std::vector< MonitorElement * > ethistisomatchreco
Definition: EmDQMReco.h:194
bool isValid() const
Definition: HandleBase.h:75
std::vector< bool > plotiso
Definition: EmDQMReco.h:112
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
unsigned int reqNum
Definition: EmDQMReco.h:123
std::vector< MonitorElement * > etahistiso
Definition: EmDQMReco.h:189
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
std::vector< MonitorElement * > etahistisomatchreco
Definition: EmDQMReco.h:193
std::vector< edm::EDGetTokenT< edm::AssociationMap< edm::OneToValue< T, float > > > > isoNameTokens_
Definition: EmDQMReco.h:38
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQMReco.h:104
boost::ptr_vector< FourVectorMonitorElements > histHltObjMatchToReco
Definition: EmDQMReco.h:183
std::vector< MonitorElement * > ethistiso
Definition: EmDQMReco.h:190
std::vector< MonitorElement * > phiHistIsoMatchReco
Definition: EmDQMReco.h:195
std::vector< MonitorElement * > histPhiIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:199

Member Data Documentation

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

Definition at line 41 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 38 of file EmDQMReco.h.

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