All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
include/N3AnaBase/cuts/source_cut.h
00001 #ifndef __N3AnaBase__source_cut_h
00002 #define __N3AnaBase__source_cut_h 1
00003 
00004 #include <cstdlib>
00005 #include <iostream>
00006 #include <stdexcept>
00007 #include <string>
00008 #include <list>
00009 
00010 #include <N3AnaBase/cuts/i_ana_event_cut.h>
00011 #include <N3AnaBase/utils/source_utils.h>
00012 
00013 namespace nemo3 {
00014   
00030 
00031   class source_cut : public nemo3::i_ana_event_cut
00032     {
00033     public:
00034       enum mode_t
00035         {
00036           MODE_INVALID            = -1,
00037           MODE_ALL_TRACKS         = 0,
00038           MODE_AT_LEAST_ONE_TRACK = 1
00039         };
00040 
00042       static int get_mode_from_label (const std::string & label_);
00043 
00045       static std::string get_label_from_mode (int mode_);
00046 
00048       static bool is_mode_valid (int mode_);
00049 
00050     private:
00051       bool __debug;
00052       int  __mode;
00053       bool __delayed;
00054       std::list<int>  __source_mask;
00055       std::string __tracking_name;
00056 
00057     public:
00058 
00060       source_cut (bool debug_ = false); 
00061 
00063       virtual ~source_cut (); 
00064 
00065     public:
00066 
00068       bool is_source_molybdenum_metallic () const
00069       {
00070         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_MO_METAL) == __source_mask.end())
00071           return false;
00072         return true;
00073       }
00074 
00076       bool is_source_molybdenum_composite () const
00077       {
00078         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_MO_COMPOSITE) == __source_mask.end())
00079           return false;
00080         return true;
00081       }
00082 
00084       bool is_source_selenium () const
00085       {
00086         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_SE) == __source_mask.end())
00087           return false;
00088         return true;
00089       }
00090 
00092       bool is_source_tellurium_natural () const
00093       {
00094         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_TE_NATURAL) == __source_mask.end())
00095           return false;
00096         return true;
00097       }
00098 
00100       bool is_source_tellurium_enriched () const
00101       {
00102         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_TE_ENRICHED) == __source_mask.end())
00103           return false;
00104         return true;
00105       }
00106 
00108       bool is_source_zirconium () const
00109       {
00110         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_ZR) == __source_mask.end())
00111           return false;
00112         return true;
00113       }
00114 
00116       bool is_source_neodymum () const
00117       {
00118         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_ND) == __source_mask.end())
00119           return false;
00120         return true;
00121       }
00122 
00124       bool is_source_calcium () const
00125       {
00126         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_CA) == __source_mask.end())
00127           return false;
00128         return true;
00129       }
00130 
00132       bool is_source_copper () const
00133       {
00134         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_CU) == __source_mask.end())
00135           return false;
00136         return true;
00137       }
00138 
00140       bool is_source_cadmium () const
00141       {
00142         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_CD) == __source_mask.end())
00143           return false;
00144         return true;
00145       }
00146 
00148       bool is_source_calibration_tube () const
00149       {
00150         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_CALIB_TUBE) == __source_mask.end())
00151           return false;
00152         return true;
00153       }
00154 
00156       bool is_source_endcap () const
00157       {
00158         if(find (__source_mask.begin(), __source_mask.end(), source_utils::SOURCE_ENDCAP) == __source_mask.end())
00159           return false;
00160         return true;
00161       }
00162 
00164       bool is_prompt () const
00165       {
00166         return ! __delayed;
00167       }
00168 
00170       bool is_delayed () const
00171       {
00172         return __delayed;
00173       }
00174 
00176       bool is_mode_all_tracks () const
00177       {
00178         return __mode == MODE_ALL_TRACKS;
00179       }
00180 
00182       bool is_mode_at_least_one_track () const
00183       {
00184         return __mode == MODE_AT_LEAST_ONE_TRACK;
00185       }
00186 
00188       bool is_debug () const;
00189 
00191       void set_debug (bool);
00192 
00194       void set (int mode_, 
00195                 std::list<int> source_mask_,
00196                 bool delayed_,
00197                 const std::string & tracking_name_ = "");
00198 
00200       void dump (std::ostream & out_ = std::clog) const;
00201 
00202     public:
00203 
00205       bool accept (); 
00206 
00207     protected:
00208 
00210       virtual void __prepare_cut ();
00211       
00212     private:
00213       
00215       static creator_registration<source_cut> __CR;
00216 
00217     public:
00218 
00220       static const std::string CUT_ID;
00221 
00223       virtual std::string cut_id () const;
00224 
00226       virtual cut_creator_t cut_creator () const;
00227 
00229       static nemo3::i_ana_event_cut * create (const nemocuts::ICutFactory::cut_properties_t & cut_properties_);
00230 
00231     };
00232 
00233 } // end of namespace nemo3 
00234 
00235 #endif /* __N3AnaBase__source_cut_h */
00236 
00237 // end of source_cut.h