Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DFDCHit_factory.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DFDCHit_factory.cc
4 // Created: Wed Aug 7 11:55:02 EDT 2013
5 // Creator: davidl (on Darwin harriet.jlab.org 11.4.2 i386)
6 //
7 
8 
9 #include <iostream>
10 #include <iomanip>
11 using namespace std;
12 
13 #include <FDC/DFDCGeometry.h>
14 #include <FDC/DFDCCathodeDigiHit.h>
15 #include <FDC/DFDCWireDigiHit.h>
16 #include "DFDCHit_factory.h"
17 #include <DAQ/Df125PulseIntegral.h>
18 #include <DAQ/Df125PulsePedestal.h>
19 #include <DAQ/Df125Config.h>
20 #include <DAQ/Df125FDCPulse.h>
21 using namespace jana;
22 
23 
24 //------------------
25 // init
26 //------------------
27 jerror_t DFDCHit_factory::init(void)
28 {
29  /// set the base conversion scales
30  a_scale = 2.4E4/1.3E5; // cathodes
31  t_scale = 8.0/10.0; // 8 ns/count and integer time is in 1/10th of sample
32  t_base = 0.; // ns
33  fadc_t_base = 0.; // ns
34 
35  return NOERROR;
36 }
37 
38 //------------------
39 // brun
40 //------------------
41 jerror_t DFDCHit_factory::brun(jana::JEventLoop *eventLoop, int32_t runnumber)
42 {
43  // Only print messages for one thread whenever run number change
44  static pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER;
45  static set<int> runs_announced;
46  pthread_mutex_lock(&print_mutex);
47  bool print_messages = false;
48  if(runs_announced.find(runnumber) == runs_announced.end()){
49  print_messages = true;
50  runs_announced.insert(runnumber);
51  }
52  pthread_mutex_unlock(&print_mutex);
53 
54  // reset constants tables
55  a_gains.clear();
56  a_pedestals.clear();
57  timing_offsets.clear();
58 
59  // now load them all
60  if(print_messages) jout << "In DFDCHit_factory, loading constants..." << endl;
61 
62  // load scale factors
63  map<string,double> scale_factors;
64  if(eventLoop->GetCalib("/FDC/digi_scales", scale_factors))
65  jout << "Error loading /FDC/digi_scales !" << endl;
66  if( scale_factors.find("FDC_ADC_ASCALE") != scale_factors.end() ) {
67  a_scale = scale_factors["FDC_ADC_ASCALE"];
68  } else {
69  jerr << "Unable to get FDC_ADC_ASCALE from /FDC/digi_scales !" << endl;
70  }
71  if( scale_factors.find("FDC_ADC_TSCALE") != scale_factors.end() ) {
72  t_scale = scale_factors["FDC_ADC_TSCALE"];
73  } else {
74  jerr << "Unable to get FDC_ADC_TSCALE from /FDC/digi_scales !" << endl;
75  }
76 
77  // load base time offset
78  map<string,double> base_time_offset;
79  if (eventLoop->GetCalib("/FDC/base_time_offset",base_time_offset))
80  jout << "Error loading /FDC/base_time_offset !" << endl;
81  if (base_time_offset.find("FDC_BASE_TIME_OFFSET") != base_time_offset.end())
82  fadc_t_base = base_time_offset["FDC_BASE_TIME_OFFSET"];
83  else
84  jerr << "Unable to get FDC_BASE_TIME_OFFSET from /FDC/base_time_offset !" << endl;
85  if (base_time_offset.find("FDC_TDC_BASE_TIME_OFFSET") != base_time_offset.end())
86  t_base = base_time_offset["FDC_TDC_BASE_TIME_OFFSET"];
87  else
88  jerr << "Unable to get FDC_TDC_BASE_TIME_OFFSET from /FDC/base_time_offset !" << endl;
89 
90 
91  // each FDC package has the same set of constants
92  LoadPackageCalibTables(eventLoop,"/FDC/package1");
93  LoadPackageCalibTables(eventLoop,"/FDC/package2");
94  LoadPackageCalibTables(eventLoop,"/FDC/package3");
95  LoadPackageCalibTables(eventLoop,"/FDC/package4");
96 
97  // Verify that the right number of layers were loaded
98  char str[256];
99  if(a_gains.size() != FDC_NUM_PLANES) {
100  sprintf(str, "Bad # of planes for FDC gains from CCDB! CCDB=%zu , should be %d",
101  a_gains.size(), FDC_NUM_PLANES);
102  cerr << str << endl;
103  throw JException(str);
104  }
105  if(a_pedestals.size() != FDC_NUM_PLANES) {
106  sprintf(str, "Bad # of planes for FDC pedestals from CCDB! CCDB=%zu , should be %d",
107  a_pedestals.size(), FDC_NUM_PLANES);
108  cerr << str << endl;
109  throw JException(str);
110  }
111  if(timing_offsets.size() != FDC_NUM_PLANES) {
112  sprintf(str, "Bad # of planes for FDC timing offsets from CCDB! CCDB=%zu , should be %d",
113  timing_offsets.size(), FDC_NUM_PLANES);
114  cerr << str << endl;
115  throw JException(str);
116  }
117 
118  return NOERROR;
119 }
120 
121 //------------------
122 // evnt
123 //------------------
124 jerror_t DFDCHit_factory::evnt(JEventLoop *loop, uint64_t eventnumber)
125 {
126  /// Generate DFDCHit object for each DFDCCathodeDigiHit and
127  /// each DFDCWireDigiHit object.
128  /// This is where the first set of calibration constants
129  /// is applied to convert from digitzed units into natural
130  /// units.
131  ///
132  /// Note that this code does NOT get called for simulated
133  /// data in HDDM format. The HDDM event source will copy
134  /// the precalibrated values directly into the _data vector.
135  char str[256];
136 
137  const DTTabUtilities* locTTabUtilities = NULL;
138  loop->GetSingle(locTTabUtilities);
139 
140  // Make hits out of all DFDCCathodeDigiHit hits
141  vector<const DFDCCathodeDigiHit*> cathodedigihits;
142  loop->Get(cathodedigihits);
143  for(unsigned int i=0; i<cathodedigihits.size(); i++){
144  const DFDCCathodeDigiHit *digihit = cathodedigihits[i];
145 
146  // The translation table has:
147  // ---------------------------------------------------
148  // package : 1-4
149  // chamber : 1-6
150  // view : 1(="U") or 3(="D")
151  // strip : 1-192
152  //
153  //
154  // The FDCHit class has 6 indexes which are derived
155  // from these and contain some redundancy. They are:
156  // ---------------------------------------------------
157  // layer : 1(V), 2(X), or 3(U)
158  // module : 1 through 8, 1 module = 3 detection layers
159  // element : wire or strip number
160  // plane : for cathodes only: u(3) or v(1) plane, u@+45,v@-45
161  // gPlane : 1 through 72
162  // gLayer : 1 through 24
163 
164  int layer=digihit->view;
165  int gLayer=digihit->chamber + 6*(digihit->package - 1);
166  int gPlane=layer + 3*(gLayer - 1);
167  // Make sure gPlane and stripare in valid range
168  if((gPlane < 1) || (gPlane > FDC_NUM_PLANES)) {
169  sprintf(str, "DFDCDigiHit plane out of range! gPlane=%d (should be 1-%d)", gPlane, FDC_NUM_PLANES);
170  throw JException(str);
171  }
172  if( (digihit->strip < 1) || (digihit->strip > STRIPS_PER_PLANE)) {
173  sprintf(str, "DFDCDigiHit straw out of range! strip=%d for plane=%d (should be 1-%d)", digihit->strip, gPlane, STRIPS_PER_PLANE);
174  throw JException(str);
175  }
176 
177  int plane_index=gPlane-1;
178  int strip_index=digihit->strip-1;
179 
180  // Apply calibration constants here
181  double T = (double)digihit->pulse_time;
182  //if (T<=0.) continue;
183 
184  // Default pedestal from CCDB
185  //double pedestal = a_pedestals[plane_index][strip_index];
186 
187  // Grab the pedestal from the digihit since this should be consistent between the old and new formats
188  int raw_ped = digihit->pedestal;
189  // int nsamples_integral;
190 
191  // There are a few values from the new data type that are critical for the interpretation of the data
192  //uint16_t IBIT = 0; // 2^{IBIT} Scale factor for integral
193  uint16_t ABIT = 0; // 2^{ABIT} Scale factor for amplitude
194  uint16_t PBIT = 0; // 2^{PBIT} Scale factor for pedestal
195  uint16_t NW = 0;
196  uint16_t IE = 0;
197 
198  // This is the place to make quality cuts on the data.
199  // Try to get the new data type, if that fails, try to get the old...
200  int pulse_peak = 0;
201  const Df125FDCPulse *FDCPulseObj = NULL;
202  digihit->GetSingle(FDCPulseObj);
203  if (FDCPulseObj != NULL){
204  // Cut on quality factor?
205  vector<const Df125Config*> configs;
206  digihit->Get(configs);
207 
208  // Set some constants to defaults until they appear correctly in the config words in the future
209  // The defaults are taken from Run 4607
210  if(!configs.empty()){
211  const Df125Config *config = configs[0];
212  //IBIT = config->IBIT == 0xffff ? 4 : config->IBIT;
213  ABIT = config->ABIT == 0xffff ? 3 : config->ABIT;
214  PBIT = config->PBIT == 0xffff ? 0 : config->PBIT;
215  NW = config->NW == 0xffff ? 80 : config->NW;
216  IE = config->IE == 0xffff ? 16 : config->IE;
217  }else{
218  static int Nwarnings = 0;
219  if(Nwarnings<10){
220  _DBG_ << "NO Df125Config object associated with Df125FDCPulse object!" << endl;
221  Nwarnings++;
222  if(Nwarnings==10) _DBG_ << " --- LAST WARNING!! ---" << endl;
223  }
224  }
225  if ((NW - (digihit->pulse_time / 10)) < IE){
226  // nsamples_integral = (NW - (digihit->pulse_time / 10));
227  }
228  else{
229  // nsamples_integral = IE;
230  }
231 
232  pulse_peak = FDCPulseObj->peak_amp << ABIT;
233  }
234  else{
235  // There is a slight difference between Mode 7 and 8 data
236  // The following condition signals an error state in the flash algorithm
237  // Do not make hits out of these
238  const Df125PulsePedestal* PPobj = NULL;
239  digihit->GetSingle(PPobj);
240  if (PPobj != NULL){
241  if (PPobj->pedestal == 0 || PPobj->pulse_peak == 0) continue;
242  if (PPobj->pulse_number == 1) continue; // Unintentionally had 2 pulses found in fall data (0-1 counting issue)
243  pulse_peak = PPobj->pulse_peak;
244  }
245 
246  const Df125PulseIntegral* PIobj = NULL;
247  digihit->GetSingle(PIobj);
248  if ( PPobj == NULL || PIobj == NULL) continue; // We don't want hits where ANY of the associated information is missing
249  }
250 
251  // Complete the pedestal subtracion here since we should know the correct number of samples.
252  int scaled_ped = raw_ped << PBIT;
253  //pedestal = double(scaled_ped * nsamples_integral);
254 
255  //double integral = double(digihit->pulse_integral << IBIT);
256  // Comment this line out temporarily until config words are behaving nicely
257  //if (A-pedestal<0.) continue;
258 
259  // ------The integral is no longer reported for FDC hits --- SJT 3/4/16
260  //double q = a_scale * a_gains[plane_index][strip_index] * (integral-pedestal);
261  double t = t_scale * T - timing_offsets[plane_index][strip_index]+fadc_t_base;
262 
263  DFDCHit *hit = new DFDCHit;
264  hit->layer = digihit->view;
265  hit->gLayer = gLayer;
266  hit->gPlane = gPlane;
267  hit->module = 1 + (gLayer-1)/3;
268  hit->element = digihit->strip;
269  hit->plane = digihit->view; // "plane" is apparently the same as "layer"
270  hit->r = DFDCGeometry::getWireR(hit);
271  hit->d = 0.0; // MC data only
272  hit->type = digihit->strip_type; // n.b. DEventSourceHDDM hardwires this as "1" for cathodes!
273  hit->itrack = -1; // MC data only
274  hit->ptype = 0;// MC data only
275  //hit->q = q;
276  hit->t = t;
277  unsigned int stripOffset=0;
278  if (digihit->strip_type == 3) stripOffset=9*12;
279  hit->pulse_height=a_gains[plane_index][strip_index+stripOffset]
280  *double(pulse_peak - scaled_ped);
281  hit->pulse_height_raw = double(pulse_peak - scaled_ped);
282  hit->q=a_scale*hit->pulse_height;
283 
284  //cerr << "FDC hitL plane = " << hit->gPlane << " element = " << hit->element << endl;
285 
286  hit->AddAssociatedObject(digihit);
287 
288  _data.push_back(hit);
289  }
290 
291  // Make hits out of all DFDCWireDigiHit hits
292  vector<const DFDCWireDigiHit*> wiredigihits;
293  loop->Get(wiredigihits);
294  for(unsigned int i=0; i<wiredigihits.size(); i++){
295  const DFDCWireDigiHit *digihit = wiredigihits[i];
296 
297  // The translation table has:
298  // ---------------------------------------------------
299  // package : 1-4
300  // chamber : 1-6
301  // wire : 1-96
302  //
303  //
304  // The FDCHit class has 6 indexes which are derived
305  // from these and contain some redundancy. They are:
306  // ---------------------------------------------------
307  // plane : 1(V), 2(X), or 3(U)
308  // layer : 1 (phi=0), 2 (phi=+60), 3 (phi=-60)
309  // module : 1 through 8, 1 module = 3 detection layers
310  // element : wire or strip number
311  // plane : for cathodes only: u(3) or v(1) plane, u@+45,v@-45
312  // gPlane : 1 through 72
313  // gLayer : 1 through 24
314 
315  DFDCHit *hit = new DFDCHit;
316  hit->gLayer = digihit->chamber + 6*(digihit->package - 1);
317  hit->module = 1 + (hit->gLayer-1)/3;
318  hit->layer = hit->gLayer - (hit->module-1)*3;
319  hit->plane = 2; // wire is always in "X" layer
320  hit->gPlane = hit->plane + 3*(hit->gLayer - 1);
321  hit->element = digihit->wire;
322  hit->r = DFDCGeometry::getWireR(hit);
323  hit->d = 0.0; // MC data only
324  hit->type = DFDCHit::AnodeWire; // n.b. DEventSourceHDDM hardwires this as "0" for anodes!
325  hit->itrack = -1; // MC data only
326  hit->ptype = 0; // MC data only
327 
328  // Make sure gPlane and wire are in valid range
329  if( (hit->gPlane < 1) || (hit->gPlane > FDC_NUM_PLANES)) {
330  sprintf(str, "DFDCDigiHit plane out of range! gPlane=%d (should be 1-%d)", hit->gPlane, FDC_NUM_PLANES);
331  throw JException(str);
332  }
333  if( (digihit->wire < 1) || (digihit->wire > WIRES_PER_PLANE)) {
334  sprintf(str, "DFDCDigiHit straw out of range! wire=%d for plane=%d (should be 1-%d)", digihit->wire, hit->gPlane, WIRES_PER_PLANE);
335  throw JException(str);
336  }
337 
338  // Apply calibration constants here
339  double T = locTTabUtilities->Convert_DigiTimeToNs_F1TDC(digihit) - timing_offsets[hit->gPlane-1][hit->element-1] + t_base;
340  hit->q = 0.0; // no charge measured for wires in FDC
341  hit->pulse_height=0.0;
342  hit->t = T;
343 
344  hit->AddAssociatedObject(digihit);
345 
346  _data.push_back(hit);
347  }
348 
349  return NOERROR;
350 }
351 
352 //------------------
353 // erun
354 //------------------
355 jerror_t DFDCHit_factory::erun(void)
356 {
357  return NOERROR;
358 }
359 
360 //------------------
361 // fini
362 //------------------
363 jerror_t DFDCHit_factory::fini(void)
364 {
365  return NOERROR;
366 }
367 
368 
369 //------------------
370 // LoadPackageCalibTables
371 //------------------
372 void DFDCHit_factory::LoadPackageCalibTables(jana::JEventLoop *eventLoop, string ccdb_prefix)
373 {
374  vector< vector<double> > new_gains, new_pedestals, new_strip_t0s, new_wire_t0s;
375  char str[256];
376 
377  if(eventLoop->GetCalib(ccdb_prefix+"/strip_gains_v2", new_gains))
378  cout << "Error loading "+ccdb_prefix+"/strip_gains_v2 !" << endl;
379  if(eventLoop->GetCalib(ccdb_prefix+"/strip_pedestals", new_pedestals))
380  cout << "Error loading "+ccdb_prefix+"/strip_pedestals !" << endl;
381  if(eventLoop->GetCalib(ccdb_prefix+"/strip_timing_offsets", new_strip_t0s))
382  cout << "Error loading "+ccdb_prefix+"/strip_timing_offsets!" << endl;
383  if(eventLoop->GetCalib(ccdb_prefix+"/wire_timing_offsets", new_wire_t0s))
384  cout << "Error loading "+ccdb_prefix+"/wire_timing_offsets!" << endl;
385 
386  for(int nchamber=0; nchamber<6; nchamber++) {
387 
388  // check the size of table rows
389  // The number of cathode strips was improperly implemented in the CCDB with only 192 channels
390  // There are actually 216 cathode strips since 24 are split to different readout around the beam.
391  if(new_gains[2*nchamber].size() != STRIPS_PER_PLANE+24) {
392  sprintf(str, "Bad # of strips for FDC gain from CCDB! CCDB=%zu , should be %d", new_gains[2*nchamber].size(), STRIPS_PER_PLANE+24);
393  cerr << str << endl;
394  throw JException(str);
395  }
396  if(new_gains[2*nchamber+1].size() != STRIPS_PER_PLANE+24) {
397  sprintf(str, "Bad # of strips for FDC gain from CCDB! CCDB=%zu , should be %d", new_gains[2*nchamber+1].size(), STRIPS_PER_PLANE+24);
398  cerr << str << endl;
399  throw JException(str);
400  }
401  if(new_pedestals[2*nchamber].size() != STRIPS_PER_PLANE) {
402  sprintf(str, "Bad # of strips for FDC pedestals from CCDB! CCDB=%zu , should be %d", new_pedestals[2*nchamber].size(), STRIPS_PER_PLANE);
403  cerr << str << endl;
404  throw JException(str);
405  }
406  if(new_pedestals[2*nchamber+1].size() != STRIPS_PER_PLANE) {
407  sprintf(str, "Bad # of strips for FDC pedestals from CCDB! CCDB=%zu , should be %d", new_pedestals[2*nchamber+1].size(), STRIPS_PER_PLANE);
408  cerr << str << endl;
409  throw JException(str);
410  }
411  if(new_strip_t0s[2*nchamber].size() != STRIPS_PER_PLANE) {
412  sprintf(str, "Bad # of strips for FDC timing offsets from CCDB! CCDB=%zu , should be %d", new_strip_t0s[2*nchamber].size(), STRIPS_PER_PLANE);
413  cerr << str << endl;
414  throw JException(str);
415  }
416  if(new_strip_t0s[2*nchamber+1].size() != STRIPS_PER_PLANE) {
417  sprintf(str, "Bad # of strips for FDC timing offsets from CCDB! CCDB=%zu , should be %d", new_strip_t0s[2*nchamber+1].size(), STRIPS_PER_PLANE);
418  cerr << str << endl;
419  throw JException(str);
420  }
421  if(new_wire_t0s[nchamber].size() != WIRES_PER_PLANE) {
422  sprintf(str, "Bad # of wires for FDC timing offsets from CCDB! CCDB=%zu , should be %d", new_wire_t0s[2*nchamber].size(), WIRES_PER_PLANE);
423  cerr << str << endl;
424  throw JException(str);
425  }
426 
427 
428  // load ADC gains (only for cathode strips)
429  a_gains.push_back( new_gains[2*nchamber] );
430  a_gains.push_back( vector<double>() );
431  a_gains.push_back( new_gains[2*nchamber+1] );
432 
433  // load ADC pedestals (only for cathode strips)
434  a_pedestals.push_back( new_pedestals[2*nchamber] );
435  a_pedestals.push_back( vector<double>() );
436  a_pedestals.push_back( new_pedestals[2*nchamber+1] );
437 
438  // load t0's for strips and wires
439  timing_offsets.push_back( new_strip_t0s[2*nchamber] );
440  timing_offsets.push_back( new_wire_t0s[nchamber] );
441  timing_offsets.push_back( new_strip_t0s[2*nchamber+1] );
442 
443  }
444 }
445 
446 //------------------------------------
447 // GetConstant
448 // Allow a few different interfaces
449 //------------------------------------
451  const int in_gPlane, const int in_element) const {
452 
453  char str[256];
454 
455  if( (in_gPlane <= 0) || (static_cast<unsigned int>(in_gPlane) > FDC_NUM_PLANES)) {
456  sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_gPlane, FDC_NUM_PLANES);
457  cerr << str << endl;
458  throw JException(str);
459  }
460  // strip and wire planes have different numbers of elements
461  if( (in_element <= 0) || (static_cast<unsigned int>(in_element) > the_table[in_gPlane].size())) {
462  sprintf(str, "Bad element # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %zu", in_element, the_table[in_gPlane].size());
463  cerr << str << endl;
464  throw JException(str);
465  }
466 
467  return the_table[in_gPlane-1][in_element-1];
468 }
469 
471  const DFDCCathodeDigiHit *in_digihit) const {
472 
473  char str[256];
474 
475  int gLayer = in_digihit->chamber + 6*(in_digihit->package - 1);
476  int gPlane = in_digihit->view + 3*(gLayer - 1);
477 
478  if( (gPlane <= 0) || (static_cast<unsigned int>(gPlane) > FDC_NUM_PLANES)) {
479  sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES);
480  cerr << str << endl;
481  throw JException(str);
482  }
483  // strip and wire planes have different numbers of elements
484  if( (in_digihit->strip <= 0) || (static_cast<unsigned int>(in_digihit->strip) > STRIPS_PER_PLANE)) {
485  sprintf(str, "Bad strip # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_digihit->strip, STRIPS_PER_PLANE);
486  cerr << str << endl;
487  throw JException(str);
488  }
489 
490  return the_table[gPlane-1][in_digihit->strip-1];
491 }
492 
494  const DFDCWireDigiHit *in_digihit) const {
495 
496  char str[256];
497 
498  int gLayer = in_digihit->chamber + 6*(in_digihit->package - 1);
499  int gPlane = 2 + 3*(gLayer - 1);
500 
501  if( (gPlane <= 0) || (static_cast<unsigned int>(gPlane) > FDC_NUM_PLANES)) {
502  sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES);
503  cerr << str << endl;
504  throw JException(str);
505  }
506  // strip and wire planes have different numbers of elements
507  if( (in_digihit->wire <= 0) || (static_cast<unsigned int>(in_digihit->wire) > WIRES_PER_PLANE)) {
508  sprintf(str, "Bad wire # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_digihit->wire, WIRES_PER_PLANE);
509  cerr << str << endl;
510  throw JException(str);
511  }
512 
513  return the_table[gPlane-1][in_digihit->wire-1];
514 }
515 
517  const DFDCHit *in_hit) const {
518 
519  char str[256];
520 
521  if( (in_hit->gPlane <= 0) || (static_cast<unsigned int>(in_hit->gPlane) > FDC_NUM_PLANES)) {
522  sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_hit->gPlane, FDC_NUM_PLANES);
523  cerr << str << endl;
524  throw JException(str);
525  }
526  // strip and wire planes have different numbers of elements
527  if( (in_hit->element <= 0) || (static_cast<unsigned int>(in_hit->element) > the_table[in_hit->gPlane].size())) {
528  sprintf(str, "Bad element # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %zu", in_hit->element, the_table[in_hit->gPlane].size());
529  cerr << str << endl;
530  throw JException(str);
531  }
532 
533  return the_table[in_hit->gPlane-1][in_hit->element-1];
534 }
535 /*
536  const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
537  const DTranslationTable *ttab,
538  const int in_rocid, const int in_slot, const int in_channel) const {
539 
540  char str[256];
541 
542  DTranslationTable::csc_t daq_index = { in_rocid, in_slot, in_channel };
543  DTranslationTable::DChannelInfo channel_info = ttab->GetDetectorIndex(daq_index);
544 
545  if( channel_info.det_sys == DTranslationTable::FDC_CATHODES ) {
546 // FDC Cathodes
547 int gLayer = channel_info.fdc_cathodes.chamber + 6*(channel_info.fdc_cathodes.package - 1);
548 int gPlane = channel_info.fdc_cathodes.view + 3*(gLayer - 1);
549 
550 if( (gPlane <= 0) || (gPlane > FDC_NUM_PLANES)) {
551 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES);
552 cerr << str << endl;
553 throw JException(str);
554 }
555 // strip and wire planes have different numbers of elements
556 if( (channel_info.fdc_cathodes.strip <= 0)
557 || (channel_info.fdc_cathodes.strip > STRIPS_PER_PLANE)) {
558 sprintf(str, "Bad strip # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", channel_info.fdc_cathodes.strip, STRIPS_PER_PLANE);
559 cerr << str << endl;
560 throw JException(str);
561 }
562 
563 return the_table[gPlane-1][channel_info.fdc_cathodes.strip-1];
564 } else if( channel_info.det_sys == DTranslationTable::FDC_WIRES ) {
565 // FDC Wirees
566 int gLayer = channel_info.fdc_wires.chamber + 6*(channel_info.fdc_wires.package - 1);
567 int gPlane = 2 + 3*(gLayer - 1); // wire planes are always layer 2
568 
569 if( (gPlane <= 0) || (gPlane > FDC_NUM_PLANES)) {
570 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES);
571 cerr << str << endl;
572 throw JException(str);
573 }
574 // strip and wire planes have different numbers of elements
575 if( (channel_info.fdc_wires.wire <= 0)
576 || (channel_info.fdc_wires.wire > WIRES_PER_PLANE)) {
577 sprintf(str, "Bad strip # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", channel_info.fdc_wires.wire, WIRES_PER_PLANE);
578 cerr << str << endl;
579 throw JException(str);
580 }
581 
582 return the_table[gPlane-1][channel_info.fdc_wires.wire-1];
583 } else {
584 sprintf(str, "Got bad detector type in DFDCHit_factory::GetConstant()! requested=%d", channel_info.module_type);
585 cerr << str << endl;
586 throw JException(str);
587 
588 return -1.; // should never reach here!
589 }
590 }
591 */
float q
Definition: DFDCHit.h:29
double Convert_DigiTimeToNs_F1TDC(const JObject *locTDCDigiHit) const
jerror_t init(void)
Called once at program start.
char str[256]
int type
Definition: DFDCHit.h:44
Int_t layer
uint32_t pulse_peak
from Pulse Pedestal Data word
sprintf(text,"Post KinFit Cut")
#define WIRES_PER_PLANE
Definition: DFDCGeometry.h:23
#define FDC_NUM_PLANES
Definition: DFDCGeometry.h:13
int gLayer
Definition: DFDCHit.h:28
float pulse_height
Definition: DFDCHit.h:30
vector< vector< double > > fdc_digi_constants_t
uint16_t PBIT
Definition: Df125Config.h:46
uint16_t IE
Definition: Df125Config.h:40
uint16_t ABIT
Definition: Df125Config.h:45
int ptype
Definition: DFDCHit.h:48
const double GetConstant(const fdc_digi_constants_t &the_table, const int in_gPlane, const int in_element) const
int layer
Definition: DFDCHit.h:23
uint32_t pedestal
pedestal info used by FPGA (if any)
float pulse_height_raw
Definition: DFDCHit.h:31
int plane
Definition: DFDCHit.h:26
#define _DBG_
Definition: HDEVIO.h:12
float d
Definition: DFDCHit.h:35
uint32_t pulse_number
from Pulse Pedestal Data word
void LoadPackageCalibTables(jana::JEventLoop *eventLoop, string ccdb_prefix)
int element
Definition: DFDCHit.h:25
uint32_t pedestal
from Pulse Pedestal Data word
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
vector< double > a_pedestals
uint16_t NW
Definition: Df125Config.h:35
int itrack
Definition: DFDCHit.h:47
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
float t
Definition: DFDCHit.h:32
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
#define STRIPS_PER_PLANE
Definition: DFDCGeometry.h:26
int module
Definition: DFDCHit.h:24
static float getWireR(const DFDCHit *h)
DFDCGeometry::getWireR(): Return X coordinate of a wire.
Definition: DFDCGeometry.h:75
int gPlane
Definition: DFDCHit.h:27
float r
Definition: DFDCHit.h:33
class DFDCHit: definition for a basic FDC hit data type.
Definition: DFDCHit.h:20