13#include "GaudiKernel/ThreadLocalContext.h"
30 for (
int ibc = 0; ibc <
NBC_HIT + 1; ibc++) {
32 std::ostringstream location;
42 for (
int ibc = 0; ibc <
NBC_TRIG; ibc++) {
44 std::ostringstream location;
64 for (
int ibc = 0; ibc <
NBC_HIT + 1; ibc++) {
66 std::ostringstream location;
79 for (
int ibc = 0; ibc <
NBC_TRIG; ibc++) {
81 std::ostringstream location;
98 return StatusCode::SUCCESS;
112 return AthAlgTool::finalize();
117 const EventContext&,
const std::vector<uint32_t>& )
const {
119 return StatusCode::FAILURE;
121template <
class ContType,
class CollType>
123 ContType&
container, std::vector<std::unique_ptr<CollType>>&& coll)
const {
124 for (std::unique_ptr<CollType>& toMove : coll) {
129 auto lock =
container.getWriteHandle(hash);
130 if (!lock.alreadyPresent()) {
131 ATH_CHECK(lock.addOrDelete(std::move(toMove)));
134 return StatusCode::SUCCESS;
138 const EventContext& ctx)
const {
142 handle.
record(std::make_unique<xAOD::TgcStripContainer>(),
143 std::make_unique<xAOD::TgcStripAuxContainer>()));
150 State& state)
const {
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 =
161 if (!externalCachePRD) {
164 handle.
record(std::make_unique<TgcPrepDataContainer>(hashMax)));
166 "TGC PrepData Container recorded in StoreGate with key "
177 std::make_unique<Muon::TgcPrepDataContainer>(update.ptr())));
187 for (
unsigned int ibc = 0; ibc <
NBC_TRIG; ibc++) {
191 const bool externalCacheCoin =
194 if (!externalCacheCoin) {
197 handle.
record(std::make_unique<TgcCoinDataContainer>(hashMax)));
203 std::make_unique<TgcCoinDataContainer>(update.ptr())));
218 return StatusCode::SUCCESS;
221 const EventContext& ctx,
222 const std::vector<IdentifierHash>& requestedIdHashVect)
const {
231 xAODHandle.
record(std::make_unique<xAOD::TgcStripContainer>(),
232 std::make_unique<xAOD::TgcStripAuxContainer>()));
235 int sizeVectorRequested = requestedIdHashVect.size();
237 <<
" offline collections called");
241 std::set<const TgcRdo*> decodedRdoCollVec{}, rdoCollVec{};
242 std::array<char, 24> decodedOnlineId{};
247 "Stored empty container. Decoding TGC RDO into TGC PrepRawData is "
249 return StatusCode::SUCCESS;
255 ATH_MSG_DEBUG(
"Retrieving TGC RDO container from the store");
260 if (rdoContainer->
empty()) {
262 ATH_MSG_DEBUG(
"Empty rdo container - no tgc rdo in this event");
263 return StatusCode::SUCCESS;
267 "Not empty rdo container in this event, the container size is "
268 << rdoContainer->
size());
271 if (sizeVectorRequested != 0) {
272 unsigned int nRdo = 0;
275 for (
const IdentifierHash& offlineCollHash : requestedIdHashVect) {
277 int subDetectorId = 0;
279 m_idHelperSvc->tgcIdHelper().get_id(offlineCollHash, elementId, &tgcContext);
284 if (decodedOnlineId.at(onlineId)) {
286 << onlineId <<
" which contains hash "
287 <<
static_cast<unsigned int>(offlineCollHash)
288 <<
" is already decoded and skipped");
292 decodedOnlineId.at(onlineId) =
true;
294 for (
const TgcRdo* rdoColl : *rdoContainer) {
295 if (rdoColl->identify() == onlineId) {
296 if (!decodedRdoCollVec.count(rdoColl)) {
297 rdoCollVec.insert(rdoColl);
308 if (sizeVectorRequested != 0) {
313 for (
const TgcRdo* rdo : rdoCollVec) {
320 offlineId, rd->subDetectorId(), rd->rodId(),
321 rd->sswId(), rd->slbId(), rd->bitpos())) {
326 if (std::find(requestedIdHashVect.begin(),
327 requestedIdHashVect.end(),
328 tgcHashId) == requestedIdHashVect.end()) {
333 decodedRdoCollVec.insert(rdo);
337 for (
const TgcRdo* rdoColl : *rdoContainer) {
338 if (rdoColl->empty() || decodedRdoCollVec.count(rdoColl) ||
339 rdoCollVec.count(rdoColl)) {
342 ATH_MSG_DEBUG(
" Number of RawData in this rdo " << rdoColl->size());
346 decodedRdoCollVec.insert(rdoColl);
350 std::set<IdentifierHash> hashesInAnyBC;
351 for (
unsigned int ibc = 0; ibc <
NBC_HIT; ++ibc) {
356 }
else if (ibc == 1) {
358 }
else if (ibc == 2) {
362 for (std::unique_ptr<TgcPrepDataCollection>& bcColl :
367 std::unique_ptr<TgcPrepDataCollection>& allBcColl =
370 allBcColl = std::make_unique<TgcPrepDataCollection>(
371 bcColl->identifyHash());
372 allBcColl->setIdentifier(bcColl->identify());
374 hashesInAnyBC.insert(bcColl->identifyHash());
376 auto search_itr = std::find_if(
377 allBcColl->begin(), allBcColl->end(),
379 return prd->identify() == prdToUpdate->identify();
381 if (search_itr == allBcColl->end()) {
382 auto allBcPrd = std::make_unique<TgcPrepData>(*prdToUpdate);
383 allBcPrd->setHashAndIndex(allBcColl->identifyHash(),
385 allBcPrd->setBcBitMap(bcBitMap);
386 allBcColl->push_back(std::move(allBcPrd));
392 <<
" Old bitmap " << bcBitMap_current <<
" adding "
393 << bcBitMap <<
" to get "
394 << (bcBitMap_current | bcBitMap));
395 allBcPrd->
setBcBitMap((bcBitMap_current | bcBitMap));
402 for (std::unique_ptr<TgcPrepDataCollection>& allBcColl :
409 xAODHandle->push_back(std::make_unique<xAOD::TgcStrip>());
411 idHelper.
isStrip(allBcPrd->identify()));
414 idHelper.
channel(allBcPrd->identify()));
421 const double locPos = (tgcStrip->
measuresPhi() ? -1. : 1.) *
422 allBcPrd->localPosition().x();
440 <<
" hashes that must be added to AllBC container");
442 return StatusCode::SUCCESS;
447 const TgcRdo* rdoColl)
const {
454 StatusCode status = StatusCode::SUCCESS;
468 (rd.
sector() & 4) != 0) ||
476 status =
decodeSL(state, rd, rdoColl);
478 if (!status.isSuccess()) {
489 return StatusCode::SUCCESS;
493 bool isConverted{
false}, isDuplicated{
false}, isInvalid{
false};
496 <<
" rod=" << rd.
rodId() <<
" ssw="
498 <<
" bitpos=" << rd.
bitpos());
510 for (
int iOr = 0; iOr < 2; iOr++) {
532 bool show_warning_level =
true;
552 if (msgLvl(show_warning_level ? MSG::WARNING : MSG::DEBUG)) {
553 msg(show_warning_level ? MSG::WARNING : MSG::DEBUG)
554 <<
"ElementID not found for "
556 <<
" rod=" << rd.
rodId() <<
" ssw=" << rd.
sswId()
557 <<
" slb=" << rd.
slbId() <<
" bitpos=" << rd.
bitpos()
558 <<
" orFlag=" << orFlag <<
endmsg;
572 "OfflineID not found for "
574 <<
" ssw=" << rd.
sswId() <<
" slb=" << rd.
slbId()
575 <<
" bitpos=" << rd.
bitpos() <<
" orFlag=" << orFlag);
580 std::unique_ptr<TgcPrepDataCollection>& collection =
583 collection = std::make_unique<TgcPrepDataCollection>(tgcHashId);
584 collection->setIdentifier(elementId);
586 const bool duplicate =
587 std::find_if(collection->begin(), collection->end(),
589 return prd->identify() == channelId;
590 }) != collection->end();
600 "decodeHits: MuonGM::TgcReadoutElement is invalid.");
604 "TGC RDO->PrepRawdata: " <<
m_idHelperSvc->toString(channelId));
606 std::vector<Identifier> identifierList{channelId};
611 position, position, hitPos);
615 "Muon::TgcRdoToPrepDataToolMT::decodeHits Amg::Vector2D* "
620 int gasGap = idHelper.
gasGap(channelId);
621 int channel = idHelper.
channel(channelId);
631 <<
" is smaller than s_cutDropPrdsWithZeroWidth= "
636 double errPos =
width / std::sqrt(12.);
640 mat *= errPos * errPos;
653 collection->push_back(newPrepData);
659 }
else if (isDuplicated || isInvalid) {
663 return StatusCode::SUCCESS;
679 return StatusCode::SUCCESS;
684 int tmp_slbId{0}, tmp_subMatrix{0}, tmp_position{0};
687 return StatusCode::SUCCESS;
692 tmp_subMatrix, tmp_position,
true);
695 return StatusCode::SUCCESS;
706 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection =
708 if (!coincollection) {
710 std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
711 coincollection->setIdentifier(
m_idHelperSvc->chamberId(channelIdOut));
714 int subMatrix =
static_cast<int>(rd.
subMatrix());
715 int trackletId =
static_cast<int>(2 * rd.
slbId() + subMatrix);
716 int delta =
static_cast<int>(rd.
delta());
719 for (
const TgcCoinData* tgcCoinData : *coincollection) {
721 tgcCoinData->type() &&
723 tgcCoinData->identify() &&
725 channelIdIn == tgcCoinData->channelIdIn() &&
726 trackletId == tgcCoinData->trackletId() &&
727 delta == tgcCoinData->delta() &&
728 subMatrix == tgcCoinData->sub()) {
732 return StatusCode::SUCCESS;
743 return StatusCode::SUCCESS;
747 int gasGap_o = idHelper.
gasGap(channelIdOut);
748 int channel_o = idHelper.
channel(channelIdOut);
749 double width_o = !idHelper.
isStrip(channelIdOut)
751 : descriptor_o->
stripWidth(gasGap_o, channel_o);
756 return StatusCode::SUCCESS;
761 bool onSurface_o = descriptor_o->
surface(channelIdOut)
766 "Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* "
767 "hitPos_o is null.");
768 return StatusCode::SUCCESS;
776 return StatusCode::SUCCESS;
779 int gasGap_i = idHelper.
gasGap(channelIdIn);
780 int channel_i = idHelper.
channel(channelIdIn);
781 double width_i = !idHelper.
isStrip(channelIdIn)
783 : descriptor_i->
stripWidth(gasGap_i, channel_i);
788 return StatusCode::SUCCESS;
793 bool onSurface_i = descriptor_i->
surface(channelIdIn)
798 "Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* "
799 "hitPos_i is null.");
800 return StatusCode::SUCCESS;
816 idHelper.
isStrip(channelIdOut),
826 coincollection->size());
827 coincollection->push_back(newCoinData);
833 return StatusCode::SUCCESS;
847 bool isForward = (rd.
slbId() % 2 == 0);
859 int slot = ((rd.
slbId() / 2) + (rd.
rodId() - 2) * 2 + 23) % 24 + 1;
861 bool isBackward =
false;
865 isBackward = !isAside;
866 }
else if (slot == 16) {
867 isBackward = isAside;
872 isBackward = (slot % 3 == 2);
874 isBackward = (slot % 3 != 2);
878 isBackward = isAside;
888 int tmpsubMatrix =
static_cast<int>(rd.
subMatrix());
892 if (tmpsubMatrix == 3) {
893 if (slot == 1 || slot == 3 || slot == 4 || slot == 5 ||
894 slot == 6 || slot == 7 || slot == 8 || slot == 10 ||
895 slot == 11 || slot == 13 || slot == 18 || slot == 19 ||
900 }
else if (tmpsubMatrix == 2) {
901 if (slot == 2 || slot == 12 || slot == 14 || slot == 15 ||
902 slot == 16 || slot == 22 || slot == 23 || slot == 24) {
932 "Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI OfflineID not "
937 <<
" bitpos=" << bitpos <<
" isStrip=" << isStrip
938 <<
" isAside=" << isAside <<
" isForward=" << isForward
939 <<
" slot=" << slot <<
" isBackward=" << isBackward);
940 return StatusCode::SUCCESS;
951 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection =
953 if (!coincollection) {
955 std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
956 coincollection->setIdentifier(
m_idHelperSvc->chamberId(channelIdIn));
960 for (
const TgcCoinData* tgcCoinData : *coincollection) {
962 tgcCoinData->type() &&
963 channelIdIn == tgcCoinData->channelIdIn() &&
964 static_cast<int>(rd.
subMatrix()) == tgcCoinData->sub()) {
967 return StatusCode::SUCCESS;
975 "Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI descriptor "
978 return StatusCode::SUCCESS;
984 bool onSurface = descriptor->
surface(channelIdIn)
989 "Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI Amg::Vector2D* "
991 return StatusCode::SUCCESS;
995 int gasGap = idHelper.
gasGap(channelIdIn);
996 int channel = idHelper.
channel(channelIdIn);
999 double localZ = (descriptor->
transform(channelIdIn).inverse() *
1006 width = std::abs(stripMaxX - stripMinX);
1008 int positiveOffset = +4;
1009 if (isForward && (slot % 3 == 2) && channel == 28) {
1010 positiveOffset = +2;
1013 descriptor->
gangLongWidth(gasGap, channel + positiveOffset);
1014 double gangMinZ = descriptor->
gangShortWidth(gasGap, channel - 3);
1015 width = std::abs(gangMaxZ - gangMinZ);
1031 coincollection->size());
1032 coincollection->push_back(newCoinData);
1036 return StatusCode::SUCCESS;
1054 "TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
1055 return StatusCode::SUCCESS;
1059 if (rd.
hitId() == 0) {
1061 "Invalid hitId_rdo_hipt, hitId == 0!! skip to convert this RDO to "
1063 return StatusCode::SUCCESS;
1065 int slbsubMatrix = 0;
1072 std::array<Identifier, 2> channelIdOut{};
1073 std::array<int, 2> bitpos_o{}, slbchannel_o{};
1074 int sswId_o{0}, sbLoc_o{0}, slbId_o{0};
1077 std::array<Identifier, 4> channelIdIn{};
1078 std::array<int, 4> bitpos_i{}, slbchannel_i{};
1079 int sswId_i{0}, sbLoc_i{0};
1081 std::array<int, 4> slbId_in{}, sbLoc_in{};
1083 std::array<int, 4> gasGap_i{}, channel_i{};
1084 double width_i{0.}, hit_position_i{0};
1087 std::array<int, 2> gasGap_o{}, channel_o{};
1088 double width_o{0.}, hit_position_o{0.};
1096 found =
getHiPtIds(state, rd, sswId_o, sbLoc_o, slbId_o);
1098 return StatusCode::SUCCESS;
1107 for (
int i = 0; i < 2; i++) {
1112 ATH_MSG_DEBUG(
"Failed to get OfflineID from ReadoutID for Pivot "
1113 << (rd.
isStrip() ?
"Strip" :
"Wire") <<
".");
1114 return StatusCode::SUCCESS;
1125 slbId_in, sbLoc_in, sswId_i, bitpos_o, slbchannel_o,
1129 sbLoc_i, sswId_i, bitpos_o, slbchannel_o);
1131 for (
int i = 0; i < 4; i++) {
1134 rd.
isStrip() ? sbLoc_i : sbLoc_in[i], bitpos_i[i]);
1136 ATH_MSG_DEBUG(
"Failed to get OfflineID from ReadoutID for Pivot "
1137 << (rd.
isStrip() ?
"Strip" :
"Wire") <<
".");
1138 return StatusCode::SUCCESS;
1154 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection =
1156 if (!coincollection) {
1158 std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1159 coincollection->setIdentifier(
1165 std::array<const MuonGM::TgcReadoutElement*, 2> descriptor_o{
1168 for (
int i = 0; i < 2; i++) {
1171 return StatusCode::SUCCESS;
1176 for (
int i = 0; i < 2; i++) {
1177 gasGap_o[i] = idHelper.
gasGap(channelIdOut[i]);
1178 channel_o[i] = idHelper.
channel(channelIdOut[i]);
1183 channel_o, width_o, hit_position_o,
1184 tmp_hitPos_o, channelIdOut_tmp);
1187 channel_o, width_o, hit_position_o,
1188 tmp_hitPos_o, channelIdOut_tmp, isBackward,
1192 return StatusCode::SUCCESS;
1197 return StatusCode::SUCCESS;
1202 return StatusCode::SUCCESS;
1209 std::array<const MuonGM::TgcReadoutElement*, 4> descriptor_i{
1214 for (
int i = 0; i < 4; i++) {
1217 return StatusCode::SUCCESS;
1220 for (
int i = 0; i < 4; i++) {
1221 gasGap_i[i] = idHelper.
gasGap(channelIdIn[i]);
1222 channel_i[i] = idHelper.
channel(channelIdIn[i]);
1227 channel_i, width_i, hit_position_i,
1228 tmp_hitPos_i, channelIdIn_tmp);
1231 channel_i, width_i, hit_position_i,
1232 tmp_hitPos_i, channelIdIn_tmp, isBackward,
1236 return StatusCode::SUCCESS;
1241 return StatusCode::SUCCESS;
1246 return StatusCode::SUCCESS;
1251 int trackletId = 2 * sbLoc_o + slbsubMatrix;
1252 int delta =
static_cast<int>(rd.
delta());
1253 int hsub =
static_cast<int>(rd.
hsub());
1254 int inner =
static_cast<int>(rd.
inner());
1257 for (
const TgcCoinData* tgcCoinData : *coincollection) {
1259 tgcCoinData->type()) &&
1260 (channelIdOut_tmp ==
1261 tgcCoinData->identify()) &&
1263 (channelIdIn_tmp == tgcCoinData->channelIdIn()) &&
1264 (trackletId == tgcCoinData->trackletId()) &&
1265 (delta == tgcCoinData->delta()) &&
1266 (hsub == tgcCoinData->sub()) &&
1267 (inner == tgcCoinData->inner())) {
1268 if (38 <= trackletId && trackletId <= 41) {
1275 return StatusCode::SUCCESS;
1279 auto hitPos_o = std::make_unique<Amg::Vector2D>(tmp_hitPos_o);
1280 auto hitPos_i = std::make_unique<Amg::Vector2D>(tmp_hitPos_i);
1283 channelIdIn_tmp, channelIdOut_tmp,
1294 hitPos_i.release(), hitPos_o.release(), width_i, width_o,
1300 coincollection->size());
1301 coincollection->push_back(newCoinData);
1307 return StatusCode::SUCCESS;
1317 if (subDetectorId !=
ASIDE && subDetectorId !=
CSIDE) {
1319 "TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
1320 return StatusCode::SUCCESS;
1323 bool isInner = ((rd.
sector() & 4) != 0);
1328 int sbLoc_o = rd.
sector() & 3;
1329 int inner = rd.
inner();
1333 bool isAside =
false;
1334 bool isEndcap =
false;
1335 if (rd.
rodId() < 13) {
1337 subDetectorId, rd.
rodId(),
1397 auto hitPos_o = std::make_unique<Amg::Vector2D>(Amg::Vector2D::Zero());
1398 auto hitPos_i = std::make_unique<Amg::Vector2D>(Amg::Vector2D::Zero());
1403 std::string stationName =
"T3E";
1411 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection =
1413 if (!coincollection) {
1415 std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1416 coincollection->setIdentifier(elementId);
1420 <<
phi <<
" isAside: " << isAside <<
" isEndcap: " << isEndcap
1421 <<
" subDetectorId: " << subDetectorId
1422 <<
" isStrip: " << rd.
isStrip() <<
" rodId: " << rd.
rodId()
1423 <<
" slbId: " << sbLoc_o <<
" inner:" << rd.
inner());
1441 hitPos_i.release(), hitPos_o.release(),
1449 coincollection->size());
1450 coincollection->push_back(newCoinData);
1452 ATH_MSG_DEBUG(
"coincollection->push_back done (for Inner)");
1456 return StatusCode::SUCCESS;
1461 const TgcRdo* rdoColl)
const {
1475 "TgcRdoToPrepDataToolMT::decodeSL::Unknown subDetectorId!!");
1476 return StatusCode::SUCCESS;
1481 std::array<Identifier, 3> channelId_wire{};
1482 int index_w{0}, chip_w{0}, hitId_w{0}, sub_w{0}, sswId_w{0}, sbLoc_w{0},
1484 std::array<int, 3> bitpos_w{};
1487 found =
getSLIds(state,
false, rd, channelId_wire, index_w, chip_w, hitId_w, sub_w,
1488 sswId_w, sbLoc_w, subMatrix_w, bitpos_w);
1490 return StatusCode::SUCCESS;
1493 std::array<Identifier, 3> channelId_strip{};
1494 int index_s{0}, chip_s{0}, hitId_s{0}, sub_s{0}, sswId_s{0}, sbLoc_s{0},
1496 std::array<int, 3> bitpos_s{};
1499 found =
getSLIds(state,
true, rd, channelId_strip, index_s, chip_s, hitId_s, sub_s,
1500 sswId_s, sbLoc_s, subMatrix_s, bitpos_s,
1504 return StatusCode::SUCCESS;
1518 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection =
1520 if (!coincollection) {
1522 std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1523 coincollection->setIdentifier(
1527 int trackletId = 2 * sbLoc_w + subMatrix_w;
1528 int trackletIdStrip = 2 * sbLoc_s + subMatrix_s;
1529 int roi =
static_cast<int>(rd.
roi());
1531 if (rd0.
rodId() > 12) {
1532 pt += (
static_cast<int>(rd.
coinflag()) << 4);
1536 bool isPositiveDeltaR =
1540 for (
const TgcCoinData* tgcCoinData : *coincollection) {
1542 channelId_wire[2] == tgcCoinData->identify() &&
1543 trackletId == tgcCoinData->trackletId() &&
1544 trackletIdStrip == tgcCoinData->trackletIdStrip() &&
1545 roi == tgcCoinData->roi() &&
pt == tgcCoinData->pt() &&
1546 veto == tgcCoinData->veto() &&
1547 isPositiveDeltaR == tgcCoinData->isPositiveDeltaR()) {
1550 return StatusCode::SUCCESS;
1555 double width_w{0.}, tmp_r{0.}, tmp_wire_z{0.};
1558 return StatusCode::SUCCESS;
1563 return StatusCode::SUCCESS;
1566 double tmp_eta = 0.;
1567 bool isGoodEta =
getEtafromRZ(tmp_r, tmp_wire_z, tmp_eta);
1570 "Conversion from r and z to eta by "
1571 "Muon::TgcRdoToPrepDataToolMT::getEtafromRZ failed.");
1572 return StatusCode::SUCCESS;
1574 if (tmp_wire_z < 0.) {
1580 double width_s{0.}, tmp_phi{0.};
1584 return StatusCode::SUCCESS;
1589 return StatusCode::SUCCESS;
1595 return StatusCode::SUCCESS;
1598 Amg::Vector3D tmp_gp(tmp_r * std::cos(tmp_phi), tmp_r * std::sin(tmp_phi),
1601 bool onSurface = descriptor_w2->
surface(channelId_wire[2])
1612 mat(0, 0) = width_w;
1613 mat(1, 1) = width_s;
1635 coincollection->size());
1636 coincollection->push_back(newCoinData);
1640 return StatusCode::SUCCESS;
1651 if (channel % 3 == 0) {
1653 }
else if (channel % 3 == 1) {
1658 return bitpos + channel / 3;
1665 if (channel % 2 == 0) {
1670 return bitpos + channel / 2;
1676 if (channel % 2 == 0) {
1681 return bitpos + channel / 2;
1712 }
else if (input == 1) {
1717 channel = 3 * (bitpos - channel) + input;
1728 channel = 2 * (bitpos - channel) + input - 1;
1736 const double z,
double&
r) {
1747 double r_tmp = std::abs(
r);
1748 double z_tmp = std::abs(
z);
1750 if ((r_tmp < std::numeric_limits<double>::epsilon()) &&
1751 (z_tmp < std::numeric_limits<double>::epsilon())) {
1755 eta = std::abs(atan2(r_tmp, z_tmp));
1764 if (!descriptor || !descriptor->
containsId(channelId)) {
1775 int& tmp_position)
const {
1777 if (tmp_subMatrix != 0 && tmp_subMatrix != 1) {
1778 ATH_MSG_DEBUG(
"getTrackletInfo: subMatrix " << tmp_subMatrix
1783 int tmp_sswId = rd.
sswId();
1784 tmp_slbId = rd.
slbId();
1787 int tmp_position_delta = tmp_position + rd.
delta();
1788 int tmp_slbType = rd.
slbType();
1792 if (tmp_subMatrix == 1) {
1796 "Expected TGC2 Strip position ("
1797 << tmp_position_delta
1798 <<
") does not exist and is changed to the edge position "
1802 ((tmp_slbId == 3) || (tmp_slbId == 11))) {
1805 <<
" doesn't exist for FWD!! (upper "
1806 "edge SLB of FWD:sbLoc3,11)");
1809 (tmp_sswId != 7) && (tmp_slbId == 9)) {
1812 <<
" doesn't exist for EWD!! (upper "
1813 "edge SLB of EWD:sbLoc9)");
1823 }
else if (tmp_position_delta < 0) {
1825 if (tmp_subMatrix == 0) {
1829 "Expected TGC2 Strip position ("
1830 << tmp_position_delta
1831 <<
") does not exist and is changed to the edge position "
1835 ((tmp_slbId == 0) || (tmp_slbId == 8))) {
1837 if (tmp_position_delta == -1) {
1842 <<
" doesn't exist for FWD!! (bottom edge "
1843 "SLB of FWD:sbLoc0,8)");
1847 (tmp_sswId != 7) && (tmp_slbId == 0)) {
1849 if (tmp_position_delta == -1) {
1854 <<
" doesn't exist for EWD!! (bottom edge "
1855 "SLB of EWD:sbLoc0)");
1867 tmp_position = tmp_position_delta;
1874 int RoiRow =
static_cast<int>(rd.
roi() / 4);
1883 (RoiRow == 3 || RoiRow == 4 ||
1884 RoiRow == 7 || RoiRow == 8 ||
1885 RoiRow == 11 || RoiRow == 12 ||
1886 RoiRow == 23 || RoiRow == 24
1894 const TgcRawData& rd,
int& slbsubMatrix, std::array<int, 2>& bitpos_o) {
1896 if ((rd.
hitId() % 2) == 1) {
1898 if ((rd.
hsub()) == 0) {
1901 }
else if ((rd.
hsub()) == 1) {
1907 if ((rd.
hsub()) == 0) {
1910 }
else if ((rd.
hsub()) == 1) {
1925 if ((rd.
chip() == 0) && (rd.
hitId() == 1) && (rd.
hsub() == 1)) {
1930 }
else if ((rd.
chip() == 3) && (rd.
hitId() == 6) &&
1936 if ((rd.
chip() == 0) && (rd.
hitId() == 1) &&
1940 }
else if ((rd.
chip() == 1) && (rd.
hitId() == 2) &&
1950 const TgcRawData& rd,
const int deltaBeforeConvert,
1951 std::array<int, 4>& bitpos_i, std::array<int, 4>& slbchannel_i,
1952 std::array<int, 4>& slbId_in, std::array<int, 4>& sbLoc_in,
int& sswId_i,
1953 const std::array<int, 2>& bitpos_o, std::array<int, 2>& slbchannel_o,
1954 const int slbId_o)
const {
1956 const int NUM_SLBID_SBLOC_OFFSET_WT =
1962 int rdochIn_max = 0;
1963 int rdochIn_min = 0;
1975 int tmp_rdochannel_i = 0;
1976 int tmp_rdochannel_i2 = 0;
1977 for (
int i = 0; i < 2; i++) {
1980 tmp_rdochannel_i =
WD_MAP_SIZE * slbId_o + slbchannel_o[i] +
1981 deltaBeforeConvert + offset_dt;
1982 if (tmp_rdochannel_i > rdochIn_max) {
1983 tmp_rdochannel_i = rdochIn_max;
1984 }
else if (tmp_rdochannel_i < rdochIn_min) {
1985 tmp_rdochannel_i = rdochIn_min;
2001 tmp_rdochannel_i2 = (tmp_rdochannel_i / 3) * 3 + 2;
2003 tmp_rdochannel_i2 = ((tmp_rdochannel_i + 1) / 3) * 3 - 1;
2006 if (tmp_rdochannel_i2 > rdochIn_max) {
2007 tmp_rdochannel_i2 = rdochIn_max;
2008 }
else if (tmp_rdochannel_i2 < rdochIn_min) {
2009 tmp_rdochannel_i2 = rdochIn_min + 2;
2013 slbId_in[i + 2] = tmp_rdochannel_i2 /
WT_MAP_SIZE;
2015 sbLoc_in[i] = slbId_in[i];
2016 sbLoc_in[i + 2] = slbId_in[i + 2];
2017 if (rd.
sector() % 2 == 1) {
2022 sbLoc_in[i] += NUM_SLBID_SBLOC_OFFSET_WT;
2023 sbLoc_in[i + 2] += NUM_SLBID_SBLOC_OFFSET_WT;
2027 slbchannel_i[i + 2] = tmp_rdochannel_i2 %
WT_MAP_SIZE;
2036 sswId_i =
static_cast<int>(rd.
sector() / 2);
2043 const TgcRawData& rd,
int& slbsubMatrix, std::array<int, 2>& bitpos_o) {
2045 if ((rd.
hitId() % 2) == 1) {
2047 if ((rd.
hsub()) == 0) {
2052 }
else if ((rd.
hsub()) == 1) {
2060 if ((rd.
hsub()) == 0) {
2065 }
else if ((rd.
hsub()) == 1) {
2075 const TgcRawData& rd,
const int deltaBeforeConvert,
2076 std::array<int, 4>& bitpos_i, std::array<int, 4>& slbchannel_i,
2077 int& sbLoc_i,
int& sswId_i,
const std::array<int, 2>& bitpos_o,
2078 std::array<int, 2>& slbchannel_o)
const {
2083 int rdochIn_min = 0;
2085 if ((rd.
sector() % 2) == 0) {
2086 if (rd.
chip() == 0) {
2088 }
else if (rd.
chip() == 1) {
2092 if (rd.
chip() == 0) {
2094 }
else if (rd.
chip() == 1) {
2099 for (
int i = 0; i < 2; i++) {
2102 slbchannel_i[i] = slbchannel_o[i] + deltaBeforeConvert;
2103 if (slbchannel_i[i] > rdochIn_max) {
2104 slbchannel_i[i] = rdochIn_max;
2105 }
else if (slbchannel_i[i] < rdochIn_min) {
2106 slbchannel_i[i] = rdochIn_min;
2110 slbchannel_i[i + 2] = slbchannel_i[i] + 1;
2112 slbchannel_i[i + 2] = slbchannel_i[i] - 1;
2115 if (slbchannel_i[i + 2] > rdochIn_max) {
2116 slbchannel_i[i + 2] = rdochIn_max;
2117 }
else if (slbchannel_i[i + 2] < rdochIn_min) {
2118 slbchannel_i[i + 2] = rdochIn_min;
2128 sswId_i =
static_cast<int>(rd.
sector() / 2);
2135 const TgcRawData& rd,
const int hitId_w,
const int sub_w,
int& subMatrix_w,
2136 std::array<int, 3>& bitpos_w)
const {
2148 if (RoiRow == 0 && !isForward) {
2154 }
else if (RoiRow == 36 && !isForward) {
2160 }
else if (RoiRow == 0 && isForward) {
2166 }
else if (RoiRow == 15 && isForward) {
2173 if ((hitId_w % 2) == 0) {
2179 }
else if (sub_w == 1) {
2190 }
else if (sub_w == 1) {
2200 const int hitId_s,
const int sub_s,
int& subMatrix_s,
2201 std::array<int, 3>& bitpos_s) {
2207 if ((hitId_s % 2) == 0) {
2216 }
else if (sub_s == 1) {
2224 }
else if ((hitId_s % 2) == 1) {
2233 }
else if (sub_s == 1) {
2245 int deltaBeforeConvert = 0;
2248 switch (rd.
delta()) {
2250 deltaBeforeConvert = 6;
2253 deltaBeforeConvert = 8;
2256 deltaBeforeConvert = 10;
2259 deltaBeforeConvert = -5;
2262 deltaBeforeConvert = -7;
2265 deltaBeforeConvert = -9;
2268 deltaBeforeConvert = -12;
2271 deltaBeforeConvert = rd.
delta();
2275 switch (rd.
delta()) {
2277 deltaBeforeConvert = 12;
2280 deltaBeforeConvert = 14;
2283 deltaBeforeConvert = 16;
2286 deltaBeforeConvert = 18;
2289 deltaBeforeConvert = 20;
2292 deltaBeforeConvert = -13;
2295 deltaBeforeConvert = -15;
2298 deltaBeforeConvert = -17;
2301 deltaBeforeConvert = -19;
2304 deltaBeforeConvert = rd.
delta();
2309 return deltaBeforeConvert;
2313 bool isBackward =
false;
2336 const std::array<Identifier, 3>& channelId_wire,
double& width_wire,
2337 double& r_wire,
double& z_wire)
const {
2341 std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_w{
2345 for (
int i = 0; i < 3; i++) {
2347 channelId_wire[i])) {
2352 Amg::Vector3D position_w = descriptor_w[2]->channelPos(channelId_wire[2]);
2354 bool onSurface_w = descriptor_w[2]
2355 ->surface(channelId_wire[2])
2356 .globalToLocal(position_w, position_w, loc_hitPos_w);
2359 "Muon::TgcRdoToPrepDataToolMT::getSLWireGeometry Amg::Vector2D* "
2360 "loc_hitPos_w is null.");
2365 std::array<int, 3> gasGap_w{}, channel_w{};
2366 for (
int i = 0; i < 3; i++) {
2367 gasGap_w[i] =
m_idHelperSvc->tgcIdHelper().gasGap(channelId_wire[i]);
2368 channel_w[i] =
m_idHelperSvc->tgcIdHelper().channel(channelId_wire[i]);
2371 std::array<double, 3> tmp_r_w{}, tmp_phi_w{}, tmp_eta_w{};
2373 std::array<Amg::Vector3D, 3> tmp_position_w{
2375 for (
int i = 0; i < 3; i += 2) {
2376 tmp_position_w[i] = descriptor_w[i]->channelPos(channelId_wire[i]);
2377 tmp_r_w[i] = tmp_position_w[i].perp();
2378 tmp_phi_w[i] = tmp_position_w[i].phi();
2379 tmp_eta_w[i] = tmp_position_w[i].eta();
2382 descriptor_w[i]->gangRadialLength(gasGap_w[i], channel_w[i]) / 2.;
2390 tmp_r_w[0] += half_width;
2391 }
else if (i == 2) {
2392 tmp_r_w[2] -= half_width;
2396 bool flag_geteta_w =
2397 getEtafromRZ(tmp_r_w[0], tmp_position_w[0].
z(), tmp_eta_w[0]);
2399 getRfromEtaZ(tmp_eta_w[0], tmp_position_w[2].
z(), tmp_r_w[0]);
2400 if (!flag_geteta_w || !flag_getr_w) {
2402 "TgcRdoToPrepDataToolMT::getSLWireGeometry::failed to getR on "
2406 width_wire = tmp_r_w[0] - tmp_r_w[2];
2407 double gang = descriptor_w[2]->gangShortWidth(gasGap_w[2], channel_w[2]) +
2414 ->surface(channelId_wire[2])
2415 .localToGlobal(tmp_hitPos_w, tmp_wire_gp, tmp_wire_gp);
2416 z_wire = tmp_wire_gp.z();
2417 r_wire = tmp_r_w[2] + width_wire / 2.;
2423 const std::array<Identifier, 3>& channelId_strip,
const bool isBackward,
2424 const bool isAside,
double& width_strip,
double& theta_strip)
const {
2428 std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_s{
2432 for (
int i = 0; i < 3; i++) {
2434 channelId_strip[i])) {
2440 Amg::Vector3D(descriptor_s[1]->channelPos(channelId_strip[1]));
2442 bool onSurface_s = descriptor_s[1]
2443 ->surface(channelId_strip[1])
2444 .globalToLocal(position_s, position_s, loc_hitPos_s);
2447 "Muon::TgcRdoToPrepDataToolMT::getSLStripGeometry Amg::Vector2D* "
2448 "loc_hitPos_s is null.");
2453 std::array<int, 3> gasGap_s, channel_s{};
2454 for (
int i = 0; i < 3; i++) {
2455 gasGap_s[i] =
m_idHelperSvc->tgcIdHelper().gasGap(channelId_strip[i]);
2456 channel_s[i] =
m_idHelperSvc->tgcIdHelper().channel(channelId_strip[i]);
2459 std::array<Amg::Vector3D, 3> localPos{Amg::Vector3D::Zero()};
2460 for (
int i = 0; i < 3; i += 2) {
2461 localPos[i] = descriptor_s[i]->transform(channelId_strip[i]).inverse() *
2462 descriptor_s[i]->channelPos(channelId_strip[i]);
2465 bool flag_reverse =
false;
2466 std::array<int, 2> index_strip{};
2472 flag_reverse =
true;
2476 flag_reverse =
false;
2482 flag_reverse =
true;
2486 flag_reverse =
false;
2490 double stripMaxX = descriptor_s[index_strip[0]]->stripHighEdgeLocX(
2491 gasGap_s[index_strip[0]], channel_s[index_strip[0]],
2492 localPos[index_strip[0]].
z());
2493 double stripMinX = descriptor_s[index_strip[1]]->stripLowEdgeLocX(
2494 gasGap_s[index_strip[1]], channel_s[index_strip[1]],
2495 localPos[index_strip[1]].
z());
2496 width_strip = stripMaxX - stripMinX;
2497 double strip = stripMinX + width_strip / 2.;
2505 int index_strip_gp = 0;
2512 descriptor_s[index_strip_gp]
2513 ->surface(channelId_strip[index_strip_gp])
2514 .localToGlobal(tmp_hitPos_s, tmp_strip_gp, tmp_strip_gp);
2515 theta_strip = atan2(tmp_strip_gp.y(), tmp_strip_gp.x());
2521 const std::array<const MuonGM::TgcReadoutElement*, 2>& descriptor_o,
2522 const std::array<Identifier, 2>& channelIdOut,
2523 const std::array<int, 2>& gasGap_o,
const std::array<int, 2>& channel_o,
2524 double& width_o,
double& hit_position_o,
Amg::Vector2D& tmp_hitPos_o,
2527 std::array<Amg::Vector3D, 2> position_o{
2529 std::array<double, 2> tmp_phi_o{}, tmp_eta_o{}, tmp_r_o{};
2531 for (
int i = 0; i < 2; i++) {
2532 position_o[i] = descriptor_o[i]->channelPos(channelIdOut[i]);
2533 tmp_r_o[i] = position_o[i].perp();
2534 tmp_phi_o[i] = position_o[i].phi();
2535 tmp_eta_o[i] = position_o[i].phi();
2538 descriptor_o[i]->gangRadialLength(gasGap_o[i], channel_o[i]) / 2.;
2545 tmp_r_o[0] += half_width;
2547 tmp_r_o[1] -= half_width;
2551 bool flag_geteta_o =
2555 if (!flag_geteta_o || !flag_getr_o) {
2557 "TgcRdoToPrepDataToolMT::getPosAndIdWireOut::failed to getR on "
2562 width_o = tmp_r_o[0] - tmp_r_o[1];
2565 descriptor_o[1]->gangShortWidth(gasGap_o[1], channel_o[1]) +
2567 tmp_hitPos_o[
Trk::locX] = (hit_position_o);
2570 Amg::Vector3D(descriptor_o[1]->channelPos(channelIdOut[1]));
2575 ->surface(channelIdOut[1])
2576 .globalToLocal(position_out, position_out, loc_hitPos_o);
2579 "Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireOut Amg::Vector2D* "
2580 "loc_hitPos_o is null.");
2585 channelIdOut_tmp = channelIdOut[1];
2591 const std::array<const MuonGM::TgcReadoutElement*, 2>& descriptor_o,
2592 const std::array<Identifier, 2>& channelIdOut,
2593 const std::array<int, 2>& gasGap_o,
const std::array<int, 2>& channel_o,
2594 double& width_o,
double& hit_position_o,
Amg::Vector2D& tmp_hitPos_o,
2595 Identifier& channelIdOut_tmp,
const bool isBackward,
2596 const bool isAside)
const {
2599 std::array<Amg::Vector3D, 2> localpos_o{
2601 for (
int i = 0; i < 2; i++) {
2602 localpos_o[i] = descriptor_o[i]->transform(channelIdOut[i]).inverse() *
2603 descriptor_o[i]->channelPos(channelIdOut[i]);
2606 std::array<int, 3>
index{};
2607 bool flag_reverse =
false;
2613 flag_reverse =
true;
2617 flag_reverse =
false;
2624 flag_reverse =
true;
2628 flag_reverse =
false;
2632 double stripMax = descriptor_o[
index[0]]->stripHighEdgeLocX(
2634 double stripMin = descriptor_o[
index[1]]->stripLowEdgeLocX(
2636 width_o = stripMax - stripMin;
2638 hit_position_o = stripMin + width_o / 2.;
2640 hit_position_o *= -1.;
2642 tmp_hitPos_o[
Trk::locX] = hit_position_o;
2645 Amg::Vector3D(descriptor_o[1]->channelPos(channelIdOut[1]));
2650 ->surface(channelIdOut[1])
2651 .globalToLocal(position_out, position_out, loc_hitPos_o);
2654 "Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripOut Amg::Vector2D* "
2655 "loc_hitPos_o is null.");
2660 channelIdOut_tmp = channelIdOut[
index[2]];
2666 const std::array<const MuonGM::TgcReadoutElement*, 4>& descriptor_i,
2667 const std::array<Identifier, 4>& channelIdIn,
2668 const std::array<int, 4>& gasGap_i,
const std::array<int, 4>& channel_i,
2669 double& width_i,
double& hit_position_i,
Amg::Vector2D& tmp_hitPos_i,
2672 int flag_boundary_i = 0;
2673 if (descriptor_i[1]->chamberType() == descriptor_i[3]->chamberType()) {
2677 flag_boundary_i = 1;
2679 flag_boundary_i = 3;
2681 }
else if (descriptor_i[0]->chamberType() ==
2682 descriptor_i[2]->chamberType()) {
2686 flag_boundary_i = 0;
2688 flag_boundary_i = 2;
2692 "TgcRdoToPrepDataToolMT::getPosAndIdWireIn::ROI has 3 readout "
2697 channelIdIn_tmp = channelIdIn[flag_boundary_i];
2707 std::array<double, 3> tmp_r_i{}, tmp_phi_i{}, tmp_eta_i{};
2709 std::array<Amg::Vector3D, 3> position_i{
2710 descriptor_i[0]->channelPos(channelIdIn[0]),
2711 descriptor_i[1]->channelPos(channelIdIn[1]),
2714 for (
int i = 0; i < 3; i++) {
2715 tmp_r_i[i] = position_i[i].perp();
2716 tmp_phi_i[i] = position_i[i].phi();
2717 tmp_eta_i[i] = position_i[i].eta();
2722 descriptor_i[i]->gangRadialLength(gasGap_i[i], channel_i[i]) /
2730 tmp_r_i[0] += half_width;
2732 tmp_r_i[1] -= half_width;
2735 bool flag_geteta_i =
2740 if (!flag_geteta_i || !flag_getr_i) {
2742 "TgcRdoToPrepDataToolMT::getPosAndIdWireIn::failed to "
2744 << i <<
" on L3!!");
2750 width_i = tmp_r_i[0] - tmp_r_i[1];
2753 "TgcRdoToPrepDataToolMT::getPosAndIdWireIn::minus value width_i = "
2758 int gasGap_tmp =
m_idHelperSvc->tgcIdHelper().gasGap(channelIdIn_tmp);
2759 int channel_tmp =
m_idHelperSvc->tgcIdHelper().channel(channelIdIn_tmp);
2767 if ((flag_boundary_i % 2) ==
2769 tmp_r_i[2] -= half_width;
2772 (tmp_r_i[2] - tmp_r_i[1]) + width_i / 2.;
2774 tmp_r_i[2] += half_width;
2775 hit_position_i = descriptor_iw->
gangLongWidth(gasGap_tmp, channel_tmp) +
2776 (tmp_r_i[0] - tmp_r_i[2]) - width_i / 2.;
2780 tmp_hitPos_i[
Trk::locX] = hit_position_i;
2781 Amg::Vector3D position_in = descriptor_i[1]->channelPos(channelIdIn[1]);
2786 ->surface(channelIdIn[1])
2787 .globalToLocal(position_in, position_in, loc_hitPos_i);
2790 "Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireIn Amg::Vector2D* "
2791 "loc_hitPos_i is null.");
2801 const std::array<const MuonGM::TgcReadoutElement*, 4>& descriptor_i,
2802 const std::array<Identifier, 4>& channelIdIn,
2803 const std::array<int, 4>& gasGap_i,
const std::array<int, 4>& channel_i,
2804 double& width_i,
double& hit_position_i,
Amg::Vector2D& tmp_hitPos_i,
2805 Identifier& channelIdIn_tmp,
const bool isBackward,
2806 const bool isAside)
const {
2810 for (
int i = 0; i < 4; i++) {
2811 if (gasGap_i[i] == 3) {
2816 if (flag_isL3 < 0 || flag_isL3 >= 4) {
2817 ATH_MSG_DEBUG(
"getPosAndIdStripIn: Any bitpos is not at Layer3!");
2821 channelIdIn_tmp = channelIdIn[flag_isL3];
2831 std::array<double, 3> tmp_r_i{}, tmp_phi_i{}, tmp_eta_i{};
2832 std::array<Amg::Vector3D, 3> position_is{
2834 for (
int i = 0; i < 3; i++) {
2836 position_is[i] = descriptor_i[i]->channelPos(channelIdIn[i]);
2838 position_is[i] = descriptor_is->
channelPos(channelIdIn_tmp);
2840 tmp_r_i[i] = position_is[i].perp();
2841 tmp_phi_i[i] = position_is[i].phi();
2842 tmp_eta_i[i] = position_is[i].eta();
2845 std::array<int, 2>
index{};
2846 bool flag_reverse =
false;
2851 flag_reverse =
true;
2855 flag_reverse =
false;
2861 flag_reverse =
true;
2865 flag_reverse =
false;
2869 std::array<Amg::Vector3D, 2> localpos_i{
2871 for (
int i = 0; i < 2; i++) {
2872 localpos_i[i] = descriptor_i[i]->transform(channelIdIn[i]).inverse() *
2873 descriptor_i[i]->channelPos(channelIdIn[i]);
2875 double stripMaxX = descriptor_i[
index[0]]->stripHighEdgeLocX(
2877 double stripMinX = descriptor_i[
index[1]]->stripLowEdgeLocX(
2879 width_i = stripMaxX - stripMinX;
2881 hit_position_i = stripMinX + width_i / 2.;
2883 hit_position_i *= -1.;
2885 tmp_hitPos_i[
Trk::locX] = hit_position_i;
2893 ->surface(channelIdIn[1])
2894 .globalToLocal(position_in, position_in, loc_hitPos_i);
2897 "Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripIn Amg::Vector2D* "
2898 "loc_hitPos_i is null.");
2908 int& sswId_o,
int& sbLoc_o,
2909 int& slbId_o)
const {
2911 int chip =
static_cast<int>(rd.
chip());
2912 int hitId =
static_cast<int>(rd.
hitId());
2918 ATH_MSG_DEBUG(
"Failed to get SimHighPtID from RDOHighPtID for Pivot "
2919 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2928 if (rd.
rodId() > 12) {
2939 ATH_MSG_DEBUG(
"Failed to get offlineID from HighPtID for Pivot "
2940 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2944 std::array<int, 3> dummy_i{};
2946 dummyId, dummy_i[0], dummy_i[1], sswId_o, sbLoc_o, dummy_i[2]);
2948 ATH_MSG_DEBUG(
"Failed to get ReadoutID from OfflineID for Pivot "
2949 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2953 std::array<int, 2> i_o{};
2954 std::array<bool, 2> b_o{
false,
false};
2955 if (rd.
rodId() > 12) {
2957 i_o[0], b_o[0], b_o[1], i_o[1], slbId_o, rd.
subDetectorId(),
2958 tmprodId, sswId_o, sbLoc_o);
2961 i_o[0], b_o[0], b_o[1], i_o[1], slbId_o, rd.
subDetectorId(),
2962 rd.
rodId(), sswId_o, sbLoc_o);
2965 ATH_MSG_DEBUG(
"Failed to get SLBID from ReadoutID for Pivot "
2966 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2974 std::array<Identifier, 3>& channelId,
int&
index,
int& chip,
int& hitId,
2975 int& sub,
int& sswId,
int& sbLoc,
int& subMatrix,
2976 std::array<int, 3>& bitpos,
const bool isBoundary,
const TgcRdo* rdoColl,
2977 const int index_w,
const int chip_w,
const int hitId_w,
2978 const int sub_w)
const
2984 index, chip, hitId, sub);
2987 << (!isStrip ?
"Wire" :
"Strip"));
2994 ATH_MSG_DEBUG(
"Failed to get SimHighPtID from RDOHighPtID for "
2995 << (!isStrip ?
"Wire" :
"Strip"));
3005 << (!isStrip ?
"Wire" :
"Strip"));
3009 if (!isStrip || !isBoundary) {
3011 channelId[1] = offlineId;
3012 std::array<int, 3> dummy_i{};
3014 channelId[1], dummy_i[0], dummy_i[1], sswId, sbLoc, dummy_i[2]);
3017 << (!isStrip ?
"Wire" :
"Strip"));
3026 rd, sbLoc, rdoColl, index_w, chip_w, hitId_w, sub_w);
3027 if (!exist_hipt_s) {
3031 rd, sbLoc, rdoColl, index_w, chip_w, hitId_w, sub_w);
3032 if (!exist_tracklet_s) {
3034 "Failed to find correspond Tracklet_strip for SL!!");
3046 for (
int i = 0; i < 3; i++) {
3047 if (i == 1 && (!isStrip || !isBoundary)) {
3056 << (!isStrip ?
"Wire" :
"Strip"));
3057 if (!isStrip || i == 1) {
3060 <<
", rodId = " << rd.
rodId()
3061 <<
", sswId = " << sswId <<
", slbId = " << sbLoc
3062 <<
", bitpos_" << (!isStrip ?
"w" :
"s") <<
"["
3063 << i <<
"] = " << bitpos[i]);
3073 const TgcRawData& rd,
int& sbLoc,
const TgcRdo* rdoColl,
const int index_w,
3074 const int chip_w,
const int hitId_w,
const int sub_w)
const {
3076 bool exist_hipt_s =
false;
3079 int trackletIdStripFirst{-1}, trackletIdStripSecond{-1},
3080 trackletIdStripThird{-1};
3082 static_cast<int>(rd.
roi()), trackletIdStripFirst, trackletIdStripSecond,
3083 trackletIdStripThird);
3091 const TgcRawData rdH(rdH0->bcTag(), rdH0->subDetectorId(), tmprodId,
3092 rdH0->l1Id(), rdH0->bcId(), rdH0->isStrip(),
3093 rdH0->isForward(), tmpsector, rdH0->chip(),
3094 rdH0->index(), rdH0->isHipt(), rdH0->hitId(),
3095 rdH0->hsub(), rdH0->delta(), rdH0->inner());
3108 int sswId_o{0}, sbLoc_o{0}, slbId_o{0};
3109 bool found =
getHiPtIds(state, rdH, sswId_o, sbLoc_o, slbId_o);
3115 int slbsubMatrix = 0;
3116 std::array<int, 2> bitpos_o{};
3120 int trackletIdStrip = 2 * sbLoc_o + slbsubMatrix;
3123 if (trackletIdStrip != trackletIdStripFirst &&
3124 trackletIdStrip != trackletIdStripSecond &&
3125 trackletIdStrip != trackletIdStripThird) {
3131 if (exist_hipt_s && trackletIdStrip == trackletIdStripThird) {
3136 int index_w_tmp = index_w;
3137 int chip_w_tmp = chip_w;
3138 int hitId_w_tmp = hitId_w;
3143 index_w_tmp, chip_w_tmp, hitId_w_tmp);
3146 "Failed to get RDOHighPtID from SimHighPtID for Wire");
3151 int chip_s =
static_cast<int>(rdH.
chip());
3152 int hitId_s =
static_cast<int>(rdH.
hitId());
3153 int hsub_s =
static_cast<int>(rdH.
hsub());
3168 "Failed to get ROINumber from HighPtID for Strip");
3172 if (roi == rd.
roi()) {
3174 exist_hipt_s =
true;
3175 if (trackletIdStrip == trackletIdStripFirst) {
3183 return exist_hipt_s;
3187 const TgcRawData& rd,
int& sbLoc,
const TgcRdo* rdoColl,
const int index_w,
3188 const int chip_w,
const int hitId_w,
const int sub_w)
const {
3190 bool exist_tracklet_s =
false;
3193 int trackletIdStripFirst{-1}, trackletIdStripSecond{-1},
3194 trackletIdStripThird{-1};
3196 static_cast<int>(rd.
roi()), trackletIdStripFirst, trackletIdStripSecond,
3197 trackletIdStripThird);
3203 uint16_t tmprodId{0}, tmpsector{0};
3205 const TgcRawData rdS(rdS0->bcTag(), rdS0->subDetectorId(), tmprodId,
3206 rdS0->sswId(), rdS0->slbId(), rdS0->l1Id(),
3207 rdS0->bcId(), rdS0->slbType(), rdS0->delta(),
3208 rdS0->segment(), rdS0->subMatrix(),
3211 bool isForward_s = (rdS.
sswId() == 7);
3227 int trackletIdStrip =
static_cast<int>(
3230 if (trackletIdStrip != trackletIdStripFirst &&
3231 trackletIdStrip != trackletIdStripSecond &&
3232 trackletIdStrip != trackletIdStripThird) {
3238 if (exist_tracklet_s && trackletIdStrip == trackletIdStripThird) {
3249 "Failed to get OfflineID from LowPtCoincidenceID for "
3254 std::array<int, 7> i{};
3255 std::array<bool, 2> b{};
3257 offlineId, i[0], i[1], i[2], b[0], b[1], i[3], i[4], i[5],
3265 "Failed to get HighPtID from OfflineID for Strip");
3270 int index_w_tmp = index_w;
3271 int chip_w_tmp = chip_w;
3272 int hitId_w_tmp = hitId_w;
3281 "Failed to get RDOHighPtID from SimHighPtID for Wire");
3293 "Failed to get RDOHighPtID from SimHighPtID for Strip");
3310 "Failed to get ROINumber from HighPtID for Strip");
3314 if (roi == rd.
roi()) {
3315 sbLoc = rdS.
slbId();
3316 exist_tracklet_s =
true;
3317 if (trackletIdStrip == trackletIdStripFirst) {
3325 return exist_tracklet_s;
3329 const int roi,
int& trackletIdStripFirst,
int& trackletIdStripSecond,
3330 int& trackletIdStripThird) {
3331 constexpr int T9SscMax = 2;
3332 constexpr int T8SscMax = 4;
3333 constexpr int T7SscMax = 6;
3334 constexpr int T6SscMax = 12;
3335 constexpr int T5SscMax = 18;
3337 constexpr int T9Offset = 32 + 0;
3338 constexpr int T8Offset = 32 + 2;
3339 constexpr int T7Offset = 32 + 4;
3340 constexpr int T6Offset = 32 + 6;
3341 constexpr int T5Offset = 32 + 8;
3346 int ssc = (roi + 4) / 8;
3347 int halfSsc = (roi % 4) / 2;
3349 if (ssc < T9SscMax) {
3350 trackletIdStripFirst = T9Offset + halfSsc;
3351 trackletIdStripSecond = -1;
3352 trackletIdStripThird = -1;
3353 }
else if (ssc == T9SscMax) {
3354 trackletIdStripFirst = T8Offset + halfSsc;
3355 trackletIdStripSecond = T9Offset + halfSsc;
3356 trackletIdStripThird = -1;
3357 }
else if (ssc < T8SscMax) {
3358 trackletIdStripFirst = T8Offset + halfSsc;
3359 trackletIdStripSecond = -1;
3360 trackletIdStripThird = -1;
3361 }
else if (ssc == T8SscMax) {
3362 trackletIdStripFirst = T7Offset + halfSsc;
3363 trackletIdStripSecond = T8Offset + halfSsc;
3364 trackletIdStripThird = -1;
3365 }
else if (ssc < T7SscMax) {
3366 trackletIdStripFirst = T7Offset + halfSsc;
3367 trackletIdStripSecond = -1;
3368 trackletIdStripThird = -1;
3369 }
else if (ssc == T7SscMax) {
3370 trackletIdStripFirst = T6Offset + halfSsc;
3371 trackletIdStripSecond = T7Offset + halfSsc;
3372 trackletIdStripThird =
3374 }
else if (ssc < T6SscMax) {
3375 trackletIdStripFirst = T6Offset + halfSsc;
3376 trackletIdStripSecond =
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 =
3387 trackletIdStripThird = -1;
3389 trackletIdStripFirst = -1;
3390 trackletIdStripSecond = -1;
3391 trackletIdStripThird = -1;
3399 const double eta,
const double phi) {
3401 return Amg::Vector2D::Zero();
3405 constexpr double length = 100.;
3406 constexpr unsigned int nRep = 10;
3407 constexpr double dRAccuracy = 1.0E-20;
3408 constexpr double maxLocR = 10000.;
3412 for (
unsigned int iRep = 0; iRep < nRep; iRep++) {
3416 loc_hitPos_c, tmp_glob_hitPos_c, tmp_glob_hitPos_c);
3419 double glob_eta_c = glob_hitPos_c.eta();
3420 double glob_phi_c = glob_hitPos_c.phi();
3425 if (dR < dRAccuracy) {
3437 loc_hitPos_w, tmp_glob_hitPos_w, tmp_glob_hitPos_w);
3441 loc_hitPos_s, tmp_glob_hitPos_s, tmp_glob_hitPos_s);
3445 matrix(0, 0) = glob_hitPos_w.eta() - glob_eta_c;
3446 matrix(1, 0) =
deltaPhi(glob_hitPos_w.phi(), glob_phi_c);
3447 matrix(0, 1) = glob_hitPos_s.eta() - glob_eta_c;
3448 matrix(1, 1) =
deltaPhi(glob_hitPos_s.phi(), glob_phi_c);
3450 bool invertible = matrix.determinant();
3454 locX +=
length * solution(0, 0);
3455 locY +=
length * solution(1, 0);
3457 double locR = sqrt(locX * locX + locY * locY);
3458 if (locR > maxLocR) {
3459 locX *= maxLocR / locR;
3460 locY *= maxLocR / locR;
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
constexpr std::array< T, N > make_array(const T &def_val)
Helper function to initialize in-place arrays with non-zero values.
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
#define AmgSymMatrix(dim)
unsigned bcTag(unsigned bcBitMap)
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
bool empty() const
return true if container is empty
size_t size() const
Duplicate of fullSize for backwards compatability.
This is a "hash" representation of an Identifier.
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const TgcReadoutElement * getTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Amg::Vector3D channelPos(const Identifier &id) const
Returns the position of the active channel (wireGang or strip)
double stripHighEdgeLocX(int gasGap, int strip, double radialPos) const
Returns the local X of the right edge of the strip at a given local radial position.
double gangShortWidth(int gasGap, int gang) const
Returns the length of the most bottom wire in the gang.
double stripWidth(int gasGap, int strip) const
Returns the width of a given strip in the gasGap i.
double stripLowEdgeLocX(int gasGap, int strip, double radialPos) const
Returns the local X of the left edge of the strip at a given local radial position.
double gangLongWidth(int gasGap, int gang) const
Returns the length of the most top wire in the gang.
double gangRadialLength(int gasGap, int gang) const
Returns the length of the wire gang along the radial direction [pitch x N_{wire}^{gang}...
virtual bool containsId(const Identifier &id) const override
int stationPhi(const Identifier &id) const
bool getOfflineIDfromHighPtID(Identifier &offlineID, const int subDetectorID, const int rodID, const int sectorInReadout, const bool isStrip, const bool isForward, const int hpb, const int chip, const int hitID, const int pos) const
bool getSLBIDfromReadoutID(int &phi, bool &isAside, bool &isEndcap, int &moduleType, int &id, const int subsectorID, const int rodID, const int sswID, const int sbLoc) const
bool getHighPtIDfromOfflineID(const Identifier &offlineID, int &subDetectorID, int &rodID, int §orInReadout, bool &isStrip, bool &isForward, int &hpb, int &chip, int &hitID, int &pos) const
bool getElementIDfromReadoutID(Identifier &elementID, const int subDetectorID, const int rodID, const int sswID, const int sbLoc, const int channelID, bool orChannel=false) const
bool getRDOHighPtIDfromSimHighPtID(const bool isForward, const bool isStrip, int &index, int &chip, int &hitId) const
bool getOfflineIDfromReadoutID(Identifier &offlineID, const int subDetectorID, const int rodID, const int sswID, const int sbLoc, const int channelID, bool orChannel=false) const
To be ported.
bool getSLIDfromReadoutID(int &phi, bool &isAside, bool &isEndcap, const int subsectorID, const int rodID, const int sswID, const int sbLoc) const
bool getReadoutIDfromOfflineID(const Identifier &offlineID, int &subDetectorID, int &rodID, int &sswID, int &sbLoc, int &channelID, bool adChannel=false) const
bool getHighPtIDfromROINumber(int roi, bool isForward, bool isStrip, int &hpb, int &chip, int &hitID, int &sub) const
bool getSimHighPtIDfromRDOHighPtID(const bool isForward, const bool isStrip, int &index, int &chip, int &hitId) const
bool getOfflineIDfromLowPtCoincidenceID(Identifier &offlineID, const int subDetectorID, const int rodID, const int sswID, const int sbLoc, const int block, const int pos, bool middle=false) const
bool getROINumberfromHighPtID(int &roi, bool isForward, int hpb_wire, int chip_wire, int hitId_wire, int sub_wire, int chip_strip, int hitId_strip, int sub_strip) const
bool getSLIDfromSReadoutID(int &phi, bool &isAside, const int subsectorID, const int srodID, const int sector, const bool forward) const
bool isOredChannel(const int subDetectorID, const int rodID, const int sswID, const int sbLoc, const int channelID) const
To be ported.
bool getReadoutIDfromElementID(const Identifier &elementID, int &subdetectorID, int &rodID) const
static constexpr uint32_t INNER_NSW_ID_BITSHIFT
static constexpr uint32_t INNER_TILE_MODULE_BITSHIFT
Bit info in int inner for the Tile inner-coincidence.
static constexpr uint32_t INNER_NSW_PHIRES_BITSHIFT
static constexpr uint32_t INNER_EIFI_CID_BITSHIFT
static constexpr uint32_t INNER_RPC_BCID_BITSHIFT
static constexpr uint32_t INNER_RPC_ETA_BITSHIFT
Bit info in int inner for the RPC inner-coincidence.
static constexpr uint32_t INNER_EIFI_EI_BITSHIFT
Bit info in int inner for the EI/FI inner-coincidence.
static constexpr uint32_t INNER_RPC_PHI_BITSHIFT
static constexpr uint32_t INNER_RPC_DPHI_BITSHIFT
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
static constexpr uint32_t INNER_NSW_PHI_BITSHIFT
static constexpr uint32_t INNER_EIFI_FI_BITSHIFT
static constexpr uint32_t INNER_RPC_FLAG_BITSHIFT
static constexpr uint32_t INNER_NSW_BCID_BITSHIFT
static constexpr uint32_t INNER_RPC_DETA_BITSHIFT
static constexpr uint32_t INNER_NSW_R_BITSHIFT
Bit info in int inner for the NSW inner-coincidence.
static constexpr uint32_t INNER_TILE_BCID_BITSHIFT
static constexpr uint32_t INNER_NSW_LOWRES_BITSHIFT
static constexpr uint32_t INNER_NSW_INPUT_BITSHIFT
static constexpr uint32_t INNER_NSW_DTHETA_BITSHIFT
Class to represent TGC measurements.
void setBcBitMap(const uint16_t)
set the bcBitMap for this PRD
uint16_t getBcBitMap() const
Returns the bcBitMap of this PRD bit2 for Previous BC, bit1 for Current BC, bit0 for Next BC.
const_pointer_type cptr()
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
int isStrip(const Identifier &id) const
isStrip corresponds to measuresPhi
An unit object of TGC ROD output.
uint16_t nswlowres() const
uint16_t position() const
uint16_t subMatrix() const
uint16_t innerflag() const
uint16_t coinflag() const
static constexpr uint32_t RPC_FLAG_BIT
static constexpr uint32_t RPC_BCID_BITSHIFT
bool isCoincidence() const
uint16_t tmdbbcid() const
static constexpr uint32_t NSW_INPUT_BIT
static constexpr uint32_t RPC_BCID_BIT
uint16_t nswphires() const
static constexpr uint32_t NSW_INPUT_BITSHIFT
uint16_t subDetectorId() const
static constexpr uint32_t RPC_FLAG_BITSHIFT
uint16_t nswdtheta() const
static constexpr uint32_t NSW_BCID_BIT
static constexpr uint32_t NSW_BCID_BITSHIFT
uint16_t threshold() const
static uint16_t calculateOnlineId(uint16_t subDetectorId, uint16_t rodId)
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for PlaneSurface: LocalToGlobal method without dynamic memory allocation.
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specified for PlaneSurface: GlobalToLocal method without dynamic memory allocation - boolean checks i...
Identifier identify() const
return the identifier
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
void setMeasuresPhi(uint8_t measPhi)
Set the measures phi flag of the measurement to true /false.
void setGasGap(uint8_t gapNum)
Set the gas gap number of the measurement [1-N].
void setChannelNumber(uint16_t chan)
Set the strip or wire group number of the measurement.
void setBcBitMap(uint16_t)
Set the bunch crossing-id map.
uint8_t measuresPhi() const
Does the object belong to an eta or a phi measurement (si /no)
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
void setIdentifier(const DetectorIdentType measId)
Sets the full Identifier of the measurement.
std::vector< std::string > veto
these patterns are anded
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
@ loc2
generic first and second local coordinate
setRcore setEtHad setFside pt
Eigen::Matrix< float, N, N > MeasMatrix
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.