/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
FloatingFeePedestalSvc Class Reference

#include <FloatingFeePedestalSvc.h>

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

List of all members.

Public Types

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

Public Member Functions

 FloatingFeePedestalSvc (const std::string &name, ISvcLocator *svc)
 ~FloatingFeePedestalSvc ()
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< unsigned int > &PreAdcs, unsigned int newPreAdc)

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
list __all__ = [ "run" ]

Detailed Description

Definition at line 24 of file FloatingFeePedestalSvc.h.


Member Typedef Documentation

typedef std::map<DayaBay::FeeChannelId, std::list<unsigned int> > FloatingFeePedestalSvc::PreAdcArray

Definition at line 46 of file FloatingFeePedestalSvc.h.

Definition at line 47 of file FloatingFeePedestalSvc.h.


Constructor & Destructor Documentation

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

Definition at line 17 of file FloatingFeePedestalSvc.cc.

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

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

Definition at line 27 of file FloatingFeePedestalSvc.cc.

{
}

Member Function Documentation

StatusCode FloatingFeePedestalSvc::initialize ( ) [virtual]

Definition at line 31 of file FloatingFeePedestalSvc.cc.

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

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

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

  m_lastTrig = TimeStamp::GetBOT();

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

Definition at line 47 of file FloatingFeePedestalSvc.cc.

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

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

Definition at line 55 of file FloatingFeePedestalSvc.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 FloatingFeePedestalSvc::cumulate ( const DayaBay::ReadoutHeader rh) [virtual]

Get Readout

Check detector type

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 73 of file FloatingFeePedestalSvc.cc.

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

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

  if( readout->detector().detectorId() != DetectorId::kAD1 &&
      readout->detector().detectorId() != DetectorId::kAD2 &&
      readout->detector().detectorId() != DetectorId::kAD3 &&
      readout->detector().detectorId() != DetectorId::kAD4 &&
      readout->detector().detectorId() != DetectorId::kIWS &&
      readout->detector().detectorId() != DetectorId::kOWS ) {
    return StatusCode::SUCCESS;
  }

  TimeStamp trigTime = readout->triggerTime();
  
  if( (m_lastTrig == TimeStamp::GetBOT()) ||
      ((trigTime-m_lastTrig).GetSeconds() > m_timeCutInSec) ) {
    
    const ReadoutPmtCrate* pPmtCrate=0;
    pPmtCrate = dynamic_cast< const DayaBay::ReadoutPmtCrate* > ( readout );
    if(!pPmtCrate) {
      log << MSG::ERROR <<"Failed to get ReadoutPmtCrate"<<endreq;
      return StatusCode::FAILURE;
    }
    
    ReadoutPmtCrate::PmtChannelReadouts channels = pPmtCrate->channelReadout();
    ReadoutPmtCrate::PmtChannelReadouts::iterator ci, ci_end = channels.end();

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

      ReadoutPmtChannel channel = ci->second;
      FeeChannelId channelId = channel.channelId();
      
      int preAdc = channel.pedestal()[0];
      int range  = channel.adcRange()[0];

      if( range == FeeGain::kHigh ) {
        list<unsigned int>& preAdcs = m_finePreAdc[ channelId ];
        m_finePedes[ channelId ] = updatePedestal( preAdcs, preAdc );
      }
      if( range == FeeGain::kLow ) {
        list<unsigned int>& preAdcs = m_crsePreAdc[ channelId ];
        m_crsePedes[ channelId ] = updatePedestal( preAdcs, preAdc );
      }
    }
    
    m_lastTrig = trigTime;
  }

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

Implements IFloatingFeePedestalSvc.

Definition at line 140 of file FloatingFeePedestalSvc.cc.

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

  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=5;
      if(count<maxCount){
        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=5;
      if(count<maxCount){
        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;
    }
  }

  log << MSG::ERROR <<"Query with wrong gain parameter"<<endreq;
  return -1000;
}
double FloatingFeePedestalSvc::updatePedestal ( std::list< unsigned int > &  PreAdcs,
unsigned int  newPreAdc 
) [private]

update array

faster new approach

update array

Definition at line 206 of file FloatingDaqFeePedestalSvc.cc.

{
  PreAdcs.push_front( newPreAdc );

  double ave=0;
  if( oldAvePed>=0 ) ave = oldAvePed;
  else ave = 0; // Not set yet

  int count = CurArySize+1;  // New size after adding a new element
  if( count <= m_limit ) {
    ave = ave*(count-1)/count  + newPreAdc/count;
  } else {
    double firstPed = *( PreAdcs.rbegin() );
    ave = -firstPed/m_limit + oldAvePed + newPreAdc/m_limit;
    PreAdcs.pop_back();
  }

  return ave;
}
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 51 of file FloatingFeePedestalSvc.h.

Definition at line 53 of file FloatingFeePedestalSvc.h.

Definition at line 54 of file FloatingFeePedestalSvc.h.

Definition at line 56 of file FloatingFeePedestalSvc.h.

Definition at line 57 of file FloatingFeePedestalSvc.h.

Definition at line 59 of file FloatingFeePedestalSvc.h.

Definition at line 60 of file FloatingFeePedestalSvc.h.

list FloatingFeePedestalSvc::__all__ = [ "run" ] [private]

Definition at line 3 of file __init__.py.


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