CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes | Friends

Selection< C, Selector, StoreContainer > Class Template Reference

#include <Selection.h>

List of all members.

Classes

class  const_iterator
struct  Count

Public Types

typedef const value_typeconst_reference
typedef std::vector< Filter * >
::iterator 
iterator
typedef value_typereference
typedef C::size_type size_type
typedef C::value_type value_type

Public Member Functions

std::map< std::string, bool > accept (edm::Event &iEvent)
const_iterator begin () const
iterator begin ()
bool empty () const
iterator end ()
const_iterator end () const
bool makeAllButOnePlots ()
bool makeContentPlots ()
bool makeCumulativePlots ()
bool makeFinalPlots ()
bool makeSummaryTable ()
const std::string & name ()
bool ntuplize ()
const_reference operator[] (size_type i)
void print (bool description=true)
void printDetailledPrintoutHeader ()
 Selection (const C &c, const Selector &sel)
 Selection (std::string name, const edm::ParameterSet &iConfig)
size_type size () const

Private Attributes

std::map< std::string, Countcounts_
std::string detailledPrintoutCategory_
std::vector< Filter * > filters_
bool makeAllButOnePlots_
bool makeContentPlots_
bool makeCumulativePlots_
bool makeDetailledPrintout_
bool makeFinalPlots_
bool makeSummaryTable_
std::string name_
unsigned int nMonitor_
unsigned int nSeen_
bool ntuplize_
Selector select_
StoreContainer selected_

Friends

class Selections

Detailed Description

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
class Selection< C, Selector, StoreContainer >

Definition at line 8 of file Selection.h.


Member Typedef Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef const value_type& Selection< C, Selector, StoreContainer >::const_reference

Definition at line 13 of file Selection.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef std::vector<Filter*>::iterator Selection< C, Selector, StoreContainer >::iterator

Definition at line 112 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef value_type& Selection< C, Selector, StoreContainer >::reference

Definition at line 12 of file Selection.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef C::size_type Selection< C, Selector, StoreContainer >::size_type

Definition at line 11 of file Selection.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef C::value_type Selection< C, Selector, StoreContainer >::value_type

Definition at line 10 of file Selection.h.


Constructor & Destructor Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
Selection< C, Selector, StoreContainer >::Selection ( const C &  c,
const Selector sel 
) [inline]

Definition at line 14 of file Selection.h.

References i, Selection< C, Selector, StoreContainer >::select_, and Selection< C, Selector, StoreContainer >::selected_.

                                                 :
    select_( sel ) {
    for( typename C::const_iterator i = c.begin(); i != c.end(); ++i ) {
      if ( select_( *i ) ) selected_.push_back( & * i );
    }
  }
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
Selection< C, Selector, StoreContainer >::Selection ( std::string  name,
const edm::ParameterSet iConfig 
) [inline]

Definition at line 115 of file Selections.h.

References Selection< C, Selector, StoreContainer >::detailledPrintoutCategory_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), Selection< C, Selector, StoreContainer >::makeDetailledPrintout_, and Selection< C, Selector, StoreContainer >::nMonitor_.

                                                            :
    name_(name), 
    ntuplize_(iConfig.getParameter<bool>("ntuplize")),
    makeContentPlots_(iConfig.getParameter<bool>("makeContentPlots")),
    makeFinalPlots_(iConfig.getParameter<bool>("makeFinalPlots")),
    makeCumulativePlots_(iConfig.getParameter<bool>("makeCumulativePlots")),
    makeAllButOnePlots_(iConfig.getParameter<bool>("makeAllButOnePlots")),
    nSeen_(0),
    makeSummaryTable_(iConfig.getParameter<bool>("makeSummaryTable")),
    makeDetailledPrintout_(iConfig.exists("detailledPrintoutCategory"))
  {
    if (iConfig.exists("nMonitor"))
      nMonitor_=iConfig.getParameter<unsigned int>("nMonitor");
    else
      nMonitor_=0;

    if (makeDetailledPrintout_)
      detailledPrintoutCategory_ = iConfig.getParameter<std::string>("detailledPrintoutCategory");
  }

Member Function Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::map<std::string, bool> Selection< C, Selector, StoreContainer >::accept ( edm::Event iEvent) [inline]

Definition at line 139 of file Selections.h.

References Selection< C, Selector, StoreContainer >::begin(), prof2calltree::count, Selection< C, Selector, StoreContainer >::counts_, Selection< C, Selector, StoreContainer >::detailledPrintoutCategory_, Selection< C, Selector, StoreContainer >::end(), edm::EventID::event(), align_tpl::filter, edm::EventBase::id(), Selection< C, Selector, StoreContainer >::makeDetailledPrintout_, Selection< C, Selector, StoreContainer >::name(), Selection< C, Selector, StoreContainer >::Count::nCumulative_, Selection< C, Selector, StoreContainer >::nMonitor_, Selection< C, Selector, StoreContainer >::Count::nPass_, Selection< C, Selector, StoreContainer >::Count::nSeen_, Selection< C, Selector, StoreContainer >::nSeen_, Selection< C, Selector, StoreContainer >::print(), runTheMatrix::ret, edm::EventID::run(), and edmLumisInFiles::summary.

                                                  {
    nSeen_++;
    if (nMonitor_!=0 && nSeen_%nMonitor_==0){
      if (nSeen_==nMonitor_) print();
      else print(false);
    }
    std::map<std::string, bool> ret;
    bool global=true;
    for (iterator filter=begin(); filter!=end();++filter){
      const std::string & fName=(*filter)->name();
      Count & count=counts_[fName];
      count.nSeen_++;
      bool decision=(*filter)->accept(iEvent);
      ret[fName]=decision;
      if (decision) count.nPass_++;
      global=global && decision;
      if (global) count.nCumulative_++;
    }

    if (makeDetailledPrintout_){
      std::stringstream summary;
      summary<<std::setw(20)<<name().substr(0,19)<<" : "
             <<std::setw(10)<<iEvent.id().run()<<" : "
             <<std::setw(10)<<iEvent.id().event();
      for (iterator filter=begin(); filter!=end();++filter){
        const std::string & fName=(*filter)->name();
        summary<<" : "<<std::setw(10)<<(ret[fName]?"pass":"reject");
      }
      edm::LogVerbatim(detailledPrintoutCategory_)<<summary.str();
    }
    
    return ret;
  }
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
const_iterator Selection< C, Selector, StoreContainer >::begin ( void  ) const [inline]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
iterator Selection< C, Selector, StoreContainer >::begin ( void  ) [inline]

Definition at line 136 of file Selections.h.

References Selection< C, Selector, StoreContainer >::filters_.

{ return filters_.begin();}
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::empty ( ) const [inline]

Definition at line 51 of file Selection.h.

References Selection< C, Selector, StoreContainer >::selected_.

{ return selected_.empty(); }
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
iterator Selection< C, Selector, StoreContainer >::end ( void  ) [inline]

Definition at line 137 of file Selections.h.

References Selection< C, Selector, StoreContainer >::filters_.

{ return filters_.end();}
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
const_iterator Selection< C, Selector, StoreContainer >::end ( void  ) const [inline]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeAllButOnePlots ( ) [inline]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeContentPlots ( ) [inline]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeCumulativePlots ( ) [inline]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeFinalPlots ( ) [inline]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeSummaryTable ( ) [inline]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
const std::string& Selection< C, Selector, StoreContainer >::name ( ) [inline]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::ntuplize ( ) [inline]

Definition at line 238 of file Selections.h.

References Selection< C, Selector, StoreContainer >::ntuplize_.

{return ntuplize_;}
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
const_reference Selection< C, Selector, StoreContainer >::operator[] ( size_type  i) [inline]

Definition at line 52 of file Selection.h.

References i, and Selection< C, Selector, StoreContainer >::selected_.

{ return * selected_[i]; }
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
void Selection< C, Selector, StoreContainer >::print ( bool  description = true) [inline]

Definition at line 186 of file Selections.h.

References Selection< C, Selector, StoreContainer >::begin(), category(), prof2calltree::count, Selection< C, Selector, StoreContainer >::counts_, gather_cfg::cout, idDealer::description, Selection< C, Selector, StoreContainer >::end(), align_tpl::filter, Selection< C, Selector, StoreContainer >::makeSummaryTable_, Selection< C, Selector, StoreContainer >::name(), Selection< C, Selector, StoreContainer >::Count::nCumulative_, Selection< C, Selector, StoreContainer >::Count::nPass_, Selection< C, Selector, StoreContainer >::Count::nSeen_, Selection< C, Selector, StoreContainer >::nSeen_, and edmLumisInFiles::summary.

Referenced by Selection< C, Selector, StoreContainer >::accept().

                                   {
    if (!makeSummaryTable_) return;

    unsigned int maxFnameSize = 20;
    for (iterator filter=begin(); filter!=end();++filter){
      if ((*filter)->name().size() > maxFnameSize) maxFnameSize = (*filter)->name().size()+1;
    }

    //    const std::string category ="Selections|"+name();
    const std::string category ="Selections";
    std::stringstream summary;
    summary<<"   Summary table for selection: "<<name()<<" with: "<<nSeen_<<" events run."<<std::endl;
    if (nSeen_==0) return;
    if (description){
      for (iterator filter=begin(); filter!=end();++filter){
        const std::string & fName=(*filter)->name();
        summary<<"filter: "<<std::right<<std::setw(10)<<fName<<"\n"
               <<(*filter)->descriptionText()<<"\n";
      }
    }
    summary<<" filter stand-alone pass: "<<std::endl;
    summary<<std::right<<std::setw(maxFnameSize)<<"total read"<<": "
           <<std::right<<std::setw(10)<<nSeen_<<std::endl;
    for (iterator filter=begin(); filter!=end();++filter){
      const std::string & fName=(*filter)->name();
      const Count & count=counts_[fName];
      summary<<std::right<<std::setw(maxFnameSize)<<fName<<": "
             <<std::right<<std::setw(10)<<count.nPass_<<" passed events. "
             <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nPass_/(float)count.nSeen_)*100.<<" [%]"<<std::endl;
    }
    summary<<" filter cumulative pass:"<<std::endl;
    summary<<std::right<<std::setw(maxFnameSize)<<"total read"<<": "
           <<std::right<<std::setw(10)<<nSeen_<<std::endl;
    unsigned int lastCount=nSeen_;
    for (iterator filter=begin(); filter!=end();++filter){
      const std::string & fName=(*filter)->name();
      const Count & count=counts_[fName];
      summary<<std::right<<std::setw(maxFnameSize)<<fName<<": "
             <<std::right<<std::setw(10)<<count.nCumulative_<<" passed events. "
             <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nCumulative_/(float)count.nSeen_)*100.<<" [%]";
      if (lastCount!=0)
        summary<<" (to previous count) "<<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nCumulative_/(float)lastCount)*100.<<" [%]";
      summary   <<std::endl;

      lastCount = count.nCumulative_;
    }
    summary<<"-------------------------------------\n";
    edm::LogVerbatim(category)<<summary.str();
    std::cout<<summary.str();
  };
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
void Selection< C, Selector, StoreContainer >::printDetailledPrintoutHeader ( ) [inline]

Definition at line 173 of file Selections.h.

References Selection< C, Selector, StoreContainer >::begin(), Selection< C, Selector, StoreContainer >::detailledPrintoutCategory_, Selection< C, Selector, StoreContainer >::end(), align_tpl::filter, Selection< C, Selector, StoreContainer >::makeDetailledPrintout_, and edmLumisInFiles::summary.

                                     {
    if (makeDetailledPrintout_){
      std::stringstream summary;
      summary<<std::setw(20)<<" selection name "<<" : "
             <<std::setw(10)<<" run "<<" : "
             <<std::setw(10)<<" event ";
      for (iterator filter=begin(); filter!=end();++filter){
        summary<<" : "<<std::setw(10)<<(*filter)->name().substr(0,9);
      }
      edm::LogVerbatim(detailledPrintoutCategory_)<<summary.str();
    }
  }
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
size_type Selection< C, Selector, StoreContainer >::size ( void  ) const [inline]

Definition at line 50 of file Selection.h.

References Selection< C, Selector, StoreContainer >::selected_.

{ return selected_.size(); }

Friends And Related Function Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
friend class Selections [friend]

Definition at line 113 of file Selections.h.


Member Data Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::map<std::string, Count> Selection< C, Selector, StoreContainer >::counts_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::string Selection< C, Selector, StoreContainer >::detailledPrintoutCategory_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::vector<Filter*> Selection< C, Selector, StoreContainer >::filters_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeAllButOnePlots_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeContentPlots_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeCumulativePlots_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeDetailledPrintout_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeFinalPlots_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeSummaryTable_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::string Selection< C, Selector, StoreContainer >::name_ [private]

Definition at line 246 of file Selections.h.

Referenced by Selection< C, Selector, StoreContainer >::name().

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
unsigned int Selection< C, Selector, StoreContainer >::nMonitor_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
unsigned int Selection< C, Selector, StoreContainer >::nSeen_ [private]
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::ntuplize_ [private]

Definition at line 249 of file Selections.h.

Referenced by Selection< C, Selector, StoreContainer >::ntuplize().

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
Selector Selection< C, Selector, StoreContainer >::select_ [private]

Definition at line 54 of file Selection.h.

Referenced by Selection< C, Selector, StoreContainer >::Selection().

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
StoreContainer Selection< C, Selector, StoreContainer >::selected_ [private]