00001 #ifndef __nemo3__i_ana_event_cut_h
00002 #define __nemo3__i_ana_event_cut_h 1
00003
00004 #include <boost/scoped_ptr.hpp>
00005
00006 #include <NemoCuts/ICut.hh>
00007
00008 #include <N3AnaBase/cuts/cut_tools.h>
00009 #include <N3AnaBase/event/ana_event.h>
00010
00011 namespace nemo3 {
00012
00013 typedef ana_event event_t;
00014
00021
00022 class i_ana_event_cut : public nemocuts::ICut
00023 {
00024
00025 public:
00026
00028 class cut_db
00029 {
00030 cut_creator_dict_t __dict;
00031
00032 public:
00033
00035 cut_db (bool = false);
00036
00038 virtual ~cut_db ();
00039
00041 const cut_creator_dict_t & get_dict () const
00042 {
00043 return __dict;
00044 }
00045
00047 cut_creator_dict_t & get_dict ()
00048 {
00049 return __dict;
00050 }
00051
00053 bool has_cut (const std::string & cut_id_) const;
00054
00056 cut_creator_t & get_cut (const std::string & cut_id_);
00057
00059 void register_cut (cut_creator_t, const std::string & cut_id_);
00060
00062 void dump_cuts (std::ostream & out_ = std::clog);
00063
00064 };
00065
00066 typedef boost::scoped_ptr<cut_db> scoped_cut_db_t;
00067
00068 private:
00069
00070 static scoped_cut_db_t g__cut_db;
00071
00072 public:
00073
00075 static cut_db & get_cut_db ();
00076
00077
00078
00079 protected:
00080
00081 bool __applyable;
00082 event_t * __ana_event;
00083
00084 public:
00085
00087 bool is_applyable () const;
00088
00090 void set_applyable (bool applyable_ = true);
00091
00093 i_ana_event_cut ();
00094
00096 virtual ~i_ana_event_cut ();
00097
00099 void set_ana_event (event_t & ana_event_);
00100
00102 virtual bool accept () = 0;
00103
00105 bool Accept ();
00106
00108 void SetUserData (void * ana_event_ptr_);
00109
00111 virtual std::string cut_id () const = 0;
00112
00114 virtual cut_creator_t cut_creator () const = 0;
00115
00116 private:
00117
00119 virtual void __prepare_cut();
00120
00122 virtual void __finish_cut();
00123
00124 protected:
00125
00127 event_t & _event ();
00128
00129 protected:
00130
00141 template <class cut_t>
00142
00144 class creator_registration
00145 {
00146 cut_t __cut;
00147
00148 public:
00149
00151 creator_registration ()
00152 {
00153 bool devel = false;
00154
00155 using namespace std;
00156 string cut_id = __cut.cut_id ();
00157 if (devel) clog << "DEVEL: i_ana_event_cut::creator_registration::ctor: "
00158 << "cut_id='" << cut_id << "'"
00159 << endl;
00160
00161 cut_creator_t cut_creator = __cut.cut_creator ();
00162 if (devel) clog << "DEVEL: i_ana_event_cut::creator_registration::ctor: "
00163 << "cut_creator='" << hex << (void *) cut_creator << dec << "'"
00164 << endl;
00165
00166 try
00167 {
00168 bool test = false;
00169
00170 if (! test)
00171 {
00172 if (devel) clog << "DEVEL: i_ana_event_cut::creator_registration::ctor: "
00173 << "register_cut='" << cut_id << " @ "
00174 << hex << (void *) cut_creator << dec << "'"
00175 << endl;
00176 i_ana_event_cut::get_cut_db ().register_cut (cut_creator,
00177 cut_id);
00178 }
00179 }
00180 catch(exception & x)
00181 {
00182 cerr << "i_ana_event_cut::creator_registration::ctor: ERROR: "
00183 << x.what () << endl;
00184 }
00185 catch(...)
00186 {
00187 cerr << "i_ana_event_cut::creator_registration::ctor: ERROR: "
00188 << "unexpected!" << endl;
00189 }
00190 }
00191 };
00192
00193 };
00194
00195 }
00196
00197 #endif // __nemo3__i_ana_event_cut_h
00198
00199