ATLAS Offline Software
RPCbytestream.cxx
Go to the documentation of this file.
1 /* // -*- C++ -*- */
2 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 
8 #include <fstream>
10 
11 using namespace std;
12 
13 RPCbytestream::RPCbytestream(CMAdata& data,const std::string& filename,MsgStream& log,
14  debu cma_debug,debu pad_debug,debu rx_debug,
15  debu sl_debug,debu cma_struc_debug,
16  debu pad_struc_debug,debu rx_struc_debug,
17  debu sl_struc_debug, uint NOBXS, uint BCZERO) :
18  RPCtrigDataObject(0,"RPC byte stream"),
19  m_cma_ro_debug(cma_debug),
20  m_pad_ro_debug(pad_debug),
21  m_rx_ro_debug(rx_debug),
22  m_sl_ro_debug(sl_debug),
23  m_cma_rostruct_debug(cma_struc_debug),
24  m_pad_rostruct_debug(pad_struc_debug),
25  m_rx_rostruct_debug(rx_struc_debug),
26  m_sl_rostruct_debug(sl_struc_debug),
27  m_filename(filename)
28 {
29  CMAdata::PatternsList list = data.give_patterns();
31 
32  while(it != list.end())
33  {
34  int key = (*it)->sector() * 10000 +
35  (*it)->cma_parameters().id().PAD_index() * 100 +
36  (*it)->cma_parameters().id().type() * 10 +
37  (*it)->cma_parameters().id().Ixx_index();
38 
39  std::pair < CMA_Readout::iterator, bool> ins =
40  m_cma_readout.insert(CMA_Readout::value_type(key,CMAreadout(*it, NOBXS, BCZERO)));
41  if(!ins.second)
42  {
43  log << MSG::ERROR << "Found duplicate CMA readout into CMA data!" << endmsg;
44  }
45 
46  ++it;
47  }
48 
49  build_pad_readout(log, NOBXS);
50  if(m_filename != "" ) dump_rpc_bytestream();
51 }
52 
54  RPCtrigDataObject(readout.number(),readout.name()),
55  m_cma_ro_debug(readout.cma_ro_debug()),
56  m_pad_ro_debug(readout.pad_ro_debug()),
57  m_rx_ro_debug(readout.rx_ro_debug()),
58  m_sl_ro_debug(readout.sl_ro_debug()),
59  m_cma_rostruct_debug(readout.cma_rostruct_debug()),
60  m_pad_rostruct_debug(readout.pad_rostruct_debug()),
61  m_rx_rostruct_debug(readout.rx_rostruct_debug()),
62  m_sl_rostruct_debug(readout.sl_rostruct_debug()),
63  m_filename(readout.filename()),
64  m_cma_readout(readout.cma_readout()),
65  m_pad_readout(readout.pad_readout())
66 {
67 }
68 
69 
71 {
72  m_cma_readout.clear();
73 }
74 
75 
76 void
78 {
79  for (int i=0;i<64;++i)
80  {
81  for(int j=0;j<=10;++j) // 99 is the maximum number allowed
82  {
83  int kPAD_lw = i * 10000 + j * 100;
84  int kPAD_hg = i * 10000 + j * 100 + 99;
85 
86  CMA_Readout::iterator PAD_l = m_cma_readout.lower_bound(kPAD_lw);
87  CMA_Readout::iterator PAD_h = m_cma_readout.upper_bound(kPAD_hg);
88 
89  if(distance(PAD_l,PAD_h) )
90  {
91  int SLid = (*PAD_l).second.sector();
92  int PADid = (*PAD_l).second.id().PAD_index();
93  PADreadout pad_readout(SLid,PADid);
94 
95  int key = SLid * 100 + PADid;
96 
97  if(SLid != i)
98  {
99  log << MSG::ERROR << "Key doesn't correspond to CMA Sector Id!" << endmsg;
100  }
101 
102  for (CMA_Readout::iterator it = PAD_l; it != PAD_h; ++it)
103  {
104  auto cma_readout = (*it).second.give_matrix_readout(log, NOBXS);
105  pad_readout.load_readout(cma_readout);
106  if (log.level() <= MSG::DEBUG) {
107  log << MSG::DEBUG << "Dump of the matrices readout into PAD " << PADid
108  << endl
109  << cma_readout[0]
110  << cma_readout[1] << endmsg;
111  }
112  }
113 
114  std::pair < PAD_Readout::iterator, bool> ins =
115  m_pad_readout.insert(PAD_Readout::value_type(key,pad_readout));
116  if(!ins.second)
117  {
118  log << MSG::ERROR << "Found duplicate PAD readout into CMA data!" << endmsg;
119  }
120  }
121  }
122  }
123 }
124 
125 void
127 {
128  ofstream out;
129  out.open(m_filename.c_str(),ios::app);
130 
131  // dump the PAD chunk of data into the byte stream file
133  while(it != m_pad_readout.end())
134  {
135  PadReadOut* readout = (*it).second.give_pad_readout();
136 
137  readout->bytestream(out);
138 
139  out << endl;
140 
141  ++it;
142  }
143 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
RPCbytestream::debu
unsigned long int debu
Definition: RPCbytestream.h:22
PadReadOut::bytestream
void bytestream(std::ostream &stream)
Definition: PadReadOut.cxx:167
RPCbytestream::RPCbytestream
RPCbytestream(CMAdata &, const std::string &, MsgStream &, debu, debu, debu, debu, debu, debu, debu, debu, uint, uint)
Definition: RPCbytestream.cxx:13
skel.it
it
Definition: skel.GENtoEVGEN.py:396
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
CMAreadout
Definition: CMAreadout.h:23
RPCbytestream::m_cma_readout
CMA_Readout m_cma_readout
Definition: RPCbytestream.h:39
RPCbytestream::dump_rpc_bytestream
void dump_rpc_bytestream(void)
Definition: RPCbytestream.cxx:126
PADreadout
Definition: PADreadout.h:20
RPCbytestream::build_pad_readout
void build_pad_readout(MsgStream &log, uint NOBXS)
Definition: RPCbytestream.cxx:77
CMAdata
Definition: CMAdata.h:19
PadReadOut
Definition: PadReadOut.h:15
CMAdata::PatternsList
std::list< CMApatterns * > PatternsList
Definition: CMAdata.h:22
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
RPCbytestream::pad_readout
const PAD_Readout & pad_readout(void) const
Definition: RPCbytestream.h:64
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
RPCbytestream::m_filename
std::string m_filename
Definition: RPCbytestream.h:37
python.selection.number
number
Definition: selection.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
RPCbytestream::~RPCbytestream
~RPCbytestream()
Definition: RPCbytestream.cxx:70
RPCtrigDataObject
Definition: RPCtrigDataObject.h:15
RPCbytestream::cma_readout
const CMA_Readout & cma_readout(void) const
Definition: RPCbytestream.h:63
RPCbytestream
Definition: RPCbytestream.h:20
RPCbytestream.h
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
RPCbytestream::m_pad_readout
PAD_Readout m_pad_readout
Definition: RPCbytestream.h:40
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37