#include <TrigEventMaker.h>
Public Member Functions | |
TrigEventMaker (const std::string &name, ISvcLocator *pSvcLocator) | |
StatusCode | initialize () |
StatusCode | execute () |
StatusCode | finalize () |
Definition at line 6 of file TrigEventMaker.h.
TrigEventMaker::TrigEventMaker | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Definition at line 17 of file TrigEventMaker.cxx.
00017 : Algorithm(name, pSvcLocator) 00018 { 00019 //Declare the properties 00020 }
StatusCode TrigEventMaker::execute | ( | ) |
Definition at line 28 of file TrigEventMaker.cxx.
References Bes_Common::DEBUG, Bes_Common::FATAL, genRecEmupikp::i, Bes_Common::INFO, iter(), ganga-rec::j, msgSvc(), delete_small_size::size, and EventModel::Trig::TrigData.
00028 { 00029 MsgStream log(msgSvc(),name()); 00030 log<<MSG::DEBUG<< "TrigEventMaker: in execute()" <<endreq; 00031 00032 // Get the event header, print out event and run number 00033 00034 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader"); 00035 if (!eventHeader) { 00036 log << MSG::FATAL << "Could not find Event Header" << endreq; 00037 return StatusCode::FAILURE; 00038 } 00039 00040 int eventId = eventHeader->eventNumber() ; 00041 int runId = eventHeader->runNumber(); 00042 log << MSG::INFO << "TrigEventMaker: retrieved event: " <<" Event Number "<< eventId << " run: " <<runId << endreq; 00043 00044 //define elements in TrigData structure 00045 int trgCond[48]; 00046 int trgChan[16]; 00047 int window = 0; 00048 int timing = 0; 00049 bool preScale = false; 00050 00051 //initialize the elements defined above 00052 for(int i = 0; i < 48; i++) { 00053 if(i < 16) trgChan[i] = 0; 00054 trgCond[i] = 0; 00055 } 00056 00057 //Get trigger information from TDS 00058 SmartDataPtr<TrigGTDCol> trigGTDCol(eventSvc(),"/Event/Trig/TrigGTDCol"); 00059 if (!trigGTDCol) { 00060 log << MSG::FATAL << "Could not find TrigGTDCol!" << endreq; 00061 return StatusCode::FAILURE; 00062 } 00063 00064 TrigGTDCol::iterator iter = trigGTDCol->begin(); 00065 for (;iter != trigGTDCol->end(); iter++ ) { 00066 const uint32_t boardId = (*iter)->getId(); //The board Id 0xd3: GTL, 0xD2: SAF1, 0xD4: SAF2, 0xD6: SAF3 00067 const uint32_t timeWindow = (*iter)->getTimeWindow(); //Time window, bit8 to bit13, total: 0--31 00068 //const uint32_t dataType = (*iter)->getDataType(); //bit3 to bit7, total: 0--31 00069 const uint32_t size = (*iter)->getDataSize(); //The size of trigger data, not include head 00070 const uint32_t* trigData = (*iter)->getDataPtr(); //Trigger data 00071 00072 window = timeWindow; 00073 00074 //Get data group 5 in GTL, including trigger channel, timing and prescale. 00075 if(boardId == 0xd3) { 00076 if(size%timeWindow != 0) { 00077 log << MSG::FATAL << "GTL data is NOT completed" << endreq; 00078 return StatusCode::FAILURE; 00079 } 00080 for(uint32_t j = 0; j < size; j++) { 00081 uint32_t dataId = ((trigData[j] >> 24) & 0x7); 00082 if(dataId != 5) continue; //find data group 5 00083 for(uint32_t i = 1, loop = 0; loop < 24; i <<= 1, loop++) { 00084 if(loop < 16) { 00085 if(trigData[j] & i) trgChan[loop] = 1; 00086 } 00087 if((loop == 16) && (trigData[j] & i)) timing = 1; 00088 if((loop == 17) && (trigData[j] & i) && (timing != 1)) timing = 2; 00089 if((loop == 18) && (trigData[j] & i) && (timing == 0)) timing = 3; 00090 if((loop == 21) && (trigData[j] & i)) preScale = true; 00091 } 00092 } 00093 } 00094 //Get "or 4" in SAF 00095 if(boardId == 0xd2 || boardId == 0xd4 || boardId == 0xd6) { 00096 for(uint32_t j = 0; j < size; j++) { 00097 uint32_t dataId = ((trigData[j] >> 16) & 0xFF); 00098 if(dataId != 4) continue; //find data "or 4" in SAF 00099 for(uint32_t i = 1, loop = 0; loop < 16; i <<= 1, loop++) { 00100 if((boardId == 0xd2) && (trigData[j] & i)) trgCond[32+loop] = 1; 00101 if((boardId == 0xd4) && (trigData[j] & i)) trgCond[16+loop] = 1; 00102 if((boardId == 0xd6) && (trigData[j] & i)) trgCond[loop] = 1; 00103 } 00104 } 00105 } 00106 } 00107 00108 //Register related trigger information to TDS for physics analysis 00109 TrigData* aTrigData = new TrigData(window, timing, trgCond, trgChan, preScale); 00110 00111 StatusCode sc = StatusCode::SUCCESS ; 00112 sc = eventSvc()->registerObject(EventModel::Trig::TrigData,aTrigData); 00113 if(sc!=StatusCode::SUCCESS) { 00114 log<<MSG::DEBUG<< "Could not register TrigData" <<endreq; 00115 return StatusCode::FAILURE; 00116 } 00117 00118 return StatusCode::SUCCESS; 00119 }
StatusCode TrigEventMaker::finalize | ( | ) |
Definition at line 121 of file TrigEventMaker.cxx.
References Bes_Common::DEBUG, and msgSvc().
00121 { 00122 MsgStream log(msgSvc(), name()); 00123 log << MSG::DEBUG << "==> Finalize TrigEventMaker" << endreq; 00124 return StatusCode::SUCCESS; 00125 }
StatusCode TrigEventMaker::initialize | ( | ) |
Definition at line 22 of file TrigEventMaker.cxx.
References Bes_Common::DEBUG, and msgSvc().
00022 { 00023 MsgStream log(msgSvc(), name()); 00024 log << MSG::DEBUG << "TrigEventMaker: in initialize()" << endreq; 00025 return StatusCode::SUCCESS; 00026 }