All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
include/N3AnaBase/event/gg_hit.h
00001 #ifndef __N3AnaBase__gg_hit_h
00002 #define __N3AnaBase__gg_hit_h 1
00003 
00004 #include <stdexcept>
00005 #include <iostream>
00006 #include <sstream>
00007 #include <string>
00008 #include <cmath>
00009 #include <limits>
00010 
00011 #include <datatools/serialization/serialization.h>
00012 #include <datatools/utils/i_tree_dump.h>
00013 #include <datatools/utils/i_clear.h>
00014 #include <datatools/utils/i_propinit.h>
00015 #include <datatools/utils/properties.h>
00016 
00017 #include <geomtools/utils.h>
00018 
00019 #include <N3GeomDef/N3GeigerGeom.h>
00020 #include <N3Event/N3StdTrackedEvent.h>
00021 
00022 #include <N3AnaBase/event/event_utils.h>
00023 
00024 namespace nemo3 {
00025   
00027   template<class Archive>
00028   void serialize (Archive & ar_, 
00029                   nemo3::gg_hit_id & id_, 
00030                   const unsigned int version_)
00031   {
00032     ar_ & boost::serialization::make_nvp ("sector", id_.fSector);
00033     ar_ & boost::serialization::make_nvp ("side",   id_.fIo);
00034     ar_ & boost::serialization::make_nvp ("plane",  id_.fAbcg);
00035     ar_ & boost::serialization::make_nvp ("cell",   id_.fNcell);
00036   }
00050 
00051   class gg_hit : 
00052     public datatools::utils::i_tree_dumpable,
00053     public datatools::utils::i_clear,
00054     public datatools::serialization::i_serializable  
00055   {
00056   public:
00057     static const int    INVALID_NUMBER = -1;
00058     static const double INVALID_Z_VALUE;
00059     static const double INVALID_POS_VALUE;
00060     static const double MISSING_BOTH_Z;
00061     static const double MISSING_BOTH_SIGMA_Z;
00062     static const std::string NEMOS_STATUS_LABEL;
00063     static const std::string MISSING_HIT_LABEL;
00064     static const int32_t MISSING_TOP_BOTTOM = 0;
00065     static const double CELL_RADIUS;
00066     // see also GeigerHitCalibData::kCELL_RADIUS (cm)
00067 
00068   private: 
00069 
00070     int32_t                      __number;
00071     gg_hit_id                    __id;
00072     datatools::utils::properties __properties;
00073     int32_t                      __fast_tdc;
00074     int32_t                      __slow_tdc;
00075     int32_t                      __time_bottom;
00076     int32_t                      __time_top;
00077     bool                         __off;
00078     bool                         __noisy;
00079     bool                         __delayed;
00080     bool                         __hot;
00081     double                       __x;       // cm
00082     double                       __y;       // cm
00083     double                       __z;       // cm
00084     double                       __sigma_z; // cm
00085     double                       __r;       // cm
00086     double                       __sigma_r; // cm
00087 
00088   public: 
00089 
00091     geomtools::vector_3d get_position () const
00092     {
00093       return geomtools::vector_3d (__x, __y, __z);
00094     }
00095 
00097     int get_sector () const
00098     {
00099       return __id.get_sector ();
00100     }
00101 
00103     int get_side () const
00104     {
00105       return __id.get_side ();
00106     }
00107 
00109     int get_plane () const
00110     {
00111       return __id.get_plane ();
00112     }
00113 
00115     int get_cell () const
00116     {
00117       return __id.get_cell ();
00118     }
00119 
00121     bool is_normal () const;
00122 
00124     bool is_off () const;
00125     
00127     bool is_on () const;
00128     
00130     bool is_hot () const;
00131     
00133     bool is_noisy () const;
00134     
00136     bool is_delayed () const;
00137 
00139     bool is_prompt () const;
00140 
00142     bool is_missing_bottom () const;
00143 
00145     bool is_missing_top () const;
00146 
00148     bool is_missing_both () const;
00149 
00151     bool is_missing_none () const;
00152 
00154     void set_off (bool off_ = true)
00155     {
00156       __off = off_;
00157     }
00158 
00160     void set_hot (bool hot_ = true)
00161     {
00162       __hot = hot_;
00163     }
00164 
00166     void set_noisy (bool noisy_ = true)
00167     {
00168       __noisy = noisy_;
00169     }
00170 
00172     void set_delayed (bool delayed_ = true)
00173     {
00174       __delayed = delayed_;
00175     }
00176 
00178     void set_missing_top ();
00179 
00181     void set_missing_bottom ();
00182 
00184     int32_t get_number () const;
00185 
00187     void set_number (int32_t);
00188 
00190     const nemo3::gg_hit_id & get_id () const;
00191 
00193     const nemo3::gg_hit_id & get_id_const () const
00194     {
00195       return get_id ();
00196     }
00197 
00199     nemo3::gg_hit_id & get_id ();
00200 
00202     void set_id (const gg_hit_id &);
00203     
00205     const datatools::utils::properties & properties () const;
00206 
00208     const datatools::utils::properties & get_properties_const () const
00209     {
00210       return properties ( );
00211     }
00212 
00214     const datatools::utils::properties & get_properties_ro () const
00215     {
00216       return properties ( );
00217     }
00218 
00220     datatools::utils::properties & properties ();
00221 
00223     datatools::utils::properties & get_properties ()
00224     {
00225       return properties ( );
00226     }
00227 
00229     datatools::utils::properties & get_properties_rw ()
00230     {
00231       return properties ( );
00232     }
00233 
00235     void set_properties (const datatools::utils::properties &);
00236 
00238     int32_t get_fast_tdc () const;
00239 
00241     void set_fast_tdc (int32_t);
00242 
00244     int32_t get_slow_tdc () const;
00245 
00247     void set_slow_tdc (int32_t);
00248 
00250     int32_t get_time_bottom () const;
00251 
00253     void set_time_bottom (int32_t);
00254 
00256     int32_t get_time_top () const;
00257 
00259     void set_time_top (int32_t);
00260     
00262     double get_x () const;
00263 
00265     void set_x (double);
00266 
00268     double get_y () const;
00269 
00271     void set_y (double);
00272 
00274     double get_z () const;
00275 
00277     void set_z (double);
00278 
00280     bool has_valid_z () const;
00281 
00283     bool has_valid_r () const;
00284 
00286     void set_z_sigma_z (double z_, double sigma_z_);
00287 
00289     double get_sigma_z () const;
00290 
00292     void set_sigma_z (double);
00293 
00295     double get_r () const;
00296 
00298     void set_r (double);
00299 
00301     double get_sigma_r () const;
00302 
00304     void set_sigma_r (double);
00305 
00307     void set_r_sigma_r (double r_, double sigma_r_);
00308 
00310     bool is_z_valid () const;
00311     
00313     bool is_r_valid () const;
00314 
00316     bool is_sigma_z_valid () const;
00317     
00319     bool is_sigma_r_valid () const;
00320 
00322     static void make_missing_hit (gg_hit &, 
00323                                   int number_,
00324                                   const nemo3::gg_hit_id & id_,
00325                                   bool delayed_,
00326                                   double r_,
00327                                   double r_err_,
00328                                   double z_,
00329                                   double z_err_);
00330 
00332     void make_missing (int number_,
00333                        const nemo3::gg_hit_id & id_,
00334                        bool delayed_,
00335                        double r_,
00336                        double r_err_,
00337                        double z_,
00338                        double z_err_);
00339 
00340   public:
00341     
00343     gg_hit ();
00344 
00346     virtual ~gg_hit ();
00347   
00348   public: 
00349     
00351     virtual void clear ();
00352     
00354     virtual void tree_dump (std::ostream & out_         = std::clog, 
00355                             const std::string & title_  = "",
00356                             const std::string & indent_ = "",
00357                             bool inherit_               = false) const;
00358     
00360     void dump () const
00361     {
00362       tree_dump (std::clog, "gg_hit", "" , false);
00363     }
00364 
00366     static const std::string SERIAL_TAG;
00367 
00369     virtual const std::string & get_serial_tag () const;
00370     
00371   private:
00372 
00374     friend class boost::serialization::access;
00375     
00377     template<class Archive>
00378     void serialize (Archive            & ar_, 
00379                     const unsigned int version_) 
00380     {
00381       ar_ & boost::serialization::make_nvp ("number",       __number);
00382       ar_ & boost::serialization::make_nvp ("id",           __id);
00383       ar_ & boost::serialization::make_nvp ("properties",   __properties);
00384       ar_ & boost::serialization::make_nvp ("fast_tdc",     __fast_tdc);
00385       ar_ & boost::serialization::make_nvp ("slow_tdc",     __slow_tdc);
00386       ar_ & boost::serialization::make_nvp ("time_bottom",  __time_bottom);
00387       ar_ & boost::serialization::make_nvp ("time_top",     __time_top);
00388       ar_ & boost::serialization::make_nvp ("off",          __off);
00389       ar_ & boost::serialization::make_nvp ("noisy",        __noisy);
00390       ar_ & boost::serialization::make_nvp ("delayed",      __delayed);
00391       ar_ & boost::serialization::make_nvp ("hot",          __hot);
00392       ar_ & boost::serialization::make_nvp ("x",            __x);
00393       ar_ & boost::serialization::make_nvp ("y",            __y);
00394       ar_ & boost::serialization::make_nvp ("z",            __z);
00395       ar_ & boost::serialization::make_nvp ("sigma_z",      __sigma_z);
00396       ar_ & boost::serialization::make_nvp ("r",            __r);
00397       ar_ & boost::serialization::make_nvp ("sigma_r",      __sigma_r);
00398     }
00399     
00400   };
00401 
00403   class gg_hit_has_id 
00404     : public std::unary_function<gg_hit, bool>
00405   {
00406     gg_hit_id __id;
00407   public:
00408     explicit gg_hit_has_id (const gg_hit_id & id_)
00409     {
00410       __id = id_;
00411     }
00412     
00413     bool operator () (const gg_hit & gg_hit_) const
00414     {
00415       return (__id == gg_hit_.get_id ());
00416     }
00417   };
00418 
00420   class gg_hit_has_number 
00421     : public std::unary_function<gg_hit, bool>
00422   {
00423     int __number;
00424   public:
00425     explicit gg_hit_has_number (int number_)
00426     {
00427       __number = number_;
00428     }
00429     
00430     bool operator () (const gg_hit & gg_hit_) const
00431     {
00432       return (__number == gg_hit_.get_number ());
00433     }
00434   };
00435 
00436 } // end of namespace nemo3
00437 
00438 #endif // __N3AnaBase__gg_hit_h
00439 
00440 // end of gg_hit.h