/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
FloatingDaqFeePedestalSvc Class Reference

#include <FloatingDaqFeePedestalSvc.h>

Inheritance diagram for FloatingDaqFeePedestalSvc:
Inheritance graph
[legend]
Collaboration diagram for FloatingDaqFeePedestalSvc:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::map
< DayaBay::FeeChannelId,
std::list< float > > 
PreAdcArray
typedef std::map
< DayaBay::FeeChannelId,
double > 
PedestalArray
typedef std::map
< DayaBay::FeeChannelId, int > 
SizeArray

Public Member Functions

 FloatingDaqFeePedestalSvc (const std::string &name, ISvcLocator *svc)
 ~FloatingDaqFeePedestalSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
StatusCode cumulate (const DayaBay::ReadoutHeader *rh)
double pedestal (const DayaBay::FeeChannelId &channelId, int gain) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

double updatePedestal (std::list< float > &PreAdcs, float oldAvePed, float newPreAdc, int CurArySize)

Private Attributes

double m_limit
 number of preAdcs used to calculate average
double m_timeCutInSec
TimeStamp m_lastTrig
PreAdcArray m_finePreAdc
PreAdcArray m_crsePreAdc
PedestalArray m_finePedes
PedestalArray m_crsePedes
SizeArray m_fineSize
SizeArray m_crseSize

Detailed Description

Definition at line 26 of file FloatingDaqFeePedestalSvc.h.


Member Typedef Documentation

typedef std::map<DayaBay::FeeChannelId, std::list<float> > FloatingDaqFeePedestalSvc::PreAdcArray

Definition at line 48 of file FloatingDaqFeePedestalSvc.h.

Definition at line 49 of file FloatingDaqFeePedestalSvc.h.

Definition at line 50 of file FloatingDaqFeePedestalSvc.h.


Constructor & Destructor Documentation

FloatingDaqFeePedestalSvc::FloatingDaqFeePedestalSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 18 of file FloatingDaqFeePedestalSvc.cc.

  : Service(name,svc)
{
  declareProperty("Limit",m_limit=100,
                  "Number of preAdcs to document");

  declareProperty("TimeCutInSec",m_timeCutInSec=0.00005,  // 50 us
                  "Time cut in second to remove afterpulses");
}
FloatingDaqFeePedestalSvc::~FloatingDaqFeePedestalSvc ( )

Definition at line 28 of file FloatingDaqFeePedestalSvc.cc.

{
}

Member Function Documentation

StatusCode FloatingDaqFeePedestalSvc::initialize ( ) [virtual]

Definition at line 32 of file FloatingDaqFeePedestalSvc.cc.

{
  StatusCode sc;
  sc = this->Service::initialize();

  m_finePreAdc.clear();
  m_crsePreAdc.clear();

  m_finePedes.clear();
  m_crsePedes.clear();

  m_fineSize.clear();
  m_crseSize.clear();

  m_lastTrig = TimeStamp::GetBOT();

  return sc;
}
StatusCode FloatingDaqFeePedestalSvc::finalize ( ) [virtual]

Definition at line 51 of file FloatingDaqFeePedestalSvc.cc.

{
  StatusCode sc;
  sc = this->Service::finalize();

  return sc;
}
StatusCode FloatingDaqFeePedestalSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
) [virtual]

Definition at line 59 of file FloatingDaqFeePedestalSvc.cc.

{
  StatusCode sc = StatusCode::FAILURE;
  if (ppvInterface) {
    *ppvInterface = 0;
    
    if (IFloatingFeePedestalSvc::interfaceID().versionMatch(riid)) {
      *ppvInterface = static_cast<IFloatingFeePedestalSvc*>(this);
      sc = StatusCode::SUCCESS;
      addRef();
    }
    else sc = Service::queryInterface( riid, ppvInterface );
  }
  return sc;
}
StatusCode FloatingDaqFeePedestalSvc::cumulate ( const DayaBay::ReadoutHeader rh) [virtual]

Check detector type

Block ESum-only trigger, always noisy

Check trigger time

Avoid afterpulses since baseline is restoring.

Get Pmt Crate

Loop over each channel

Get channel ID and preAdc and range

update current preAdc array and calculate pedestal;

Implements IFloatingFeePedestalSvc.

Definition at line 77 of file FloatingDaqFeePedestalSvc.cc.

{
    MsgStream log(msgSvc(), "FloatingFeePedestalSvc");

      const DaqCrate* daqCrate = rh->daqCrate();
      if(!daqCrate) {
        log << MSG::ERROR <<"Failed to get daqCrate from header"<<endreq;
        return StatusCode::FAILURE;
      }

      // check for rpc's sneaking in
      if( ! (daqCrate->detector().isAD() || daqCrate->detector().isWaterShield() ) ) {
          return StatusCode::SUCCESS;
      }

      if( daqCrate->triggerType() == Trigger::kESumAll )   return StatusCode::SUCCESS;

      TimeStamp trigTime = daqCrate->triggerTime();

      if( (m_lastTrig == TimeStamp::GetBOT()) ||
          ((trigTime-m_lastTrig).GetSeconds() > m_timeCutInSec) ) {

          const DaqPmtCrate* pPmtCrate=daqCrate->asPmtCrate();
          if(!pPmtCrate) {
              log << MSG::ERROR <<"Failed to get ReadoutPmtCrate"<<endreq;
              return StatusCode::FAILURE;
          }

          DaqPmtCrate::PmtChannelPtrList channels = pPmtCrate->pmtChannelReadouts();
          DaqPmtCrate::PmtChannelPtrList::iterator ci, ci_end = channels.end();

          for(ci = channels.begin(); ci!=ci_end; ci++) {

              DaqPmtChannel *channel = *ci;
              FeeChannelId channelId = channel->channelId();

              float preAdc = channel->preAdcAvg(0);   /* Only the first hit */
              int range  = channel->isHighGainAdc(0) ? FeeGain::kHigh 
                                                     : FeeGain::kLow ;

              double oldAvePed = pedestal( channelId, range );
              if( range == FeeGain::kHigh ) {
                  list<float>& preAdcs = m_finePreAdc[ channelId ];
                  int size = m_limit;
                  if( m_fineSize[ channelId ] < m_limit ) { 
                    size = m_fineSize[ channelId ] = preAdcs.size();
                  }
                  m_finePedes[ channelId ] = updatePedestal( preAdcs, oldAvePed, preAdc, size );
              }
              if( range == FeeGain::kLow ) {
                  list<float>& preAdcs = m_crsePreAdc[ channelId ];
                  int size = m_limit;
                  if( m_fineSize[ channelId ] < m_limit ) {
                    size = m_fineSize[ channelId ] = preAdcs.size();
                  }
                  m_crsePedes[ channelId ] = updatePedestal( preAdcs, oldAvePed, preAdc, size );
              }
          }

          m_lastTrig = trigTime;
      }

      return StatusCode::SUCCESS;
}
double FloatingDaqFeePedestalSvc::pedestal ( const DayaBay::FeeChannelId channelId,
int  gain 
) const [virtual]

Implements IFloatingFeePedestalSvc.

Definition at line 151 of file FloatingDaqFeePedestalSvc.cc.

{
  if( gain==FeeGain::kHigh ) {
    PedestalArray::const_iterator ci;
    ci = m_finePedes.find( channelId );
    if( ci != m_finePedes.end() ) {
      return ci->second;
    } else {
      static int count=0;
      int maxCount=1;

      if(count<maxCount){

        MsgStream log(msgSvc(), "FloatingDaqFeePedestalSvc");
        log << MSG::DEBUG <<"Incomplete fine range pedestal map for channel " 
            << channelId << ". Try preADC."
            << endreq;
        count++;
        if(count==maxCount){
          log << MSG::DEBUG <<"Further error messages will be suppressed."
              << endreq;
        }
      }
      return -1000;
    }
  }

  if( gain==FeeGain::kLow ) {
    PedestalArray::const_iterator ci;
    ci = m_crsePedes.find( channelId );
    if( ci != m_crsePedes.end() ) {
      return ci->second;
    } else {
      static int count=0;
      int maxCount=1;

      if(count<maxCount){
        MsgStream log(msgSvc(), "FloatingDaqFeePedestalSvc");
        log << MSG::DEBUG <<"Incomplete coarse range pedestal map for channel " 
            << channelId << ". Try preADC."
            << endreq;
        count++;
        if(count==maxCount){
          log << MSG::DEBUG <<"Further error messages will be suppressed."
              << endreq;
        }
      }
      return -1000;
    }
  }

  return -1000;
}
double FloatingDaqFeePedestalSvc::updatePedestal ( std::list< float > &  PreAdcs,
float  oldAvePed,
float  newPreAdc,
int  CurArySize 
) [private]
static const InterfaceID& IFloatingFeePedestalSvc::interfaceID ( ) [inline, static, inherited]

Definition at line 25 of file IFloatingFeePedestalSvc.h.


Member Data Documentation

number of preAdcs used to calculate average

Definition at line 54 of file FloatingDaqFeePedestalSvc.h.

Definition at line 56 of file FloatingDaqFeePedestalSvc.h.

Definition at line 57 of file FloatingDaqFeePedestalSvc.h.

Definition at line 59 of file FloatingDaqFeePedestalSvc.h.

Definition at line 60 of file FloatingDaqFeePedestalSvc.h.

Definition at line 62 of file FloatingDaqFeePedestalSvc.h.

Definition at line 63 of file FloatingDaqFeePedestalSvc.h.

Definition at line 65 of file FloatingDaqFeePedestalSvc.h.

Definition at line 66 of file FloatingDaqFeePedestalSvc.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 Fri May 16 2014 10:04:02 for FloatingFeePedestalSvc by doxygen 1.7.4