9 #include "GaudiKernel/ThreadLocalContext.h"
27 : base_class(
t,
n,
p) {}
35 m_outputprepdataKeys.resize(NBC_HIT+1);
36 for (
int ibc=0; ibc < NBC_HIT+1; ibc++) {
39 location << m_outputCollectionLocation.value()
43 << (
bcTag==(NBC_HIT+1) ?
"AllBCs" :
"");
44 m_outputprepdataKeys.at(ibc) =
location.str();
47 m_outputCoinKeys.resize(NBC_TRIG);
48 for (
int ibc=0; ibc < NBC_TRIG; ibc++) {
51 location << m_outputCoinCollectionLocation.value()
55 m_outputCoinKeys.at(ibc) =
location.str();
59 ATH_CHECK(m_outputprepdataKeys.initialize());
63 ATH_CHECK( m_rdoContainerKey.initialize() );
68 ATH_MSG_INFO(
"TGCCablingServerSvc not yet configured; postpone TGCcabling initialization at first event.");
72 if (not m_prdContainerCacheKeyStr.empty()) {
73 m_prdContainerCacheKeys.resize(NBC_HIT+1);
74 for (
int ibc=0; ibc < NBC_HIT+1; ibc++) {
77 location << m_prdContainerCacheKeyStr.value()
81 << (
bcTag==(NBC_HIT+1) ?
"AllBCs" :
"");
82 m_prdContainerCacheKeys.at(ibc) =
location.str();
87 if (not m_coinContainerCacheKeyStr.empty()){
88 m_coinContainerCacheKeys.resize(NBC_TRIG);
89 for (
int ibc=0; ibc < NBC_TRIG; ibc++) {
92 location << m_coinContainerCacheKeyStr.value()
96 m_coinContainerCacheKeys.at(ibc) =
location.str();
102 ATH_CHECK( m_prdContainerCacheKeys.initialize( not m_prdContainerCacheKeyStr.empty() ) );
103 ATH_CHECK( m_coinContainerCacheKeys.initialize( not m_coinContainerCacheKeyStr.empty() ) );
105 ATH_CHECK(m_xAODKey.initialize(!m_xAODKey.empty()));
106 return StatusCode::SUCCESS;
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 <<
"]");
126 return StatusCode::FAILURE;
131 return setupState(ctx, state);
136 for(
unsigned int ibc=0; ibc < NBC_HIT+1; ibc++) {
140 const bool externalCachePRD = (m_prdContainerCacheKeys.size()>ibc) and (not m_prdContainerCacheKeys[ibc].
key().empty());
141 if (!externalCachePRD) {
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;
148 ATH_MSG_DEBUG(
"TGC PrepData Container recorded in StoreGate with key " << m_outputprepdataKeys[ibc].
key());
156 ATH_MSG_FATAL(
"Invalid UpdateHandle " << m_prdContainerCacheKeys[ibc].
key());
157 return StatusCode::FAILURE;
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;
166 ATH_MSG_DEBUG(
"Created container using cache for " << m_prdContainerCacheKeys[ibc].
key());
170 if (!m_xAODKey.empty()){
172 ATH_CHECK(state.
m_xaodHandle.record(std::make_unique<xAOD::TgcStripContainer>(), std::make_unique<xAOD::TgcStripAuxContainer>()));
175 return StatusCode::SUCCESS;
178 const std::vector<IdentifierHash>& requestedIdHashVect)
const {
183 int sizeVectorRequested = requestedIdHashVect.size();
184 ATH_MSG_DEBUG(
"decode for " << sizeVectorRequested <<
" offline collections called");
188 return StatusCode::FAILURE;
192 std::vector<const TgcRdo*> decodedRdoCollVec;
193 std::vector<bool> decodedOnlineId (cinfo->
m_MAX_N_ROD,
false);
196 for (
unsigned int ibc=0; ibc < NBC_TRIG; ibc++) {
200 const bool externalCacheCoin = (m_coinContainerCacheKeys.size()>ibc) and (not m_coinContainerCacheKeys[ibc].
key().empty());
201 if(!externalCacheCoin) {
203 handle = std::make_unique<TgcCoinDataContainer> (m_idHelperSvc->tgcIdHelper().module_hash_max());
206 ATH_MSG_FATAL(
"Could not record container of TGC CoinData at " << m_outputCoinKeys[ibc].
key());
207 return StatusCode::FAILURE;
209 ATH_MSG_DEBUG(
"TGC CoinData Container recorded in StoreGate with key " << m_outputCoinKeys[ibc].
key());
216 ATH_MSG_FATAL(
"Invalid UpdateHandle " << m_coinContainerCacheKeys[ibc].
key());
217 return StatusCode::FAILURE;
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;
224 ATH_MSG_DEBUG(
"Created container using cache for " << m_coinContainerCacheKeys[ibc].
key());
234 ATH_MSG_DEBUG(
"Stored empty container. Decoding TGC RDO into TGC PrepRawData is switched off");
235 return StatusCode::SUCCESS;
243 if(!rdoContainer.isValid()) {
245 return StatusCode::SUCCESS;
249 if(rdoContainer->empty()) {
251 ATH_MSG_DEBUG(
"Empty rdo container - no tgc rdo in this event");
252 return StatusCode::SUCCESS;
255 ATH_MSG_DEBUG(
"Not empty rdo container in this event, the container size is " <<
256 rdoContainer->size());
259 std::vector<const TgcRdo*> rdoCollVec;
260 if(sizeVectorRequested!=0) {
261 unsigned int nRdo = 0;
262 for (IdentifierHash offlineCollHash : requestedIdHashVect) {
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");
272 decodedOnlineId.at(onlineId) =
true;
274 for(
const TgcRdo* rdoColl : *rdoContainer) {
275 if(rdoColl->identify()==onlineId) {
276 if(!isAlreadyConverted(decodedRdoCollVec, rdoCollVec, rdoColl)) {
277 rdoCollVec.push_back(rdoColl);
288 if(sizeVectorRequested!=0) {
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) {
299 Identifier offlineId;
300 IdentifierHash tgcHashId;
301 IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
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()){
308 prdCollectionMap, coinMap);
313 decodedRdoCollVec.push_back(rdo);
317 for(
unsigned int ibc = 0; ibc < prdCollectionMap.size(); ++ibc) {
319 auto& thismap = prdCollectionMap[ibc];
320 for(
auto& mapPair : thismap) {
321 IdentifierHash tgcHashId = mapPair.first;
322 if(tgcHashId.is_valid()) {
325 ATH_MSG_DEBUG(
"Calling addOrDelete " << ibc <<
" " << tgcHashId);
327 }
else ATH_MSG_DEBUG(
"lock.alreadyPresent for " << ibc <<
" " << tgcHashId);
329 ATH_MSG_ERROR(
"Invalid hash ID when trying to write, this should not happen");
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()) {
343 ATH_MSG_DEBUG(
"Call addOrDelete for coin " << ibc <<
" tgcHashId: " << tgcHashId <<
" size = " << mapPair.second->size());
347 ATH_MSG_ERROR(
"Invalid hash ID when trying to write, this should not happen");
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());
365 prdCollectionMap, coinMap);
367 decodedRdoCollVec.push_back(rdoColl);
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()) {
379 ATH_MSG_DEBUG(
"Call addOrDelete for " << ibc <<
" tgcHashId: " << tgcHashId <<
" size = " << mapPair.second->size());
383 ATH_MSG_ERROR(
"Invalid hash ID when trying to write, this should not happen");
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()) {
396 ATH_MSG_DEBUG(
"Call addOrDelete for coin " << ibc <<
" tgcHashId: " << tgcHashId <<
" size = " << mapPair.second->size());
400 ATH_MSG_ERROR(
"Invalid hash ID when trying to write, this should not happen");
406 showIdentifierHash(state);
412 std::set<IdentifierHash> hashesInAnyBC;
413 for(
unsigned int ibc = 0; ibc < NBC_HIT; ++ibc) {
416 hashesInAnyBC.insert(theseHashes.begin(), theseHashes.end());
418 ATH_MSG_DEBUG(
"Found " << hashesInAnyBC.size() <<
" hashes that must be added to AllBC container");
421 for(
const auto& tgcHashId : hashesInAnyBC) {
425 std::unique_ptr<TgcPrepDataCollection> collAllBc = std::make_unique<TgcPrepDataCollection>(tgcHashId);
427 for(
unsigned int ibc = 0; ibc < NBC_HIT; ++ibc) {
429 if( coll !=
nullptr) {
431 for(
const auto *prd : *coll) {
433 for(
auto prdAllBc : *collAllBc) {
434 if( prd->identify() == prdAllBc->identify() ){
435 prdToUpdate = prdAllBc;
443 prdAllBc->
setHashAndIndex(collAllBc->identifyHash(), collAllBc->size());
444 collAllBc->push_back( prdAllBc );
445 prdToUpdate = prdAllBc;
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");
461 ATH_MSG_DEBUG(
"Calling addOrDelete for AllBC colelction " << tgcHashId);
464 else ATH_MSG_DEBUG(
"AllBC Collection already present, no need to create it");
468 if (sizeVectorRequested != 0) {
473 for(
int iHash=0; iHash<sizeVectorRequested; iHash++) {
474 IdentifierHash
hash = requestedIdHashVect.at(iHash);
475 if(isIdentifierHashFoundInAnyTgcPrepDataContainer(state,
hash) || isIdentifierHashFoundInAnyTgcCoinDataContainer(state,
hash)) {
480 return StatusCode::SUCCESS;
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
497 status = decodeHits(state, rd, collectionMap);
506 status = decodeTracklet(state, rd, coinMap);
509 status = decodeTrackletEIFI(state, rd, coinMap);
512 status = decodeHiPt(state, rd, coinMap);
518 status = decodeInner(state, rd, coinMap);
520 status = decodeSL(state, rd, rdoColl, coinMap);
530 std::vector<std::unordered_map<IdentifierHash, std::unique_ptr<TgcPrepDataCollection> > >& collectionMap)
const
536 bool isConverted =
false;
537 bool isDuplicated =
false;
538 bool isInvalid =
false;
542 <<
" rod=" << rd.
rodId()
543 <<
" ssw=" << rd.
sswId()
544 <<
" slb=" << rd.
slbId()
545 <<
" bitpos=" << rd.
bitpos());
549 return StatusCode::FAILURE;
556 IdentifierHash tgcHashId;
557 IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
564 for(
int iOr=0; iOr<2; iOr++) {
574 if(o_found) orFlag =
true;
579 Identifier elementId;
589 bool show_warning_level =
true;
612 show_warning_level = m_show_warning_level_invalid_A09_SSW6_hit;
617 <<
"ElementID not found for "
619 <<
" rod=" << rd.
rodId()
620 <<
" ssw=" << rd.
sswId()
621 <<
" slb=" << rd.
slbId()
622 <<
" bitpos=" << rd.
bitpos()
623 <<
" orFlag=" << orFlag
629 if(m_idHelperSvc->tgcIdHelper().get_module_hash(elementId, tgcHashId)) {
631 <<
"context begin_index = " << tgcContext.
begin_index()
632 <<
" context end_index = " << tgcContext.
end_index()
633 <<
" the identifier is ");
649 <<
" ssw=" << rd.
sswId()<<
" slb=" << rd.
slbId()
650 <<
" bitpos=" << rd.
bitpos()<<
" orFlag=" << orFlag);
658 if( collectionMap[locId].
count(tgcHashId) > 0 ) {
659 ATH_MSG_DEBUG(
"Collection is already in map, will use it " << tgcHashId);
664 auto itPair = collectionMap[locId].emplace(std::make_pair(tgcHashId, std::make_unique<TgcPrepDataCollection>(tgcHashId)));
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);
671 ATH_MSG_DEBUG(
"Collection is in cache, do not need to decode " << tgcHashId);
676 collection = collectionMap[locId][tgcHashId].
get();
680 bool duplicate =
false;
681 for (
const TgcPrepData* tgcPrepData : *collection) {
695 if(!isOfflineIdOKForTgcReadoutElement(descriptor,
channelId)) {
701 std::vector<Identifier> identifierList;
709 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeHits Amg::Vector2D* hitPos is null.");
716 if(!m_idHelperSvc->tgcIdHelper().isStrip(
channelId)) {
721 if(
width<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
722 ATH_MSG_WARNING(
"decodeHits: width= " <<
width <<
" is smaller than s_cutDropPrdsWithZeroWidth= "
723 << s_cutDropPrdsWithZeroWidth<<
" "<<m_idHelperSvc->toString(
channelId));
726 double errPos =
width/sqrt(12.);
730 mat *= errPos*errPos;
741 newPrepData->
setHashAndIndex(collection->identifyHash(), collection->size());
742 collection->push_back(newPrepData);
745 if (!m_xAODKey.empty()){
746 const TgcIdHelper& id_helper = m_idHelperSvc->tgcIdHelper();
762 if(isConverted) m_nHitPRDs++;
763 else if(isDuplicated || isInvalid) m_nHitRDOs--;
765 return StatusCode::SUCCESS;
776 if( coinMap[locId].
count(tgcHashId) > 0 ) {
777 ATH_MSG_DEBUG(
"Collection is already in map, will use it " << tgcHashId);
782 auto itPair = coinMap[locId].emplace(std::make_pair(tgcHashId, std::make_unique<TgcCoinDataCollection>(tgcHashId)));
784 ATH_MSG_ERROR(
"Did not insert TGC Coin collection, this is not expected");
786 ATH_MSG_DEBUG(
"Inserted TgcCoinDataCollection into map with hash ID " << tgcHashId);
788 itPair.first->second->setIdentifier(elementId);
792 ATH_MSG_DEBUG(
"Coin collection " << tgcHashId <<
" in cache, no need to decode");
799 return coinMap[locId][tgcHashId].get();
806 std::vector< std::unordered_map<IdentifierHash, std::unique_ptr<TgcCoinDataCollection> > >& coinMap)
const
812 return StatusCode::FAILURE;
819 Identifier channelIdOut;
830 return StatusCode::SUCCESS;
839 int tmp_subMatrix = 0;
840 int tmp_position = 0;
841 found = getTrackletInfo(rd, tmp_slbId, tmp_subMatrix, tmp_position);
843 return StatusCode::SUCCESS;
845 Identifier channelIdIn;
856 return StatusCode::SUCCESS;
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)) {
865 <<
"context begin_index = " << tgcContext.
begin_index()
866 <<
" context end_index = " << tgcContext.
end_index()
867 <<
" the identifier is ");
875 if(coincollection==
nullptr) {
876 ATH_MSG_DEBUG(
"Collection is in cache, do not need to decode " << tgcHashId);
877 return StatusCode::SUCCESS;
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());
885 for (
const TgcCoinData* tgcCoinData : *coincollection) {
887 (channelIdOut==tgcCoinData->identify()) &&
888 (channelIdIn==tgcCoinData->channelIdIn()) &&
889 (trackletId==tgcCoinData->trackletId()) &&
890 (delta==tgcCoinData->delta()) &&
891 (subMatrix==tgcCoinData->sub())
894 << m_idHelperSvc->toString(channelIdIn));
895 return StatusCode::SUCCESS;
899 ATH_MSG_DEBUG(
"TGC RDO->Coindata for LowPT: " << m_idHelperSvc->toString(channelIdOut));
903 if(!isOfflineIdOKForTgcReadoutElement(descriptor_o, channelIdOut)) {
904 return StatusCode::SUCCESS;
907 int gasGap_o = m_idHelperSvc->tgcIdHelper().gasGap(channelIdOut);
908 int channel_o = m_idHelperSvc->tgcIdHelper().channel(channelIdOut);
910 if(!(
static_cast<bool> (m_idHelperSvc->tgcIdHelper().isStrip(channelIdOut)))) {
913 width_o = descriptor_o->
stripWidth(gasGap_o, channel_o);
915 if(width_o<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
916 return StatusCode::SUCCESS;
921 bool onSurface_o = descriptor_o->
surface(channelIdOut).
globalToLocal(position_o,position_o,hitPos_o);
924 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* hitPos_o is null.");
925 return StatusCode::SUCCESS;
931 if(!isOfflineIdOKForTgcReadoutElement(descriptor_i, channelIdIn)) {
932 return StatusCode::SUCCESS;
935 int gasGap_i = m_idHelperSvc->tgcIdHelper().gasGap(channelIdIn);
936 int channel_i = m_idHelperSvc->tgcIdHelper().channel(channelIdIn);
938 if(!(
static_cast<bool>(m_idHelperSvc->tgcIdHelper().isStrip(channelIdIn)))) {
941 width_i = descriptor_i->
stripWidth(gasGap_i, channel_i);
943 if(width_i<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
944 return StatusCode::SUCCESS;
949 bool onSurface_i = descriptor_i->
surface(channelIdIn).
globalToLocal(position_i,position_i,hitPos_i);
952 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* hitPos_i is null.");
953 return StatusCode::SUCCESS;
966 static_cast<int>(m_idHelperSvc->tgcIdHelper().stationPhi(channelIdOut)),
969 static_cast<bool>(m_idHelperSvc->tgcIdHelper().isStrip(channelIdOut)),
978 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
979 coincollection->push_back(newCoinData);
985 return StatusCode::SUCCESS;
990 std::vector< std::unordered_map<IdentifierHash, std::unique_ptr<TgcCoinDataCollection> > >& coinMap)
const
993 m_nTrackletEIFIRDOs++;
997 return StatusCode::FAILURE;
1005 bool isForward = (rd.
slbId()%2==0);
1014 int slot = ((rd.
slbId()/2) + (rd.
rodId()-2)*2 + 23)%24 + 1;
1017 bool isBackward =
false;
1021 isBackward = !isAside;
1022 }
else if(slot==16) {
1023 isBackward = isAside;
1027 if(isAside) isBackward = (slot%3==2);
1028 else isBackward = (slot%3!=2);
1031 isBackward = isAside;
1041 int tmpsubMatrix =
static_cast<int>(rd.
subMatrix());
1043 if(tmpsubMatrix==3) {
1045 slot== 3 || slot== 4 || slot== 5 ||
1046 slot== 6 || slot== 7 || slot== 8 ||
1047 slot==10 || slot==11 ||
1049 slot==18 || slot==19 || slot==20) {
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) {
1064 bitpos = BIT_POS_D_INPUT_ORIGIN - BIT_POS_INPUT_SIZE + 1 + BIT_POS_ASD_SIZE/4*(tmpsubMatrix*2+1);
1068 bitpos = BIT_POS_B_INPUT_ORIGIN - BIT_POS_INPUT_SIZE + (isAside ? 1 : 0) + BIT_POS_ASD_SIZE/4*(rd.
subMatrix()*2+1);
1071 bitpos = BIT_POS_A_INPUT_ORIGIN - BIT_POS_INPUT_SIZE + (isAside ? 0 : 1) + BIT_POS_ASD_SIZE/4*(rd.
subMatrix()*2+1);
1076 Identifier channelIdIn;
1085 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI OfflineID not found for "
1087 <<
" rodId=" << rd.
rodId()
1088 <<
" sswId=" << rd.
sswId()
1089 <<
" slbId=" << rd.
slbId()
1090 <<
" slbType=" << rd.
slbType()
1092 <<
" bitpos=" << bitpos
1094 <<
" isAside=" << isAside
1095 <<
" isForward=" << isForward
1097 <<
" isBackward=" << isBackward);
1098 return StatusCode::SUCCESS;
1102 Identifier elementId = m_idHelperSvc->tgcIdHelper().elementID(channelIdIn);
1105 IdentifierHash tgcHashId;
1106 IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
1107 if(m_idHelperSvc->tgcIdHelper().get_module_hash(elementId, tgcHashId)) {
1109 <<
"context begin_index = " << tgcContext.
begin_index()
1110 <<
" context end_index = " << tgcContext.
end_index()
1111 <<
" the identifier is ");
1120 if(coincollection==
nullptr) {
1121 ATH_MSG_DEBUG(
"Collection is in cache, do not need to decode " << tgcHashId);
1122 return StatusCode::SUCCESS;
1126 for (
const TgcCoinData* tgcCoinData : *coincollection) {
1128 (channelIdIn==tgcCoinData->channelIdIn()) &&
1129 (
static_cast<int>(rd.
subMatrix())==tgcCoinData->sub())) {
1131 << m_idHelperSvc->toString(channelIdIn));
1132 return StatusCode::SUCCESS;
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;
1152 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI Amg::Vector2D* hitPos is null.");
1153 return StatusCode::SUCCESS;
1158 int gasGap = m_idHelperSvc->tgcIdHelper().gasGap(channelIdIn);
1159 int channel = m_idHelperSvc->tgcIdHelper().channel(channelIdIn);
1161 double localZ = (descriptor->
transform(channelIdIn).inverse()*descriptor->
channelPos(channelIdIn)).
z();
1164 width =std::abs(stripMaxX - stripMinX);
1166 int positiveOffset = +4;
1167 if(isForward && (slot%3==2) &&
channel==28) positiveOffset = +2;
1170 width = std::abs(gangMaxZ - gangMinZ);
1180 m_idHelperSvc->tgcIdHelper().stationPhi(channelIdIn),
1186 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1187 coincollection->push_back(newCoinData);
1190 m_nTrackletEIFIPRDs++;
1191 return StatusCode::SUCCESS;
1196 std::vector< std::unordered_map<IdentifierHash, std::unique_ptr<TgcCoinDataCollection> > >& coinMap)
const
1202 return StatusCode::FAILURE;
1208 convertToRun2(rd0,tmprodId,tmpsector);
1227 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
1228 return StatusCode::SUCCESS;
1233 ATH_MSG_DEBUG(
"Invalid hitId_rdo_hipt, hitId == 0!! skip to convert this RDO to PRD");
1234 return StatusCode::SUCCESS;
1239 int slbsubMatrix = 0;
1240 bool isBackward = isBackwardBW(rd);
1241 int deltaBeforeConvert = getDeltaBeforeConvert(rd);
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};
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};
1255 std::array<int, 4> slbId_in {}, sbLoc_in{};
1257 std::array<int, 4> gasGap_i{}, channel_i{};
1258 double width_i{0.},hit_position_i{0};
1261 std::array<int, 2> gasGap_o{}, channel_o{};
1262 double width_o{0.}, hit_position_o{0.};
1270 found = getHiPtIds(rd, sswId_o, sbLoc_o, slbId_o);
1272 return StatusCode::SUCCESS;
1277 getBitPosOutWire(rd, slbsubMatrix, bitpos_o);
1279 getBitPosOutStrip(rd, slbsubMatrix, bitpos_o);
1281 for(
int i=0;
i<2;
i++) {
1283 sswId_o, sbLoc_o, bitpos_o[
i]);
1285 ATH_MSG_DEBUG(
"Failed to get OfflineID from ReadoutID for Pivot "
1286 << (rd.
isStrip() ?
"Strip" :
"Wire") <<
".");
1287 return StatusCode::SUCCESS;
1297 getBitPosInWire(rd, deltaBeforeConvert, bitpos_i, slbchannel_i, slbId_in, sbLoc_in, sswId_i, bitpos_o,
1298 slbchannel_o, slbId_o);
1300 getBitPosInStrip(rd, deltaBeforeConvert, bitpos_i, slbchannel_i, sbLoc_i, sswId_i, bitpos_o, slbchannel_o);
1302 for(
int i=0;
i<4;
i++) {
1304 (rd.
isStrip() ? sbLoc_i : sbLoc_in[
i]),
1307 ATH_MSG_DEBUG(
"Failed to get OfflineID from ReadoutID for Pivot "
1308 << (rd.
isStrip() ?
"Strip" :
"Wire") <<
".");
1309 return StatusCode::SUCCESS;
1315 ATH_MSG_DEBUG(
"TGC RDO->Coindata for HIPT: " << m_idHelperSvc->toString(channelIdOut[1]));
1317 Identifier elementId = m_idHelperSvc->tgcIdHelper().elementID(channelIdOut[1]);
1318 const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(elementId);
1324 if(coincollection==
nullptr) {
1325 ATH_MSG_DEBUG(
"Collection is in cache, do not need to decode " << tgcHashId);
1326 return StatusCode::SUCCESS;
1331 std::array<const MuonGM::TgcReadoutElement*, 2> descriptor_o{muDetMgr->
getTgcReadoutElement(channelIdOut[0]),
1333 for(
int i=0;
i<2;
i++) {
1334 if(!isOfflineIdOKForTgcReadoutElement(descriptor_o[
i], channelIdOut[
i])) {
1335 return StatusCode::SUCCESS;
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]);
1345 found = getPosAndIdWireOut(descriptor_o, channelIdOut,
1346 gasGap_o, channel_o,
1347 width_o, hit_position_o, tmp_hitPos_o,
1350 found = getPosAndIdStripOut(descriptor_o, channelIdOut,
1351 gasGap_o, channel_o,
1352 width_o, hit_position_o, tmp_hitPos_o,
1357 return StatusCode::SUCCESS;
1359 if(width_o<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
1360 return StatusCode::SUCCESS;
1364 if(!isOfflineIdOKForTgcReadoutElement(descriptor_oo, channelIdOut_tmp)) {
1365 return StatusCode::SUCCESS;
1372 std::array<const MuonGM::TgcReadoutElement*, 4> descriptor_i{muDetMgr->
getTgcReadoutElement(channelIdIn[0]),
1376 for(
int i=0;
i<4;
i++) {
1377 if(!isOfflineIdOKForTgcReadoutElement(descriptor_i[
i], channelIdIn[
i])) {
1378 return StatusCode::SUCCESS;
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]);
1387 found = getPosAndIdWireIn(descriptor_i, channelIdIn,
1388 gasGap_i, channel_i,
1389 width_i, hit_position_i, tmp_hitPos_i,
1392 found = getPosAndIdStripIn(descriptor_i, channelIdIn,
1393 gasGap_i, channel_i,
1394 width_i, hit_position_i, tmp_hitPos_i,
1399 return StatusCode::SUCCESS;
1401 if(width_i<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
1402 return StatusCode::SUCCESS;
1406 if(!isOfflineIdOKForTgcReadoutElement(descriptor_ii, channelIdIn_tmp)) {
1407 return StatusCode::SUCCESS;
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());
1418 for (
const TgcCoinData* tgcCoinData : *coincollection) {
1420 (channelIdOut_tmp==tgcCoinData->identify()) &&
1421 (channelIdIn_tmp==tgcCoinData->channelIdIn()) &&
1422 (trackletId==tgcCoinData->trackletId()) &&
1423 (delta==tgcCoinData->delta()) &&
1424 (hsub==tgcCoinData->sub()) &&
1425 (inner==tgcCoinData->inner())
1427 if(38<=trackletId && trackletId<=41) {
1432 << m_idHelperSvc->toString(channelIdOut_tmp));
1433 return StatusCode::SUCCESS;
1437 auto hitPos_o = std::make_unique< Amg::Vector2D >(tmp_hitPos_o);
1438 auto hitPos_i = std::make_unique< Amg::Vector2D >(tmp_hitPos_i);
1447 static_cast<int>(m_idHelperSvc->tgcIdHelper().stationPhi(channelIdOut_tmp)),
1450 static_cast<bool>(rd.
isStrip()),
1460 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1461 coincollection->push_back(newCoinData);
1467 return StatusCode::SUCCESS;
1472 std::vector< std::unordered_map<IdentifierHash, std::unique_ptr<TgcCoinDataCollection> > >& coinMap)
const
1478 return StatusCode::FAILURE;
1484 if(subDetectorId!=
ASIDE && subDetectorId!=
CSIDE) {
1485 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
1486 return StatusCode::SUCCESS;
1489 bool isInner = ((rd.
sector() & 4) != 0 );
1491 IdentifierHash tgcHashId;
1492 IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
1494 Identifier channelIdIn;
1495 Identifier channelIdOut;
1497 int sbLoc_o = rd.
sector() & 3;
1498 int inner = rd.
inner();
1501 int phi = 0;
bool isAside =
false;
bool isEndcap =
false;
1502 if(rd.
rodId() < 13){
1504 rd.
rodId(), sswId_o, sbLoc_o);
1510 isInner =
true;
isStrip =
false;
1521 isInner =
true;
isStrip =
true;
1530 isInner =
false;
isStrip =
false;
1536 isInner =
false;
isStrip =
true;
1546 auto hitPos_o = std::make_unique< Amg::Vector2D >(0,0);
1547 auto hitPos_i = std::make_unique< Amg::Vector2D >(0,0);
1553 int stationEta = isAside ? 1 : -1;
1554 int stationPhi =
phi;
1556 Identifier elementId = m_idHelperSvc->tgcIdHelper().elementID(
stationName, stationEta, stationPhi,
isValid);
1557 if(!
isValid || m_idHelperSvc->tgcIdHelper().get_module_hash(elementId, tgcHashId)) {
1559 <<
"context begin_index = " << tgcContext.
begin_index()
1560 <<
" context end_index = " << tgcContext.
end_index()
1561 <<
" the identifier is ");
1566 if(coincollection==
nullptr) {
1567 ATH_MSG_DEBUG(
"Collection is in cache, do not need to decode " << tgcHashId);
1568 return StatusCode::SUCCESS;
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());
1598 ATH_MSG_DEBUG(
"coincollection->push_back done (for Inner)");
1602 return StatusCode::SUCCESS;
1608 std::vector< std::unordered_map<IdentifierHash, std::unique_ptr<TgcCoinDataCollection> > >& coinMap)
const
1614 convertToRun2(rd0,tmprodId,tmpsector);
1630 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::decodeSL::Unknown subDetectorId!!");
1631 return StatusCode::SUCCESS;
1634 IdentifierHash tgcHashId;
1635 IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
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{};
1644 found = getSLIds(
false, rd, channelId_wire, index_w, chip_w, hitId_w, sub_w, sswId_w, sbLoc_w,
1645 subMatrix_w, bitpos_w);
1647 return StatusCode::SUCCESS;
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{};
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);
1658 return StatusCode::SUCCESS;
1661 ATH_MSG_DEBUG(
"TGC RDO->TgcCoindata(SL): " << m_idHelperSvc->toString(channelId_wire[1]));
1663 Identifier elementId = m_idHelperSvc->tgcIdHelper().elementID(channelId_wire[1]);
1664 if(m_idHelperSvc->tgcIdHelper().get_module_hash(elementId, tgcHashId)) {
1666 <<
"context begin_index = " << tgcContext.
begin_index()
1667 <<
" context end_index = " << tgcContext.
end_index()
1668 <<
" the identifier is ");
1676 if(coincollection==
nullptr) {
1677 ATH_MSG_DEBUG(
"Collection is in cache, do not need to decode " << tgcHashId);
1678 return StatusCode::SUCCESS;
1681 int trackletId = 2*sbLoc_w + subMatrix_w;
1682 int trackletIdStrip = 2*sbLoc_s + subMatrix_s;
1683 int roi =
static_cast<int>(rd.
roi());
1686 pt += (
static_cast<int>( rd.
coinflag() ) << 4 );
1690 bool isPositiveDeltaR = rd.
isMuplus();
1693 for (
const TgcCoinData* tgcCoinData : *coincollection) {
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())
1704 << m_idHelperSvc->toString(channelId_wire[2]));
1705 return StatusCode::SUCCESS;
1710 double width_w = 0.;
1712 double tmp_wire_z = 0.;
1713 found = getSLWireGeometry(channelId_wire, width_w, tmp_r, tmp_wire_z);
1715 return StatusCode::SUCCESS;
1717 if(width_w<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
1718 return StatusCode::SUCCESS;
1721 double tmp_eta = 0.;
1722 bool isGoodEta = getEtafromRZ(tmp_r, tmp_wire_z, tmp_eta);
1724 ATH_MSG_WARNING(
"Conversion from r and z to eta by Muon::TgcRdoToPrepDataToolMT::getEtafromRZ failed.");
1725 return StatusCode::SUCCESS;
1727 if(tmp_wire_z<0.) tmp_eta *= -1.;
1731 double width_s = 0.;
1732 double tmp_phi = 0.;
1735 return StatusCode::SUCCESS;
1737 if(width_s<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
1738 return StatusCode::SUCCESS;
1744 if(!isOfflineIdOKForTgcReadoutElement(descriptor_w2, channelId_wire[2])) {
1745 return StatusCode::SUCCESS;
1750 bool onSurface = descriptor_w2->
surface(channelId_wire[2]).
globalToLocal(tmp_gp,tmp_gp,tmp_hitPos);
1754 const Amg::Vector2D* hitPos = !onSurface ?
new Amg::Vector2D(tmp_hitPos) : getSLLocalPosition(descriptor_w2, channelId_wire[2], tmp_eta, tmp_phi);
1770 static_cast<int>(m_idHelperSvc->tgcIdHelper().stationPhi(channelId_wire[2])),
1782 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1783 coincollection->push_back(newCoinData);
1787 return StatusCode::SUCCESS;
1792 int bitpos = -BIT_POS_INPUT_SIZE +1;
1794 if(channel<0 || channel>=WT_MAP_SIZE)
return -1;
1796 if(
channel%3==0) bitpos += BIT_POS_C_INPUT_ORIGIN;
1797 else if(
channel%3==1) bitpos += BIT_POS_B_INPUT_ORIGIN;
1798 else bitpos += BIT_POS_A_INPUT_ORIGIN;
1802 if(channel<0 || channel>=ST_MAP_SIZE)
return -1;
1804 if(
channel%2==0) bitpos += BIT_POS_B_INPUT_ORIGIN;
1805 else bitpos += BIT_POS_A_INPUT_ORIGIN;
1808 if(channel<0 || channel>=WD_MAP_SIZE)
return -1;
1810 if(
channel%2==0) bitpos += BIT_POS_B_INPUT_ORIGIN;
1811 else bitpos += BIT_POS_A_INPUT_ORIGIN;
1821 if( (bitpos<=BIT_POS_A_INPUT_ORIGIN) && (bitpos>BIT_POS_A_INPUT_ORIGIN-BIT_POS_INPUT_SIZE))
input = 2;
1822 else if((bitpos<=BIT_POS_B_INPUT_ORIGIN) && (bitpos>BIT_POS_B_INPUT_ORIGIN-BIT_POS_INPUT_SIZE))
input = 1;
1823 else if((bitpos<=BIT_POS_C_INPUT_ORIGIN) && (bitpos>BIT_POS_C_INPUT_ORIGIN-BIT_POS_INPUT_SIZE))
input = 0;
1828 int channel = 1-BIT_POS_INPUT_SIZE;
1832 else channel += BIT_POS_C_INPUT_ORIGIN;
1839 else channel += BIT_POS_B_INPUT_ORIGIN;
1848 double&
r,
double&
phi,
double&
eta)
1850 if((fabs(
x)<DBL_MIN) && (fabs(
y)<DBL_MIN))
return false;
1852 r = sqrt(
x*
x +
y*
y);
1855 double z_tmp = fabs(
z);
1856 eta = fabs(atan2(
r,z_tmp));
1875 double r_tmp = fabs(
r);
1876 double z_tmp = fabs(
z);
1878 if((r_tmp<DBL_MIN) && (z_tmp<DBL_MIN))
return false;
1880 eta = fabs(atan2(r_tmp,z_tmp));
1887 const std::vector<const TgcRdo*>& rdoCollVec,
1891 (
std::find (rdoCollVec.begin(), rdoCollVec.end(), rdoColl)
1892 != rdoCollVec.end()) ||
1893 (
std::find (decodedRdoCollVec.begin(), decodedRdoCollVec.end(), rdoColl)
1894 != decodedRdoCollVec.end());
1898 IdentifierHash tgcHashId)
1901 (
std::find (requestedIdHashVect.begin(), requestedIdHashVect.end(), tgcHashId)
1902 != requestedIdHashVect.end());
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++) {
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));
1934 (
const State& state,
const IdentifierHash Hash)
1936 for(
int ibc=0; ibc < NBC_HIT+1; ibc++) {
1945 (
const State& state,
const IdentifierHash Hash)
1947 for(
int ibc=0; ibc<NBC_TRIG; ibc++) {
1956 int& tmp_slbId,
int& tmp_subMatrix,
int& tmp_position)
const
1959 if(tmp_subMatrix!=0 && tmp_subMatrix!=1) {
1960 ATH_MSG_DEBUG(
"getTrackletInfo: subMatrix " << tmp_subMatrix <<
" is invalid.");
1964 int tmp_sswId = rd.
sswId();
1965 tmp_slbId = rd.
slbId();
1968 int tmp_position_delta = tmp_position + rd.
delta();
1969 int tmp_slbType = rd.
slbType();
1971 if(tmp_position_delta>=BIT_POS_INPUT_SIZE) {
1972 tmp_position = tmp_position_delta-BIT_POS_INPUT_SIZE;
1973 if(tmp_subMatrix==1) {
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);
1980 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId+1 <<
" doesn't exist for FWD!! (upper edge SLB of FWD:sbLoc3,11)");
1984 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId+1 <<
" doesn't exist for EWD!! (upper edge SLB of EWD:sbLoc9)");
1994 }
else if(tmp_position_delta<0) {
1995 tmp_position = tmp_position_delta+BIT_POS_INPUT_SIZE;
1996 if(tmp_subMatrix==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);
2003 if(tmp_position_delta==-1) {
2006 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId-1 <<
" doesn't exist for FWD!! (bottom edge SLB of FWD:sbLoc0,8)");
2011 if(tmp_position_delta==-1) {
2014 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId-1 <<
" doesn't exist for EWD!! (bottom edge SLB of EWD:sbLoc0)");
2026 tmp_position = tmp_position_delta;
2034 int RoiRow =
static_cast<int>(rd.
roi()/4);
2040 int RoiRow = getRoiRow(rd);
2043 (RoiRow== 3 || RoiRow== 4 ||
2044 RoiRow== 7 || RoiRow== 8 ||
2045 RoiRow==11 || RoiRow==12 ||
2046 RoiRow==23 || RoiRow==24
2054 std::array<int, 2>& bitpos_o) {
2056 if((rd.
hitId()%2)==1) {
2058 if((rd.
hsub())==0) {
2059 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_R_CH15;
2060 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_R_CH08;
2061 }
else if((rd.
hsub())==1) {
2062 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_R_CH07;
2063 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_R_CH00;
2067 if((rd.
hsub())==0) {
2068 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH15;
2069 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH08;
2070 }
else if((rd.
hsub())==1) {
2071 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
2072 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH00;
2086 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH05;
2087 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH00;
2088 }
else if((rd.
chip()==3) && (rd.
hitId()==6) && (rd.
hsub()==1)) {
2089 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
2090 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
2094 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_R_CH12;
2095 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_R_CH08;
2096 }
else if((rd.
chip()==1) && (rd.
hitId()==2) && (rd.
hsub()==1)) {
2097 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
2098 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH03;
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,
2111 const std::array<int, 2>& bitpos_o,
2112 std::array<int, 2>& slbchannel_o,
const int slbId_o)
const {
2114 const int NUM_SLBID_SBLOC_OFFSET_WT = 8;
2118 int rdochIn_max = 0;
2119 int rdochIn_min = 0;
2131 int tmp_rdochannel_i = 0;
2132 int tmp_rdochannel_i2 = 0;
2133 for(
int i=0;
i<2;
i++) {
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;
2155 tmp_rdochannel_i2 = (tmp_rdochannel_i/3)*3 + 2;
2157 tmp_rdochannel_i2 = ((tmp_rdochannel_i + 1)/3)*3 - 1;
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;
2166 slbId_in[
i] = tmp_rdochannel_i /WT_MAP_SIZE;
2167 slbId_in[
i+2] = tmp_rdochannel_i2/WT_MAP_SIZE;
2169 sbLoc_in[
i] = slbId_in[
i];
2170 sbLoc_in[
i+2] = slbId_in[
i+2];
2174 sbLoc_in[
i] += NUM_SLBID_SBLOC_OFFSET_WT;
2175 sbLoc_in[
i+2] += NUM_SLBID_SBLOC_OFFSET_WT;
2178 slbchannel_i[
i] = tmp_rdochannel_i %WT_MAP_SIZE;
2179 slbchannel_i[
i+2] = tmp_rdochannel_i2%WT_MAP_SIZE;
2186 sswId_i =
static_cast<int>(rd.
sector()/2);
2194 std::array<int,2 >& bitpos_o) {
2196 if((rd.
hitId()%2)==1) {
2198 if((rd.
hsub())==0) {
2199 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH15;
2200 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH08;
2201 }
else if((rd.
hsub())==1) {
2202 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH07;
2203 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH00;
2207 if((rd.
hsub())==0) {
2208 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH15;
2209 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH08;
2210 }
else if((rd.
hsub())==1) {
2211 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH07;
2212 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH00;
2218 const int deltaBeforeConvert,
2219 std::array<int, 4>& bitpos_i,
2220 std::array<int, 4>& slbchannel_i,
2223 const std::array<int,2>& bitpos_o,
2224 std::array<int,2>& slbchannel_o)
const {
2228 int rdochIn_max = ST_MAP_SIZE-1;
2229 int rdochIn_min = 0;
2234 }
else if(rd.
chip()==1) {
2240 }
else if(rd.
chip()==1) {
2245 for(
int i=0;
i<2;
i++) {
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;
2255 slbchannel_i[
i+2] = slbchannel_i[
i] + 1;
2257 slbchannel_i[
i+2] = slbchannel_i[
i] - 1;
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;
2271 sswId_i =
static_cast<int>(rd.
sector()/2);
2281 std::array<int, 3>& bitpos_w)
const
2291 int RoiRow = getRoiRow(rd);
2294 if(RoiRow==0 && !isForward) {
2296 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH05;
2297 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
2298 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH00;
2299 }
else if(RoiRow==36 && !isForward) {
2301 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
2302 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
2303 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH04;
2304 }
else if(RoiRow==0 && isForward) {
2306 bitpos_w[0] = BIT_POS_B_INPUT_LARGE_R_CH12;
2307 bitpos_w[1] = BIT_POS_A_INPUT_LARGE_R_CH12;
2308 bitpos_w[2] = BIT_POS_A_INPUT_LARGE_R_CH08;
2309 }
else if(RoiRow==15 && isForward) {
2311 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
2312 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
2313 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH03;
2315 if((hitId_w%2)==0) {
2318 bitpos_w[0] = BIT_POS_B_INPUT_LARGE_R_CH15;
2319 bitpos_w[1] = BIT_POS_A_INPUT_LARGE_R_CH12;
2320 bitpos_w[2] = BIT_POS_A_INPUT_LARGE_R_CH08;
2321 }
else if(sub_w==1) {
2322 bitpos_w[0] = BIT_POS_B_INPUT_LARGE_R_CH07;
2323 bitpos_w[1] = BIT_POS_A_INPUT_LARGE_R_CH04;
2324 bitpos_w[2] = BIT_POS_A_INPUT_LARGE_R_CH00;
2329 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH15;
2330 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH12;
2331 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH08;
2332 }
else if(sub_w==1) {
2333 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
2334 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
2335 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH00;
2344 std::array<int, 3>& bitpos_s)
2351 if((hitId_s%2)==0) {
2354 bitpos_s[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH15;
2355 bitpos_s[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH12;
2356 bitpos_s[2] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH08;
2357 }
else if(sub_s==1) {
2358 bitpos_s[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH07;
2359 bitpos_s[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH04;
2360 bitpos_s[2] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH00;
2362 }
else if((hitId_s%2)==1) {
2365 bitpos_s[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH15;
2366 bitpos_s[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH12;
2367 bitpos_s[2] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH08;
2368 }
else if(sub_s==1) {
2369 bitpos_s[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH07;
2370 bitpos_s[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH04;
2371 bitpos_s[2] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH00;
2378 int deltaBeforeConvert = 0;
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;
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;
2406 return deltaBeforeConvert;
2411 bool isBackward =
false;
2434 double& width_wire,
double& r_wire,
double& z_wire)
const
2438 std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_w{muDetMgr->
getTgcReadoutElement(channelId_wire[0]),
2441 for(
int i=0;
i<3;
i++) {
2442 if(!isOfflineIdOKForTgcReadoutElement(descriptor_w[
i], channelId_wire[
i])) {
2449 bool onSurface_w = descriptor_w[2]->surface(channelId_wire[2]).globalToLocal(position_w,position_w,loc_hitPos_w);
2451 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getSLWireGeometry Amg::Vector2D* loc_hitPos_w is null.");
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]);
2462 std::array<double,3> tmp_r_w{}, tmp_phi_w{}, tmp_eta_w{};
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) {
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!!");
2474 double half_width = descriptor_w[
i]->gangRadialLength(gasGap_w[
i], channel_w[
i])/2.;
2475 if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) {
2480 tmp_r_w[0] += half_width;
2482 tmp_r_w[2] -= half_width;
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!!");
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.;
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.;
2506 const bool isBackward,
const bool isAside,
2507 double& width_strip,
double& theta_strip)
const
2511 std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_s{muDetMgr->
getTgcReadoutElement(channelId_strip[0]),
2514 for(
int i=0;
i<3;
i++) {
2515 if(!isOfflineIdOKForTgcReadoutElement(descriptor_s[
i], channelId_strip[
i])) {
2522 bool onSurface_s = descriptor_s[1]->surface(channelId_strip[1]).globalToLocal(position_s,position_s,loc_hitPos_s);
2524 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getSLStripGeometry Amg::Vector2D* loc_hitPos_s is null.");
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]);
2536 for(
int i=0;
i<3;
i+=2) {
2537 localPos[
i] = descriptor_s[
i]->transform(channelId_strip[
i]).inverse()
2538 *descriptor_s[
i]->channelPos(channelId_strip[
i]);
2541 bool flag_reverse =
false;
2542 std::array<int, 2> index_strip{};
2546 index_strip[0] = 2; index_strip[1] = 0; flag_reverse =
true;
2548 index_strip[0] = 0; index_strip[1] = 2; flag_reverse =
false;
2552 index_strip[0] = 0; index_strip[1] = 2; flag_reverse =
true;
2554 index_strip[0] = 2; index_strip[1] = 0; flag_reverse =
false;
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.;
2569 int index_strip_gp = 0;
2570 if(!isBackward) index_strip_gp = 0;
2571 else index_strip_gp = 2;
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());
2581 const std::array<Identifier, 2>& channelIdOut,
2582 const std::array<int, 2>& gasGap_o,
2583 const std::array<int, 2>& channel_o,
2585 double& hit_position_o,
2587 Identifier& channelIdOut_tmp)
const
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 {};
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!!");
2602 double half_width = descriptor_o[
i]->gangRadialLength(gasGap_o[
i], channel_o[
i])/2.;
2603 if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) {
2606 if(
i==0) tmp_r_o[0] += half_width;
2607 else tmp_r_o[1] -= half_width;
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!!");
2617 width_o = tmp_r_o[0] - tmp_r_o[1];
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);
2625 bool onSurface_o = descriptor_o[1]->surface(channelIdOut[1]).globalToLocal(position_out,position_out,loc_hitPos_o);
2627 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireOut Amg::Vector2D* loc_hitPos_o is null.");
2632 channelIdOut_tmp = channelIdOut[1];
2638 const std::array<Identifier, 2>& channelIdOut,
2639 const std::array<int, 2>& gasGap_o,
2640 const std::array<int, 2>& channel_o,
2642 double& hit_position_o,
2644 Identifier& channelIdOut_tmp,
2645 const bool isBackward,
const bool isAside)
const
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]);
2654 std::array<int, 3>
index{};
2655 bool flag_reverse =
false;
2659 index[0] = 1;
index[1] = 0; flag_reverse =
true;
2661 index[0] = 0;
index[1] = 1; flag_reverse =
false;
2666 index[0] = 0;
index[1] = 1; flag_reverse =
true;
2668 index[0] = 1;
index[1] = 0; flag_reverse =
false;
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;
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;
2685 bool onSurface_o = descriptor_o[1]->surface(channelIdOut[1]).globalToLocal(position_out,position_out,loc_hitPos_o);
2687 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripOut Amg::Vector2D* loc_hitPos_o is null.");
2692 channelIdOut_tmp = channelIdOut[
index[2]];
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,
2703 Identifier& channelIdIn_tmp)
const
2706 int flag_boundary_i = 0;
2707 if(descriptor_i[1]->chamberType()==descriptor_i[3]->chamberType()) {
2709 if(gasGap_i[1]==gasGap_i[3]) {
2710 flag_boundary_i = 1;
2712 flag_boundary_i = 3;
2714 }
else if(descriptor_i[0]->chamberType()==descriptor_i[2]->chamberType()) {
2716 if(gasGap_i[0]==gasGap_i[2]) {
2717 flag_boundary_i = 0;
2719 flag_boundary_i = 2;
2722 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::ROI has 3 readout elements!!");
2726 channelIdIn_tmp = channelIdIn[flag_boundary_i];
2730 if(!isOfflineIdOKForTgcReadoutElement(descriptor_iw, channelIdIn_tmp)) {
2734 std::array<double, 3> tmp_r_i{}, tmp_phi_i{}, tmp_eta_i{};
2736 std::array<Amg::Vector3D, 3> position_i {descriptor_i[0]->channelPos(channelIdIn[0]),
2737 descriptor_i[1]->channelPos(channelIdIn[1]),
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]);
2744 if(!flag_getrphi_i) {
2745 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::failed to getRPhiEtaIn!!");
2751 double half_width = descriptor_i[
i]->gangRadialLength(gasGap_i[
i], channel_i[
i])/2.;
2752 if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) {
2755 if(
i==0) tmp_r_i[0] += half_width;
2756 else tmp_r_i[1] -= half_width;
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]);
2761 if(!flag_geteta_i || !flag_getr_i) {
2762 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::failed to getRIn" <<
i <<
" on L3!!");
2768 width_i = tmp_r_i[0] - tmp_r_i[1];
2770 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::minus value width_i = " << width_i);
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) {
2780 if((flag_boundary_i%2)==1) {
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.;
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.;
2791 tmp_hitPos_i[
Trk::locX] = hit_position_i;
2795 bool onSurface_i = descriptor_i[1]->surface(channelIdIn[1]).globalToLocal(position_in,position_in,loc_hitPos_i);
2797 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireIn Amg::Vector2D* loc_hitPos_i is null.");
2807 const std::array<Identifier, 4>& channelIdIn,
2808 const std::array<int, 4>& gasGap_i,
2809 const std::array<int, 4>& channel_i,
2811 double& hit_position_i,
2813 Identifier& channelIdIn_tmp,
2814 const bool isBackward,
const bool isAside)
const
2819 for(
int i=0;
i<4;
i++) {
2820 if(gasGap_i[
i]==3) {
2825 if(flag_isL3<0 || flag_isL3>=4) {
2826 ATH_MSG_DEBUG(
"getPosAndIdStripIn: Any bitpos is not at Layer3!");
2830 channelIdIn_tmp = channelIdIn[flag_isL3];
2834 if(!isOfflineIdOKForTgcReadoutElement(descriptor_is, channelIdIn_tmp)) {
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++) {
2842 position_is[
i] = descriptor_i[
i]->channelPos(channelIdIn[
i]);
2844 position_is[
i] = descriptor_is->
channelPos(channelIdIn_tmp);
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!!");
2854 std::array<int, 2>
index{};
2855 bool flag_reverse =
false;
2858 index[0] = 1;
index[1] = 0; flag_reverse =
true;
2860 index[0] = 0;
index[1] = 1; flag_reverse =
false;
2864 index[0] = 0;
index[1] = 1; flag_reverse =
true;
2866 index[0] = 1;
index[1] = 0; flag_reverse =
false;
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]);
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;
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;
2887 bool onSurface_i = descriptor_i[1]->surface(channelIdIn[1]).globalToLocal(position_in,position_in,loc_hitPos_i);
2889 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripIn Amg::Vector2D* loc_hitPos_i is null.");
2907 int chip =
static_cast<int>(rd.
chip());
2908 int hitId =
static_cast<int>(rd.
hitId());
2913 ATH_MSG_DEBUG(
"Failed to get SimHighPtID from RDOHighPtID for Pivot "
2914 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2920 convertToRun2(rd,tmprodId,tmpsector);
2927 chip, hitId, rd.
hsub());
2932 chip, hitId, rd.
hsub());
2936 ATH_MSG_DEBUG(
"Failed to get offlineID from HighPtID for Pivot "
2937 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2941 std::array<int, 3> dummy_i{};
2944 ATH_MSG_DEBUG(
"Failed to get ReadoutID from OfflineID for Pivot "
2945 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2949 std::array<int, 2> i_o{};
2950 std::array<bool, 2> b_o{
false,
false};
2959 ATH_MSG_DEBUG(
"Failed to get SLBID from ReadoutID for Pivot "
2960 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2969 int&
index,
int& chip,
int& hitId,
int& sub,
int& sswId,
int& sbLoc,
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
2991 << (!
isStrip ?
"Wire" :
"Strip"));
3001 ATH_MSG_DEBUG(
"Failed to get SimHighPtID from RDOHighPtID for "
3002 << (!
isStrip ?
"Wire" :
"Strip"));
3006 Identifier offlineId;
3019 << (!
isStrip ?
"Wire" :
"Strip"));
3025 std::array<int, 3> dummy_i{};
3034 << (!
isStrip ?
"Wire" :
"Strip"));
3041 bool exist_hipt_s = getSbLocOfEndcapStripBoundaryFromHiPt(rd, sbLoc, rdoColl, index_w, chip_w, hitId_w, sub_w);
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!!");
3053 getBitPosWire(rd, hitId, sub, subMatrix, bitpos);
3055 getBitPosStrip(hitId, sub, subMatrix, bitpos);
3058 for(
int i=0;
i<3;
i++) {
3059 if(
i==1 && (!
isStrip || !isBoundary))
continue;
3069 << (!
isStrip ?
"Wire" :
"Strip"));
3072 <<
", rodId = " << rd.
rodId()
3073 <<
", sswId = " << sswId
3074 <<
", slbId = " << sbLoc
3075 <<
", bitpos_" << (!
isStrip ?
"w" :
"s")
3076 <<
"[" <<
i <<
"] = " << bitpos[
i]);
3088 const int index_w,
const int chip_w,
const int hitId_w,
const int sub_w)
const
3096 bool exist_hipt_s =
false;
3099 int trackletIdStripFirst{-1}, trackletIdStripSecond{-1}, trackletIdStripThird{-1};
3100 getEndcapStripCandidateTrackletIds(
static_cast<int>(rd.
roi()), trackletIdStripFirst,
3101 trackletIdStripSecond, trackletIdStripThird);
3108 convertToRun2(rdH0,tmprodId,tmpsector);
3110 rdH0->subDetectorId(),
3136 int sswId_o{0}, sbLoc_o{0}, slbId_o{0};
3137 bool found = getHiPtIds(rdH, sswId_o, sbLoc_o, slbId_o);
3143 int slbsubMatrix = 0;
3144 std::array<int, 2> bitpos_o{};
3145 getBitPosOutStrip(rdH, slbsubMatrix, bitpos_o);
3148 int trackletIdStrip = 2*sbLoc_o + slbsubMatrix;
3151 if(trackletIdStrip!=trackletIdStripFirst &&
3152 trackletIdStrip!=trackletIdStripSecond &&
3153 trackletIdStrip!=trackletIdStripThird)
continue;
3156 if(exist_hipt_s && trackletIdStrip==trackletIdStripThird)
continue;
3159 int index_w_tmp = index_w;
3160 int chip_w_tmp = chip_w;
3161 int hitId_w_tmp = hitId_w;
3169 ATH_MSG_DEBUG(
"Failed to get RDOHighPtID from SimHighPtID for Wire");
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());
3189 ATH_MSG_DEBUG(
"Failed to get ROINumber from HighPtID for Strip");
3195 exist_hipt_s =
true;
3196 if(trackletIdStrip==trackletIdStripFirst)
break;
3201 return exist_hipt_s;
3206 const int index_w,
const int chip_w,
3207 const int hitId_w,
const int sub_w)
const
3215 bool exist_tracklet_s =
false;
3218 int trackletIdStripFirst{-1}, trackletIdStripSecond{-1}, trackletIdStripThird{-1};
3219 getEndcapStripCandidateTrackletIds(
static_cast<int>(rd.
roi()), trackletIdStripFirst,
3220 trackletIdStripSecond, trackletIdStripThird);
3226 uint16_t tmprodId{0}, tmpsector{0};
3227 convertToRun2(rdS0,tmprodId,tmpsector);
3229 rdS0->subDetectorId(),
3241 bool isForward_s = (rdS.
sswId()==7);
3242 if(isForward_s)
continue;
3253 int trackletIdStrip =
static_cast<int>(2*rdS.
slbId()+rdS.
subMatrix());
3254 if(trackletIdStrip!=trackletIdStripFirst &&
3255 trackletIdStrip!=trackletIdStripSecond &&
3256 trackletIdStrip!=trackletIdStripThird)
continue;
3259 if(exist_tracklet_s && trackletIdStrip==trackletIdStripThird)
continue;
3261 Identifier offlineId;
3266 ATH_MSG_DEBUG(
"Failed to get OfflineID from LowPtCoincidenceID for Strip");
3270 std::array<int, 7>
i{};
3271 std::array<bool, 2>
b{};
3277 ATH_MSG_DEBUG(
"Failed to get HighPtID from OfflineID for Strip");
3282 int index_w_tmp = index_w;
3283 int chip_w_tmp = chip_w;
3284 int hitId_w_tmp = hitId_w;
3291 ATH_MSG_DEBUG(
"Failed to get RDOHighPtID from SimHighPtID for Wire");
3301 ATH_MSG_DEBUG(
"Failed to get RDOHighPtID from SimHighPtID for Strip");
3316 ATH_MSG_DEBUG(
"Failed to get ROINumber from HighPtID for Strip");
3321 sbLoc = rdS.
slbId();
3322 exist_tracklet_s =
true;
3323 if(trackletIdStrip==trackletIdStripFirst)
break;
3328 return exist_tracklet_s;
3332 int &trackletIdStripSecond,
int &trackletIdStripThird) {
3333 constexpr
int T9SscMax = 2;
3334 constexpr
int T8SscMax = 4;
3335 constexpr
int T7SscMax = 6;
3336 constexpr
int T6SscMax = 12;
3337 constexpr
int T5SscMax = 18;
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;
3348 int ssc = (roi+4)/8;
3349 int halfSsc = (roi%4)/2;
3351 if( ssc< T9SscMax) {
3352 trackletIdStripFirst = T9Offset + halfSsc;
3353 trackletIdStripSecond = -1;
3354 trackletIdStripThird = -1;
3355 }
else if(ssc==T9SscMax) {
3356 trackletIdStripFirst = T8Offset + halfSsc;
3357 trackletIdStripSecond = T9Offset + halfSsc;
3358 trackletIdStripThird = -1;
3359 }
else if(ssc< T8SscMax) {
3360 trackletIdStripFirst = T8Offset + halfSsc;
3361 trackletIdStripSecond = -1;
3362 trackletIdStripThird = -1;
3363 }
else if(ssc==T8SscMax) {
3364 trackletIdStripFirst = T7Offset + halfSsc;
3365 trackletIdStripSecond = T8Offset + halfSsc;
3366 trackletIdStripThird = -1;
3367 }
else if(ssc< T7SscMax) {
3368 trackletIdStripFirst = T7Offset + halfSsc;
3369 trackletIdStripSecond = -1;
3370 trackletIdStripThird = -1;
3371 }
else if(ssc==T7SscMax) {
3372 trackletIdStripFirst = T6Offset + halfSsc;
3373 trackletIdStripSecond = T7Offset + halfSsc;
3374 trackletIdStripThird = T5Offset + halfSsc;
3375 }
else if(ssc< T6SscMax) {
3376 trackletIdStripFirst = T6Offset + halfSsc;
3377 trackletIdStripSecond = T5Offset + halfSsc;
3378 trackletIdStripThird = -1;
3379 }
else if(ssc==T6SscMax) {
3380 trackletIdStripFirst = T6Offset + halfSsc;
3381 trackletIdStripSecond = T5Offset + halfSsc;
3382 trackletIdStripThird = -1;
3383 }
else if(ssc<=T5SscMax) {
3384 trackletIdStripFirst = T5Offset + halfSsc;
3385 trackletIdStripSecond = T6Offset + halfSsc;
3386 trackletIdStripThird = -1;
3388 trackletIdStripFirst = -1;
3389 trackletIdStripSecond = -1;
3390 trackletIdStripThird = -1;
3397 if (m_cablingInfo.isValid()) {
3398 return m_cablingInfo.ptr();
3403 if (TgcCabGet.retrieve().isFailure()) {
3410 if (TgcCabGet->giveCabling(cinfo.
m_tgcCabling).isFailure()) {
3411 ATH_MSG_ERROR(
"Could not get ITGCcablingSvc from Server!" );
3418 unsigned int hashId_max = m_idHelperSvc->tgcIdHelper().module_hash_max();
3420 IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
3421 Identifier elementId;
3422 int subDetectorId = 0;
3425 for(
unsigned int hashId=0; hashId<hashId_max; hashId++) {
3426 IdentifierHash
hash(hashId);
3427 m_idHelperSvc->tgcIdHelper().get_id(
hash, elementId, &tgcContext);
3438 m_cablingInfo.set (std::move (cinfo));
3439 return m_cablingInfo.ptr();
3443 const Identifier identify,
3446 if(!readout)
return nullptr;
3449 constexpr
double length = 100.;
3450 constexpr
unsigned int nRep = 10;
3451 constexpr
double dRAccuracy = 1.0E-20;
3452 constexpr
double maxLocR = 10000.;
3456 for(
unsigned int iRep=0; iRep<nRep; iRep++) {
3462 double glob_eta_c = glob_hitPos_c.eta();
3463 double glob_phi_c = glob_hitPos_c.phi();
3467 double dR = std::hypot(vector[0], vector[1]);
3482 matrix(0,0) = glob_hitPos_w.eta() - glob_eta_c;
3484 matrix(0,1) = glob_hitPos_s.eta() - glob_eta_c;
3487 bool invertible =
matrix.determinant();