ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCalibStreamFileInputSvc.cxx
Go to the documentation of this file.
1//===================================================================
2// Implementation of MuonCalibStreamFileInputSvc
3//===================================================================
4//
5
6// Include files.
8
9#include <iostream>
10
11#include "EventStorage/pickDataReader.h"
12#include "GaudiKernel/GenericAddress.h"
13#include "GaudiKernel/IChronoStatSvc.h"
14#include "GaudiKernel/ISvcLocator.h"
15#include "MuCalDecode/CalibUti.h"
16//#include "EventStorage/DataReaderBase.h"
17//#include "EventStorage/DataReader.h"
18#include "EventStorage/EventStorageRecords.h"
19#include "EventStorage/fRead.h"
20#include "EventStorage/loadfRead.h"
21
22// Constructor.
23MuonCalibStreamFileInputSvc::MuonCalibStreamFileInputSvc(const std::string& name, ISvcLocator* svcloc) :
24 base_class(name, svcloc) {}
25
26// Destructor.
28
29// Open the first input file and read the first event.
31
32 // Check that the vector of input file names is not empty.
33 if (m_inputFiles.empty()) {
34 ATH_MSG_ERROR(" initialize: No input event files ");
35 return StatusCode::FAILURE;
36 }
37
38 // Set the iterator to the first input file.
40
41 // instantiate the data loader
42 m_dataLoader = std::make_unique<LVL2_MUON_CALIBRATION::CalibDataLoader>(m_inputFilesIt->c_str(), false, 0xffffffff, 0, DEFAULT_BUFFER_SIZE);
43
44 m_EoF = false;
45
46 return StatusCode::SUCCESS;
47} // MuonCalibStreamFileInputSvc::initialize()
48
49// Read the next event.
50const LVL2_MUON_CALIBRATION::CalibEvent* MuonCalibStreamFileInputSvc::nextEvent() {
51
52 if (m_EoF) { // EOF reached, need to change input file
53 ATH_MSG_INFO("nextEvent: end of file reached ");
55
56 ATH_MSG_INFO("nextEvent: finished with file " << *m_inputFilesIt);
57 ATH_MSG_INFO(" Number of Events in this file " << m_fileEventCounter);
58 ATH_MSG_INFO(" Total number of Events " << m_totalEventCounter);
59
60 // Reinitialize the file event counter.
62
64
65 if (m_inputFilesIt == m_inputFiles.end()) {
66 ATH_MSG_INFO("no more file to read ");
67 return 0;
68 }
69
70 // do the next File
71 m_dataLoader = std::make_unique<LVL2_MUON_CALIBRATION::CalibDataLoader>(m_inputFilesIt->c_str(), false, 0xffffffff, 0, DEFAULT_BUFFER_SIZE);
72
73 m_EoF = false;
74
75 return nextEvent();
76 }
77
79
80 // try to read next event
81 // add TGC fragment and move the print out of the fragment to DEBUG outputLevel
82 if (m_dataLoader->next(m_dataBuffer)) {
83 m_re = std::make_unique<LVL2_MUON_CALIBRATION::CalibEvent>(m_dataBuffer);
84
85 if (m_re) {
86 if (m_re->mdt() != 0) {
87 if (m_DumpStream != 0)
88 ATH_MSG_DEBUG(" MuonCalibStreamFileInputSvc::next event -- eta=" << m_re->eta() << " mdt " << *(m_re->mdt()));
89 }
90 if (m_re->rpc() != 0) {
91 if (m_DumpStream != 0)
92 ATH_MSG_DEBUG(" MuonCalibStreamFileInputSvc::next event -- eta=" << m_re->eta() << " rpc " << *(m_re->rpc()));
93 }
94 if (m_re->tgc() != 0) {
95 if (m_DumpStream != 0)
96 ATH_MSG_DEBUG(" MuonCalibStreamFileInputSvc::next event -- eta=" << m_re->eta() << " tgc " << *(m_re->tgc()));
97 }
98 }
99 } else {
100 // file must be over
101 m_EoF = true;
102 return nextEvent();
103 }
104
105 // Return
106 return m_re.get();
107} // MuonCalibStreamFileInputSvc::nextEvent()
108
110const LVL2_MUON_CALIBRATION::CalibEvent* MuonCalibStreamFileInputSvc::currentEvent() const {
111 // Return a pointer to the raw event.
112 return m_re.get();
113}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::unique_ptr< LVL2_MUON_CALIBRATION::CalibEvent > m_re
virtual const LVL2_MUON_CALIBRATION::CalibEvent * nextEvent() override
virtual StatusCode initialize() override
Gaudi::Property< std::vector< std::string > > m_inputFiles
MuonCalibStreamFileInputSvc(const std::string &name, ISvcLocator *svcloc)
std::unique_ptr< LVL2_MUON_CALIBRATION::CalibDataLoader > m_dataLoader
virtual const LVL2_MUON_CALIBRATION::CalibEvent * currentEvent() const override
Get a pointer to the current event.
std::vector< std::string >::iterator m_inputFilesIt