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 /* \brief 00013 Class to collect number of events for the one sample of statistics. 00014 This class is used internally by the Stat class. 00015 00016 \author Viatcheslav Shary (shary@fnal.gov) 00017 00018 */ 00019 class StatSample { 00020 00021 std::string _name ; //< sample name 00022 std::vector<std::string> _tags ; //< tags used to add events to the sample (ANY) 00023 std::vector<std::string> _tags_and ; //< tags requiered with AND 00024 std::vector<StatSelection*> _events ; //< selected events or event weight 00025 StatWeight* _weight ; //< the global event weight 00026 std::vector<std::pair<StatWeight*,StatWeight*> > _syst ; //< systematics +sigma, -sigma 00027 00028 public: 00029 00030 StatSample(const std::string& sample="data") ; 00031 virtual ~StatSample() ; 00032 00033 const std::string& name() const {return _name ;} 00034 const std::vector<std::string>& tags() const {return _tags ;} 00035 const std::vector<std::string>& tagsAnd() const {return _tags_and ;} 00036 00038 void AddTags(const std::string& tag) {_tags.push_back(tag);} 00039 00041 void AddTags(const std::vector<std::string>& tags) ; 00042 00044 void AddAndTags(const std::vector<std::string>& tags) ; 00045 00047 void AddAndTags(const std::string& tag) {_tags_and.push_back(tag);} 00048 00049 //return false if events does not have tags used for this sample 00050 bool tagged(const cafe::Event* event) const ; 00051 00053 unsigned int size() const { return _events.size();} 00054 00056 unsigned long nevents(unsigned int n = 0) const ; 00057 00059 unsigned long nevents(const std::string& name) const ; 00060 00062 double eff(unsigned int n = 0) const ; 00063 00065 double eff(const std::string& name) const ; 00066 00069 double effGlob(unsigned int n = 0) const ; 00070 00072 double effGlob(const std::string& name) const ; 00073 00075 double effErr(unsigned int n = 0) const ; 00076 00078 double effErr(const std::string& name) const ; 00079 00081 double effErrGlob(unsigned int n = 0) const ; 00082 00084 double effErrGlob(const std::string& name) const ; 00085 00087 const StatSelection* eventSelection(unsigned int n = 0) const ; 00088 00090 const StatSelection* eventSelection(const std::string& name) const ; 00091 00093 const StatWeight* eventWeight(unsigned int n) const ; 00094 00096 const StatWeight* eventWeight(const std::string& name="global") const ; 00097 00099 double correctedEff(const StatWeight* w=0) const ; 00100 00102 double correctedEffErr(const StatWeight* w=0) const ; 00103 00105 const std::pair<StatWeight*, StatWeight*>& systematics(unsigned int n = 0) const ; 00106 00108 unsigned int systsize() const { return _syst.size();} 00109 00111 double totalsyst_pos() const ; 00112 00114 double totalsyst_neg() const ; 00115 00117 bool compareNames(const StatSample& sample) const ; 00118 00120 unsigned long add(cafe::Event* event, const std::string& name="Initial") ; 00121 00123 double applyWeight(cafe::Event* event, const std::string& name, 00124 double weight, double weight_pos, double weight_neg) ; 00125 00127 double calculateGlobalWeight(cafe::Event* event) ; 00128 00130 void Clear() ; 00131 00133 ostream& HtmlTable(ostream& os) const ; 00134 00136 ostream& print_tex (ostream& os, const std::string title) const ; 00137 00139 ostream& print_tex_syst (ostream& os) const ; 00140 00142 static std::string tex(const std::string& init) ; 00143 00144 public: 00145 ClassDef(StatSample, 0); 00146 00147 } ; 00148 00149 } 00150 00151 #endif // CAFE_STATSAMPLE_HPP__
1.3.4