// $Id$ // // File: DBCAL_TDCHit_factory.cc // Created: Thu Aug 10 14:45:37 EDT 2006 // Creator: davidl (on Darwin swire-b241.jlab.org 8.7.0 powerpc) // #include #include #include "DBCAL_TDCHit_factory.h" #include "DEventSourceET/DTDC.h" #include "DEventSourceET/DTrigger.h" #include "TRIGGER/DTRIGGER_TDCHit.h" //------------------ // brun //------------------ jerror_t DBCAL_TDCHit_factory::brun(JEventLoop *eventLoop, int runnumber) { // The following came from COSMIC run 2252 int offsets[36] = { -42, -41, -43, -33, -26, -26, -39, -39, -37, -30, -32, -27, -43, -40, -39, -35, -33, -25, -40, -40, -42, -29, -33, -24, -38, -38, -39, -29, -37, -25, -39, -41, -40, -22, -33, -32, }; // Set TDC offsets here. for(int i=0;i<36;i++){ this->offsets[i] = offsets[i]; //this->offsets[i] = 0; } return NOERROR; } //------------------ // evnt //------------------ jerror_t DBCAL_TDCHit_factory::evnt(JEventLoop *loop, int eventnumber) { vector dtdcs; vector trigs; vector trig_tdcs; loop->Get(dtdcs); loop->Get(trigs); loop->Get(trig_tdcs); //int latch = trigs.size() ? trigs[0]->latch:0; // slot 10: // channels 0-15 BCALN2-BCALN18 (excluding BCALN13) // channels 16-31 BCALS2-BCALS18 (excluding BCALS13) // // slot 11: // channels 2,3,4,5 BCALN1,BCALN13,BCALS1,BCALS13 // channel 19 T12 // channel 20 T11 // channel 21 T10 // channel 22 T9 // channel 23 T8 // channel 24 T7 // channel 25 T6 // channel 26 T5 // channel 27 T4 // channel 28 T3 // channel 29 T2 // channel 30 T1 // channel 31 unused // We need to find the TDC value representing the trigger. // Look through the DTRIGGER_TDCHit objects for the one // at t=0 and use its TDC value for the reference. float min_t = 1.0E6; int tdc_ref = 0; // holds TDC value of trigger that caused event int trig_ref = 1000000; // holds trigger bit used for ref (1-8) for(unsigned int i=0; it)t); tdc_ref=tdc->tdc; trig_ref = tdc->tid; } } for(unsigned int i=0; icrate!=0x1)continue; if((tdc->slot!=10) && (tdc->slot!=11))continue; // Translate crate, slot, channel to section id and end int cid=(tdc->channel%16)+2; // channels 0 and 16 are both cid=2 if(cid>=13)cid++; // skip cid=13 int end = tdc->channel<16; // BCALN is in channels 0-15, BCALS 16-31 if(tdc->slot == 11){ switch(tdc->channel){ // !!! NOTE !!! // The values of "end" here are reversed from what we thought // they should be due to evidence Alex D. found in the cosmic // data that they were mis-cabled. 6/22/07 D. Lawrence case 2: end=1; cid= 1; break; case 3: end=1; cid=13; break; case 4: end=0; cid= 1; break; case 5: end=0; cid=13; break; default: continue; } } DBCAL_TDCHit *hit = new DBCAL_TDCHit; hit->cid = cid; hit->layer = 1 + ((cid-1)%6); hit->sector = 1 + ((cid-1)/6); hit->end = end; hit->tdc = tdc->tdc; hit->t = hit->tdc - tdc_ref; hit->t *= 57.0E-12/1.0E-9; // convert to ns hit->t -= offsets[hit->cid-1 + (hit->end ? 18:0)]; // timing offset _data.push_back(hit); } return NOERROR; } //------------------ // toString //------------------ const string DBCAL_TDCHit_factory::toString(void) { // Ensure our Get method has been called so _data is up to date Get(); if(_data.size()<=0)return string(); // don't print anything if we have no data! printheader("cid: layer: sector: end: tdc: t(ns):"); for(unsigned int i=0; i<_data.size(); i++){ DBCAL_TDCHit *hit = _data[i]; printnewrow(); printcol("%d", hit->cid); printcol("%d", hit->layer); printcol("%d", hit->sector); printcol("%d", hit->end); printcol("%d", hit->tdc); printcol("%4.3f", hit->t); printrow(); } return _table; }