| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

ROsFeeReadoutTool Class Reference

#include <ROsFeeReadoutTool.h>

Inheritance diagram for ROsFeeReadoutTool:

[legend]
Collaboration diagram for ROsFeeReadoutTool:
[legend]
List of all members.

Public Types

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
enum  Status

Public Member Functions

 ROsFeeReadoutTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ROsFeeReadoutTool ()
virtual StatusCode mutate (DayaBay::SimReadoutHeader *roHeader, std::vector< DayaBay::ReadoutTriggerDataPkg * > &trigDataPkg, const DayaBay::ElecHeader &elecHeader)
 Modify the event.
virtual StatusCode initialize ()
virtual StatusCode finalize ()
INTupleSvcntupleSvc () const
INTupleSvcevtColSvc () const
IDataProviderSvcdetSvc () const
IDataProviderSvcevtSvc () const
IIncidentSvcincSvc () const
IChronoStatSvcchronoSvc () const
IHistogramSvchistoSvc () const
IAlgContextSvccontextSvc () const
DataObjectput (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
DataObjectput (DataObject *object, const std::string &address, const bool useRootInTES=true) const
Gaudi::Utils::GetData< TYPE
>::return_type 
get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Gaudi::Utils::GetData< TYPE
>::return_type 
get (const std::string &location, const bool useRootInTES=true) const
TYPE * getDet (IDataProviderSvc *svc, const std::string &location) const
TYPE * getDet (const std::string &location) const
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
bool exist (const std::string &location, const bool useRootInTES=true) const
bool existDet (IDataProviderSvc *svc, const std::string &location) const
bool existDet (const std::string &location) const
TYPE * getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
TYPE * getOrCreate (const std::string &location, const bool useRootInTES=true) const
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
SERVICE * svc (const std::string &name, const bool create=true) const
IUpdateManagerSvcupdMgrSvc () const
IDataProviderSvcfastContainersSvc () const
StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
StatusCode Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
MsgStreammsgStream (const MSG::Level level) const
MsgStreamalways () const
MsgStreamfatal () const
MsgStreamerr () const
MsgStreamerror () const
MsgStreamwarning () const
MsgStreaminfo () const
MsgStreamdebug () const
MsgStreamverbose () const
MsgStreammsg () const
const Statisticscounters () const
StatEntitycounter (const std::string &tag) const
MSG::Level msgLevel () const
bool msgLevel (const MSG::Level level) const
void resetMsgStream () const
bool typePrint () const
bool propsPrint () const
bool statPrint () const
bool errorsPrint () const
long printStat (const MSG::Level level=MSG::ALWAYS) const
long printErrors (const MSG::Level level=MSG::ALWAYS) const
long printProps (const MSG::Level level=MSG::ALWAYS) const
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
StatusCode runUpdate ()
TransientFastContainer< T > * getFastContainer (const std::string &location, typename TransientFastContainer< T >::size_type initial=0)
StatusCode release (const IInterface *interface) const
virtual unsigned long release ()
const std::string & context () const
const std::string & rootInTES () const
double globalTimeOffset () const
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual unsigned long addRef ()
virtual const std::string & name () const
virtual const std::string & type () const
virtual const IInterfaceparent () const
virtual StatusCode configure ()
virtual StatusCode start ()
virtual StatusCode stop ()
virtual StatusCode terminate ()
virtual StatusCode reinitialize ()
virtual StatusCode restart ()
virtual Gaudi::StateMachine::State FSMState () const
virtual Gaudi::StateMachine::State targetFSMState () const
virtual StatusCode sysInitialize ()
virtual StatusCode sysStart ()
virtual StatusCode sysStop ()
virtual StatusCode sysFinalize ()
virtual StatusCode sysReinitialize ()
virtual StatusCode sysRestart ()
virtual StatusCode setProperty (const Property &p)
virtual StatusCode setProperty (const std::string &s)
virtual StatusCode setProperty (const std::string &n, const std::string &v)
StatusCode setProperty (const std::string &name, const TYPE &value)
virtual StatusCode getProperty (Property *p) const
virtual const PropertygetProperty (const std::string &name) const
virtual StatusCode getProperty (const std::string &n, std::string &v) const
virtual const std::vector<
Property * > & 
getProperties () const
PropertyMgrgetPropertyMgr ()
ISvcLocatorserviceLocator () const
ISvcLocatorsvcLoc () const
IMessageSvcmsgSvc () const
IToolSvctoolSvc () const
StatusCode setProperties ()
StatusCode service (const std::string &name, T *&svc, bool createIf=true) const
StatusCode service (const std::string &type, const std::string &name, T *&svc) const
void declInterface (const InterfaceID &, void *)
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
IAuditorSvcauditorSvc () const
IMonitorSvcmonitorSvc () const
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
virtual const std::string & type () const =0
virtual const IInterfaceparent () const =0
virtual StatusCode configure ()=0
virtual StatusCode start ()=0
virtual StatusCode stop ()=0
virtual StatusCode terminate ()=0
virtual StatusCode reinitialize ()=0
virtual StatusCode restart ()=0
virtual Gaudi::StateMachine::State FSMState () const =0
virtual StatusCode sysInitialize ()=0
virtual StatusCode sysStart ()=0
virtual StatusCode sysStop ()=0
virtual StatusCode sysFinalize ()=0
virtual StatusCode sysReinitialize ()=0
virtual StatusCode sysRestart ()=0
virtual unsigned long refCount () const =0
virtual const std::string & name () const =0
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)=0
virtual unsigned long addRef ()=0
virtual unsigned long release ()=0

Static Public Member Functions

static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
 Retrieve interface ID.

Public Attributes

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR

Protected Types

typedef std::map< std::string,
StatEntity
Statistics
typedef std::map< std::string,
unsigned int > 
Counter
typedef std::vector< IAlgTool * > AlgTools
typedef std::pair< IInterface *,
std::string > 
ServiceEntry
typedef std::vector< ServiceEntryServices

Protected Member Functions

StatusCode releaseTool (const IAlgTool *tool) const
StatusCode releaseSvc (const IInterface *svc) const
int outputLevel () const
virtual unsigned long refCount () const
IntegerPropertyoutputLevelProperty ()
void initOutputLevel (Property &prop)

Static Protected Attributes

static const bool IgnoreRootInTES
static const bool UseRootInTES

Private Member Functions

virtual StatusCode makeReadouts (DayaBay::SimReadoutHeader *roHeader, std::vector< DayaBay::ReadoutTriggerDataPkg * > &trigDataPkg, const DayaBay::ElecHeader &elecHeader)
DayaBay::ReadoutPmtCratereadoutCrate (const DayaBay::ReadoutTriggerDataFrame *tdf, const DayaBay::ElecFeeCrate *cr, Context context)
DayaBay::ReadoutPmtChannelreadoutChannel (const DayaBay::ReadoutTriggerDataFrame *tdf, const DayaBay::ElecFeeChannel *ch, DayaBay::FeeChannelId channelId, Context context)

Private Attributes

IROsFeeTdcToolm_tdcTool
IROsFeeWaveformToolm_waveformTool
IROsFadcReadoutToolm_fadcTool
bool m_enablePeakReadout
bool m_enableWaveformReadout
bool m_enableFadcReadout
std::string m_tdcToolName
std::string m_waveformToolName
std::string m_fadcToolName
std::string m_simDataSvcName
ISimDataSvcm_simDataSvc
std::vector< std::string > m_detectorsToProcess
std::set< DayaBay::Detectorm_detectors
std::vector< int > m_roCycles
int m_readoutLength
int m_triggerLatency
int m_peakFindingLength
int m_peakFindingOffset
bool m_peakFindingOverlap
int m_readoutOffset
int m_preAdcOffset
int m_fadcOffset
int m_fadcLength
int m_nhitCycles
int m_eSumCycles
int m_maxFineAdc

Detailed Description

Definition at line 40 of file ROsFeeReadoutTool.h.


Constructor & Destructor Documentation

ROsFeeReadoutTool::ROsFeeReadoutTool ( const std::string &  type,
const std::string &  name,
const IInterface parent 
)

Definition at line 26 of file ROsFeeReadoutTool.cc.

00029   : GaudiTool(type,name,parent)
00030 {
00031   declareInterface< IROsReadoutTool >(this) ;
00032   // for now add all but RPC's as default.
00033   m_detectorsToProcess.push_back("DayaBayAD1");
00034   m_detectorsToProcess.push_back("DayaBayAD2");
00035   m_detectorsToProcess.push_back("DayaBayIWS");
00036   m_detectorsToProcess.push_back("DayaBayOWS");
00037   m_detectorsToProcess.push_back("LingAoAD1");
00038   m_detectorsToProcess.push_back("LingAoAD2");
00039   m_detectorsToProcess.push_back("LingAoIWS");
00040   m_detectorsToProcess.push_back("LingAoOWS"); 
00041   m_detectorsToProcess.push_back("FarAD1");
00042   m_detectorsToProcess.push_back("FarAD2");
00043   m_detectorsToProcess.push_back("FarAD3");
00044   m_detectorsToProcess.push_back("FarAD4");
00045   m_detectorsToProcess.push_back("FarIWS");
00046   m_detectorsToProcess.push_back("FarOWS");
00047   
00048   declareProperty("SimDataSvcName",m_simDataSvcName="StaticSimDataSvc",
00049                   "Name of service to provide FEE channel properties for simulation");
00050   declareProperty("DetectorsToProcess",m_detectorsToProcess,
00051                   "List of detectors to process with this tool");
00052   declareProperty("EnablePeakReadout",m_enablePeakReadout=true,
00053                   "Switch on/off peak readout mode");
00054   declareProperty("EnableWaveformReadout",m_enableWaveformReadout=false,
00055                   "Switch on/off waveform readout mode");
00056   declareProperty("EnableFadcReadout", m_enableFadcReadout=false,
00057                   "Switch on/off FADC readout mode");
00058   declareProperty("WaveformTool", m_waveformToolName="ROsFeeAdcMultiTool", 
00059                   "Name of waveform readout tool");
00060   declareProperty("TdcTool", m_tdcToolName="ROsFeeTdcTool", 
00061                   "Name of tdc readout tool");
00062   declareProperty("FadcTool", m_fadcToolName="ROsFadcReadoutTool", 
00063                   "Name of fadc readout tool");      
00064 
00065   //Changed readout Length : (1200/1.5625 = 768)
00066   declareProperty("ReadoutLength",m_readoutLength=768,
00067                   "Length of readout window in 640Mhz clock cycles");
00068   //Changed trigger Latency to 980 (why ?)
00069   declareProperty("TriggerLatency",m_triggerLatency=980,
00070                   "Trigger latency in 640Mhz clock cycles");
00071   //Changed readout offset (200/1.5625 = 128)
00072   declareProperty("ReadoutOffset",m_readoutOffset=128,
00073                   "Offset of readout window from trigger tdc in 640Mhz clock cycles");
00074 
00075 
00076   declareProperty("PeakFindingLength",m_peakFindingLength=12,
00077                   "Length of peak finding window in 40Mhz clock cycles");
00078   declareProperty("PeakFindingOffset",m_peakFindingOffset=0,
00079                   "Offset of peak finding window from corresponding hit in 40Mhz clock cycles");                
00080   declareProperty("PeakFindingOverlap",m_peakFindingOverlap=true,
00081                   "Allow overlapping peakfinding for consecutive hits");
00082   declareProperty("PreAdcOffset",m_preAdcOffset=3,
00083                   "Offset of first PreADC cycle from start of ADC peak finding window in 40Mhz clock cycles");
00084   declareProperty("NhitCycles", m_nhitCycles = DayaBay::NhitCycles, "Nhit cycles");
00085   declareProperty("EsumCycles", m_eSumCycles = DayaBay::EsumCycles, "Esum cycles");
00086   declareProperty("FADCOffset", m_fadcOffset = 100, "FADC offset");
00087   declareProperty("FADCLength", m_fadcLength = 400, "FADC readout window legth");
00088   declareProperty("MaxFineAdc",m_maxFineAdc=3500,
00089                   "Maximum fine-range ADC value before using the coarse range");
00090 }

ROsFeeReadoutTool::~ROsFeeReadoutTool (  )  [virtual]

Definition at line 92 of file ROsFeeReadoutTool.cc.

00092 {}


Member Function Documentation

StatusCode ROsFeeReadoutTool::mutate ( DayaBay::SimReadoutHeader roHeader,
std::vector< DayaBay::ReadoutTriggerDataPkg * > &  trigDataPkg,
const DayaBay::ElecHeader elecHeader 
) [virtual]

Modify the event.

Implements IROsReadoutTool.

Definition at line 488 of file ROsFeeReadoutTool.cc.

00491 {     
00492     verbose() << "calling ROsFeeReadoutTool.mutate()" << endreq;
00493     return makeReadouts(roHeader,trigDataPkg,elecHeader);
00494 }

StatusCode ROsFeeReadoutTool::initialize (  )  [virtual]

Reimplemented from GaudiTool.

Definition at line 94 of file ROsFeeReadoutTool.cc.

00095 {
00096   std::vector<std::string>::iterator it;
00097   for(it=m_detectorsToProcess.begin();it!=m_detectorsToProcess.end();++it){
00098     short int detId = DayaBay::Detector::siteDetPackedFromString(*it);
00099     DayaBay::Detector det(detId);
00100     m_detectors.insert(det);
00101   }
00102   
00103   try {
00104       m_waveformTool = tool<IROsFeeWaveformTool>(m_waveformToolName) ;
00105     debug() << "Using \"" << m_waveformToolName 
00106             << "\" for waveform readout " << endreq; 
00107   }
00108   catch(const GaudiException& exg) {
00109       fatal() << "Failed to get Readout Tool: \"" 
00110               << m_waveformToolName << "\"" << endreq;
00111       return StatusCode::FAILURE;
00112   }
00113   try {
00114       m_tdcTool = tool<IROsFeeTdcTool>(m_tdcToolName) ;
00115       debug() << "Using \"" << m_tdcToolName 
00116             << "\" for TDC readout " << endreq;
00117   }
00118   catch(const GaudiException& exg) {
00119       fatal() << "Failed to get Readout Tool: \"" << m_tdcToolName << "\"" << endreq;
00120       return StatusCode::FAILURE;
00121   }
00122   try {
00123       m_fadcTool = tool<IROsFadcReadoutTool>(m_fadcToolName) ;
00124     debug() << "Using \"" << m_fadcToolName 
00125             << "\" for fadc readout " << endreq; 
00126   }
00127   catch(const GaudiException& exg) {
00128       fatal() << "Failed to get Readout Tool: \"" 
00129               << m_waveformToolName << "\"" << endreq;
00130       return StatusCode::FAILURE;
00131   }
00132   
00133   // Get PMT simulation input data service
00134   m_simDataSvc = svc<ISimDataSvc>(m_simDataSvcName,true);
00135 
00136   if( !m_enablePeakReadout && !m_enableWaveformReadout ) {
00137       error() << "All readout modes switched off" << endreq;
00138       return StatusCode::FAILURE;
00139   }
00140   if( m_enablePeakReadout )
00141       info() << "Peak readout mode enabled" << endreq;
00142   if( m_enableWaveformReadout )
00143       info() << "Waveform readout mode enabled" << endreq;
00144       
00145   return StatusCode::SUCCESS;
00146 }

StatusCode ROsFeeReadoutTool::finalize (  )  [virtual]

Reimplemented from GaudiTool.

Definition at line 148 of file ROsFeeReadoutTool.cc.

00149 {
00150   return StatusCode::SUCCESS;
00151 }

StatusCode ROsFeeReadoutTool::makeReadouts ( DayaBay::SimReadoutHeader roHeader,
std::vector< DayaBay::ReadoutTriggerDataPkg * > &  trigDataPkg,
const DayaBay::ElecHeader elecHeader 
) [private, virtual]

Definition at line 153 of file ROsFeeReadoutTool.cc.

00156 {
00157   debug() << "running makeReadouts() in FeeReadoutTool" << endreq;
00158   
00159   DayaBay::SimReadoutHeader::SimReadoutContainer& outputReadouts 
00160     = roHeader->readouts();
00161   
00162   Context context = roHeader->context();
00163   //Get Crate Map
00164   const DayaBay::ElecCrateHeader *ech = elecHeader.crateHeader();
00165   const DayaBay::ElecCrateHeader::CrateMap crMap = ech->crates();
00166   DayaBay::ElecCrateHeader::CrateMap::const_iterator crIt;
00167     
00168   std::vector<DayaBay::ReadoutTriggerDataPkg*>::iterator pkgIt; 
00169 
00170   //Loop over All trigger data packages
00171   for(pkgIt = trigDataPkg.begin(); pkgIt != trigDataPkg.end(); ++pkgIt)
00172   {
00173     DayaBay::Detector det((*pkgIt)->detector());
00174     if(m_detectors.find(det) != m_detectors.end()){
00175       crIt = crMap.find(det);
00176       const DayaBay::ElecFeeCrate *crate; 
00177       if(crIt == crMap.end()){
00178         if((*pkgIt)->frames().size()==0){
00179           fatal() << "Trying to process a trigger for " << det.detName()
00180                   << " But Package Has No Frames" << endreq;
00181           return StatusCode::FAILURE;
00182         }else{
00183           fatal() << "Trying to process a trigger for " << det.detName()
00184                   << " But no crate exists -- skipping" << endreq;
00185           return StatusCode::FAILURE;
00186         }
00187         crate = 0;
00188       }else{
00189         crate = dynamic_cast<const DayaBay::ElecFeeCrate*>(crIt->second);
00190         debug() << "Processing a trigger for " << det.detName()
00191                   << " found crate at " << crate << endreq;
00192       }
00193       if(crate != 0){ // if the crate exists read it out.
00194         debug()<<"Reading out 1 trigger with: "
00195                <<((*pkgIt)->frames().size())-1
00196                <<" masked triggers."<<endreq;
00197         
00198         const DayaBay::ReadoutTriggerDataFrame *tdf = (*pkgIt)->frames().at(0);
00199         
00200         DayaBay::ReadoutPmtCrate *crateReadout = readoutCrate(tdf,crate,context);
00201        
00202         outputReadouts.push_back(new DayaBay::SimReadout(crateReadout,
00203                                                          roHeader)); 
00204         
00206         (*pkgIt)->setReadout(crateReadout);
00207         crateReadout->setTriggerDataPkg(*pkgIt);
00208         
00209         verbose() << "set readout:\n" << (**pkgIt) << endreq;
00210         
00211         if( m_enableFadcReadout )
00212         {
00213                 debug() << " Trying FADC Readout " << endreq;
00214         
00215                 unsigned int triggerCycle = tdf->cycle();        
00216 
00217                 int start = int((triggerCycle*m_eSumCycles)/m_nhitCycles)+m_fadcOffset; 
00218         
00219                 int stop = start+m_fadcLength;  
00220 
00221                 m_fadcTool->readoutFADC(crate,crateReadout,start,stop);
00222                 debug() << "readout map size: " << (crateReadout->fadcReadout()).size() << endreq;
00223         
00224         debug() << " Done reading out FADC" << endreq;
00225         }
00226       }
00227     }else{
00228       verbose() << "Found Trigger For " << det.detName()
00229                 << "but this tool is not supposed "
00230                 << "to process that detector type "
00231                 << "check properties to configure."
00232                 << endreq;
00233     }
00234   }
00235   return StatusCode::SUCCESS;                             
00236 }

DayaBay::ReadoutPmtCrate * ROsFeeReadoutTool::readoutCrate ( const DayaBay::ReadoutTriggerDataFrame tdf,
const DayaBay::ElecFeeCrate cr,
Context  context 
) [private]

Definition at line 238 of file ROsFeeReadoutTool.cc.

00240 { 
00241   TimeStamp triggerTime(cr->header()->header()->earliest());
00242   triggerTime.Add( tdf->cycle() / double(DayaBay::NhitFrequencyHz) );
00243   DayaBay::ReadoutPmtCrate *out_readout 
00244     = new DayaBay::ReadoutPmtCrate(cr->detector(),0, triggerTime, tdf->triggerType());  
00245   
00246   DayaBay::ReadoutPmtCrate::PmtChannelReadouts ro_chMap;
00247   
00248   const DayaBay::ElecFeeCrate::ChannelData& chmap = cr->channelData();
00249   DayaBay::ElecFeeCrate::ChannelData::const_iterator chIt;
00250   
00251   for(chIt = chmap.begin(); chIt != chmap.end() ; ++chIt){
00252     DayaBay::ReadoutPmtChannel *ro_ch = readoutChannel(tdf,&(chIt->second),
00253                                                        chIt->first,context);
00254     if (ro_ch == 0) continue;         // test to see if channel has readout
00255     ro_ch->setChannelId(chIt->first); // set these here since an ElecFeeChannel
00256     ro_ch->setReadout(out_readout);   //     does not know about them
00257     ro_chMap[chIt->first] = *ro_ch;   // copy the value by it's address to the map
00258     ro_ch->setReadout(0);             // reset Readout, to avoid double deletion
00259     delete ro_ch;                     // delete unnecessary copy
00260   }
00261   
00262   out_readout->setChannelReadout(ro_chMap);
00263   return out_readout; 
00264 }

DayaBay::ReadoutPmtChannel * ROsFeeReadoutTool::readoutChannel ( const DayaBay::ReadoutTriggerDataFrame tdf,
const DayaBay::ElecFeeChannel ch,
DayaBay::FeeChannelId  channelId,
Context  context 
) [private]

Definition at line 266 of file ROsFeeReadoutTool.cc.

00271 {  
00272   // Get the simulation properties for this channel
00273    int task = 0;
00274   ServiceMode svcMode(context, task);
00275   const DayaBay::FeeSimData* feeSimData = 
00276     m_simDataSvc->feeSimData(channelId, svcMode);
00277   if(!feeSimData){
00278     error() << "No Simulation input properties for FEE channel: " 
00279             << channelId << endreq;
00280   }
00281 
00282   // convert trigger clock cycle from NhitFrequencyHz to TdcFrequencyHz
00283   DayaBay::ReadoutPmtChannel *ro_ch = new DayaBay::ReadoutPmtChannel();
00284   int nHitTrigCycle = tdf->cycle();
00285   int tdcTrigCyc = (int)(double(nHitTrigCycle) * 
00286      double(DayaBay::TdcCycles)/double(DayaBay::NhitCycles) + 0.5);
00287   verbose() << "Conv TDC Clock Cycle: " << tdcTrigCyc << endreq;
00288   std::vector<int> hit = feeChannel->hit(); 
00289   int tdcSize = hit.size() *(1+int(DayaBay::TdcCycles/DayaBay::NhitCycles));
00290 
00291   // Find clock cycle of readout window start and end in TDC frequency
00292   int tdcFirst;    
00293   if( (int)tdcTrigCyc - m_readoutOffset < 0){
00294     verbose() << "Invalid Readout TDC Start Cycle " 
00295         << (int)tdcTrigCyc - m_readoutOffset
00296               << " Using 0" << endreq;
00297     tdcFirst = 0;
00298   } else tdcFirst = tdcTrigCyc - m_readoutOffset;
00299   verbose() << "TDC First in ns: " << tdcFirst *1.5625 << endreq;
00300   
00301   int tdcLast;   
00302   if( tdcTrigCyc - m_readoutOffset + m_readoutLength > tdcSize){
00303      verbose() << "Invalid Readout TDC Last Cycle " 
00304          << tdcTrigCyc - m_readoutOffset + m_readoutLength
00305          << " Using " << tdcSize << endreq;
00306      tdcLast = tdcSize;
00307   } else tdcLast = tdcTrigCyc - m_readoutOffset + m_readoutLength;
00308   verbose() << "TDC Last in ns: " << tdcLast *1.5625 << endreq;
00309   verbose() << "reading out tdc window [ " 
00310          << tdcFirst << "," << tdcLast << " )" << endreq;
00311   
00312   // Compute common stop clock cycle for TDC values
00313   int tdcStopCycle = tdcTrigCyc + m_triggerLatency;
00314   const DayaBay::DigitalSignal* adc;
00315   int adcFirst;
00316   int adcLast;
00317   int adcPedFirst;
00318       
00319   // Compute variables for peak readout mode
00320   if ( m_enablePeakReadout ){                                            
00321     // Read out clock numbers which represent the time when signal crosses threshold 
00322     const std::vector<int>& tdcOrg = feeChannel->tdc();
00323     std::vector<int> tdc_vec;
00324     StatusCode sc = m_tdcTool->readoutTdc(tdcOrg,tdcFirst,tdcLast,tdc_vec);
00325     if( !sc.isSuccess() || tdc_vec.empty() ) {
00326         delete ro_ch;
00327         return 0;
00328     }
00329     
00330     // Loop over TDC values to compute corresponding peak ADC values and peaking clock cycles
00331     int nTdc = tdc_vec.size();
00332     std::vector<int> tdc_out(nTdc); 
00333     std::vector<int> tdcHitCount_out(nTdc);
00334     std::vector<int> adc_out(nTdc); 
00335     std::vector<int> adcCycle_out(nTdc);
00336     std::vector<int> adcRange_out(nTdc);
00337     std::vector<int> preAdc_out(nTdc);
00338 
00339     DayaBay::FeeGain::FeeGain_t gain; 
00340     int currentAdc;
00341     
00342     int currentTdc = -1000;  
00343     
00344     for ( int i = 0; i < nTdc; i++ ){
00345       // Check if preceeding peak finding is finished
00346       if ( tdc_vec[i] - currentTdc  > m_peakFindingLength * 16 || m_peakFindingOverlap == true){
00347         
00348         // Assume the high gain ADC will be read out 
00349         adc = &(feeChannel->adcHigh());         
00350         gain = DayaBay::FeeGain::kHigh;
00351         verbose() << "Maximum available ADC window [ " << 0 << "," << adc->size() 
00352                  << " )" << endreq;
00353         
00354         // Search for peak within 300 ns window from corresponding TDC clock cycle
00355         currentTdc = tdc_vec[i];
00356         currentAdc = (int) (double(currentTdc) * double(DayaBay::AdcCycles)/double(DayaBay::TdcCycles) );
00357         
00358         if( currentAdc - m_peakFindingOffset < 0){
00359           verbose() << "Invalid ADC Peak Finding Start Cycle " 
00360                     <<  currentAdc - m_peakFindingOffset
00361                     << " Using 0" << endreq;
00362           adcFirst = 0;
00363         } 
00364         else adcFirst = currentAdc - m_peakFindingOffset;
00365         verbose() << "ADC First in ns: " << adcFirst * 25. << endreq;
00366   
00367         if( currentAdc - m_peakFindingOffset + m_peakFindingLength > adc->size() ){
00368           verbose() << "Invalid ATDC Peak Finding Last Cycle " 
00369                     << currentAdc - m_peakFindingOffset + m_peakFindingLength
00370                     << " Using " << adc->size() -1 << endreq;
00371           adcLast = adc->size() -1;
00372         } 
00373         else adcLast = currentAdc - m_peakFindingOffset + m_peakFindingLength;
00374         verbose() << "ADC Last in ns: " << adcLast * 25. << endreq;
00375        
00376         verbose() << "Reading out peak finding window [ " 
00377                   << adcFirst << "," << adcLast +1 << ")" << endreq;
00378                  
00379         // Check if high gain assumption was correct
00380         for( int j = adcFirst; j < adcLast; ++j ){
00381           if( adc->at(j) >= m_maxFineAdc ){
00382             gain = DayaBay::FeeGain::kLow;
00383             adc = &(feeChannel->adcLow());
00384             debug() << "Switching to Low gain ADC since High was saturated" 
00385                    << endreq;
00386             break;
00387           }
00388         } // end check high gain adc
00389        
00390         verbose() << "Ready to readout ADC's" << endreq;
00391        
00392         // Find Peak ADC value
00393         int adcPeak = -1;
00394         int adcPeakCycle = 0; 
00395         for(int adcCycle = (int)adcFirst; adcCycle < (int)adcLast; ++adcCycle){
00396           if( adc->at(adcCycle) > adcPeak ){
00397             // Peak clock cycle will be read out wrt start of the peak finding window
00398             adcPeak = adc->at(adcCycle);
00399             adcPeakCycle = adcCycle-adcFirst;
00400             verbose() << "Found New Max ADC at " << adcPeakCycle << endreq;
00401           }
00402         }
00403 
00404         // Compute PreADC value    
00405         int preAdc = 0;
00406         adcPedFirst = adcFirst - m_preAdcOffset;
00407         for(int adcCycle = adcPedFirst; adcCycle<adcPedFirst + 4; adcCycle++){
00408           if(adcCycle < 0) {
00409             verbose() << "Invalid PreADC Cycle " 
00410                       <<  adcCycle
00411                       << " Using standard baseline value" << endreq;
00412             if(gain == DayaBay::FeeGain::kHigh) preAdc += int(feeSimData->m_adcBaselineHigh);
00413             if(gain == DayaBay::FeeGain::kLow) preAdc += int(feeSimData->m_adcBaselineLow);
00414           }
00415           else preAdc += adc->at(adcCycle);
00416         }
00417         verbose() << "First PreADC cycle in ns: " << adcPedFirst * 25. << endreq;
00418         preAdc /= 4;
00419         verbose() << "Reading out adc " <<  adcPeak
00420                   << " at cycle " << adcPeakCycle << endreq;
00421         verbose() << "Reading out preADC " << preAdc << endreq;
00422         
00423         adc_out[i] = adcPeak; 
00424         adcCycle_out[i] = adcPeakCycle; 
00425         adcRange_out[i] = gain;
00426         preAdc_out[i] = preAdc;
00427 
00428       } //end if -- check if preceding peak find alg is finished
00429       else {
00430        verbose() << "No peak finding (previous not finished)" << endreq;
00431        // Fill adc vectors with zeros
00432        adc_out[i] = 0; 
00433        adcCycle_out[i] = 0;
00434        adcRange_out[i] = 0;
00435        preAdc_out[i] = 0;
00436       } // end else
00437       
00438       // TDC will be read out wrt common stop time
00439       tdc_out[i] = tdcStopCycle - tdc_vec[i];  
00440       tdcHitCount_out[i] = nTdc - i;
00441     }// end tdc forloop
00442     
00443     // finalize peaking mode variables for current channel
00444     ro_ch->setTdc(tdc_out);
00445     ro_ch->setTdcHitCount(tdcHitCount_out);
00446     ro_ch->setAdc(adc_out);
00447     ro_ch->setAdcCycle(adcCycle_out);
00448     ro_ch->setAdcRange(adcRange_out);
00449     ro_ch->setPedestal(preAdc_out);
00450   }
00451   
00452   // Compute variables for waveform readout mode
00453   if ( m_enableWaveformReadout ){
00454     adcFirst = (int) (double(tdcFirst) * double(DayaBay::AdcCycles)/double(DayaBay::TdcCycles) + 0.5);
00455     adcLast = (int) (double(tdcLast) * double(DayaBay::AdcCycles)/double(DayaBay::TdcCycles) + 0.5);
00456     int adcStopCycle = (int) (double(tdcStopCycle) * double(DayaBay::AdcCycles)/double(DayaBay::TdcCycles) + 0.5);
00457 
00458     std::vector<int> waveAdcLow_out; 
00459     std::vector<int> waveAdcHigh_out;
00460     std::vector<int> waveAdcCycle_out;
00461     
00462     // readout low gain waveform
00463     adc = &(feeChannel->adcLow());
00464     StatusCode sc = m_waveformTool->readoutWaveform(*adc, adcFirst, adcLast, adcStopCycle, waveAdcLow_out, waveAdcCycle_out);
00465     if( !sc.isSuccess() || waveAdcLow_out.empty() ) {
00466         delete ro_ch;
00467         return 0;
00468     }
00469     waveAdcCycle_out.clear();
00470     
00471     // readout high gain waveform
00472     adc = &(feeChannel->adcHigh());
00473     sc = m_waveformTool->readoutWaveform(*adc, adcFirst, adcLast, adcStopCycle, waveAdcHigh_out, waveAdcCycle_out);
00474     if( !sc.isSuccess() || waveAdcHigh_out.empty() ){
00475         delete ro_ch;
00476         return 0;
00477     }
00478     
00479     // finalize waveform mode variables for current channel
00480     ro_ch->setWaveAdcLow(waveAdcLow_out);
00481     ro_ch->setWaveAdcHigh(waveAdcHigh_out);
00482     ro_ch->setWaveAdcCycle(waveAdcCycle_out);
00483   }        
00484   return ro_ch;
00485 }

const InterfaceID & IROsReadoutTool::interfaceID (  )  [static, inherited]

Retrieve interface ID.

Reimplemented from IAlgTool.

Definition at line 8 of file IROsReadoutTool.cc.

00009 { 
00010     return IID_IROsReadoutTool; 
00011 }


Member Data Documentation

IROsFeeTdcTool* ROsFeeReadoutTool::m_tdcTool [private]

Definition at line 70 of file ROsFeeReadoutTool.h.

IROsFeeWaveformTool* ROsFeeReadoutTool::m_waveformTool [private]

Definition at line 71 of file ROsFeeReadoutTool.h.

IROsFadcReadoutTool* ROsFeeReadoutTool::m_fadcTool [private]

Definition at line 72 of file ROsFeeReadoutTool.h.

bool ROsFeeReadoutTool::m_enablePeakReadout [private]

Definition at line 74 of file ROsFeeReadoutTool.h.

bool ROsFeeReadoutTool::m_enableWaveformReadout [private]

Definition at line 75 of file ROsFeeReadoutTool.h.

bool ROsFeeReadoutTool::m_enableFadcReadout [private]

Definition at line 76 of file ROsFeeReadoutTool.h.

std::string ROsFeeReadoutTool::m_tdcToolName [private]

Definition at line 77 of file ROsFeeReadoutTool.h.

std::string ROsFeeReadoutTool::m_waveformToolName [private]

Definition at line 78 of file ROsFeeReadoutTool.h.

std::string ROsFeeReadoutTool::m_fadcToolName [private]

Definition at line 79 of file ROsFeeReadoutTool.h.

std::string ROsFeeReadoutTool::m_simDataSvcName [private]

Definition at line 82 of file ROsFeeReadoutTool.h.

ISimDataSvc* ROsFeeReadoutTool::m_simDataSvc [private]

Definition at line 83 of file ROsFeeReadoutTool.h.

std::vector<std::string> ROsFeeReadoutTool::m_detectorsToProcess [private]

Definition at line 85 of file ROsFeeReadoutTool.h.

std::set<DayaBay::Detector> ROsFeeReadoutTool::m_detectors [private]

Definition at line 86 of file ROsFeeReadoutTool.h.

std::vector<int> ROsFeeReadoutTool::m_roCycles [private]

Definition at line 87 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_readoutLength [private]

Definition at line 88 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_triggerLatency [private]

Definition at line 89 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_peakFindingLength [private]

Definition at line 90 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_peakFindingOffset [private]

Definition at line 91 of file ROsFeeReadoutTool.h.

bool ROsFeeReadoutTool::m_peakFindingOverlap [private]

Definition at line 92 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_readoutOffset [private]

Definition at line 93 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_preAdcOffset [private]

Definition at line 94 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_fadcOffset [private]

Definition at line 95 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_fadcLength [private]

Definition at line 96 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_nhitCycles [private]

Definition at line 97 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_eSumCycles [private]

Definition at line 98 of file ROsFeeReadoutTool.h.

int ROsFeeReadoutTool::m_maxFineAdc [private]

Definition at line 99 of file ROsFeeReadoutTool.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:50:39 2011 for ReadoutSim by doxygen 1.4.7