All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
include/N3AnaBase/cuts/energy_cut.h
00001 // -*- mode: c++; -*-
00002 // energy_cut.h
00003 
00004 #ifndef __N3AnaBase__energy_cut_h
00005 #define __N3AnaBase__energy_cut_h 1
00006 
00007 #include <cstdlib>
00008 #include <iostream>
00009 #include <string>
00010 #include <sstream>
00011 #include <stdexcept>
00012 
00013 #include <boost/numeric/interval.hpp>
00014 
00015 #include <N3AnaBase/cuts/i_ana_event_cut.h>
00016 
00017 namespace nemo3 {
00019 
00045   class energy_cut : public nemo3::i_ana_event_cut
00046   {
00047   public:
00050     enum mode_t
00051       {
00052         MODE_INVALID     = -1, 
00053         MODE_ENERGY_MIN  = 0,  
00054         MODE_ENERGY_MAX  = 1,  
00055         MODE_ENERGY_SUM  = 2,  
00056         MODE_ENERGY_EACH = 3,  
00057 
00058         MODE_UNASSOCIATED_ENERGY_MIN  = 4, 
00059         MODE_UNASSOCIATED_ENERGY_MAX  = 5, 
00060         MODE_UNASSOCIATED_ENERGY_SUM  = 6, 
00061         MODE_UNASSOCIATED_ENERGY_EACH = 7, 
00062 
00063         MODE_TRACK_ENERGY_MIN  = 8,  
00064         MODE_TRACK_ENERGY_MAX  = 9,  
00065         MODE_TRACK_ENERGY_SUM  = 10, 
00066         MODE_TRACK_ENERGY_EACH = 11, 
00067 
00068         MODE_GAMMA_TRACK_ENERGY_MIN  = 12, 
00069         MODE_GAMMA_TRACK_ENERGY_MAX  = 13, 
00070         MODE_GAMMA_TRACK_ENERGY_SUM  = 14, 
00071         MODE_GAMMA_TRACK_ENERGY_EACH = 15, 
00072 
00073         MODE_GAMMA_TRACKED_TRACK_ENERGY_MIN  = 16, 
00074         MODE_GAMMA_TRACKED_TRACK_ENERGY_MAX  = 17, 
00075         MODE_GAMMA_TRACKED_TRACK_ENERGY_SUM  = 18, 
00076         MODE_GAMMA_TRACKED_TRACK_ENERGY_EACH = 19, 
00077 
00078         MODE_ENERGY_CUT_LAST, 
00079 
00080       };
00081 
00082     static const double RANGE_MIN; 
00083     static const double RANGE_MAX; 
00084 
00085     static int get_mode_from_label (const std::string & label_); 
00086 
00087     static std::string get_label_from_mode (int mode_); 
00088 
00089     static bool is_mode_valid (int mode_); 
00090 
00091 
00092     typedef boost::numeric::interval<double> range_t; 
00093 
00094     static std::ostream & print_range (std::ostream & out_,
00095                                        const range_t & range_);
00096 
00097   private:
00098     bool    __debug;
00099     int     __mode;
00100     range_t __range;
00101     bool    __inverted; 
00102     double  __proba;    
00103 
00104   public:
00105 
00106     bool is_inverted () const; 
00107 
00108     bool is_mode_energy_min () const; 
00109 
00110     bool is_mode_energy_max () const; 
00111 
00112     bool is_mode_energy_sum () const; 
00113 
00114     bool is_mode_energy_each () const; 
00115 
00116     bool is_mode (std::string mode_) const; 
00117 
00118     energy_cut (bool debug_ = false); 
00119 
00120     virtual ~energy_cut (); 
00121 
00123     void set (int mode_,
00124               double min_,
00125               double max_,
00126               double proba_,
00127               bool inverted_ = false);
00128 
00129   public:
00130 
00131     bool is_debug () const; 
00132 
00133     void set_debug (bool); 
00134 
00135     void dump (std::ostream & out_ = std::clog) const; 
00136 
00137   public:
00139 
00140     bool accept ();
00141 
00142   protected:
00143     virtual void __prepare_cut (); 
00144 
00146   private:
00147     static creator_registration<energy_cut> __CR;
00148 
00149   public:
00150 
00151     static const std::string CUT_ID;
00152 
00153     virtual std::string cut_id () const;
00154 
00155     virtual cut_creator_t cut_creator () const;
00156 
00157     static nemo3::i_ana_event_cut * create (const nemocuts::ICutFactory::cut_properties_t & cut_properties_); 
00158 
00159   };
00160 
00161 } // end of namespace nemo3
00162 
00163 #endif /* __N3AnaBase_energy__cut_h */
00164 
00165 // end of energy_cut.h