| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

EsDarkDetectorAlg.cc

Go to the documentation of this file.
00001 #include "EsDarkDetectorAlg.h"
00002 
00003 #include "Event/SimHeader.h"
00004 #include "Conventions/Detectors.h"
00005 #include "CLHEP/Units/SystemOfUnits.h"
00006 
00007 EsDarkDetectorAlg::EsDarkDetectorAlg(const std::string& name, ISvcLocator* pSvcLocator)
00008   : DybAlgorithm<DayaBay::SimHeader>(name,pSvcLocator),
00009     m_detectors()
00010 {
00011     declareProperty("SimLocation",m_simLocation=DayaBay::SimHeaderLocation::Default,
00012                     "Location in the TES where the input SimHeader is to be found.");
00013     declareProperty("Detectors",m_detectors,
00014                     "List of detectors to simulate");
00015     declareProperty("SimWindow",m_simWindow=0,
00016                     "Length of the simulation time window");
00017     declareProperty("SimDeltaT",m_simDeltaT=1.0*CLHEP::second,
00018                     "Time between each simulation cycle");
00019     declareProperty("SimStartTime",m_simStartTime=0.0,
00020                     "Starting timestamp of the simulation");
00021 }
00022 
00023 EsDarkDetectorAlg::~EsDarkDetectorAlg()
00024 {
00025 }
00026 
00027 StatusCode EsDarkDetectorAlg::initialize()
00028 {
00029   m_currentTime = m_simStartTime;
00030   return StatusCode::SUCCESS;
00031 }
00032 
00033 StatusCode EsDarkDetectorAlg::execute()
00034 {
00035     // Create output header 
00036     DayaBay::SimHeader* simHeader = MakeHeaderObject();
00037     simHeader->setTimeStamp( m_currentTime );
00038 
00039     // Set the simulation time range
00040     // Add padding to ElecHeader time window
00041     TimeStamp earliest = m_currentTime;
00042     TimeStamp latest = m_currentTime;
00043     latest.Add(m_simWindow);
00044     simHeader->setEarliest(earliest);
00045     simHeader->setLatest(latest);
00046     Context context;
00047     context.SetSimFlag(SimFlag::kMC);
00048     context.SetTimeStamp(earliest);
00049 
00050     // Add the sim hit header
00051     DayaBay::SimHitHeader* hitHeader = 
00052       new DayaBay::SimHitHeader(simHeader);
00053     simHeader->setHits(hitHeader);
00054     DayaBay::SimHitCollection::hit_container hits;
00055 
00056     bool firstDetector = true;
00057     // Loop over detectors and add an empty sim hit collection for each detector
00058     std::vector<std::string>::const_iterator detIter, end = 
00059       m_detectors.end();
00060     for(detIter = m_detectors.begin(); detIter != end; detIter++){
00061       DayaBay::Detector detector 
00062         = DayaBay::Detector::siteDetPackedFromString(*detIter);
00063       hitHeader->addHitCollection(
00064                       new DayaBay::SimHitCollection(hitHeader,detector,hits));
00065 
00066       // Reset context if needed
00067       if(firstDetector){
00068         // Keep track of sites/detectors in this simulation for context
00069         context.SetSite(detector.site());
00070         context.SetDetId(detector.detectorId());
00071         firstDetector = false;
00072       }
00073       if(context.GetSite() != detector.site()){
00074         // Simulation contains multiple sites, unset
00075         context.SetSite(Site::kUnknown);
00076       }
00077       if(context.GetDetId() != detector.detectorId()){
00078         // Simulation contains multiple detectors, unset
00079         context.SetDetId(DetectorId::kUnknown);
00080       }
00081     }
00082     simHeader->setContext(context);
00083 
00084     m_currentTime.Add(m_simDeltaT / CLHEP::second);
00085     return StatusCode::SUCCESS;
00086 }
00087 
00088 StatusCode EsDarkDetectorAlg::finalize()
00089 {
00090     return StatusCode::SUCCESS;
00091 }
00092 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:49:26 2011 for ElecSim by doxygen 1.4.7