StatSample.hpp

Go to the documentation of this file.
00001 #ifndef CAFE_STATSAMPLE_HPP__
00002 #define CAFE_STATSAMPLE_HPP__
00003 
00004 #include "cafe/Event.hpp" 
00005 #include "cafe/StatWeight.hpp" 
00006 
00007 #include <string>
00008 #include <vector>
00009 
00010 namespace cafe {
00011   
00012   struct  StatWeightNotFoundException {
00013     std::string _weight_name ;
00014     StatWeightNotFoundException(std::string weight_name): _weight_name(weight_name) {}
00015   };
00016 
00017   /* \brief
00018      Class to collect number of events for the one sample of statistics.
00019      This class is used internally by the Stat class.
00020      
00021      \authors  Viatcheslav Shary (shary@fnal.gov), Yann Coadou (yann@fnal.gov)
00022      
00023 \ingroup group_cafe
00024   */
00025   class StatSample {
00026     
00027     std::string _name ; //< sample name
00028     std::vector<std::string> _tags ; //< tags used to add events to the sample (ANY)
00029     std::vector<std::string> _tags_and ; //< tags requiered with AND 
00030     std::vector<StatWeight*> _events; //< selected events and associated global events weight for each selection 
00031     StatWeight* _weight ; //< the global event weight is a product of all weight applied to the event up to the current selection 
00032 
00033   public: 
00034     
00035     StatSample(const std::string& sample="data") ;
00036     virtual ~StatSample() ;
00037     
00038     const std::string& name() const {return _name ;}
00039     const std::vector<std::string>& tags() const {return _tags ;}
00040     const std::vector<std::string>& tagsAnd() const {return _tags_and ;}
00041     
00043     void AddTags(const std::string& tag) {_tags.push_back(tag);}
00044     
00046     void AddTags(const std::vector<std::string>& tags) ;
00047     
00049     void AddAndTags(const std::vector<std::string>& tags) ;
00050     
00052     void AddAndTags(const std::string& tag) {_tags_and.push_back(tag);}
00053     
00054     //return false if events does not have tags used for this sample
00055     bool tagged(const cafe::Event* event) const  ;
00056     
00058     unsigned int size() const { return _events.size();} 
00059     
00061     unsigned long nevents(unsigned int n = 0) const ;
00062     
00064     unsigned long nevents(const std::string& name) const ;
00065     
00067     double eff(unsigned int n = 0) const ;
00068     
00070     double eff(const std::string& name) const ;
00071     
00074     double effGlob(unsigned int n = 0) const ;
00075     
00077     double effGlob(const std::string& name) const ;
00078 
00082     double correctedEfficiency(unsigned int n = 0) const ;
00083     
00086     double correctedEfficiency(const std::string& name) const ;
00087     
00089     double effErr(unsigned int n = 0) const ;
00090     
00092     double effErr(const std::string& name) const ;
00093     
00095     double effErrGlob(unsigned int n = 0) const ;
00096     
00098     double effErrGlob(const std::string& name) const ;
00099     
00102     double correctedEffErr(unsigned int n = 0) const ;
00103     
00106     double correctedEffErr(const std::string& name) const ;
00107     
00109     const StatWeight* eventSelection(unsigned int n = 0) const ;
00110     
00112     const StatWeight* eventSelection(const std::string& name) const ;
00113     
00115     const StatWeight* eventWeight(unsigned int n) const ;
00116 
00118     const StatWeight*  eventWeight(const std::string& name="global") const ;
00119     
00121     Collection<EventWeight> ListEventWeights() const ;
00122 
00124     bool compareNames(const StatSample& sample) const ;
00125 
00127     unsigned long add(cafe::Event* event, const std::string& name="Initial") ;
00128     
00130     double applyWeight(cafe::Event* event, const std::string& name, 
00131                        double weight, double weight_pos, double weight_neg) ;
00132 
00134     void Clear() ; 
00135 
00137     ostream& HtmlTable(ostream& os) const ;
00138 
00140     ostream& print_tex (ostream& os, const std::string title) const ;
00141 
00143     static std::string tex(const std::string& init) ;
00144 
00145   public:
00146        ClassDef(StatSample, 0);     
00147 
00148    } ;
00149   
00150 }
00151 
00152 #endif // CAFE_STATSAMPLE_HPP__

Generated on Thu Apr 3 04:14:23 2008 for CAF by doxygen 1.3.4