Bug Summary

File:libraries/FDC/DFDCHit_factory.cc
Location:line 185, column 16
Description:Value stored to 'pedestal' during its initialization is never read

Annotated Source Code

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>
11using 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>
21using namespace jana;
22
23
24//------------------
25// init
26//------------------
27jerror_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//------------------
41jerror_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{ { 0, 0, 0, 0, 0, 0, { 0, 0 } } };
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_PLANES72) {
100 sprintf(str, "Bad # of planes for FDC gains from CCDB! CCDB=%zu , should be %d",
101 a_gains.size(), FDC_NUM_PLANES72);
102 cerr << str << endl;
103 throw JException(str);
104 }
105 if(a_pedestals.size() != FDC_NUM_PLANES72) {
106 sprintf(str, "Bad # of planes for FDC pedestals from CCDB! CCDB=%zu , should be %d",
107 a_pedestals.size(), FDC_NUM_PLANES72);
108 cerr << str << endl;
109 throw JException(str);
110 }
111 if(timing_offsets.size() != FDC_NUM_PLANES72) {
112 sprintf(str, "Bad # of planes for FDC timing offsets from CCDB! CCDB=%zu , should be %d",
113 timing_offsets.size(), FDC_NUM_PLANES72);
114 cerr << str << endl;
115 throw JException(str);
116 }
117
118 return NOERROR;
119}
120
121//------------------
122// evnt
123//------------------
124jerror_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__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_PLANES72)) {
169 sprintf(str, "DFDCDigiHit plane out of range! gPlane=%d (should be 1-%d)", gPlane, FDC_NUM_PLANES72);
170 throw JException(str);
171 }
172 if( (digihit->strip < 1) || (digihit->strip > STRIPS_PER_PLANE192)) {
173 sprintf(str, "DFDCDigiHit straw out of range! strip=%d for plane=%d (should be 1-%d)", digihit->strip, gPlane, STRIPS_PER_PLANE192);
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];
Value stored to 'pedestal' during its initialization is never read
186
187 // Grab the pedestal from the digihit since this should be consistent between the old and new formats
188 uint32_t raw_ped = digihit->pedestal;
189 uint32_t nsamples_integral = digihit->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 uint32_t pulse_peak = 0;
201 const Df125FDCPulse *FDCPulseObj = NULL__null;
202 digihit->GetSingle(FDCPulseObj);
203 if (FDCPulseObj != NULL__null){
204 // Cut on quality factor?
205 const Df125Config *config = NULL__null;
206 FDCPulseObj->GetSingle(config);
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(config){
211 IBIT = config->IBIT == 0xffff ? 4 : config->IBIT;
212 ABIT = config->ABIT == 0xffff ? 3 : config->ABIT;
213 PBIT = config->PBIT == 0xffff ? 0 : config->PBIT;
214 NW = config->NW == 0xffff ? 80 : config->NW;
215 IE = config->IE == 0xffff ? 16 : config->IE;
216 }else{
217 static int Nwarnings = 0;
218 if(Nwarnings<10){
219 _DBG_std::cerr<<"libraries/FDC/DFDCHit_factory.cc"<<":"
<<219<<" "
<< "NO Df125Config object associated with Df125FDCPulse object!" << endl;
220 Nwarnings++;
221 if(Nwarnings==10) _DBG_std::cerr<<"libraries/FDC/DFDCHit_factory.cc"<<":"
<<221<<" "
<< " --- LAST WARNING!! ---" << endl;
222 }
223 }
224 if ((NW - (digihit->pulse_time / 10)) < IE){
225 nsamples_integral = (NW - (digihit->pulse_time / 10));
226 }
227 else{
228 nsamples_integral = IE;
229 }
230
231 pulse_peak = FDCPulseObj->peak_amp << ABIT;
232 }
233 else{
234 // There is a slight difference between Mode 7 and 8 data
235 // The following condition signals an error state in the flash algorithm
236 // Do not make hits out of these
237 const Df125PulsePedestal* PPobj = NULL__null;
238 digihit->GetSingle(PPobj);
239 if (PPobj != NULL__null){
240 if (PPobj->pedestal == 0 || PPobj->pulse_peak == 0) continue;
241 if (PPobj->pulse_number == 1) continue; // Unintentionally had 2 pulses found in fall data (0-1 counting issue)
242 pulse_peak = PPobj->pulse_peak;
243 }
244
245 const Df125PulseIntegral* PIobj = NULL__null;
246 digihit->GetSingle(PIobj);
247 if ( PPobj == NULL__null || PIobj == NULL__null) continue; // We don't want hits where ANY of the associated information is missing
248 }
249
250 // Complete the pedestal subtracion here since we should know the correct number of samples.
251 uint32_t scaled_ped = raw_ped << PBIT;
252 pedestal = double(scaled_ped * nsamples_integral);
253
254 double integral = double(digihit->pulse_integral << IBIT);
255 // Comment this line out temporarily until config words are behaving nicely
256 //if (A-pedestal<0.) continue;
257
258 double q = a_scale * a_gains[plane_index][strip_index] * (integral-pedestal);
259 double t = t_scale * T - timing_offsets[plane_index][strip_index]+fadc_t_base;
260
261 DFDCHit *hit = new DFDCHit;
262 hit->layer = digihit->view;
263 hit->gLayer = gLayer;
264 hit->gPlane = gPlane;
265 hit->module = 1 + (gLayer-1)/3;
266 hit->element = digihit->strip;
267 hit->plane = digihit->view; // "plane" is apparently the same as "layer"
268 hit->r = DFDCGeometry::getWireR(hit);
269 hit->d = 0.0; // MC data only
270 hit->type = digihit->strip_type; // n.b. DEventSourceHDDM hardwires this as "1" for cathodes!
271 hit->itrack = -1; // MC data only
272 hit->ptype = 0;// MC data only
273 hit->q = q;
274 hit->t = t;
275 hit->pulse_height=a_gains[plane_index][strip_index]
276 *double(pulse_peak - scaled_ped);
277
278 //cerr << "FDC hitL plane = " << hit->gPlane << " element = " << hit->element << endl;
279
280 hit->AddAssociatedObject(digihit);
281
282 _data.push_back(hit);
283 }
284
285 // Make hits out of all DFDCWireDigiHit hits
286 vector<const DFDCWireDigiHit*> wiredigihits;
287 loop->Get(wiredigihits);
288 for(unsigned int i=0; i<wiredigihits.size(); i++){
289 const DFDCWireDigiHit *digihit = wiredigihits[i];
290
291 // The translation table has:
292 // ---------------------------------------------------
293 // package : 1-4
294 // chamber : 1-6
295 // wire : 1-96
296 //
297 //
298 // The FDCHit class has 6 indexes which are derived
299 // from these and contain some redundancy. They are:
300 // ---------------------------------------------------
301 // plane : 1(V), 2(X), or 3(U)
302 // layer : 1 (phi=0), 2 (phi=+60), 3 (phi=-60)
303 // module : 1 through 8, 1 module = 3 detection layers
304 // element : wire or strip number
305 // plane : for cathodes only: u(3) or v(1) plane, u@+45,v@-45
306 // gPlane : 1 through 72
307 // gLayer : 1 through 24
308
309 DFDCHit *hit = new DFDCHit;
310 hit->gLayer = digihit->chamber + 6*(digihit->package - 1);
311 hit->module = 1 + (hit->gLayer-1)/3;
312 hit->layer = hit->gLayer - (hit->module-1)*3;
313 hit->plane = 2; // wire is always in "X" layer
314 hit->gPlane = hit->plane + 3*(hit->gLayer - 1);
315 hit->element = digihit->wire;
316 hit->r = DFDCGeometry::getWireR(hit);
317 hit->d = 0.0; // MC data only
318 hit->type = DFDCHit::AnodeWire; // n.b. DEventSourceHDDM hardwires this as "0" for anodes!
319 hit->itrack = -1; // MC data only
320 hit->ptype = 0; // MC data only
321
322 // Make sure gPlane and wire are in valid range
323 if( (hit->gPlane < 1) || (hit->gPlane > FDC_NUM_PLANES72)) {
324 sprintf(str, "DFDCDigiHit plane out of range! gPlane=%d (should be 1-%d)", hit->gPlane, FDC_NUM_PLANES72);
325 throw JException(str);
326 }
327 if( (digihit->wire < 1) || (digihit->wire > WIRES_PER_PLANE96)) {
328 sprintf(str, "DFDCDigiHit straw out of range! wire=%d for plane=%d (should be 1-%d)", digihit->wire, hit->gPlane, WIRES_PER_PLANE96);
329 throw JException(str);
330 }
331
332 // Apply calibration constants here
333 double T = locTTabUtilities->Convert_DigiTimeToNs_F1TDC(digihit) - timing_offsets[hit->gPlane-1][hit->element-1] + t_base;
334 hit->q = 0.0; // no charge measured for wires in FDC
335 hit->pulse_height=0.0;
336 hit->t = T;
337
338 hit->AddAssociatedObject(digihit);
339
340 _data.push_back(hit);
341 }
342
343 return NOERROR;
344}
345
346//------------------
347// erun
348//------------------
349jerror_t DFDCHit_factory::erun(void)
350{
351 return NOERROR;
352}
353
354//------------------
355// fini
356//------------------
357jerror_t DFDCHit_factory::fini(void)
358{
359 return NOERROR;
360}
361
362
363//------------------
364// LoadPackageCalibTables
365//------------------
366void DFDCHit_factory::LoadPackageCalibTables(jana::JEventLoop *eventLoop, string ccdb_prefix)
367{
368 vector< vector<double> > new_gains, new_pedestals, new_strip_t0s, new_wire_t0s;
369 char str[256];
370
371 if(eventLoop->GetCalib(ccdb_prefix+"/strip_gains", new_gains))
372 cout << "Error loading "+ccdb_prefix+"/strip_gains !" << endl;
373 if(eventLoop->GetCalib(ccdb_prefix+"/strip_pedestals", new_pedestals))
374 cout << "Error loading "+ccdb_prefix+"/strip_pedestals !" << endl;
375 if(eventLoop->GetCalib(ccdb_prefix+"/strip_timing_offsets", new_strip_t0s))
376 cout << "Error loading "+ccdb_prefix+"/strip_timing_offsets!" << endl;
377 if(eventLoop->GetCalib(ccdb_prefix+"/wire_timing_offsets", new_wire_t0s))
378 cout << "Error loading "+ccdb_prefix+"/wire_timing_offsets!" << endl;
379
380 for(int nchamber=0; nchamber<6; nchamber++) {
381
382 // check the size of table rows
383 if(new_gains[2*nchamber].size() != STRIPS_PER_PLANE192) {
384 sprintf(str, "Bad # of strips for FDC gain from CCDB! CCDB=%zu , should be %d", new_gains[2*nchamber].size(), STRIPS_PER_PLANE192);
385 cerr << str << endl;
386 throw JException(str);
387 }
388 if(new_gains[2*nchamber+1].size() != STRIPS_PER_PLANE192) {
389 sprintf(str, "Bad # of strips for FDC gain from CCDB! CCDB=%zu , should be %d", new_gains[2*nchamber+1].size(), STRIPS_PER_PLANE192);
390 cerr << str << endl;
391 throw JException(str);
392 }
393 if(new_pedestals[2*nchamber].size() != STRIPS_PER_PLANE192) {
394 sprintf(str, "Bad # of strips for FDC pedestals from CCDB! CCDB=%zu , should be %d", new_pedestals[2*nchamber].size(), STRIPS_PER_PLANE192);
395 cerr << str << endl;
396 throw JException(str);
397 }
398 if(new_pedestals[2*nchamber+1].size() != STRIPS_PER_PLANE192) {
399 sprintf(str, "Bad # of strips for FDC pedestals from CCDB! CCDB=%zu , should be %d", new_pedestals[2*nchamber+1].size(), STRIPS_PER_PLANE192);
400 cerr << str << endl;
401 throw JException(str);
402 }
403 if(new_strip_t0s[2*nchamber].size() != STRIPS_PER_PLANE192) {
404 sprintf(str, "Bad # of strips for FDC timing offsets from CCDB! CCDB=%zu , should be %d", new_strip_t0s[2*nchamber].size(), STRIPS_PER_PLANE192);
405 cerr << str << endl;
406 throw JException(str);
407 }
408 if(new_strip_t0s[2*nchamber+1].size() != STRIPS_PER_PLANE192) {
409 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_PLANE192);
410 cerr << str << endl;
411 throw JException(str);
412 }
413 if(new_wire_t0s[nchamber].size() != WIRES_PER_PLANE96) {
414 sprintf(str, "Bad # of wires for FDC timing offsets from CCDB! CCDB=%zu , should be %d", new_wire_t0s[2*nchamber].size(), WIRES_PER_PLANE96);
415 cerr << str << endl;
416 throw JException(str);
417 }
418
419
420 // load ADC gains (only for cathode strips)
421 a_gains.push_back( new_gains[2*nchamber] );
422 a_gains.push_back( vector<double>() );
423 a_gains.push_back( new_gains[2*nchamber+1] );
424
425 // load ADC pedestals (only for cathode strips)
426 a_pedestals.push_back( new_pedestals[2*nchamber] );
427 a_pedestals.push_back( vector<double>() );
428 a_pedestals.push_back( new_pedestals[2*nchamber+1] );
429
430 // load t0's for strips and wires
431 timing_offsets.push_back( new_strip_t0s[2*nchamber] );
432 timing_offsets.push_back( new_wire_t0s[nchamber] );
433 timing_offsets.push_back( new_strip_t0s[2*nchamber+1] );
434
435 }
436}
437
438//------------------------------------
439// GetConstant
440// Allow a few different interfaces
441//------------------------------------
442const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
443 const int in_gPlane, const int in_element) const {
444
445 char str[256];
446
447 if( (in_gPlane <= 0) || (static_cast<unsigned int>(in_gPlane) > FDC_NUM_PLANES72)) {
448 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_gPlane, FDC_NUM_PLANES72);
449 cerr << str << endl;
450 throw JException(str);
451 }
452 // strip and wire planes have different numbers of elements
453 if( (in_element <= 0) || (static_cast<unsigned int>(in_element) > the_table[in_gPlane].size())) {
454 sprintf(str, "Bad element # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %zu", in_element, the_table[in_gPlane].size());
455 cerr << str << endl;
456 throw JException(str);
457 }
458
459 return the_table[in_gPlane-1][in_element-1];
460}
461
462const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
463 const DFDCCathodeDigiHit *in_digihit) const {
464
465 char str[256];
466
467 int gLayer = in_digihit->chamber + 6*(in_digihit->package - 1);
468 int gPlane = in_digihit->view + 3*(gLayer - 1);
469
470 if( (gPlane <= 0) || (static_cast<unsigned int>(gPlane) > FDC_NUM_PLANES72)) {
471 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES72);
472 cerr << str << endl;
473 throw JException(str);
474 }
475 // strip and wire planes have different numbers of elements
476 if( (in_digihit->strip <= 0) || (static_cast<unsigned int>(in_digihit->strip) > STRIPS_PER_PLANE192)) {
477 sprintf(str, "Bad strip # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_digihit->strip, STRIPS_PER_PLANE192);
478 cerr << str << endl;
479 throw JException(str);
480 }
481
482 return the_table[gPlane-1][in_digihit->strip-1];
483}
484
485const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
486 const DFDCWireDigiHit *in_digihit) const {
487
488 char str[256];
489
490 int gLayer = in_digihit->chamber + 6*(in_digihit->package - 1);
491 int gPlane = 2 + 3*(gLayer - 1);
492
493 if( (gPlane <= 0) || (static_cast<unsigned int>(gPlane) > FDC_NUM_PLANES72)) {
494 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES72);
495 cerr << str << endl;
496 throw JException(str);
497 }
498 // strip and wire planes have different numbers of elements
499 if( (in_digihit->wire <= 0) || (static_cast<unsigned int>(in_digihit->wire) > WIRES_PER_PLANE96)) {
500 sprintf(str, "Bad wire # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_digihit->wire, WIRES_PER_PLANE96);
501 cerr << str << endl;
502 throw JException(str);
503 }
504
505 return the_table[gPlane-1][in_digihit->wire-1];
506}
507
508const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
509 const DFDCHit *in_hit) const {
510
511 char str[256];
512
513 if( (in_hit->gPlane <= 0) || (static_cast<unsigned int>(in_hit->gPlane) > FDC_NUM_PLANES72)) {
514 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_hit->gPlane, FDC_NUM_PLANES72);
515 cerr << str << endl;
516 throw JException(str);
517 }
518 // strip and wire planes have different numbers of elements
519 if( (in_hit->element <= 0) || (static_cast<unsigned int>(in_hit->element) > the_table[in_hit->gPlane].size())) {
520 sprintf(str, "Bad element # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %zu", in_hit->element, the_table[in_hit->gPlane].size());
521 cerr << str << endl;
522 throw JException(str);
523 }
524
525 return the_table[in_hit->gPlane-1][in_hit->element-1];
526}
527/*
528 const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
529 const DTranslationTable *ttab,
530 const int in_rocid, const int in_slot, const int in_channel) const {
531
532 char str[256];
533
534 DTranslationTable::csc_t daq_index = { in_rocid, in_slot, in_channel };
535 DTranslationTable::DChannelInfo channel_info = ttab->GetDetectorIndex(daq_index);
536
537 if( channel_info.det_sys == DTranslationTable::FDC_CATHODES ) {
538// FDC Cathodes
539int gLayer = channel_info.fdc_cathodes.chamber + 6*(channel_info.fdc_cathodes.package - 1);
540int gPlane = channel_info.fdc_cathodes.view + 3*(gLayer - 1);
541
542if( (gPlane <= 0) || (gPlane > FDC_NUM_PLANES)) {
543sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES);
544cerr << str << endl;
545throw JException(str);
546}
547// strip and wire planes have different numbers of elements
548if( (channel_info.fdc_cathodes.strip <= 0)
549|| (channel_info.fdc_cathodes.strip > STRIPS_PER_PLANE)) {
550sprintf(str, "Bad strip # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", channel_info.fdc_cathodes.strip, STRIPS_PER_PLANE);
551cerr << str << endl;
552throw JException(str);
553}
554
555return the_table[gPlane-1][channel_info.fdc_cathodes.strip-1];
556} else if( channel_info.det_sys == DTranslationTable::FDC_WIRES ) {
557// FDC Wirees
558int gLayer = channel_info.fdc_wires.chamber + 6*(channel_info.fdc_wires.package - 1);
559int gPlane = 2 + 3*(gLayer - 1); // wire planes are always layer 2
560
561if( (gPlane <= 0) || (gPlane > FDC_NUM_PLANES)) {
562sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES);
563cerr << str << endl;
564throw JException(str);
565}
566// strip and wire planes have different numbers of elements
567if( (channel_info.fdc_wires.wire <= 0)
568|| (channel_info.fdc_wires.wire > WIRES_PER_PLANE)) {
569sprintf(str, "Bad strip # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", channel_info.fdc_wires.wire, WIRES_PER_PLANE);
570cerr << str << endl;
571throw JException(str);
572}
573
574return the_table[gPlane-1][channel_info.fdc_wires.wire-1];
575} else {
576sprintf(str, "Got bad detector type in DFDCHit_factory::GetConstant()! requested=%d", channel_info.module_type);
577cerr << str << endl;
578throw JException(str);
579
580return -1.; // should never reach here!
581}
582}
583*/