Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

cafe::Stat Class Reference

Class to collect selections statistics and print efficiencies. More...

#include <Stat.hpp>

Inheritance diagram for cafe::Stat:

cafe::Processor List of all members.

Public Member Functions

 Stat (const char *name)
 What everyone else should use.

 Stat (const char *name, bool duplicate_ok)
 Use if you are trying to keep more than one around at once.

 ~Stat ()
double eventWeight (const std::string &name="global", const std::string sample_name="not_specified") const
double nevents (const std::string &name="Initial", const std::string &sample_name="not_specified") const
 Return number of events by selection name.

double efficiencyCorrected (const std::string &sample_name="not_specified") const
 return efficiency corrected by the global event weight

double efficiency (const std::string &sample_name="not_specified") const
 return global efficiency

double syst_pos (const std::string &name, const std::string &sample_name="not_specified") const
 return positive systematics with name name for the sample sample_name

double syst_neg (const std::string &name, const std::string &sample_name="not_specified") const
 return negative systematics with name name for the sample sample_name

double systerr_pos (const std::string &name, const std::string &sample_name="not_specified") const
 return error for the positive systematics with name name for the sample sample_name

double systerr_neg (const std::string &name, const std::string &sample_name="not_specified") const
 return error for the positive systematics with name name for the sample sample_name

std::vector< const cafe::StatSample * > get_samples () const
 retun list of samples

std::vector< const cafe::Syst * > get_syst () const
 retun list of systematics samples

void begin ()
 initialization

void finish ()
 Print efficiencies.

bool processEvent (cafe::Event &event)
 increase number of events before any selection

void EventSelected (const std::string &selection_name)
 Increase number of event selected. If such selection does not exist it will be added.

void applyWeight (const std::string &weight_name, double weight, double weight_pos=-1.0, double weight_neg=-1.0)
 apply weight to efficiency calculation.

double calculateGlobalWeight ()
 calculate global event weight

void eventEnd ()
 make clean in the end of the event

StatSampleadd_sample (const std::string &name)
 Add sample and return reference to it.

void add_syst (const std::string &name, StatSample *sample=0)
void tag (const std::vector< std::string > &tags)
 these tags will be added to the list to tag event in the begining ProcessEvent

ostream & print_html (ostream &os) const
 output operator

ostream & print_tex (ostream &os, const std::string title="Efficiency") const
 output operator

void chain (void)
void unchain (void)
void inheritWeights ()
 Get a list of all applied weights from the parent and apply them down here.

 ClassDef (Stat, 0)

Private Member Functions

double syst_pos (std::vector< Syst >::const_iterator jt) const
 return positive systematics

double syst_neg (std::vector< Syst >::const_iterator jt) const
 return negative systematics

double systerr_pos (std::vector< Syst >::const_iterator jt) const
 return error for the positive systematics

double systerr_neg (std::vector< Syst >::const_iterator jt) const
 return error for the positive systematics


Private Attributes

std::vector< StatSample_samples
std::vector< Syst_syst
cafe::Event_event
std::vector< std::string > _tags
bool _ignoreauto
Stat_parent_stat
 Pointer to the paretn Stat object if we are chained.


Detailed Description

Class to collect selections statistics and print efficiencies.

The Stat(name) call must be added to the directive cafe.Run ... (or to any other Cafe::Controller). To calculate efficiency relative to the all event, this call must be put in the beginning. In any other case only events selected before this call will be taken into account.

The efficiency could be calculated for the several different samples using the event tagging mechanism. First one need to specify sample names using the Sample configuration option, e.g.
.Sample: sample_name1, sample_name2.
If no Sample specified, the default sample with name equal to the Stat class name will be created. Than one specifies the event tags to be selected by the sample with given name. sample_name1.UseTag: tag1,tag2,tag3 If tag is not specified all selected events will be added to a sample. One event can be counted in the several samples.

Configuration options:

To add efficiency calculation for your one Processor, add following lines to the YourProcessor::processEvent(cafe::Event &event) method:

Stat* stat = 0 ;
event.get("Stat", stat) ;

... Selection 1 ...

stat->EventSelected("Selection 1 name") ;

... Selection 2 ....

stat->EventSelected("Selection 2 name") ;

Author:
Viatcheslav Shary (shary@fnal.gov)

Definition at line 89 of file cafe/cafe/Stat.hpp.


Constructor & Destructor Documentation

cafe::Stat::Stat const char *  name  ) 
 

What everyone else should use.

If we are the first one, we establish ourselves as the primere dude. Otherwise, we don't do anything. Errors will occur further down if the user tries to do two Stat at once without some careful shuffling.

Definition at line 36 of file Stat.cpp.

References cafe::Processor::name(), and STAT.

cafe::Stat::Stat const char *  name,
bool  duplicate_ok
 

Use if you are trying to keep more than one around at once.

Definition at line 50 of file Stat.cpp.

References cafe::Processor::name(), and STAT.

cafe::Stat::~Stat  ) 
 

Definition at line 62 of file Stat.cpp.


Member Function Documentation

StatSample& cafe::Stat::add_sample const std::string &  name  )  [inline]
 

Add sample and return reference to it.

Definition at line 177 of file cafe/cafe/Stat.hpp.

References _samples.

void cafe::Stat::add_syst const std::string &  name,
StatSample sample = 0
 

Definition at line 706 of file Stat.cpp.

References _samples, _syst, and cafe::StatSample::AddAndTags().

Referenced by begin().

void cafe::Stat::applyWeight const std::string &  weight_name,
double  weight,
double  weight_pos = -1.0,
double  weight_neg = -1.0
 

apply weight to efficiency calculation.

Definition at line 239 of file Stat.cpp.

References _event, _samples, and _syst.

Referenced by cafe::StatPointer::applyWeight(), inheritWeights(), and cafe::EventMultiSplitter::processPermutation().

void cafe::Stat::begin  )  [virtual]
 

initialization

add systematics

Reimplemented from cafe::Processor.

Definition at line 114 of file Stat.cpp.

References _ignoreauto, _samples, add_syst(), cafe::Config::get(), cafe::Config::getVString(), cafe::Processor::name(), and tag().

Referenced by cafe::EventMultiSplitter::EventMultiSplitter().

double cafe::Stat::calculateGlobalWeight  ) 
 

calculate global event weight

Definition at line 683 of file Stat.cpp.

References _event, and _samples.

Referenced by cafe::StatPointer::calculateGlobalWeight().

void cafe::Stat::chain void   ) 
 

We can't chain if we are already in the chain!

Definition at line 64 of file Stat.cpp.

References _parent_stat, and STAT.

Referenced by cafe::EventMultiSplitter::processEvent().

cafe::Stat::ClassDef Stat  ,
 

double cafe::Stat::efficiency const std::string &  sample_name = "not_specified"  )  const
 

return global efficiency

Definition at line 661 of file Stat.cpp.

References _samples.

double cafe::Stat::efficiencyCorrected const std::string &  sample_name = "not_specified"  )  const
 

return efficiency corrected by the global event weight

Definition at line 651 of file Stat.cpp.

References _samples.

void cafe::Stat::eventEnd  ) 
 

make clean in the end of the event

Definition at line 176 of file Stat.cpp.

References _event, _samples, and _syst.

Referenced by cafe::EventBase::clear(), and cafe::EventMultiSplitter::processPermutation().

void cafe::Stat::EventSelected const std::string &  selection_name  ) 
 

Increase number of event selected. If such selection does not exist it will be added.

Definition at line 221 of file Stat.cpp.

References _event, _ignoreauto, _samples, and _syst.

Referenced by cafe::StatPointer::EventSelected(), cafe::Processor::incEventCount(), and inheritWeights().

double cafe::Stat::eventWeight const std::string &  name = "global",
const std::string  sample_name = "not_specified"
const
 

Return event weight by name. Return global event weight for the first sample by default. If weight with specified name was not found or sample with name sample_name does not exist return -1.0

Definition at line 671 of file Stat.cpp.

References _samples.

void cafe::Stat::finish  )  [virtual]
 

Print efficiencies.

Reimplemented from cafe::Processor.

Definition at line 153 of file Stat.cpp.

References cafe::Config::get(), cafe::Processor::name(), print_html(), and print_tex().

Referenced by cafe::EventMultiSplitter::finish().

vector< const StatSample * > cafe::Stat::get_samples  )  const
 

retun list of samples

Definition at line 784 of file Stat.cpp.

References _samples.

Referenced by inheritWeights().

vector< const Syst * > cafe::Stat::get_syst  )  const
 

retun list of systematics samples

Definition at line 791 of file Stat.cpp.

References _syst.

void cafe::Stat::inheritWeights void   ) 
 

Get a list of all applied weights from the parent and apply them down here.

Use only the first stat sample to do the weight mapping.

Definition at line 87 of file Stat.cpp.

References _parent_stat, applyWeight(), EventSelected(), cafe::StatSample::eventSelection(), get_samples(), cafe::StatSelection::isWeight(), cafe::StatSelection::name(), cafe::StatSample::size(), STAT, cafe::StatWeight::weight(), cafe::StatWeight::weight_neg(), and cafe::StatWeight::weight_pos().

Referenced by cafe::EventMultiSplitter::processPermutation().

double cafe::Stat::nevents const std::string &  name = "Initial",
const std::string &  sample_name = "not_specified"
const
 

Return number of events by selection name.

Definition at line 690 of file Stat.cpp.

References _samples.

ostream & cafe::Stat::print_html ostream &  os  )  const
 

output operator

Definition at line 257 of file Stat.cpp.

References _samples, _syst, syst_neg(), syst_pos(), systerr_neg(), systerr_pos(), and cafe::StatWeight::weight_average().

Referenced by finish().

ostream & cafe::Stat::print_tex ostream &  os,
const std::string  title = "Efficiency"
const
 

output operator

Definition at line 610 of file Stat.cpp.

References _samples, _syst, syst_neg(), syst_pos(), systerr_neg(), and systerr_pos().

Referenced by finish().

bool cafe::Stat::processEvent cafe::Event event  )  [virtual]
 

increase number of events before any selection

Reimplemented from cafe::Processor.

Definition at line 189 of file Stat.cpp.

References _event, _samples, _syst, _tags, cafe::Processor::err(), cafe::EventBase::get(), cafe::Processor::name(), cafe::EventBase::put(), and cafe::EventBase::tag().

Referenced by cafe::EventMultiSplitter::processPermutation().

double cafe::Stat::syst_neg const std::string &  name,
const std::string &  sample_name = "not_specified"
const
 

return negative systematics with name name for the sample sample_name

Definition at line 766 of file Stat.cpp.

References _syst, and syst_neg().

double cafe::Stat::syst_neg std::vector< Syst >::const_iterator  jt  )  const [private]
 

return negative systematics

Definition at line 753 of file Stat.cpp.

Referenced by print_html(), print_tex(), and syst_neg().

double cafe::Stat::syst_pos const std::string &  name,
const std::string &  sample_name = "not_specified"
const
 

return positive systematics with name name for the sample sample_name

Definition at line 734 of file Stat.cpp.

References _syst, and syst_pos().

double cafe::Stat::syst_pos std::vector< Syst >::const_iterator  jt  )  const [private]
 

return positive systematics

Definition at line 721 of file Stat.cpp.

Referenced by print_html(), print_tex(), and syst_pos().

double cafe::Stat::systerr_neg const std::string &  name,
const std::string &  sample_name = "not_specified"
const
 

return error for the positive systematics with name name for the sample sample_name

Definition at line 775 of file Stat.cpp.

References _syst, and systerr_neg().

double cafe::Stat::systerr_neg std::vector< Syst >::const_iterator  jt  )  const [private]
 

return error for the positive systematics

Definition at line 758 of file Stat.cpp.

Referenced by print_html(), print_tex(), and systerr_neg().

double cafe::Stat::systerr_pos const std::string &  name,
const std::string &  sample_name = "not_specified"
const
 

return error for the positive systematics with name name for the sample sample_name

Definition at line 743 of file Stat.cpp.

References _syst, and systerr_pos().

double cafe::Stat::systerr_pos std::vector< Syst >::const_iterator  jt  )  const [private]
 

return error for the positive systematics

Definition at line 726 of file Stat.cpp.

Referenced by print_html(), print_tex(), and systerr_pos().

void cafe::Stat::tag const std::vector< std::string > &  tags  ) 
 

these tags will be added to the list to tag event in the begining ProcessEvent

Definition at line 700 of file Stat.cpp.

References _tags.

Referenced by begin().

void cafe::Stat::unchain void   ) 
 

Can't unchain if we aren't in a chain!

Definition at line 74 of file Stat.cpp.

References _parent_stat, and STAT.

Referenced by cafe::EventMultiSplitter::processEvent().


Member Data Documentation

cafe::Event* cafe::Stat::_event [private]
 

Definition at line 93 of file cafe/cafe/Stat.hpp.

Referenced by applyWeight(), calculateGlobalWeight(), eventEnd(), EventSelected(), and processEvent().

bool cafe::Stat::_ignoreauto [private]
 

Definition at line 95 of file cafe/cafe/Stat.hpp.

Referenced by begin(), and EventSelected().

Stat* cafe::Stat::_parent_stat [private]
 

Pointer to the paretn Stat object if we are chained.

Definition at line 110 of file cafe/cafe/Stat.hpp.

Referenced by chain(), inheritWeights(), and unchain().

std::vector<StatSample> cafe::Stat::_samples [private]
 

Definition at line 91 of file cafe/cafe/Stat.hpp.

Referenced by add_sample(), add_syst(), applyWeight(), begin(), calculateGlobalWeight(), efficiency(), efficiencyCorrected(), eventEnd(), EventSelected(), eventWeight(), get_samples(), nevents(), print_html(), print_tex(), and processEvent().

std::vector<Syst> cafe::Stat::_syst [private]
 

Definition at line 92 of file cafe/cafe/Stat.hpp.

Referenced by add_syst(), applyWeight(), eventEnd(), EventSelected(), get_syst(), print_html(), print_tex(), processEvent(), syst_neg(), syst_pos(), systerr_neg(), and systerr_pos().

std::vector<std::string> cafe::Stat::_tags [private]
 

Definition at line 94 of file cafe/cafe/Stat.hpp.

Referenced by processEvent(), and tag().


The documentation for this class was generated from the following files:
Generated on Tue Mar 28 10:13:11 2006 for CAF by doxygen 1.3.4