00001 #include "src/TESDemoFill1.h"
00002
00003 #include "GaudiKernel/IDataProviderSvc.h"
00004
00005 #include "Event/TESDemoReadout.h"
00006 #include "Event/TESDemoPositron.h"
00007
00008 #include <cstdlib>
00009
00010 using namespace DayaBay;
00011
00012 TESDemoFill1::TESDemoFill1( const std::string& name,
00013 ISvcLocator* pSvcLocator ) :
00014 GaudiAlgorithm(name,
00015 pSvcLocator)
00016 {
00017 declareProperty("PositronPercentage",
00018 m_percentage=50,
00019 "Percentage of Readouts to contain Positrons");
00020 declareProperty("ReadoutPath",
00021 m_readoutPath="/Event/TESDemo/Readout",
00022 "Path from which to retrieve the Readouts");
00023 declareProperty("PositronPath",
00024 m_positronPath="/Event/TESDemo/Positron",
00025 "Path, in the TES, into which the Positron is stored");
00026 }
00027
00028 StatusCode TESDemoFill1::initialize() {
00029
00030 info() << "in initialize"
00031 << endreq;
00032 info() << m_percentage
00033 << endreq;
00034 info() << m_readoutPath
00035 << endreq;
00036 info() << m_positronPath
00037 << endreq;
00038 return StatusCode::SUCCESS;
00039
00040 }
00041
00042 StatusCode TESDemoFill1::execute() {
00043
00044 SmartDataPtr<const TESDemoReadout> readout(eventSvc(),
00045 m_readoutPath.value());
00046 if (0 == readout) {
00047 return Error("Failed to retrieve readout from Event Store");
00048 }
00049
00050
00051 if (random() % 101 <= m_percentage.value()) {
00052 return StatusCode::SUCCESS;
00053 }
00054
00055 TESDemoPositron* positron = new TESDemoPositron(readout->timeStamp(),
00056 readout);
00057 StatusCode status = eventSvc()->registerObject(m_positronPath.value(),
00058 positron);
00059 if (status.isFailure()) {
00060 return Error("Failed to store positron in Event Store",
00061 status);
00062 }
00063
00064 return StatusCode::SUCCESS;
00065 }
00066
00067 StatusCode TESDemoFill1::finalize() {
00068
00069 info() << "in finalize"
00070 << endreq;
00071 return StatusCode::SUCCESS;
00072
00073 }
00074
00075
00076