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

EsTestAlg. More...

#include <EsTestAlg.h>

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

List of all members.

Public Member Functions

 EsTestAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~EsTestAlg ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
DayaBay::SimHeaderGetCurrentHeaderObject () 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::SimHeaderMakeHeaderObject ()
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 Member Functions

DayaBay::SimHitCollection::hit_container genHitCollection (Context context, DayaBay::SimHitCollection *shc)

Private Attributes

std::string m_simLocation
 Property SimLocation - location in TES where the input SimHeader is to be put.
std::string m_cableSvcName
std::vector< std::string > m_detectors
double m_simWindow
double m_simDeltaT
double m_simStartTime
TimeStamp m_currentTime
double m_promptCharge
int m_delayedCharge
double m_delayTime
double m_weight
std::string m_chargeMode
double m_timeSmear
bool m_singleChannel
Rndm::Numbers m_uni
Rndm::Numbers m_gauss
Rndm::Numbers m_poisson
std::vector
< DayaBay::DetectorSensor
m_sensors
std::vector< int > m_sensorIds
ICableSvcm_cableSvc

Detailed Description

EsTestAlg.

Used to feed electronics simulation with dummy p.e. hits

Definition at line 19 of file EsTestAlg.h.


Constructor & Destructor Documentation

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

Definition at line 7 of file EsTestAlg.cc.

  : DybAlgorithm<DayaBay::SimHeader>(name,pSvcLocator),
    m_detectors(),
    m_sensors(),
    m_sensorIds(),
    m_cableSvc(0)
{
    declareProperty("CableSvcName",m_cableSvcName="CableSvc",
                    "Name of service to map between detector, hardware, and    electronic IDs");
    declareProperty("SimLocation",m_simLocation=DayaBay::SimHeaderLocation::Default,
                    "Location in the TES where the input SimHeader is to be found.");
    declareProperty("Detectors",m_detectors,
                    "List of detectors to simulate");
    declareProperty("SimWindow",m_simWindow=0,
                    "Length of the simulation time window");
    declareProperty("SimDeltaT",m_simDeltaT=1.0*CLHEP::second,
                    "Time between each simulation cycle");
    declareProperty("SimStartTime",m_simStartTime=1000.0,
                    "Starting timestamp of the simulation");
    declareProperty("PromptCharge",m_promptCharge=1,
                    "Mean prompt charge per channel in p.e.");
    declareProperty("DelayedCharge",m_delayedCharge=0,
                    "Delayed charge per channel in p.e.");
    declareProperty("DelayTime",m_delayTime=500,
                    "Time between prompt and delayed hits in ns");
    declareProperty("Weight",m_weight=1,
                    "Weight of each hit");
    declareProperty("ChargeMode",m_chargeMode="Fixed",
                    "Charge distribution mode: Fixed or Poisson");
    declareProperty("TimeSmear",m_timeSmear=0,
                    "Sigma of hit time smearing");
    declareProperty("SingleChannel",m_singleChannel=false,
                    "Only simulate 1 channel");
    declareProperty("Channels",m_sensorIds,
                    "List of channels to simulate");

}
EsTestAlg::~EsTestAlg ( ) [virtual]

Definition at line 45 of file EsTestAlg.cc.

{
}

Member Function Documentation

StatusCode EsTestAlg::initialize ( ) [virtual]

Definition at line 49 of file EsTestAlg.cc.

{
  info() << "Initialize EsTestAlg " << endreq;
  m_currentTime = m_simStartTime;

  // Get Cable Service
  m_cableSvc = svc<ICableSvc>(m_cableSvcName,true);

  // Random number service
  IRndmGenSvc *rgs = 0;
  if (service("RndmGenSvc",rgs,true).isFailure()) {
    fatal() << "Failed to get random service" << endreq;
    return StatusCode::FAILURE;
  }

  StatusCode sc;
  sc = m_uni.initialize(rgs, Rndm::Flat(0,1));
  if (sc.isFailure()) {
    fatal() << "Failed to initialize uniform random numbers" << endreq;
    return StatusCode::FAILURE;
  }
  if(m_timeSmear>0){
    m_simWindow += m_timeSmear * 8 * 1e-9;
    sc = m_gauss.initialize(rgs, Rndm::Gauss(4*m_timeSmear,m_timeSmear));
    if (sc.isFailure()) {
      fatal() << "Failed to initialize gaussian random numbers" << endreq;
      return StatusCode::FAILURE;
    }
  }
  if(m_delayedCharge>0){
    m_simWindow += m_delayTime * 1e-9;
  }
  if(m_chargeMode=="Poisson"){
    sc = m_poisson.initialize(rgs, Rndm::Poisson(m_promptCharge));
    if (sc.isFailure()) {
      fatal() << "Failed to initialize poisson random numbers" << endreq;
      return StatusCode::FAILURE;
    }
  }

  // prepare channels to be simulated
    if(m_sensorIds.size() > 0) {
        std::vector<int>::iterator idIt, idDone = m_sensorIds.end();
        for (idIt = m_sensorIds.begin(); idIt != idDone; idIt++) {
            m_sensors.push_back(DayaBay::DetectorSensor(*idIt));
        }
    }

  //if (m_channels.size() > 0) {
      //std::vector<DayaBay::DetectorSensor>::iterator it, done = m_channels.end();
      //for (it = m_channels.begin(); it != done; it++) {
          //DayaBay::Detector det(it->site(), it->detectorId());
          //m_channelsByDet[det].push_bach(*it);
      //}
  //}
  info() << "Finish initializing EsTestAlg " << endreq;
  return StatusCode::SUCCESS;
}
StatusCode EsTestAlg::execute ( ) [virtual]

Definition at line 108 of file EsTestAlg.cc.

{
  // Create output header
  DayaBay::SimHeader* simHeader = MakeHeaderObject();
  simHeader->setTimeStamp( m_currentTime );

  // Set the simulation time range
  // Add padding to ElecHeader time window
  TimeStamp earliest = m_currentTime;
  TimeStamp latest = m_currentTime;
  latest.Add(m_simWindow);
  simHeader->setEarliest(earliest);
  simHeader->setLatest(latest);
  Context context;
  context.SetSimFlag(SimFlag::kMC);
  context.SetTimeStamp(earliest);

  // Add the sim hit header to sim header and vice versa
  DayaBay::SimHitHeader* hitHeader =
  new DayaBay::SimHitHeader(simHeader);
  simHeader->setHits(hitHeader);
  DayaBay::SimHitCollection::hit_container hits;

  bool firstDetector = true;
  // Loop over detectors and add sim hit collection for each detector
  std::vector<std::string>::const_iterator detIter, end =
    m_detectors.end();
  for(detIter = m_detectors.begin(); detIter != end; detIter++){
    DayaBay::Detector detector
    = DayaBay::Detector::siteDetPackedFromString(*detIter);
    // Reset context if needed
    if(firstDetector){
      // Keep track of sites/detectors in this simulation for context
      context.SetSite(detector.site());
      context.SetDetId(detector.detectorId());
      firstDetector = false;
    }
    if(context.GetSite() != detector.site()){
      // Simulation contains multiple sites, unset
      context.SetSite(Site::kUnknown);
    }
    if(context.GetDetId() != detector.detectorId()){
      // Simulation contains multiple detectors, unset
      context.SetDetId(DetectorId::kUnknown);
    }

    DayaBay::SimHitCollection* shc = new DayaBay::SimHitCollection(hitHeader,detector,hits);
    hits = genHitCollection(context, shc);

    shc->setDetector(detector);
    shc->setCollection(hits);
    info() << "Adding " << shc->collection().size() << " "
    << detector.detName() << " hits to header." << endreq;
    hitHeader->addHitCollection(shc);
  }
  simHeader->setContext(context);
  m_currentTime.Add(m_simDeltaT / CLHEP::second);

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

Definition at line 169 of file EsTestAlg.cc.

{
  return StatusCode::SUCCESS;
}
DayaBay::SimHitCollection::hit_container EsTestAlg::genHitCollection ( Context  context,
DayaBay::SimHitCollection shc 
) [private]

Definition at line 174 of file EsTestAlg.cc.

                                                                                                               {
  DayaBay::SimHitCollection::hit_container hitCol;
  int task = 0;
  ServiceMode svcMode(context, task);
  const std::vector<DayaBay::DetectorSensor>& detSensors = (m_sensors.size() == 0) ? m_cableSvc->sensors( svcMode) : m_sensors;
  //if (m_sensors.size() == 0) {
      //detSensors = m_cableSvc->sensors( svcMode);
  //}

  for (size_t idet = 0; idet < detSensors.size(); ++idet) {
    DayaBay::DetectorSensor detSens = detSensors[idet];
    DayaBay::AdPmtSensor pmtid(detSens.fullPackedData());
    //info() << "pmtid: " << pmtid << endreq;
    int hitNumber =  int(m_promptCharge);
    if(m_chargeMode=="Poisson") hitNumber = int(m_poisson());
    for (int iHit=0; iHit<hitNumber; iHit++){
      DayaBay::SimHit* hit = new DayaBay::SimHit();
      double hitTime;
      if(m_timeSmear==0) hitTime = 0;
      else hitTime = m_gauss();
      if(hitTime<0) hitTime = 0;
      if(hitTime>8*m_timeSmear) hitTime = 4*m_timeSmear;
      hit->setHitTime(hitTime);
      hit->setSensDetId(detSens.fullPackedData());
      hit->setHc(shc);
      hit->setWeight(m_weight);
      //hit->setLocalPos (const CLHEP::Hep3Vector &value)
      hitCol.push_back(hit);
    }
    hitNumber =  m_delayedCharge;
    for (int iHit=0; iHit<hitNumber; iHit++){
      DayaBay::SimHit* hit = new DayaBay::SimHit();
      hit->setSensDetId(detSens.fullPackedData());
      hit->setHc(shc);
      hit->setHitTime(m_delayTime);
      hit->setWeight(m_weight);
      hitCol.push_back(hit);
    }
    if(m_singleChannel) break;
  }
  return hitCol;
}
DayaBay::SimHeader * DybAlgorithm< DayaBay::SimHeader >::GetCurrentHeaderObject ( ) const [inherited]
virtual StatusCode DybAlgorithm< DayaBay::SimHeader >::sysInitialize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.


Member Data Documentation

std::string EsTestAlg::m_simLocation [private]

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

Default is DayaBay::SimHeader::Default

Definition at line 37 of file EsTestAlg.h.

std::string EsTestAlg::m_cableSvcName [private]

Definition at line 40 of file EsTestAlg.h.

std::vector<std::string> EsTestAlg::m_detectors [private]

Definition at line 43 of file EsTestAlg.h.

double EsTestAlg::m_simWindow [private]

Definition at line 45 of file EsTestAlg.h.

double EsTestAlg::m_simDeltaT [private]

Definition at line 47 of file EsTestAlg.h.

double EsTestAlg::m_simStartTime [private]

Definition at line 49 of file EsTestAlg.h.

Definition at line 51 of file EsTestAlg.h.

double EsTestAlg::m_promptCharge [private]

Definition at line 53 of file EsTestAlg.h.

Definition at line 55 of file EsTestAlg.h.

double EsTestAlg::m_delayTime [private]

Definition at line 57 of file EsTestAlg.h.

double EsTestAlg::m_weight [private]

Definition at line 59 of file EsTestAlg.h.

std::string EsTestAlg::m_chargeMode [private]

Definition at line 63 of file EsTestAlg.h.

double EsTestAlg::m_timeSmear [private]

Definition at line 65 of file EsTestAlg.h.

Definition at line 67 of file EsTestAlg.h.

Rndm::Numbers EsTestAlg::m_uni [private]

Definition at line 69 of file EsTestAlg.h.

Rndm::Numbers EsTestAlg::m_gauss [private]

Definition at line 69 of file EsTestAlg.h.

Rndm::Numbers EsTestAlg::m_poisson [private]

Definition at line 69 of file EsTestAlg.h.

Definition at line 71 of file EsTestAlg.h.

std::vector<int> EsTestAlg::m_sensorIds [private]

Definition at line 72 of file EsTestAlg.h.

Definition at line 76 of file EsTestAlg.h.

Reimplemented from DybBaseAlg.

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

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::SimHeader >::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