/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 | Private Types | Private Member Functions | Private Attributes
SingleLoader Class Reference

#include <SingleLoader.h>

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

List of all members.

Public Member Functions

 SingleLoader (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~SingleLoader ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
StatusCode registerData (IStageData &data)
IStagethisStage ()
IStagelowerStage ()

Private Types

typedef HeaderStageData
< SimReadoutHeader
SimReadoutData
typedef HeaderStageData
< ReadoutHeader
ReadoutData
typedef std::multimap
< TimeStamp, Readout
*, std::less< TimeStamp > > 
ReadoutMultimap

Private Member Functions

StatusCode fillPipeline (SimReadoutHeader *pSimReadoutHeader)
 execution detail

Private Attributes

FFTimeStamp m_currentTime
 The earliest (smallest) time which this has provided.
ReadoutMultimap m_readoutMultimap
SimReadoutHeaderm_pCurrentSRHeader

Detailed Description

Definition at line 24 of file SingleLoader.h.


Member Typedef Documentation

Definition at line 42 of file SingleLoader.h.

Definition at line 43 of file SingleLoader.h.

typedef std::multimap<TimeStamp,Readout*, std::less<TimeStamp> > SingleLoader::ReadoutMultimap [private]

Definition at line 47 of file SingleLoader.h.


Constructor & Destructor Documentation

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

Definition at line 9 of file SingleLoader.cc.

SingleLoader::~SingleLoader ( ) [virtual]

Definition at line 15 of file SingleLoader.cc.

{
}

Member Function Documentation

StatusCode SingleLoader::initialize ( ) [virtual]

Reimplemented from StageProcessor< DayaBay::ReadoutHeader >.

Definition at line 20 of file SingleLoader.cc.

{
  StatusCode status = this->StageProcessor<ReadoutHeader>::initialize();
  if (status.isFailure()) return status;

  m_readoutMultimap.clear();

  return StatusCode::SUCCESS;
}
StatusCode SingleLoader::execute ( ) [virtual]

Definition at line 30 of file SingleLoader.cc.

{
  debug()<<"executing... "<<endreq;
  // Only do anything if the current stage time has advanced beyond
  // the last time we ran.
  static bool first_time = true;
  if (!first_time && m_currentTime > thisStage()->currentTime()) {
    return StatusCode::SUCCESS;
  }
  first_time = false;

  // preExecute
  StatusCode sc = this->preExecute();
  if (sc.isFailure()) return sc;


  // keep trying until get at least one Readout in pipeline
  while(m_readoutMultimap.size()==0) {
    // get SimReadoutHeader
    IStageData* pIStageData = 0;
    sc = lowerStage()->nextElement(pIStageData);
    if (sc.isFailure()) return sc;
    
    // cast it to SimReadoutData
    const SimReadoutData* input =0;
    try{
      input = dynamic_cast<SimReadoutData*>(pIStageData);
    }
    catch(...) {
      error()<<"Failed to get SimReadoutData pointer"<<endreq;
    }
    // get SimReadoutHeader
    SimReadoutHeader* pSrHeader = &input->header();
    
    sc = this->fillPipeline(pSrHeader);
    if (sc.isFailure()) return sc;
    debug()<<"exec num "<<pSrHeader->execNumber()<<endreq;

    // It will not be used again
    delete input; input = 0;
  }

  // get the first Readout from pipeline
  ReadoutMultimap::iterator top=m_readoutMultimap.begin();
  TimeStamp ts=top->first;
  Readout* pReadout=top->second;
  m_readoutMultimap.erase(top);

  // define output header
  ReadoutHeader* pReadoutHeader=MakeHeaderObject();
  pReadoutHeader->setReadout(pReadout);
  pReadout->setHeader(pReadoutHeader);

  // set context and update detector and site infor
  Context context = m_pCurrentSRHeader->context();
  // After spliting, the detector infor should be specific to it.
  DayaBay::Detector det(pReadout->detector());
  context.SetSite(det.site());
  context.SetDetId(det.detectorId());

  pReadoutHeader->setContext( context );

  // set its time
  pReadoutHeader->setEarliest(ts);
  pReadoutHeader->setLatest(ts);
  pReadoutHeader->setTimeStamp(ts);

  // define ReadoutData
  ReadoutData* output=new ReadoutData(*pReadoutHeader);

  // input header
  AppendInputHeader(m_pCurrentSRHeader);

  // push out
  thisStage()->pushElement(output);
  this->registerData(*output);
  debug()<<"to grep: new data pushed out at time "<<output->time()<<endreq;

  // update current time
  m_currentTime=output->time();

  // postExecute, in AES now
  sc = this->postExecute();

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

Definition at line 118 of file SingleLoader.cc.

StatusCode SingleLoader::fillPipeline ( SimReadoutHeader pSimReadoutHeader) [private]

execution detail

Definition at line 123 of file SingleLoader.cc.

{
  // m_pCurrentSRHeader might live multi execution cycles, protection needed.
  if(m_pCurrentSRHeader != 0) {
    m_pCurrentSRHeader->release();
  }

  debug() <<"Get pSimReadoutHeader at "<<pSimReadoutHeader<<endreq;
  SimReadoutHeader::SimReadoutContainer readouts = pSimReadoutHeader->readouts();
  int size = readouts.size();
  debug() << "It has "<<size<<" readouts"<<endreq;
  debug() << "TimeStamp "<<pSimReadoutHeader->timeStamp()<<endreq;
  debug() << "Earliest  "<<pSimReadoutHeader->earliest()<<endreq;
  debug() << "Latest    "<<pSimReadoutHeader->latest()<<endreq;

  m_pCurrentSRHeader=pSimReadoutHeader;
  m_pCurrentSRHeader->addRef();

  DayaBay::SimReadoutHeader::SimReadoutContainer& sroc = pSimReadoutHeader->readouts();
  for (size_t ind=0; ind<sroc.size(); ++ind) {
    DayaBay::SimReadout* pSimReadout = sroc[ind];
    TimeStamp ts = pSimReadout->readout()->triggerTime();

    // The following deep copy or cast has very weird problem
    const DayaBay::Readout* pReadout = pSimReadout->readout();
    DayaBay::Detector det(pReadout->detector());

    if(det.detectorId() == DetectorId::kAD1
       || det.detectorId() == DetectorId::kAD2
       || det.detectorId() == DetectorId::kAD3
       || det.detectorId() == DetectorId::kAD4
       || det.detectorId() == DetectorId::kIWS
       || det.detectorId() == DetectorId::kOWS){

      const DayaBay::ReadoutPmtCrate* pmtcrate = 0;
      try{
        pmtcrate = dynamic_cast<const DayaBay::ReadoutPmtCrate*>(pReadout);
      }
      catch(...) {
        error()<<"Failed to get ReadoutPmtCrate pointer"<<endreq;
      }
      // create a new one, deep copy
      DayaBay::ReadoutPmtCrate *pout = new DayaBay::ReadoutPmtCrate(*pmtcrate);
      
      m_readoutMultimap.insert(pair<TimeStamp,DayaBay::Readout*>(ts,pout));

    } else if( det.detectorId() == DetectorId::kRPC )  {
      const DayaBay::ReadoutRpcCrate* rpccrate = 0;
      try{
        rpccrate = dynamic_cast<const DayaBay::ReadoutRpcCrate*>(pReadout);
      }
      catch(...) {
        error()<<"Failed to get ReadoutRpcCrate pointer"<<endreq;
      }
      // create a new one, deep copy
      DayaBay::ReadoutRpcCrate *pout = new DayaBay::ReadoutRpcCrate(*rpccrate);
      
      m_readoutMultimap.insert(pair<TimeStamp,DayaBay::Readout*>(ts,pout));

    } else if( det.detectorId() == DetectorId::kUnknown )  {
      DayaBay::Readout *pout = new DayaBay::Readout(*pReadout);
      m_readoutMultimap.insert(pair<TimeStamp, DayaBay::Readout*>(ts,pout));
    }
  }

  debug() << "fillPipeline(): Adding " << sroc.size() << " Readout" << endreq;
  
  return StatusCode::SUCCESS;
}
StatusCode StageProcessor< class >::registerData ( IStageData data) [inherited]
IStage * StageProcessor< class >::thisStage ( ) [inherited]
IStage * StageProcessor< class >::lowerStage ( ) [inherited]

Member Data Documentation

The earliest (smallest) time which this has provided.

Definition at line 37 of file SingleLoader.h.

Definition at line 48 of file SingleLoader.h.

Definition at line 51 of file SingleLoader.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:16:29 for SingleLoader by doxygen 1.7.4