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