00001 #ifndef CAFE_STATWEIGHT_HPP__ 00002 #define CAFE_STATWEIGHT_HPP__ 00003 00004 #include <string> 00005 #include <TROOT.h> 00006 00007 namespace cafe { 00008 00009 /* \brief 00010 Class to encapsulated information about events selected. Will be overwritten for the 00011 event weights. This class is used internally by the StatSample class 00012 00013 \author Viatcheslav Shary (shary@fnal.gov) 00014 \ingroup group_cafe 00015 */ 00016 class StatSelection { 00017 00018 std::string _name ; 00019 unsigned long _events ; //< number of selected events 00020 bool _updated ; //< flag to verify that selections was done only once per event 00021 bool _weight ; //< if "true" should be interpreted as "pure" event weigth and not number of events with weight 00022 00023 public: 00024 StatSelection(const std::string& name, unsigned long events=1, bool weight=false) ; 00025 virtual ~StatSelection() {} 00026 00027 const std::string& name() const {return _name ;} 00028 unsigned long addEvent() ; 00029 unsigned long nevents() const {return _events ;} 00030 bool isUpdated() const {return _updated ;} 00031 bool isWeight() const {return _weight ;} 00032 00034 double err(const StatSelection& selection) const ; 00035 00037 virtual void Clear() {_updated = false ;} 00038 00039 bool operator== (const std::string& name) const {return name == _name ;} 00040 00041 ClassDef(StatSelection, 0) ; 00042 00043 } ; 00044 00045 /* \brief 00046 Class to collect different event weights 00047 This class is used internally by the Stat class 00048 00049 \author Viatcheslav Shary (shary@fnal.gov) 00050 \ingroup group_cafe 00051 */ 00052 00053 class StatWeight : public StatSelection { 00054 00055 double _weight_average ; //< event weight averaged over all previous events 00056 double _weight; //< the current event weight, must be cleared in the beginnin of the event 00057 double _rms2 ; //< weight rms 00058 double _weight_old ; //< internal bookkeeping variable 00059 double _rms2_old ; //< internal bookkeeping variable 00060 00061 double _weight_average_pos ; //< event weight shifted by +1 sigma averaged over all previous events 00062 double _weight_pos; //< the current event weight shifted by +1 sigma, must be cleared in the beginnin of the event 00063 double _rms2_pos ; //< weight shifted by +1 sigma rms 00064 double _weight_old_pos ; //< internal bookkeeping variable 00065 double _rms2_old_pos ; //< internal bookkeeping variable 00066 00067 00068 double _weight_average_neg ; //< event weight shifted by -1 sigma averaged over all previous events 00069 double _weight_neg; //< the current event weight shifted by -1 sigma , must be cleared in the beginnin of the event 00070 double _rms2_neg ; //< weight shifted by -1 sigma rms 00071 double _weight_old_neg ; //< internal bookkeeping variable 00072 double _rms2_old_neg ; //< internal bookkeeping variable 00073 00074 00075 public: 00076 00077 StatWeight(const std::string& name="NoName", bool event_selection=false) ; 00078 ~StatWeight() {} 00079 00081 double weight_average() const {return _weight_average ;} 00082 00084 double weight_average_pos() const {return _weight_average_pos ;} 00085 00087 double weight_average_neg() const {return _weight_average_neg ;} 00088 00090 double weight() const {return _weight ;} 00091 00093 double weight_pos() const {return _weight_pos ;} 00094 00096 double weight_neg() const {return _weight_neg ;} 00097 00099 double rms() const ; 00100 00102 double err() const ; 00103 00105 double err(const StatWeight& selection) const {return StatSelection::err((StatSelection) selection) ;} 00106 00108 double rms_pos() const ; 00109 00111 double err_pos() const ; 00112 00114 double rms_neg() const ; 00115 00117 double err_neg() const ; 00118 00120 void Clear() ; 00121 00122 double applyWeight(double weight, double weight_pos=-1.0, double weight_neg=-1.0) ; 00123 00124 ClassDef(StatWeight, 0) 00125 00126 } ; 00127 00128 } 00129 00130 #endif // CAFE_STATWEIGHT_HPP__
1.3.4