CMS 3D CMS Logo

Public Member Functions | Private Attributes

Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg > Class Template Reference

#include <Comparison.h>

List of all members.

Public Member Functions

void book ()
void book (ofstream &)
 Comparison (const edm::ParameterSet &)
std::map< unsigned int,
unsigned int > 
operator() (const Ref &, const Rec &)
void summarize ()
 ~Comparison ()

Private Attributes

Alg alg_
unsigned int failed_
unsigned int found_
std::vector< TH1F * > hDR_
std::vector< TH1F * > hEta_
std::vector< TH1F * > hPt_
double maxDR_
double maxEtaRec_
double maxEtaRef_
double maxPtRec_
double maxPtRef_
double minEtaRec_
double minEtaRef_
double minPtRec_
double minPtRef_
unsigned int missed_
RecQualifier recQualifier_
RefQualifier refQualifier_

Detailed Description

template<typename Ref, typename RefQualifier, typename Rec, typename RecQualifier, typename Alg>
class Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >

Definition at line 22 of file Comparison.h.


Constructor & Destructor Documentation

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::Comparison ( const edm::ParameterSet cfg)

Definition at line 56 of file Comparison.h.

References Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::book(), mergeVDriftHistosByStation::file, edm::ParameterSet::getParameter(), estimatePileup::hist, and dbtoconf::out.

                                                                                           :
  maxDR_( cfg.getParameter<double>( "maxDR" ) ),
  minPtRef_ ( cfg.getParameter<double>( "minPtRef"  ) ),
  maxPtRef_ ( cfg.getParameter<double>( "maxPtRef"  ) ),
  minPtRec_ ( cfg.getParameter<double>( "minPtRec"  ) ),
  maxPtRec_ ( cfg.getParameter<double>( "maxPtRec"  ) ),
  minEtaRef_( cfg.getParameter<double>( "minEtaRef" ) ),
  maxEtaRef_( cfg.getParameter<double>( "maxEtaRef" ) ),
  minEtaRec_( cfg.getParameter<double>( "minEtaRec" ) ),
  maxEtaRec_( cfg.getParameter<double>( "maxEtaRec" ) ),
  refQualifier_( cfg ), recQualifier_( cfg ),
  found_( 0 ), missed_( 0 ), failed_( 0 )
{
  std::string hist=cfg.getParameter<std::string>("hist");
  if( hist.empty() )
    book();
  else{
    ofstream file(hist.c_str(), std::ios::out);
    book(file);
  }
}
template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::~Comparison ( ) [inline]

Definition at line 26 of file Comparison.h.

{};

Member Function Documentation

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
void Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::book ( )

Definition at line 144 of file Comparison.h.

References edm::errors::Configuration, Exception, match(), and NameScheme::name().

Referenced by Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::Comparison().

{
  edm::Service<TFileService> fs;
  if( !fs )
    throw edm::Exception( edm::errors::Configuration, "TFile Service is not registered in cfg file" );

  NameScheme match("match");
  static const unsigned int MAXHIST=2;
  for(unsigned int idx=0; idx<MAXHIST; ++idx){
    hDR_ .push_back( fs->make<TH1F>( match.name(      "deltaR", idx), match.name("dR"), 100, 0.,   1.) );
    hPt_ .push_back( fs->make<TH1F>( match.name(      "effPt",  idx), match.name("pt"),  30, 0., 300.) );
    hEta_.push_back( fs->make<TH1F>( match.name(      "effEta", idx), match.name("eta"), 30,-3.,   3.) );
  }
}
template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
void Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::book ( ofstream &  file)

Definition at line 160 of file Comparison.h.

References edm::errors::Configuration, Exception, match(), and NameScheme::name().

{
  edm::Service<TFileService> fs;
  if( !fs )
    throw edm::Exception( edm::errors::Configuration, "TFile Service is not registered in cfg file" );

  NameScheme match("match");
  static const unsigned int MAXHIST=2;
  for(unsigned int idx=0; idx<MAXHIST; ++idx){
    hDR_ .push_back( fs->make<TH1F>( match.name(file, "deltaR", idx), match.name("dR"), 100, 0.,   1.) );
    hPt_ .push_back( fs->make<TH1F>( match.name(file, "effPt",  idx), match.name("pt"),  30, 0., 300.) );
    hEta_.push_back( fs->make<TH1F>( match.name(file, "effEta", idx), match.name("eta"), 30,-3.,   3.) );
  }
}
template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
std::map< unsigned int, unsigned int > Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::operator() ( const Ref &  refs,
const Rec &  recs 
)

Definition at line 80 of file Comparison.h.

References eta(), HcalObjRepresent::Fill(), match(), MultipleCompare::ref, and findQualityFiles::size.

{
  int refIdx=0;
  std::map<unsigned int, unsigned int> matches;
  for(typename Ref::const_iterator ref=refs.begin(); 
      ref!=refs.end(); ++ref, ++refIdx ){
    if( !(minEtaRef_<ref->eta() && ref->eta()<maxEtaRef_) ) 
      // retrict to visible range in eta
      continue;
    
    if( !(minPtRef_ <ref->pt()  && ref->pt() <maxPtRef_ ) )
      // restrict to visible range in pt
      continue;

    if( !refQualifier_( *ref ) ) 
      // restrtict to properly qualified reference object
      continue;

    int jetIdx=0;
    int match=-1;
    double dist=-1.;    
    for(typename Rec::const_iterator rec = recs.begin();
        rec!=recs.end(); ++rec, ++jetIdx ){
      if( !(minEtaRec_<rec->eta() && rec->eta()<maxEtaRec_) ) 
        // retrict to visible range in eta
        continue;
      
      if( !(minPtRec_ <rec->pt()  && rec->pt() <maxPtRec_ ) )
        // restrict to visible range in pt
        continue;
      
      if( !recQualifier_( *rec ) ) 
        // restrtict to properly qualified CaloJet
        continue;
      
      double dR = alg_(*ref, *rec);
      if( dist<0 || dR<dist ){
        dist  = dR;
        match = jetIdx;
      }
    }
    if( match<0 ) ++failed_;
    if( match>=0 ){
      if(hDR_ .size()>0) hDR_ [0]->Fill( dist );
      if(hPt_ .size()>0) hPt_ [0]->Fill( ref->pt()  );
      if(hEta_.size()>0) hEta_[0]->Fill( ref->eta() );
    }
    if( 0<dist && dist<maxDR_ ){
      ++found_;
      if( match>=0 ){
        if(hDR_ .size()>1) hDR_ [1]->Fill( dist );
        if(hPt_ .size()>1) hPt_ [1]->Fill( ref->pt()  );
        if(hEta_.size()>1) hEta_[1]->Fill( ref->eta() );
      }
      if( !matches.insert(std::pair<int, int>(refIdx, match)).second )
        edm::LogWarning ( "MapMismatch" ) 
          << "Match could not be inserted in map; entry already exited?!";
    }
    else ++missed_;
  }
  return matches;
}
template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
void Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::summarize ( )

Definition at line 176 of file Comparison.h.

References cond::ecalcond::all.

{
  unsigned int all=found_+missed_+failed_;
  if(all>0){
    edm::LogInfo("MatchSummary") << "=============================================";
    edm::LogInfo("MatchSummary") << "Reference :";
    edm::LogInfo("MatchSummary") << "CaloJet   :";
    edm::LogInfo("MatchSummary") << "fraction of found  jets: " << 100*found_ /all << "%";
    edm::LogInfo("MatchSummary") << "fraction of missed jets: " << 100*missed_/all << "%";
    edm::LogInfo("MatchSummary") << "fraction of failed jets: " << 100*failed_/all << "%";
  }
  else{
    edm::LogWarning ( "MatchOrBalanceFault" ) 
      << "No missed, failed nor counts found";    
  }
}

Member Data Documentation

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
Alg Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::alg_ [private]

Definition at line 46 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
unsigned int Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::failed_ [private]

Definition at line 52 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
unsigned int Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::found_ [private]

Definition at line 50 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
std::vector<TH1F*> Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::hDR_ [private]

Definition at line 42 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
std::vector<TH1F*> Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::hEta_ [private]

Definition at line 44 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
std::vector<TH1F*> Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::hPt_ [private]

Definition at line 43 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
double Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::maxDR_ [private]

Definition at line 34 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
double Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::maxEtaRec_ [private]

Definition at line 38 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
double Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::maxEtaRef_ [private]

Definition at line 37 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
double Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::maxPtRec_ [private]

Definition at line 36 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
double Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::maxPtRef_ [private]

Definition at line 35 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
double Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::minEtaRec_ [private]

Definition at line 38 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
double Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::minEtaRef_ [private]

Definition at line 37 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
double Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::minPtRec_ [private]

Definition at line 36 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
double Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::minPtRef_ [private]

Definition at line 35 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
unsigned int Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::missed_ [private]

Definition at line 51 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
RecQualifier Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::recQualifier_ [private]

Definition at line 48 of file Comparison.h.

template<typename Ref , typename RefQualifier , typename Rec , typename RecQualifier , typename Alg >
RefQualifier Comparison< Ref, RefQualifier, Rec, RecQualifier, Alg >::refQualifier_ [private]

Definition at line 47 of file Comparison.h.