/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 #include "ADLEDTag.h" 00002 //#include "Event/CalibReadoutHeader.h" 00003 #include "Event/HeaderObject.h" 00004 #include "Event/ReadoutHeader.h" 00005 #include "Event/UserDataHeader.h" 00006 #include "Event/JobInfo.h" 00007 #include "Conventions/JobId.h" 00008 #include "DataSvc/IJobInfoSvc.h" 00009 #include "GaudiKernel/SystemOfUnits.h" 00010 00011 00012 ADLEDTag::ADLEDTag(const std::string& name, ISvcLocator* svcloc) 00013 : GaudiAlgorithm(name, svcloc) 00014 { 00015 declareProperty("ReadoutHeaderLocation", m_readoutHeaderLocation="/Event/Readout/ReadoutHeader", 00016 "Location of the ReadoutHeader"); 00017 declareProperty("CalibStatsLocation", m_calibStatsLocation="/Event/Data/CalibStats", 00018 "Location of the CalibStats User data"); 00019 declareProperty("ADLEDLocation", m_ADLEDLocation="/Event/Tag/Calib/ADLED", 00020 "Location of the ADLED Tag"); 00021 } 00022 00023 ADLEDTag::~ADLEDTag() 00024 { 00025 } 00026 00027 StatusCode ADLEDTag::initialize() 00028 { 00029 debug() << "initialize()" << endreq; 00030 00031 m_jobInfoSvc = svc<IJobInfoSvc>("JobInfoSvc",true); 00032 if(!m_jobInfoSvc) { 00033 error() << "Failed to initialize JobInfoSvc" << endreq; 00034 return StatusCode::FAILURE; 00035 } 00036 m_tagged = 0; 00037 00038 return StatusCode::SUCCESS; 00039 } 00040 00041 StatusCode ADLEDTag::execute() 00042 { 00043 debug() << "execute() ______________________________ start" << endreq; 00044 00045 const DayaBay::ReadoutHeader *readoutHdr = 0; // DayaBay::CLID_CalibReadoutHeader 00046 DayaBay::UserDataHeader *calibStatsHdr = 0; // 00047 00048 //Get Raw Readout Header 00049 if ( !exist<DayaBay::ReadoutHeader>(evtSvc(), m_readoutHeaderLocation)) { 00050 warning() << "Cannot find header at " << m_readoutHeaderLocation << endreq; 00051 return StatusCode::FAILURE; 00052 } else { 00053 readoutHdr = get<DayaBay::ReadoutHeader>(m_readoutHeaderLocation); 00054 } 00055 00056 //Get CalibStats Header 00057 if (!exist<DayaBay::UserDataHeader>(evtSvc(), m_calibStatsLocation)) { 00058 warning() << "Cannot find header at " << m_calibStatsLocation << endreq; 00059 return StatusCode::FAILURE; 00060 } else { 00061 calibStatsHdr = get<DayaBay::UserDataHeader>(m_calibStatsLocation); 00062 } 00063 00064 DetectorId::DetectorId_t detectorId = readoutHdr->context().GetDetId(); 00065 //ingore RPC readouts 00066 if(detectorId == DetectorId::kRPC) return StatusCode::SUCCESS; 00067 //info() << "detectorId = " << detectorId << endreq; 00068 00069 //const DayaBay::Readout * readout = readoutHeader->readout(); 00070 const DayaBay::DaqPmtCrate * readout = readoutHdr->daqCrate()->asPmtCrate(); 00071 //readoutHdr.daqCrate().asPmtCrate() 00072 if(readout == 0){ 00073 warning() << "Cannot find readout from readout header" << endreq; 00074 return StatusCode::FAILURE; 00075 } 00076 00077 DayaBay::Trigger::TriggerType_t triggerType = readout->triggerType(); 00078 //info() << "triggerType = " << std::hex << "0x" << triggerType << endreq; 00079 00080 // Only consider AD triggers 00081 if (detectorId == DetectorId::kAD1 || detectorId == DetectorId::kAD2 00082 || detectorId == DetectorId::kAD3 || detectorId == DetectorId::kAD4) { 00083 // Skip if not cross-in (aka calib) trigger 00084 if ((triggerType & DayaBay::Trigger::kCalib) == DayaBay::Trigger::kNone){ 00085 return StatusCode::SUCCESS; 00086 } 00087 } 00088 00089 // Tag as ADLED event 00090 DayaBay::HeaderObject *header = new DayaBay::HeaderObject(); 00091 std::vector<const DayaBay::IHeader*> inputHeaders; 00092 inputHeaders.push_back(readoutHdr); 00093 inputHeaders.push_back(calibStatsHdr); 00094 header->setInputHeaders(inputHeaders); 00095 header->setExecNumber(readoutHdr->execNumber()); 00096 header->setContext(readoutHdr->context()); 00097 header->setEarliest(readoutHdr->earliest()); 00098 header->setLatest(readoutHdr->latest()); 00099 m_tagged++; 00100 00101 const DayaBay::JobId &m_currentJobId = m_jobInfoSvc->currentJobInfo()->jobId(); 00102 header->setJobId(m_currentJobId); 00103 00104 put(header, m_ADLEDLocation); 00105 00106 debug() << "execute() ______________________________ end" << endreq; 00107 return StatusCode::SUCCESS; 00108 } 00109 00110 StatusCode ADLEDTag::finalize() 00111 { 00112 debug() << "finalize()" << endreq; 00113 switch(m_tagged){ 00114 case 0: info () << "No trigger was tagged as ADLED event." << endreq; break; 00115 case 1: info () << "Only one trigger was tagged as ADLED event." << endreq; break; 00116 default: info () << m_tagged << " triggers were tagged as ADLED events." << endreq; 00117 } 00118 return StatusCode::SUCCESS; 00119 } 00120