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