Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DBCALHit_factory.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DBCALHit_factory.h
4 // Created: Tue Aug 6 09:26:13 EDT 2013
5 // Creator: davidl (on Darwin harriet.jlab.org 11.4.2 i386)
6 //
7 
8 #ifndef _DBCALHit_factory_
9 #define _DBCALHit_factory_
10 
11 #include <vector>
12 #include <map>
13 #include <utility>
14 using namespace std;
15 
16 #include <JANA/JFactory.h>
17 #include "TTAB/DTranslationTable.h"
18 #include "DBCALHit.h"
19 
20 // store up/down-stream values for each detector cell
21 typedef pair<double,double> cell_calib_t;
22 typedef vector<cell_calib_t> bcal_digi_constants_t;
23 
24 class DBCALHit_factory:public jana::JFactory<DBCALHit>{
25  public:
27  PRINTCALIBRATION = false;
28  VERBOSE = 0;
29  CHECK_FADC_ERRORS = false;
30  if(gPARMS){
31  gPARMS->SetDefaultParameter("BCALHIT:PRINTCALIBRATION", PRINTCALIBRATION, "Print the calibration parameters.");
32  gPARMS->SetDefaultParameter("BCALHIT:VERBOSE", VERBOSE, "Set level of verbosity.");
33  //gPARMS->SetDefaultParameter("BCAL:CHECK_FADC_ERRORS", CHECK_FADC_ERRORS, "Set to 1 to reject hits with fADC250 errors, ser to 0 to keep these hits");
34  }
35  };
37 
38  bool PRINTCALIBRATION;
39  int VERBOSE;
40 
41  // shortcut geometry factors
42  // these should really be taken from
43  // DBCALGeometry/DGeometry objects
44  static const int BCAL_NUM_MODULES = 48;
45  static const int BCAL_NUM_LAYERS = 4;
46  static const int BCAL_NUM_ENDS = 2;
47  static const int BCAL_NUM_SECTORS = 4;
48  static const int BCAL_MAX_CHANNELS = 1536;
49 
50  // overall scale factors
51  double a_scale;
52  double t_scale;
53  double t_base;
54 
55  // constants tables
61 
62  const int GetCalibIndex( int module, int layer, int sector ) const {
63  return BCAL_NUM_LAYERS*BCAL_NUM_SECTORS*(module-1) + BCAL_NUM_SECTORS*(layer-1) + (sector-1);
64  }
65 
66  const double GetConstant( const bcal_digi_constants_t &the_table,
67  const int in_module, const int in_layer,
68  const int in_sector, const int in_end) const;
69  const double GetConstant( const bcal_digi_constants_t &the_table,
70  const DBCALDigiHit *the_digihit) const;
71  const double GetConstant( const bcal_digi_constants_t &the_table,
72  const DBCALHit *the_hit) const;
73  //const double GetConstant( const bcal_digi_constants_t &the_table,
74  // const DTranslationTable *ttab,
75  // const int in_rocid, const int in_slot, const int in_channel) const;
76 
77  private:
78  jerror_t init(void); ///< Called once at program start.
79  jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber); ///< Called everytime a new run number is detected.
80  jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber); ///< Called every event.
81  jerror_t erun(void); ///< Called everytime run number changes, provided brun has been called.
82  jerror_t fini(void); ///< Called after last event of last event source has been processed.
83 
84  void FillCalibTable( bcal_digi_constants_t &table,
85  const vector<double> &raw_table);
86  void FillCalibTableShort( bcal_digi_constants_t &table,
87  const vector<double> &raw_table);
88 
89  bool CHECK_FADC_ERRORS, CORRECT_FADC_SATURATION,CORRECT_SIPM_SATURATION;
90  double fADC_MinIntegral_Saturation[BCAL_NUM_ENDS][BCAL_NUM_LAYERS];
91  double fADC_Saturation_Linear[BCAL_NUM_ENDS][BCAL_NUM_LAYERS];
92  double fADC_Saturation_Quadratic[BCAL_NUM_ENDS][BCAL_NUM_LAYERS];
93  double integral_to_peak[BCAL_NUM_ENDS][BCAL_NUM_LAYERS]; // ration of pulse integral to peak value (integral counts)
94  double sipm_npixels[BCAL_NUM_ENDS][BCAL_NUM_LAYERS]; // number of pixels per sensor(s)
95  double pixel_per_count[BCAL_NUM_ENDS][BCAL_NUM_LAYERS]; // conversion between counts and pixels
96 };
97 
98 #endif // _DBCALHit_factory_
99 
bcal_digi_constants_t ADC_timing_offsets
Int_t layer
const int GetCalibIndex(int module, int layer, int sector) const
const bool VERBOSE
bcal_digi_constants_t tdiff_u_d
bcal_digi_constants_t channel_global_offset
pair< double, double > cell_calib_t
bcal_digi_constants_t pedestals
bcal_digi_constants_t gains
vector< cell_calib_t > bcal_digi_constants_t