// $Id$ // // File: DTRIGGER_TDCHit_factory.cc // Created: Fri Spe 22 EDT 2006 // Creator: davidl (on Darwin swire-b241.jlab.org 8.7.0 powerpc) // #include #include "DTRIGGER_TDCHit_factory.h" #include "DEventSourceET/DTDC.h" #include "DEventSourceET/DTrigger.h" //------------------ // brun //------------------ jerror_t DTRIGGER_TDCHit_factory::brun(JEventLoop *eventLoop, int runnumber) { return NOERROR; } //------------------ // evnt //------------------ jerror_t DTRIGGER_TDCHit_factory::evnt(JEventLoop *loop, int eventnumber) { vector dtdcs; vector trigs; loop->Get(dtdcs); loop->Get(trigs); int latch = trigs.size() ? trigs[0]->latch:0; // slot 11: // 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. We look // through all triggers corresponding to bits set in the latch word. // Of these, the one with the smallest TDC value(i.e. latest time) // should be the trigger causing signal. int tdc_ref = (int)1E6; // holds TDC value of trigger that caused event int trig_ref = 0; // holds trigger bit used for ref (1-8) for(unsigned int i=0; icrate!=0x1)continue; if(tdc->slot!=11)continue; int trigbit = 30-tdc->channel; if(trigbit<0 || trigbit>=12)continue; if((latch>>trigbit)&0x1){ if(tdc->tdctdc; trig_ref = trigbit+1; } } } for(unsigned int i=0; icrate!=0x1)continue; if(tdc->slot!=11)continue; // Translate crate, slot, channel to section id and end int tid= 31-tdc->channel; if(tid<1 || tid>12)continue; DTRIGGER_TDCHit *hit = new DTRIGGER_TDCHit; hit->tid = tid; hit->tdc = tdc->tdc; hit->t = hit->tdc - tdc_ref; hit->t *= 57.0E-12/1.0E-9; // convert to ns _data.push_back(hit); } return NOERROR; } //------------------ // toString //------------------ const string DTRIGGER_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("tid: tdc: t(ns):"); for(unsigned int i=0; i<_data.size(); i++){ DTRIGGER_TDCHit *hit = _data[i]; printnewrow(); printcol("%d", hit->tid); printcol("%d", hit->tdc); printcol("%4.3f", hit->t); printrow(); } return _table; }