9 #include "GaudiKernel/ThreadLocalContext.h"
25 : base_class(
t,
n,
p) {}
33 m_outputprepdataKeys.resize(NBC_HIT+1);
34 for (
int ibc=0; ibc < NBC_HIT+1; ibc++) {
36 std::ostringstream location;
37 location << m_outputCollectionLocation.value()
41 << (
bcTag==(NBC_HIT+1) ?
"AllBCs" :
"");
42 m_outputprepdataKeys.at(ibc) = location.str();
45 m_outputCoinKeys.resize(NBC_TRIG);
46 for (
int ibc=0; ibc < NBC_TRIG; ibc++) {
48 std::ostringstream location;
49 location << m_outputCoinCollectionLocation.value()
53 m_outputCoinKeys.at(ibc) = location.str();
57 ATH_CHECK(m_outputprepdataKeys.initialize());
61 ATH_CHECK( m_rdoContainerKey.initialize() );
66 ATH_MSG_INFO(
"MuonTGC_CablingSvc not yet retrieved; postpone TGCcabling initialization at first event.");
70 if (not m_prdContainerCacheKeyStr.empty()) {
71 m_prdContainerCacheKeys.resize(NBC_HIT+1);
72 for (
int ibc=0; ibc < NBC_HIT+1; ibc++) {
74 std::ostringstream location;
75 location << m_prdContainerCacheKeyStr.value()
79 << (
bcTag==(NBC_HIT+1) ?
"AllBCs" :
"");
80 m_prdContainerCacheKeys.at(ibc) = location.str();
85 if (not m_coinContainerCacheKeyStr.empty()){
86 m_coinContainerCacheKeys.resize(NBC_TRIG);
87 for (
int ibc=0; ibc < NBC_TRIG; ibc++) {
89 std::ostringstream location;
90 location << m_coinContainerCacheKeyStr.value()
94 m_coinContainerCacheKeys.at(ibc) = location.str();
100 ATH_CHECK( m_prdContainerCacheKeys.initialize( not m_prdContainerCacheKeyStr.empty() ) );
101 ATH_CHECK( m_coinContainerCacheKeys.initialize( not m_coinContainerCacheKeyStr.empty() ) );
103 ATH_CHECK(m_xAODKey.initialize(!m_xAODKey.empty()));
104 return StatusCode::SUCCESS;
112 "Hit: " << m_nHitRDOs <<
"->" << m_nHitPRDs <<
", " <<
113 "Tracklet: " << m_nTrackletRDOs <<
"->" << m_nTrackletPRDs <<
", " <<
114 "TrackletEIFI: " << m_nTrackletEIFIRDOs <<
"->" << m_nTrackletEIFIPRDs <<
", " <<
115 "HiPt: " << m_nHiPtRDOs <<
"->" << m_nHiPtPRDs <<
", " <<
116 "SL: " << m_nSLRDOs <<
"->" << m_nSLPRDs <<
"]");
124 return StatusCode::FAILURE;
126 template<
class ContType,
class CollType>
128 std::vector<std::unique_ptr<CollType>>&& coll)
const {
129 for (std::unique_ptr<CollType>& toMove : coll) {
130 if (!toMove)
continue;
131 const IdentifierHash
hash = toMove->identifyHash();
132 auto lock = container.getWriteHandle(
hash);
133 if(!lock.alreadyPresent()) {
134 ATH_CHECK(lock.addOrDelete(std::move(toMove)));
137 return StatusCode::SUCCESS;
141 if (!m_xAODKey.empty()){
144 std::make_unique<xAOD::TgcStripAuxContainer>()));
147 return setupState(ctx, state);
152 const unsigned hashMax = m_idHelperSvc->tgcIdHelper().module_hash_max();
154 for(
unsigned int ibc=0; ibc < NBC_HIT+1; ibc++) {
158 const bool externalCachePRD = m_prdContainerCacheKeys.size()>ibc &&
159 !m_prdContainerCacheKeys[ibc].key().empty();
160 if (!externalCachePRD) {
162 ATH_CHECK(handle.
record(std::make_unique<TgcPrepDataContainer>(hashMax)));
163 ATH_MSG_DEBUG(
"TGC PrepData Container recorded in StoreGate with key " << m_outputprepdataKeys[ibc].
key());
172 ATH_CHECK(handle.
record(std::make_unique<Muon::TgcPrepDataContainer>(update.ptr())));
175 ATH_MSG_DEBUG(
"Created container using cache for " << m_prdContainerCacheKeys[ibc].
key());
181 for (
unsigned int ibc=0; ibc < NBC_TRIG; ibc++) {
185 const bool externalCacheCoin = m_coinContainerCacheKeys.size()>ibc &&
186 !m_coinContainerCacheKeys[ibc].key().empty();
187 if(!externalCacheCoin) {
189 ATH_CHECK(handle.
record(std::make_unique<TgcCoinDataContainer>(hashMax)));
194 ATH_CHECK(handle.
record(std::make_unique<TgcCoinDataContainer>(update.ptr())));
195 ATH_MSG_DEBUG(
"Created container using cache for " << m_coinContainerCacheKeys[ibc].
key());
208 return StatusCode::SUCCESS;
211 const std::vector<IdentifierHash>& requestedIdHashVect)
const {
217 if (!m_xAODKey.empty()) {
219 ATH_CHECK(xAODHandle.record(std::make_unique<xAOD::TgcStripContainer>(),
220 std::make_unique<xAOD::TgcStripAuxContainer>()));
223 int sizeVectorRequested = requestedIdHashVect.size();
224 ATH_MSG_DEBUG(
"decode for " << sizeVectorRequested <<
" offline collections called");
228 return StatusCode::FAILURE;
230 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
232 std::set<const TgcRdo*> decodedRdoCollVec{}, rdoCollVec{};
233 std::vector<bool> decodedOnlineId (cinfo->
m_MAX_N_ROD,
false);
237 ATH_MSG_DEBUG(
"Stored empty container. Decoding TGC RDO into TGC PrepRawData is switched off");
238 return StatusCode::SUCCESS;
248 if(rdoContainer->empty()) {
250 ATH_MSG_DEBUG(
"Empty rdo container - no tgc rdo in this event");
251 return StatusCode::SUCCESS;
254 ATH_MSG_DEBUG(
"Not empty rdo container in this event, the container size is " << rdoContainer->size());
257 if(sizeVectorRequested!=0) {
258 unsigned int nRdo = 0;
259 for (IdentifierHash offlineCollHash : requestedIdHashVect) {
262 if(decodedOnlineId.at(onlineId)) {
263 ATH_MSG_DEBUG(
"The ROB with onlineId " << onlineId <<
" which contains hash "
264 <<
static_cast<unsigned int>(offlineCollHash)
265 <<
" is already decoded and skipped");
269 decodedOnlineId.at(onlineId) =
true;
271 for(
const TgcRdo* rdoColl : *rdoContainer) {
272 if(rdoColl->identify()==onlineId) {
273 if(!decodedRdoCollVec.count(rdoColl)) {
274 rdoCollVec.insert(rdoColl);
285 if(sizeVectorRequested!=0) {
289 for (
const TgcRdo* rdo : rdoCollVec) {
294 if(!cinfo->
m_tgcCabling->getElementIDfromReadoutID(offlineId, rd->subDetectorId(),
295 rd->rodId(), rd->sswId(), rd->slbId(),
299 const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(offlineId);
300 if (
std::find(requestedIdHashVect.begin(), requestedIdHashVect.end(), tgcHashId) == requestedIdHashVect.end()){
303 selectDecoder(state,*rd, rdo);
305 decodedRdoCollVec.insert(rdo);
309 for(
const TgcRdo* rdoColl : *rdoContainer) {
310 if (rdoColl->empty() || decodedRdoCollVec.count(rdoColl) || rdoCollVec.count(rdoColl)) {
313 ATH_MSG_DEBUG(
" Number of RawData in this rdo " << rdoColl->size());
315 selectDecoder(state,*rd, rdoColl);
317 decodedRdoCollVec.insert(rdoColl);
321 std::set<IdentifierHash> hashesInAnyBC;
322 for(
unsigned int ibc = 0; ibc < NBC_HIT; ++ibc) {
329 for (std::unique_ptr<TgcPrepDataCollection>& bcColl : state.tgcPrepDataCollections[ibc]) {
330 if (!bcColl)
continue;
331 std::unique_ptr<TgcPrepDataCollection>& allBcColl = state.tgcPrepDataCollections[NBC_HIT][bcColl->identifyHash()];
333 allBcColl = std::make_unique<TgcPrepDataCollection>(bcColl->identifyHash());
336 hashesInAnyBC.insert(bcColl->identifyHash());
338 auto search_itr = std::find_if(allBcColl->
begin(), allBcColl->
end(),
340 return prd->identify() == prdToUpdate->identify();
342 if (search_itr == allBcColl->
end()) {
343 auto allBcPrd = std::make_unique<TgcPrepData>(*prdToUpdate);
345 allBcPrd->setBcBitMap(bcBitMap);
346 allBcColl->
push_back(std::move(allBcPrd));
351 <<
" adding " << bcBitMap <<
" to get " << (bcBitMap_current | bcBitMap));
352 allBcPrd->
setBcBitMap((bcBitMap_current | bcBitMap));
358 if (!m_xAODKey.empty()) {
359 for (std::unique_ptr<TgcPrepDataCollection>& allBcColl : state.tgcPrepDataCollections[NBC_HIT]) {
360 if (!allBcColl)
continue;
362 xAOD::TgcStrip* tgcStrip = xAODHandle->push_back(std::make_unique<xAOD::TgcStrip>());
364 tgcStrip->
setGasGap(idHelper.gasGap(allBcPrd->identify()));
368 tgcStrip->
setMeasurement(m_idHelperSvc->moduleHash(allBcPrd->identify()),
375 for (
unsigned int k = 0 ;
k < state.tgcPrepDataContainer.size(); ++
k){
376 ATH_CHECK(transferData(*state.tgcPrepDataContainer[
k], std::move(state.tgcPrepDataCollections[
k])));
378 for (
unsigned int k = 0 ;
k < state.tgcCoinDataContainer.size(); ++
k) {
379 ATH_CHECK(transferData(*state.tgcCoinDataContainer[
k], std::move(state.tgcCoinDataCollections[
k])));
381 ATH_MSG_DEBUG(
"Found " << hashesInAnyBC.size() <<
" hashes that must be added to AllBC container");
383 return StatusCode::SUCCESS;
388 const TgcRdo* rdoColl)
const {
396 if(!decodeHits(state, rd).isSuccess()) {
404 status = decodeTracklet(state, rd);
407 status = decodeTrackletEIFI(state, rd);
412 status = decodeHiPt(state, rd);
418 status = decodeInner(state, rd);
420 status = decodeSL(state, rd, rdoColl);
433 bool isConverted{
false}, isDuplicated{
false}, isInvalid{
false};
436 <<
" rod=" << rd.
rodId() <<
" ssw=" << rd.
sswId()
437 <<
" slb=" << rd.
slbId() <<
" bitpos=" << rd.
bitpos());
441 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
448 for(
int iOr=0; iOr<2; iOr++) {
455 if(o_found) orFlag =
true;
461 bool e_found = cinfo->
m_tgcCabling->getElementIDfromReadoutID(elementId,
467 bool show_warning_level =
true;
480 show_warning_level = m_show_warning_level_invalid_A09_SSW6_hit;
483 if (msgLvl(show_warning_level ? MSG::WARNING :
MSG::DEBUG)){
484 msg(show_warning_level ? MSG::WARNING :
MSG::DEBUG) <<
"ElementID not found for "
486 <<
" slb=" << rd.
slbId() <<
" bitpos=" << rd.
bitpos() <<
" orFlag=" << orFlag <<
endmsg;
491 const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(elementId);
502 <<
" ssw=" << rd.
sswId()<<
" slb=" << rd.
slbId()
503 <<
" bitpos=" << rd.
bitpos()<<
" orFlag=" << orFlag);
511 collection = std::make_unique<TgcPrepDataCollection>(tgcHashId);
514 const bool duplicate = std::find_if(collection->
begin(), collection->
end(),
516 return prd->identify() == channelId;
517 }) != collection->
end();
524 if(!isOfflineIdOKForTgcReadoutElement(descriptor,
channelId)) {
530 std::vector<Identifier> identifierList{
channelId};
537 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeHits Amg::Vector2D* hitPos is null.");
547 if(
width<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
548 ATH_MSG_WARNING(
"decodeHits: width= " <<
width <<
" is smaller than s_cutDropPrdsWithZeroWidth= "
549 << s_cutDropPrdsWithZeroWidth<<
" "<<m_idHelperSvc->toString(
channelId));
552 double errPos =
width/std::sqrt(12.);
556 mat *= errPos*errPos;
571 if(isConverted) m_nHitPRDs++;
572 else if(isDuplicated || isInvalid) m_nHitRDOs--;
574 return StatusCode::SUCCESS;
592 return StatusCode::SUCCESS;
597 int tmp_slbId{0}, tmp_subMatrix{0}, tmp_position{0};
598 found = getTrackletInfo(rd, tmp_slbId, tmp_subMatrix, tmp_position);
600 return StatusCode::SUCCESS;
605 rd.
sswId(), tmp_slbId,
606 tmp_subMatrix, tmp_position,
true);
609 return StatusCode::SUCCESS;
613 const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(channelIdOut);
618 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
619 if (!coincollection) {
620 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
621 coincollection->
setIdentifier(m_idHelperSvc->chamberId(channelIdOut));
624 int subMatrix =
static_cast<int>(rd.
subMatrix());
625 int trackletId =
static_cast<int>(2*rd.
slbId()+subMatrix);
626 int delta =
static_cast<int>(rd.
delta());
629 for (
const TgcCoinData* tgcCoinData : *coincollection) {
631 channelIdOut==tgcCoinData->identify() &&
632 channelIdIn==tgcCoinData->channelIdIn() &&
633 trackletId==tgcCoinData->trackletId() &&
634 delta==tgcCoinData->delta() &&
635 subMatrix==tgcCoinData->sub()) {
637 ATH_MSG_DEBUG(
"Duplicated TgcCoinData (Tracklet) = "<< m_idHelperSvc->toString(channelIdIn));
638 return StatusCode::SUCCESS;
642 ATH_MSG_DEBUG(
"TGC RDO->Coindata for LowPT: " << m_idHelperSvc->toString(channelIdOut));
646 if(!isOfflineIdOKForTgcReadoutElement(descriptor_o, channelIdOut)) {
647 return StatusCode::SUCCESS;
650 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
651 int gasGap_o = idHelper.
gasGap(channelIdOut);
652 int channel_o = idHelper.channel(channelIdOut);
653 double width_o = !idHelper.isStrip(channelIdOut) ? descriptor_o->
gangRadialLength(gasGap_o, channel_o)
654 : descriptor_o->
stripWidth(gasGap_o, channel_o);
656 if(width_o<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
657 return StatusCode::SUCCESS;
662 bool onSurface_o = descriptor_o->
surface(channelIdOut).
globalToLocal(position_o,position_o,hitPos_o);
665 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* hitPos_o is null.");
666 return StatusCode::SUCCESS;
672 if(!isOfflineIdOKForTgcReadoutElement(descriptor_i, channelIdIn)) {
673 return StatusCode::SUCCESS;
676 int gasGap_i = idHelper.gasGap(channelIdIn);
677 int channel_i = idHelper.channel(channelIdIn);
678 double width_i = !idHelper.isStrip(channelIdIn) ? descriptor_i->
gangRadialLength(gasGap_i, channel_i)
679 : descriptor_i->
stripWidth(gasGap_i, channel_i);
681 if(width_i<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
682 return StatusCode::SUCCESS;
687 bool onSurface_i = descriptor_i->
surface(channelIdIn).
globalToLocal(position_i,position_i,hitPos_i);
690 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* hitPos_i is null.");
691 return StatusCode::SUCCESS;
704 idHelper.stationPhi(channelIdOut),
707 idHelper.isStrip(channelIdOut),
716 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
717 coincollection->push_back(newCoinData);
723 return StatusCode::SUCCESS;
728 m_nTrackletEIFIRDOs++;
732 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
739 bool isForward = (rd.
slbId()%2==0);
748 int slot = ((rd.
slbId()/2) + (rd.
rodId()-2)*2 + 23)%24 + 1;
750 bool isBackward =
false;
754 isBackward = !isAside;
755 }
else if(slot==16) {
756 isBackward = isAside;
760 if(isAside) isBackward = (slot%3==2);
761 else isBackward = (slot%3!=2);
764 isBackward = isAside;
774 int tmpsubMatrix =
static_cast<int>(rd.
subMatrix());
776 if(tmpsubMatrix==3) {
777 if(slot== 1 || slot== 3 || slot== 4 || slot== 5 || slot== 6 || slot== 7 || slot== 8 ||
778 slot==10 || slot==11 || slot==13 || slot==18 || slot==19 || slot==20) {
782 }
else if(tmpsubMatrix==2) {
783 if(slot== 2 || slot==12 || slot==14 || slot==15 || slot==16 || slot==22 || slot==23 || slot==24) {
790 bitpos = BIT_POS_D_INPUT_ORIGIN - BIT_POS_INPUT_SIZE + 1 + BIT_POS_ASD_SIZE/4*(tmpsubMatrix*2+1);
794 bitpos = BIT_POS_B_INPUT_ORIGIN - BIT_POS_INPUT_SIZE + (isAside ? 1 : 0) + BIT_POS_ASD_SIZE/4*(rd.
subMatrix()*2+1);
797 bitpos = BIT_POS_A_INPUT_ORIGIN - BIT_POS_INPUT_SIZE + (isAside ? 0 : 1) + BIT_POS_ASD_SIZE/4*(rd.
subMatrix()*2+1);
803 bool o_found = cinfo->
m_tgcCabling->getOfflineIDfromReadoutID(channelIdIn,
808 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI OfflineID not found for "
810 <<
" sswId=" << rd.
sswId()<<
" slbId=" << rd.
slbId() <<
" slbType=" << rd.
slbType()
811 <<
" subMatrix=" << rd.
subMatrix() <<
" bitpos=" << bitpos <<
" isStrip=" <<
isStrip
812 <<
" isAside=" << isAside<<
" isForward=" << isForward<<
" slot=" << slot
813 <<
" isBackward=" << isBackward);
814 return StatusCode::SUCCESS;
819 const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(channelIdIn);
823 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
824 if (!coincollection) {
825 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
826 coincollection->
setIdentifier(m_idHelperSvc->chamberId(channelIdIn));
830 for (
const TgcCoinData* tgcCoinData : *coincollection) {
832 channelIdIn==tgcCoinData->channelIdIn() &&
833 static_cast<int>(rd.
subMatrix())==tgcCoinData->sub()) {
834 ATH_MSG_DEBUG(
"Duplicated TgcCoinData (TrackletEIFI) = "<< m_idHelperSvc->toString(channelIdIn));
835 return StatusCode::SUCCESS;
840 if(!isOfflineIdOKForTgcReadoutElement(descriptor, channelIdIn)) {
841 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI descriptor doesn't contain "
842 << m_idHelperSvc->toString(channelIdIn));
843 return StatusCode::SUCCESS;
852 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI Amg::Vector2D* hitPos is null.");
853 return StatusCode::SUCCESS;
857 int gasGap = idHelper.gasGap(channelIdIn);
858 int channel = idHelper.channel(channelIdIn);
861 double localZ = (descriptor->
transform(channelIdIn).inverse()*descriptor->
channelPos(channelIdIn)).
z();
864 width = std::abs(stripMaxX - stripMinX);
866 int positiveOffset = +4;
867 if(isForward && (slot%3==2) &&
channel==28) positiveOffset = +2;
870 width = std::abs(gangMaxZ - gangMinZ);
880 m_idHelperSvc->tgcIdHelper().stationPhi(channelIdIn),
886 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
887 coincollection->push_back(newCoinData);
890 m_nTrackletEIFIPRDs++;
891 return StatusCode::SUCCESS;
901 convertToRun2(rd0,tmprodId,tmpsector);
910 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
911 return StatusCode::SUCCESS;
916 ATH_MSG_DEBUG(
"Invalid hitId_rdo_hipt, hitId == 0!! skip to convert this RDO to PRD");
917 return StatusCode::SUCCESS;
919 int slbsubMatrix = 0;
920 bool isBackward = isBackwardBW(rd);
921 int deltaBeforeConvert = getDeltaBeforeConvert(rd);
926 std::array<Identifier, 2> channelIdOut{};
927 std::array<int, 2> bitpos_o{}, slbchannel_o{};
928 int sswId_o{0}, sbLoc_o{0}, slbId_o{0};
931 std::array<Identifier, 4> channelIdIn{};
932 std::array<int, 4> bitpos_i{}, slbchannel_i{};
933 int sswId_i{0}, sbLoc_i{0};
935 std::array<int, 4> slbId_in {}, sbLoc_in{};
937 std::array<int, 4> gasGap_i{}, channel_i{};
938 double width_i{0.},hit_position_i{0};
941 std::array<int, 2> gasGap_o{}, channel_o{};
942 double width_o{0.}, hit_position_o{0.};
950 found = getHiPtIds(rd, sswId_o, sbLoc_o, slbId_o);
952 return StatusCode::SUCCESS;
957 getBitPosOutWire(rd, slbsubMatrix, bitpos_o);
959 getBitPosOutStrip(rd, slbsubMatrix, bitpos_o);
961 for(
int i=0;
i<2;
i++) {
963 sswId_o, sbLoc_o, bitpos_o[
i]);
965 ATH_MSG_DEBUG(
"Failed to get OfflineID from ReadoutID for Pivot " << (rd.
isStrip() ?
"Strip" :
"Wire") <<
".");
966 return StatusCode::SUCCESS;
976 getBitPosInWire(rd, deltaBeforeConvert, bitpos_i, slbchannel_i, slbId_in, sbLoc_in, sswId_i, bitpos_o,
977 slbchannel_o, slbId_o);
979 getBitPosInStrip(rd, deltaBeforeConvert, bitpos_i, slbchannel_i, sbLoc_i, sswId_i, bitpos_o, slbchannel_o);
981 for(
int i=0;
i<4;
i++) {
983 rd.
isStrip() ? sbLoc_i : sbLoc_in[
i],
986 ATH_MSG_DEBUG(
"Failed to get OfflineID from ReadoutID for Pivot "
987 << (rd.
isStrip() ?
"Strip" :
"Wire") <<
".");
988 return StatusCode::SUCCESS;
994 ATH_MSG_DEBUG(
"TGC RDO->Coindata for HIPT: " << m_idHelperSvc->toString(channelIdOut[1]));
996 const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(channelIdOut[1]);
1000 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
1001 if (!coincollection) {
1002 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1003 coincollection->
setIdentifier(m_idHelperSvc->chamberId(channelIdOut[1]));
1010 for(
int i=0;
i<2;
i++) {
1011 if(!isOfflineIdOKForTgcReadoutElement(descriptor_o[
i], channelIdOut[
i])) {
1012 return StatusCode::SUCCESS;
1016 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
1017 for(
int i=0;
i<2;
i++) {
1018 gasGap_o[
i] = idHelper.
gasGap(channelIdOut[
i]);
1019 channel_o[
i] = idHelper.channel(channelIdOut[
i]);
1023 found = getPosAndIdWireOut(descriptor_o, channelIdOut,
1024 gasGap_o, channel_o,
1025 width_o, hit_position_o, tmp_hitPos_o,
1028 found = getPosAndIdStripOut(descriptor_o, channelIdOut,
1029 gasGap_o, channel_o,
1030 width_o, hit_position_o, tmp_hitPos_o,
1035 return StatusCode::SUCCESS;
1037 if(width_o<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
1038 return StatusCode::SUCCESS;
1042 if(!isOfflineIdOKForTgcReadoutElement(descriptor_oo, channelIdOut_tmp)) {
1043 return StatusCode::SUCCESS;
1054 for(
int i=0;
i<4;
i++) {
1055 if(!isOfflineIdOKForTgcReadoutElement(descriptor_i[
i], channelIdIn[
i])) {
1056 return StatusCode::SUCCESS;
1059 for(
int i=0;
i<4;
i++) {
1060 gasGap_i[
i] = idHelper.gasGap(channelIdIn[
i]);
1061 channel_i[
i] = idHelper.channel(channelIdIn[
i]);
1065 found = getPosAndIdWireIn(descriptor_i, channelIdIn,
1066 gasGap_i, channel_i,
1067 width_i, hit_position_i, tmp_hitPos_i,
1070 found = getPosAndIdStripIn(descriptor_i, channelIdIn,
1071 gasGap_i, channel_i,
1072 width_i, hit_position_i, tmp_hitPos_i,
1077 return StatusCode::SUCCESS;
1079 if(width_i<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
1080 return StatusCode::SUCCESS;
1084 if(!isOfflineIdOKForTgcReadoutElement(descriptor_ii, channelIdIn_tmp)) {
1085 return StatusCode::SUCCESS;
1090 int trackletId = 2*sbLoc_o + slbsubMatrix;
1091 int delta =
static_cast<int>(rd.
delta());
1092 int hsub =
static_cast<int>(rd.
hsub());
1093 int inner =
static_cast<int>(rd.
inner());
1096 for (
const TgcCoinData* tgcCoinData : *coincollection) {
1098 (channelIdOut_tmp==tgcCoinData->identify()) &&
1099 (channelIdIn_tmp==tgcCoinData->channelIdIn()) &&
1100 (trackletId==tgcCoinData->trackletId()) &&
1101 (delta==tgcCoinData->delta()) &&
1102 (hsub==tgcCoinData->sub()) &&
1103 (inner==tgcCoinData->inner())) {
1104 if(38<=trackletId && trackletId<=41) {
1108 ATH_MSG_DEBUG(
"Duplicated TgcCoinData (HiPt) = "<< m_idHelperSvc->toString(channelIdOut_tmp));
1109 return StatusCode::SUCCESS;
1113 auto hitPos_o = std::make_unique<Amg::Vector2D>(tmp_hitPos_o);
1114 auto hitPos_i = std::make_unique<Amg::Vector2D>(tmp_hitPos_i);
1123 idHelper.stationPhi(channelIdOut_tmp),
1136 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1137 coincollection->push_back(newCoinData);
1143 return StatusCode::SUCCESS;
1151 return StatusCode::FAILURE;
1156 if(subDetectorId!=
ASIDE && subDetectorId!=
CSIDE) {
1157 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
1158 return StatusCode::SUCCESS;
1161 bool isInner = ((rd.
sector() & 4) != 0 );
1167 int sbLoc_o = rd.
sector() & 3;
1168 int inner = rd.
inner();
1171 int phi = 0;
bool isAside =
false;
bool isEndcap =
false;
1172 if(rd.
rodId() < 13){
1173 cinfo->
m_tgcCabling->getSLIDfromReadoutID(phi, isAside, isEndcap, subDetectorId,
1174 rd.
rodId(), sswId_o, sbLoc_o);
1180 isInner =
true;
isStrip =
false;
1190 isInner =
true;
isStrip =
true;
1198 isInner =
false;
isStrip =
false;
1203 isInner =
false;
isStrip =
true;
1218 int stationEta = isAside ? 1 : -1;
1219 int stationPhi = phi;
1222 const IdentifierHash tgcHashId = m_idHelperSvc->moduleHash(elementId);
1224 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
1225 if (!coincollection) {
1226 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1230 ATH_MSG_DEBUG(
"Inner Data Word, phi: " << phi <<
" isAside: " << isAside <<
" isEndcap: " << isEndcap
1231 <<
" subDetectorId: " << subDetectorId <<
" isStrip: " << rd.
isStrip()
1232 <<
" rodId: " << rd.
rodId() <<
" slbId: " << sbLoc_o <<
" inner:"<< rd.
inner());
1257 ATH_MSG_DEBUG(
"coincollection->push_back done (for Inner)");
1261 return StatusCode::SUCCESS;
1269 convertToRun2(rd0,tmprodId,tmpsector);
1276 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::decodeSL::Unknown subDetectorId!!");
1277 return StatusCode::SUCCESS;
1282 std::array<Identifier, 3> channelId_wire{};
1283 int index_w{0}, chip_w{0}, hitId_w{0}, sub_w{0}, sswId_w{0}, sbLoc_w{0}, subMatrix_w{0};
1284 std::array<int, 3> bitpos_w{};
1287 found = getSLIds(
false, rd, channelId_wire, index_w, chip_w, hitId_w, sub_w, sswId_w, sbLoc_w,
1288 subMatrix_w, bitpos_w);
1290 return StatusCode::SUCCESS;
1293 std::array<Identifier, 3> channelId_strip{};
1294 int index_s{0}, chip_s{0}, hitId_s{0}, sub_s{0}, sswId_s{0}, sbLoc_s{0}, subMatrix_s{0};
1295 std::array<int, 3> bitpos_s{};
1298 found = getSLIds(
true, rd, channelId_strip, index_s, chip_s, hitId_s, sub_s, sswId_s, sbLoc_s, subMatrix_s,
1299 bitpos_s, isIncludedInChamberBoundary(rd), rdoColl, index_w, chip_w, hitId_w, sub_w);
1301 return StatusCode::SUCCESS;
1304 ATH_MSG_DEBUG(
"TGC RDO->TgcCoindata(SL): " << m_idHelperSvc->toString(channelId_wire[1]));
1306 const IdentifierHash tgcHashId= m_idHelperSvc->moduleHash(channelId_wire[1]);
1311 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
1312 if (!coincollection) {
1313 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1314 coincollection->
setIdentifier(m_idHelperSvc->chamberId(channelId_wire[1]));
1318 int trackletId = 2*sbLoc_w + subMatrix_w;
1319 int trackletIdStrip = 2*sbLoc_s + subMatrix_s;
1320 int roi =
static_cast<int>(rd.
roi());
1323 pt += (
static_cast<int>( rd.
coinflag() ) << 4 );
1327 bool isPositiveDeltaR = rd.
isMuplus();
1330 for (
const TgcCoinData* tgcCoinData : *coincollection) {
1332 trackletId==tgcCoinData->trackletId() && trackletIdStrip==tgcCoinData->trackletIdStrip() &&
1333 roi==tgcCoinData->roi() &&
pt==tgcCoinData->pt() &&
veto==tgcCoinData->veto() &&
1334 isPositiveDeltaR==tgcCoinData->isPositiveDeltaR()) {
1336 << m_idHelperSvc->toString(channelId_wire[2]));
1337 return StatusCode::SUCCESS;
1342 double width_w{0.}, tmp_r{0.}, tmp_wire_z{0.};
1343 found = getSLWireGeometry(channelId_wire, width_w, tmp_r, tmp_wire_z);
1345 return StatusCode::SUCCESS;
1347 if(width_w<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
1348 return StatusCode::SUCCESS;
1351 double tmp_eta = 0.;
1352 bool isGoodEta = getEtafromRZ(tmp_r, tmp_wire_z, tmp_eta);
1354 ATH_MSG_WARNING(
"Conversion from r and z to eta by Muon::TgcRdoToPrepDataToolMT::getEtafromRZ failed.");
1355 return StatusCode::SUCCESS;
1357 if(tmp_wire_z<0.) tmp_eta *= -1.;
1361 double width_s{0.}, tmp_phi{0.};
1364 return StatusCode::SUCCESS;
1366 if(width_s<s_cutDropPrdsWithZeroWidth && m_dropPrdsWithZeroWidth) {
1367 return StatusCode::SUCCESS;
1371 if(!isOfflineIdOKForTgcReadoutElement(descriptor_w2, channelId_wire[2])) {
1372 return StatusCode::SUCCESS;
1377 bool onSurface = descriptor_w2->
surface(channelId_wire[2]).
globalToLocal(tmp_gp,tmp_gp,tmp_hitPos);
1382 getSLLocalPosition(descriptor_w2, channelId_wire[2], tmp_eta, tmp_phi);
1398 m_idHelperSvc->tgcIdHelper().stationPhi(channelId_wire[2]),
1410 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1411 coincollection->push_back(newCoinData);
1415 return StatusCode::SUCCESS;
1420 int bitpos = -BIT_POS_INPUT_SIZE +1;
1422 if(channel<0 || channel>=WT_MAP_SIZE)
return -1;
1424 if(
channel%3==0) bitpos += BIT_POS_C_INPUT_ORIGIN;
1425 else if(
channel%3==1) bitpos += BIT_POS_B_INPUT_ORIGIN;
1426 else bitpos += BIT_POS_A_INPUT_ORIGIN;
1430 if(channel<0 || channel>=ST_MAP_SIZE)
return -1;
1432 if(
channel%2==0) bitpos += BIT_POS_B_INPUT_ORIGIN;
1433 else bitpos += BIT_POS_A_INPUT_ORIGIN;
1436 if(channel<0 || channel>=WD_MAP_SIZE)
return -1;
1438 if(
channel%2==0) bitpos += BIT_POS_B_INPUT_ORIGIN;
1439 else bitpos += BIT_POS_A_INPUT_ORIGIN;
1449 if( (bitpos<=BIT_POS_A_INPUT_ORIGIN) && (bitpos>BIT_POS_A_INPUT_ORIGIN-BIT_POS_INPUT_SIZE)) input = 2;
1450 else if((bitpos<=BIT_POS_B_INPUT_ORIGIN) && (bitpos>BIT_POS_B_INPUT_ORIGIN-BIT_POS_INPUT_SIZE)) input = 1;
1451 else if((bitpos<=BIT_POS_C_INPUT_ORIGIN) && (bitpos>BIT_POS_C_INPUT_ORIGIN-BIT_POS_INPUT_SIZE)) input = 0;
1456 int channel = 1-BIT_POS_INPUT_SIZE;
1458 if( input==2)
channel += BIT_POS_A_INPUT_ORIGIN;
1459 else if(input==1)
channel += BIT_POS_B_INPUT_ORIGIN;
1460 else channel += BIT_POS_C_INPUT_ORIGIN;
1466 if(input==2)
channel += BIT_POS_A_INPUT_ORIGIN;
1467 else channel += BIT_POS_B_INPUT_ORIGIN;
1487 double r_tmp = std::abs(
r);
1488 double z_tmp = std::abs(
z);
1490 if((r_tmp<std::numeric_limits<double>::epsilon()) && (z_tmp<std::numeric_limits<double>::epsilon()))
return false;
1492 eta = std::abs(atan2(r_tmp,z_tmp));
1509 int& tmp_subMatrix,
int& tmp_position)
const {
1511 if(tmp_subMatrix!=0 && tmp_subMatrix!=1) {
1512 ATH_MSG_DEBUG(
"getTrackletInfo: subMatrix " << tmp_subMatrix <<
" is invalid.");
1516 int tmp_sswId = rd.
sswId();
1517 tmp_slbId = rd.
slbId();
1520 int tmp_position_delta = tmp_position + rd.
delta();
1521 int tmp_slbType = rd.
slbType();
1523 if(tmp_position_delta>=BIT_POS_INPUT_SIZE) {
1524 tmp_position = tmp_position_delta-BIT_POS_INPUT_SIZE;
1525 if(tmp_subMatrix==1) {
1527 tmp_position = BIT_POS_INPUT_SIZE-1;
1528 ATH_MSG_DEBUG(
"Expected TGC2 Strip position (" << tmp_position_delta <<
1529 ") does not exist and is changed to the edge position " << tmp_position);
1532 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId+1 <<
" doesn't exist for FWD!! (upper edge SLB of FWD:sbLoc3,11)");
1536 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId+1 <<
" doesn't exist for EWD!! (upper edge SLB of EWD:sbLoc9)");
1546 }
else if(tmp_position_delta<0) {
1547 tmp_position = tmp_position_delta+BIT_POS_INPUT_SIZE;
1548 if(tmp_subMatrix==0) {
1551 ATH_MSG_DEBUG(
"Expected TGC2 Strip position (" << tmp_position_delta <<
1552 ") does not exist and is changed to the edge position " << tmp_position);
1555 if(tmp_position_delta==-1) {
1558 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId-1 <<
" doesn't exist for FWD!! (bottom edge SLB of FWD:sbLoc0,8)");
1563 if(tmp_position_delta==-1) {
1566 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId-1 <<
" doesn't exist for EWD!! (bottom edge SLB of EWD:sbLoc0)");
1578 tmp_position = tmp_position_delta;
1586 int RoiRow =
static_cast<int>(rd.
roi()/4);
1592 int RoiRow = getRoiRow(rd);
1595 (RoiRow== 3 || RoiRow== 4 ||
1596 RoiRow== 7 || RoiRow== 8 ||
1597 RoiRow==11 || RoiRow==12 ||
1598 RoiRow==23 || RoiRow==24
1606 std::array<int, 2>& bitpos_o) {
1608 if((rd.
hitId()%2)==1) {
1610 if((rd.
hsub())==0) {
1611 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_R_CH15;
1612 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_R_CH08;
1613 }
else if((rd.
hsub())==1) {
1614 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_R_CH07;
1615 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_R_CH00;
1619 if((rd.
hsub())==0) {
1620 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH15;
1621 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH08;
1622 }
else if((rd.
hsub())==1) {
1623 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
1624 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH00;
1638 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH05;
1639 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH00;
1640 }
else if((rd.
chip()==3) && (rd.
hitId()==6) && (rd.
hsub()==1)) {
1641 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
1642 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
1646 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_R_CH12;
1647 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_R_CH08;
1648 }
else if((rd.
chip()==1) && (rd.
hitId()==2) && (rd.
hsub()==1)) {
1649 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
1650 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_R_CH03;
1657 const int deltaBeforeConvert,
1658 std::array<int,4>& bitpos_i,
1659 std::array<int,4>& slbchannel_i,
1660 std::array<int,4>& slbId_in,
1661 std::array<int,4>& sbLoc_in,
1663 const std::array<int, 2>& bitpos_o,
1664 std::array<int, 2>& slbchannel_o,
const int slbId_o)
const {
1666 const int NUM_SLBID_SBLOC_OFFSET_WT = 8;
1670 int rdochIn_max = 0;
1671 int rdochIn_min = 0;
1683 int tmp_rdochannel_i = 0;
1684 int tmp_rdochannel_i2 = 0;
1685 for(
int i=0;
i<2;
i++) {
1687 tmp_rdochannel_i = WD_MAP_SIZE*slbId_o + slbchannel_o[
i] + deltaBeforeConvert + offset_dt;
1688 if(tmp_rdochannel_i>rdochIn_max) {
1689 tmp_rdochannel_i = rdochIn_max;
1690 }
else if(tmp_rdochannel_i<rdochIn_min) {
1691 tmp_rdochannel_i = rdochIn_min;
1707 tmp_rdochannel_i2 = (tmp_rdochannel_i/3)*3 + 2;
1709 tmp_rdochannel_i2 = ((tmp_rdochannel_i + 1)/3)*3 - 1;
1712 if(tmp_rdochannel_i2>rdochIn_max) {
1713 tmp_rdochannel_i2 = rdochIn_max;
1714 }
else if(tmp_rdochannel_i2<rdochIn_min) {
1715 tmp_rdochannel_i2 = rdochIn_min + 2;
1718 slbId_in[
i] = tmp_rdochannel_i /WT_MAP_SIZE;
1719 slbId_in[
i+2] = tmp_rdochannel_i2/WT_MAP_SIZE;
1721 sbLoc_in[
i] = slbId_in[
i];
1722 sbLoc_in[
i+2] = slbId_in[
i+2];
1726 sbLoc_in[
i] += NUM_SLBID_SBLOC_OFFSET_WT;
1727 sbLoc_in[
i+2] += NUM_SLBID_SBLOC_OFFSET_WT;
1730 slbchannel_i[
i] = tmp_rdochannel_i %WT_MAP_SIZE;
1731 slbchannel_i[
i+2] = tmp_rdochannel_i2%WT_MAP_SIZE;
1738 sswId_i =
static_cast<int>(rd.
sector()/2);
1746 std::array<int,2 >& bitpos_o) {
1748 if((rd.
hitId()%2)==1) {
1750 if((rd.
hsub())==0) {
1751 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH15;
1752 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH08;
1753 }
else if((rd.
hsub())==1) {
1754 bitpos_o[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH07;
1755 bitpos_o[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH00;
1759 if((rd.
hsub())==0) {
1760 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH15;
1761 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH08;
1762 }
else if((rd.
hsub())==1) {
1763 bitpos_o[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH07;
1764 bitpos_o[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH00;
1770 const int deltaBeforeConvert,
1771 std::array<int, 4>& bitpos_i,
1772 std::array<int, 4>& slbchannel_i,
1775 const std::array<int,2>& bitpos_o,
1776 std::array<int,2>& slbchannel_o)
const {
1780 int rdochIn_max = ST_MAP_SIZE-1;
1781 int rdochIn_min = 0;
1786 }
else if(rd.
chip()==1) {
1792 }
else if(rd.
chip()==1) {
1797 for(
int i=0;
i<2;
i++) {
1799 slbchannel_i[
i] = slbchannel_o[
i] + deltaBeforeConvert;
1800 if(slbchannel_i[
i]>rdochIn_max) {
1801 slbchannel_i[
i] = rdochIn_max;
1802 }
else if(slbchannel_i[
i]<rdochIn_min) {
1803 slbchannel_i[
i] = rdochIn_min;
1807 slbchannel_i[
i+2] = slbchannel_i[
i] + 1;
1809 slbchannel_i[
i+2] = slbchannel_i[
i] - 1;
1812 if(slbchannel_i[
i+2] > rdochIn_max) {
1813 slbchannel_i[
i+2] = rdochIn_max;
1814 }
else if(slbchannel_i[
i+2] < rdochIn_min) {
1815 slbchannel_i[
i+2] = rdochIn_min;
1823 sswId_i =
static_cast<int>(rd.
sector()/2);
1833 std::array<int, 3>& bitpos_w)
const
1843 int RoiRow = getRoiRow(rd);
1846 if(RoiRow==0 && !isForward) {
1848 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH05;
1849 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
1850 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH00;
1851 }
else if(RoiRow==36 && !isForward) {
1853 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
1854 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
1855 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH04;
1856 }
else if(RoiRow==0 && isForward) {
1858 bitpos_w[0] = BIT_POS_B_INPUT_LARGE_R_CH12;
1859 bitpos_w[1] = BIT_POS_A_INPUT_LARGE_R_CH12;
1860 bitpos_w[2] = BIT_POS_A_INPUT_LARGE_R_CH08;
1861 }
else if(RoiRow==15 && isForward) {
1863 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
1864 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
1865 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH03;
1867 if((hitId_w%2)==0) {
1870 bitpos_w[0] = BIT_POS_B_INPUT_LARGE_R_CH15;
1871 bitpos_w[1] = BIT_POS_A_INPUT_LARGE_R_CH12;
1872 bitpos_w[2] = BIT_POS_A_INPUT_LARGE_R_CH08;
1873 }
else if(sub_w==1) {
1874 bitpos_w[0] = BIT_POS_B_INPUT_LARGE_R_CH07;
1875 bitpos_w[1] = BIT_POS_A_INPUT_LARGE_R_CH04;
1876 bitpos_w[2] = BIT_POS_A_INPUT_LARGE_R_CH00;
1881 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH15;
1882 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH12;
1883 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH08;
1884 }
else if(sub_w==1) {
1885 bitpos_w[0] = BIT_POS_B_INPUT_SMALL_R_CH07;
1886 bitpos_w[1] = BIT_POS_A_INPUT_SMALL_R_CH04;
1887 bitpos_w[2] = BIT_POS_A_INPUT_SMALL_R_CH00;
1896 std::array<int, 3>& bitpos_s)
1903 if((hitId_s%2)==0) {
1906 bitpos_s[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH15;
1907 bitpos_s[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH12;
1908 bitpos_s[2] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH08;
1909 }
else if(sub_s==1) {
1910 bitpos_s[0] = BIT_POS_B_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH07;
1911 bitpos_s[1] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH04;
1912 bitpos_s[2] = BIT_POS_A_INPUT_LARGE_PHI_FOR_A_FWD_C_BWD_CH00;
1914 }
else if((hitId_s%2)==1) {
1917 bitpos_s[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH15;
1918 bitpos_s[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH12;
1919 bitpos_s[2] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH08;
1920 }
else if(sub_s==1) {
1921 bitpos_s[0] = BIT_POS_B_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH07;
1922 bitpos_s[1] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH04;
1923 bitpos_s[2] = BIT_POS_A_INPUT_SMALL_PHI_FOR_A_FWD_C_BWD_CH00;
1930 int deltaBeforeConvert = 0;
1933 switch(rd.
delta()) {
1934 case 5: deltaBeforeConvert = 6;
break;
1935 case 6: deltaBeforeConvert = 8;
break;
1936 case 7: deltaBeforeConvert = 10;
break;
1937 case -4: deltaBeforeConvert = -5;
break;
1938 case -5: deltaBeforeConvert = -7;
break;
1939 case -6: deltaBeforeConvert = -9;
break;
1940 case -7: deltaBeforeConvert = -12;
break;
1941 default: deltaBeforeConvert = rd.
delta();
break;
1944 switch (rd.
delta()) {
1945 case 11: deltaBeforeConvert = 12;
break;
1946 case 12: deltaBeforeConvert = 14;
break;
1947 case 13: deltaBeforeConvert = 16;
break;
1948 case 14: deltaBeforeConvert = 18;
break;
1949 case 15: deltaBeforeConvert = 20;
break;
1950 case -12: deltaBeforeConvert = -13;
break;
1951 case -13: deltaBeforeConvert = -15;
break;
1952 case -14: deltaBeforeConvert = -17;
break;
1953 case -15: deltaBeforeConvert = -19;
break;
1954 default: deltaBeforeConvert = rd.
delta();
break;
1958 return deltaBeforeConvert;
1963 bool isBackward =
false;
1986 double& width_wire,
double& r_wire,
double& z_wire)
const
1990 std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_w{muDetMgr->
getTgcReadoutElement(channelId_wire[0]),
1993 for(
int i=0;
i<3;
i++) {
1994 if(!isOfflineIdOKForTgcReadoutElement(descriptor_w[
i], channelId_wire[
i])) {
2001 bool onSurface_w = descriptor_w[2]->surface(channelId_wire[2]).globalToLocal(position_w,position_w,loc_hitPos_w);
2003 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getSLWireGeometry Amg::Vector2D* loc_hitPos_w is null.");
2008 std::array<int, 3> gasGap_w{}, channel_w{};
2009 for(
int i=0;
i<3;
i++) {
2010 gasGap_w[
i] = m_idHelperSvc->tgcIdHelper().gasGap(channelId_wire[
i]);
2011 channel_w[
i] = m_idHelperSvc->tgcIdHelper().channel(channelId_wire[
i]);
2014 std::array<double,3> tmp_r_w{}, tmp_phi_w{}, tmp_eta_w{};
2016 std::array<Amg::Vector3D,3> tmp_position_w{make_array<Amg::Vector3D, 3>(
Amg::Vector3D::Zero())};
2017 for(
int i=0;
i<3;
i+=2) {
2018 tmp_position_w[
i] = descriptor_w[
i]->channelPos(channelId_wire[
i]);
2019 tmp_r_w[
i] = tmp_position_w[
i].perp();
2020 tmp_phi_w[
i] = tmp_position_w[
i].phi();
2021 tmp_eta_w[
i] = tmp_position_w[
i].eta();
2023 double half_width = descriptor_w[
i]->gangRadialLength(gasGap_w[
i], channel_w[
i])/2.;
2024 if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) {
2029 tmp_r_w[0] += half_width;
2031 tmp_r_w[2] -= half_width;
2035 bool flag_geteta_w = getEtafromRZ(tmp_r_w[0], tmp_position_w[0].
z(), tmp_eta_w[0]);
2036 bool flag_getr_w = getRfromEtaZ(tmp_eta_w[0], tmp_position_w[2].
z(), tmp_r_w[0]);
2037 if(!flag_geteta_w || !flag_getr_w) {
2038 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getSLWireGeometry::failed to getR on L7!!");
2041 width_wire = tmp_r_w[0] - tmp_r_w[2];
2042 double gang = descriptor_w[2]->gangShortWidth(gasGap_w[2],channel_w[2]) + width_wire/2.;
2047 descriptor_w[2]->surface(channelId_wire[2]).localToGlobal(tmp_hitPos_w,tmp_wire_gp,tmp_wire_gp);
2048 z_wire = tmp_wire_gp.z();
2049 r_wire = tmp_r_w[2] + width_wire/2.;
2055 const bool isBackward,
const bool isAside,
2056 double& width_strip,
double& theta_strip)
const
2060 std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_s{muDetMgr->
getTgcReadoutElement(channelId_strip[0]),
2063 for(
int i=0;
i<3;
i++) {
2064 if(!isOfflineIdOKForTgcReadoutElement(descriptor_s[
i], channelId_strip[
i])) {
2071 bool onSurface_s = descriptor_s[1]->surface(channelId_strip[1]).globalToLocal(position_s,position_s,loc_hitPos_s);
2073 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getSLStripGeometry Amg::Vector2D* loc_hitPos_s is null.");
2078 std::array<int, 3> gasGap_s, channel_s{};
2079 for(
int i=0;
i<3;
i++) {
2080 gasGap_s[
i] = m_idHelperSvc->tgcIdHelper().gasGap(channelId_strip[
i]);
2081 channel_s[
i] = m_idHelperSvc->tgcIdHelper().channel(channelId_strip[
i]);
2085 for(
int i=0;
i<3;
i+=2) {
2086 localPos[
i] = descriptor_s[
i]->transform(channelId_strip[
i]).inverse()
2087 *descriptor_s[
i]->channelPos(channelId_strip[
i]);
2090 bool flag_reverse =
false;
2091 std::array<int, 2> index_strip{};
2095 index_strip[0] = 2; index_strip[1] = 0; flag_reverse =
true;
2097 index_strip[0] = 0; index_strip[1] = 2; flag_reverse =
false;
2101 index_strip[0] = 0; index_strip[1] = 2; flag_reverse =
true;
2103 index_strip[0] = 2; index_strip[1] = 0; flag_reverse =
false;
2107 double stripMaxX = descriptor_s[index_strip[0]]->stripHighEdgeLocX(gasGap_s[index_strip[0]], channel_s[index_strip[0]],
2108 localPos[index_strip[0]].
z());
2109 double stripMinX = descriptor_s[index_strip[1]]->stripLowEdgeLocX(gasGap_s[index_strip[1]], channel_s[index_strip[1]],
2110 localPos[index_strip[1]].
z());
2111 width_strip = stripMaxX - stripMinX;
2112 double strip = stripMinX + width_strip/2.;
2113 if(flag_reverse) strip *= -1.;
2118 int index_strip_gp = 0;
2119 if(!isBackward) index_strip_gp = 0;
2120 else index_strip_gp = 2;
2122 descriptor_s[index_strip_gp]->surface(channelId_strip[index_strip_gp]).localToGlobal(tmp_hitPos_s,tmp_strip_gp,tmp_strip_gp);
2123 theta_strip = atan2(tmp_strip_gp.y(), tmp_strip_gp.x());
2130 const std::array<Identifier, 2>& channelIdOut,
2131 const std::array<int, 2>& gasGap_o,
2132 const std::array<int, 2>& channel_o,
2134 double& hit_position_o,
2139 std::array<Amg::Vector3D, 2> position_o{make_array<Amg::Vector3D, 2>(
Amg::Vector3D::Zero())};
2140 std::array<double, 2> tmp_phi_o{}, tmp_eta_o{}, tmp_r_o {};
2142 for(
int i=0;
i<2;
i++) {
2143 position_o[
i] = descriptor_o[
i]->channelPos(channelIdOut[
i]);
2144 tmp_r_o[
i] = position_o[
i].perp();
2145 tmp_phi_o[
i] = position_o[
i].phi();
2146 tmp_eta_o[
i] = position_o[
i].phi();
2148 double half_width = descriptor_o[
i]->gangRadialLength(gasGap_o[
i], channel_o[
i])/2.;
2149 if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) {
2152 if(
i==0) tmp_r_o[0] += half_width;
2153 else tmp_r_o[1] -= half_width;
2156 bool flag_geteta_o = getEtafromRZ(tmp_r_o[0], position_o[0].
z(), tmp_eta_o[0]);
2157 bool flag_getr_o = getRfromEtaZ(tmp_eta_o[0], position_o[1].
z(), tmp_r_o[0]);
2158 if(!flag_geteta_o || !flag_getr_o) {
2159 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireOut::failed to getR on L7!!");
2163 width_o = tmp_r_o[0] - tmp_r_o[1];
2165 hit_position_o = descriptor_o[1]->gangShortWidth(gasGap_o[1], channel_o[1]) + width_o/2;
2166 tmp_hitPos_o[
Trk::locX] = (hit_position_o);
2171 bool onSurface_o = descriptor_o[1]->surface(channelIdOut[1]).globalToLocal(position_out,position_out,loc_hitPos_o);
2173 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireOut Amg::Vector2D* loc_hitPos_o is null.");
2178 channelIdOut_tmp = channelIdOut[1];
2184 const std::array<Identifier, 2>& channelIdOut,
2185 const std::array<int, 2>& gasGap_o,
2186 const std::array<int, 2>& channel_o,
2188 double& hit_position_o,
2191 const bool isBackward,
const bool isAside)
const
2195 std::array<Amg::Vector3D, 2> localpos_o{make_array<Amg::Vector3D, 2>(
Amg::Vector3D::Zero())};
2196 for(
int i=0;
i<2;
i++) {
2197 localpos_o[
i] = descriptor_o[
i]->transform(channelIdOut[
i]).inverse()*descriptor_o[
i]->channelPos(channelIdOut[
i]);
2200 std::array<int, 3>
index{};
2201 bool flag_reverse =
false;
2205 index[0] = 1;
index[1] = 0; flag_reverse =
true;
2207 index[0] = 0;
index[1] = 1; flag_reverse =
false;
2212 index[0] = 0;
index[1] = 1; flag_reverse =
true;
2214 index[0] = 1;
index[1] = 0; flag_reverse =
false;
2218 double stripMax = descriptor_o[
index[0]]->stripHighEdgeLocX(gasGap_o[
index[0]], channel_o[
index[0]],
2219 localpos_o[
index[0]].
z());
2220 double stripMin = descriptor_o[
index[1]]->stripLowEdgeLocX(gasGap_o[
index[1]], channel_o[
index[1]],
2221 localpos_o[
index[1]].
z());
2222 width_o = stripMax - stripMin;
2224 hit_position_o = stripMin + width_o/2.;
2225 if(flag_reverse) hit_position_o *= -1.;
2226 tmp_hitPos_o[
Trk::locX] = hit_position_o;
2231 bool onSurface_o = descriptor_o[1]->surface(channelIdOut[1]).globalToLocal(position_out,position_out,loc_hitPos_o);
2233 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripOut Amg::Vector2D* loc_hitPos_o is null.");
2238 channelIdOut_tmp = channelIdOut[
index[2]];
2244 const std::array<Identifier, 4>& channelIdIn,
2245 const std::array<int, 4>& gasGap_i,
2246 const std::array<int, 4>& channel_i,
2247 double& width_i,
double& hit_position_i,
2252 int flag_boundary_i = 0;
2253 if(descriptor_i[1]->chamberType()==descriptor_i[3]->chamberType()) {
2255 if(gasGap_i[1]==gasGap_i[3]) {
2256 flag_boundary_i = 1;
2258 flag_boundary_i = 3;
2260 }
else if(descriptor_i[0]->chamberType()==descriptor_i[2]->chamberType()) {
2262 if(gasGap_i[0]==gasGap_i[2]) {
2263 flag_boundary_i = 0;
2265 flag_boundary_i = 2;
2268 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::ROI has 3 readout elements!!");
2272 channelIdIn_tmp = channelIdIn[flag_boundary_i];
2276 if(!isOfflineIdOKForTgcReadoutElement(descriptor_iw, channelIdIn_tmp)) {
2280 std::array<double, 3> tmp_r_i{}, tmp_phi_i{}, tmp_eta_i{};
2282 std::array<Amg::Vector3D, 3> position_i {descriptor_i[0]->channelPos(channelIdIn[0]),
2283 descriptor_i[1]->channelPos(channelIdIn[1]),
2286 for(
int i=0;
i<3;
i++) {
2287 tmp_r_i[
i] =position_i[
i].perp();
2288 tmp_phi_i[
i] = position_i[
i].phi();
2289 tmp_eta_i[
i] = position_i[
i].eta();
2293 double half_width = descriptor_i[
i]->gangRadialLength(gasGap_i[
i], channel_i[
i])/2.;
2294 if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) {
2297 if(
i==0) tmp_r_i[0] += half_width;
2298 else tmp_r_i[1] -= half_width;
2300 bool flag_geteta_i = getEtafromRZ(tmp_r_i[
i], position_i[
i].
z(), tmp_eta_i[
i]);
2301 bool flag_getr_i = getRfromEtaZ(tmp_eta_i[
i], position_i[2].
z(), tmp_r_i[
i]);
2303 if(!flag_geteta_i || !flag_getr_i) {
2304 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::failed to getRIn" <<
i <<
" on L3!!");
2310 width_i = tmp_r_i[0] - tmp_r_i[1];
2312 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::minus value width_i = " << width_i);
2316 int gasGap_tmp = m_idHelperSvc->tgcIdHelper().gasGap(channelIdIn_tmp);
2317 int channel_tmp = m_idHelperSvc->tgcIdHelper().channel(channelIdIn_tmp);
2318 double half_width = descriptor_iw->
gangRadialLength(gasGap_tmp, channel_tmp)/2.;
2319 if(half_width<s_cutDropPrdsWithZeroWidth/2. && m_dropPrdsWithZeroWidth) {
2322 if((flag_boundary_i%2)==1) {
2323 tmp_r_i[2] -= half_width;
2324 hit_position_i = descriptor_iw->
gangShortWidth(gasGap_tmp, channel_tmp)
2325 - (tmp_r_i[2] - tmp_r_i[1]) + width_i/2.;
2327 tmp_r_i[2] += half_width;
2328 hit_position_i = descriptor_iw->
gangLongWidth(gasGap_tmp, channel_tmp)
2329 + (tmp_r_i[0] - tmp_r_i[2]) - width_i/2.;
2333 tmp_hitPos_i[
Trk::locX] = hit_position_i;
2334 Amg::Vector3D position_in = descriptor_i[1]->channelPos(channelIdIn[1]);
2337 bool onSurface_i = descriptor_i[1]->surface(channelIdIn[1]).globalToLocal(position_in,position_in,loc_hitPos_i);
2339 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireIn Amg::Vector2D* loc_hitPos_i is null.");
2349 const std::array<Identifier, 4>& channelIdIn,
2350 const std::array<int, 4>& gasGap_i,
2351 const std::array<int, 4>& channel_i,
2353 double& hit_position_i,
2356 const bool isBackward,
const bool isAside)
const
2361 for(
int i=0;
i<4;
i++) {
2362 if(gasGap_i[
i]==3) {
2367 if(flag_isL3<0 || flag_isL3>=4) {
2368 ATH_MSG_DEBUG(
"getPosAndIdStripIn: Any bitpos is not at Layer3!");
2372 channelIdIn_tmp = channelIdIn[flag_isL3];
2376 if(!isOfflineIdOKForTgcReadoutElement(descriptor_is, channelIdIn_tmp)) {
2380 std::array<double, 3> tmp_r_i{}, tmp_phi_i{}, tmp_eta_i{};
2381 std::array<Amg::Vector3D, 3> position_is{make_array<Amg::Vector3D, 3>(
Amg::Vector3D::Zero())};
2382 for(
int i=0;
i<3;
i++) {
2384 position_is[
i] = descriptor_i[
i]->channelPos(channelIdIn[
i]);
2386 position_is[
i] = descriptor_is->
channelPos(channelIdIn_tmp);
2388 tmp_r_i[
i] = position_is[
i].perp();
2389 tmp_phi_i[
i] = position_is[
i].phi();
2390 tmp_eta_i[
i] = position_is[
i].eta();
2393 std::array<int, 2>
index{};
2394 bool flag_reverse =
false;
2397 index[0] = 1;
index[1] = 0; flag_reverse =
true;
2399 index[0] = 0;
index[1] = 1; flag_reverse =
false;
2403 index[0] = 0;
index[1] = 1; flag_reverse =
true;
2405 index[0] = 1;
index[1] = 0; flag_reverse =
false;
2409 std::array<Amg::Vector3D,2 > localpos_i{make_array<Amg::Vector3D, 2>(
Amg::Vector3D::Zero())};
2410 for(
int i=0;
i<2;
i++) {
2411 localpos_i[
i] = descriptor_i[
i]->transform(channelIdIn[
i]).inverse()*descriptor_i[
i]->channelPos(channelIdIn[
i]);
2413 double stripMaxX = descriptor_i[
index[0]]->stripHighEdgeLocX(gasGap_i[
index[0]], channel_i[
index[0]],
2414 localpos_i[
index[0]].
z());
2415 double stripMinX = descriptor_i[
index[1]]->stripLowEdgeLocX(gasGap_i[
index[1]], channel_i[
index[1]],
2416 localpos_i[
index[1]].
z());
2417 width_i = stripMaxX - stripMinX;
2419 hit_position_i = stripMinX + width_i/2.;
2420 if(flag_reverse) hit_position_i *= -1.;
2421 tmp_hitPos_i[
Trk::locX] = hit_position_i;
2426 bool onSurface_i = descriptor_i[1]->surface(channelIdIn[1]).globalToLocal(position_in,position_in,loc_hitPos_i);
2428 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripIn Amg::Vector2D* loc_hitPos_i is null.");
2445 int chip =
static_cast<int>(rd.
chip());
2446 int hitId =
static_cast<int>(rd.
hitId());
2451 ATH_MSG_DEBUG(
"Failed to get SimHighPtID from RDOHighPtID for Pivot "
2452 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2458 convertToRun2(rd,tmprodId,tmpsector);
2465 chip, hitId, rd.
hsub());
2470 chip, hitId, rd.
hsub());
2474 ATH_MSG_DEBUG(
"Failed to get offlineID from HighPtID for Pivot "
2475 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2479 std::array<int, 3> dummy_i{};
2480 found = cinfo->
m_tgcCabling->getReadoutIDfromOfflineID(dummyId, dummy_i[0], dummy_i[1], sswId_o, sbLoc_o, dummy_i[2]);
2482 ATH_MSG_DEBUG(
"Failed to get ReadoutID from OfflineID for Pivot "
2483 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2487 std::array<int, 2> i_o{};
2488 std::array<bool, 2> b_o{
false,
false};
2490 found = cinfo->
m_tgcCabling->getSLBIDfromReadoutID(i_o[0], b_o[0], b_o[1], i_o[1], slbId_o,
2493 found = cinfo->
m_tgcCabling->getSLBIDfromReadoutID(i_o[0], b_o[0], b_o[1], i_o[1], slbId_o,
2497 ATH_MSG_DEBUG(
"Failed to get SLBID from ReadoutID for Pivot "
2498 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2507 int&
index,
int& chip,
int& hitId,
int& sub,
int& sswId,
int& sbLoc,
2509 std::array<int, 3>& bitpos,
2510 const bool isBoundary,
const TgcRdo* rdoColl,
2511 const int index_w,
const int chip_w,
const int hitId_w,
const int sub_w)
const
2528 << (!
isStrip ?
"Wire" :
"Strip"));
2538 ATH_MSG_DEBUG(
"Failed to get SimHighPtID from RDOHighPtID for "
2539 << (!
isStrip ?
"Wire" :
"Strip"));
2556 << (!
isStrip ?
"Wire" :
"Strip"));
2562 std::array<int, 3> dummy_i{};
2571 << (!
isStrip ?
"Wire" :
"Strip"));
2578 bool exist_hipt_s = getSbLocOfEndcapStripBoundaryFromHiPt(rd, sbLoc, rdoColl, index_w, chip_w, hitId_w, sub_w);
2581 bool exist_tracklet_s = getSbLocOfEndcapStripBoundaryFromTracklet(rd, sbLoc, rdoColl, index_w, chip_w, hitId_w, sub_w);
2582 if(!exist_tracklet_s) {
2583 ATH_MSG_DEBUG(
"Failed to find correspond Tracklet_strip for SL!!");
2590 getBitPosWire(rd, hitId, sub, subMatrix, bitpos);
2592 getBitPosStrip(hitId, sub, subMatrix, bitpos);
2595 for(
int i=0;
i<3;
i++) {
2596 if(
i==1 && (!
isStrip || !isBoundary))
continue;
2606 << (!
isStrip ?
"Wire" :
"Strip"));
2609 <<
", rodId = " << rd.
rodId()
2610 <<
", sswId = " << sswId
2611 <<
", slbId = " << sbLoc
2612 <<
", bitpos_" << (!
isStrip ?
"w" :
"s")
2613 <<
"[" <<
i <<
"] = " << bitpos[
i]);
2625 const int index_w,
const int chip_w,
const int hitId_w,
const int sub_w)
const
2632 bool exist_hipt_s =
false;
2635 int trackletIdStripFirst{-1}, trackletIdStripSecond{-1}, trackletIdStripThird{-1};
2636 getEndcapStripCandidateTrackletIds(
static_cast<int>(rd.
roi()), trackletIdStripFirst,
2637 trackletIdStripSecond, trackletIdStripThird);
2644 convertToRun2(rdH0,tmprodId,tmpsector);
2645 const TgcRawData rdH(rdH0->bcTag(), rdH0->subDetectorId(), tmprodId,
2646 rdH0->l1Id(), rdH0->bcId(), rdH0->isStrip(),
2647 rdH0->isForward(), tmpsector, rdH0->chip(),
2648 rdH0->index(),rdH0->isHipt(), rdH0->hitId(),
2649 rdH0->hsub(), rdH0->delta(), rdH0->inner());
2662 int sswId_o{0}, sbLoc_o{0}, slbId_o{0};
2663 bool found = getHiPtIds(rdH, sswId_o, sbLoc_o, slbId_o);
2669 int slbsubMatrix = 0;
2670 std::array<int, 2> bitpos_o{};
2671 getBitPosOutStrip(rdH, slbsubMatrix, bitpos_o);
2674 int trackletIdStrip = 2*sbLoc_o + slbsubMatrix;
2677 if(trackletIdStrip!=trackletIdStripFirst && trackletIdStrip!=trackletIdStripSecond &&
2678 trackletIdStrip!=trackletIdStripThird)
continue;
2681 if(exist_hipt_s && trackletIdStrip==trackletIdStripThird)
continue;
2684 int index_w_tmp = index_w;
2685 int chip_w_tmp = chip_w;
2686 int hitId_w_tmp = hitId_w;
2694 ATH_MSG_DEBUG(
"Failed to get RDOHighPtID from SimHighPtID for Wire");
2699 int chip_s =
static_cast<int>(rdH.
chip());
2700 int hitId_s =
static_cast<int>(rdH.
hitId());
2701 int hsub_s =
static_cast<int>(rdH.
hsub());
2714 ATH_MSG_DEBUG(
"Failed to get ROINumber from HighPtID for Strip");
2720 exist_hipt_s =
true;
2721 if(trackletIdStrip==trackletIdStripFirst)
break;
2726 return exist_hipt_s;
2731 const int index_w,
const int chip_w,
2732 const int hitId_w,
const int sub_w)
const
2736 bool exist_tracklet_s =
false;
2739 int trackletIdStripFirst{-1}, trackletIdStripSecond{-1}, trackletIdStripThird{-1};
2740 getEndcapStripCandidateTrackletIds(
static_cast<int>(rd.
roi()), trackletIdStripFirst,
2741 trackletIdStripSecond, trackletIdStripThird);
2747 uint16_t tmprodId{0}, tmpsector{0};
2748 convertToRun2(rdS0,tmprodId,tmpsector);
2749 const TgcRawData rdS(rdS0->bcTag(), rdS0->subDetectorId(), tmprodId,
2750 rdS0->sswId(), rdS0->slbId(), rdS0->l1Id(),
2751 rdS0->bcId(), rdS0->slbType(), rdS0->delta(),
2752 rdS0->segment(), rdS0->subMatrix(), rdS0->position());
2754 bool isForward_s = (rdS.
sswId()==7);
2755 if(isForward_s)
continue;
2766 int trackletIdStrip =
static_cast<int>(2*rdS.
slbId()+rdS.
subMatrix());
2767 if(trackletIdStrip!=trackletIdStripFirst &&
2768 trackletIdStrip!=trackletIdStripSecond &&
2769 trackletIdStrip!=trackletIdStripThird)
continue;
2772 if(exist_tracklet_s && trackletIdStrip==trackletIdStripThird)
continue;
2779 ATH_MSG_DEBUG(
"Failed to get OfflineID from LowPtCoincidenceID for Strip");
2783 std::array<int, 7>
i{};
2784 std::array<bool, 2>
b{};
2790 ATH_MSG_DEBUG(
"Failed to get HighPtID from OfflineID for Strip");
2795 int index_w_tmp = index_w;
2796 int chip_w_tmp = chip_w;
2797 int hitId_w_tmp = hitId_w;
2804 ATH_MSG_DEBUG(
"Failed to get RDOHighPtID from SimHighPtID for Wire");
2814 ATH_MSG_DEBUG(
"Failed to get RDOHighPtID from SimHighPtID for Strip");
2829 ATH_MSG_DEBUG(
"Failed to get ROINumber from HighPtID for Strip");
2834 sbLoc = rdS.
slbId();
2835 exist_tracklet_s =
true;
2836 if(trackletIdStrip==trackletIdStripFirst)
break;
2841 return exist_tracklet_s;
2845 int &trackletIdStripSecond,
2846 int &trackletIdStripThird) {
2847 constexpr
int T9SscMax = 2;
2848 constexpr
int T8SscMax = 4;
2849 constexpr
int T7SscMax = 6;
2850 constexpr
int T6SscMax = 12;
2851 constexpr
int T5SscMax = 18;
2853 constexpr
int T9Offset = 32 + 0;
2854 constexpr
int T8Offset = 32 + 2;
2855 constexpr
int T7Offset = 32 + 4;
2856 constexpr
int T6Offset = 32 + 6;
2857 constexpr
int T5Offset = 32 + 8;
2862 int ssc = (roi+4)/8;
2863 int halfSsc = (roi%4)/2;
2865 if( ssc< T9SscMax) {
2866 trackletIdStripFirst = T9Offset + halfSsc;
2867 trackletIdStripSecond = -1;
2868 trackletIdStripThird = -1;
2869 }
else if(ssc==T9SscMax) {
2870 trackletIdStripFirst = T8Offset + halfSsc;
2871 trackletIdStripSecond = T9Offset + halfSsc;
2872 trackletIdStripThird = -1;
2873 }
else if(ssc< T8SscMax) {
2874 trackletIdStripFirst = T8Offset + halfSsc;
2875 trackletIdStripSecond = -1;
2876 trackletIdStripThird = -1;
2877 }
else if(ssc==T8SscMax) {
2878 trackletIdStripFirst = T7Offset + halfSsc;
2879 trackletIdStripSecond = T8Offset + halfSsc;
2880 trackletIdStripThird = -1;
2881 }
else if(ssc< T7SscMax) {
2882 trackletIdStripFirst = T7Offset + halfSsc;
2883 trackletIdStripSecond = -1;
2884 trackletIdStripThird = -1;
2885 }
else if(ssc==T7SscMax) {
2886 trackletIdStripFirst = T6Offset + halfSsc;
2887 trackletIdStripSecond = T7Offset + halfSsc;
2888 trackletIdStripThird = T5Offset + halfSsc;
2889 }
else if(ssc< T6SscMax) {
2890 trackletIdStripFirst = T6Offset + halfSsc;
2891 trackletIdStripSecond = T5Offset + halfSsc;
2892 trackletIdStripThird = -1;
2893 }
else if(ssc==T6SscMax) {
2894 trackletIdStripFirst = T6Offset + halfSsc;
2895 trackletIdStripSecond = T5Offset + halfSsc;
2896 trackletIdStripThird = -1;
2897 }
else if(ssc<=T5SscMax) {
2898 trackletIdStripFirst = T5Offset + halfSsc;
2899 trackletIdStripSecond = T6Offset + halfSsc;
2900 trackletIdStripThird = -1;
2902 trackletIdStripFirst = -1;
2903 trackletIdStripSecond = -1;
2904 trackletIdStripThird = -1;
2911 if (m_cablingInfo.isValid()) {
2912 return m_cablingInfo.ptr();
2926 unsigned int hashId_max = m_idHelperSvc->tgcIdHelper().module_hash_max();
2928 IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
2930 int subDetectorId = 0;
2933 for(
unsigned int hashId=0; hashId<hashId_max; hashId++) {
2934 IdentifierHash
hash(hashId);
2935 m_idHelperSvc->tgcIdHelper().get_id(
hash, elementId, &tgcContext);
2936 cinfo.
m_tgcCabling->getReadoutIDfromElementID(elementId, subDetectorId, rodId);
2945 m_cablingInfo.set (std::move (cinfo));
2946 return m_cablingInfo.ptr();
2953 if(!readout)
return nullptr;
2956 constexpr
double length = 100.;
2957 constexpr
unsigned int nRep = 10;
2958 constexpr
double dRAccuracy = 1.0E-20;
2959 constexpr
double maxLocR = 10000.;
2963 for(
unsigned int iRep=0; iRep<nRep; iRep++) {
2969 double glob_eta_c = glob_hitPos_c.eta();
2970 double glob_phi_c = glob_hitPos_c.phi();
2974 double dR = std::hypot(vector[0], vector[1]);
2989 matrix(0,0) = glob_hitPos_w.eta() - glob_eta_c;
2991 matrix(0,1) = glob_hitPos_s.eta() - glob_eta_c;
2994 bool invertible =
matrix.determinant();