41 pedestals = new_pedestals;
42 time_offsets = new_t0s;
43 block_qualities = new_qualities;
44 ADC_Offsets = ADC_offsets;
54 CHECK_FADC_ERRORS =
true;
55 gPARMS->SetDefaultParameter(
"FCAL:CHECK_FADC_ERRORS", CHECK_FADC_ERRORS,
"Set to 1 to reject hits with fADC250 errors, ser to 0 to keep these hits");
66 static pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER;
67 static set<int> runs_announced;
68 pthread_mutex_lock(&print_mutex);
69 bool print_messages =
false;
70 if(runs_announced.find(runnumber) == runs_announced.end()){
71 print_messages =
true;
72 runs_announced.insert(runnumber);
74 pthread_mutex_unlock(&print_mutex);
77 vector<const DFCALGeometry*> fcalGeomVect;
78 eventLoop->Get( fcalGeomVect );
79 if (fcalGeomVect.size() < 1)
80 return OBJECT_NOT_AVAILABLE;
84 vector< double > raw_gains;
85 vector< double > raw_pedestals;
86 vector< double > raw_time_offsets;
87 vector< double > raw_block_qualities;
88 vector< double > raw_ADCoffsets;
90 if(print_messages) jout <<
"In DFCALHit_factory, loading constants..." << endl;
93 map<string,double> scale_factors;
94 if (eventLoop->GetCalib(
"/FCAL/digi_scales", scale_factors))
95 jout <<
"Error loading /FCAL/digi_scales !" << endl;
96 if (scale_factors.find(
"FCAL_ADC_ASCALE") != scale_factors.end())
97 a_scale = scale_factors[
"FCAL_ADC_ASCALE"];
99 jerr <<
"Unable to get FCAL_ADC_ASCALE from /FCAL/digi_scales !" << endl;
100 if (scale_factors.find(
"FCAL_ADC_TSCALE") != scale_factors.end())
101 t_scale = scale_factors[
"FCAL_ADC_TSCALE"];
103 jerr <<
"Unable to get FCAL_ADC_TSCALE from /FCAL/digi_scales !" << endl;
106 map<string,double> base_time_offset;
107 if (eventLoop->GetCalib(
"/FCAL/base_time_offset",base_time_offset))
108 jout <<
"Error loading /FCAL/base_time_offset !" << endl;
109 if (base_time_offset.find(
"FCAL_BASE_TIME_OFFSET") != base_time_offset.end())
110 t_base = base_time_offset[
"FCAL_BASE_TIME_OFFSET"];
112 jerr <<
"Unable to get FCAL_BASE_TIME_OFFSET from /FCAL/base_time_offset !" << endl;
115 if (eventLoop->GetCalib(
"/FCAL/gains", raw_gains))
116 jout <<
"Error loading /FCAL/gains !" << endl;
117 if (eventLoop->GetCalib(
"/FCAL/pedestals", raw_pedestals))
118 jout <<
"Error loading /FCAL/pedestals !" << endl;
119 if (eventLoop->GetCalib(
"/FCAL/timing_offsets", raw_time_offsets))
120 jout <<
"Error loading /FCAL/timing_offsets !" << endl;
121 if (eventLoop->GetCalib(
"/FCAL/block_quality", raw_block_qualities))
122 jout <<
"Error loading /FCAL/block_quality !" << endl;
123 if (eventLoop->GetCalib(
"/FCAL/ADC_Offsets", raw_ADCoffsets))
124 jout <<
"Error loading /FCAL/ADC_Offsets !" << endl;
126 FillCalibTable(gains, raw_gains, fcalGeom);
127 FillCalibTable(pedestals, raw_pedestals, fcalGeom);
128 FillCalibTable(time_offsets, raw_time_offsets, fcalGeom);
129 FillCalibTable(block_qualities, raw_block_qualities, fcalGeom);
130 FillCalibTable(ADC_Offsets, raw_ADCoffsets, fcalGeom);
151 vector<const DFCALGeometry*> fcalGeomVect;
152 eventLoop->Get( fcalGeomVect );
153 if (fcalGeomVect.size() < 1)
154 return OBJECT_NOT_AVAILABLE;
158 loop->GetSingle(locTTabUtilities);
160 vector<const DFCALDigiHit*> digihits;
162 for (
unsigned int i=0; i < digihits.size(); i++) {
172 sprintf(str,
"DFCALHit corresponds to inactive channel! "
175 throw JException(str);
181 if ( (quality==BAD) || (quality==NOISY) )
continue;
198 if(nsamples_pedestal == 0) {
199 jerr <<
"DFCALDigiHit with nsamples_pedestal == 0 ! Event = " << eventnumber << endl;
206 pedestal = (double)digihit->
pedestal/nsamples_pedestal;
214 double integratedPedestal = pedestal * nsamples_integral;
224 hit->
E = a_scale * gains[hit->
row][hit->
column] * (A - integratedPedestal);
235 hit->
intOverPeak = ( A - integratedPedestal ) / pulse_amplitude;
238 if( ( hit->
E > 0 ) &&
240 hit->AddAssociatedObject(digihit);
241 _data.push_back(hit);
270 const vector<double> &raw_table,
278 sprintf(str,
"FCAL geometry is wrong size! channels=%d (should be %d)",
280 throw JException(str);
284 if ( fcalGeom.
numActiveBlocks() !=
static_cast<int>(raw_table.size()) ) {
285 sprintf(str,
"FCAL constant table is wrong size! channels=%d (should be %d)",
287 throw JException(str);
290 for (
int channel=0; channel < static_cast<int>(raw_table.size()); channel++)
296 int row = fcalGeom.
row(channel);
297 int col = fcalGeom.
column(channel);
302 sprintf(str,
"Loading FCAL constant for inactive channel! "
303 "row=%d, col=%d", row, col);
304 throw JException(str);
307 table[row][col] = raw_table[channel];
317 const int in_column)
const
322 sprintf(str,
"Bad row # requested in DFCALHit_factory::GetConstant()!"
325 throw JException(str);
328 sprintf(str,
"Bad column # requested in DFCALHit_factory::GetConstant()!"
331 throw JException(str);
334 return the_table[in_row][in_column];
343 sprintf(str,
"Bad row # requested in DFCALHit_factory::GetConstant()!"
344 " requested=%d , should be %ud",
347 throw JException(str);
350 sprintf(str,
"Bad column # requested in DFCALHit_factory::GetConstant()!"
351 " requested=%d , should be %ud",
354 throw JException(str);
357 return the_table[in_digihit->
row][in_digihit->
column];
366 sprintf(str,
"Bad row # requested in DFCALHit_factory::GetConstant()! "
369 throw JException(str);
372 sprintf(str,
"Bad column # requested in DFCALHit_factory::GetConstant()!"
373 " requested=%d , should be %ud",
376 throw JException(str);
379 return the_table[in_hit->
row][in_hit->
column];
uint32_t QF
Quality Factor from FPGA algorithms.
jerror_t fini(void)
Called after last event of last event source has been processed.
vector< vector< double > > fcal_digi_constants_t
const double GetConstant(const fcal_digi_constants_t &the_table, const int in_row, const int in_column) const
bool CheckFADC250_NoErrors(uint32_t QF) const
uint32_t pulse_peak
maximum sample in pulse
uint32_t nsamples_integral
number of samples used in integral
sprintf(text,"Post KinFit Cut")
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
DVector2 positionOnFace(int row, int column) const
uint32_t pedestal
pedestal info used by FPGA (if any)
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
uint32_t nsamples_pedestal
number of samples used in pedestal
int column(int channel) const
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
bool CheckFADC250_PedestalOK(uint32_t QF) const
void FillCalibTable(fcal_digi_constants_t &table, const vector< double > &raw_table, const DFCALGeometry &fcalGeom)
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
static TH1I * pedestal[nChan]
jerror_t init(void)
Called once at program start.2.
int row(int channel) const
bool isBlockActive(int row, int column) const
int numActiveBlocks() const