BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
GenRdmTrgIdxAlg Class Reference

#include <GenRdmTrgIdxAlg.h>

+ Inheritance diagram for GenRdmTrgIdxAlg:

Public Member Functions

 GenRdmTrgIdxAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~GenRdmTrgIdxAlg ()
 
virtual StatusCode initialize ()
 Algorithm initialization.
 
virtual StatusCode execute ()
 Algorithm execution.
 
virtual StatusCode finalize ()
 Algorithm finalization.
 

Detailed Description

Definition at line 11 of file GenRdmTrgIdxAlg.h.

Constructor & Destructor Documentation

◆ GenRdmTrgIdxAlg()

GenRdmTrgIdxAlg::GenRdmTrgIdxAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 9 of file GenRdmTrgIdxAlg.cxx.

10 : GaudiAlgorithm(name, pSvcLocator),
11 m_fcount(0)
12{
13 declareProperty("RandomTriggerFiles", m_rdmFiles);
14}

◆ ~GenRdmTrgIdxAlg()

GenRdmTrgIdxAlg::~GenRdmTrgIdxAlg ( )
virtual

Definition at line 16 of file GenRdmTrgIdxAlg.cxx.

17{
18}

Member Function Documentation

◆ execute()

StatusCode GenRdmTrgIdxAlg::execute ( )
virtual

Algorithm execution.

Definition at line 35 of file GenRdmTrgIdxAlg.cxx.

36{
37 SmartDataPtr<TrigData> trigData(eventSvc(), EventModel::Trig::TrigData);
38 if ( trigData->getTrigChannel(9) != 1 ) {
39 // this is not a random trigger event, pass it
40 return StatusCode::SUCCESS;
41 }
42
43 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(), "/Event/EventHeader");
44 uint32_t evtNo = eventHeader->eventNumber();
45 uint32_t runNo = eventHeader->runNumber();
46
47 uint32_t thePos = 0;
48 const uint32_t* data = NULL;
49 uint32_t rdmEvtNo = 0xFFFFFFFF;
50
51 //std::cout << "BEGIN " << evtNo << std::endl;
52 do {
53 thePos = m_freader->raw_stream()->tellg();
54 try {
55 data = m_freader->nextEvent();
56 }
57 catch ( ReachEndOfFile& e ) {
58 m_idxhandler->write( RawFileTools::fname2idxname(m_freader->raw_stream()->currentFile()) );
59 delete m_freader;
60 m_freader = NULL;
61 ++m_fcount;
62 if ( m_fcount < m_rdmFiles.size() ) {
63 m_freader = new SimpleRawReader(m_rdmFiles[m_fcount]);
64 rdmEvtNo = 0xFFFFFFFF;
65 continue;
66 }
67 else {
68 fatal() << "can not find event " << evtNo << " in random trigger data files" << endmsg;
69 return StatusCode::FAILURE;
70 }
71 }
72 catch ( RawFileException& e ) {
73 e.print();
74 throw e;
75 }
76
77 //std::cout << "run " << data[9+data[5]] << ", event " << data[8+data[5]] << std::endl;
78
79 if ( data[9+data[5]] != runNo ) {
80 fatal() << "bad runNo in random trigger data" << endmsg;
81 return StatusCode::FAILURE;
82 }
83 rdmEvtNo = data[8+data[5]];
84 } while ( rdmEvtNo != evtNo );
85
86 m_idxhandler->addPos(data[8+data[5]], thePos);
87
88 return StatusCode::SUCCESS;
89}
int runNo
Definition: DQA_TO_DB.cxx:12
TTree * data
#define NULL
void write(std::string fname)
void addPos(uint32_t evtId, uint32_t pos)
virtual void print() const
const uint32_t * nextEvent()
raw_ifstream * raw_stream()
std::string currentFile() const
Definition: raw_ifstream.h:29
_EXTERN_ std::string TrigData
Definition: EventModel.h:68
std::string fname2idxname(const std::string &fname)
@ fatal
Definition: Core.h:24

◆ finalize()

StatusCode GenRdmTrgIdxAlg::finalize ( )
virtual

Algorithm finalization.

Definition at line 91 of file GenRdmTrgIdxAlg.cxx.

92{
93 if ( m_freader != NULL ) {
94 m_idxhandler->write( RawFileTools::fname2idxname(m_freader->raw_stream()->currentFile()) );
95 delete m_freader;
96 }
97 delete m_idxhandler;
98
99 return GaudiAlgorithm::finalize(); // must be called after all other actions
100}

◆ initialize()

StatusCode GenRdmTrgIdxAlg::initialize ( )
virtual

Algorithm initialization.

Definition at line 20 of file GenRdmTrgIdxAlg.cxx.

21{
22 StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first
23
24 if ( m_rdmFiles.empty() ) {
25 error() << "RandomTriggerFiles is empty" << endmsg;
26 return StatusCode::FAILURE;
27 }
28
29 m_idxhandler = new EvtIdxHandler;
30 m_freader = new SimpleRawReader(m_rdmFiles[0]);
31
32 return sc;
33}
@ error
Definition: Core.h:24

The documentation for this class was generated from the following files: