ATLAS Offline Software
TrigRpcDataRetriever.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "TrigRpcDataRetriever.h"
6 
7 #include "MuonFullIDHelper.h"
10 
11 #include <vector>
12 #include <list>
13 
14 namespace JiveXML {
15 
16  //--------------------------------------------------------------------------
17 
18  TrigRpcDataRetriever::TrigRpcDataRetriever(const std::string& type, const std::string& name, const IInterface* parent):
20  m_typeName("RPC") // same datatype name as RPC ! Must not be run together
21  {
22  declareInterface<IDataRetriever>(this);
23  }
24 
25  //--------------------------------------------------------------------------
26 
28  ATH_CHECK(m_idHelperSvc.retrieve());
30  ATH_CHECK(m_rpcDecoder.retrieve());
32  return StatusCode::SUCCESS;
33  }
34 
35  //--------------------------------------------------------------------------
36 
37  StatusCode TrigRpcDataRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
38 
39  //be verbose
40  ATH_MSG_DEBUG("Retrieving " << dataTypeName());
41 
42  // retrieve the collection of RDO
44 
45  int ndata=0;
46  for (auto containerIt=rdoContainer->begin(); containerIt!=rdoContainer->end(); ++containerIt) {
47  ndata += (*containerIt)->size();
48  }
49 
50  //Make the vectors to contain the information and reserve space accordingly
51  DataVect x; x.reserve(ndata);
52  DataVect y; y.reserve(ndata);
53  DataVect z; z.reserve(ndata);
54  DataVect lengthVec; lengthVec.reserve(ndata);
55  DataVect widthVec; widthVec.reserve(ndata);
56  DataVect idVec; idVec.reserve(ndata);
57  DataVect identifierVec; identifierVec.reserve(ndata);
58  DataVect barcode; barcode.reserve(ndata);
59 
60  int ipad = 0 ;
61  double time = 0. ;
62  double time1 = 0. ;
63 
65  const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr();
66  if(!MuonDetMgr){
67  ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object");
68  return StatusCode::FAILURE;
69  }
70 
71 
72  //loop on pad
73  SG::ReadCondHandle<RpcCablingCondData> readHandle{m_rpcCab, Gaudi::Hive::currentContext()};
74  const RpcCablingCondData* rpcCabling{*readHandle};
75 
76  for (auto itColl=rdoContainer->begin(); itColl!=rdoContainer->end(); ++itColl) {
77  if ( itColl->size() == 0 ) continue;
78 
79  ipad++;
80  ATH_MSG_DEBUG("Ipad " << ipad);
81  //Get pad online id and sector id
82  uint16_t padId = itColl->onlineId();
83  uint16_t sectorId = itColl->sector() ;
84 
85  // For each pad, loop on the coincidence matrices
86  RpcPad::const_iterator itCM = itColl->begin();
87  RpcPad::const_iterator itCM_e = itColl->end();
88  for (; itCM != itCM_e ; ++itCM) {
89  // Get CM online Id
90  uint16_t cmaId = (*itCM)->onlineId();
91 
92  // For each CM, loop on the fired channels
93  RpcCoinMatrix::const_iterator itD = (*itCM)->begin();
94  RpcCoinMatrix::const_iterator itD_e = (*itCM)->end();
95  for (; itD != itD_e ; ++itD) {
96  const RpcFiredChannel * rpcChan = (*itD);
97  ATH_MSG_DEBUG("RpcFiredChannel: " <<
98  " sectorId " << sectorId <<
99  " padId " << padId <<
100  " cmId " << cmaId <<
101  " bcid " << rpcChan->bcid() <<
102  " time " << rpcChan->time() <<
103  " ijk " << rpcChan->ijk() <<
104  " ch " << rpcChan->channel());
105  //look for trigger hits
106  if(rpcChan->ijk()==6){
107  //found trigger hit. Look for confirm hits
108  RpcCoinMatrix::const_iterator itD1 = (*itCM)->begin();
109  RpcCoinMatrix::const_iterator itD_e1 = (*itCM)->end();
110  int idata1 = 0;
111  for (; itD1 != itD_e1 ; ++itD1) {
112 
113  const RpcFiredChannel * rpcChan1 = (*itD1);
114  if( rpcChan1->ijk() > 1 && rpcChan1->ijk() <6){
115 
116  //write trigger hit only once
117  if(idata1==0){
118  std::vector<Identifier> digitVec{m_rpcDecoder->getOfflineData(rpcChan, sectorId, padId, cmaId, time, rpcCabling)};
119  // Loop on the digits corresponding to the fired channel
121  ATH_MSG_DEBUG("Number of digits: " << digitVec.size());
122 
123  // transform the pad sectorId according to the cabling convention
124  uint16_t side = (sectorId<32) ? 0 : 1;
125  uint16_t sl = sectorId-side*32 ;
126  std::list<Identifier> stripList = rpcCabling->give_strip_id(side,sl,padId,cmaId,rpcChan->ijk(),rpcChan->channel(),&m_idHelperSvc->rpcIdHelper());
127  std::list<Identifier>::const_iterator it_list;
128  for (it_list=stripList.begin() ; it_list != stripList.end() ; ++it_list) {
129  Identifier stripOfflineId = *it_list;
130  ATH_MSG_DEBUG(" cablingId " << m_idHelperSvc->rpcIdHelper().show_to_string(stripOfflineId));
131 
132  const MuonGM::RpcReadoutElement* element = MuonDetMgr->getRpcReadoutElement(stripOfflineId);
133  char ChID[100];
134  snprintf(ChID, 100, "SL%d-Pad%d-CM%d-ijk%d-ch%d-time%d",sectorId,padId,cmaId,
135  rpcChan->ijk(),rpcChan->channel(),8*rpcChan->bcid()+rpcChan->time());
136 
137  Amg::Vector3D globalPos = element->stripPos(stripOfflineId);
138  int measuresPhi = m_idHelperSvc->rpcIdHelper().measuresPhi(stripOfflineId);
139  double stripLength = element->StripLength(measuresPhi);
140  double stripWidth = element->StripWidth(measuresPhi);
141 
142  x.push_back(DataType(globalPos.x()/CLHEP::cm));
143  y.push_back(DataType(globalPos.y()/CLHEP::cm));
144  z.push_back(DataType(globalPos.z()/CLHEP::cm));
145  lengthVec.push_back(DataType(stripLength/CLHEP::cm));
146  widthVec.push_back(DataType(stripWidth/CLHEP::cm));
147  identifierVec.push_back(DataType(ChID));
148  idVec.push_back(DataType( m_idHelperSvc->rpcIdHelper().show_to_string(stripOfflineId) ));
149  barcode.push_back(DataType(0));
150  }
151  }
152  idata1++;
153 
154  ATH_MSG_DEBUG("RpcFiredChannel1:" <<
155  " sectorId1 " << sectorId <<
156  " padId1 " << padId <<
157  " cmId1 " << cmaId <<
158  " bcid1 " << rpcChan1->bcid() <<
159  " time1 " << rpcChan1->time() <<
160  " ijk1 " << rpcChan1->ijk() <<
161  " ch1 " << rpcChan1->channel());
162 
163  //write confirm hits
164  std::vector<Identifier> digitVec1{m_rpcDecoder->getOfflineData(rpcChan1, sectorId, padId, cmaId, time1, rpcCabling)};
165  // Loop on the digits corresponding to the fired channel
166 
167  ATH_MSG_DEBUG("Number of digits: " << digitVec1.size());
168 
169  // transform the pad sectorId according to the cabling convention
170  uint16_t side = (sectorId<32) ? 0 : 1;
171  uint16_t sl = sectorId-side*32 ;
172  std::list<Identifier> stripList1 = rpcCabling->give_strip_id(side,sl,padId,cmaId,rpcChan1->ijk(),rpcChan1->channel(),&m_idHelperSvc->rpcIdHelper());
173  std::list<Identifier>::const_iterator it_list1;
174  for (it_list1=stripList1.begin() ; it_list1 != stripList1.end() ; ++it_list1) {
175  Identifier stripOfflineId1 = *it_list1;
176  ATH_MSG_DEBUG(" cablingId1 " << m_idHelperSvc->rpcIdHelper().show_to_string(stripOfflineId1));
177 
178  const MuonGM::RpcReadoutElement* element1 = MuonDetMgr->getRpcReadoutElement(stripOfflineId1);
179 
180  char ChID1[100];
181  snprintf(ChID1,100, "SL%d-Pad%d-CM%d-ijk%d-ch%d-time%d",sectorId,padId,cmaId,
182  rpcChan1->ijk(),rpcChan1->channel(),8*rpcChan1->bcid()+rpcChan1->time());
183 
184  Amg::Vector3D globalPos1 = element1->stripPos(stripOfflineId1);
185  int measuresPhi1 = m_idHelperSvc->rpcIdHelper().measuresPhi(stripOfflineId1);
186  double stripLength1 = element1->StripLength(measuresPhi1);
187  double stripWidth1 = element1->StripWidth(measuresPhi1);
188 
189  x.push_back(DataType(globalPos1.x()/CLHEP::cm));
190  y.push_back(DataType(globalPos1.y()/CLHEP::cm));
191  z.push_back(DataType(globalPos1.z()/CLHEP::cm));
192  lengthVec.push_back(DataType(stripLength1/CLHEP::cm));
193  widthVec.push_back(DataType(stripWidth1/CLHEP::cm));
194  identifierVec.push_back(DataType(ChID1));
195  idVec.push_back(DataType( m_idHelperSvc->rpcIdHelper().show_to_string(stripOfflineId1) ));
196  barcode.push_back(DataType(0));
197  }
198  }//write hits
199  }//look for confirm
200  }//found trigger hit
201 
202  }//End channels
203  }//End CM
204  }//End if
205 
206  DataMap myDataMap;
207  myDataMap["x"] = x;
208  myDataMap["y"] = y;
209  myDataMap["z"] = z;
210  myDataMap["length"] = lengthVec;
211  myDataMap["width"] = widthVec;
212  myDataMap["identifier"] = identifierVec;
213  myDataMap["id"] = idVec;
214  myDataMap["barcode"] = barcode;
215 
216  //Be verbose
217  ATH_MSG_DEBUG(dataTypeName() << ": "<< x.size());
218 
219  //forward data to formating tool
220  return FormatTool->AddToEvent(dataTypeName(), m_sgKey.key(), &myDataMap);
221  }
222 }
MuonGM::MuonDetectorManager::getRpcReadoutElement
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:168
JiveXML::TrigRpcDataRetriever::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: TrigRpcDataRetriever.h:48
RpcFiredChannel::ijk
ubit16 ijk() const
Definition: RpcFiredChannel.h:56
RpcFiredChannel::time
ubit16 time() const
Definition: RpcFiredChannel.h:54
JiveXML::TrigRpcDataRetriever::m_sgKey
SG::ReadHandleKey< RpcPadContainer > m_sgKey
Definition: TrigRpcDataRetriever.h:46
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
MuonGM::RpcReadoutElement::StripLength
double StripLength(bool measphi) const
returns the strip length for the phi or eta plane
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
RpcFiredChannel::channel
ubit16 channel() const
Definition: RpcFiredChannel.h:58
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
JiveXML::TrigRpcDataRetriever::TrigRpcDataRetriever
TrigRpcDataRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: TrigRpcDataRetriever.cxx:18
MuonGM::RpcReadoutElement
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/RpcReadoutElement.h:54
JiveXML::TrigRpcDataRetriever::initialize
StatusCode initialize()
Default AthAlgTool methods.
Definition: TrigRpcDataRetriever.cxx:27
MuonPrepDataContainer.h
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
x
#define x
RpcFiredChannel
Definition: RpcFiredChannel.h:20
RpcCablingCondData
Definition: RpcCablingCondData.h:21
TRT::Hit::side
@ side
Definition: HitInfo.h:83
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
JiveXML::TrigRpcDataRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: TrigRpcDataRetriever.cxx:37
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
z
#define z
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
JiveXML::TrigRpcDataRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: TrigRpcDataRetriever.h:36
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:21
JiveXML::TrigRpcDataRetriever::m_DetectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Definition: TrigRpcDataRetriever.h:53
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
JiveXML::TrigRpcDataRetriever::m_rpcCab
SG::ReadCondHandleKey< RpcCablingCondData > m_rpcCab
Definition: TrigRpcDataRetriever.h:52
MuonGM::RpcReadoutElement::stripPos
Amg::Vector3D stripPos(const Identifier &id) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/RpcReadoutElement.cxx:177
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonGM::RpcReadoutElement::StripWidth
double StripWidth(bool measphi) const
returns the strip width for the phi or eta plane
RpcFiredChannel::bcid
ubit16 bcid() const
Definition: RpcFiredChannel.h:52
y
#define y
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
JiveXML::TrigRpcDataRetriever::m_rpcDecoder
ToolHandle< Muon::IRPC_RDO_Decoder > m_rpcDecoder
Definition: TrigRpcDataRetriever.h:50
TrigRpcDataRetriever.h
MuonFullIDHelper.h
AthAlgTool
Definition: AthAlgTool.h:26
RpcReadoutElement.h