CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ObjectCounter< C > Class Template Reference

#include <ObjectCounter.h>

Inheritance diagram for ObjectCounter< C >:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void endJob ()
 end-of-job processing More...
 
 ObjectCounter (const edm::ParameterSet &)
 constructor from parameter set More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 event processing More...
 

Private Attributes

unsigned long n2Sum_
 
unsigned long n_
 partial statistics More...
 
unsigned long nSum_
 
edm::EDGetTokenT< C > srcToken_
 label of source collection More...
 
bool verbose_
 verbosity flag More...
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

template<typename C>
class ObjectCounter< C >

Counts the number of objects in a collection and prints a summary report at the end of a job.

Template parameters:

Author
Luca Lista, INFN
Version
Revision:
1.1
Id:
ObjectCounter.h,v 1.1 2009/03/03 13:07:27 llista Exp

Definition at line 26 of file ObjectCounter.h.

Constructor & Destructor Documentation

template<typename C >
ObjectCounter< C >::ObjectCounter ( const edm::ParameterSet par)
explicit

constructor from parameter set

Definition at line 45 of file ObjectCounter.h.

45  :
46  srcToken_( consumes<C>( edm::InputTag( par.template getParameter<std::string>( "src" ) ) ) ),
47  verbose_( par.template getUntrackedParameter<bool>( "verbose", true ) ),
48  n_( 0 ), nSum_( 0 ), n2Sum_( 0 ) {
49 }
unsigned long n_
partial statistics
Definition: ObjectCounter.h:41
bool verbose_
verbosity flag
Definition: ObjectCounter.h:39
edm::EDGetTokenT< C > srcToken_
label of source collection
Definition: ObjectCounter.h:37
unsigned long nSum_
Definition: ObjectCounter.h:41
unsigned long n2Sum_
Definition: ObjectCounter.h:41

Member Function Documentation

template<typename C >
void ObjectCounter< C >::analyze ( const edm::Event evt,
const edm::EventSetup  
)
overrideprivatevirtual

event processing

Implements edm::EDAnalyzer.

Definition at line 68 of file ObjectCounter.h.

References dtNoiseDBValidation_cfg::cerr, edm::Event::getByToken(), h, edm::HandleBase::isValid(), and n.

68  {
70  evt.getByToken( srcToken_, h );
71  if (!h.isValid()) {
72  std::cerr << ">>> product: " << srcToken_ << " not found" << std::endl;
73  } else {
74  int n = h->size();
75  nSum_ += n;
76  n2Sum_ += ( n * n );
77  }
78  ++ n_;
79 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
unsigned long n_
partial statistics
Definition: ObjectCounter.h:41
edm::EDGetTokenT< C > srcToken_
label of source collection
Definition: ObjectCounter.h:37
unsigned long nSum_
Definition: ObjectCounter.h:41
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
bool isValid() const
Definition: HandleBase.h:76
unsigned long n2Sum_
Definition: ObjectCounter.h:41
template<typename C >
void ObjectCounter< C >::endJob ( void  )
virtual

end-of-job processing

Reimplemented from edm::EDAnalyzer.

Definition at line 52 of file ObjectCounter.h.

References gather_cfg::cout, n, alignCSCRings::s, and mathSSE::sqrt().

52  {
53  double n = 0, n2 = 0, s;
54  if ( n_!= 0 ) {
55  n = double( nSum_ ) / n_;
56  n2 = double ( n2Sum_ ) / n_;
57  }
58  s = sqrt( n2 - n * n );
59  if ( verbose_ ) {
60  edm::TypeID id( typeid( typename C::value_type ) );
61  std::cout << ">>> collection \"" << srcToken_ << "\" contains ("
62  << n << " +/- " << s << ") "
63  << id.friendlyClassName() << " objects" << std::endl;
64  }
65 }
unsigned long n_
partial statistics
Definition: ObjectCounter.h:41
bool verbose_
verbosity flag
Definition: ObjectCounter.h:39
edm::EDGetTokenT< C > srcToken_
label of source collection
Definition: ObjectCounter.h:37
unsigned long nSum_
Definition: ObjectCounter.h:41
T sqrt(T t)
Definition: SSEVec.h:48
Container::value_type value_type
tuple cout
Definition: gather_cfg.py:121
unsigned long n2Sum_
Definition: ObjectCounter.h:41

Member Data Documentation

template<typename C >
unsigned long ObjectCounter< C >::n2Sum_
private

Definition at line 41 of file ObjectCounter.h.

template<typename C >
unsigned long ObjectCounter< C >::n_
private

partial statistics

Definition at line 41 of file ObjectCounter.h.

template<typename C >
unsigned long ObjectCounter< C >::nSum_
private

Definition at line 41 of file ObjectCounter.h.

template<typename C >
edm::EDGetTokenT<C> ObjectCounter< C >::srcToken_
private

label of source collection

Definition at line 37 of file ObjectCounter.h.

template<typename C >
bool ObjectCounter< C >::verbose_
private

verbosity flag

Definition at line 39 of file ObjectCounter.h.