00001 #ifndef __N3AnaBase__scin_hit_h
00002 #define __N3AnaBase__scin_hit_h 1
00003
00004 #include <stdexcept>
00005 #include <iostream>
00006 #include <sstream>
00007 #include <string>
00008
00009 #include <boost/cstdint.hpp>
00010
00011
00012 #include <boost/serialization/nvp.hpp>
00013 #include <boost/serialization/access.hpp>
00014 #include <boost/serialization/version.hpp>
00015 #include <datatools/serialization/i_serializable.h>
00016
00017 #include <datatools/utils/i_tree_dump.h>
00018 #include <datatools/utils/i_clear.h>
00019 #include <datatools/utils/i_propinit.h>
00020 #include <datatools/utils/properties.h>
00021
00022 #include <geomtools/utils.h>
00023
00024 #include <N3GeomDef/N3ScinHitId.h>
00025
00026 #include <N3AnaBase/event/event_utils.h>
00027
00028 namespace nemo3 {
00029
00030 template<class Archive>
00031 void serialize (Archive & ar_,
00032 nemo3::scin_hit_id & id_,
00033 const unsigned int version_)
00034 {
00035 ar_ & boost::serialization::make_nvp ("sector", id_.fSector);
00036 ar_ & boost::serialization::make_nvp ("iobt", id_.fIobt );
00037 ar_ & boost::serialization::make_nvp ("fcll", id_.fFcll );
00038 ar_ & boost::serialization::make_nvp ("block", id_.fBlock );
00039 }
00040
00055
00056 class scin_hit :
00057 public datatools::utils::i_tree_dumpable,
00058 public datatools::utils::i_clear,
00059 public datatools::serialization::i_serializable
00060 {
00061 public:
00062 static const int INVALID_NUMBER = -1;
00063
00064 private:
00065
00066 int32_t __number;
00067 nemo3::scin_hit_id __id;
00068 datatools::utils::properties __properties;
00069 int32_t __adc;
00070 int32_t __tdc;
00071 bool __high_threshold;
00072 bool __off;
00073 bool __bad;
00074 bool __hot;
00075 bool __associated;
00076 double __energy;
00077 double __sigma_energy;
00078 double __time;
00079 double __sigma_time;
00080
00081 std::list<ScinHitId> __all_pmts;
00082
00083
00084 public:
00085
00087 void init_PMT_table ();
00088
00090 int get_PMT_number ();
00091
00092
00093 public:
00094
00096 int get_sector () const
00097 {
00098 return __id.get_sector ();
00099 }
00100
00102 int get_iobt () const
00103 {
00104 return __id.get_iobt ();
00105 }
00106
00108 int get_fcll () const
00109 {
00110 return __id.get_fcll ();
00111 }
00112
00114 int get_block () const
00115 {
00116 return __id.get_block ();
00117 }
00118
00120 bool is_off () const
00121 {
00122 return __off;
00123 }
00124
00126 bool is_hot () const
00127 {
00128 return __hot;
00129 }
00130
00132 bool is_on () const
00133 {
00134 return ! is_off ();
00135 }
00136
00138 bool is_bad () const
00139 {
00140 return __bad;
00141 }
00142
00144 bool is_good () const
00145 {
00146 return ! is_bad ();
00147 }
00148
00150 void set_off (bool off_ = true)
00151 {
00152 __off = off_;
00153 }
00154
00156 void set_hot (bool hot_ = true)
00157 {
00158 __hot = hot_;
00159 }
00160
00162 void set_bad (bool bad_ = true)
00163 {
00164 __bad = bad_;
00165 }
00166
00168 void set_associated (bool asso_)
00169 {
00170 __associated=asso_;
00171 }
00172
00174 int32_t get_number () const;
00175
00177 void set_number (int32_t);
00178
00180 void set_id (const nemo3::scin_hit_id &);
00181
00183 const nemo3::scin_hit_id & get_id () const;
00184
00186 const nemo3::scin_hit_id & get_id_const () const
00187 {
00188 return get_id ();
00189 }
00190
00192 const datatools::utils::properties & properties () const;
00193
00195 const datatools::utils::properties & get_properties_const () const
00196 {
00197 return properties ();
00198 }
00199
00201 const datatools::utils::properties & get_properties_ro () const
00202 {
00203 return properties ();
00204 }
00205
00207 datatools::utils::properties & properties ();
00208
00210 datatools::utils::properties & get_properties ()
00211 {
00212 return properties ();
00213 }
00214
00216 datatools::utils::properties & get_properties_rw ()
00217 {
00218 return properties ();
00219 }
00220
00222 int32_t get_adc () const;
00223
00225 void set_adc (const int32_t &);
00226
00228 int32_t get_tdc () const;
00229
00231 void set_tdc (const int32_t &);
00232
00234 bool is_high_threshold () const;
00235
00237 bool is_associated () const {return __associated;}
00238
00240 void set_high_threshold (bool);
00241
00243 double get_energy () const;
00244
00246 void set_energy (double);
00247
00249 double get_sigma_energy () const;
00250
00252 void set_sigma_energy (double);
00253
00255 double get_time () const;
00256
00258 void set_time (double);
00259
00261 double get_sigma_time () const;
00262
00264 void set_sigma_time (double);
00265
00266 public:
00267
00269 scin_hit ();
00270
00272 virtual ~scin_hit ();
00273
00274 public:
00275
00277 virtual void clear ();
00278
00280 virtual void tree_dump (std::ostream & out_ = std::cerr,
00281 const std::string & title_ = "",
00282 const std::string & indent_ = "",
00283 bool inherit_ = false) const;
00284
00286 void dump () const
00287 {
00288 tree_dump (std::clog, "scin_hit", "" , false);
00289 }
00290
00292 static const std::string SERIAL_TAG;
00293
00295 virtual const std::string & get_serial_tag () const;
00296
00297 private:
00298
00300 friend class boost::serialization::access;
00301
00303 template<class Archive>
00304 void serialize (Archive & ar_,
00305 const unsigned int version_)
00306 {
00307 ar_ & boost::serialization::make_nvp ("number", __number);
00308 ar_ & boost::serialization::make_nvp ("id", __id);
00309 ar_ & boost::serialization::make_nvp ("properties", __properties);
00310 ar_ & boost::serialization::make_nvp ("adc", __adc);
00311 ar_ & boost::serialization::make_nvp ("tdc", __tdc);
00312 ar_ & boost::serialization::make_nvp ("high_threshold", __high_threshold);
00313 ar_ & boost::serialization::make_nvp ("energy", __energy);
00314 ar_ & boost::serialization::make_nvp ("sigma_energy", __sigma_energy);
00315 ar_ & boost::serialization::make_nvp ("time", __time);
00316 ar_ & boost::serialization::make_nvp ("sigma_time", __sigma_time);
00317 ar_ & boost::serialization::make_nvp ("off", __off);
00318 ar_ & boost::serialization::make_nvp ("hot", __hot);
00319 ar_ & boost::serialization::make_nvp ("bad", __bad);
00320 if(version_ > 0)
00321 ar_ & boost::serialization::make_nvp ("associated", __associated);
00322 }
00323
00324 };
00325
00327 class scin_hit_has_number
00328 : public std::unary_function<scin_hit, bool>
00329 {
00330 int __number;
00331 public:
00332 explicit scin_hit_has_number (int number_)
00333 {
00334 __number = number_;
00335 }
00336
00337 bool operator () (const scin_hit & scin_hit_) const
00338 {
00339 return (__number == scin_hit_.get_number ());
00340 }
00341 };
00342
00343 }
00344
00345 BOOST_CLASS_VERSION(nemo3::scin_hit, 1)
00346 #endif // __N3AnaBase__scin_hit_h
00347
00348