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

In This Package:

ROsSequencerAlg.cc
Go to the documentation of this file.
00001 #include "ROsSequencerAlg.h"
00002 
00003 #include "Event/SimReadoutHeader.h"
00004 #include "Event/ReadoutPmtCrate.h"
00005 #include "Event/ReadoutRpcCrate.h"
00006 
00007 ROsSequencerAlg::ROsSequencerAlg(const std::string& name, 
00008                                  ISvcLocator* pSvcLocator)
00009   : DybAlgorithm<DayaBay::ReadoutHeader>(name,pSvcLocator)
00010 {
00011     declareProperty("SimReadoutLocation",m_simRoLocation=DayaBay::SimReadoutHeaderLocation::Default,
00012                     "Location in the TES where the input SimReadoutHeader is to be found.");
00013     declareProperty("ReadoutLocation",m_roLocation=DayaBay::ReadoutHeaderLocation::Default,
00014                     "Location in the TES where the output ReadoutHeader is to be put.");
00015 
00016 }
00017 
00018 ROsSequencerAlg::~ROsSequencerAlg()
00019 {
00020 }
00021 
00022 StatusCode ROsSequencerAlg::initialize()
00023 {
00024   return this->GaudiAlgorithm::initialize();
00025 }
00026 
00027 StatusCode ROsSequencerAlg::execute()
00028 {
00029     // Look for pre-existing header object or make new one
00030     DayaBay::ReadoutHeader* roHeader = MakeHeaderObject();
00031     
00032     DayaBay::SimReadoutHeader* simReadoutHeader 
00033       = getTES<DayaBay::SimReadoutHeader>(m_simRoLocation);
00034 
00035     TimeStamp earliest = simReadoutHeader->earliest();
00036     TimeStamp latest = simReadoutHeader->latest();
00037     
00038     roHeader->setEarliest(earliest);
00039     roHeader->setLatest(latest);
00040 
00041     Context context = simReadoutHeader->context();
00042     
00043     
00044     
00045     const DayaBay::SimReadoutHeader::SimReadoutContainer& simReadouts
00046       = simReadoutHeader->readouts();
00047     DayaBay::SimReadoutHeader::SimReadoutContainer::const_iterator simReadoutIter 
00048       = simReadouts.begin();
00049 
00050     if(simReadouts.size() >= 1){
00051       const DayaBay::SimReadout* simReadout = *simReadoutIter;
00052       DayaBay::Detector det(simReadout->readout()->detector());
00053       context.SetSite(det.site());
00054       context.SetDetId(det.detectorId());
00055 
00056       if(det.detectorId() == DetectorId::kAD1
00057          || det.detectorId() == DetectorId::kAD2
00058          || det.detectorId() == DetectorId::kAD3
00059          || det.detectorId() == DetectorId::kAD4
00060          || det.detectorId() == DetectorId::kIWS
00061          || det.detectorId() == DetectorId::kOWS){
00062         const DayaBay::ReadoutPmtCrate* pmtReadout 
00063           = dynamic_cast<const DayaBay::ReadoutPmtCrate*>(simReadout->readout());
00064         if(!pmtReadout){
00065           error() << "Readout from detector " << det 
00066                   << " is not a PMT Crate readout." << endreq;
00067           return StatusCode::FAILURE;
00068         }
00069         DayaBay::ReadoutPmtCrate* readout 
00070           = new DayaBay::ReadoutPmtCrate(*pmtReadout);
00071         readout->setHeader(roHeader);
00072         roHeader->setReadout(readout);
00073       }else if(det.detectorId() == DetectorId::kRPC){
00074         const DayaBay::ReadoutRpcCrate* rpcReadout 
00075           = dynamic_cast<const DayaBay::ReadoutRpcCrate*>(simReadout->readout());
00076         if(!rpcReadout){
00077           error() << "Readout from detector " << det 
00078                   << " is not an RPC Crate readout." << endreq;
00079           return StatusCode::FAILURE;
00080         }
00081         DayaBay::ReadoutRpcCrate* readout 
00082           = new DayaBay::ReadoutRpcCrate(*rpcReadout);
00083         readout->setHeader(roHeader);
00084         roHeader->setReadout(readout);
00085       }else{
00086         error() << "Unknown detector " << det 
00087                 << " for readout " << simReadout << endreq;
00088         return StatusCode::FAILURE;
00089       }
00090       if(simReadouts.size() > 1){
00091         warning() << "Simulation produced " << simReadouts.size()
00092                   <<" readouts, ignoring all but first."  << endreq;
00093       }
00094     }else{
00095       roHeader->setReadout(0);
00096       info() << "No Readouts produced this cycle." << endreq;
00097       context.SetSite(Site::kUnknown);
00098       context.SetDetId(DetectorId::kUnknown);
00099     }
00100     roHeader->setContext(context);
00101     return StatusCode::SUCCESS;
00102 }
00103 
00104 StatusCode ROsSequencerAlg::finalize()
00105 {
00106   return this->GaudiAlgorithm::finalize();
00107 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:17:05 for ReadoutSim by doxygen 1.7.4