ATLAS Offline Software
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.
23 MuonCalibStreamFileInputSvc::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.
39  m_inputFilesIt = m_inputFiles.begin();
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.
50 const 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 
110 const LVL2_MUON_CALIBRATION::CalibEvent* MuonCalibStreamFileInputSvc::currentEvent() const {
111  // Return a pointer to the raw event.
112  return m_re.get();
113 }
MuonCalibStreamFileInputSvc::m_re
std::unique_ptr< LVL2_MUON_CALIBRATION::CalibEvent > m_re
Definition: MuonCalibStreamFileInputSvc.h:43
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MuonCalibStreamFileInputSvc::m_fileEventCounter
Long64_t m_fileEventCounter
Definition: MuonCalibStreamFileInputSvc.h:38
MuonCalibStreamFileInputSvc::m_EoF
bool m_EoF
Definition: MuonCalibStreamFileInputSvc.h:42
MuonCalibStreamFileInputSvc.h
MuonCalibStreamFileInputSvc::m_totalEventCounter
Long64_t m_totalEventCounter
Definition: MuonCalibStreamFileInputSvc.h:39
MuonCalibStreamFileInputSvc::initialize
virtual StatusCode initialize() override
Definition: MuonCalibStreamFileInputSvc.cxx:30
MuonCalibStreamFileInputSvc::m_inputFilesIt
std::vector< std::string >::iterator m_inputFilesIt
Definition: MuonCalibStreamFileInputSvc.h:47
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonCalibStreamFileInputSvc::m_dataLoader
std::unique_ptr< LVL2_MUON_CALIBRATION::CalibDataLoader > m_dataLoader
Definition: MuonCalibStreamFileInputSvc.h:44
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonCalibStreamFileInputSvc::currentEvent
virtual const LVL2_MUON_CALIBRATION::CalibEvent * currentEvent() const override
Get a pointer to the current event.
Definition: MuonCalibStreamFileInputSvc.cxx:110
MuonCalibStreamFileInputSvc::m_dataBuffer
DataBuffer m_dataBuffer
Definition: MuonCalibStreamFileInputSvc.h:45
MuonCalibStreamFileInputSvc::nextEvent
virtual const LVL2_MUON_CALIBRATION::CalibEvent * nextEvent() override
Definition: MuonCalibStreamFileInputSvc.cxx:50
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonCalibStreamFileInputSvc::MuonCalibStreamFileInputSvc
MuonCalibStreamFileInputSvc(const std::string &name, ISvcLocator *svcloc)
Definition: MuonCalibStreamFileInputSvc.cxx:23
MuonCalibStreamFileInputSvc::~MuonCalibStreamFileInputSvc
virtual ~MuonCalibStreamFileInputSvc()
Definition: MuonCalibStreamFileInputSvc.cxx:27
MuonCalibStreamFileInputSvc::m_DumpStream
Gaudi::Property< int > m_DumpStream
Definition: MuonCalibStreamFileInputSvc.h:40
MuonCalibStreamFileInputSvc::m_inputFiles
Gaudi::Property< std::vector< std::string > > m_inputFiles
Definition: MuonCalibStreamFileInputSvc.h:46