57 #include "StBbcTriggerDetector.h"
59 #include "tables/St_dst_TrgDet_Table.h"
60 #include "StTriggerData.h"
62 static const char rcsid[] =
"$Id: StBbcTriggerDetector.cxx,v 2.14 2009/11/23 16:34:05 fisyak Exp $";
68 memset(mBeg,0,mEnd-mBeg);
73 StBbcTriggerDetector::StBbcTriggerDetector(
const dst_TrgDet_st& t)
75 int east_q_map[24] = { 8 , 5 , 4 , 40 , 37 , 36 , 7 , 6 ,
76 3 , 2 , 1 , 39 , 38 , 35 , 34 , 33 ,
77 72 , 71 , 70 , 69 , 68 , 67 , 66 , 65 };
78 int east_t_map[16] = { 16 , 13 , 12 , 48 , 45 , 44 , 15 , 14 ,
79 11 , 10 , 9 , 47 , 46 , 43 , 42 , 41 };
80 int west_q_map[24] = { 24 , 21 , 20 , 56 , 53 , 52 , 23 , 22 ,
81 19 , 18 , 17 , 55 , 54 , 51 , 50 , 49 ,
82 80 , 79 , 78 , 77 , 76 , 75 , 74 , 73 };
83 int west_t_map[16] = { 32 , 29 , 28 , 64 , 61 , 60 , 31 , 30 ,
84 27 , 26 , 25 , 63 , 62 , 59 , 58 , 57 };
86 memset(mBeg,0,mEnd-mBeg);
90 mAdc[i ] = (
unsigned short) t.BBC[east_q_map[i]-1];
91 mAdc[i+24] = (
unsigned short) t.BBC[west_q_map[i]-1];
94 mTdc[i ] = (
unsigned short) t.BBC[east_t_map[i]-1];
95 mTdc[i+24] = (
unsigned short) t.BBC[west_t_map[i]-1];
100 StBbcTriggerDetector::StBbcTriggerDetector(
const StTriggerData& t)
110 memset(mBeg,0,mEnd-mBeg);
118 for (i=0; i<24; i++){
119 mAdc[i ] = (
unsigned short) t.bbcADC(east, i+1);
120 mAdc[i+24] = (
unsigned short) t.bbcADC(west, i+1);
122 for (i=0; i<maxt; i++){
123 mTdc[i ] = (
unsigned short) t.bbcTDC(east, i+1);
124 mTdc[i+24] = (
unsigned short) t.bbcTDC(west, i+1);
126 mDSMVTX=t.bbcTimeDifference();
129 StBbcTriggerDetector::~StBbcTriggerDetector() {}
132 StBbcTriggerDetector::adc(
unsigned int pmt)
const
141 StBbcTriggerDetector::tdc(
unsigned int pmt)
const
150 StBbcTriggerDetector::bbcRegister(
unsigned int n)
const
152 if (n < mMaxRegisters)
159 StBbcTriggerDetector::pedestalData(
unsigned int n)
const
168 StBbcTriggerDetector::scalar(
unsigned int n)
const
177 StBbcTriggerDetector::setAdc(
unsigned int pmt,
unsigned short val)
179 if (pmt < mMaxPMTs) mAdc[pmt] = val;
183 StBbcTriggerDetector::setTdc(
unsigned int pmt,
unsigned short val)
185 if (pmt < mMaxPMTs) mTdc[pmt] = val;
189 StBbcTriggerDetector::setRegister(
unsigned int id,
unsigned short val)
191 if (
id < mMaxRegisters) mReg[id] = val;
195 StBbcTriggerDetector::setPedestal(
unsigned int id,
unsigned short val)
197 if (
id < mMaxPedData) mPed[id] = val;
201 StBbcTriggerDetector::setScalar(
unsigned int id,
unsigned int val)
203 if (
id < mMaxScalars) mScl[id] = val;
207 StBbcTriggerDetector::nHitEast()
211 for (
int i=0; i<8; i++) {
if (tdc(i)>0 && tdc(i)<1500) {nhit++;}}
213 else if (mYear==2003) {
214 for (
int i=0; i<16; i++) {
if (adc(i)>5) {nhit++;}}
217 cerr <<
"StBbcTriggerDetector::nHitEast: No longer supported after 2003. Do not use!" << endl;
223 StBbcTriggerDetector::nHitWest()
227 for (
int i=0; i<8; i++) {
if (tdc(i+16)>0 && tdc(i+16)<1500) {nhit++;}}
229 else if (mYear==2003) {
230 for (
int i=0; i<16; i++) {
if (adc(i+24)>5) {nhit++;}}
233 cerr <<
"StBbcTriggerDetector::nHitWest: No longer supported after 2003. Do not use!" << endl;
239 StBbcTriggerDetector::nHitEastLarge()
243 for (
int i=8; i<15; i++) {
if (tdc(i)>0 && tdc(i)<1500) {nhit++;}}
245 else if (mYear==2003) {
246 for (
int i=16; i<24; i++) {
if (adc(i)>5) {nhit++;}}
249 cerr <<
"StBbcTriggerDetector::nHitEastlarge: No longer supported after 2003. Do not use!" << endl;
255 StBbcTriggerDetector::nHitWestLarge()
259 for (
int i=8; i<15; i++) {
if (tdc(i+16)>0 && tdc(i+16)<1500) {nhit++;}}
261 else if (mYear==2003) {
262 for (
int i=16; i<24; i++) {
if (adc(i+24)>5) {nhit++;}}
265 cerr <<
"StBbcTriggerDetector::nHitWestLarge: No longer supported after 2003. Do not use!" << endl;
271 StBbcTriggerDetector::nHit() {
return nHitEast()+nHitWest();}
274 StBbcTriggerDetector::nHitLarge() {
return nHitEastLarge()+nHitWestLarge();}
277 StBbcTriggerDetector::nHitAll() {
return nHit()+nHitLarge();}
280 StBbcTriggerDetector::adcSumEast()
284 for (
int i=0; i<8; i++){sum+=adc(i);}
286 else if (mYear>=2003) {
287 for (
int i=0; i<16; i++){sum+=adc(i);}
293 StBbcTriggerDetector::adcSumWest()
297 for (
int i=0; i<8; i++){sum+=adc(i+16);}
299 else if (mYear>=2003) {
300 for (
int i=0; i<16; i++){sum+=adc(i+24);}
306 StBbcTriggerDetector::adcSumEastLarge()
310 for (
int i=8; i<15; i++){sum+=adc(i);}
312 else if (mYear>=2003) {
313 for (
int i=16; i<24; i++){sum+=adc(i);}
319 StBbcTriggerDetector::adcSumWestLarge()
323 for (
int i=8; i<15; i++){sum+=adc(i);}
325 else if (mYear>=2003) {
326 for (
int i=16; i<24; i++){sum+=adc(i+24);}
332 StBbcTriggerDetector::adcSum(){
return adcSumEast()+adcSumWest();}
335 StBbcTriggerDetector::adcSumLarge(){
return adcSumEastLarge()+adcSumWestLarge();}
338 StBbcTriggerDetector::adcSumAll() {
return adcSum()+adcSumLarge();}
341 StBbcTriggerDetector::tdcEarliestEast()
344 unsigned short earliest=2000;
345 for (
int i=0; i<8; i++){
346 if (tdc(i)>0 && tdc(i)<earliest ) earliest=tdc(i);
353 else if (mYear==2003){
354 unsigned short earliest=0;
355 for (
int i=0; i<16; i++){
356 if (tdc(i)<245 && tdc(i)>earliest && adc(i)>5 ) earliest=tdc(i);
364 cerr <<
"StBbcTriggerDetector::tdcEarliestEast: No longer supported after 2003. Do not use!" << endl;
370 StBbcTriggerDetector::tdcEarliestWest()
373 unsigned short earliest=2000;
374 for (
int i=16; i<24; i++){
375 if (tdc(i)>0 && tdc(i)<earliest ) earliest=tdc(i);
382 else if (mYear==2003){
383 unsigned short earliest=0;
384 for (
int i=24; i<40; i++){
385 if (tdc(i)<245 && tdc(i)>earliest && adc(i)>5 ) earliest=tdc(i);
393 cerr <<
"StBbcTriggerDetector::tdcEarliestWest: No longer supported after 2003. Do not use!" << endl;
399 StBbcTriggerDetector::zVertex()
402 unsigned short east=tdcEarliestEast();
403 unsigned short west=tdcEarliestWest();
404 if (east<2000 && west<2000 && east!=0 && west!=0)
405 return (
float(east-west))*5.0;
409 else if (mYear==2003){
410 unsigned short east=tdcEarliestEast();
411 unsigned short west=tdcEarliestWest();
412 if (east>0 && west>0)
413 return float(west-east)*3.0;
419 float tc[4]={49.89, -3.155, 4.537, -0.1471};
421 float offset[2][16] = {
422 {-2.00982, 4.09827, 4.83372, -4.71373,
423 -8.33428, -8.51657, -2.16193, 14.6726,
424 1.61522, 0.605228, 4.98944, -1.86768,
425 -2.46653, -2.70569, -4.33065, -5.07069},
426 {-4.90599, -2.62884, -2.87498, 5.58336,
427 0.100682, 0.065195, -0.35114, -2.96953,
428 1.2031, 2.94575, -1.93577, -1.13641,
429 1.86768, 4.27345, 7.0431, -1.16071}
431 float maxtac[2]={0.0, 0.0};
432 for(
int iew=0; iew<2; iew++){
433 for(
int ich=0; ich<16; ich++){
435 float tac = tdc(j) - offset[iew][ich] - (tc[0]+tc[1]/TMath::Exp(-tc[2]*TMath::Power(adc(j),tc[3])))/slope;
436 if(adc(j)>10 && tac<200 && tac>maxtac[iew]) {maxtac[iew]=tac;}
439 if(maxtac[0]>0.0 && maxtac[1]>0.0){
440 float zvt=slope*(maxtac[1]-maxtac[0])+off;
448 StBbcTriggerDetector::dump()
451 cout <<
"BBC data (" << mYear <<
") dump" << endl;
453 cout <<
"East small tile ADC ";
for (i=0; i<8; i++){cout << adc(i) <<
" ";}; cout << endl;
454 cout <<
"East large tile ADC ";
for (i=0; i<8; i++){cout << adc(i+8) <<
" ";}; cout << endl;
455 cout <<
"West small tile ADC ";
for (i=0; i<8; i++){cout << adc(i+16) <<
" ";}; cout << endl;
456 cout <<
"West large tile ADC ";
for (i=0; i<8; i++){cout << adc(i+24) <<
" ";}; cout << endl;
457 cout <<
"East small tile TDC ";
for (i=0; i<8; i++){cout << tdc(i) <<
" ";}; cout << endl;
458 cout <<
"East large tile TDC ";
for (i=0; i<8; i++){cout << tdc(i+8) <<
" ";}; cout << endl;
459 cout <<
"West small tile TDC ";
for (i=0; i<8; i++){cout << tdc(i+16) <<
" ";}; cout << endl;
460 cout <<
"West large tile TDC ";
for (i=0; i<8; i++){cout << tdc(i+24) <<
" ";}; cout << endl;
461 cout <<
"Number of hits east " << nHitEast() <<
" west " << nHitWest() <<
" Total " << nHit() << endl;
462 cout <<
"ADC sum east " << adcSumEast() <<
" west " << adcSumWest() <<
" Total " << adcSum() << endl;
463 cout <<
"z vertex position = " << zVertex() <<
" cm" << endl;
464 cout <<
"Registers = ";
for (i=0; i<mMaxRegisters; i++){cout << bbcRegister(i) <<
" ";}; cout << endl;
465 cout <<
"Scalars = ";
for (i=0; i<mMaxScalars; i++){cout << scalar(i) <<
" ";}; cout << endl;
467 else if (mYear>2002) {
468 cout <<
"East small tile ADC ";
for (i=0; i<16; i++){cout << adc(i) <<
" ";}; cout << endl;
469 cout <<
"West small tile ADC ";
for (i=0; i<16; i++){cout << adc(i+24) <<
" ";}; cout << endl;
470 cout <<
"East small tile TDC ";
for (i=0; i<16; i++){cout << tdc(i) <<
" ";}; cout << endl;
471 cout <<
"West small tile TDC ";
for (i=0; i<16; i++){cout << tdc(i+24) <<
" ";}; cout << endl;
472 cout <<
"East large tile ADC ";
for (i=0; i<8; i++) {cout << adc(i+16) <<
" ";}; cout << endl;
473 cout <<
"West large tile ADC ";
for (i=0; i<8; i++) {cout << adc(i+40) <<
" ";}; cout << endl;
475 cout <<
"East large tile TDC ";
for (i=0; i<8; i++) {cout << tdc(i+16) <<
" ";}; cout << endl;
476 cout <<
"West large tile TDC ";
for (i=0; i<8; i++) {cout << tdc(i+40) <<
" ";}; cout << endl;
478 cout <<
"Number of hits east " << nHitEast() <<
" west " << nHitWest() <<
" Total " << nHit() << endl;
479 cout <<
"ADC sum east " << adcSumEast() <<
" west " << adcSumWest() <<
" Total " << adcSum() << endl;
480 cout <<
"Earliest TDC east " << tdcEarliestEast() <<
" west " << tdcEarliestWest() << endl;
481 cout <<
"z vertex position = " << zVertex() <<
" cm" << endl;