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

In This Package:

ROsFadcReadoutTool Class Reference

#include <ROsFadcReadoutTool.h>

Inheritance diagram for ROsFadcReadoutTool:

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

Public Types

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
enum  Status

Public Member Functions

 ROsFadcReadoutTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ROsFadcReadoutTool ()
virtual StatusCode readoutFADC (const DayaBay::ElecFeeCrate *elecCrate, DayaBay::ReadoutPmtCrate *roCrate, unsigned int startCycle, unsigned int stopCycle)
 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 Types

typedef std::map< int, DayaBay::AnalogSignalanalogFADCmap

Private Member Functions

double linearInterpolate (double y1, double y2, double mu, double leftPoint, double rightPoint)
StatusCode fillFadcMap (const DayaBay::ElecFeeCrate::AnalogMap &input, analogFADCmap &output)
StatusCode upsample (const DayaBay::AnalogSignal &signal, DayaBay::AnalogSignal &output, int inputFrequency, int outputFrequency, int start, int stop)
StatusCode digitize (const DayaBay::AnalogSignal &signal, DayaBay::DigitalSignal &output, double range, double bits, double offset)
const int getFadcInputChId (const DayaBay::FeeChannelId &boardId)

Private Attributes

int m_simFrequency
int m_eSumFrequency
int m_fadcFrequency
double m_adcRange
double m_adcBits
double m_adcOffset

Detailed Description

Definition at line 25 of file ROsFadcReadoutTool.h.


Member Typedef Documentation

typedef std::map<int,DayaBay::AnalogSignal> ROsFadcReadoutTool::analogFADCmap [private]

Definition at line 43 of file ROsFadcReadoutTool.h.


Constructor & Destructor Documentation

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

Definition at line 13 of file ROsFadcReadoutTool.cc.

00016   : GaudiTool(type,name,parent)
00017 {
00018   declareInterface< IROsFadcReadoutTool >(this) ;
00019   declareProperty("SimFrequency", m_simFrequency = DayaBay::TdcFrequencyHz,"Simulation Frequency");
00020   declareProperty("ESumFrequency", m_eSumFrequency = DayaBay::EsumFrequencyHz,"Esum Frequency");
00021   declareProperty("FadcFrequency", m_fadcFrequency = DayaBay::FadcFrequencyHz,"Fadc Frequency");
00022   declareProperty("ADCOffset", m_adcOffset = 130,"Fadc Frequency");
00023   declareProperty("ADCRange", m_adcRange = 2.2e-6,"Fadc Range");
00024   declareProperty("ADCBits", m_adcBits = 8,"Fadc bits");
00025 }

ROsFadcReadoutTool::~ROsFadcReadoutTool (  )  [virtual]

Definition at line 27 of file ROsFadcReadoutTool.cc.

00027 {}


Member Function Documentation

StatusCode ROsFadcReadoutTool::readoutFADC ( const DayaBay::ElecFeeCrate elecCrate,
DayaBay::ReadoutPmtCrate roCrate,
unsigned int  startCycle,
unsigned int  stopCycle 
) [virtual]

Modify the event.

Implements IROsFadcReadoutTool.

Definition at line 39 of file ROsFadcReadoutTool.cc.

00043 {  
00044   info() << "Doing FADC readout" << endreq;
00045   const DayaBay::ElecFeeCrate::AnalogMap& boardMap = elecCrate->esum();
00046   DayaBay::ReadoutPmtCrate::FadcReadouts& fadcMap = roCrate->fadcReadout();
00047   ROsFadcReadoutTool::analogFADCmap analogFADCMap;
00048  
00049   debug() << "Filling fadc map with esum map of size " << boardMap.size() << endreq;
00050 
00051   if ( fillFadcMap(boardMap, analogFADCMap).isFailure() )
00052     {
00053       fatal() << "fillFadcMap failed" << endreq;
00054       return StatusCode::FAILURE;
00055     }
00056 
00057   debug() << "Size of filled FADC map " << analogFADCMap.size() << endreq;
00058   
00059   // loop over FADC vectors and upsample them
00060   ROsFadcReadoutTool::analogFADCmap::iterator boardIt = analogFADCMap.begin();
00061   for( ; boardIt != analogFADCMap.end(); ++boardIt)
00062     {
00063       DayaBay::FadcChannelId *outputId = new DayaBay::FadcChannelId(boardIt->first);
00064       //DayaBay::FadcChannelId outputId(boardIt->first);  
00065 
00066       verbose() << "Processing: " << outputId->connector() << " w/ id = "
00067                 << *outputId << endreq;
00068    
00069       DayaBay::AnalogSignal& fadcVector = boardIt->second;
00070       DayaBay::AnalogSignal interpFadcVec;
00071       
00072       DayaBay::DigitalSignal& digFadcVec = fadcMap[*outputId];
00073       
00074       debug() << "Upsampling vec of size " << fadcVector.size() << endreq;
00075 
00076       if ( upsample(fadcVector, interpFadcVec, m_simFrequency, m_fadcFrequency, startCycle, stopCycle).isFailure() )
00077         {
00078           fatal() << "upsample failed" << endreq;
00079           return StatusCode::FAILURE;
00080         }
00081 
00082       debug() << "Upsampled vec has size " << interpFadcVec.size() << endreq;      
00083       debug() << "Digitizing vec of size " << interpFadcVec.size() << endreq;
00084       verbose() << "interpVector " << interpFadcVec << endreq;
00085 
00086       if ( digitize(interpFadcVec, fadcMap[*outputId], m_adcRange, m_adcBits, m_adcOffset).isFailure() )
00087         {
00088           fatal() << "digitize failed" << endreq;
00089           return StatusCode::FAILURE;
00090         }
00091       //delete outputId;
00092       debug() << "Digitized vec has size " << digFadcVec.size() << endreq;
00093 
00094     }
00095 
00096     return StatusCode::SUCCESS;
00097 }

StatusCode ROsFadcReadoutTool::initialize (  )  [virtual]

Reimplemented from GaudiTool.

Definition at line 29 of file ROsFadcReadoutTool.cc.

00030 {
00031   return StatusCode::SUCCESS;
00032 }

StatusCode ROsFadcReadoutTool::finalize (  )  [virtual]

Reimplemented from GaudiTool.

Definition at line 34 of file ROsFadcReadoutTool.cc.

00035 {
00036   return StatusCode::SUCCESS;
00037 }

double ROsFadcReadoutTool::linearInterpolate ( double  y1,
double  y2,
double  mu,
double  leftPoint,
double  rightPoint 
) [private]

Definition at line 225 of file ROsFadcReadoutTool.cc.

00226 {
00227   // simple linear interpolation function to upsample the signal to 1 GHz
00228   verbose() << "Using linear interpolation function" << endreq;
00229   if(leftPoint <= mu && mu <= rightPoint)
00230     {
00231       return( y1 + ((mu - leftPoint)/(rightPoint - leftPoint))*(y2 - y1) );
00232     }
00233 
00234   warning()<< "This should never happen! Interpolation point out of bounds. Returning value at left point." << endreq;
00235   return y1;
00236 }

StatusCode ROsFadcReadoutTool::fillFadcMap ( const DayaBay::ElecFeeCrate::AnalogMap input,
analogFADCmap output 
) [private]

Definition at line 101 of file ROsFadcReadoutTool.cc.

00103 {
00104   // Fills a map with the FADC channel IDs and ESum vectors
00105     debug() << "Filling FADC map " << endreq;
00106     DayaBay::ElecFeeCrate::AnalogMap::const_iterator boardIt = input.begin();
00107     for (;boardIt != input.end(); ++boardIt)
00108     {
00109         DayaBay::FeeChannelId boardId = boardIt->first;
00110         const DayaBay::AnalogSignal& boardEnergy = boardIt->second;
00111         //int boardNum = boardId.board();
00112         unsigned int boardIdx = boardEnergy.size();
00113          
00114         verbose() << "boardIdx = " <<  boardEnergy.size() << endreq;
00115  
00116         // Get the FADC input and output channel IDs
00117         DayaBay::FadcChannelId fadcChId(getFadcInputChId(boardId));
00118         DayaBay::FadcChannelId outputChannel(fadcChId.outputId());
00119         
00120         verbose() << " FeeBoard -> FADCInputChannel -> FADCOutputChannel : " 
00121                   << boardId.board()
00122                   << " -> " << fadcChId.connector() 
00123                   << " -> " << outputChannel.connector() << endreq;
00124         
00125         DayaBay::AnalogSignal& fadcVector = output[outputChannel.fullPackedData()];
00126 
00127         // Resize the FADC vectors
00128         if(fadcVector.size() != boardEnergy.size())
00129         {
00130             fadcVector.resize(boardEnergy.size());
00131         }
00132 
00133         for( unsigned int i = 0; i < boardIdx; i++)
00134         {
00135             fadcVector[i] += boardEnergy[i];
00136         }
00137             
00138         verbose() << "FADC vector size " << fadcVector.size() << endreq;
00139     }
00140     return StatusCode::SUCCESS;
00141 }

StatusCode ROsFadcReadoutTool::upsample ( const DayaBay::AnalogSignal signal,
DayaBay::AnalogSignal output,
int  inputFrequency,
int  outputFrequency,
int  start,
int  stop 
) [private]

Definition at line 155 of file ROsFadcReadoutTool.cc.

00159 {
00160       // Finds the points needed for the interpolation function
00161       // Make sure the output vector is properly sized to the size of the 
00162       // the readout window
00163 
00164       verbose() << "Upsampling FADC vector" << endreq;
00165 
00166       double timeStep = 1/((inputFrequency)*(1.e-9));
00167       double fadcStep = 1/((outputFrequency)*(1.e-9));
00168       // Factor to get the correct interpolation values
00169       double muFactor = fadcStep/timeStep;
00170       int maxIdx = signal.size();
00171       // Check to make sure the start and stop times are between 0 and the max index
00172       if (start < 0) start=0;
00173       if (stop < 0) stop=0;
00174       if (stop > maxIdx) stop=maxIdx;
00175       if (start > maxIdx) start=maxIdx;
00176       if (start > stop) return StatusCode::FAILURE;
00177 
00178       output.resize(stop - start);
00179 
00180       debug() << " start " << start << " stop " << stop << " muFactor " << muFactor << " timeStep " << timeStep <<endreq;
00181       // Only read out the vector in the readout window (between start and stop)
00182 
00183       for(int i = start; i < stop; i++)
00184         {  
00185           // Calculate the x and y values we want to interpolate between
00186           int ileftPoint = int (i/timeStep);
00187           int irightPoint = ileftPoint + 1;
00188           double y1 = signal[ileftPoint];
00189           double y2 = signal[irightPoint];
00190           double leftPoint = double( ileftPoint );
00191           double rightPoint = double( irightPoint );
00192           double mu = i*muFactor;
00193 
00194           // avoid rounding problems
00195           if ( abs(mu-leftPoint) < 1.e-6 ) mu = std::max(mu,leftPoint) ;
00196           if ( abs(mu-rightPoint) < 1.e-6 ) mu = std::min(mu,rightPoint) ; 
00197 
00198           debug() << "Try to interpolate. leftPoint " << leftPoint << " mu " << mu << " rightPoint " << rightPoint 
00199                   << " mu-leftPoint " << mu-leftPoint << " rightPoint-mu " << rightPoint-mu 
00200                   << " signal(leftPoint) " << y1 << " signal(rightPoint) " << y2 << endreq;
00201 
00202           // Only interpolate the values of mu that are between the left and right points
00203           if( leftPoint <= mu && mu <= rightPoint)
00204             {
00205               output[i - start] = linearInterpolate(y1, y2, mu, leftPoint, rightPoint);
00206             }
00207 
00208           else
00209             {
00210               fatal() << "Interpolation point out of bounds.leftPoint " << leftPoint << " mu " << mu 
00211                       << " rightPoint " << rightPoint << " mu-leftPoint " << mu-leftPoint << " rightPoint-mu " << rightPoint-mu << endreq;
00212               return StatusCode::FAILURE;
00213             }
00214 
00215           // add different options here if necessary
00216           debug() << "upsample " << output[i-start] << " <- "
00217                     << "linear Interp ( " << y1 << "," << y2 << "," << mu
00218                   << ")" << endreq;
00219       
00220         }
00221 
00222       return StatusCode::SUCCESS;
00223 }

StatusCode ROsFadcReadoutTool::digitize ( const DayaBay::AnalogSignal signal,
DayaBay::DigitalSignal output,
double  range,
double  bits,
double  offset 
) [private]

Definition at line 241 of file ROsFadcReadoutTool.cc.

00244 {
00245   // Simple digitization algorithm
00246   verbose() << "digitizing vectors" << endreq;
00247   if(output.size() != signal.size()) output.resize(signal.size());
00248   int maxADC = int( pow(2, bits) );
00249   int signalN = signal.size();
00250   const double* inputStart = &signal[0];
00251   int* outputStart = &output[0];
00252   for (int i=0; i<signalN; i++) {
00253     int* curOutput = outputStart + i;
00254     *(curOutput) = int(((*(inputStart + i))/range)*maxADC + offset);
00255     //verbose() << "Trying to digitize " << *(inputStart + i) << endreq;
00256     if (*curOutput>maxADC)
00257       *curOutput=maxADC;
00258     if (*curOutput<0)
00259       *curOutput=0;
00260     /* Slower, but easier to read version of the same calculation
00261     outputStart[i] = int((signal[i]/range)*maxADC + offset);
00262     if (output[i]>maxADC)
00263       output[i]=maxADC;
00264     if (output[i]<0)
00265       output[i]=0;
00266     */
00267   }
00268   return StatusCode::SUCCESS;
00269 }

const int ROsFadcReadoutTool::getFadcInputChId ( const DayaBay::FeeChannelId boardId  )  [private]

Definition at line 143 of file ROsFadcReadoutTool.cc.

00143                                                                                 {
00144     // convert FEE Board Id to Corresponding FADC input ID
00145     
00146     // Update to use Cable Mapping Svc...
00147     // for now create it on the fly.
00148     int boardNum=boardId.board();
00149     debug() << "getting input connector id for FEE board" << boardNum << endreq;
00150     
00151     DayaBay::FadcChannelId fadcChId(boardNum,boardId.site(),boardId.detectorId());
00152     return fadcChId.fullPackedData();
00153 }

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

Retrieve interface ID.

Reimplemented from IAlgTool.

Definition at line 8 of file IROsFadcReadoutTool.cc.

00009 { 
00010     return IID_IROsFadcReadoutTool; 
00011 }


Member Data Documentation

int ROsFadcReadoutTool::m_simFrequency [private]

Definition at line 46 of file ROsFadcReadoutTool.h.

int ROsFadcReadoutTool::m_eSumFrequency [private]

Definition at line 48 of file ROsFadcReadoutTool.h.

int ROsFadcReadoutTool::m_fadcFrequency [private]

Definition at line 50 of file ROsFadcReadoutTool.h.

double ROsFadcReadoutTool::m_adcRange [private]

Definition at line 51 of file ROsFadcReadoutTool.h.

double ROsFadcReadoutTool::m_adcBits [private]

Definition at line 52 of file ROsFadcReadoutTool.h.

double ROsFadcReadoutTool::m_adcOffset [private]

Definition at line 53 of file ROsFadcReadoutTool.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:38 2011 for ReadoutSim by doxygen 1.4.7