ATLAS Offline Software
TgcRdoToPrepDataToolMT.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 #include "GaudiKernel/ThreadLocalContext.h"
13 #include "TrkSurfaces/Surface.h"
15 #include <algorithm>
16 #include <cfloat>
17 #include <memory>
19 
20 //================ Constructor =================================================
21 namespace{
22  using namespace xAOD::P4Helpers;
23 }
24 Muon::TgcRdoToPrepDataToolMT::TgcRdoToPrepDataToolMT(const std::string& t, const std::string& n, const IInterface* p)
25  : base_class(t, n, p) {}
26 
27 //================ Initialization =================================================
28 
30 {
31  ATH_CHECK(m_idHelperSvc.retrieve());
32 
33  m_outputprepdataKeys.resize(NBC_HIT+1);
34  for (int ibc=0; ibc < NBC_HIT+1; ibc++) {
35  int bcTag = ibc+1;
36  std::ostringstream location;
37  location << m_outputCollectionLocation.value()
38  << (bcTag==TgcDigit::BC_PREVIOUS ? "PriorBC" : "")
39  << (bcTag==TgcDigit::BC_CURRENT ? "" : "")
40  << (bcTag==TgcDigit::BC_NEXT ? "NextBC" : "")
41  << (bcTag==(NBC_HIT+1) ? "AllBCs" : "");
42  m_outputprepdataKeys.at(ibc) = location.str();
43  }
44 
45  m_outputCoinKeys.resize(NBC_TRIG);
46  for (int ibc=0; ibc < NBC_TRIG; ibc++) {
47  int bcTag = ibc+1;
48  std::ostringstream location;
49  location << m_outputCoinCollectionLocation.value()
50  << (bcTag==TgcDigit::BC_PREVIOUS ? "PriorBC" : "")
51  << (bcTag==TgcDigit::BC_NEXT ? "NextBC" : "")
52  << (bcTag==TgcDigit::BC_NEXTNEXT ? "NextNextBC" : "");
53  m_outputCoinKeys.at(ibc) = location.str();
54  }
55 
56  ATH_CHECK(m_outputCoinKeys.initialize());
57  ATH_CHECK(m_outputprepdataKeys.initialize());
58  ATH_CHECK(m_muDetMgrKey.initialize());
59 
60  // check if initializing of DataHandle objects success
61  ATH_CHECK( m_rdoContainerKey.initialize() );
62 
63  //try to configure the cabling service
64  if (!getCabling()) {
65  // ??? Is this delayed initialization still needed?
66  ATH_MSG_INFO("MuonTGC_CablingSvc not yet retrieved; postpone TGCcabling initialization at first event.");
67  }
68 
69  // Build names for the keys same as done for output containers
70  if (not m_prdContainerCacheKeyStr.empty()) {
71  m_prdContainerCacheKeys.resize(NBC_HIT+1);
72  for (int ibc=0; ibc < NBC_HIT+1; ibc++) {
73  int bcTag = ibc+1;
74  std::ostringstream location;
75  location << m_prdContainerCacheKeyStr.value()
76  << (bcTag==TgcDigit::BC_PREVIOUS ? "PriorBC" : "")
77  << (bcTag==TgcDigit::BC_CURRENT ? "" : "")
78  << (bcTag==TgcDigit::BC_NEXT ? "NextBC" : "")
79  << (bcTag==(NBC_HIT+1) ? "AllBCs" : "");
80  m_prdContainerCacheKeys.at(ibc) = location.str();
81  ATH_MSG_DEBUG(location.str());
82  }
83  }
84 
85  if (not m_coinContainerCacheKeyStr.empty()){
86  m_coinContainerCacheKeys.resize(NBC_TRIG);
87  for (int ibc=0; ibc < NBC_TRIG; ibc++) {
88  int bcTag = ibc+1;
89  std::ostringstream location;
90  location << m_coinContainerCacheKeyStr.value()
91  << (bcTag==TgcDigit::BC_PREVIOUS ? "PriorBC" : "")
92  << (bcTag==TgcDigit::BC_NEXT ? "NextBC" : "")
93  << (bcTag==TgcDigit::BC_NEXTNEXT ? "NextNextBC" : "");
94  m_coinContainerCacheKeys.at(ibc) = location.str();
95  ATH_MSG_DEBUG(location.str());
96  }
97  }
98 
99  // Only initialise if we passed in the cache name
100  ATH_CHECK( m_prdContainerCacheKeys.initialize( not m_prdContainerCacheKeyStr.empty() ) );
101  ATH_CHECK( m_coinContainerCacheKeys.initialize( not m_coinContainerCacheKeyStr.empty() ) );
102 
103  ATH_CHECK(m_xAODKey.initialize(!m_xAODKey.empty()));
104  return StatusCode::SUCCESS;
105 }
106 
107 //================ Finalization =================================================
108 
110 {
111  ATH_MSG_INFO("finalize(): input RDOs->output PRDs [" <<
112  "Hit: " << m_nHitRDOs << "->" << m_nHitPRDs << ", " <<
113  "Tracklet: " << m_nTrackletRDOs << "->" << m_nTrackletPRDs << ", " <<
114  "TrackletEIFI: " << m_nTrackletEIFIRDOs << "->" << m_nTrackletEIFIPRDs << ", " <<
115  "HiPt: " << m_nHiPtRDOs << "->" << m_nHiPtPRDs << ", " <<
116  "SL: " << m_nSLRDOs << "->" << m_nSLPRDs << "]");
117 
118  return AthAlgTool::finalize();
119 }
120 
121 //================ Decoding =================================================
122 StatusCode Muon::TgcRdoToPrepDataToolMT::decode(const EventContext&, const std::vector<uint32_t>& /*robIds*/ ) const {
123  ATH_MSG_FATAL("ROB based decoding is not supported....");
124  return StatusCode::FAILURE;
125 }
126 template<class ContType, class CollType>
128  std::vector<std::unique_ptr<CollType>>&& coll) const {
129  for (std::unique_ptr<CollType>& toMove : coll) {
130  if (!toMove) continue;
131  const IdentifierHash hash = toMove->identifyHash();
132  auto lock = container.getWriteHandle(hash);
133  if(!lock.alreadyPresent()) {
134  ATH_CHECK(lock.addOrDelete(std::move(toMove)));
135  }
136  }
137  return StatusCode::SUCCESS;
138 }
139 
141  if (!m_xAODKey.empty()){
142  SG::WriteHandle<xAOD::TgcStripContainer> handle(m_xAODKey, ctx);
143  ATH_CHECK(handle.record(std::make_unique<xAOD::TgcStripContainer>(),
144  std::make_unique<xAOD::TgcStripAuxContainer>()));
145  }
146  State state{};
147  return setupState(ctx, state);
148 }
149 
150 StatusCode Muon::TgcRdoToPrepDataToolMT::setupState(const EventContext& ctx, State& state) const{
152  const unsigned hashMax = m_idHelperSvc->tgcIdHelper().module_hash_max();
153 
154  for(unsigned int ibc=0; ibc < NBC_HIT+1; ibc++) { // +1 for AllBCs
155  // initialize with false
156  SG::WriteHandle<TgcPrepDataContainer> handle(m_outputprepdataKeys[ibc], ctx);
157 
158  const bool externalCachePRD = m_prdContainerCacheKeys.size()>ibc &&
159  !m_prdContainerCacheKeys[ibc].key().empty();
160  if (!externalCachePRD) {
161  // record the container in storeGate
162  ATH_CHECK(handle.record(std::make_unique<TgcPrepDataContainer>(hashMax)));
163  ATH_MSG_DEBUG("TGC PrepData Container recorded in StoreGate with key " << m_outputprepdataKeys[ibc].key());
164 
165  // cache the pointer, storegate retains ownership
166  state.tgcPrepDataContainer[ibc] = handle.ptr();
167  } else {
168  // use the cache to get the container
169  SG::UpdateHandle<TgcPrepDataCollection_Cache> update(m_prdContainerCacheKeys[ibc], ctx);
170  ATH_CHECK(update.isValid());
171 
172  ATH_CHECK(handle.record(std::make_unique<Muon::TgcPrepDataContainer>(update.ptr())));
173 
174  state.tgcPrepDataContainer[ibc] = handle.ptr();
175  ATH_MSG_DEBUG("Created container using cache for " << m_prdContainerCacheKeys[ibc].key());
176  }
177  state.tgcPrepDataCollections[ibc].resize(hashMax);
178  }
179 
181  for (unsigned int ibc=0; ibc < NBC_TRIG; ibc++) {
182  // prepare write handle for this BC
183  SG::WriteHandle<TgcCoinDataContainer> handle(m_outputCoinKeys[ibc], ctx);
184 
185  const bool externalCacheCoin = m_coinContainerCacheKeys.size()>ibc &&
186  !m_coinContainerCacheKeys[ibc].key().empty();
187  if(!externalCacheCoin) {
188  // No cache (offline case), just record container into store gate
189  ATH_CHECK(handle.record(std::make_unique<TgcCoinDataContainer>(hashMax)));
190  } else {
191  // Using the cache (trigger case)
192  SG::UpdateHandle<TgcCoinDataCollection_Cache> update(m_coinContainerCacheKeys[ibc], ctx);
193  ATH_CHECK(update.isValid());
194  ATH_CHECK(handle.record(std::make_unique<TgcCoinDataContainer>(update.ptr())));
195  ATH_MSG_DEBUG("Created container using cache for " << m_coinContainerCacheKeys[ibc].key());
196 
197  }//external cache
198 
199  // cache the pointer for duration of function, storegate retains ownership
200  state.tgcCoinDataContainer[ibc] = handle.ptr();
201  state.tgcCoinDataCollections[ibc].resize(hashMax);
202 
203  } // loop on BC_TRIG
204 
205  SG::ReadCondHandle<MuonGM::MuonDetectorManager> detMgr{m_muDetMgrKey, ctx};
206  ATH_CHECK(detMgr.isValid());
207  state.muDetMgr = detMgr.cptr();
208  return StatusCode::SUCCESS;
209 }
211  const std::vector<IdentifierHash>& requestedIdHashVect) const {
212  // Object to hold the containers for this decode call
213  State state{};
214  ATH_CHECK(setupState(ctx, state));
215 
217  if (!m_xAODKey.empty()) {
218  xAODHandle = SG::WriteHandle<xAOD::TgcStripContainer>{m_xAODKey, ctx};
219  ATH_CHECK(xAODHandle.record(std::make_unique<xAOD::TgcStripContainer>(),
220  std::make_unique<xAOD::TgcStripAuxContainer>()));
221  }
222 
223  int sizeVectorRequested = requestedIdHashVect.size();
224  ATH_MSG_DEBUG("decode for " << sizeVectorRequested << " offline collections called");
225 
226  const CablingInfo* cinfo = getCabling();
227  if (!cinfo) {
228  return StatusCode::FAILURE;
229  }
230  const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
231 
232  std::set<const TgcRdo*> decodedRdoCollVec{}, rdoCollVec{};
233  std::vector<bool> decodedOnlineId (cinfo->m_MAX_N_ROD, false);
234 
235  // if TGC decoding is switched off stop here
236  if(!m_decodeData) {
237  ATH_MSG_DEBUG("Stored empty container. Decoding TGC RDO into TGC PrepRawData is switched off");
238  return StatusCode::SUCCESS;
239  }
240 
241  ATH_MSG_DEBUG("Decoding TGC RDO into TGC PrepRawData");
242 
243  // retrieve the collection of RDO
244  ATH_MSG_DEBUG("Retriving TGC RDO container from the store");
245  SG::ReadHandle<TgcRdoContainer> rdoContainer{m_rdoContainerKey, ctx};
246  ATH_CHECK(rdoContainer.isValid());
248  if(rdoContainer->empty()) {
249  // empty csm container - no tgc rdo in this event
250  ATH_MSG_DEBUG("Empty rdo container - no tgc rdo in this event");
251  return StatusCode::SUCCESS;
252  }
253 
254  ATH_MSG_DEBUG("Not empty rdo container in this event, the container size is " << rdoContainer->size());
255 
256  // select RDOs to be decoded when seeded mode is used
257  if(sizeVectorRequested!=0) {
258  unsigned int nRdo = 0;
259  for (IdentifierHash offlineCollHash : requestedIdHashVect) {
260  uint16_t onlineId = cinfo->m_hashToOnlineId.at(static_cast<unsigned int>(offlineCollHash));
261 
262  if(decodedOnlineId.at(onlineId)) {
263  ATH_MSG_DEBUG("The ROB with onlineId " << onlineId << " which contains hash "
264  << static_cast<unsigned int>(offlineCollHash)
265  << " is already decoded and skipped");
266  continue;
267  }
268 
269  decodedOnlineId.at(onlineId) = true; // The ROB with this onlineId will be decoded only once
270 
271  for(const TgcRdo* rdoColl : *rdoContainer) {
272  if(rdoColl->identify()==onlineId) {
273  if(!decodedRdoCollVec.count(rdoColl)) {
274  rdoCollVec.insert(rdoColl);
275  nRdo++;
276  }
277  break;
278  }
279  }
280  }
281  ATH_MSG_DEBUG("Number of RDOs to be converted is " << nRdo);
282  } // End of selection of RDOs to be decoded
283 
284  // Decode Hits
285  if(sizeVectorRequested!=0) {
286  ATH_MSG_DEBUG("Start loop over rdos - seeded mode");
287  // for each RDO collection we collect up all the PRD collections and then write them once filled
288  // need a vector because we have the collections for the different bunch crosssings
289  for (const TgcRdo* rdo : rdoCollVec) {
290  for (const TgcRawData* rd : *rdo) {
291  //Since OnlineIds are not unique, need some additional filtering on offline hashId
292  //to avoid decoding RDO outside of an RoI
293  Identifier offlineId{};
294  if(!cinfo->m_tgcCabling->getElementIDfromReadoutID(offlineId, rd->subDetectorId(),
295  rd->rodId(), rd->sswId(), rd->slbId(),
296  rd->bitpos())){
297  continue;
298  }
299  const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(offlineId);
300  if (std::find(requestedIdHashVect.begin(), requestedIdHashVect.end(), tgcHashId) == requestedIdHashVect.end()){
301  continue;
302  }
303  selectDecoder(state,*rd, rdo);
304  }
305  decodedRdoCollVec.insert(rdo);
306  }
307  } else {
308  ATH_MSG_DEBUG("Start loop over rdos - unseeded mode");
309  for(const TgcRdo* rdoColl : *rdoContainer) {
310  if (rdoColl->empty() || decodedRdoCollVec.count(rdoColl) || rdoCollVec.count(rdoColl)) {
311  continue;
312  }
313  ATH_MSG_DEBUG(" Number of RawData in this rdo " << rdoColl->size());
314  for (const TgcRawData* rd : *rdoColl) {
315  selectDecoder(state,*rd, rdoColl);
316  }
317  decodedRdoCollVec.insert(rdoColl);
318  }
319  }
320  // first collect up all the HashIDs in any of the containers
321  std::set<IdentifierHash> hashesInAnyBC;
322  for(unsigned int ibc = 0; ibc < NBC_HIT; ++ibc) {
323 
324  uint16_t bcBitMap = 0;
325  if(ibc == 0) bcBitMap = TgcPrepData::BCBIT_PREVIOUS;
326  else if (ibc == 1) bcBitMap = TgcPrepData::BCBIT_CURRENT;
327  else if (ibc == 2) bcBitMap = TgcPrepData::BCBIT_NEXT;
328 
329  for (std::unique_ptr<TgcPrepDataCollection>& bcColl : state.tgcPrepDataCollections[ibc]) {
330  if (!bcColl) continue;
331  std::unique_ptr<TgcPrepDataCollection>& allBcColl = state.tgcPrepDataCollections[NBC_HIT][bcColl->identifyHash()];
332  if (!allBcColl) {
333  allBcColl = std::make_unique<TgcPrepDataCollection>(bcColl->identifyHash());
334  allBcColl->setIdentifier(bcColl->identify());
335  }
336  hashesInAnyBC.insert(bcColl->identifyHash());
337  for (const TgcPrepData* prdToUpdate : *bcColl) {
338  auto search_itr = std::find_if(allBcColl->begin(), allBcColl->end(),
339  [prdToUpdate](const TgcPrepData* prd){
340  return prd->identify() == prdToUpdate->identify();
341  });
342  if (search_itr == allBcColl->end()) {
343  auto allBcPrd = std::make_unique<TgcPrepData>(*prdToUpdate);
344  allBcPrd->setHashAndIndex(allBcColl->identifyHash(), allBcColl->size());
345  allBcPrd->setBcBitMap(bcBitMap);
346  allBcColl->push_back(std::move(allBcPrd));
347  } else {
348  TgcPrepData* allBcPrd = (*search_itr);
349  const uint16_t bcBitMap_current = allBcPrd->getBcBitMap();
350  ATH_MSG_VERBOSE(m_idHelperSvc->toString(allBcPrd->identify())<<" Old bitmap " << bcBitMap_current
351  << " adding " << bcBitMap << " to get " << (bcBitMap_current | bcBitMap));
352  allBcPrd->setBcBitMap((bcBitMap_current | bcBitMap));
353  }
354  }
355  }
356  }
357 
358  if (!m_xAODKey.empty()) {
359  for (std::unique_ptr<TgcPrepDataCollection>& allBcColl : state.tgcPrepDataCollections[NBC_HIT]) {
360  if (!allBcColl) continue;
361  for (const TgcPrepData* allBcPrd : *allBcColl) {
362  xAOD::TgcStrip* tgcStrip = xAODHandle->push_back(std::make_unique<xAOD::TgcStrip>());
363  tgcStrip->setMeasuresPhi(idHelper.isStrip(allBcPrd->identify()));
364  tgcStrip->setGasGap(idHelper.gasGap(allBcPrd->identify()));
365  tgcStrip->setChannelNumber(idHelper.channel(allBcPrd->identify()));
366  tgcStrip->setBcBitMap(allBcPrd->getBcBitMap());
367  tgcStrip->setIdentifier(allBcPrd->identify().get_compact());
368  tgcStrip->setMeasurement(m_idHelperSvc->moduleHash(allBcPrd->identify()),
369  xAOD::MeasVector<1>(allBcPrd->localPosition().x()),
370  xAOD::MeasMatrix<1>(allBcPrd->localCovariance()(0,0)));
371  }
372  }
373 }
374 
375  for (unsigned int k = 0 ; k < state.tgcPrepDataContainer.size(); ++k){
376  ATH_CHECK(transferData(*state.tgcPrepDataContainer[k], std::move(state.tgcPrepDataCollections[k])));
377  }
378  for (unsigned int k = 0 ; k < state.tgcCoinDataContainer.size(); ++k) {
379  ATH_CHECK(transferData(*state.tgcCoinDataContainer[k], std::move(state.tgcCoinDataCollections[k])));
380  }
381  ATH_MSG_DEBUG("Found " << hashesInAnyBC.size() << " hashes that must be added to AllBC container");
382 
383  return StatusCode::SUCCESS;
384 }
385 
387  const TgcRawData& rd,
388  const TgcRdo* rdoColl) const {
389 
390  const CablingInfo* cinfo = getCabling();
391  if (!cinfo) {
392  return;
393  }
394 
395  if(!rd.isCoincidence()) {
396  if(!decodeHits(state, rd).isSuccess()) {
397  ATH_MSG_WARNING("Cannot decode TGC Hits");
398  }
399  } else if(rd.isCoincidence() && m_fillCoinData) { // coincidence start
400  StatusCode status = StatusCode::SUCCESS;
401  if (rd.type()==TgcRawData::TYPE_TRACKLET) {
404  status = decodeTracklet(state, rd);
405  } else if(rd.slbType()==TgcRawData::SLB_TYPE_INNER_WIRE ||
407  status = decodeTrackletEIFI(state, rd);
408  }
409  } // rd.rodId()<13 for Run2, rd.rodId()>12 for Run3
410  else if( rd.type()==TgcRawData::TYPE_HIPT &&
411  ( (rd.isHipt() && rd.rodId()<13) || rd.rodId()>12) ) {
412  status = decodeHiPt(state, rd);
413  } else if( (rd.rodId()<13 && rd.type()==TgcRawData::TYPE_HIPT && (rd.sector() & 4)!=0) || // Run2
414  (rd.rodId()>12 && ( rd.type()==TgcRawData::TYPE_INNER_NSW || // Run3
415  rd.type()==TgcRawData::TYPE_INNER_BIS || // Run3
416  rd.type()==TgcRawData::TYPE_INNER_EIFI || // Run3
417  rd.type()==TgcRawData::TYPE_INNER_TMDB )) ){ // Run3
418  status = decodeInner(state, rd);
419  } else if(rd.type()==TgcRawData::TYPE_SL) {
420  status = decodeSL(state, rd, rdoColl);
421  }
422  if(!status.isSuccess()) {
423  ATH_MSG_WARNING("Cannot decode TGC Coincidences");
424  }
425  }
426 }
427 
429  // The channel hit by hardware-ROD supports only three-bunch readout. Data of TgcDigit::BC_NEXTNEXT should be skipped in this function.
430  if (rd.bcTag() == TgcDigit::BC_NEXTNEXT) return StatusCode::SUCCESS;
431 
432  m_nHitRDOs++; // Count the number of input Hit RDOs.
433  bool isConverted{false}, isDuplicated{false}, isInvalid{false};
434 
435  ATH_MSG_DEBUG("decodeHits() :"<<__LINE__<< " sub=" << rd.subDetectorId()
436  << " rod=" << rd.rodId() << " ssw=" << rd.sswId()
437  << " slb=" << rd.slbId() << " bitpos=" << rd.bitpos());
438 
439  const CablingInfo* cinfo = getCabling();
440 
441  const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
442 
443  // select current Hits, =0 for backward compatibility
444  // BC_CURRENT=2, BC_UNDEFINED=0
445  int locId = (rd.bcTag()==TgcDigit::BC_CURRENT || rd.bcTag()==TgcDigit::BC_UNDEFINED) ? 1 : rd.bcTag()-1;
446 
447  // repeat two times for ORed channel
448  for(int iOr=0; iOr<2; iOr++) {
449  bool orFlag = false;
450  // check if this channel has ORed partner only when 2nd time
451  if(iOr != 0) {
452  bool o_found = cinfo->m_tgcCabling->isOredChannel(rd.subDetectorId(), rd.rodId(), rd.sswId(),
453  rd.slbId(), rd.bitpos());
454  // set OR flag
455  if(o_found) orFlag = true;
456  else continue;
457  }
458 
459  // get element ID
460  Identifier elementId{};
461  bool e_found = cinfo->m_tgcCabling->getElementIDfromReadoutID(elementId,
462  rd.subDetectorId(), rd.rodId(),
463  rd.sswId(), rd.slbId(),
464  rd.bitpos(), orFlag);
465  if(!e_found) {
466  if(!orFlag) {
467  bool show_warning_level = true;
468 
469  /* One invalid channel in sector A09:
470  sub=103 rod=9 ssw=6 slb=20 bitpos=151 +offset=0 orFlag=0
471  was always seen in 2008 data, at least run 79772 - 91800.
472  bug #48828 */
473  /* One invalid channel in sector A11:
474  sub=103 rod=11 ssw=2 slb=8 bitpos=41 orFlag=0
475  was seen 5 times in 1,059,867 events of run 159179. */
476  /* EIFI of MC ByteStream without correction issue : bug 57051 */
477  if( (rd.subDetectorId()==103 && rd.rodId()==9 && rd.sswId()==6 && rd.slbId()==20 && rd.bitpos()==151) ||
478  (rd.subDetectorId()==103 && rd.rodId()==11 && rd.sswId()==2 &&rd.slbId()==8 && rd.bitpos()==41) ||
479  (rd.rodId()%3==2 && rd.sswId()==8)) {
480  show_warning_level = m_show_warning_level_invalid_A09_SSW6_hit;
481  isInvalid = true;
482  }
483  if (msgLvl(show_warning_level ? MSG::WARNING : MSG::DEBUG)){
484  msg(show_warning_level ? MSG::WARNING : MSG::DEBUG) << "ElementID not found for "
485  << " sub=" << rd.subDetectorId() << " rod=" << rd.rodId() << " ssw=" << rd.sswId()
486  << " slb=" << rd.slbId() << " bitpos=" << rd.bitpos() << " orFlag=" << orFlag << endmsg;
487  }
488  }
489  continue;
490  }
491  const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(elementId);
492 
494  bool c_found = cinfo->m_tgcCabling->getOfflineIDfromReadoutID(channelId,
495  rd.subDetectorId(), rd.rodId(),
496  rd.sswId(), rd.slbId(),
497  rd.bitpos(), orFlag);
498  if(!c_found) {
499  if(!orFlag) {
500  ATH_MSG_WARNING("OfflineID not found for "
501  << " sub=" << rd.subDetectorId()<< " rod=" << rd.rodId()
502  << " ssw=" << rd.sswId()<< " slb=" << rd.slbId()
503  << " bitpos=" << rd.bitpos()<< " orFlag=" << orFlag);
504  }
505  continue;
506  }
507 
508 
509  std::unique_ptr<TgcPrepDataCollection>& collection = state.tgcPrepDataCollections[locId][tgcHashId];
510  if (!collection) {
511  collection = std::make_unique<TgcPrepDataCollection>(tgcHashId);
512  collection->setIdentifier(elementId);
513  }
514  const bool duplicate = std::find_if(collection->begin(), collection->end(),
515  [&channelId](const TgcPrepData* prd){
516  return prd->identify() == channelId;
517  }) != collection->end();
518  if(duplicate) {
519  isDuplicated = true; // A converted PRD of this RDO is duplicated.
520  continue;
521  }
522 
524  if(!isOfflineIdOKForTgcReadoutElement(descriptor, channelId)) {
525  ATH_MSG_WARNING("decodeHits: MuonGM::TgcReadoutElement is invalid.");
526  continue;
527  }
528  ATH_MSG_DEBUG("TGC RDO->PrepRawdata: " << m_idHelperSvc->toString(channelId));
529 
530  std::vector<Identifier> identifierList{channelId};
531 
532  Amg::Vector3D position = descriptor->channelPos(channelId);
534  bool onSurface = descriptor->surface(channelId).globalToLocal(position,position,hitPos);
535  // the globalToLocal should not fail, if it does produce a WARNING
536  if(!onSurface) {
537  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::decodeHits Amg::Vector2D* hitPos is null.");
538  continue;
539  }
540 
541 
542  int gasGap = idHelper.gasGap(channelId);
543  int channel = idHelper.channel(channelId);
544  const double width = !idHelper.isStrip(channelId) ? descriptor->gangRadialLength(gasGap, channel)
545  : descriptor->stripWidth(gasGap, channel);
546 
547  if(width<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
548  ATH_MSG_WARNING("decodeHits: width= " << width << " is smaller than s_cutDropPrdsWithZeroWidth= "
549  << s_cutDropPrdsWithZeroWidth<<" "<<m_idHelperSvc->toString(channelId));
550  continue;
551  }
552  double errPos = width/std::sqrt(12.);
553 
554  Amg::MatrixX mat(1,1);
555  mat.setIdentity();
556  mat *= errPos*errPos;
557 
558  // add the digit to the collection
559  // new TgcPrepRawData
560  TgcPrepData* newPrepData = new TgcPrepData(channelId, // Readout ID -> Offline ID
561  tgcHashId, // Readout ID -> Element ID -> Hash
562  hitPos, // determined from channelId
563  identifierList, // holds channelId only
564  mat, // determined from channelId
565  descriptor); // determined from channelId
566  newPrepData->setHashAndIndex(collection->identifyHash(), collection->size());
567  collection->push_back(newPrepData);
568  isConverted = true; // This RDO is converted to at least one PRD.
569  }
570 
571  if(isConverted) m_nHitPRDs++; // Count the number of output Hit PRDs.
572  else if(isDuplicated || isInvalid) m_nHitRDOs--; // Reduce the number of input RDOs.
573 
574  return StatusCode::SUCCESS;
575 }
576 
578  ++m_nTrackletRDOs; // Count the number of input Tracklet RDOs.
579 
580  const CablingInfo* cinfo = getCabling();
581 
582  bool found = false;
583 
584  //*** Get OfflineId of pivot plane (TGC3) start ***//
585  Identifier channelIdOut{};
586  found = cinfo->m_tgcCabling->getOfflineIDfromLowPtCoincidenceID(channelIdOut,
587  rd.subDetectorId(), rd.rodId(),
588  rd.sswId(), rd.slbId(), rd.subMatrix(),
589  rd.position(), false);
590  if(!found) {
591  ATH_MSG_DEBUG("decodeTracklet: can't get the OfflineIdOut");
592  return StatusCode::SUCCESS;
593  }
594  //*** Get OfflineId of pivot plane (TGC3) end ***//
595 
596  //*** Get OfflineId of non-pivot plane (TGC2) start ***//
597  int tmp_slbId{0}, tmp_subMatrix{0}, tmp_position{0};
598  found = getTrackletInfo(rd, tmp_slbId, tmp_subMatrix, tmp_position);
599  if(!found) {
600  return StatusCode::SUCCESS;
601  }
602  Identifier channelIdIn{};
603  found = cinfo->m_tgcCabling->getOfflineIDfromLowPtCoincidenceID(channelIdIn,
604  rd.subDetectorId(), rd.rodId(),
605  rd.sswId(), tmp_slbId,
606  tmp_subMatrix, tmp_position, true);
607  if(!found) {
608  ATH_MSG_DEBUG("decodeTracklet: can't get the OfflineIdIn");
609  return StatusCode::SUCCESS;
610  }
611  //*** Get OfflineId of non-pivot plane (TGC2) end ***//
612 
613  const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(channelIdOut);
614 
615 
616  int locId = (rd.bcTag()==TgcDigit::BC_CURRENT || rd.bcTag()==TgcDigit::BC_UNDEFINED)? 1 : rd.bcTag()-1;
617 
618  std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.tgcCoinDataCollections[locId][tgcHashId];
619  if (!coincollection) {
620  coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
621  coincollection->setIdentifier(m_idHelperSvc->chamberId(channelIdOut));
622  }
623 
624  int subMatrix = static_cast<int>(rd.subMatrix());
625  int trackletId = static_cast<int>(2*rd.slbId()+subMatrix);
626  int delta = static_cast<int>(rd.delta());
627 
628  // Check duplicate digits
629  for (const TgcCoinData* tgcCoinData : *coincollection) {
630  if(TgcCoinData::TYPE_TRACKLET==tgcCoinData->type() && // coincidence type
631  channelIdOut==tgcCoinData->identify() && // channelIdOut, identify returns channelIdOut for Tracklet
632  channelIdIn==tgcCoinData->channelIdIn() && // channelIdIn
633  trackletId==tgcCoinData->trackletId() && // trackletId
634  delta==tgcCoinData->delta() && // delta
635  subMatrix==tgcCoinData->sub()) { // subMatrix
636 
637  ATH_MSG_DEBUG("Duplicated TgcCoinData (Tracklet) = "<< m_idHelperSvc->toString(channelIdIn));
638  return StatusCode::SUCCESS;
639  }
640  }
641 
642  ATH_MSG_DEBUG("TGC RDO->Coindata for LowPT: " << m_idHelperSvc->toString(channelIdOut));
643 
644  //*** Get geometry of pivot plane (TGC3) start ***//
645  const MuonGM::TgcReadoutElement* descriptor_o = state.muDetMgr->getTgcReadoutElement(channelIdOut);
646  if(!isOfflineIdOKForTgcReadoutElement(descriptor_o, channelIdOut)) {
647  return StatusCode::SUCCESS;
648  }
649 
650  const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
651  int gasGap_o = idHelper.gasGap(channelIdOut);
652  int channel_o = idHelper.channel(channelIdOut);
653  double width_o = !idHelper.isStrip(channelIdOut) ? descriptor_o->gangRadialLength(gasGap_o, channel_o)
654  : descriptor_o->stripWidth(gasGap_o, channel_o);
655 
656  if(width_o<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
657  return StatusCode::SUCCESS;
658  }
659 
660  Amg::Vector3D position_o = descriptor_o->channelPos(channelIdOut);
662  bool onSurface_o = descriptor_o->surface(channelIdOut).globalToLocal(position_o,position_o,hitPos_o);
663  // the globalToLocal should not fail, if it does produce a WARNING
664  if(!onSurface_o) {
665  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* hitPos_o is null.");
666  return StatusCode::SUCCESS;
667  }
668  //*** Get geometry of pivot plane (TGC3) end ***//
669 
670  //*** Get geometry of non-pivot plane (TGC2) start ***//
671  const MuonGM::TgcReadoutElement* descriptor_i = state.muDetMgr->getTgcReadoutElement(channelIdIn);
672  if(!isOfflineIdOKForTgcReadoutElement(descriptor_i, channelIdIn)) {
673  return StatusCode::SUCCESS;
674  }
675 
676  int gasGap_i = idHelper.gasGap(channelIdIn);
677  int channel_i = idHelper.channel(channelIdIn);
678  double width_i = !idHelper.isStrip(channelIdIn) ? descriptor_i->gangRadialLength(gasGap_i, channel_i)
679  : descriptor_i->stripWidth(gasGap_i, channel_i);
680 
681  if(width_i<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
682  return StatusCode::SUCCESS;
683  }
684 
685  Amg::Vector3D position_i = descriptor_i->channelPos(channelIdIn);
687  bool onSurface_i = descriptor_i->surface(channelIdIn).globalToLocal(position_i,position_i,hitPos_i);
688  // the globalToLocal should not fail, if it does produce a WARNING
689  if(!onSurface_i) {
690  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* hitPos_i is null.");
691  return StatusCode::SUCCESS;
692  }
693  //*** Get geometry of non-pivot plane (TGC2) end ***//
694  const Amg::Vector2D* hitPosition_o = new Amg::Vector2D(hitPos_o);
695  const Amg::Vector2D* hitPosition_i = new Amg::Vector2D(hitPos_i);
696  // Add the digit to the collection
697  TgcCoinData* newCoinData = new TgcCoinData(channelIdIn,
698  channelIdOut,
699  tgcHashId, // determined from channelIdOut
700  descriptor_i, // determined from channelIdIn
701  descriptor_o, // determined from channelIdOut
703  rd.subDetectorId()==ASIDE, // isAside
704  idHelper.stationPhi(channelIdOut), // phi
705  0, // isInner
706  rd.sswId()==7||rd.sswId()==2, // isForward
707  idHelper.isStrip(channelIdOut), // isStrip
708  trackletId, // trackletId
709  hitPosition_i, // determined from channelIdIn
710  hitPosition_o, // determined from channelIdOut
711  width_i, // determined from channelIdIn
712  width_o, // determined from channelIdOut
713  delta, // delta
714  subMatrix,
715  0); // subMatrix
716  newCoinData->setHashAndIndex(coincollection->identifyHash(), coincollection->size());
717  coincollection->push_back(newCoinData);
718 
719  ATH_MSG_DEBUG("coincollection->push_back done (for LowPT)");
720 
721  m_nTrackletPRDs++; // Count the number of output Tracklet PRDs.
722 
723  return StatusCode::SUCCESS;
724 }
725 
727  // Count the number of input TrackletEIFI RDOs.
728  m_nTrackletEIFIRDOs++;
729 
730  const CablingInfo* cinfo = getCabling();
731 
732  const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
733 
734 
735  // Determine chamber type
737  bool isAside = rd.subDetectorId()==ASIDE;
738  // https://twiki.cern.ch/twiki/pub/Main/TgcDocument/EIFI_PSB_SSW_ConnectionTable_v20080808.pdf
739  bool isForward = (rd.slbId()%2==0);
740  // Assuming RXID in the above file is equal to slbId
741  // rodId: 2 5 8 11
742  // slbId FI: 0 2 4 6 8 10 0 2 4 6 8 10 0 2 4 6 8 10 0 2 4 6 8 10
743  // EI: 1 3 5 7 9 11 1 3 5 XX 9 11 1 3 5 7 9 XX 1 3 5 XX 9 11
744  // slot: 24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
745  // stationPhi
746  // FI: 24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
747  // EI: 21 1 2 3 4 5 6 7 8 XX 9 10 11 12 13 14 15 XX 16 17 18 XX 19 20
748  int slot = ((rd.slbId()/2) + (rd.rodId()-2)*2 + 23)%24 + 1;
749 
750  bool isBackward = false;
751  if(!isForward) { // EI
752  // Special case of EI11
753  if(slot==15) {
754  isBackward = !isAside;
755  } else if(slot==16) {
756  isBackward = isAside;
757  } else {
758  // A-side phi0 F: phi1 F: phi2 B
759  // C-side phi0 B: phi1 B: phi2 F
760  if(isAside) isBackward = (slot%3==2);
761  else isBackward = (slot%3!=2);
762  }
763  } else { // FI
764  isBackward = isAside;
765  }
766 
767  // Determine bitpos based on wire/strip and subMatrix
768  // Input is chosen so that gasGap is 1 and channel is 4,12,20,28.
769  // One subMatrix covers 8 channels (=BIT_POS_ASD_SIZE/2)
770  uint16_t bitpos = 0;
771  if(!isStrip) { // Wire
772  // For wires, D-Input is gasGap=1
773 
774  int tmpsubMatrix = static_cast<int>(rd.subMatrix());
775  if(!isForward) { // If an edge channel of EI fires, subMatrix of the tracklet can be greater than one of the hit channel.
776  if(tmpsubMatrix==3) {
777  if(slot== 1 || slot== 3 || slot== 4 || slot== 5 || slot== 6 || slot== 7 || slot== 8 ||
778  slot==10 || slot==11 || slot==13 || slot==18 || slot==19 || slot==20) {
779  // These slots have only 24 wire channels (=3 submatrixes)
780  tmpsubMatrix = 2;
781  }
782  } else if(tmpsubMatrix==2) {
783  if(slot== 2 || slot==12 || slot==14 || slot==15 || slot==16 || slot==22 || slot==23 || slot==24) {
784  // These slots have only 16 wire channels (=2 submatrixes)
785  tmpsubMatrix = 1;
786  }
787  }
788  }
789 
790  bitpos = BIT_POS_D_INPUT_ORIGIN - BIT_POS_INPUT_SIZE + 1 + BIT_POS_ASD_SIZE/4*(tmpsubMatrix*2+1);
791  } else { // Strip
792  if(isBackward) {
793  // For Backward chambers, B-Input is gasGap 1
794  bitpos = BIT_POS_B_INPUT_ORIGIN - BIT_POS_INPUT_SIZE + (isAside ? 1 : 0) + BIT_POS_ASD_SIZE/4*(rd.subMatrix()*2+1);
795  } else {
796  // For Forward chambers, A-Input is gasGap 1
797  bitpos = BIT_POS_A_INPUT_ORIGIN - BIT_POS_INPUT_SIZE + (isAside ? 0 : 1) + BIT_POS_ASD_SIZE/4*(rd.subMatrix()*2+1);
798  }
799  }
800 
801  // Retrieve OfflineID from ReadoutID
802  Identifier channelIdIn;
803  bool o_found = cinfo->m_tgcCabling->getOfflineIDfromReadoutID(channelIdIn,
804  rd.subDetectorId(), rd.rodId(),
805  rd.sswId(),rd.slbId(), bitpos,
806  false/*orflag*/);
807  if(!o_found) {
808  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI OfflineID not found for "
809  << " subDetectorId=" << rd.subDetectorId() << " rodId=" << rd.rodId()
810  << " sswId=" << rd.sswId()<< " slbId=" << rd.slbId() << " slbType=" << rd.slbType()
811  << " subMatrix=" << rd.subMatrix() << " bitpos=" << bitpos << " isStrip=" << isStrip
812  << " isAside=" << isAside<< " isForward=" << isForward<< " slot=" << slot
813  << " isBackward=" << isBackward);
814  return StatusCode::SUCCESS;
815  }
816 
817 
818  // Retrieve Hash from ElementID
819  const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(channelIdIn);
820  // Index is determined based on bcTag.
821  int locId = (rd.bcTag()==TgcDigit::BC_CURRENT || rd.bcTag()==TgcDigit::BC_UNDEFINED) ? 1 : rd.bcTag()-1;
822 
823  std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.tgcCoinDataCollections[locId][tgcHashId];
824  if (!coincollection) {
825  coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
826  coincollection->setIdentifier(m_idHelperSvc->chamberId(channelIdIn));
827  }
828 
829  // Check duplicate digits
830  for (const TgcCoinData* tgcCoinData : *coincollection) {
831  if(TgcCoinData::TYPE_TRACKLET_EIFI==tgcCoinData->type() && // coincidence type
832  channelIdIn==tgcCoinData->channelIdIn() && // channelIdIn
833  static_cast<int>(rd.subMatrix())==tgcCoinData->sub()) { // sub
834  ATH_MSG_DEBUG("Duplicated TgcCoinData (TrackletEIFI) = "<< m_idHelperSvc->toString(channelIdIn));
835  return StatusCode::SUCCESS;
836  }
837  }
838  // Get MuonGM::TgcReadoutElement from channelIdIn
839  const MuonGM::TgcReadoutElement* descriptor = state.muDetMgr->getTgcReadoutElement(channelIdIn);
840  if(!isOfflineIdOKForTgcReadoutElement(descriptor, channelIdIn)) {
841  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI descriptor doesn't contain "
842  << m_idHelperSvc->toString(channelIdIn));
843  return StatusCode::SUCCESS;
844  }
845 
846  // Get Amg::Vector2D from channelIdIn //here I am
847  Amg::Vector3D position = descriptor->channelPos(channelIdIn);
849  bool onSurface = descriptor->surface(channelIdIn).globalToLocal(position,position,hitPos);
850  // the globalToLocal should not fail, if it does produce a WARNING
851  if(!onSurface) {
852  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI Amg::Vector2D* hitPos is null.");
853  return StatusCode::SUCCESS;
854  }
855 
856  // Get width from channelIdIn, one subMatrix covers 8 channels per gasGap
857  int gasGap = idHelper.gasGap(channelIdIn); // 1
858  int channel = idHelper.channel(channelIdIn); // 4, 12, 20, 28
859  double width {0};
860  if(isStrip) { // Strip
861  double localZ = (descriptor->transform(channelIdIn).inverse()*descriptor->channelPos(channelIdIn)).z();
862  double stripMaxX = descriptor->stripHighEdgeLocX(gasGap, channel+4, localZ);
863  double stripMinX = descriptor->stripLowEdgeLocX(gasGap, channel-3, localZ);
864  width = std::abs(stripMaxX - stripMinX);
865  } else { // Wire
866  int positiveOffset = +4;
867  if(isForward && (slot%3==2) && channel==28) positiveOffset = +2; // T10S has only 30 channels.
868  double gangMaxZ = descriptor->gangLongWidth(gasGap, channel+positiveOffset);
869  double gangMinZ = descriptor->gangShortWidth(gasGap, channel-3);
870  width = std::abs(gangMaxZ - gangMinZ);
871  }
872 
873  const Amg::Vector2D* hitPosition = new Amg::Vector2D(hitPos);
874  // Add the digit to the collection
875  TgcCoinData* newCoinData = new TgcCoinData(channelIdIn,
876  tgcHashId, // determined from channelIdIn
877  descriptor, // determined from channelIdIn
879  isAside,
880  m_idHelperSvc->tgcIdHelper().stationPhi(channelIdIn),
881  isForward,
882  isStrip,
883  hitPosition, // determined from channelIdIn
884  width, // determined from channelIdIn
885  static_cast<int>(rd.subMatrix())); // subMatrix
886  newCoinData->setHashAndIndex(coincollection->identifyHash(), coincollection->size());
887  coincollection->push_back(newCoinData);
888 
889  // Count the number of output Tracklet EIFI PRDs.
890  m_nTrackletEIFIPRDs++;
891  return StatusCode::SUCCESS;
892 }
893 
895  m_nHiPtRDOs++; // Count the number of input HiPt RDOs.
896 
897  const CablingInfo* cinfo = getCabling();
898 
899  // conversion for Run3
900  uint16_t tmprodId{}, tmpsector{};
901  convertToRun2(rd0,tmprodId,tmpsector);
902  const TgcRawData rd(rd0.bcTag(), rd0.subDetectorId(), tmprodId,
903  rd0.l1Id(), rd0.bcId(), rd0.isStrip(),
904  rd0.isForward(), tmpsector, rd0.chip(),
905  rd0.index(), rd0.isHipt(), rd0.hitId(),
906  rd0.hsub(), rd0.delta(), rd0.inner());
907 
908  // Protection against invalid subDetectorId and isForward
909  if((rd.subDetectorId()!=ASIDE && rd.subDetectorId()!=CSIDE)) {
910  ATH_MSG_DEBUG("TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
911  return StatusCode::SUCCESS;
912  }
913 
914  // Protection against invalid hitId
915  if(rd.hitId()==0) {
916  ATH_MSG_DEBUG("Invalid hitId_rdo_hipt, hitId == 0!! skip to convert this RDO to PRD");
917  return StatusCode::SUCCESS;
918  }
919  int slbsubMatrix = 0;
920  bool isBackward = isBackwardBW(rd); // Backward or Forward
921  int deltaBeforeConvert = getDeltaBeforeConvert(rd);
922 
923  bool found = false;
924 
925  Identifier channelIdOut_tmp{};
926  std::array<Identifier, 2> channelIdOut{};
927  std::array<int, 2> bitpos_o{}, slbchannel_o{};
928  int sswId_o{0}, sbLoc_o{0}, slbId_o{0};
929 
930  Identifier channelIdIn_tmp{};
931  std::array<Identifier, 4> channelIdIn{};
932  std::array<int, 4> bitpos_i{}, slbchannel_i{};
933  int sswId_i{0}, sbLoc_i{0};
934 
935  std::array<int, 4> slbId_in {}, sbLoc_in{}; // only used for wire
936 
937  std::array<int, 4> gasGap_i{}, channel_i{};
938  double width_i{0.},hit_position_i{0};
939  Amg::Vector2D tmp_hitPos_i{Amg::Vector2D::Zero()};
940 
941  std::array<int, 2> gasGap_o{}, channel_o{};
942  double width_o{0.}, hit_position_o{0.};
943  Amg::Vector2D tmp_hitPos_o{Amg::Vector2D::Zero()};
944 
945  const MuonGM::TgcReadoutElement* descriptor_ii = nullptr;
946  const MuonGM::TgcReadoutElement* descriptor_oo = nullptr;
947 
948  //*** TGC3 start ***//
949  // RDOHighPtID --> (Sim)HighPtID --> OfflineID --> ReadoutID --> getSLBID
950  found = getHiPtIds(rd, sswId_o, sbLoc_o, slbId_o);
951  if(!found) {
952  return StatusCode::SUCCESS;
953  }
954 
955  // get the OfflineID of cernter of ROI of TGC3
956  if(!rd.isStrip()) { // wire
957  getBitPosOutWire(rd, slbsubMatrix, bitpos_o);
958  } else { // strip
959  getBitPosOutStrip(rd, slbsubMatrix, bitpos_o);
960  }
961  for(int i=0; i<2; i++) {
962  found = cinfo->m_tgcCabling->getOfflineIDfromReadoutID(channelIdOut[i], rd.subDetectorId(), rd.rodId(),
963  sswId_o, sbLoc_o, bitpos_o[i]);
964  if(!found) {
965  ATH_MSG_DEBUG("Failed to get OfflineID from ReadoutID for Pivot " << (rd.isStrip() ? "Strip" : "Wire") << ".");
966  return StatusCode::SUCCESS;
967  }
968  }
969 
970  //}
971  //*** TGC3 end ***//
972 
973  //*** TGC1 start ***//
974  // get the OfflineID of cernter of ROI of TGC1
975  if(!rd.isStrip()) { // wire
976  getBitPosInWire(rd, deltaBeforeConvert, bitpos_i, slbchannel_i, slbId_in, sbLoc_in, sswId_i, bitpos_o,
977  slbchannel_o, slbId_o);
978  } else { // strip
979  getBitPosInStrip(rd, deltaBeforeConvert, bitpos_i, slbchannel_i, sbLoc_i, sswId_i, bitpos_o, slbchannel_o);
980  }
981  for(int i=0; i<4; i++) {
982  found = cinfo->m_tgcCabling->getOfflineIDfromReadoutID(channelIdIn[i], rd.subDetectorId(), rd.rodId(), sswId_i,
983  rd.isStrip() ? sbLoc_i : sbLoc_in[i],
984  bitpos_i[i]);
985  if(!found) {
986  ATH_MSG_DEBUG("Failed to get OfflineID from ReadoutID for Pivot "
987  << (rd.isStrip() ? "Strip" : "Wire") << ".");
988  return StatusCode::SUCCESS;
989  }
990  }
991  //}
992  //*** TGC1 end ***//
993 
994  ATH_MSG_DEBUG("TGC RDO->Coindata for HIPT: " << m_idHelperSvc->toString(channelIdOut[1]));
995 
996  const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(channelIdOut[1]);
997 
998  int locId = (rd.bcTag()==TgcDigit::BC_CURRENT || rd.bcTag()==TgcDigit::BC_UNDEFINED) ? 1 : rd.bcTag()-1;
999 
1000  std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.tgcCoinDataCollections[locId][tgcHashId];
1001  if (!coincollection) {
1002  coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1003  coincollection->setIdentifier(m_idHelperSvc->chamberId(channelIdOut[1]));
1004  }
1005 
1006  //*** TGC3 start ***//
1007  // Get geometry of pivot plane
1008  std::array<const MuonGM::TgcReadoutElement*, 2> descriptor_o{state.muDetMgr->getTgcReadoutElement(channelIdOut[0]),
1009  state.muDetMgr->getTgcReadoutElement(channelIdOut[1])};
1010  for(int i=0; i<2; i++) {
1011  if(!isOfflineIdOKForTgcReadoutElement(descriptor_o[i], channelIdOut[i])) {
1012  return StatusCode::SUCCESS;
1013  }
1014  }
1015 
1016  const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
1017  for(int i=0; i<2; i++) {
1018  gasGap_o[i] = idHelper.gasGap(channelIdOut[i]);
1019  channel_o[i] = idHelper.channel(channelIdOut[i]);
1020  }
1021 
1022  if(!rd.isStrip()) { // wire
1023  found = getPosAndIdWireOut(descriptor_o, channelIdOut,
1024  gasGap_o, channel_o,
1025  width_o, hit_position_o, tmp_hitPos_o,
1026  channelIdOut_tmp);
1027  } else { //strip
1028  found = getPosAndIdStripOut(descriptor_o, channelIdOut,
1029  gasGap_o, channel_o,
1030  width_o, hit_position_o, tmp_hitPos_o,
1031  channelIdOut_tmp,
1032  isBackward, rd.subDetectorId()==ASIDE);
1033  }
1034  if(!found) {
1035  return StatusCode::SUCCESS;
1036  }
1037  if(width_o<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
1038  return StatusCode::SUCCESS;
1039  }
1040 
1041  descriptor_oo = state.muDetMgr->getTgcReadoutElement(channelIdOut_tmp);
1042  if(!isOfflineIdOKForTgcReadoutElement(descriptor_oo, channelIdOut_tmp)) {
1043  return StatusCode::SUCCESS;
1044  }
1045  //}
1046  //*** TGC3 end ***//
1047 
1048  //*** TGC1 start ***//
1049  // Get geometry of non-pivot plane
1050  std::array<const MuonGM::TgcReadoutElement*, 4> descriptor_i{state.muDetMgr->getTgcReadoutElement(channelIdIn[0]),
1051  state.muDetMgr->getTgcReadoutElement(channelIdIn[1]),
1052  state.muDetMgr->getTgcReadoutElement(channelIdIn[2]),
1053  state.muDetMgr->getTgcReadoutElement(channelIdIn[3])};
1054  for(int i=0; i<4; i++) {
1055  if(!isOfflineIdOKForTgcReadoutElement(descriptor_i[i], channelIdIn[i])) {
1056  return StatusCode::SUCCESS;
1057  }
1058  }
1059  for(int i=0; i<4; i++) {
1060  gasGap_i[i] = idHelper.gasGap(channelIdIn[i]);
1061  channel_i[i] = idHelper.channel(channelIdIn[i]);
1062  }
1063 
1064  if(!rd.isStrip()) { // WIRE
1065  found = getPosAndIdWireIn(descriptor_i, channelIdIn,
1066  gasGap_i, channel_i,
1067  width_i, hit_position_i, tmp_hitPos_i,
1068  channelIdIn_tmp);
1069  } else { // STRIP
1070  found = getPosAndIdStripIn(descriptor_i, channelIdIn,
1071  gasGap_i, channel_i,
1072  width_i, hit_position_i, tmp_hitPos_i,
1073  channelIdIn_tmp,
1074  isBackward, (rd.subDetectorId()==ASIDE));
1075  }
1076  if(!found) {
1077  return StatusCode::SUCCESS;
1078  }
1079  if(width_i<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
1080  return StatusCode::SUCCESS;
1081  }
1082 
1083  descriptor_ii = state.muDetMgr->getTgcReadoutElement(channelIdIn_tmp);
1084  if(!isOfflineIdOKForTgcReadoutElement(descriptor_ii, channelIdIn_tmp)) {
1085  return StatusCode::SUCCESS;
1086  }
1087  //}
1088  //*** TGC1 end ***//
1089 
1090  int trackletId = 2*sbLoc_o + slbsubMatrix;
1091  int delta = static_cast<int>(rd.delta());
1092  int hsub = static_cast<int>(rd.hsub());
1093  int inner = static_cast<int>(rd.inner());
1094 
1095  // check duplicate digits
1096  for (const TgcCoinData* tgcCoinData : *coincollection) {
1097  if((TgcCoinData::TYPE_HIPT==tgcCoinData->type()) && // Coincidence type
1098  (channelIdOut_tmp==tgcCoinData->identify()) && // channelIdOut, identify returns channelIdOut for HiPt
1099  (channelIdIn_tmp==tgcCoinData->channelIdIn()) && // channelIdIn
1100  (trackletId==tgcCoinData->trackletId()) && // trackletId
1101  (delta==tgcCoinData->delta()) && // delta
1102  (hsub==tgcCoinData->sub()) && // hsub
1103  (inner==tgcCoinData->inner())) {
1104  if(38<=trackletId && trackletId<=41) {
1105  // This drop is most probably due to the fix of the HiPt Endcap Strip Board bug.
1106  m_nHiPtRDOs--; // Reduce the number of input RDOs.
1107  }
1108  ATH_MSG_DEBUG("Duplicated TgcCoinData (HiPt) = "<< m_idHelperSvc->toString(channelIdOut_tmp));
1109  return StatusCode::SUCCESS;
1110  }
1111  }
1112 
1113  auto hitPos_o = std::make_unique<Amg::Vector2D>(tmp_hitPos_o);
1114  auto hitPos_i = std::make_unique<Amg::Vector2D>(tmp_hitPos_i);
1115 
1116  TgcCoinData* newCoinData = new TgcCoinData(channelIdIn_tmp,
1117  channelIdOut_tmp,
1118  tgcHashId, // determined from channelIdOut[1]
1119  descriptor_ii, // determined from channelIdIn_tmp
1120  descriptor_oo, // determined from channelIdOut_tmp
1121  TgcCoinData::TYPE_HIPT, // Coincidence type
1122  rd.subDetectorId()==ASIDE, // isAside
1123  idHelper.stationPhi(channelIdOut_tmp), // phi
1124  0, // isInner
1125  rd.isForward(), // isForward
1126  rd.isStrip(), // isStrip
1127  trackletId, // trackletId
1128  hitPos_i.release(),
1129  hitPos_o.release(),
1130  width_i,
1131  width_o,
1132  delta, // delta
1133  hsub, // hsub
1134  inner);
1135  // add the digit to the collection
1136  newCoinData->setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1137  coincollection->push_back(newCoinData);
1138 
1139  ATH_MSG_DEBUG("coincollection->push_back done (for HIPT)");
1140 
1141  m_nHiPtPRDs++; // Count the number of output HiPt PRDs.
1142 
1143  return StatusCode::SUCCESS;
1144 }
1145 
1147  m_nHiPtRDOs++; // Count the number of input HiPt RDOs.
1148 
1149  const CablingInfo* cinfo = getCabling();
1150  if (!cinfo) {
1151  return StatusCode::FAILURE;
1152  }
1153 
1154  int subDetectorId = rd.subDetectorId();
1155  // Protection against invalid subDetectorId and isForward
1156  if(subDetectorId!=ASIDE && subDetectorId!=CSIDE) {
1157  ATH_MSG_DEBUG("TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
1158  return StatusCode::SUCCESS;
1159  }
1160 
1161  bool isInner = ((rd.sector() & 4) != 0 ); // Inner flag for EIFI and Tilecal
1162 
1163 
1164  Identifier channelIdIn{};
1165  Identifier channelIdOut{};
1166  int sswId_o = 9;
1167  int sbLoc_o = rd.sector() & 3;
1168  int inner = rd.inner();
1169  bool isStrip = rd.isStrip();
1170 
1171  int phi = 0; bool isAside = false; bool isEndcap = false;
1172  if(rd.rodId() < 13){ // Run2
1173  cinfo->m_tgcCabling->getSLIDfromReadoutID(phi, isAside, isEndcap, subDetectorId,
1174  rd.rodId(), sswId_o, sbLoc_o);
1175  }else{ // Run3
1176  sbLoc_o = rd.sector();
1177  cinfo->m_tgcCabling->getSLIDfromSReadoutID(phi, isAside, subDetectorId, rd.rodId(), sbLoc_o, rd.isForward());
1178  isEndcap = !rd.isForward();
1179  if(rd.type()==TgcRawData::TYPE_INNER_NSW){
1180  isInner = true; isStrip = false;
1189  } else if(rd.type()==TgcRawData::TYPE_INNER_BIS){
1190  isInner = true; isStrip = true;
1197  }else if(rd.type()==TgcRawData::TYPE_INNER_EIFI){
1198  isInner = false; isStrip = false;
1202  }else if(rd.type()==TgcRawData::TYPE_INNER_TMDB){
1203  isInner = false; isStrip = true;
1206  }
1207  }
1208 
1209  int locId = (rd.bcTag()==TgcDigit::BC_CURRENT || rd.bcTag()==TgcDigit::BC_UNDEFINED) ? 1 : rd.bcTag()-1;
1210 
1211  auto hitPos_o = std::make_unique< Amg::Vector2D >(Amg::Vector2D::Zero());
1212  auto hitPos_i = std::make_unique< Amg::Vector2D >(Amg::Vector2D::Zero());
1213 
1214  const MuonGM::TgcReadoutElement* descriptor_ii = nullptr;
1215  const MuonGM::TgcReadoutElement* descriptor_oo = nullptr;
1216 
1217  std::string stationName = "T3E";
1218  int stationEta = isAside ? 1 : -1;
1219  int stationPhi = phi;
1220  bool isValid{false};
1221  Identifier elementId = m_idHelperSvc->tgcIdHelper().elementID(stationName, stationEta, stationPhi, isValid);
1222  const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(elementId);
1223 
1224  std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.tgcCoinDataCollections[locId][tgcHashId];
1225  if (!coincollection) {
1226  coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1227  coincollection->setIdentifier(elementId);
1228  }
1229 
1230  ATH_MSG_DEBUG("Inner Data Word, phi: " << phi << " isAside: " << isAside << " isEndcap: " << isEndcap
1231  << " subDetectorId: " << subDetectorId << " isStrip: " << rd.isStrip()
1232  << " rodId: " << rd.rodId() << " slbId: " << sbLoc_o << " inner:"<< rd.inner());
1233 
1234  TgcCoinData* newCoinData = new TgcCoinData(channelIdIn, // empty
1235  channelIdOut, // empty
1236  tgcHashId, // determined from channelIdOut[1]
1237  descriptor_ii, // determined from channelIdIn_tmp
1238  descriptor_oo, // determined from channelIdOut_tmp
1239  (rd.rodId()<13)?(TgcCoinData::TYPE_HIPT):(TgcCoinData::TYPE_UNKNOWN), // Coincidence type: rd.rodId()<13 for Run2, rd.rodId()>12 for Run3
1240  isAside, // isAside
1241  phi, // phi
1242  isInner, // Selection for NSW/BIS/EIFI/TMDB
1243  !isEndcap, // isForward
1244  isStrip, // Selection for NSW/BIS/EIFI/TMDB
1245  0, // trackletId
1246  hitPos_i.release(),
1247  hitPos_o.release(),
1248  0., // width_i,
1249  0., // width_o,
1250  0, // delta,
1251  0, // hsub,
1252  inner);
1253  // add the digit to the collection
1254  newCoinData->setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1255  coincollection->push_back(newCoinData);
1256 
1257  ATH_MSG_DEBUG("coincollection->push_back done (for Inner)");
1258 
1259  m_nHiPtPRDs++; // Count the number of output HiPt PRDs.
1260 
1261  return StatusCode::SUCCESS;
1262 }
1263 
1264 StatusCode Muon::TgcRdoToPrepDataToolMT::decodeSL(State& state, const TgcRawData& rd0, const TgcRdo* rdoColl) const {
1265  m_nSLRDOs++; // Count the number of input SL RDOs.
1266 
1267  // conversion for Run3
1268  uint16_t tmprodId, tmpsector;
1269  convertToRun2(rd0,tmprodId,tmpsector);
1270  const TgcRawData rd(rd0.bcTag(), rd0.subDetectorId(), tmprodId, rd0.l1Id(),rd0.bcId(),
1271  rd0.isForward(), tmpsector, rd0.innerflag(), rd0.coinflag(),
1272  rd0.isMuplus(), rd0.threshold(), rd0.roi());
1273 
1274  // Protection against invalid subDetectorId
1275  if(rd.subDetectorId()!=ASIDE && rd.subDetectorId()!=CSIDE) {
1276  ATH_MSG_DEBUG("TgcRdoToPrepDataToolMT::decodeSL::Unknown subDetectorId!!");
1277  return StatusCode::SUCCESS;
1278  }
1279 
1280  bool found = false;
1281 
1282  std::array<Identifier, 3> channelId_wire{};
1283  int index_w{0}, chip_w{0}, hitId_w{0}, sub_w{0}, sswId_w{0}, sbLoc_w{0}, subMatrix_w{0};
1284  std::array<int, 3> bitpos_w{};
1285 
1286  //*** get OfflineID, center of ROI of R (wire) ***//
1287  found = getSLIds(false, rd, channelId_wire, index_w, chip_w, hitId_w, sub_w, sswId_w, sbLoc_w,
1288  subMatrix_w, bitpos_w);
1289  if(!found) {
1290  return StatusCode::SUCCESS;
1291  }
1292 
1293  std::array<Identifier, 3> channelId_strip{};
1294  int index_s{0}, chip_s{0}, hitId_s{0}, sub_s{0}, sswId_s{0}, sbLoc_s{0}, subMatrix_s{0};
1295  std::array<int, 3> bitpos_s{};
1296 
1297  //*** get OfflineID, center of ROI of phi (strip) ***//
1298  found = getSLIds(true, rd, channelId_strip, index_s, chip_s, hitId_s, sub_s, sswId_s, sbLoc_s, subMatrix_s,
1299  bitpos_s, isIncludedInChamberBoundary(rd), rdoColl, index_w, chip_w, hitId_w, sub_w);
1300  if(!found) {
1301  return StatusCode::SUCCESS;
1302  }
1303 
1304  ATH_MSG_DEBUG("TGC RDO->TgcCoindata(SL): " << m_idHelperSvc->toString(channelId_wire[1]));
1305 
1306  const IdentifierHash tgcHashId= m_idHelperSvc->moduleHash(channelId_wire[1]);
1307 
1308 
1309  int locId = (rd.bcTag()==TgcDigit::BC_CURRENT || rd.bcTag()==TgcDigit::BC_UNDEFINED) ? 1 : rd.bcTag()-1;
1310 
1311  std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.tgcCoinDataCollections[locId][tgcHashId];
1312  if (!coincollection) {
1313  coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1314  coincollection->setIdentifier(m_idHelperSvc->chamberId(channelId_wire[1]));
1315  }
1316 
1317 
1318  int trackletId = 2*sbLoc_w + subMatrix_w;
1319  int trackletIdStrip = 2*sbLoc_s + subMatrix_s;
1320  int roi = static_cast<int>(rd.roi());
1321  int pt = static_cast<int>(rd.threshold());
1322  if(rd0.rodId()>12){ // Run3: pT 4 bit, CoinFlag 3 bit, InnerFlag 4 bit
1323  pt += (static_cast<int>( rd.coinflag() ) << 4 );
1324  pt += (static_cast<int>( rd.innerflag() ) << 7 );
1325  }
1326  bool veto = rd.isVeto();
1327  bool isPositiveDeltaR = rd.isMuplus(); // Current SL sets isMuplus flag based on sign of deltaR.
1328  // Postive deltaR gives isMuplus=true.
1329  // check duplicate digits
1330  for (const TgcCoinData* tgcCoinData : *coincollection) {
1331  if(TgcCoinData::TYPE_SL==tgcCoinData->type() && channelId_wire[2]==tgcCoinData->identify() &&
1332  trackletId==tgcCoinData->trackletId() && trackletIdStrip==tgcCoinData->trackletIdStrip() &&
1333  roi==tgcCoinData->roi() && pt==tgcCoinData->pt() && veto==tgcCoinData->veto() &&
1334  isPositiveDeltaR==tgcCoinData->isPositiveDeltaR()) {
1335  ATH_MSG_DEBUG("Duplicated TgcCoinData (SL) = "
1336  << m_idHelperSvc->toString(channelId_wire[2]));
1337  return StatusCode::SUCCESS;
1338  }
1339  }
1340 
1341  //*** R (wire) start ***//
1342  double width_w{0.}, tmp_r{0.}, tmp_wire_z{0.};
1343  found = getSLWireGeometry(channelId_wire, width_w, tmp_r, tmp_wire_z);
1344  if(!found) {
1345  return StatusCode::SUCCESS;
1346  }
1347  if(width_w<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
1348  return StatusCode::SUCCESS;
1349  }
1350 
1351  double tmp_eta = 0.;
1352  bool isGoodEta = getEtafromRZ(tmp_r, tmp_wire_z, tmp_eta);
1353  if(!isGoodEta) {
1354  ATH_MSG_WARNING("Conversion from r and z to eta by Muon::TgcRdoToPrepDataToolMT::getEtafromRZ failed.");
1355  return StatusCode::SUCCESS;
1356  }
1357  if(tmp_wire_z<0.) tmp_eta *= -1.;
1358  //*** R (wire) end ***//
1359 
1360  //*** Phi (strip) start ***//
1361  double width_s{0.}, tmp_phi{0.};
1362  found = getSLStripGeometry(channelId_strip, isBackwardBW(rd), (rd.subDetectorId()==ASIDE), width_s, tmp_phi);
1363  if(!found) {
1364  return StatusCode::SUCCESS;
1365  }
1366  if(width_s<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
1367  return StatusCode::SUCCESS;
1368  }
1369  //*** Phi (strip) end ***//
1370  const MuonGM::TgcReadoutElement* descriptor_w2 = state.muDetMgr->getTgcReadoutElement(channelId_wire[2]);
1371  if(!isOfflineIdOKForTgcReadoutElement(descriptor_w2, channelId_wire[2])) {
1372  return StatusCode::SUCCESS;
1373  }
1374 
1375  Amg::Vector3D tmp_gp(tmp_r*std::cos(tmp_phi), tmp_r*std::sin(tmp_phi), tmp_wire_z);
1376  Amg::Vector2D tmp_hitPos{Amg::Vector2D::Zero()};
1377  bool onSurface = descriptor_w2->surface(channelId_wire[2]).globalToLocal(tmp_gp,tmp_gp,tmp_hitPos);
1378  // If TGC A-lines with rotations are used, the z-coordinate of a chamber depends on position.
1379  // In this case, the global to local conversion fails.
1380  // Obtain the local position in a different way.
1381  const Amg::Vector2D* hitPos = !onSurface ? new Amg::Vector2D(tmp_hitPos) :
1382  getSLLocalPosition(descriptor_w2, channelId_wire[2], tmp_eta, tmp_phi);
1383 
1384 
1385  Amg::MatrixX mat(2,2);
1386  mat.setIdentity();
1387  mat(0,0) = width_w;
1388  mat(1,1) = width_s;
1389  const Amg::MatrixX* errMat = new Amg::MatrixX(std::move(mat));
1390 
1391 
1392  // new TgcCoinData
1393  TgcCoinData* newCoinData = new TgcCoinData(channelId_wire[2],
1394  tgcHashId, // determined from channelId_wire[1]
1395  descriptor_w2, // determined from channelId_wire[2]
1396  TgcCoinData::TYPE_SL, // Coincidence type
1397  rd.subDetectorId()==ASIDE, // isAside
1398  m_idHelperSvc->tgcIdHelper().stationPhi(channelId_wire[2]), // phi
1399  rd.isForward(), // isForward
1400  trackletId, // trackletId
1401  trackletIdStrip, // trackletIdStrip
1402  hitPos,
1403  errMat,
1404  roi, // roi from RDO
1405  pt, // threshold from RDO
1406  veto, // veto flag from RDO
1407  isPositiveDeltaR); // isMuplus from RDO
1408 
1409  // add the digit to the collection
1410  newCoinData->setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1411  coincollection->push_back(newCoinData);
1412  ATH_MSG_DEBUG("coincollection->push_back done (for SL)");
1413 
1414  m_nSLPRDs++; // Count the number of output SL PRDs.
1415  return StatusCode::SUCCESS;
1416 }
1417 
1419 {
1420  int bitpos = -BIT_POS_INPUT_SIZE +1;
1421  if(slbType==TgcRawData::SLB_TYPE_TRIPLET_WIRE) {
1422  if(channel<0 || channel>=WT_MAP_SIZE) return -1; // Invalid channel
1423 
1424  if( channel%3==0) bitpos += BIT_POS_C_INPUT_ORIGIN; // C-Input
1425  else if(channel%3==1) bitpos += BIT_POS_B_INPUT_ORIGIN; // B-Input
1426  else bitpos += BIT_POS_A_INPUT_ORIGIN; // A-Input
1427  return bitpos + channel/3;
1428  } else if(slbType==TgcRawData::SLB_TYPE_TRIPLET_STRIP ||
1430  if(channel<0 || channel>=ST_MAP_SIZE) return -1; // Invalid channel, SD_MAP_SIZE is equal to ST_MAP_SIZE.
1431 
1432  if(channel%2==0) bitpos += BIT_POS_B_INPUT_ORIGIN; // B-Input
1433  else bitpos += BIT_POS_A_INPUT_ORIGIN; // A-Input
1434  return bitpos + channel/2;
1435  } else if(slbType==TgcRawData::SLB_TYPE_DOUBLET_WIRE) {
1436  if(channel<0 || channel>=WD_MAP_SIZE) return -1; // Invalid channel
1437 
1438  if(channel%2==0) bitpos += BIT_POS_B_INPUT_ORIGIN; // B-Input
1439  else bitpos += BIT_POS_A_INPUT_ORIGIN; // A-Input
1440  return bitpos + channel/2;
1441  } else {
1442  return -1;
1443  }
1444 }
1445 
1447 {
1448  int input = -1;
1449  if( (bitpos<=BIT_POS_A_INPUT_ORIGIN) && (bitpos>BIT_POS_A_INPUT_ORIGIN-BIT_POS_INPUT_SIZE)) input = 2; // A-Input
1450  else if((bitpos<=BIT_POS_B_INPUT_ORIGIN) && (bitpos>BIT_POS_B_INPUT_ORIGIN-BIT_POS_INPUT_SIZE)) input = 1; // B-Input
1451  else if((bitpos<=BIT_POS_C_INPUT_ORIGIN) && (bitpos>BIT_POS_C_INPUT_ORIGIN-BIT_POS_INPUT_SIZE)) input = 0; // C-Input
1452  // D-Input is not implemented yet.
1453  else return -1; // Invalid bitpos
1454  if(input==0 && slbType!=TgcRawData::SLB_TYPE_TRIPLET_WIRE) return -1; // Only Wire Triplet has C-input.
1455 
1456  int channel = 1-BIT_POS_INPUT_SIZE;
1457  if(slbType==TgcRawData::SLB_TYPE_TRIPLET_WIRE) {
1458  if( input==2) channel += BIT_POS_A_INPUT_ORIGIN; // A-input
1459  else if(input==1) channel += BIT_POS_B_INPUT_ORIGIN; // B-input
1460  else channel += BIT_POS_C_INPUT_ORIGIN; // C-input
1461  channel = 3*(bitpos - channel) + input;
1462  return channel; // C(0)->B(1)->A(2)->C(3)->B(4)->A(5)-> ... ->C(96-3)->B(96-2)->A(96-1)
1463  } else if(slbType==TgcRawData::SLB_TYPE_TRIPLET_STRIP ||
1466  if(input==2) channel += BIT_POS_A_INPUT_ORIGIN; // A-input
1467  else channel += BIT_POS_B_INPUT_ORIGIN; // B-input
1468  channel = 2*(bitpos - channel) + input-1;
1469  return channel; // B(0)->A(1)->B(2)->A(3)-> ... ->B(64-2)->A(64-1)
1470  } else {
1471  return -1;
1472  }
1473 }
1474 
1475 bool Muon::TgcRdoToPrepDataToolMT::getRfromEtaZ(const double eta, const double z, double& r)
1476 {
1477  r = exp(-eta); // tan(theta/2)
1478  r = atan(r); // theta/2
1479  r = tan(2.*r); // tan(theta)
1480  r *= std::abs(z); // r=|z|*tan(theta)
1481 
1482  return r >= 0.;
1483 }
1484 
1485 bool Muon::TgcRdoToPrepDataToolMT::getEtafromRZ(const double r, const double z, double& eta)
1486 {
1487  double r_tmp = std::abs(r);
1488  double z_tmp = std::abs(z);
1489 
1490  if((r_tmp<std::numeric_limits<double>::epsilon()) && (z_tmp<std::numeric_limits<double>::epsilon())) return false;
1491 
1492  eta = std::abs(atan2(r_tmp,z_tmp)); // theta
1493  eta = tan(eta/2.); // tan(theta/2)
1494  eta = -log(eta); // rapidity=-log(tan(theta/2))
1495  return true;
1496 }
1497 
1498 
1500  const Identifier channelId) const {
1501  if(!descriptor || !descriptor->containsId(channelId)) {
1502  ATH_MSG_DEBUG("Illegal OfflineID for TgcReadoutElement" << m_idHelperSvc->toString(channelId));
1503  return false;
1504  }
1505  return true;
1506 }
1507 
1509  int& tmp_subMatrix, int& tmp_position) const {
1510  tmp_subMatrix = rd.subMatrix();
1511  if(tmp_subMatrix!=0 && tmp_subMatrix!=1) {
1512  ATH_MSG_DEBUG("getTrackletInfo: subMatrix " << tmp_subMatrix << " is invalid.");
1513  return false;
1514  }
1515 
1516  int tmp_sswId = rd.sswId();
1517  tmp_slbId = rd.slbId();
1518  tmp_position = rd.position();
1519 
1520  int tmp_position_delta = tmp_position + rd.delta();
1521  int tmp_slbType = rd.slbType();
1522 
1523  if(tmp_position_delta>=BIT_POS_INPUT_SIZE) {
1524  tmp_position = tmp_position_delta-BIT_POS_INPUT_SIZE;
1525  if(tmp_subMatrix==1) {
1526  if(tmp_slbType==TgcRawData::SLB_TYPE_DOUBLET_STRIP) {
1527  tmp_position = BIT_POS_INPUT_SIZE-1;
1528  ATH_MSG_DEBUG("Expected TGC2 Strip position (" << tmp_position_delta <<
1529  ") does not exist and is changed to the edge position " << tmp_position);
1530  } else if((tmp_slbType==TgcRawData::SLB_TYPE_DOUBLET_WIRE) && (tmp_sswId==7) && ((tmp_slbId==3) || (tmp_slbId==11))) {
1531  // upper edge SLB of FWD:sbLoc3,11
1532  ATH_MSG_DEBUG("sbLoc " << tmp_slbId+1 << " doesn't exist for FWD!! (upper edge SLB of FWD:sbLoc3,11)");
1533  return false;
1534  } else if((tmp_slbType==TgcRawData::SLB_TYPE_DOUBLET_WIRE) && (tmp_sswId!=7) && (tmp_slbId==9)) {
1535  // upper edge SLB of EWD:sbLoc9
1536  ATH_MSG_DEBUG("sbLoc " << tmp_slbId+1 << " doesn't exist for EWD!! (upper edge SLB of EWD:sbLoc9)");
1537  return false;
1538  } else {
1539  // Valid sbLoc,delta,blockpos
1540  tmp_subMatrix = 0;
1541  tmp_slbId++;
1542  }
1543  } else {
1544  tmp_subMatrix = 1;
1545  }
1546  } else if(tmp_position_delta<0) {
1547  tmp_position = tmp_position_delta+BIT_POS_INPUT_SIZE;
1548  if(tmp_subMatrix==0) {
1549  if(tmp_slbType==TgcRawData::SLB_TYPE_DOUBLET_STRIP) {
1550  tmp_position = 0;
1551  ATH_MSG_DEBUG("Expected TGC2 Strip position (" << tmp_position_delta <<
1552  ") does not exist and is changed to the edge position " << tmp_position);
1553  } else if((tmp_slbType==TgcRawData::SLB_TYPE_DOUBLET_WIRE) && (tmp_sswId==7) && ((tmp_slbId==0) || (tmp_slbId==8))) {
1554  // bottom edge SLB of FWD:sbLoc0,8
1555  if(tmp_position_delta==-1) { // This case is valid.
1556  tmp_position = 0;
1557  } else {
1558  ATH_MSG_DEBUG("sbLoc " << tmp_slbId-1 << " doesn't exist for FWD!! (bottom edge SLB of FWD:sbLoc0,8)");
1559  return false;
1560  }
1561  } else if((tmp_slbType==TgcRawData::SLB_TYPE_DOUBLET_WIRE) &&(tmp_sswId!=7) && (tmp_slbId==0)) {
1562  // bottom edge SLB of EWD:sbLoc0
1563  if(tmp_position_delta==-1) { // This case is valid.
1564  tmp_position = 0;
1565  } else {
1566  ATH_MSG_DEBUG("sbLoc " << tmp_slbId-1 << " doesn't exist for EWD!! (bottom edge SLB of EWD:sbLoc0)");
1567  return false;
1568  }
1569  } else {
1570  // Valid sbLoc,delta,
1571  tmp_subMatrix = 1;
1572  tmp_slbId--;
1573  }
1574  } else {
1575  tmp_subMatrix = 0;
1576  }
1577  } else {
1578  tmp_position = tmp_position_delta;
1579  }
1580 
1581  return true;
1582 }
1583 
1585 {
1586  int RoiRow = static_cast<int>(rd.roi()/4);
1587  return RoiRow;
1588 }
1589 
1591 {
1592  int RoiRow = getRoiRow(rd);
1593 
1594  if(!rd.isForward() &&
1595  (RoiRow== 3 || RoiRow== 4 || // SSC 2 : ROI 12-19
1596  RoiRow== 7 || RoiRow== 8 || // SSC 4 : ROI 28-35
1597  RoiRow==11 || RoiRow==12 || // SSC 6 : ROI 44-51
1598  RoiRow==23 || RoiRow==24 // SSC12 : ROI 92-99
1599  )) {
1600  return true;
1601  }
1602  return false;
1603 }
1604 
1606  std::array<int, 2>& bitpos_o) {
1607  // This method is used by decodeHiPt
1608  if((rd.hitId()%2)==1) { // 1,3,5
1609  slbsubMatrix = 0;
1610  if((rd.hsub())==0) {
1611  bitpos_o[0] = BIT_POS_B_INPUT_LARGE_R_CH15; // 78
1612  bitpos_o[1] = BIT_POS_A_INPUT_LARGE_R_CH08; // 49
1613  } else if((rd.hsub())==1) {
1614  bitpos_o[0] = BIT_POS_B_INPUT_LARGE_R_CH07; // 86
1615  bitpos_o[1] = BIT_POS_A_INPUT_LARGE_R_CH00; // 57
1616  }
1617  } else { // 2,4,6
1618  slbsubMatrix = 1;
1619  if((rd.hsub())==0) {
1620  bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH15; // 94
1621  bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH08; // 65
1622  } else if((rd.hsub())==1) {
1623  bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH07; // 102
1624  bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH00; // 73
1625  }
1626  }
1627 
1628  // In case of WIRE, there are no bit assign.(EWD0 EWD4 FWD0 FWD1)-----------------------------
1629  // EWD0 sbLoc = 0 bitpos = 102 : does not exist and has 6 channels only (the largest R, RoiRow== 0).
1630  // EWD4 sbLoc = 9 bitpos = 73 : does not exist and has 4 channels only (the smallest R, RoiRow==36).
1631  // FWD0 sbLoc = 0, 8 bitpos = 78 : does not exist and has 5 channels only (the largest R, RoiRow== 0).
1632  // FWD1 sbLoc = 3, 11 bitpos = 73 : does not exist and has 5 channels only (the smallest R, RoiTow==15).
1633  // fixed it by following description.
1634  if(!rd.isForward()) { // Endcap
1635  if((rd.chip()==0) && (rd.hitId()==1) && (rd.hsub()==1)) {
1636  // chip 0 should have these values and means EWD0's position.
1637  slbsubMatrix = 1;
1638  bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH05; // 104
1639  bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH00; // 73
1640  } else if((rd.chip()==3) && (rd.hitId()==6) && (rd.hsub()==1)) { // EWD4's position
1641  bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH07; // 102
1642  bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH04; // 69
1643  }
1644  } else { // Forward
1645  if((rd.chip()==0) && (rd.hitId()==1) && (rd.hsub()==0)) { // FWD0
1646  bitpos_o[0] = BIT_POS_B_INPUT_LARGE_R_CH12; // 81
1647  bitpos_o[1] = BIT_POS_A_INPUT_LARGE_R_CH08; // 49
1648  } else if((rd.chip()==1) && (rd.hitId()==2) && (rd.hsub()==1)) { //FWD1
1649  bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH07; // 102
1650  bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH03; // 70
1651  }
1652  }// end of Forward
1653  // end of fixed----------------------------------------------------------------------------------
1654 }
1655 
1657  const int deltaBeforeConvert,
1658  std::array<int,4>& bitpos_i,
1659  std::array<int,4>& slbchannel_i,
1660  std::array<int,4>& slbId_in,
1661  std::array<int,4>& sbLoc_in,
1662  int& sswId_i,
1663  const std::array<int, 2>& bitpos_o,
1664  std::array<int, 2>& slbchannel_o, const int slbId_o) const {
1665  // This method is used by decodeHiPt
1666  const int NUM_SLBID_SBLOC_OFFSET_WT = 8; // (see https://twiki.cern.ch/twiki/pub/Main/TgcDocument/sbloc-070701.xls)
1667 
1668  /*** get bitpos for TGC1 Station ***/
1669 
1670  int rdochIn_max = 0;
1671  int rdochIn_min = 0;
1672  int offset_dt = 0;
1673  if(!rd.isForward()) { // EWT
1674  rdochIn_max = 665;
1675  rdochIn_min = 78;
1676  offset_dt = 32;
1677  } else { // FWT
1678  rdochIn_max = 312;
1679  rdochIn_min = 0;
1680  offset_dt = 0;
1681  }
1682 
1683  int tmp_rdochannel_i = 0;
1684  int tmp_rdochannel_i2 = 0;
1685  for(int i=0; i<2; i++) {
1686  slbchannel_o[i] = getchannel(bitpos_o[i], TgcRawData::SLB_TYPE_DOUBLET_WIRE);
1687  tmp_rdochannel_i = WD_MAP_SIZE*slbId_o + slbchannel_o[i] + deltaBeforeConvert + offset_dt;
1688  if(tmp_rdochannel_i>rdochIn_max) {
1689  tmp_rdochannel_i = rdochIn_max;
1690  } else if(tmp_rdochannel_i<rdochIn_min) {
1691  tmp_rdochannel_i = rdochIn_min;
1692  }
1693 
1694  // Large R <-----------------> Small R
1695  // tmp_rdochannel_i : 0 1 2 3 4 5 6 7 8 9 10 ...
1696  //-------------------------------------------------------------------
1697  // tmp_rdochannel_i/3 : 0 0 0 1 1 1 2 2 2 3 3 ...
1698  // (tmp_rdochannel_i/3)*3 : 0 0 0 3 3 3 6 6 6 9 9 ...
1699  // tmp_rdochannel_i2 (i==0) : 2 2 2 5 5 5 8 8 8 11 11 ...
1700  //-------------------------------------------------------------------
1701  // tmp_rdochannel_i+1 : 1 2 3 4 5 6 7 8 9 10 11 ...
1702  // (tmp_rdochannel_i+1)/3 : 0 0 1 1 1 2 2 2 3 3 3 ...
1703  // ((tmp_rdochannel_i+1)/3)*3 : 0 0 3 3 3 6 6 6 9 9 9 ...
1704  // tmp_rdochannel_i2 (i==1) : -1 -1 2 2 2 5 5 5 8 8 8 ...
1705 
1706  if(i==0) { // get the lower R channel on L3 nearest from bitpos_o[0]
1707  tmp_rdochannel_i2 = (tmp_rdochannel_i/3)*3 + 2;
1708  } else { // get the higher R channel on L3 nearest from bitpos_o[1]
1709  tmp_rdochannel_i2 = ((tmp_rdochannel_i + 1)/3)*3 - 1;
1710  }
1711 
1712  if(tmp_rdochannel_i2>rdochIn_max) {
1713  tmp_rdochannel_i2 = rdochIn_max;
1714  } else if(tmp_rdochannel_i2<rdochIn_min) {
1715  tmp_rdochannel_i2 = rdochIn_min + 2; // 2 is added for L3
1716  }
1717 
1718  slbId_in[i] = tmp_rdochannel_i /WT_MAP_SIZE;
1719  slbId_in[i+2] = tmp_rdochannel_i2/WT_MAP_SIZE;
1720 
1721  sbLoc_in[i] = slbId_in[i];
1722  sbLoc_in[i+2] = slbId_in[i+2];
1723  if(rd.sector()%2==1) {
1724  // phi1 and phi3 have offset (see https://twiki.cern.ch/twiki/pub/Main/TgcDocument/sbloc-070701.xls)
1725  // Endcap sector=1, 3 are phi1 and phi3, and Forward sector=1 is phi2.
1726  sbLoc_in[i] += NUM_SLBID_SBLOC_OFFSET_WT;
1727  sbLoc_in[i+2] += NUM_SLBID_SBLOC_OFFSET_WT;
1728  }
1729 
1730  slbchannel_i[i] = tmp_rdochannel_i %WT_MAP_SIZE;
1731  slbchannel_i[i+2] = tmp_rdochannel_i2%WT_MAP_SIZE;
1732 
1733  bitpos_i[i] = getbitpos(slbchannel_i[i], TgcRawData::SLB_TYPE_TRIPLET_WIRE);
1734  bitpos_i[i+2] = getbitpos(slbchannel_i[i+2], TgcRawData::SLB_TYPE_TRIPLET_WIRE);
1735  }
1736 
1737  if(!rd.isForward()) { // EWT
1738  sswId_i = static_cast<int>(rd.sector()/2);
1739  } else { // FWT
1740  sswId_i = 2;
1741  }
1742 }
1743 
1745  int& slbsubMatrix,
1746  std::array<int,2 >& bitpos_o) {
1747  // This method is used by decodeHiPt
1748  if((rd.hitId()%2)==1) { // 1,3,5::hitId:1-6 for EC, 2-3 for Fw
1749  slbsubMatrix = 0;
1750  if((rd.hsub())==0) {
1751  bitpos_o[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH15; // 78
1752  bitpos_o[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH08; // 49
1753  } else if((rd.hsub())==1) {
1754  bitpos_o[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH07; // 86
1755  bitpos_o[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH00; // 57
1756  }
1757  } else { // 2,4,6
1758  slbsubMatrix = 1;
1759  if((rd.hsub())==0) {
1760  bitpos_o[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH15; // 94
1761  bitpos_o[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH08; // 65
1762  } else if((rd.hsub())==1) {
1763  bitpos_o[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH07; // 102
1764  bitpos_o[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH00; // 73
1765  }
1766  }
1767 }
1768 
1770  const int deltaBeforeConvert,
1771  std::array<int, 4>& bitpos_i,
1772  std::array<int, 4>& slbchannel_i,
1773  int& sbLoc_i,
1774  int& sswId_i,
1775  const std::array<int,2>& bitpos_o,
1776  std::array<int,2>& slbchannel_o) const {
1777  // This method is used by decodeHiPt
1778  //*** get bitpos for TGC1 Station ***//
1779  // ST
1780  int rdochIn_max = ST_MAP_SIZE-1;
1781  int rdochIn_min = 0;
1782 
1783  if((rd.sector()%2)==0) {
1784  if(rd.chip()==0) {
1785  sbLoc_i = 16; // EST0 (phi0 and phi2) or FST0 (phi0)
1786  } else if(rd.chip()==1) {
1787  sbLoc_i = 17; // EST1 (phi0 and phi2)
1788  }
1789  } else {
1790  if(rd.chip()==0) {
1791  sbLoc_i = 24; // EST0 (phi1 and phi3) or FST0 (phi2)
1792  } else if(rd.chip()==1) {
1793  sbLoc_i = 25; // EST1 (phi1 and phi3)
1794  }
1795  }
1796 
1797  for(int i=0; i<2; i++) {
1798  slbchannel_o[i] = getchannel(bitpos_o[i], TgcRawData::SLB_TYPE_DOUBLET_STRIP);
1799  slbchannel_i[i] = slbchannel_o[i] + deltaBeforeConvert;
1800  if(slbchannel_i[i]>rdochIn_max) {
1801  slbchannel_i[i] = rdochIn_max;
1802  } else if(slbchannel_i[i]<rdochIn_min) {
1803  slbchannel_i[i] = rdochIn_min;
1804  }
1805 
1806  if(i==0) {
1807  slbchannel_i[i+2] = slbchannel_i[i] + 1;
1808  } else {
1809  slbchannel_i[i+2] = slbchannel_i[i] - 1;
1810  }
1811 
1812  if(slbchannel_i[i+2] > rdochIn_max) {
1813  slbchannel_i[i+2] = rdochIn_max;
1814  } else if(slbchannel_i[i+2] < rdochIn_min) {
1815  slbchannel_i[i+2] = rdochIn_min;
1816  }
1817 
1818  bitpos_i[i] = getbitpos(slbchannel_i[i], TgcRawData::SLB_TYPE_TRIPLET_STRIP);
1819  bitpos_i[i+2] = getbitpos(slbchannel_i[i+2], TgcRawData::SLB_TYPE_TRIPLET_STRIP);
1820  }
1821 
1822  if(!rd.isForward()) { // EST
1823  sswId_i = static_cast<int>(rd.sector()/2);
1824  } else { // FST
1825  sswId_i = 2;
1826  }
1827 }
1828 
1830  const int hitId_w,
1831  const int sub_w,
1832  int& subMatrix_w,
1833  std::array<int, 3>& bitpos_w) const
1834 {
1835  // This method is used by getSLIds
1836  // This method assumes sub_w is 0 or 1.
1837  // Protection for other possibility is needed.
1838 
1839  // 0 : Index for the largest R channel
1840  // 1 : Index for the smallest R channel
1841  // 2 : Index for the "center" channel
1842 
1843  int RoiRow = getRoiRow(rd);
1844  bool isForward = rd.isForward();
1845 
1846  if(RoiRow==0 && !isForward) { // EWD0,SLB0 exception (It has 6 channels only, the largest R)
1847  subMatrix_w = 1;
1848  bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH05; // 104
1849  bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04; // 69
1850  bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH00; // 73
1851  } else if(RoiRow==36 && !isForward) { // EWD4,SLB1 exception (It has 4 channels only, the smallest R)
1852  subMatrix_w = 1;
1853  bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH07; // 102
1854  bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04; // 69
1855  bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH04; // 69
1856  } else if(RoiRow==0 && isForward) { // FWD0,SLB0 exception (It has 5 channels only, the largest R)
1857  subMatrix_w = 0;
1858  bitpos_w[0] = BIT_POS_B_INPUT_LARGE_R_CH12; // 81
1859  bitpos_w[1] = BIT_POS_A_INPUT_LARGE_R_CH12; // 45
1860  bitpos_w[2] = BIT_POS_A_INPUT_LARGE_R_CH08; // 49
1861  } else if(RoiRow==15 && isForward) { // FWD1,SLB1 exception (It has 5 channels only, the smallest R)
1862  subMatrix_w = 1;
1863  bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH07; // 102
1864  bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04; // 69
1865  bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH03; // 70
1866  } else {
1867  if((hitId_w%2)==0) { // 0, 2, 4
1868  subMatrix_w = 0;
1869  if(sub_w==0) {
1870  bitpos_w[0] = BIT_POS_B_INPUT_LARGE_R_CH15; // 78
1871  bitpos_w[1] = BIT_POS_A_INPUT_LARGE_R_CH12; // 45
1872  bitpos_w[2] = BIT_POS_A_INPUT_LARGE_R_CH08; // 49
1873  } else if(sub_w==1) {
1874  bitpos_w[0] = BIT_POS_B_INPUT_LARGE_R_CH07; // 86
1875  bitpos_w[1] = BIT_POS_A_INPUT_LARGE_R_CH04; // 53
1876  bitpos_w[2] = BIT_POS_A_INPUT_LARGE_R_CH00; // 57
1877  }
1878  } else { // 1, 3, 5
1879  subMatrix_w = 1;
1880  if(sub_w==0) {
1881  bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH15; // 94
1882  bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH12; // 61
1883  bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH08; // 65
1884  } else if(sub_w==1) {
1885  bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH07; // 102
1886  bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04; // 69
1887  bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH00; // 73
1888  }
1889  }
1890  }
1891 }
1892 
1894  const int sub_s,
1895  int& subMatrix_s,
1896  std::array<int, 3>& bitpos_s)
1897 {
1898  // This method is used by getSLIds
1899  // 0 : Index for the largest phi (for A-side forward and C-side backward) channel
1900  // 1 : Index for the smallest phi (for A-side forward and C-side backward) channel
1901  // 2 : Index for the "center" channel
1902 
1903  if((hitId_s%2)==0) { // 0, 2, 4
1904  subMatrix_s = 0;
1905  if(sub_s==0) {
1906  bitpos_s[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH15; // 78
1907  bitpos_s[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH12; // 45
1908  bitpos_s[2] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH08; // 49
1909  } else if(sub_s==1) {
1910  bitpos_s[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH07; // 86
1911  bitpos_s[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH04; // 53
1912  bitpos_s[2] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH00; // 57
1913  }
1914  } else if((hitId_s%2)==1) { // 1, 3, 5
1915  subMatrix_s = 1;
1916  if(sub_s==0) {
1917  bitpos_s[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH15; // 94
1918  bitpos_s[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH12; // 61
1919  bitpos_s[2] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH08; // 65
1920  } else if(sub_s==1) {
1921  bitpos_s[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH07; // 102
1922  bitpos_s[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH04; // 69
1923  bitpos_s[2] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH00; // 73
1924  }
1925  }
1926 }
1927 
1929 {
1930  int deltaBeforeConvert = 0;
1931 
1932  if(rd.isStrip()) {// strip
1933  switch(rd.delta()) {
1934  case 5: deltaBeforeConvert = 6; break;
1935  case 6: deltaBeforeConvert = 8; break;
1936  case 7: deltaBeforeConvert = 10; break;
1937  case -4: deltaBeforeConvert = -5; break;
1938  case -5: deltaBeforeConvert = -7; break;
1939  case -6: deltaBeforeConvert = -9; break;
1940  case -7: deltaBeforeConvert = -12; break;
1941  default: deltaBeforeConvert = rd.delta(); break;
1942  }
1943  } else {// wire
1944  switch (rd.delta()) {
1945  case 11: deltaBeforeConvert = 12; break;
1946  case 12: deltaBeforeConvert = 14; break;
1947  case 13: deltaBeforeConvert = 16; break;
1948  case 14: deltaBeforeConvert = 18; break;
1949  case 15: deltaBeforeConvert = 20; break;
1950  case -12: deltaBeforeConvert = -13; break;
1951  case -13: deltaBeforeConvert = -15; break;
1952  case -14: deltaBeforeConvert = -17; break;
1953  case -15: deltaBeforeConvert = -19; break;
1954  default: deltaBeforeConvert = rd.delta(); break;
1955  }
1956  }
1957 
1958  return deltaBeforeConvert;
1959 }
1960 
1962 {
1963  bool isBackward = false;
1964 
1965  if(!rd.isForward()) { // Endcap
1966  if(((rd.subDetectorId()==ASIDE) && (rd.sector()%2==1)) ||
1967  ((rd.subDetectorId()==CSIDE) && (rd.sector()%2==0))) {
1968  // Aside,phi_odd::Backward
1969  // Cside,phi_even::Backward
1970  isBackward = true;
1971  } else {
1972  // Aside,phi_even::Forward
1973  // Cside,phi_odd::Forward
1974  isBackward = false;
1975  }
1976  } else { // Forward
1977  // Aide::Backward
1978  // Cside::Forward
1979  isBackward = (rd.subDetectorId()==ASIDE);
1980  }
1981 
1982  return isBackward;
1983 }
1984 
1985 bool Muon::TgcRdoToPrepDataToolMT::getSLWireGeometry(const std::array<Identifier, 3>& channelId_wire,
1986  double& width_wire, double& r_wire, double& z_wire) const
1987 {
1988  SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{m_muDetMgrKey};
1989  const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.cptr();
1990  std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_w{muDetMgr->getTgcReadoutElement(channelId_wire[0]),
1991  muDetMgr->getTgcReadoutElement(channelId_wire[1]),
1992  muDetMgr->getTgcReadoutElement(channelId_wire[2])};
1993  for(int i=0; i<3; i++) {
1994  if(!isOfflineIdOKForTgcReadoutElement(descriptor_w[i], channelId_wire[i])) {
1995  return false;
1996  }
1997  }
1998 
1999  Amg::Vector3D position_w = descriptor_w[2]->channelPos(channelId_wire[2]);
2000  Amg::Vector2D loc_hitPos_w{Amg::Vector2D::Zero()};
2001  bool onSurface_w = descriptor_w[2]->surface(channelId_wire[2]).globalToLocal(position_w,position_w,loc_hitPos_w);
2002  if(!onSurface_w) {
2003  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::getSLWireGeometry Amg::Vector2D* loc_hitPos_w is null.");
2004  return false;
2005  }
2006  Amg::Vector2D tmp_hitPos_w{Amg::Vector2D::Zero()};
2007 
2008  std::array<int, 3> gasGap_w{}, channel_w{};
2009  for(int i=0; i<3; i++) {
2010  gasGap_w[i] = m_idHelperSvc->tgcIdHelper().gasGap(channelId_wire[i]);
2011  channel_w[i] = m_idHelperSvc->tgcIdHelper().channel(channelId_wire[i]);
2012  }
2013 
2014  std::array<double,3> tmp_r_w{}, tmp_phi_w{}, tmp_eta_w{};
2015 
2016  std::array<Amg::Vector3D,3> tmp_position_w{make_array<Amg::Vector3D, 3>(Amg::Vector3D::Zero())};
2017  for(int i=0; i<3; i+=2) { // i=0 and 2
2018  tmp_position_w[i] = descriptor_w[i]->channelPos(channelId_wire[i]);
2019  tmp_r_w[i] = tmp_position_w[i].perp();
2020  tmp_phi_w[i] = tmp_position_w[i].phi();
2021  tmp_eta_w[i] = tmp_position_w[i].eta();
2022 
2023  double half_width = descriptor_w[i]->gangRadialLength(gasGap_w[i], channel_w[i])/2.;
2024  if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
2025  return false;
2026  }
2027  // add half widths of edge channels
2028  if(i==0) {
2029  tmp_r_w[0] += half_width;
2030  } else if(i==2) {
2031  tmp_r_w[2] -= half_width;
2032  }
2033  }
2034 
2035  bool flag_geteta_w = getEtafromRZ(tmp_r_w[0], tmp_position_w[0].z(), tmp_eta_w[0]);
2036  bool flag_getr_w = getRfromEtaZ(tmp_eta_w[0], tmp_position_w[2].z(), tmp_r_w[0]);
2037  if(!flag_geteta_w || !flag_getr_w) {
2038  ATH_MSG_DEBUG("TgcRdoToPrepDataToolMT::getSLWireGeometry::failed to getR on L7!!");
2039  return false;
2040  }
2041  width_wire = tmp_r_w[0] - tmp_r_w[2];
2042  double gang = descriptor_w[2]->gangShortWidth(gasGap_w[2],channel_w[2]) + width_wire/2.;
2043  tmp_hitPos_w[Trk::locX] = gang;
2044  tmp_hitPos_w[Trk::locY] = ((loc_hitPos_w)[Trk::loc2]);
2045 
2046  Amg::Vector3D tmp_wire_gp;
2047  descriptor_w[2]->surface(channelId_wire[2]).localToGlobal(tmp_hitPos_w,tmp_wire_gp,tmp_wire_gp);
2048  z_wire = tmp_wire_gp.z();
2049  r_wire = tmp_r_w[2] + width_wire/2.;
2050 
2051  return true;
2052 }
2053 
2054 bool Muon::TgcRdoToPrepDataToolMT::getSLStripGeometry(const std::array<Identifier, 3>& channelId_strip,
2055  const bool isBackward, const bool isAside,
2056  double& width_strip, double& theta_strip) const
2057 {
2058  SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{m_muDetMgrKey};
2059  const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.cptr();
2060  std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_s{muDetMgr->getTgcReadoutElement(channelId_strip[0]),
2061  muDetMgr->getTgcReadoutElement(channelId_strip[1]),
2062  muDetMgr->getTgcReadoutElement(channelId_strip[2])};
2063  for(int i=0; i<3; i++) {
2064  if(!isOfflineIdOKForTgcReadoutElement(descriptor_s[i], channelId_strip[i])) {
2065  return false;
2066  }
2067  }
2068 
2069  Amg::Vector3D position_s = Amg::Vector3D(descriptor_s[1]->channelPos(channelId_strip[1]));
2070  Amg::Vector2D loc_hitPos_s;
2071  bool onSurface_s = descriptor_s[1]->surface(channelId_strip[1]).globalToLocal(position_s,position_s,loc_hitPos_s);
2072  if(!onSurface_s) {
2073  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::getSLStripGeometry Amg::Vector2D* loc_hitPos_s is null.");
2074  return false;
2075  }
2076  Amg::Vector2D tmp_hitPos_s{Amg::Vector2D::Zero()};
2077 
2078  std::array<int, 3> gasGap_s, channel_s{};
2079  for(int i=0; i<3; i++) {
2080  gasGap_s[i] = m_idHelperSvc->tgcIdHelper().gasGap(channelId_strip[i]);
2081  channel_s[i] = m_idHelperSvc->tgcIdHelper().channel(channelId_strip[i]);
2082  }
2083 
2084  std::array<Amg::Vector3D, 3> localPos{Amg::Vector3D::Zero()};
2085  for(int i=0; i<3; i+=2) { // i=0 and 2
2086  localPos[i] = descriptor_s[i]->transform(channelId_strip[i]).inverse()
2087  *descriptor_s[i]->channelPos(channelId_strip[i]);
2088  }
2089 
2090  bool flag_reverse = false;
2091  std::array<int, 2> index_strip{};
2092 
2093  if(!isBackward) { // Forward chamber
2094  if(isAside) { // Aside/Forward Chamber
2095  index_strip[0] = 2; index_strip[1] = 0; flag_reverse = true;
2096  } else { // Cside/Forward Chamber
2097  index_strip[0] = 0; index_strip[1] = 2; flag_reverse = false;
2098  }
2099  } else { // Backward chamber
2100  if(isAside) { // Aside/Backward Chamber
2101  index_strip[0] = 0; index_strip[1] = 2; flag_reverse = true;
2102  } else { // Cside/Backward Chamber
2103  index_strip[0] = 2; index_strip[1] = 0; flag_reverse = false;
2104  }
2105  }
2106 
2107  double stripMaxX = descriptor_s[index_strip[0]]->stripHighEdgeLocX(gasGap_s[index_strip[0]], channel_s[index_strip[0]],
2108  localPos[index_strip[0]].z());
2109  double stripMinX = descriptor_s[index_strip[1]]->stripLowEdgeLocX(gasGap_s[index_strip[1]], channel_s[index_strip[1]],
2110  localPos[index_strip[1]].z());
2111  width_strip = stripMaxX - stripMinX;
2112  double strip = stripMinX + width_strip/2.;
2113  if(flag_reverse) strip *= -1.;
2114 
2115  tmp_hitPos_s[Trk::locX] = strip;
2116  tmp_hitPos_s[Trk::locY] = loc_hitPos_s[Trk::loc2];
2117 
2118  int index_strip_gp = 0;
2119  if(!isBackward) index_strip_gp = 0;
2120  else index_strip_gp = 2;
2121  Amg::Vector3D tmp_strip_gp;
2122  descriptor_s[index_strip_gp]->surface(channelId_strip[index_strip_gp]).localToGlobal(tmp_hitPos_s,tmp_strip_gp,tmp_strip_gp);
2123  theta_strip = atan2(tmp_strip_gp.y(), tmp_strip_gp.x());
2124 
2125 
2126  return true;
2127 }
2128 
2129 bool Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireOut(const std::array<const MuonGM::TgcReadoutElement*, 2>& descriptor_o,
2130  const std::array<Identifier, 2>& channelIdOut,
2131  const std::array<int, 2>& gasGap_o,
2132  const std::array<int, 2>& channel_o,
2133  double& width_o,
2134  double& hit_position_o,
2135  Amg::Vector2D& tmp_hitPos_o,
2136  Identifier& channelIdOut_tmp) const
2137 {
2138  // This method is used by decodeHiPt
2139  std::array<Amg::Vector3D, 2> position_o{make_array<Amg::Vector3D, 2>(Amg::Vector3D::Zero())};
2140  std::array<double, 2> tmp_phi_o{}, tmp_eta_o{}, tmp_r_o {};
2141 
2142  for(int i=0; i<2; i++) {
2143  position_o[i] = descriptor_o[i]->channelPos(channelIdOut[i]);
2144  tmp_r_o[i] = position_o[i].perp();
2145  tmp_phi_o[i] = position_o[i].phi();
2146  tmp_eta_o[i] = position_o[i].phi();
2147  // add half widths of edge channels
2148  double half_width = descriptor_o[i]->gangRadialLength(gasGap_o[i], channel_o[i])/2.;
2149  if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
2150  return false;
2151  }
2152  if(i==0) tmp_r_o[0] += half_width;
2153  else tmp_r_o[1] -= half_width;
2154  }
2155 
2156  bool flag_geteta_o = getEtafromRZ(tmp_r_o[0], position_o[0].z(), tmp_eta_o[0]);
2157  bool flag_getr_o = getRfromEtaZ(tmp_eta_o[0], position_o[1].z(), tmp_r_o[0]);
2158  if(!flag_geteta_o || !flag_getr_o) {
2159  ATH_MSG_DEBUG("TgcRdoToPrepDataToolMT::getPosAndIdWireOut::failed to getR on L7!!");
2160  return false;
2161  }
2162 
2163  width_o = tmp_r_o[0] - tmp_r_o[1];
2164  // X-coordinate
2165  hit_position_o = descriptor_o[1]->gangShortWidth(gasGap_o[1], channel_o[1]) + width_o/2;
2166  tmp_hitPos_o[Trk::locX] = (hit_position_o);
2167  // Y-coordinate
2168  Amg::Vector3D position_out = Amg::Vector3D(descriptor_o[1]->channelPos(channelIdOut[1]));
2169  // dummy global pos
2170  Amg::Vector2D loc_hitPos_o;
2171  bool onSurface_o = descriptor_o[1]->surface(channelIdOut[1]).globalToLocal(position_out,position_out,loc_hitPos_o);
2172  if(!onSurface_o) {
2173  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireOut Amg::Vector2D* loc_hitPos_o is null.");
2174  return false;
2175  }
2176  tmp_hitPos_o[Trk::locY] = loc_hitPos_o[Trk::loc2];
2177 
2178  channelIdOut_tmp = channelIdOut[1];
2179 
2180  return true;
2181 }
2182 
2183 bool Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripOut(const std::array<const MuonGM::TgcReadoutElement*, 2>& descriptor_o,
2184  const std::array<Identifier, 2>& channelIdOut,
2185  const std::array<int, 2>& gasGap_o,
2186  const std::array<int, 2>& channel_o,
2187  double& width_o,
2188  double& hit_position_o,
2189  Amg::Vector2D& tmp_hitPos_o,
2190  Identifier& channelIdOut_tmp,
2191  const bool isBackward, const bool isAside) const
2192 {
2193  // This method is used by decodeHiPt
2194  // Currently, this method always returns true.
2195  std::array<Amg::Vector3D, 2> localpos_o{make_array<Amg::Vector3D, 2>(Amg::Vector3D::Zero())};
2196  for(int i=0; i<2; i++) {
2197  localpos_o[i] = descriptor_o[i]->transform(channelIdOut[i]).inverse()*descriptor_o[i]->channelPos(channelIdOut[i]);
2198  }
2199 
2200  std::array<int, 3> index{};
2201  bool flag_reverse = false;
2202  if(!isBackward) { // Forward chamber
2203  index[2] = 0;
2204  if(isAside) { // Aside/Forward Chamber
2205  index[0] = 1; index[1] = 0; flag_reverse = true;
2206  } else { // Cside/Forward Chamber
2207  index[0] = 0; index[1] = 1; flag_reverse = false;
2208  }
2209  } else { // Backward chamber
2210  index[2] = 1;
2211  if(isAside) { // Aside/Backward Chamber
2212  index[0] = 0; index[1] = 1; flag_reverse = true;
2213  } else { // Cside/Backward Chamber
2214  index[0] = 1; index[1] = 0; flag_reverse = false;
2215  }
2216  }
2217 
2218  double stripMax = descriptor_o[index[0]]->stripHighEdgeLocX(gasGap_o[index[0]], channel_o[index[0]],
2219  localpos_o[index[0]].z());
2220  double stripMin = descriptor_o[index[1]]->stripLowEdgeLocX(gasGap_o[index[1]], channel_o[index[1]],
2221  localpos_o[index[1]].z());
2222  width_o = stripMax - stripMin;
2223  // X-coordinate
2224  hit_position_o = stripMin + width_o/2.;
2225  if(flag_reverse) hit_position_o *= -1.;
2226  tmp_hitPos_o[Trk::locX] = hit_position_o;
2227  // Y-coordinate
2228  Amg::Vector3D position_out = Amg::Vector3D(descriptor_o[1]->channelPos(channelIdOut[1]));
2229  // dummy global pos
2230  Amg::Vector2D loc_hitPos_o{Amg::Vector2D::Zero()};
2231  bool onSurface_o = descriptor_o[1]->surface(channelIdOut[1]).globalToLocal(position_out,position_out,loc_hitPos_o);
2232  if(!onSurface_o) {
2233  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripOut Amg::Vector2D* loc_hitPos_o is null.");
2234  return false;
2235  }
2236  tmp_hitPos_o[Trk::locY] = loc_hitPos_o[Trk::loc2];
2237 
2238  channelIdOut_tmp = channelIdOut[index[2]];
2239 
2240  return true;
2241 }
2242 
2243 bool Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireIn(const std::array<const MuonGM::TgcReadoutElement*, 4>& descriptor_i,
2244  const std::array<Identifier, 4>& channelIdIn,
2245  const std::array<int, 4>& gasGap_i,
2246  const std::array<int, 4>& channel_i,
2247  double& width_i, double& hit_position_i,
2248  Amg::Vector2D& tmp_hitPos_i,
2249  Identifier& channelIdIn_tmp) const
2250 {
2251  // This method is used by decodeHiPt
2252  int flag_boundary_i = 0;
2253  if(descriptor_i[1]->chamberType()==descriptor_i[3]->chamberType()) {
2254  // in case lower edge is not chamber boundary
2255  if(gasGap_i[1]==gasGap_i[3]) { // in case that edge channel is on L3; use [1]
2256  flag_boundary_i = 1;
2257  } else { // in case that edge channel is not on L3; use [3]
2258  flag_boundary_i = 3;
2259  }
2260  } else if(descriptor_i[0]->chamberType()==descriptor_i[2]->chamberType()) {
2261  // in case higher edge is not chamber boundary
2262  if(gasGap_i[0]==gasGap_i[2]) { // in case that edge channel is on L3; use [0]
2263  flag_boundary_i = 0;
2264  } else { // in case that edge channel is not on L3; use [2]
2265  flag_boundary_i = 2;
2266  }
2267  } else {
2268  ATH_MSG_DEBUG("TgcRdoToPrepDataToolMT::getPosAndIdWireIn::ROI has 3 readout elements!!");
2269  return false;
2270  }
2271 
2272  channelIdIn_tmp = channelIdIn[flag_boundary_i];
2273  SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{m_muDetMgrKey};
2274  const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.cptr();
2275  const MuonGM::TgcReadoutElement* descriptor_iw = muDetMgr->getTgcReadoutElement(channelIdIn_tmp);
2276  if(!isOfflineIdOKForTgcReadoutElement(descriptor_iw, channelIdIn_tmp)) {
2277  return false;
2278  }
2279 
2280  std::array<double, 3> tmp_r_i{}, tmp_phi_i{}, tmp_eta_i{};
2281 
2282  std::array<Amg::Vector3D, 3> position_i {descriptor_i[0]->channelPos(channelIdIn[0]),
2283  descriptor_i[1]->channelPos(channelIdIn[1]),
2284  descriptor_iw->channelPos(channelIdIn_tmp)};
2285 
2286  for(int i=0; i<3; i++) {
2287  tmp_r_i[i] =position_i[i].perp();
2288  tmp_phi_i[i] = position_i[i].phi();
2289  tmp_eta_i[i] = position_i[i].eta();
2290 
2291  if(i<2) {
2292  // add half widths of edge channels
2293  double half_width = descriptor_i[i]->gangRadialLength(gasGap_i[i], channel_i[i])/2.;
2294  if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
2295  return false;
2296  }
2297  if(i==0) tmp_r_i[0] += half_width;
2298  else tmp_r_i[1] -= half_width;
2299 
2300  bool flag_geteta_i = getEtafromRZ(tmp_r_i[i], position_i[i].z(), tmp_eta_i[i]);
2301  bool flag_getr_i = getRfromEtaZ(tmp_eta_i[i], position_i[2].z(), tmp_r_i[i]);
2302 
2303  if(!flag_geteta_i || !flag_getr_i) {
2304  ATH_MSG_DEBUG("TgcRdoToPrepDataToolMT::getPosAndIdWireIn::failed to getRIn" << i << " on L3!!");
2305  return false;
2306  }
2307  }
2308  }
2309 
2310  width_i = tmp_r_i[0] - tmp_r_i[1];
2311  if(width_i<0.) {
2312  ATH_MSG_DEBUG("TgcRdoToPrepDataToolMT::getPosAndIdWireIn::minus value width_i = " << width_i);
2313  return false;
2314  }
2315 
2316  int gasGap_tmp = m_idHelperSvc->tgcIdHelper().gasGap(channelIdIn_tmp);
2317  int channel_tmp = m_idHelperSvc->tgcIdHelper().channel(channelIdIn_tmp);
2318  double half_width = descriptor_iw->gangRadialLength(gasGap_tmp, channel_tmp)/2.;
2319  if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) { // Invalid PRD's whose widths are zero are dropped.
2320  return false;
2321  }
2322  if((flag_boundary_i%2)==1) { // in case lower edge is not chamber boundary
2323  tmp_r_i[2] -= half_width;
2324  hit_position_i = descriptor_iw->gangShortWidth(gasGap_tmp, channel_tmp)
2325  - (tmp_r_i[2] - tmp_r_i[1]) + width_i/2.;
2326  } else { // in case higher edge is not chamber boundary
2327  tmp_r_i[2] += half_width;
2328  hit_position_i = descriptor_iw->gangLongWidth(gasGap_tmp, channel_tmp)
2329  + (tmp_r_i[0] - tmp_r_i[2]) - width_i/2.;
2330  }
2331 
2332  // X-coordinate
2333  tmp_hitPos_i[Trk::locX] = hit_position_i;
2334  Amg::Vector3D position_in = descriptor_i[1]->channelPos(channelIdIn[1]);
2335  // dummy global pos
2336  Amg::Vector2D loc_hitPos_i{Amg::Vector2D::Zero()};
2337  bool onSurface_i = descriptor_i[1]->surface(channelIdIn[1]).globalToLocal(position_in,position_in,loc_hitPos_i);
2338  if(!onSurface_i) {
2339  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireIn Amg::Vector2D* loc_hitPos_i is null.");
2340  return false;
2341  }
2342  // Y-coordinate
2343  tmp_hitPos_i[Trk::locY] = loc_hitPos_i[Trk::loc2];
2344 
2345  return true;
2346 }
2347 
2348 bool Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripIn(const std::array<const MuonGM::TgcReadoutElement*, 4>& descriptor_i,
2349  const std::array<Identifier, 4>& channelIdIn,
2350  const std::array<int, 4>& gasGap_i,
2351  const std::array<int, 4>& channel_i,
2352  double& width_i,
2353  double& hit_position_i,
2354  Amg::Vector2D& tmp_hitPos_i,
2355  Identifier& channelIdIn_tmp,
2356  const bool isBackward, const bool isAside) const
2357 {
2358  // This method is used by decodeHiPt
2359  int flag_isL3 = -1;
2360  // which bitpos is Layer3?
2361  for(int i=0; i<4; i++) {
2362  if(gasGap_i[i]==3) {
2363  flag_isL3 = i;
2364  break;
2365  }
2366  }
2367  if(flag_isL3<0 || flag_isL3>=4) {
2368  ATH_MSG_DEBUG("getPosAndIdStripIn: Any bitpos is not at Layer3!");
2369  return false;
2370  }
2371 
2372  channelIdIn_tmp = channelIdIn[flag_isL3];
2373  SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{m_muDetMgrKey};
2374  const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.cptr();
2375  const MuonGM::TgcReadoutElement* descriptor_is = muDetMgr->getTgcReadoutElement(channelIdIn_tmp);
2376  if(!isOfflineIdOKForTgcReadoutElement(descriptor_is, channelIdIn_tmp)) {
2377  return true;
2378  }
2379 
2380  std::array<double, 3> tmp_r_i{}, tmp_phi_i{}, tmp_eta_i{};
2381  std::array<Amg::Vector3D, 3> position_is{make_array<Amg::Vector3D, 3>(Amg::Vector3D::Zero())};
2382  for(int i=0; i<3; i++) {
2383  if(i<2) {
2384  position_is[i] = descriptor_i[i]->channelPos(channelIdIn[i]);
2385  } else {
2386  position_is[i] = descriptor_is->channelPos(channelIdIn_tmp);
2387  }
2388  tmp_r_i[i] = position_is[i].perp();
2389  tmp_phi_i[i] = position_is[i].phi();
2390  tmp_eta_i[i] = position_is[i].eta();
2391  }
2392 
2393  std::array<int, 2> index{};
2394  bool flag_reverse = false;
2395  if(!isBackward) { // Forward chamber
2396  if(isAside) { // Aside/Forward Chamber
2397  index[0] = 1; index[1] = 0; flag_reverse = true;
2398  } else { // Cside/Forward Chamber
2399  index[0] = 0; index[1] = 1; flag_reverse = false;
2400  }
2401  } else { // Backward chamber
2402  if(isAside) { // Aside/Backward Chamber
2403  index[0] = 0; index[1] = 1; flag_reverse = true;
2404  } else { // Cside/Backward Chamber
2405  index[0] = 1; index[1] = 0; flag_reverse = false;
2406  }
2407  }
2408 
2409  std::array<Amg::Vector3D,2 > localpos_i{make_array<Amg::Vector3D, 2>(Amg::Vector3D::Zero())};
2410  for(int i=0; i<2; i++) {
2411  localpos_i[i] = descriptor_i[i]->transform(channelIdIn[i]).inverse()*descriptor_i[i]->channelPos(channelIdIn[i]);
2412  }
2413  double stripMaxX = descriptor_i[index[0]]->stripHighEdgeLocX(gasGap_i[index[0]], channel_i[index[0]],
2414  localpos_i[index[0]].z());
2415  double stripMinX = descriptor_i[index[1]]->stripLowEdgeLocX(gasGap_i[index[1]], channel_i[index[1]],
2416  localpos_i[index[1]].z());
2417  width_i = stripMaxX - stripMinX;
2418  // X-coordinate
2419  hit_position_i = stripMinX + width_i/2.;
2420  if(flag_reverse) hit_position_i *= -1.;
2421  tmp_hitPos_i[Trk::locX] = hit_position_i;
2422  // Y-coordinate
2423  Amg::Vector3D position_in = Amg::Vector3D(descriptor_i[1]->channelPos(channelIdIn[1]));
2424  // dummy global pos
2425  Amg::Vector2D loc_hitPos_i;
2426  bool onSurface_i = descriptor_i[1]->surface(channelIdIn[1]).globalToLocal(position_in,position_in,loc_hitPos_i);
2427  if(!onSurface_i) {
2428  ATH_MSG_WARNING("Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripIn Amg::Vector2D* loc_hitPos_i is null.");
2429  return false;
2430  }
2431  tmp_hitPos_i[Trk::locY] = loc_hitPos_i[Trk::loc2];
2432 
2433  return true;
2434 }
2435 
2436 // RDOHighPtID --> (Sim)HighPtID --> OfflineID --> ReadoutID --> getSLBID
2437 bool Muon::TgcRdoToPrepDataToolMT::getHiPtIds(const TgcRawData& rd, int& sswId_o, int& sbLoc_o, int& slbId_o) const
2438 {
2439  const CablingInfo* cinfo = getCabling();
2440  if (!cinfo) {
2441  return false;
2442  }
2443 
2444  int index = static_cast<int>(rd.index());
2445  int chip = static_cast<int>(rd.chip());
2446  int hitId = static_cast<int>(rd.hitId());
2447 
2448  // getSimHighPtIDfromRDOHighPtID changes index, chip and hitId.
2449  bool found = cinfo->m_tgcCabling->getSimHighPtIDfromRDOHighPtID(rd.isForward(), rd.isStrip(), index, chip, hitId);
2450  if(!found) {
2451  ATH_MSG_DEBUG("Failed to get SimHighPtID from RDOHighPtID for Pivot "
2452  << (rd.isStrip() ? "Strip" : "Wire"));
2453  return false;
2454  }
2455 
2456  // conversion for Run3
2457  uint16_t tmprodId, tmpsector;
2458  convertToRun2(rd,tmprodId,tmpsector);
2459 
2460  Identifier dummyId;
2461  if (rd.rodId()>12){ // Run3
2462  found = cinfo->m_tgcCabling->getOfflineIDfromHighPtID(dummyId,
2463  rd.subDetectorId(), tmprodId, tmpsector,
2464  rd.isStrip(), rd.isForward(), index,
2465  chip, hitId, rd.hsub());
2466  }else{
2467  found = cinfo->m_tgcCabling->getOfflineIDfromHighPtID(dummyId,
2468  rd.subDetectorId(), rd.rodId(), rd.sector(),
2469  rd.isStrip(), rd.isForward(), index,
2470  chip, hitId, rd.hsub());
2471  }
2472 
2473  if(!found) {
2474  ATH_MSG_DEBUG("Failed to get offlineID from HighPtID for Pivot "
2475  << (rd.isStrip() ? "Strip" : "Wire"));
2476  return false;
2477  }
2478 
2479  std::array<int, 3> dummy_i{};
2480  found = cinfo->m_tgcCabling->getReadoutIDfromOfflineID(dummyId, dummy_i[0], dummy_i[1], sswId_o, sbLoc_o, dummy_i[2]);
2481  if(!found) {
2482  ATH_MSG_DEBUG("Failed to get ReadoutID from OfflineID for Pivot "
2483  << (rd.isStrip() ? "Strip" : "Wire"));
2484  return false;
2485  }
2486 
2487  std::array<int, 2> i_o{};
2488  std::array<bool, 2> b_o{false, false};
2489  if (rd.rodId()>12){ // Run3
2490  found = cinfo->m_tgcCabling->getSLBIDfromReadoutID(i_o[0], b_o[0], b_o[1], i_o[1], slbId_o,
2491  rd.subDetectorId(), tmprodId, sswId_o, sbLoc_o);
2492  }else{
2493  found = cinfo->m_tgcCabling->getSLBIDfromReadoutID(i_o[0], b_o[0], b_o[1], i_o[1], slbId_o,
2494  rd.subDetectorId(), rd.rodId(), sswId_o, sbLoc_o);
2495  }
2496  if(!found) {
2497  ATH_MSG_DEBUG("Failed to get SLBID from ReadoutID for Pivot "
2498  << (rd.isStrip() ? "Strip" : "Wire"));
2499  return false;
2500  }
2501 
2502  return true;
2503 }
2505  const TgcRawData& rd,
2506  std::array<Identifier, 3>& channelId,
2507  int& index, int& chip, int& hitId, int& sub, int& sswId, int& sbLoc,
2508  int& subMatrix,
2509  std::array<int, 3>& bitpos,
2510  const bool isBoundary, const TgcRdo* rdoColl,
2511  const int index_w, const int chip_w, const int hitId_w, const int sub_w) const
2512 
2513 {
2514  const CablingInfo* cinfo = getCabling();
2515  if (!cinfo) {
2516  return false;
2517  }
2518 
2519  bool found = cinfo->m_tgcCabling->getHighPtIDfromROINumber(rd.roi(),
2520  rd.isForward(),
2521  isStrip, // get HitID of HPT Board
2522  index,
2523  chip,
2524  hitId,
2525  sub);
2526  if(!found) {
2527  ATH_MSG_DEBUG("Failed to get HighPtID from ROINumber for "
2528  << (!isStrip ? "Wire" : "Strip"));
2529  return false;
2530  }
2531 
2532  found = cinfo->m_tgcCabling->getSimHighPtIDfromRDOHighPtID(rd.isForward(),
2533  isStrip,
2534  index,
2535  chip,
2536  hitId);
2537  if(!found) {
2538  ATH_MSG_DEBUG("Failed to get SimHighPtID from RDOHighPtID for "
2539  << (!isStrip ? "Wire" : "Strip"));
2540  return false;
2541  }
2542 
2543  Identifier offlineId;
2544  found = cinfo->m_tgcCabling->getOfflineIDfromHighPtID(offlineId,
2545  rd.subDetectorId(),
2546  rd.rodId(),
2547  rd.sector(),
2548  isStrip,
2549  rd.isForward(),
2550  index,
2551  chip,
2552  hitId,
2553  sub);
2554  if(!found) {
2555  ATH_MSG_DEBUG("Failed to get OfflineID from HighPtID for "
2556  << (!isStrip ? "Wire" : "Strip"));
2557  return false;
2558  }
2559 
2560  if(!isStrip || !isBoundary) { // Wire or strip whose ROI not including chamber boundary
2561  channelId[1] = offlineId;
2562  std::array<int, 3> dummy_i{};
2563  found = cinfo->m_tgcCabling->getReadoutIDfromOfflineID(channelId[1],
2564  dummy_i[0],
2565  dummy_i[1],
2566  sswId,
2567  sbLoc,
2568  dummy_i[2]);
2569  if(!found) {
2570  ATH_MSG_DEBUG("Failed to get ReadoutID from OfflineID for "
2571  << (!isStrip ? "Wire" : "Strip"));
2572  return false;
2573  }
2574  } else { // --> solving the chamber boundary of strip
2575  sswId = rd.sector()+3; // SSW3: M3-EC phi0, SSW4: M3-EC phi1, SSW5: M3-EC phi2, SSW6: M3-EC phi3
2576 
2577  // Loop over all HiPt Strip to find an associated one to obtain sbLoc
2578  bool exist_hipt_s = getSbLocOfEndcapStripBoundaryFromHiPt(rd, sbLoc, rdoColl, index_w, chip_w, hitId_w, sub_w);
2579  if(!exist_hipt_s) {
2580  // Loop over all Tracklet Strip to find an associated one to obtain sbLoc
2581  bool exist_tracklet_s = getSbLocOfEndcapStripBoundaryFromTracklet(rd, sbLoc, rdoColl, index_w, chip_w, hitId_w, sub_w);
2582  if(!exist_tracklet_s) {
2583  ATH_MSG_DEBUG("Failed to find correspond Tracklet_strip for SL!!");
2584  return false;
2585  }
2586  }
2587  }
2588 
2589  if(!isStrip) { // wire
2590  getBitPosWire(rd, hitId, sub, subMatrix, bitpos);
2591  } else { // strip
2592  getBitPosStrip(hitId, sub, subMatrix, bitpos);
2593  }
2594 
2595  for(int i=0; i<3; i++) {
2596  if(i==1 && (!isStrip || !isBoundary)) continue;
2597 
2598  found = cinfo->m_tgcCabling->getOfflineIDfromReadoutID(channelId[i],
2599  rd.subDetectorId(),
2600  rd.rodId(),
2601  sswId,
2602  sbLoc,
2603  bitpos[i]);
2604  if(!found) {
2605  ATH_MSG_DEBUG("Failed to get OfflineID from ReadoutID for "
2606  << (!isStrip ? "Wire" : "Strip"));
2607  if(!isStrip || i==1) {
2608  ATH_MSG_DEBUG("subDetectorId = " << rd.subDetectorId()
2609  << ", rodId = " << rd.rodId()
2610  << ", sswId = " << sswId
2611  << ", slbId = " << sbLoc
2612  << ", bitpos_" << (!isStrip ? "w" : "s")
2613  << "[" << i << "] = " << bitpos[i]);
2614  }
2615  return false;
2616  }
2617  }
2618 
2619  return true;
2620 }
2621 
2622 
2624  const TgcRdo* rdoColl,
2625  const int index_w, const int chip_w, const int hitId_w, const int sub_w) const
2626 {
2627  const CablingInfo* cinfo = getCabling();
2628  if (!cinfo) {
2629  return false;
2630  }
2631 
2632  bool exist_hipt_s = false;
2633 
2634  // Get trackletIds of three candidates
2635  int trackletIdStripFirst{-1}, trackletIdStripSecond{-1}, trackletIdStripThird{-1};
2636  getEndcapStripCandidateTrackletIds(static_cast<int>(rd.roi()), trackletIdStripFirst,
2637  trackletIdStripSecond, trackletIdStripThird);
2638 
2639  // Loop over all HiPt Strip to find an associated one
2640  for (const TgcRawData* rdH0 : *rdoColl) {
2641 
2642  // conversion for Run3
2643  uint16_t tmprodId, tmpsector;
2644  convertToRun2(rdH0,tmprodId,tmpsector);
2645  const TgcRawData rdH(rdH0->bcTag(), rdH0->subDetectorId(), tmprodId,
2646  rdH0->l1Id(), rdH0->bcId(), rdH0->isStrip(),
2647  rdH0->isForward(), tmpsector, rdH0->chip(),
2648  rdH0->index(),rdH0->isHipt(), rdH0->hitId(),
2649  rdH0->hsub(), rdH0->delta(), rdH0->inner());
2650 
2651  if((rdH.type()==TgcRawData::TYPE_HIPT) && // HiPt
2652  (rdH.isHipt()) && // HiPt flag is required
2653  (rdH.isStrip()) && // Strip
2654  (!rdH.isForward()) && // Endcap
2655  (rdH.bcTag()==rd.bcTag()) && // The same timing
2656  (rdH.subDetectorId()==rd.subDetectorId()) && // The same side
2657  (rdH.rodId()==rd.rodId()) && // The same ROD
2658  (rdH.sector()==rd.sector()) // The same sector (1/48 phi)
2659  ) {
2660 
2661  // Get sbLoc
2662  int sswId_o{0}, sbLoc_o{0}, slbId_o{0};
2663  bool found = getHiPtIds(rdH, sswId_o, sbLoc_o, slbId_o);
2664  if(!found){
2665  continue;
2666  }
2667 
2668  // Get subMatrix
2669  int slbsubMatrix = 0;
2670  std::array<int, 2> bitpos_o{};
2671  getBitPosOutStrip(rdH, slbsubMatrix, bitpos_o);
2672 
2673  // Get trackletId
2674  int trackletIdStrip = 2*sbLoc_o + slbsubMatrix;
2675 
2676  // Compare trackletIds
2677  if(trackletIdStrip!=trackletIdStripFirst && trackletIdStrip!=trackletIdStripSecond &&
2678  trackletIdStrip!=trackletIdStripThird) continue;
2679 
2680  // The third candidate is used only if any corresponding HiPt Strip is found so far.
2681  if(exist_hipt_s && trackletIdStrip==trackletIdStripThird) continue;
2682 
2683  // getRDOHighPtIDfromSimHighPtID overwrites index, chip and hitId.
2684  int index_w_tmp = index_w;
2685  int chip_w_tmp = chip_w;
2686  int hitId_w_tmp = hitId_w;
2687  // Get RDO HighPt ID from SimHighPtID for wire
2688  found = cinfo->m_tgcCabling->getRDOHighPtIDfromSimHighPtID(false, // false for endcap
2689  false, // wire
2690  index_w_tmp,
2691  chip_w_tmp,
2692  hitId_w_tmp);
2693  if(!found) {
2694  ATH_MSG_DEBUG("Failed to get RDOHighPtID from SimHighPtID for Wire");
2695  continue;
2696  }
2697 
2698  // RDO High Pt ID of Strip
2699  int chip_s = static_cast<int>(rdH.chip());
2700  int hitId_s = static_cast<int>(rdH.hitId());
2701  int hsub_s = static_cast<int>(rdH.hsub());
2702 
2703  int roi = 0;
2704  found = cinfo->m_tgcCabling->getROINumberfromHighPtID(roi,
2705  false, // false for Endcap
2706  index_w_tmp, // hpb_wire (not used)
2707  chip_w_tmp, // chip_wire
2708  hitId_w_tmp, // hitId_wire
2709  sub_w, // sub_wire
2710  chip_s, // chip_strip (not used)
2711  hitId_s, // hitId_strip
2712  hsub_s); // sub_strip
2713  if(!found) {
2714  ATH_MSG_DEBUG("Failed to get ROINumber from HighPtID for Strip");
2715  continue;
2716  }
2717 
2718  if(roi==rd.roi()) {
2719  sbLoc = sbLoc_o;
2720  exist_hipt_s = true;
2721  if(trackletIdStrip==trackletIdStripFirst) break; // If the first candidate is found, exit from this for loop
2722  }
2723  }
2724  }
2725 
2726  return exist_hipt_s;
2727 }
2728 
2730  const TgcRdo* rdoColl,
2731  const int index_w, const int chip_w,
2732  const int hitId_w, const int sub_w) const
2733 {
2734  const CablingInfo* cinfo = getCabling();
2735 
2736  bool exist_tracklet_s = false;
2737 
2738  // Get trackletIds of three candidates
2739  int trackletIdStripFirst{-1}, trackletIdStripSecond{-1}, trackletIdStripThird{-1};
2740  getEndcapStripCandidateTrackletIds(static_cast<int>(rd.roi()), trackletIdStripFirst,
2741  trackletIdStripSecond, trackletIdStripThird);
2742 
2743  // Loop over all Tracklet Strip to find an associated one
2744  for (const TgcRawData* rdS0 : *rdoColl) {
2745 
2746  // conversion for Run3
2747  uint16_t tmprodId{0}, tmpsector{0};
2748  convertToRun2(rdS0,tmprodId,tmpsector);
2749  const TgcRawData rdS(rdS0->bcTag(), rdS0->subDetectorId(), tmprodId,
2750  rdS0->sswId(), rdS0->slbId(), rdS0->l1Id(),
2751  rdS0->bcId(), rdS0->slbType(), rdS0->delta(),
2752  rdS0->segment(), rdS0->subMatrix(), rdS0->position());
2753 
2754  bool isForward_s = (rdS.sswId()==7); // Doublet, Forward
2755  if(isForward_s) continue; // Chamber boundaries exist in endcap only
2756 
2757  if((rdS.type()==TgcRawData::TYPE_TRACKLET) &&
2759  (rdS.bcTag()==rd.bcTag()) &&
2760  (rdS.subDetectorId()==rd.subDetectorId()) &&
2761  (rdS.rodId()==rd.rodId()) &&
2762  (rdS.sswId()-3==rd.sector()) // SSW3: M3-EC phi0, SSW4: M3-EC phi1, SSW5: M3-EC phi2, SSW6: M3-EC phi3
2763  ) {
2764 
2765  // Compare trackletIds
2766  int trackletIdStrip = static_cast<int>(2*rdS.slbId()+rdS.subMatrix()); // trackletId of Tracklet Strip
2767  if(trackletIdStrip!=trackletIdStripFirst &&
2768  trackletIdStrip!=trackletIdStripSecond &&
2769  trackletIdStrip!=trackletIdStripThird) continue;
2770 
2771  // The third candidate is used only if any corresponding Tracklet Strip is found so far.
2772  if(exist_tracklet_s && trackletIdStrip==trackletIdStripThird) continue;
2773 
2774  Identifier offlineId;
2775  bool found = cinfo->m_tgcCabling->getOfflineIDfromLowPtCoincidenceID(offlineId, rdS.subDetectorId(), rdS.rodId(),
2776  rdS.sswId(), rdS.slbId(), rdS.subMatrix(),
2777  rdS.position(), false);
2778  if(!found) {
2779  ATH_MSG_DEBUG("Failed to get OfflineID from LowPtCoincidenceID for Strip");
2780  continue;
2781  }
2782 
2783  std::array<int, 7> i{};
2784  std::array<bool, 2> b{};
2785  found = cinfo->m_tgcCabling->getHighPtIDfromOfflineID(offlineId,i[0],i[1],i[2],b[0],b[1],i[3],i[4],i[5],i[6]);
2786  // i[0] subDetectorID, i[1] rodID, i[2] sectorInReadout, b[0] isStrip,
2787  // b[1] isForward, i[3] hpb, i[4] chip, i[5] hitID, i[6] pos
2788 
2789  if(!found) {
2790  ATH_MSG_DEBUG("Failed to get HighPtID from OfflineID for Strip");
2791  continue;
2792  }
2793 
2794  // getRDOHighPtIDfromSimHighPtID overwrites index, chip and hitId.
2795  int index_w_tmp = index_w;
2796  int chip_w_tmp = chip_w;
2797  int hitId_w_tmp = hitId_w;
2798  found = cinfo->m_tgcCabling->getRDOHighPtIDfromSimHighPtID(rd.isForward(), // false for endcap
2799  false, // wire
2800  index_w_tmp, // hpb-index
2801  chip_w_tmp, // chip-chip
2802  hitId_w_tmp); // hitID-hitId
2803  if(!found) {
2804  ATH_MSG_DEBUG("Failed to get RDOHighPtID from SimHighPtID for Wire");
2805  continue;
2806  }
2807 
2808  found = cinfo->m_tgcCabling->getRDOHighPtIDfromSimHighPtID(rd.isForward(), // false for endcap
2809  true, // strip
2810  i[3], // hpb-index
2811  i[4], // chip-chip
2812  i[5]); // hitID-hitId
2813  if(!found) {
2814  ATH_MSG_DEBUG("Failed to get RDOHighPtID from SimHighPtID for Strip");
2815  continue;
2816  }
2817 
2818  int roi = 0;
2819  found = cinfo->m_tgcCabling->getROINumberfromHighPtID(roi,
2820  rd.isForward(), // false for endcap
2821  index_w_tmp, // hpb_wire (not used)
2822  chip_w_tmp, // chip_wire
2823  hitId_w_tmp, // hitId_wire
2824  sub_w, // sub_wire
2825  i[4], // chip_strip (not used)
2826  i[5], // hitId_strip
2827  i[6]); // sub_strip
2828  if(!found) {
2829  ATH_MSG_DEBUG("Failed to get ROINumber from HighPtID for Strip");
2830  continue;
2831  }
2832 
2833  if(roi==rd.roi()) {
2834  sbLoc = rdS.slbId();
2835  exist_tracklet_s = true;
2836  if(trackletIdStrip==trackletIdStripFirst) break; // If the first candidate is found, exit from this for loop
2837  }
2838  }
2839  }
2840 
2841  return exist_tracklet_s;
2842 }
2843 
2844 void Muon::TgcRdoToPrepDataToolMT::getEndcapStripCandidateTrackletIds(const int roi, int &trackletIdStripFirst,
2845  int &trackletIdStripSecond,
2846  int &trackletIdStripThird) {
2847  constexpr int T9SscMax = 2; // SSC 0 to SSC 2
2848  constexpr int T8SscMax = 4; // SSC 3 to SSC 4
2849  constexpr int T7SscMax = 6; // SSC 5 to SSC 6
2850  constexpr int T6SscMax = 12; // SSC 7 to SSC12
2851  constexpr int T5SscMax = 18; // SSC13 to SSC18
2852 
2853  constexpr int T9Offset = 32 + 0;
2854  constexpr int T8Offset = 32 + 2;
2855  constexpr int T7Offset = 32 + 4;
2856  constexpr int T6Offset = 32 + 6;
2857  constexpr int T5Offset = 32 + 8;
2858 
2859  // ROI : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...
2860  // SSC : 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 ...
2861  // Half SSC: 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 ...
2862  int ssc = (roi+4)/8;
2863  int halfSsc = (roi%4)/2;
2864 
2865  if( ssc< T9SscMax) { // SSC 0 to SSC 1
2866  trackletIdStripFirst = T9Offset + halfSsc; // T9
2867  trackletIdStripSecond = -1;
2868  trackletIdStripThird = -1;
2869  } else if(ssc==T9SscMax) { // SSC 2 (boundary)
2870  trackletIdStripFirst = T8Offset + halfSsc; // T8
2871  trackletIdStripSecond = T9Offset + halfSsc; // T9
2872  trackletIdStripThird = -1;
2873  } else if(ssc< T8SscMax) { // SSC 3
2874  trackletIdStripFirst = T8Offset + halfSsc; // T8
2875  trackletIdStripSecond = -1;
2876  trackletIdStripThird = -1;
2877  } else if(ssc==T8SscMax) { // SSC 4 (boundary)
2878  trackletIdStripFirst = T7Offset + halfSsc; // T7
2879  trackletIdStripSecond = T8Offset + halfSsc; // T8
2880  trackletIdStripThird = -1;
2881  } else if(ssc< T7SscMax) { // SSC 5
2882  trackletIdStripFirst = T7Offset + halfSsc; // T7
2883  trackletIdStripSecond = -1;
2884  trackletIdStripThird = -1;
2885  } else if(ssc==T7SscMax) { // SSC 6 (boundary)
2886  trackletIdStripFirst = T6Offset + halfSsc; // T6
2887  trackletIdStripSecond = T7Offset + halfSsc; // T7
2888  trackletIdStripThird = T5Offset + halfSsc; // T5, HiPt Endcap Strip board bug
2889  } else if(ssc< T6SscMax) { // SSC 7 to SSC11
2890  trackletIdStripFirst = T6Offset + halfSsc; // T6
2891  trackletIdStripSecond = T5Offset + halfSsc; // T5, HiPt Endcap Strip board bug
2892  trackletIdStripThird = -1;
2893  } else if(ssc==T6SscMax) { // SSC12 (boundary)
2894  trackletIdStripFirst = T6Offset + halfSsc; // T6
2895  trackletIdStripSecond = T5Offset + halfSsc; // T5
2896  trackletIdStripThird = -1;
2897  } else if(ssc<=T5SscMax) { // SSC13 to SSC18
2898  trackletIdStripFirst = T5Offset + halfSsc; // T5
2899  trackletIdStripSecond = T6Offset + halfSsc; // T6, HiPt Endcap Strip board bug
2900  trackletIdStripThird = -1;
2901  } else {
2902  trackletIdStripFirst = -1;
2903  trackletIdStripSecond = -1;
2904  trackletIdStripThird = -1;
2905  }
2906 }
2907 
2910 {
2911  if (m_cablingInfo.isValid()) {
2912  return m_cablingInfo.ptr();
2913  }
2914 
2915  // get TGC Cabling Svc
2916  CablingInfo cinfo;
2917  cinfo.m_tgcCabling = service("MuonTGC_CablingSvc");
2918  if (!cinfo.m_tgcCabling) {
2919  ATH_MSG_ERROR( "Could not get MuonTGC_CablingSvc!" );
2920  return nullptr;
2921  }
2922 
2923  ATH_MSG_DEBUG(cinfo.m_tgcCabling->name() << " is OK");
2924 
2925  // check the relation between hash and onlineId (onlineId depends on cabling)
2926  unsigned int hashId_max = m_idHelperSvc->tgcIdHelper().module_hash_max();
2927  cinfo.m_hashToOnlineId.reserve(hashId_max);
2928  IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context(); // TGC context
2929  Identifier elementId;
2930  int subDetectorId = 0; // 103(=0x67) for A side, 104(=0x68) for C side
2931  int rodId = 0; // 1 to 12 (12-fold cabling)
2932  TgcRdo tgcRdo; // For onlineId conversion
2933  for(unsigned int hashId=0; hashId<hashId_max; hashId++) {
2934  IdentifierHash hash(hashId);
2935  m_idHelperSvc->tgcIdHelper().get_id(hash, elementId, &tgcContext);
2936  cinfo.m_tgcCabling->getReadoutIDfromElementID(elementId, subDetectorId, rodId);
2937  // onlineId: 0 to 11 on A side and 12 to 23 on C side (12-fold cabling)
2938  uint16_t onlineId = TgcRdo::calculateOnlineId(subDetectorId, rodId);
2939  cinfo.m_hashToOnlineId.push_back(onlineId);
2940  }
2941 
2942  // initialize with false
2943  cinfo.m_MAX_N_ROD = 2*12;
2944 
2945  m_cablingInfo.set (std::move (cinfo));
2946  return m_cablingInfo.ptr();
2947 }
2948 
2950  const Identifier identify,
2951  const double eta,
2952  const double phi) {
2953  if(!readout) return nullptr;
2954 
2955  // Obtain the local coordinate by the secant method
2956  constexpr double length = 100.; // 100 mm
2957  constexpr unsigned int nRep = 10; // 10 repetitions
2958  constexpr double dRAccuracy = 1.0E-20; // recuqired dR accuracy
2959  constexpr double maxLocR = 10000.; // 10 m
2960 
2961  double locX = 0.;
2962  double locY = 0.;
2963  for(unsigned int iRep=0; iRep<nRep; iRep++) {
2964  Amg::Vector2D loc_hitPos_c(locX, locY); // center or current position
2965  Amg::Vector3D tmp_glob_hitPos_c{Amg::Vector3D::Zero()};
2966  readout->surface(identify).localToGlobal(loc_hitPos_c,tmp_glob_hitPos_c,tmp_glob_hitPos_c);
2967  const Amg::Vector3D &glob_hitPos_c = tmp_glob_hitPos_c;
2968 
2969  double glob_eta_c = glob_hitPos_c.eta();
2970  double glob_phi_c = glob_hitPos_c.phi();
2971 
2972  Amg::Vector2D vector{eta - glob_eta_c, deltaPhi(phi, glob_phi_c)};
2973 
2974  double dR = std::hypot(vector[0], vector[1]);
2975  if(dR<dRAccuracy) {
2976  break;
2977  }
2978 
2979  Amg::Vector2D loc_hitPos_w(locX+length, locY ); // slightly shifted position in the wire direction
2980  Amg::Vector2D loc_hitPos_s(locX, locY+length); // slightly shifted position in the strip direction
2981  Amg::Vector3D tmp_glob_hitPos_w{Amg::Vector3D::Zero()};
2982  readout->surface(identify).localToGlobal(loc_hitPos_w,tmp_glob_hitPos_w,tmp_glob_hitPos_w);
2983  const Amg::Vector3D &glob_hitPos_w = tmp_glob_hitPos_w;
2984  Amg::Vector3D tmp_glob_hitPos_s{Amg::Vector3D::Zero()};
2985  readout->surface(identify).localToGlobal(loc_hitPos_s,tmp_glob_hitPos_s,tmp_glob_hitPos_s);
2986  const Amg::Vector3D &glob_hitPos_s = tmp_glob_hitPos_s;
2987 
2988  AmgSymMatrix(2) matrix{AmgSymMatrix(2)::Identity()};
2989  matrix(0,0) = glob_hitPos_w.eta() - glob_eta_c;
2990  matrix(1,0) = deltaPhi(glob_hitPos_w.phi(), glob_phi_c);
2991  matrix(0,1) = glob_hitPos_s.eta() - glob_eta_c;
2992  matrix(1,1) = deltaPhi(glob_hitPos_s.phi(), glob_phi_c);
2993 
2994  bool invertible = matrix.determinant();
2995  if(invertible) {
2996  Amg::MatrixX invertedMatrix = matrix.inverse();
2997  Amg::Vector2D solution = invertedMatrix * vector;
2998  locX += length * solution(0,0);
2999  locY += length * solution(1,0);
3000 
3001  double locR = sqrt(locX*locX + locY*locY);
3002  if(locR>maxLocR) {
3003  locX *= maxLocR/locR;
3004  locY *= maxLocR/locR;
3005  }
3006  }
3007  }
3008 
3009  return new Amg::Vector2D(locX, locY);
3010 }
3011 
Muon::TgcRdoToPrepDataToolMT::getSLIds
bool getSLIds(const bool isStrip, const TgcRawData &rd, std::array< Identifier, 3 > &channelId, int &index, int &chip, int &hitId, int &sub, int &sswId, int &sbLoc, int &subMatrix, std::array< int, 3 > &bitpos, const bool isBoundary=false, const TgcRdo *rdoColl=0, const int index_w=-1, const int chip_w=-1, const int hitId_w=-1, const int sub_w=-1) const
Get ReadoutID of SL from RDO.
Definition: TgcRdoToPrepDataToolMT.cxx:2504
TgcRawData::SLB_TYPE_DOUBLET_STRIP
@ SLB_TYPE_DOUBLET_STRIP
Definition: TgcRawData.h:33
TgcRawData::inner
uint16_t inner() const
Definition: TgcRawData.h:321
beamspotman.r
def r
Definition: beamspotman.py:676
TgcRawData::RPC_BCID_BIT
static constexpr uint32_t RPC_BCID_BIT
Definition: TgcRawData.h:227
Trk::PlaneSurface::globalToLocal
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specified for PlaneSurface: GlobalToLocal method without dynamic memory allocation - boolean checks i...
Definition: PlaneSurface.cxx:215
Muon::TgcCoinData::INNER_RPC_DPHI_BITSHIFT
static constexpr uint32_t INNER_RPC_DPHI_BITSHIFT
Definition: TgcCoinData.h:252
MuonGM::MuonClusterReadoutElement::transform
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
Definition: MuonClusterReadoutElement.h:124
LVL1TGC::CSIDE
@ CSIDE
Definition: TGCNumbering.h:15
xAOD::identify
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:61
Muon::TgcRdoToPrepDataToolMT::TgcRdoToPrepDataToolMT
TgcRdoToPrepDataToolMT(const std::string &t, const std::string &n, const IInterface *p)
Constructor.
Definition: TgcRdoToPrepDataToolMT.cxx:24
TgcRawData::NSW_INPUT_BITSHIFT
static constexpr uint32_t NSW_INPUT_BITSHIFT
Definition: TgcRawData.h:217
dumpTgcDigiDeadChambers.gasGap
list gasGap
Definition: dumpTgcDigiDeadChambers.py:33
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
TgcRawData::innerflag
uint16_t innerflag() const
Definition: TgcRawData.h:381
TgcRawData::bitpos
uint16_t bitpos() const
Definition: TgcRawData.h:293
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::TgcStrip_v1::setChannelNumber
void setChannelNumber(uint16_t chan)
Muon::TgcCoinData::INNER_TILE_BCID_BITSHIFT
static constexpr uint32_t INNER_TILE_BCID_BITSHIFT
Definition: TgcCoinData.h:270
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
Muon::TgcRdoToPrepDataToolMT::getRfromEtaZ
static bool getRfromEtaZ(const double eta, const double z, double &r)
Get r from eta and z.
Definition: TgcRdoToPrepDataToolMT.cxx:1475
xAOD::TgcStrip_v1::setGasGap
void setGasGap(uint8_t gapNum)
Muon::TgcRdoToPrepDataToolMT::s_cutDropPrdsWithZeroWidth
static const double s_cutDropPrdsWithZeroWidth
Cut value for zero widths.
Definition: TgcRdoToPrepDataToolMT.h:396
Muon::TgcRdoToPrepDataToolMT::decode
virtual StatusCode decode(const EventContext &ctx, const std::vector< IdentifierHash > &idVect) const override
Decode RDO to PRD A vector of IdentifierHash are passed in, and the data corresponding to this list...
Definition: TgcRdoToPrepDataToolMT.cxx:210
Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripOut
bool getPosAndIdStripOut(const std::array< const MuonGM::TgcReadoutElement *, 2 > &descriptor_o, const std::array< Identifier, 2 > &channelIdOut, const std::array< int, 2 > &gasGap_o, const std::array< int, 2 > &channel_o, double &width_o, double &hit_position_o, Amg::Vector2D &tmp_hitPos_o, Identifier &channelIdOut_tmp, const bool isBackward, const bool isAside) const
Get position and offline ID of TGC3 strip for HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:2183
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
TgcRawData::isCoincidence
bool isCoincidence() const
Definition: TgcRawData.h:237
Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireIn
bool getPosAndIdWireIn(const std::array< const MuonGM::TgcReadoutElement *, 4 > &descriptor_i, const std::array< Identifier, 4 > &channelIdIn, const std::array< int, 4 > &gasGap_i, const std::array< int, 4 > &channel_i, double &width_i, double &hit_position_i, Amg::Vector2D &tmp_hitPos_i, Identifier &channelIdIn_tmp) const
Get position and offline ID of TGC1 wire for HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:2243
TgcRawData::rpcdeta
uint16_t rpcdeta() const
Definition: TgcRawData.h:433
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Muon::TgcRdoToPrepDataToolMT::isIncludedInChamberBoundary
bool isIncludedInChamberBoundary(const TgcRawData &rd) const
Check SL RDO is at the chamber boundary.
Definition: TgcRdoToPrepDataToolMT.cxx:1590
Trk::locX
@ locX
Definition: ParamDefs.h:37
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
TgcRdo::calculateOnlineId
static uint16_t calculateOnlineId(uint16_t subDetectorId, uint16_t rodId)
Definition: TgcRdo.cxx:58
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
TgcIdHelper::gasGap
int gasGap(const Identifier &id) const override
get the hashes
Definition: TgcIdHelper.cxx:642
Surface.h
MuonGM::TgcReadoutElement::stripHighEdgeLocX
double stripHighEdgeLocX(int gasGap, int strip, double radialPos) const
Returns the local X of the right edge of the strip at a given local radial position.
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:138
TgcRawData::isMuplus
bool isMuplus() const
Definition: TgcRawData.h:361
TgcDigit::BC_UNDEFINED
@ BC_UNDEFINED
Definition: TgcDigit.h:37
TgcRawData::tmdbmod
uint16_t tmdbmod() const
Definition: TgcRawData.h:453
Muon::TgcRdoToPrepDataToolMT::getBitPosWire
void getBitPosWire(const TgcRawData &rd, const int hitId_w, const int sub_w, int &subMatrix_w, std::array< int, 3 > &bitpos_w) const
Get bitPos etc of wire for SL.
Definition: TgcRdoToPrepDataToolMT.cxx:1829
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
TgcRawData::TYPE_INNER_EIFI
@ TYPE_INNER_EIFI
Definition: TgcRawData.h:50
Muon::TgcRdoToPrepDataToolMT::getSLStripGeometry
bool getSLStripGeometry(const std::array< Identifier, 3 > &channelId_strip, const bool isBackWard, const bool isAside, double &width_strip, double &theta_strip) const
Get strip geometry (width, theta) for SL.
Definition: TgcRdoToPrepDataToolMT.cxx:2054
Muon::TgcRdoToPrepDataToolMT::isBackwardBW
static bool isBackwardBW(const TgcRawData &rd)
Check if a chamber in BigWheel is a backward chamber or a forward chamber.
Definition: TgcRdoToPrepDataToolMT.cxx:1961
TgcIdHelper
Definition: TgcIdHelper.h:50
TgcDigit::BC_NEXTNEXT
@ BC_NEXTNEXT
Definition: TgcDigit.h:37
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
index
Definition: index.py:1
TgcRawData::delta
int16_t delta() const
Definition: TgcRawData.h:317
xAODP4Helpers.h
TgcRawData::hsub
uint16_t hsub() const
Definition: TgcRawData.h:349
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
xAOD::TgcStrip_v1
Definition: TgcStrip_v1.h:19
TgcRawData::NSW_BCID_BITSHIFT
static constexpr uint32_t NSW_BCID_BITSHIFT
Definition: TgcRawData.h:219
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:55
Muon::TgcRdoToPrepDataToolMT::getBitPosInWire
void getBitPosInWire(const TgcRawData &rd, const int DeltaBeforeConvert, std::array< int, 4 > &bitpos_i, std::array< int, 4 > &slbchannel_i, std::array< int, 4 > &slbId_in, std::array< int, 4 > &sbLoc_in, int &sswId_i, const std::array< int, 2 > &bitpos_o, std::array< int, 2 > &slbchannel_o, const int slbId_o) const
Get bitPos etc of TGC1 wire for HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:1656
Muon::TgcCoinData::INNER_RPC_PHI_BITSHIFT
static constexpr uint32_t INNER_RPC_PHI_BITSHIFT
Definition: TgcCoinData.h:248
test_pyathena.pt
pt
Definition: test_pyathena.py:11
TgcDigit::BC_PREVIOUS
@ BC_PREVIOUS
Definition: TgcDigit.h:37
Muon::TgcRdoToPrepDataToolMT::CablingInfo::m_MAX_N_ROD
int m_MAX_N_ROD
Definition: TgcRdoToPrepDataToolMT.h:109
Muon::TgcRdoToPrepDataToolMT::decodeHits
StatusCode decodeHits(State &state, const TgcRawData &rd) const
Decode RDO's of Hit.
Definition: TgcRdoToPrepDataToolMT.cxx:428
TgcRawData::rpceta
uint16_t rpceta() const
Definition: TgcRawData.h:421
TgcRawData::TYPE_INNER_TMDB
@ TYPE_INNER_TMDB
Definition: TgcRawData.h:51
Muon::TgcRdoToPrepDataToolMT::getSLWireGeometry
bool getSLWireGeometry(const std::array< Identifier, 3 > &channelId_wire, double &width_wire, double &r_wire, double &z_wire) const
Get wire geometry (width, r, z) for SL.
Definition: TgcRdoToPrepDataToolMT.cxx:1985
Muon::TgcRdoToPrepDataToolMT::initialize
virtual StatusCode initialize() override
Standard AthAlgTool initialize method.
Definition: TgcRdoToPrepDataToolMT.cxx:29
Trk::loc2
@ loc2
generic first and second local coordinate
Definition: ParamDefs.h:35
Muon::TgcRdoToPrepDataToolMT::selectDecoder
void selectDecoder(State &state, const TgcRawData &rd, const TgcRdo *rdoColl) const
Select decoder based on RDO type (Hit or Coincidence (Tracklet, HiPt and SL))
Definition: TgcRdoToPrepDataToolMT.cxx:386
TgcRawData::nswcand
uint16_t nswcand() const
Definition: TgcRawData.h:401
Muon::TgcCoinData::TYPE_TRACKLET
@ TYPE_TRACKLET
Definition: TgcCoinData.h:50
Muon::TgcCoinData::INNER_NSW_BCID_BITSHIFT
static constexpr uint32_t INNER_NSW_BCID_BITSHIFT
Definition: TgcCoinData.h:240
TgcRawData::subDetectorId
uint16_t subDetectorId() const
Definition: TgcRawData.h:264
TgcRawData::bcId
uint16_t bcId() const
Definition: TgcRawData.h:259
Trk::locR
@ locR
Definition: ParamDefs.h:44
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
TgcRawData::isHipt
bool isHipt() const
Definition: TgcRawData.h:341
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
isValid
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition: AtlasPID.h:778
Muon::TgcRdoToPrepDataToolMT::decodeTracklet
StatusCode decodeTracklet(State &state, const TgcRawData &rd) const
Decode RDO's of Tracklet.
Definition: TgcRdoToPrepDataToolMT.cxx:577
Muon::TgcRdoToPrepDataToolMT::getEtafromRZ
static bool getEtafromRZ(const double r, const double z, double &eta)
Get eta from r and z.
Definition: TgcRdoToPrepDataToolMT.cxx:1485
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
Muon::TgcRdoToPrepDataToolMT::getBitPosInStrip
void getBitPosInStrip(const TgcRawData &rd, const int DeltaBeforeConvert, std::array< int, 4 > &bitpos_i, std::array< int, 4 > &slbchannel_i, int &sbLoc_i, int &sswId_i, const std::array< int, 2 > &bitpos_o, std::array< int, 2 > &slbchannel_o) const
Get bitPos etc of TGC1 strip for HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:1769
Muon::TgcCoinData::INNER_RPC_DETA_BITSHIFT
static constexpr uint32_t INNER_RPC_DETA_BITSHIFT
Definition: TgcCoinData.h:250
Muon::MuonPrepDataCollection::setIdentifier
virtual void setIdentifier(Identifier id)
MuonGM::MuonClusterReadoutElement::surface
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
Definition: MuonClusterReadoutElement.h:123
MuonGM::TgcReadoutElement::stripLowEdgeLocX
double stripLowEdgeLocX(int gasGap, int strip, double radialPos) const
Returns the local X of the left edge of the strip at a given local radial position.
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:130
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
TgcRawData::NSW_INPUT_BIT
static constexpr uint32_t NSW_INPUT_BIT
Definition: TgcRawData.h:218
TgcRawData::SLB_TYPE_TRIPLET_WIRE
@ SLB_TYPE_TRIPLET_WIRE
Definition: TgcRawData.h:34
Muon::TgcCoinData
Definition: TgcCoinData.h:37
Muon::TgcCoinData::INNER_NSW_INPUT_BITSHIFT
static constexpr uint32_t INNER_NSW_INPUT_BITSHIFT
Definition: TgcCoinData.h:242
Muon::TgcRdoToPrepDataToolMT::finalize
virtual StatusCode finalize() override
Standard AthAlgTool finalize method.
Definition: TgcRdoToPrepDataToolMT.cxx:109
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
Muon::TgcCoinData::INNER_NSW_ID_BITSHIFT
static constexpr uint32_t INNER_NSW_ID_BITSHIFT
Definition: TgcCoinData.h:238
Muon::TgcRdoToPrepDataToolMT::getSbLocOfEndcapStripBoundaryFromHiPt
bool getSbLocOfEndcapStripBoundaryFromHiPt(const TgcRawData &rd, int &sbLoc, const TgcRdo *rdoColl, const int index_w, const int chip_w, const int hitId_w, const int sub_w) const
Get strip sbLoc of Endcap chamber boundary from HiPt Strip.
Definition: TgcRdoToPrepDataToolMT.cxx:2623
MuonGM::TgcReadoutElement::channelPos
Amg::Vector3D channelPos(const Identifier &id) const
Returns the position of the active channel (wireGang or strip)
TgcRawData::rodId
uint16_t rodId() const
Definition: TgcRawData.h:268
TgcRawData::subMatrix
uint16_t subMatrix() const
Definition: TgcRawData.h:329
MuonGM::MuonDetectorManager::getTgcReadoutElement
const TgcReadoutElement * getTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:247
Muon::TgcRdoToPrepDataToolMT::State::muDetMgr
const MuonGM::MuonDetectorManager * muDetMgr
Definition: TgcRdoToPrepDataToolMT.h:98
Muon::TgcRdoToPrepDataToolMT::decodeInner
StatusCode decodeInner(State &state, const TgcRawData &rd) const
Decode RDO's of Inner.
Definition: TgcRdoToPrepDataToolMT.cxx:1146
Muon::TgcRdoToPrepDataToolMT::provideEmptyContainer
virtual StatusCode provideEmptyContainer(const EventContext &ctx) const override
Definition: TgcRdoToPrepDataToolMT.cxx:140
Muon::TgcPrepData::BCBIT_CURRENT
@ BCBIT_CURRENT
Definition: TgcPrepData.h:97
xAOD::UncalibratedMeasurement_v1::setIdentifier
void setIdentifier(const DetectorIdentType measId)
Sets the full Identifier of the measurement.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Muon::MuonPrepDataCollection::identifyHash
virtual IdentifierHash identifyHash() const override final
Muon::TgcCoinData::INNER_NSW_PHIRES_BITSHIFT
static constexpr uint32_t INNER_NSW_PHIRES_BITSHIFT
Definition: TgcCoinData.h:234
TgcRawData::isForward
bool isForward() const
Definition: TgcRawData.h:289
Muon::TgcPrepData::getBcBitMap
uint16_t getBcBitMap() const
Returns the bcBitMap of this PRD bit2 for Previous BC, bit1 for Current BC, bit0 for Next BC.
Definition: TgcPrepData.cxx:75
MuonGM::TgcReadoutElement::gangLongWidth
double gangLongWidth(int gasGap, int gang) const
Returns the length of the most top wire in the gang.
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:86
MuonGM::TgcReadoutElement::containsId
virtual bool containsId(const Identifier &id) const override
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:282
Muon::TgcCoinData::TYPE_HIPT
@ TYPE_HIPT
Definition: TgcCoinData.h:51
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonGM::TgcReadoutElement::stripWidth
double stripWidth(int gasGap, int strip) const
Returns the width of a given strip in the gasGap i.
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:146
Muon::TgcRdoToPrepDataToolMT::getRoiRow
static int getRoiRow(const TgcRawData &rd)
Get ROI row from RDO.
Definition: TgcRdoToPrepDataToolMT.cxx:1584
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
Muon::TgcRdoToPrepDataToolMT::getHiPtIds
bool getHiPtIds(const TgcRawData &rd, int &sswId_o, int &sbLoc_o, int &slbId_o) const
Get ReadoutID of HiPt from RDOHighPtID.
Definition: TgcRdoToPrepDataToolMT.cxx:2437
Muon::TgcRdoToPrepDataToolMT::getchannel
static int getchannel(int bitpos, TgcRawData::SlbType slbType)
Get channel from bitpos and SlbType.
Definition: TgcRdoToPrepDataToolMT.cxx:1446
xAOD::TgcStrip_v1::setBcBitMap
void setBcBitMap(uint16_t)
Trk::PrepRawData::setHashAndIndex
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
beamspotman.n
n
Definition: beamspotman.py:731
Muon::TgcRdoToPrepDataToolMT::getEndcapStripCandidateTrackletIds
static void getEndcapStripCandidateTrackletIds(const int roi, int &trackletIdStripFirst, int &trackletIdStripSecond, int &trackletIdStripThird)
Get trackletIds of three Tracklet Strip candidates in the Endcap boudary.
Definition: TgcRdoToPrepDataToolMT.cxx:2844
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonGM::TgcReadoutElement::gangShortWidth
double gangShortWidth(int gasGap, int gang) const
Returns the length of the most bottom wire in the gang.
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:79
TgcRawData::RPC_FLAG_BITSHIFT
static constexpr uint32_t RPC_FLAG_BITSHIFT
Definition: TgcRawData.h:222
Muon::TgcCoinData::setHashAndIndex
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
Definition: TgcCoinData.h:326
Muon::TgcRdoToPrepDataToolMT::getSLLocalPosition
static const Amg::Vector2D * getSLLocalPosition(const MuonGM::TgcReadoutElement *readout, const Identifier, const double eta, const double phi)
Get SL local position.
Definition: TgcRdoToPrepDataToolMT.cxx:2949
Muon::TgcRdoToPrepDataToolMT::State::tgcPrepDataCollections
std::array< TempPrepDataContainer, NBC_HIT+1 > tgcPrepDataCollections
Definition: TgcRdoToPrepDataToolMT.h:88
Muon::TgcRdoToPrepDataToolMT::State::tgcCoinDataCollections
std::array< TempCoinDataContainer, NBC_TRIG > tgcCoinDataCollections
Definition: TgcRdoToPrepDataToolMT.h:93
Muon::TgcRdoToPrepDataToolMT::CablingInfo
Definition: TgcRdoToPrepDataToolMT.h:105
TgcDigit::BC_NEXT
@ BC_NEXT
Definition: TgcDigit.h:37
MuonGM::TgcReadoutElement
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/TgcReadoutElement.h:42
TgcDigit.h
Muon::TgcCoinData::INNER_RPC_ETA_BITSHIFT
static constexpr uint32_t INNER_RPC_ETA_BITSHIFT
Bit info in int inner for the RPC inner-coincidence.
Definition: TgcCoinData.h:246
Muon::TgcCoinData::INNER_TILE_MODULE_BITSHIFT
static constexpr uint32_t INNER_TILE_MODULE_BITSHIFT
Bit info in int inner for the Tile inner-coincidence.
Definition: TgcCoinData.h:268
Muon::TgcCoinData::INNER_NSW_DTHETA_BITSHIFT
static constexpr uint32_t INNER_NSW_DTHETA_BITSHIFT
Definition: TgcCoinData.h:232
Muon::TgcRdoToPrepDataToolMT::isOfflineIdOKForTgcReadoutElement
bool isOfflineIdOKForTgcReadoutElement(const MuonGM::TgcReadoutElement *descriptor, const Identifier channelId) const
Check offline ID is OK for TgcReadoutElement.
Definition: TgcRdoToPrepDataToolMT.cxx:1499
MuonGM::TgcReadoutElement::gangRadialLength
double gangRadialLength(int gasGap, int gang) const
Returns the length of the wire gang along the radial direction [pitch x N_{wire}^{gang}].
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:72
xAOD::TgcStrip_v1::setMeasuresPhi
void setMeasuresPhi(uint8_t measPhi)
TgcRawData::TYPE_SL
@ TYPE_SL
Definition: TgcRawData.h:46
Muon::TgcRdoToPrepDataToolMT::setupState
StatusCode setupState(const EventContext &ctx, State &state) const
Definition: TgcRdoToPrepDataToolMT.cxx:150
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TgcRawData::sector
uint16_t sector() const
Definition: TgcRawData.h:333
Muon::TgcRdoToPrepDataToolMT::getSbLocOfEndcapStripBoundaryFromTracklet
bool getSbLocOfEndcapStripBoundaryFromTracklet(const TgcRawData &rd, int &sbLoc, const TgcRdo *rdoColl, const int index_w, const int chip_w, const int hitId_w, const int sub_w) const
Get strip sbLoc of Endcap chamber boundary from Tracklet Strip.
Definition: TgcRdoToPrepDataToolMT.cxx:2729
TgcRawData::nswlowres
uint16_t nswlowres() const
Definition: TgcRawData.h:413
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
TgcDigit::BC_CURRENT
@ BC_CURRENT
Definition: TgcDigit.h:37
TgcRawData::isVeto
bool isVeto() const
Definition: TgcRawData.h:373
TgcRawData::sswId
uint16_t sswId() const
Definition: TgcRawData.h:272
TgcRawData::l1Id
uint16_t l1Id() const
Definition: TgcRawData.h:255
Muon::TgcCoinData::INNER_RPC_BCID_BITSHIFT
static constexpr uint32_t INNER_RPC_BCID_BITSHIFT
Definition: TgcCoinData.h:256
Muon::TgcRdoToPrepDataToolMT::getBitPosStrip
static void getBitPosStrip(const int hitId_s, const int sub_s, int &subMatrix_s, std::array< int, 3 > &bitpos_s)
Get bitPos etc of strip for SL.
Definition: TgcRdoToPrepDataToolMT.cxx:1893
TgcRawData::ei
uint16_t ei() const
Definition: TgcRawData.h:441
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
Muon::TgcCoinData::TYPE_UNKNOWN
@ TYPE_UNKNOWN
Definition: TgcCoinData.h:53
TgcRawData::isStrip
bool isStrip() const
Definition: TgcRawData.h:353
TgcRawData::position
uint16_t position() const
Definition: TgcRawData.h:313
Muon::TgcRdoToPrepDataToolMT::getBitPosOutStrip
static void getBitPosOutStrip(const TgcRawData &rd, int &slbsubMatrix, std::array< int, 2 > &bitpos_o)
Get bitPos etc of TGC3 strip for HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:1744
TgcRawData::nswphi
uint16_t nswphi() const
Definition: TgcRawData.h:393
xAOD::MeasVector
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Definition: MeasurementDefs.h:53
TgcRawData::hitId
uint16_t hitId() const
Definition: TgcRawData.h:345
TgcRawData::threshold
uint16_t threshold() const
Definition: TgcRawData.h:365
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
dumpTgcDigiThreshold.isStrip
list isStrip
Definition: dumpTgcDigiThreshold.py:33
Muon::TgcPrepData::setBcBitMap
void setBcBitMap(const uint16_t)
set the bcBitMap for this PRD
Definition: TgcPrepData.cxx:80
TgcRawData::nswid
uint16_t nswid() const
Definition: TgcRawData.h:417
Muon::TgcRdoToPrepDataToolMT::getbitpos
static int getbitpos(int channel, TgcRawData::SlbType slbType)
Get bitpos from channel and SlbType.
Definition: TgcRdoToPrepDataToolMT.cxx:1418
TgcRawData::chip
uint16_t chip() const
Definition: TgcRawData.h:337
TgcRawData::roi
uint16_t roi() const
Definition: TgcRawData.h:377
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SG::UpdateHandle
Definition: UpdateHandle.h:91
Muon::TgcRdoToPrepDataToolMT::CablingInfo::m_tgcCabling
SmartIF< MuonTGC_CablingSvc > m_tgcCabling
Definition: TgcRdoToPrepDataToolMT.h:106
TgcRawData::cid
uint16_t cid() const
Definition: TgcRawData.h:449
Muon::TgcCoinData::INNER_NSW_R_BITSHIFT
static constexpr uint32_t INNER_NSW_R_BITSHIFT
Bit info in int inner for the NSW inner-coincidence.
Definition: TgcCoinData.h:228
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
checkTriggerxAOD.found
found
Definition: checkTriggerxAOD.py:328
Muon::TgcRdoToPrepDataToolMT::getTrackletInfo
bool getTrackletInfo(const TgcRawData &rd, int &tmp_slbId, int &tmp_subMatrix, int &tmp_position) const
Retrieve slbId, subMatrix and position from Tracklet RDO.
Definition: TgcRdoToPrepDataToolMT.cxx:1508
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::TgcRdoToPrepDataToolMT::decodeSL
StatusCode decodeSL(State &state, const TgcRawData &rd, const TgcRdo *rdoColl) const
Decode RDO's of SectorLogic.
Definition: TgcRdoToPrepDataToolMT.cxx:1264
Muon::TgcCoinData::INNER_RPC_FLAG_BITSHIFT
static constexpr uint32_t INNER_RPC_FLAG_BITSHIFT
Definition: TgcCoinData.h:254
Muon::TgcRdoToPrepDataToolMT::getDeltaBeforeConvert
static int getDeltaBeforeConvert(const TgcRawData &rd)
Get delta (sagitta) before converion for HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:1928
LVL1TGC::ASIDE
@ ASIDE
Definition: TGCNumbering.h:14
Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireOut
bool getPosAndIdWireOut(const std::array< const MuonGM::TgcReadoutElement *, 2 > &descriptor_o, const std::array< Identifier, 2 > &channelIdOut, const std::array< int, 2 > &gasGap_o, const std::array< int, 2 > &channel_o, double &width_o, double &hit_position_o, Amg::Vector2D &tmp_hitPos_o, Identifier &channelIdOut_tmp) const
Get position and offline ID of TGC3 wire for HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:2129
Muon::MuonCoinDataCollection::identifyHash
IdentifierHash identifyHash() const
TgcRawData::coinflag
uint16_t coinflag() const
Definition: TgcRawData.h:385
TgcRawData::TYPE_INNER_NSW
@ TYPE_INNER_NSW
Definition: TgcRawData.h:48
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
TgcRawData::nswdtheta
uint16_t nswdtheta() const
Definition: TgcRawData.h:405
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
DeMoScan.index
string index
Definition: DeMoScan.py:364
TgcRawData::bcTag
uint16_t bcTag() const
Definition: TgcRawData.h:251
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:66
TgcRawData::tmdbbcid
uint16_t tmdbbcid() const
Definition: TgcRawData.h:457
TgcRawData::slbId
uint16_t slbId() const
Definition: TgcRawData.h:276
TgcRawData::index
uint16_t index() const
Definition: TgcRawData.h:309
xAOD::UncalibratedMeasurement_v1::setMeasurement
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
Muon::TgcRdoToPrepDataToolMT::State::tgcCoinDataContainer
std::array< TgcCoinDataContainer *, NBC_TRIG > tgcCoinDataContainer
TgcCoinData (coincidence PRD) containers.
Definition: TgcRdoToPrepDataToolMT.h:90
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::P4Helpers
Definition: xAODP4Helpers.h:36
Muon::TgcCoinData::TYPE_SL
@ TYPE_SL
Definition: TgcCoinData.h:52
TgcRawData::TYPE_HIPT
@ TYPE_HIPT
Definition: TgcRawData.h:45
TgcRawData::RPC_FLAG_BIT
static constexpr uint32_t RPC_FLAG_BIT
Definition: TgcRawData.h:223
GeoPrimitivesHelpers.h
TgcRawData
An unit object of TGC ROD output.
Definition: TgcRawData.h:23
DEBUG
#define DEBUG
Definition: page_access.h:11
bcTag
unsigned bcTag(unsigned bcBitMap)
Definition: TgcByteStreamData.h:359
TgcRawData::slbType
SlbType slbType() const
Definition: TgcRawData.h:285
TgcRawData::SLB_TYPE_INNER_STRIP
@ SLB_TYPE_INNER_STRIP
Definition: TgcRawData.h:37
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Muon::TgcPrepData
Class to represent TGC measurements.
Definition: TgcPrepData.h:32
TgcRawData::rpcflag
uint16_t rpcflag() const
Definition: TgcRawData.h:429
Muon::TgcCoinData::TYPE_TRACKLET_EIFI
@ TYPE_TRACKLET_EIFI
Definition: TgcCoinData.h:54
TgcRawData::type
DataType type() const
Definition: TgcRawData.h:280
Muon::TgcCoinData::INNER_EIFI_FI_BITSHIFT
static constexpr uint32_t INNER_EIFI_FI_BITSHIFT
Definition: TgcCoinData.h:262
TgcRdoToPrepDataToolMT.h
TgcRawData::NSW_BCID_BIT
static constexpr uint32_t NSW_BCID_BIT
Definition: TgcRawData.h:220
Muon::TgcRdoToPrepDataToolMT::decodeHiPt
StatusCode decodeHiPt(State &state, const TgcRawData &rd) const
Decode RDO's of HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:894
Muon::MuonCoinDataCollection::setIdentifier
void setIdentifier(Identifier id)
Muon::TgcRdoToPrepDataToolMT::State
Definition: TgcRdoToPrepDataToolMT.h:83
TgcRawData::TYPE_INNER_BIS
@ TYPE_INNER_BIS
Definition: TgcRawData.h:49
TgcRawData::nswphires
uint16_t nswphires() const
Definition: TgcRawData.h:409
TgcReadoutElement.h
TgcRawData::SLB_TYPE_INNER_WIRE
@ SLB_TYPE_INNER_WIRE
Definition: TgcRawData.h:36
Muon::TgcCoinData::INNER_NSW_PHI_BITSHIFT
static constexpr uint32_t INNER_NSW_PHI_BITSHIFT
Definition: TgcCoinData.h:230
merge.status
status
Definition: merge.py:17
TgcRdo
Definition: TgcRdo.h:22
xAOD::MeasMatrix
Eigen::Matrix< float, N, N > MeasMatrix
Definition: MeasurementDefs.h:55
veto
std::vector< std::string > veto
these patterns are anded
Definition: listroot.cxx:191
TgcRawData::rpcphi
uint16_t rpcphi() const
Definition: TgcRawData.h:425
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Muon::TgcPrepData::BCBIT_NEXT
@ BCBIT_NEXT
Definition: TgcPrepData.h:97
TgcCoinData.h
Muon::TgcRdoToPrepDataToolMT::getBitPosOutWire
static void getBitPosOutWire(const TgcRawData &rd, int &slbsubMatrix, std::array< int, 2 > &bitpos_o)
Get bitPos etc of TGC3 wire for HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:1605
TgcRawData::RPC_BCID_BITSHIFT
static constexpr uint32_t RPC_BCID_BITSHIFT
Definition: TgcRawData.h:226
Trk::PlaneSurface::localToGlobal
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for PlaneSurface: LocalToGlobal method without dynamic memory allocation.
Definition: PlaneSurface.cxx:204
Muon::TgcPrepData::BCBIT_PREVIOUS
@ BCBIT_PREVIOUS
Definition: TgcPrepData.h:97
TgcRawData::TYPE_TRACKLET
@ TYPE_TRACKLET
Definition: TgcRawData.h:44
Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI
StatusCode decodeTrackletEIFI(State &state, const TgcRawData &rd) const
Decode RDO's of Tracklet EIFI.
Definition: TgcRdoToPrepDataToolMT.cxx:726
TgcRawData::SLB_TYPE_TRIPLET_STRIP
@ SLB_TYPE_TRIPLET_STRIP
Definition: TgcRawData.h:35
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
Muon::TgcCoinData::INNER_EIFI_CID_BITSHIFT
static constexpr uint32_t INNER_EIFI_CID_BITSHIFT
Definition: TgcCoinData.h:264
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
TgcStripAuxContainer.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
Muon::TgcCoinData::INNER_NSW_LOWRES_BITSHIFT
static constexpr uint32_t INNER_NSW_LOWRES_BITSHIFT
Definition: TgcCoinData.h:236
TgcRawData::nsweta
uint16_t nsweta() const
Definition: TgcRawData.h:389
TgcRawData::fi
uint16_t fi() const
Definition: TgcRawData.h:445
Muon::TgcCoinData::INNER_EIFI_EI_BITSHIFT
static constexpr uint32_t INNER_EIFI_EI_BITSHIFT
Bit info in int inner for the EI/FI inner-coincidence.
Definition: TgcCoinData.h:260
TgcRawData::SLB_TYPE_DOUBLET_WIRE
@ SLB_TYPE_DOUBLET_WIRE
Definition: TgcRawData.h:32
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
fitman.k
k
Definition: fitman.py:528
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
Muon::TgcRdoToPrepDataToolMT::CablingInfo::m_hashToOnlineId
std::vector< uint16_t > m_hashToOnlineId
Conversion from hash to onlineId.
Definition: TgcRdoToPrepDataToolMT.h:108
Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripIn
bool getPosAndIdStripIn(const std::array< const MuonGM::TgcReadoutElement *, 4 > &descriptor_i, const std::array< Identifier, 4 > &channelIdIn, const std::array< int, 4 > &gasGap_i, const std::array< int, 4 > &channel_i, double &width_i, double &hit_position_i, Amg::Vector2D &tmp_hitPos_i, Identifier &channelIdIn_tmp, const bool isBackward, const bool isAside) const
Get position and offline ID of TGC1 strip for HiPt.
Definition: TgcRdoToPrepDataToolMT.cxx:2348
TgcRawData::rpcdphi
uint16_t rpcdphi() const
Definition: TgcRawData.h:437
Muon::TgcRdoToPrepDataToolMT::getCabling
const CablingInfo * getCabling() const
Definition: TgcRdoToPrepDataToolMT.cxx:2909
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
TgcRawData::SlbType
SlbType
Definition: TgcRawData.h:31
Muon::TgcRdoToPrepDataToolMT::State::tgcPrepDataContainer
std::array< TgcPrepDataContainer *, NBC_HIT+1 > tgcPrepDataContainer
TgcPrepRawData (hit PRD) containers.
Definition: TgcRdoToPrepDataToolMT.h:85
Muon::TgcRdoToPrepDataToolMT::transferData
StatusCode transferData(ContType &container, std::vector< std::unique_ptr< CollType >> &&coll) const
Definition: TgcRdoToPrepDataToolMT.cxx:127
Identifier
Definition: IdentifierFieldParser.cxx:14