ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include "MuonFullIDHelper.h"
10
11#include <vector>
12#include <list>
13
14namespace JiveXML {
15
16 //--------------------------------------------------------------------------
17
18 TrigRpcDataRetriever::TrigRpcDataRetriever(const std::string& type, const std::string& name, const IInterface* parent):
19 AthAlgTool(type, name, 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());
29 ATH_CHECK(m_rpcCab.initialize());
30 ATH_CHECK(m_rpcDecoder.retrieve());
31 ATH_CHECK(m_DetectorManagerKey.initialize());
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
#define y
#define x
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
const std::string m_typeName
The data type that is generated by this retriever.
virtual std::string dataTypeName() const
Return the name of the data type.
StatusCode initialize()
Default AthAlgTool methods.
SG::ReadCondHandleKey< RpcCablingCondData > m_rpcCab
ToolHandle< Muon::IRPC_RDO_Decoder > m_rpcDecoder
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
TrigRpcDataRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
SG::ReadHandleKey< RpcPadContainer > m_sgKey
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
double StripLength(bool measphi) const
returns the strip length for the phi or eta plane
double StripWidth(bool measphi) const
returns the strip width for the phi or eta plane
std::list< Identifier > give_strip_id(unsigned short int SubsystemId, unsigned short int SectorId, unsigned short int PADId, unsigned short int CMAId, unsigned short ijk, unsigned short int Channel, const RpcIdHelper *rpcId) const
ubit16 bcid() const
ubit16 channel() const
ubit16 ijk() const
ubit16 time() const
const_pointer_type cptr()
Eigen::Matrix< double, 3, 1 > Vector3D
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58