Stat.hpp

Go to the documentation of this file.
00001 #ifndef CAFE_STAT_HPP__
00002 #define CAFE_STAT_HPP__
00003 
00004 #include "cafe/StatSample.hpp"
00005 #include "cafe/Processor.hpp"
00006 
00007 #include <string>
00008 #include <vector>
00009 #include <map>
00010 
00011 namespace cafe {
00012 
00013   /*
00014  Structure with samples for the systematics study
00015  \ingroup group_cafe
00016   */
00017   struct Syst {
00018     std::string name ;
00019     const StatSample* reference;
00020     StatSample pos, neg ;
00021     Syst(const std::string& syst_name, const StatSample* reference_sample) :
00022       name(syst_name), reference(reference_sample), 
00023       pos(reference_sample->name()+"_"+name+"_pos"), 
00024       neg(reference_sample->name()+"_"+name+"_neg") {
00025 
00026       pos.AddTags(reference->tags()) ;
00027       //      pos.AddAndTags(reference->tagsAnd()) ;
00028       pos.AddAndTags(syst_name+"_pos") ;
00029 
00030       neg.AddTags(reference->tags()) ;
00031       //      neg.AddAndTags(reference->tagsAnd()) ;
00032       neg.AddAndTags(syst_name+"_neg") ;
00033 
00034     }
00035   };
00036     
00240   class Stat : public cafe::Processor{
00241 
00242     std::vector<StatSample> _samples ; //< number of selected events for the different samples
00243     std::vector<Syst> _syst ; //< vector with systematics samples
00244     cafe::Event* _event ; //< pointer to the event object
00245     std::vector<std::string> _tags ; //< initial tags used to tag events
00246     bool _ignoreauto ;  //< ignore records made automatically
00247     int _precision ; //< presicion parameter for output streams
00248     unsigned long int _update ; // number of events between output statistics updates
00249     std::string _output_name;   // name of efficiencies file
00250     std::string _title;
00251 
00253     double syst_pos(std::vector<Syst>::const_iterator jt) const ;
00254 
00256     double syst_neg(std::vector<Syst>::const_iterator jt) const ;
00257 
00259     double systerr_pos(std::vector<Syst>::const_iterator jt) const ;
00260 
00262     double systerr_neg(std::vector<Syst>::const_iterator jt) const ;
00263 
00265         Stat *_parent_stat;
00266 
00267   public:
00268 
00270     Stat(const char *name);
00272         Stat(const char *name, bool duplicate_ok);
00273     ~Stat();
00274 
00279     double eventWeight(const std::string& name="global", 
00280                        const std::string sample_name="not_specified") const ;
00281 
00282 
00284     Collection<EventWeight> ListEventWeights(const std::string sample_name="not_specified") const ;
00285 
00287     double nevents(const std::string& name="Initial", const std::string& sample_name="not_specified") const ;
00288 
00290     double efficiencyCorrected(const std::string& sample_name="not_specified") const;
00291 
00293     double efficiency(const std::string& sample_name="not_specified") const;
00294 
00297     double syst_pos(const std::string& name, const std::string& sample_name="not_specified") const ; 
00298 
00301     double syst_neg(const std::string& name, const std::string& sample_name="not_specified") const ; 
00302 
00304     double systerr_pos(const std::string& name, const std::string& sample_name="not_specified") const ; 
00305 
00307     double systerr_neg(const std::string& name, const std::string& sample_name="not_specified") const ; 
00308 
00310     std::vector<const cafe::StatSample*> get_samples() const ;
00311 
00313     std::vector<const cafe::Syst*> get_syst() const ;
00314 
00316     void begin();
00317 
00319     void finish() ;
00320 
00322     bool processEvent(cafe::Event& event);
00323 
00325     void EventSelected(const std::string& selection_name) ;
00326 
00328     void applyWeight(const std::string& weight_name, 
00329                      double weight, double weight_pos=-1.0, double weight_neg=-1.0) ;
00330 
00332     void eventEnd() ;
00333 
00335     StatSample&  add_sample(const std::string& name) {_samples.push_back(name); return _samples.back();} 
00336 
00340     void add_syst(const std::string& name, StatSample* sample=0) ;
00341 
00343     void tag(const std::vector<std::string>& tags) ;
00344 
00346     ostream& print_html(ostream& os) const ; 
00347     ostream& print_tex(ostream& os, const std::string title="Efficiency") const ; 
00348 
00349         // Use when you need to use a sub-stat processor.
00350         void chain (void);
00351         void unchain (void);
00352         
00353         // Use to inherrit current weights from parent
00354         void inheritWeights();
00355     
00356   public:
00357     ClassDef(Stat, 0) ;
00358   };
00359 
00361   class StatPointer {
00362     Stat* _stat ;
00363     
00364   public :
00365     StatPointer(Stat* stat=0) ;
00366     virtual ~StatPointer() ;
00367     Stat* pointer() {return _stat;}
00368  
00370     void EventSelected(const std::string& selection_name) ;
00371 
00373     void applyWeight(const std::string& weight_name, 
00374                      double weight, double weight_pos=-1.0, double weight_neg=-1.0) ;
00375 
00376     ClassDef(StatPointer, 0) ;
00377 
00378   } ;
00379 }
00380 
00381 #endif // CAFE_STAT_HPP__

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