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

In This Package:

Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
EsFrontEndAlg Class Reference

#include <EsFrontEndAlg.h>

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

List of all members.

Public Member Functions

 EsFrontEndAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~EsFrontEndAlg ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
DayaBay::ElecHeaderGetCurrentHeaderObject () const
virtual StatusCode sysInitialize ()
virtual StatusCode sysExecute ()
virtual StatusCode preExecute ()
virtual StatusCode postExecute ()
virtual StatusCode sysFinalize ()
IDataProviderSvc * arcSvc () const
void putTES (DataObject *obj, std::string location) const
TYPE * getTES (std::string location) const
TYPE * getAES (std::string location, int index) const
std::vector< DataObject * > getAEScollection (std::string location) const
int getExecNum ()
std::string Location () const

Protected Member Functions

DayaBay::ElecHeaderMakeHeaderObject ()
void InitializeHeader (DayaBay::HeaderObject *header)
TYPE * MakeHeader ()
TYPE * MakeHeader (std::vector< const DayaBay::IHeader * > &inputHeaders)
TYPE * MakeHeader (const DayaBay::IHeader *referenceHeader)
void AppendInputHeader (const DayaBay::HeaderObject *header) const

Protected Attributes

DayaBay::HeaderObjectm_headerObject
bool m_pullMode
std::string m_location

Private Attributes

std::string m_simLocation
 Property SimLocation - location in TES where the input SimHeader is to be found.
std::vector< std::string > m_detectorNames
std::string m_pmtToolName
std::string m_rpcToolName
std::string m_feeToolName
std::string m_fecToolName
std::vector< DayaBay::Detectorm_detectors
IEsPulseToolm_pmtTool
IEsPulseToolm_rpcTool
IEsFrontEndToolm_feeTool
IEsFrontEndToolm_fecTool
double m_maxSimulationTime

Detailed Description

Definition at line 24 of file EsFrontEndAlg.h.


Constructor & Destructor Documentation

EsFrontEndAlg::EsFrontEndAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 16 of file EsFrontEndAlg.cc.

    : DybAlgorithm<DayaBay::ElecHeader>(name,pSvcLocator)
    , m_pmtTool(0)
    , m_rpcTool(0)
    , m_feeTool(0)
    , m_fecTool(0)
{
    declareProperty("SimLocation",m_simLocation=DayaBay::SimHeaderLocation::Default,
                    "Location in the TES where the input SimHeader is to be found.");
    declareProperty("Detectors",m_detectorNames,"List of active detectors");
    declareProperty("PmtTool",m_pmtToolName="EsPmtEffectPulseTool",
                    "Name of the PMT simulation tool");
    declareProperty("RpcTool",m_rpcToolName="EsIdealPulseTool",
                    "Name of the RPC simulation tool");
    declareProperty("FeeTool",m_feeToolName="EsIdealFeeTool",
                    "Name of the PMT Front-end electronics simulation tool");
    declareProperty("FecTool",m_fecToolName="EsIdealFecTool",
                    "Name of the RPC Front-end electronics simulation tool");
    declareProperty("MaxSimulationTime",
                    m_maxSimulationTime=50*CLHEP::microsecond,
                    "Maximum time window length for electronics simulation");
    // Default configuration includes all PMT detectors
    m_detectorNames.push_back("DayaBayAD1");
    m_detectorNames.push_back("DayaBayAD2");
    m_detectorNames.push_back("DayaBayIWS");
    m_detectorNames.push_back("DayaBayOWS");
    m_detectorNames.push_back("DayaBayRPC");
    m_detectorNames.push_back("LingAoAD1");
    m_detectorNames.push_back("LingAoAD2");
    m_detectorNames.push_back("LingAoIWS");
    m_detectorNames.push_back("LingAoOWS");
    m_detectorNames.push_back("LingAoRPC");
    m_detectorNames.push_back("FarAD1");
    m_detectorNames.push_back("FarAD2");
    m_detectorNames.push_back("FarAD3");
    m_detectorNames.push_back("FarAD4");
    m_detectorNames.push_back("FarIWS");
    m_detectorNames.push_back("FarOWS");
    m_detectorNames.push_back("FarRPC");
    m_detectorNames.push_back("SABAD1");
    m_detectorNames.push_back("SABAD2");
}
EsFrontEndAlg::~EsFrontEndAlg ( ) [virtual]

Definition at line 59 of file EsFrontEndAlg.cc.

{
}

Member Function Documentation

StatusCode EsFrontEndAlg::initialize ( ) [virtual]

Definition at line 63 of file EsFrontEndAlg.cc.

{

  // Convert detector names to Detector IDs
  int nDetNames = m_detectorNames.size();
  for(int detIdx=0; detIdx<nDetNames; detIdx++){
    DayaBay::Detector det(m_detectorNames[detIdx]);
    if(det.site() == Site::kUnknown
       || det.detectorId() == DetectorId::kUnknown){
      error() << "Invalid detector name: " << m_detectorNames[detIdx] << endreq;
      return StatusCode::FAILURE;
    }
    m_detectors.push_back(det);
  }
  if ( msgLevel(MSG::DEBUG) ) {
      debug()<<"Signals for the following detectors will be simulated: "
        <<m_detectorNames<<endreq;
  }

  // Get PMT Pulse tool
  try {
    m_pmtTool = tool<IEsPulseTool>(m_pmtToolName);
  }
  catch(const GaudiException& exg) {
    fatal() << "Failed to get pmt tool: \"" << m_pmtToolName << "\"" << endreq;
            return StatusCode::FAILURE;
  }
  info () << "Added tool " << m_pmtToolName << endreq;

  // Get RPC Pulse tool
  if(m_pmtToolName == m_rpcToolName){
    m_rpcTool = m_pmtTool;
  }else{
    try {
      m_rpcTool = tool<IEsPulseTool>(m_rpcToolName);
    }
    catch(const GaudiException& exg) {
      fatal() << "Failed to get rpc tool: \"" << m_rpcToolName << "\"" << endreq;
      return StatusCode::FAILURE;
    }
    info () << "Added tool " << m_rpcToolName << endreq;
  }

  // Get PMT Front-end Electronics tool
  try {
    m_feeTool = tool<IEsFrontEndTool>(m_feeToolName);
  }
  catch(const GaudiException& exg) {
    fatal() << "Failed to get fee tool: \"" << m_feeToolName << "\"" << endreq;
            return StatusCode::FAILURE;
  }
  info () << "Added tool " << m_feeToolName << endreq;

  // Get RPC Front-end Electronics tool
  try {
    m_fecTool = tool<IEsFrontEndTool>(m_fecToolName);
  }
  catch(const GaudiException& exg) {
    fatal() << "Failed to get fec tool: \"" << m_fecToolName << "\"" << endreq;
            return StatusCode::FAILURE;
  }
  info () << "Added tool " << m_fecToolName << endreq;

  // Set the 'partition' for this run in RunDataSvc
  IRunDataSvc* runDataSvc = svc<IRunDataSvc>("RunDataSvc",true);
  if(!runDataSvc){
    error() << "Failed to get RunDataSvc" << endreq;
    return StatusCode::FAILURE;
  }
  int task = 1;  // Tells RunDataSvc to use new simulation run data.
  Context emptyContext; // Need a dummy context for this service call
  ServiceMode svcMode(emptyContext, task);
  const DayaBay::RunData* runData = runDataSvc->runData(svcMode);
  if(!runData){
    error() << "Failed to get RunData for simulation" << endreq;
    return StatusCode::FAILURE;
  }
  DayaBay::RunData modifiedRunData(*runData);
  modifiedRunData.setDetectors(m_detectors);
  StatusCode sc = runDataSvc->setRunData(modifiedRunData);
  if( !sc.isSuccess() ){
    error() << "Failed to set detectors in run" << endreq;
  }
  return sc;
}
StatusCode EsFrontEndAlg::execute ( ) [virtual]

Loop over all SimHitCollections

Definition at line 149 of file EsFrontEndAlg.cc.

{

    // Get input header
    DayaBay::SimHeader* simHeader = getTES<DayaBay::SimHeader>(m_simLocation);

    // Create output header
    DayaBay::ElecHeader* elecHeader = MakeHeaderObject();

    // Set the simulation time range
    // Add padding to ElecHeader time window
    TimeStamp earliest = simHeader->earliest();
    TimeStamp latest = simHeader->latest();

    earliest.Add(-DayaBay::preTimeTolerance/CLHEP::second);
    latest.Add(DayaBay::postTimeTolerance/CLHEP::second);

    elecHeader->setContext(simHeader->context());
    elecHeader->setEarliest(earliest);
    elecHeader->setLatest(latest);
    elecHeader->setTimeStamp(earliest);

    // Add the pulse collection header
    DayaBay::ElecPulseHeader* pulseHeader =
      new DayaBay::ElecPulseHeader(elecHeader);
    elecHeader->setPulseHeader(pulseHeader);

    // Add the crate header
    DayaBay::ElecCrateHeader* crateHeader =
      new DayaBay::ElecCrateHeader(elecHeader);
    elecHeader->setCrateHeader(crateHeader);

    double simDeltaT = (latest-earliest).GetSeconds()*CLHEP::second;
    if( simDeltaT > m_maxSimulationTime ){
      //error() << "SimHits span to much time (" << simDeltaT/CLHEP::microsecond
            //  << " us).  Simulate kinematics individually,"
            //  << " or use the Fifteen algorithm." << endreq;
      //return StatusCode::FAILURE;
      info() << "SimHits span too much time (" << simDeltaT/CLHEP::second
              << " s).  Simulate kinematics individually." << endreq;
      return StatusCode::SUCCESS;
    }

    // Get the SimHit Header
    const DayaBay::SimHitHeader* simHitHeader = simHeader->hits();
    if ( !simHitHeader ) {
      info() << "Empty simhitheader. Do not try to process non-existent hit collections." <<endreq;
      return StatusCode::SUCCESS;
    }

    const DayaBay::SimHitHeader::hc_map& hcMap = simHitHeader->hitCollection();

    info() << "Processing hit collections" <<endreq;

    DayaBay::SimHitHeader::hc_map::const_iterator hcIter;
    for (hcIter=hcMap.begin(); hcIter != hcMap.end(); ++hcIter) {

      DayaBay::Detector det(hcIter->first);
      debug() << "Checking " << det.detName() << " for hits." << endreq;
      DayaBay::SimHitCollection* hits = hcIter->second;
      if(!hits) return StatusCode::FAILURE;

      debug() << "Got hit collection from " << det.detName()<<" (id= "
          << det.siteDetPackedData() << ") " << " with "
          << hits->collection().size() << " hits." << endreq;

      StatusCode sc;
      // Check if this detector should be simulated.
      if( std::find(m_detectors.begin(),m_detectors.end(),det)
        == m_detectors.end()){
            debug() << "Detector " << det.detName() << " not simulated." << endreq;
            continue;
        }

        if( det.isAD() || det.isWaterShield() ){
            // Process PMT hits
            debug() << "Processing PMT hits" <<endreq;
            DayaBay::ElecPulseCollection* pulses =
              new DayaBay::ElecPulseCollection(pulseHeader, det);
            sc = m_pmtTool->generatePulses(hits, pulses);
            if( sc != StatusCode::SUCCESS ) return sc;
            pulseHeader->addPulseCollection(pulses);

            DayaBay::ElecFeeCrate* crate = new DayaBay::ElecFeeCrate(det,
                                         crateHeader);
            sc = m_feeTool->generateSignals(pulses, crate);
            if( sc != StatusCode::SUCCESS ) return sc;
            crateHeader->addCrate(crate);

        }else if(det.detectorId() == DetectorId::kRPC){
            // Process RPC hits
            if (msgLevel(MSG::DEBUG)) {
                debug() << "Processing RPC hits" <<endreq;
                debug() << "Creating pulses." << endreq;
            }
            DayaBay::ElecPulseCollection* pulses =
              new DayaBay::ElecPulseCollection(pulseHeader, det);
            sc = m_rpcTool->generatePulses(hits, pulses);
            if( sc != StatusCode::SUCCESS ) return sc;
            pulseHeader->addPulseCollection(pulses);

            if (msgLevel(MSG::DEBUG)) {
                debug() << "Converting pulses into signals." << endreq;
            }
            DayaBay::ElecFecCrate* crate = new DayaBay::ElecFecCrate(det,
                                         crateHeader);
            sc = m_fecTool->generateSignals(pulses, crate);
            if( sc != StatusCode::SUCCESS ) return sc;
            if (msgLevel(MSG::DEBUG)) {
                debug() << "Conversion successful." << endreq;
                debug() << "Adding crate into crate header" << endreq;
            }
            crateHeader->addCrate(crate);
        }else{
            error() << "Unknown detector " << det << endreq;
            return StatusCode::FAILURE;
        }
    }

    return StatusCode::SUCCESS;
}
StatusCode EsFrontEndAlg::finalize ( ) [virtual]

Definition at line 272 of file EsFrontEndAlg.cc.

{
    return StatusCode::SUCCESS;
}
DayaBay::ElecHeader * DybAlgorithm< DayaBay::ElecHeader >::GetCurrentHeaderObject ( ) const [inherited]
virtual StatusCode DybAlgorithm< DayaBay::ElecHeader >::sysInitialize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::ElecHeader >::sysExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::ElecHeader >::preExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::ElecHeader >::postExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::ElecHeader >::sysFinalize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

IDataProviderSvc * DybAlgorithm< DayaBay::ElecHeader >::arcSvc ( ) const [inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::ElecHeader >::putTES ( DataObject *  obj,
std::string  location 
) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ElecHeader >::getTES ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ElecHeader >::getAES ( std::string  location,
int  index 
) const [inherited]

Reimplemented from DybBaseAlg.

std::vector< DataObject * > DybAlgorithm< DayaBay::ElecHeader >::getAEScollection ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

int DybAlgorithm< DayaBay::ElecHeader >::getExecNum ( ) [inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::ElecHeader >::Location ( ) const [inherited]

Reimplemented from DybBaseAlg.

DayaBay::ElecHeader * DybAlgorithm< DayaBay::ElecHeader >::MakeHeaderObject ( ) [protected, inherited]
void DybAlgorithm< DayaBay::ElecHeader >::InitializeHeader ( DayaBay::HeaderObject header) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ElecHeader >::MakeHeader ( ) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ElecHeader >::MakeHeader ( std::vector< const DayaBay::IHeader * > &  inputHeaders) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ElecHeader >::MakeHeader ( const DayaBay::IHeader referenceHeader) [protected, inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::ElecHeader >::AppendInputHeader ( const DayaBay::HeaderObject header) const [protected, inherited]

Reimplemented from DybBaseAlg.


Member Data Documentation

std::string EsFrontEndAlg::m_simLocation [private]

Property SimLocation - location in TES where the input SimHeader is to be found.

Default is DayaBay::SimHeader::Default

Definition at line 42 of file EsFrontEndAlg.h.

std::vector<std::string> EsFrontEndAlg::m_detectorNames [private]

Definition at line 45 of file EsFrontEndAlg.h.

std::string EsFrontEndAlg::m_pmtToolName [private]

Definition at line 47 of file EsFrontEndAlg.h.

std::string EsFrontEndAlg::m_rpcToolName [private]

Definition at line 49 of file EsFrontEndAlg.h.

std::string EsFrontEndAlg::m_feeToolName [private]

Definition at line 51 of file EsFrontEndAlg.h.

std::string EsFrontEndAlg::m_fecToolName [private]

Definition at line 53 of file EsFrontEndAlg.h.

Definition at line 56 of file EsFrontEndAlg.h.

Definition at line 58 of file EsFrontEndAlg.h.

Definition at line 60 of file EsFrontEndAlg.h.

Definition at line 62 of file EsFrontEndAlg.h.

Definition at line 64 of file EsFrontEndAlg.h.

Definition at line 67 of file EsFrontEndAlg.h.

Reimplemented from DybBaseAlg.

bool DybAlgorithm< DayaBay::ElecHeader >::m_pullMode [protected, inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::ElecHeader >::m_location [protected, inherited]

Reimplemented from DybBaseAlg.


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:16:37 for ElecSim by doxygen 1.7.4