00001 #ifndef __N3AnaBase__tof_tools_h
00002 #define __N3AnaBase__tof_tools_h 1
00003
00004 #include <N3AnaBase/event/ana_event.h>
00005 #include <cmath>
00006 #include <string>
00007 #include <map>
00008 #include <sstream>
00009
00010 #include <N3GeomDef/N3Vec3.h>
00011 #include <N3GeomDef/N3SourceGeom.h>
00012 #include <N3GeomDef/N3ScinGeom.h>
00013
00014
00015 #include <gsl/gsl_cdf.h>
00016
00017 namespace nemo3 {
00018
00019 using namespace std;
00020
00037
00038 class tof_tools
00039 {
00040
00041 private :
00042 static const double kC;
00043 static const double kMe;
00044 static const double kSig;
00045 static double kTauSc;
00046 static double kTauSc_g;
00047 static double kTauEl;
00048 static double kVg;
00049 static double fwhm_trans;
00050 public :
00052 tof_tools ();
00054 tof_tools ( bool debug_, bool use_energy_loss_ = false, bool timeerr_ = false, bool fluct_ = false );
00056 ~tof_tools ();
00057
00058 void init_from (const datatools::utils::properties &);
00059
00060 void set_debug ( bool debug_ );
00061 void set_run_number ( int run_number_, std::string runtype_ = "" );
00062 void set_ECorr ( bool energy_loss_ );
00063 void set_TimeErr ( bool timeerr_ );
00064 void set_LTFluct ( bool fluct_ );
00065 void set_simulation ( bool simu_);
00066 void set_nodb4simu ( bool nodb_);
00067 void set_tau_sc ( double ts_ ) {kTauSc=ts_;}
00068 void set_tau_sc_g ( double ts_ ) {kTauSc_g=ts_;}
00069 void set_tau_el ( double ts_ ) {kTauEl=ts_;}
00070 void set_Vg ( double vg_ ) {kVg=vg_;}
00071 void set_run_type ( std::string rt_ ) {__run_type=rt_;}
00072 bool get_simulation ();
00073 string get_run_type () {return __run_type;}
00074
00075 private:
00076 float get_tse (int sector_, int iobt_, int fcll_, int block_);
00077 float get_ltce (int sector_, int iobt_, int fcll_, int block_);
00078 float get_ltfluct (int sector_, int iobt_, int fcll_, int block_);
00079
00080
00081 private :
00082 double Beta ( double ke_, double mass_ );
00083
00085 double T_th ( double ke_, double mass_, double trlen_ );
00086
00089 double ECorrTracking ( double energy_, double trlen_, scin_hit_id & id_ );
00090
00122 double SigmaE ( scin_hit_id & id_, double ke_ );
00123
00130 double SigmaTrlen ( double mass_ );
00131 double SigmaT ( scin_hit_id & id_, double ke_, bool gamma_=false );
00132
00139 double FWHM ( scin_hit_id & id_ );
00140 double g_trlen ( geomtools::vector_3d & vertex_, scin_hit_id & id_ );
00141 double g_trlen ( scin_hit_id& id1_, scin_hit_id& id2_);
00142
00143 public :
00144 bool get_dt (const track & track1_,const track & track2_,
00145 double & dt_int_, double & dt_ext_);
00146
00150 bool get_dt (const track & track1_,const scin_hit & scin_hit2_,
00151 double & dt_int_, double & dt_ext_, bool change_elec_energy_=false,
00152 double elec_energy_=0, double elec_length_=0);
00153
00157 bool get_dt (const scin_hit & scin_hit1_,const scin_hit & scin_hit2_,
00158 double & dt_);
00159
00164 bool get_chi2 (const track & track1_,const track & track2_,
00165 double & internal_chi2_, double & external_chi2_,
00166 bool keep_dt_=false);
00167
00187 bool get_chi2 (const track & track_,const scin_hit & scin_hit_,
00188 double & internal_chi2_, double & external_chi2_,
00189 bool keep_dt_=false, bool change_elec_energy_=false,
00190 double elec_energy_=0, double elec_length_=0);
00191
00211 bool get_chi2 (const scin_hit & scin_hit1_,const scin_hit & scin_hit2_,
00212 double &chi2_,
00213 bool keep_dt_=false);
00214
00234 bool get_chi2_1e (const scin_hit & scin_hit1_,const scin_hit & scin_hit2_,
00235 double & internal_chi2_, double & internal_prob_);
00236
00251 bool get_chi2_2e_1g (const track & track1_, const track & track2_,
00252 const scin_hit & scin_hit3_, const bool switch_,
00253 double & internal_chi2_, double & internal_prob_);
00254
00270 bool get_chi2_2e_2g (const track & track1_, const track & track2_,
00271 const scin_hit & scin_hit3_, const scin_hit & scin_hit4_,
00272 const bool switch_, double & internal_chi2_, double & internal_prob_);
00273
00289 bool get_chi2_2g (const track & track_, const scin_hit & scin_hit2_,
00290 const scin_hit & scin_hit3_, const bool switch_,
00291 double & internal_chi2_, double & internal_prob_,
00292 bool change_elec_energy_=false, double elec_energy_=0,
00293 double elec_length_=0);
00294
00313 bool get_chi2_3g (const track & track_, const scin_hit & scin_hit2_,
00314 const scin_hit & scin_hit3_, const scin_hit & scin_hit4_,
00315 const bool switch_, double & internal_chi2_, double & internal_prob_,
00316 bool change_elec_energy_=false, double elec_energy_=0,
00317 double elec_length_=0);
00318
00337 static void get_proba (double internal_chi2_, double external_chi2_,
00338 double & internal_prob_, double & external_prob_,
00339 unsigned int freedom_=1);
00340
00345 void set_vera (bool vera_){__vera_method=vera_;}
00346
00347 private:
00348 bool __debug;
00349 bool __use_energy_loss;
00350 bool __use_ltfluct;
00351 bool __use_time_err;
00352 bool __simulation;
00353 bool __vera_method;
00354 bool __nodb4simu;
00355 int __run_number;
00356 double __t1;
00357 double __t2;
00358 double __t_th1_int;
00359 double __t_th2_int;
00360 double __t_th1_ext;
00361 double __t_th2_ext;
00362 double __dt_int;
00363 double __dt_ext;
00364 double __dt;
00365 double __e1;
00366 double __e2;
00367 double __e_last;
00368 string __run_type;
00369
00370
00371 };
00372 }
00373
00374 #endif // __N3AnaBase__tof_tools_h
00375
00376