Bug Summary

File:libraries/FDC/DFDCHit_factory.cc
Location:line 252, column 9
Description:Value stored to 'pedestal' 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];
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);
Value stored to 'pedestal' is never read
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 // ------The integral is no longer reported for FDC hits --- SJT 3/4/16
259 //double q = a_scale * a_gains[plane_index][strip_index] * (integral-pedestal);
260 double t = t_scale * T - timing_offsets[plane_index][strip_index]+fadc_t_base;
261
262 DFDCHit *hit = new DFDCHit;
263 hit->layer = digihit->view;
264 hit->gLayer = gLayer;
265 hit->gPlane = gPlane;
266 hit->module = 1 + (gLayer-1)/3;
267 hit->element = digihit->strip;
268 hit->plane = digihit->view; // "plane" is apparently the same as "layer"
269 hit->r = DFDCGeometry::getWireR(hit);
270 hit->d = 0.0; // MC data only
271 hit->type = digihit->strip_type; // n.b. DEventSourceHDDM hardwires this as "1" for cathodes!
272 hit->itrack = -1; // MC data only
273 hit->ptype = 0;// MC data only
274 //hit->q = q;
275 hit->t = t;
276 hit->pulse_height=a_gains[plane_index][strip_index]
277 *double(pulse_peak - scaled_ped);
278 hit->q=a_scale*hit->pulse_height;
279
280 //cerr << "FDC hitL plane = " << hit->gPlane << " element = " << hit->element << endl;
281
282 hit->AddAssociatedObject(digihit);
283
284 _data.push_back(hit);
285 }
286
287 // Make hits out of all DFDCWireDigiHit hits
288 vector<const DFDCWireDigiHit*> wiredigihits;
289 loop->Get(wiredigihits);
290 for(unsigned int i=0; i<wiredigihits.size(); i++){
291 const DFDCWireDigiHit *digihit = wiredigihits[i];
292
293 // The translation table has:
294 // ---------------------------------------------------
295 // package : 1-4
296 // chamber : 1-6
297 // wire : 1-96
298 //
299 //
300 // The FDCHit class has 6 indexes which are derived
301 // from these and contain some redundancy. They are:
302 // ---------------------------------------------------
303 // plane : 1(V), 2(X), or 3(U)
304 // layer : 1 (phi=0), 2 (phi=+60), 3 (phi=-60)
305 // module : 1 through 8, 1 module = 3 detection layers
306 // element : wire or strip number
307 // plane : for cathodes only: u(3) or v(1) plane, u@+45,v@-45
308 // gPlane : 1 through 72
309 // gLayer : 1 through 24
310
311 DFDCHit *hit = new DFDCHit;
312 hit->gLayer = digihit->chamber + 6*(digihit->package - 1);
313 hit->module = 1 + (hit->gLayer-1)/3;
314 hit->layer = hit->gLayer - (hit->module-1)*3;
315 hit->plane = 2; // wire is always in "X" layer
316 hit->gPlane = hit->plane + 3*(hit->gLayer - 1);
317 hit->element = digihit->wire;
318 hit->r = DFDCGeometry::getWireR(hit);
319 hit->d = 0.0; // MC data only
320 hit->type = DFDCHit::AnodeWire; // n.b. DEventSourceHDDM hardwires this as "0" for anodes!
321 hit->itrack = -1; // MC data only
322 hit->ptype = 0; // MC data only
323
324 // Make sure gPlane and wire are in valid range
325 if( (hit->gPlane < 1) || (hit->gPlane > FDC_NUM_PLANES72)) {
326 sprintf(str, "DFDCDigiHit plane out of range! gPlane=%d (should be 1-%d)", hit->gPlane, FDC_NUM_PLANES72);
327 throw JException(str);
328 }
329 if( (digihit->wire < 1) || (digihit->wire > WIRES_PER_PLANE96)) {
330 sprintf(str, "DFDCDigiHit straw out of range! wire=%d for plane=%d (should be 1-%d)", digihit->wire, hit->gPlane, WIRES_PER_PLANE96);
331 throw JException(str);
332 }
333
334 // Apply calibration constants here
335 double T = locTTabUtilities->Convert_DigiTimeToNs_F1TDC(digihit) - timing_offsets[hit->gPlane-1][hit->element-1] + t_base;
336 hit->q = 0.0; // no charge measured for wires in FDC
337 hit->pulse_height=0.0;
338 hit->t = T;
339
340 hit->AddAssociatedObject(digihit);
341
342 _data.push_back(hit);
343 }
344
345 return NOERROR;
346}
347
348//------------------
349// erun
350//------------------
351jerror_t DFDCHit_factory::erun(void)
352{
353 return NOERROR;
354}
355
356//------------------
357// fini
358//------------------
359jerror_t DFDCHit_factory::fini(void)
360{
361 return NOERROR;
362}
363
364
365//------------------
366// LoadPackageCalibTables
367//------------------
368void DFDCHit_factory::LoadPackageCalibTables(jana::JEventLoop *eventLoop, string ccdb_prefix)
369{
370 vector< vector<double> > new_gains, new_pedestals, new_strip_t0s, new_wire_t0s;
371 char str[256];
372
373 if(eventLoop->GetCalib(ccdb_prefix+"/strip_gains", new_gains))
374 cout << "Error loading "+ccdb_prefix+"/strip_gains !" << endl;
375 if(eventLoop->GetCalib(ccdb_prefix+"/strip_pedestals", new_pedestals))
376 cout << "Error loading "+ccdb_prefix+"/strip_pedestals !" << endl;
377 if(eventLoop->GetCalib(ccdb_prefix+"/strip_timing_offsets", new_strip_t0s))
378 cout << "Error loading "+ccdb_prefix+"/strip_timing_offsets!" << endl;
379 if(eventLoop->GetCalib(ccdb_prefix+"/wire_timing_offsets", new_wire_t0s))
380 cout << "Error loading "+ccdb_prefix+"/wire_timing_offsets!" << endl;
381
382 for(int nchamber=0; nchamber<6; nchamber++) {
383
384 // check the size of table rows
385 if(new_gains[2*nchamber].size() != STRIPS_PER_PLANE192) {
386 sprintf(str, "Bad # of strips for FDC gain from CCDB! CCDB=%zu , should be %d", new_gains[2*nchamber].size(), STRIPS_PER_PLANE192);
387 cerr << str << endl;
388 throw JException(str);
389 }
390 if(new_gains[2*nchamber+1].size() != STRIPS_PER_PLANE192) {
391 sprintf(str, "Bad # of strips for FDC gain from CCDB! CCDB=%zu , should be %d", new_gains[2*nchamber+1].size(), STRIPS_PER_PLANE192);
392 cerr << str << endl;
393 throw JException(str);
394 }
395 if(new_pedestals[2*nchamber].size() != STRIPS_PER_PLANE192) {
396 sprintf(str, "Bad # of strips for FDC pedestals from CCDB! CCDB=%zu , should be %d", new_pedestals[2*nchamber].size(), STRIPS_PER_PLANE192);
397 cerr << str << endl;
398 throw JException(str);
399 }
400 if(new_pedestals[2*nchamber+1].size() != STRIPS_PER_PLANE192) {
401 sprintf(str, "Bad # of strips for FDC pedestals from CCDB! CCDB=%zu , should be %d", new_pedestals[2*nchamber+1].size(), STRIPS_PER_PLANE192);
402 cerr << str << endl;
403 throw JException(str);
404 }
405 if(new_strip_t0s[2*nchamber].size() != STRIPS_PER_PLANE192) {
406 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);
407 cerr << str << endl;
408 throw JException(str);
409 }
410 if(new_strip_t0s[2*nchamber+1].size() != STRIPS_PER_PLANE192) {
411 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);
412 cerr << str << endl;
413 throw JException(str);
414 }
415 if(new_wire_t0s[nchamber].size() != WIRES_PER_PLANE96) {
416 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);
417 cerr << str << endl;
418 throw JException(str);
419 }
420
421
422 // load ADC gains (only for cathode strips)
423 a_gains.push_back( new_gains[2*nchamber] );
424 a_gains.push_back( vector<double>() );
425 a_gains.push_back( new_gains[2*nchamber+1] );
426
427 // load ADC pedestals (only for cathode strips)
428 a_pedestals.push_back( new_pedestals[2*nchamber] );
429 a_pedestals.push_back( vector<double>() );
430 a_pedestals.push_back( new_pedestals[2*nchamber+1] );
431
432 // load t0's for strips and wires
433 timing_offsets.push_back( new_strip_t0s[2*nchamber] );
434 timing_offsets.push_back( new_wire_t0s[nchamber] );
435 timing_offsets.push_back( new_strip_t0s[2*nchamber+1] );
436
437 }
438}
439
440//------------------------------------
441// GetConstant
442// Allow a few different interfaces
443//------------------------------------
444const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
445 const int in_gPlane, const int in_element) const {
446
447 char str[256];
448
449 if( (in_gPlane <= 0) || (static_cast<unsigned int>(in_gPlane) > FDC_NUM_PLANES72)) {
450 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_gPlane, FDC_NUM_PLANES72);
451 cerr << str << endl;
452 throw JException(str);
453 }
454 // strip and wire planes have different numbers of elements
455 if( (in_element <= 0) || (static_cast<unsigned int>(in_element) > the_table[in_gPlane].size())) {
456 sprintf(str, "Bad element # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %zu", in_element, the_table[in_gPlane].size());
457 cerr << str << endl;
458 throw JException(str);
459 }
460
461 return the_table[in_gPlane-1][in_element-1];
462}
463
464const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
465 const DFDCCathodeDigiHit *in_digihit) const {
466
467 char str[256];
468
469 int gLayer = in_digihit->chamber + 6*(in_digihit->package - 1);
470 int gPlane = in_digihit->view + 3*(gLayer - 1);
471
472 if( (gPlane <= 0) || (static_cast<unsigned int>(gPlane) > FDC_NUM_PLANES72)) {
473 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES72);
474 cerr << str << endl;
475 throw JException(str);
476 }
477 // strip and wire planes have different numbers of elements
478 if( (in_digihit->strip <= 0) || (static_cast<unsigned int>(in_digihit->strip) > STRIPS_PER_PLANE192)) {
479 sprintf(str, "Bad strip # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_digihit->strip, STRIPS_PER_PLANE192);
480 cerr << str << endl;
481 throw JException(str);
482 }
483
484 return the_table[gPlane-1][in_digihit->strip-1];
485}
486
487const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
488 const DFDCWireDigiHit *in_digihit) const {
489
490 char str[256];
491
492 int gLayer = in_digihit->chamber + 6*(in_digihit->package - 1);
493 int gPlane = 2 + 3*(gLayer - 1);
494
495 if( (gPlane <= 0) || (static_cast<unsigned int>(gPlane) > FDC_NUM_PLANES72)) {
496 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES72);
497 cerr << str << endl;
498 throw JException(str);
499 }
500 // strip and wire planes have different numbers of elements
501 if( (in_digihit->wire <= 0) || (static_cast<unsigned int>(in_digihit->wire) > WIRES_PER_PLANE96)) {
502 sprintf(str, "Bad wire # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_digihit->wire, WIRES_PER_PLANE96);
503 cerr << str << endl;
504 throw JException(str);
505 }
506
507 return the_table[gPlane-1][in_digihit->wire-1];
508}
509
510const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
511 const DFDCHit *in_hit) const {
512
513 char str[256];
514
515 if( (in_hit->gPlane <= 0) || (static_cast<unsigned int>(in_hit->gPlane) > FDC_NUM_PLANES72)) {
516 sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", in_hit->gPlane, FDC_NUM_PLANES72);
517 cerr << str << endl;
518 throw JException(str);
519 }
520 // strip and wire planes have different numbers of elements
521 if( (in_hit->element <= 0) || (static_cast<unsigned int>(in_hit->element) > the_table[in_hit->gPlane].size())) {
522 sprintf(str, "Bad element # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %zu", in_hit->element, the_table[in_hit->gPlane].size());
523 cerr << str << endl;
524 throw JException(str);
525 }
526
527 return the_table[in_hit->gPlane-1][in_hit->element-1];
528}
529/*
530 const double DFDCHit_factory::GetConstant(const fdc_digi_constants_t &the_table,
531 const DTranslationTable *ttab,
532 const int in_rocid, const int in_slot, const int in_channel) const {
533
534 char str[256];
535
536 DTranslationTable::csc_t daq_index = { in_rocid, in_slot, in_channel };
537 DTranslationTable::DChannelInfo channel_info = ttab->GetDetectorIndex(daq_index);
538
539 if( channel_info.det_sys == DTranslationTable::FDC_CATHODES ) {
540// FDC Cathodes
541int gLayer = channel_info.fdc_cathodes.chamber + 6*(channel_info.fdc_cathodes.package - 1);
542int gPlane = channel_info.fdc_cathodes.view + 3*(gLayer - 1);
543
544if( (gPlane <= 0) || (gPlane > FDC_NUM_PLANES)) {
545sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES);
546cerr << str << endl;
547throw JException(str);
548}
549// strip and wire planes have different numbers of elements
550if( (channel_info.fdc_cathodes.strip <= 0)
551|| (channel_info.fdc_cathodes.strip > STRIPS_PER_PLANE)) {
552sprintf(str, "Bad strip # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", channel_info.fdc_cathodes.strip, STRIPS_PER_PLANE);
553cerr << str << endl;
554throw JException(str);
555}
556
557return the_table[gPlane-1][channel_info.fdc_cathodes.strip-1];
558} else if( channel_info.det_sys == DTranslationTable::FDC_WIRES ) {
559// FDC Wirees
560int gLayer = channel_info.fdc_wires.chamber + 6*(channel_info.fdc_wires.package - 1);
561int gPlane = 2 + 3*(gLayer - 1); // wire planes are always layer 2
562
563if( (gPlane <= 0) || (gPlane > FDC_NUM_PLANES)) {
564sprintf(str, "Bad gPlane # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", gPlane, FDC_NUM_PLANES);
565cerr << str << endl;
566throw JException(str);
567}
568// strip and wire planes have different numbers of elements
569if( (channel_info.fdc_wires.wire <= 0)
570|| (channel_info.fdc_wires.wire > WIRES_PER_PLANE)) {
571sprintf(str, "Bad strip # requested in DFDCHit_factory::GetConstant()! requested=%d , should be %ud", channel_info.fdc_wires.wire, WIRES_PER_PLANE);
572cerr << str << endl;
573throw JException(str);
574}
575
576return the_table[gPlane-1][channel_info.fdc_wires.wire-1];
577} else {
578sprintf(str, "Got bad detector type in DFDCHit_factory::GetConstant()! requested=%d", channel_info.module_type);
579cerr << str << endl;
580throw JException(str);
581
582return -1.; // should never reach here!
583}
584}
585*/