9#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;
62 ATH_MSG_INFO(
"MuonTGC_CablingSvc not yet retrieved; postpone TGCcabling initialization at first event.");
68 for (
int ibc=0; ibc <
NBC_HIT+1; ibc++) {
70 std::ostringstream location;
83 for (
int ibc=0; ibc <
NBC_TRIG; ibc++) {
85 std::ostringstream location;
100 return StatusCode::SUCCESS;
114 return AthAlgTool::finalize();
120 return StatusCode::FAILURE;
122template<
class ContType,
class CollType>
124 std::vector<std::unique_ptr<CollType>>&& coll)
const {
125 for (std::unique_ptr<CollType>& toMove : coll) {
126 if (!toMove)
continue;
128 auto lock =
container.getWriteHandle(hash);
129 if(!lock.alreadyPresent()) {
130 ATH_CHECK(lock.addOrDelete(std::move(toMove)));
133 return StatusCode::SUCCESS;
140 std::make_unique<xAOD::TgcStripAuxContainer>()));
148 const unsigned hashMax =
m_idHelperSvc->tgcIdHelper().module_hash_max();
150 for(
unsigned int ibc=0; ibc <
NBC_HIT+1; ibc++) {
156 if (!externalCachePRD) {
158 ATH_CHECK(handle.
record(std::make_unique<TgcPrepDataContainer>(hashMax)));
168 ATH_CHECK(handle.
record(std::make_unique<Muon::TgcPrepDataContainer>(update.ptr())));
177 for (
unsigned int ibc=0; ibc <
NBC_TRIG; ibc++) {
183 if(!externalCacheCoin) {
185 ATH_CHECK(handle.
record(std::make_unique<TgcCoinDataContainer>(hashMax)));
190 ATH_CHECK(handle.
record(std::make_unique<TgcCoinDataContainer>(update.ptr())));
204 return StatusCode::SUCCESS;
207 const std::vector<IdentifierHash>& requestedIdHashVect)
const {
215 ATH_CHECK(xAODHandle.
record(std::make_unique<xAOD::TgcStripContainer>(),
216 std::make_unique<xAOD::TgcStripAuxContainer>()));
219 int sizeVectorRequested = requestedIdHashVect.size();
220 ATH_MSG_DEBUG(
"decode for " << sizeVectorRequested <<
" offline collections called");
224 return StatusCode::FAILURE;
228 std::set<const TgcRdo*> decodedRdoCollVec{}, rdoCollVec{};
229 std::vector<bool> decodedOnlineId (cinfo->
m_MAX_N_ROD,
false);
233 ATH_MSG_DEBUG(
"Stored empty container. Decoding TGC RDO into TGC PrepRawData is switched off");
234 return StatusCode::SUCCESS;
240 ATH_MSG_DEBUG(
"Retrieving TGC RDO container from the store");
244 if(rdoContainer->empty()) {
246 ATH_MSG_DEBUG(
"Empty rdo container - no tgc rdo in this event");
247 return StatusCode::SUCCESS;
250 ATH_MSG_DEBUG(
"Not empty rdo container in this event, the container size is " << rdoContainer->size());
253 if(sizeVectorRequested!=0) {
254 unsigned int nRdo = 0;
258 if(decodedOnlineId.at(onlineId)) {
259 ATH_MSG_DEBUG(
"The ROB with onlineId " << onlineId <<
" which contains hash "
260 <<
static_cast<unsigned int>(offlineCollHash)
261 <<
" is already decoded and skipped");
265 decodedOnlineId.at(onlineId) =
true;
267 for(
const TgcRdo* rdoColl : *rdoContainer) {
268 if(rdoColl->identify()==onlineId) {
269 if(!decodedRdoCollVec.count(rdoColl)) {
270 rdoCollVec.insert(rdoColl);
281 if(sizeVectorRequested!=0) {
285 for (
const TgcRdo* rdo : rdoCollVec) {
290 if(!cinfo->
m_tgcCabling->getElementIDfromReadoutID(offlineId, rd->subDetectorId(),
291 rd->rodId(), rd->sswId(), rd->slbId(),
296 if (std::find(requestedIdHashVect.begin(), requestedIdHashVect.end(), tgcHashId) == requestedIdHashVect.end()){
301 decodedRdoCollVec.insert(rdo);
305 for(
const TgcRdo* rdoColl : *rdoContainer) {
306 if (rdoColl->empty() || decodedRdoCollVec.count(rdoColl) || rdoCollVec.count(rdoColl)) {
309 ATH_MSG_DEBUG(
" Number of RawData in this rdo " << rdoColl->size());
313 decodedRdoCollVec.insert(rdoColl);
317 std::set<IdentifierHash> hashesInAnyBC;
318 for(
unsigned int ibc = 0; ibc <
NBC_HIT; ++ibc) {
326 if (!bcColl)
continue;
329 allBcColl = std::make_unique<TgcPrepDataCollection>(bcColl->identifyHash());
330 allBcColl->setIdentifier(bcColl->identify());
332 hashesInAnyBC.insert(bcColl->identifyHash());
334 auto search_itr = std::find_if(allBcColl->begin(), allBcColl->end(),
336 return prd->identify() == prdToUpdate->identify();
338 if (search_itr == allBcColl->end()) {
339 auto allBcPrd = std::make_unique<TgcPrepData>(*prdToUpdate);
340 allBcPrd->setHashAndIndex(allBcColl->identifyHash(), allBcColl->size());
341 allBcPrd->setBcBitMap(bcBitMap);
342 allBcColl->push_back(std::move(allBcPrd));
347 <<
" adding " << bcBitMap <<
" to get " << (bcBitMap_current | bcBitMap));
348 allBcPrd->
setBcBitMap((bcBitMap_current | bcBitMap));
356 if (!allBcColl)
continue;
358 xAOD::TgcStrip* tgcStrip = xAODHandle->push_back(std::make_unique<xAOD::TgcStrip>());
366 const double locPos = (tgcStrip->
measuresPhi() ? -1. : 1.) * allBcPrd->localPosition().x();
380 ATH_MSG_DEBUG(
"Found " << hashesInAnyBC.size() <<
" hashes that must be added to AllBC container");
382 return StatusCode::SUCCESS;
387 const TgcRdo* rdoColl)
const {
399 StatusCode status = StatusCode::SUCCESS;
419 status =
decodeSL(state, rd, rdoColl);
421 if(!status.isSuccess()) {
432 bool isConverted{
false}, isDuplicated{
false}, isInvalid{
false};
435 <<
" rod=" << rd.
rodId() <<
" ssw=" << rd.
sswId()
436 <<
" slb=" << rd.
slbId() <<
" bitpos=" << rd.
bitpos());
447 for(
int iOr=0; iOr<2; iOr++) {
454 if(o_found) orFlag =
true;
460 bool e_found = cinfo->
m_tgcCabling->getElementIDfromReadoutID(elementId,
466 bool show_warning_level =
true;
482 if (msgLvl(show_warning_level ? MSG::WARNING : MSG::DEBUG)){
483 msg(show_warning_level ? MSG::WARNING : MSG::DEBUG) <<
"ElementID not found for "
485 <<
" slb=" << rd.
slbId() <<
" bitpos=" << rd.
bitpos() <<
" orFlag=" << orFlag <<
endmsg;
493 bool c_found = cinfo->
m_tgcCabling->getOfflineIDfromReadoutID(channelId,
501 <<
" ssw=" << rd.
sswId()<<
" slb=" << rd.
slbId()
502 <<
" bitpos=" << rd.
bitpos()<<
" orFlag=" << orFlag);
510 collection = std::make_unique<TgcPrepDataCollection>(tgcHashId);
511 collection->setIdentifier(elementId);
513 const bool duplicate = std::find_if(collection->begin(), collection->end(),
515 return prd->identify() == channelId;
516 }) != collection->end();
529 std::vector<Identifier> identifierList{channelId};
536 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeHits Amg::Vector2D* hitPos is null.");
541 int gasGap = idHelper.
gasGap(channelId);
542 int channel = idHelper.
channel(channelId);
547 ATH_MSG_WARNING(
"decodeHits: width= " <<
width <<
" is smaller than s_cutDropPrdsWithZeroWidth= "
551 double errPos =
width/std::sqrt(12.);
555 mat *= errPos*errPos;
565 newPrepData->
setHashAndIndex(collection->identifyHash(), collection->size());
566 collection->push_back(newPrepData);
571 else if(isDuplicated || isInvalid)
m_nHitRDOs--;
573 return StatusCode::SUCCESS;
585 found = cinfo->
m_tgcCabling->getOfflineIDfromLowPtCoincidenceID(channelIdOut,
591 return StatusCode::SUCCESS;
596 int tmp_slbId{0}, tmp_subMatrix{0}, tmp_position{0};
599 return StatusCode::SUCCESS;
602 found = cinfo->
m_tgcCabling->getOfflineIDfromLowPtCoincidenceID(channelIdIn,
604 rd.
sswId(), tmp_slbId,
605 tmp_subMatrix, tmp_position,
true);
608 return StatusCode::SUCCESS;
617 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
618 if (!coincollection) {
619 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
620 coincollection->setIdentifier(
m_idHelperSvc->chamberId(channelIdOut));
623 int subMatrix =
static_cast<int>(rd.
subMatrix());
624 int trackletId =
static_cast<int>(2*rd.
slbId()+subMatrix);
625 int delta =
static_cast<int>(rd.
delta());
628 for (
const TgcCoinData* tgcCoinData : *coincollection) {
630 channelIdOut==tgcCoinData->identify() &&
631 channelIdIn==tgcCoinData->channelIdIn() &&
632 trackletId==tgcCoinData->trackletId() &&
633 delta==tgcCoinData->delta() &&
634 subMatrix==tgcCoinData->sub()) {
637 return StatusCode::SUCCESS;
646 return StatusCode::SUCCESS;
650 int gasGap_o = idHelper.
gasGap(channelIdOut);
651 int channel_o = idHelper.
channel(channelIdOut);
653 : descriptor_o->
stripWidth(gasGap_o, channel_o);
656 return StatusCode::SUCCESS;
661 bool onSurface_o = descriptor_o->
surface(channelIdOut).
globalToLocal(position_o,position_o,hitPos_o);
664 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* hitPos_o is null.");
665 return StatusCode::SUCCESS;
672 return StatusCode::SUCCESS;
675 int gasGap_i = idHelper.
gasGap(channelIdIn);
676 int channel_i = idHelper.
channel(channelIdIn);
678 : descriptor_i->
stripWidth(gasGap_i, channel_i);
681 return StatusCode::SUCCESS;
686 bool onSurface_i = descriptor_i->
surface(channelIdIn).
globalToLocal(position_i,position_i,hitPos_i);
689 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTracklet Amg::Vector2D* hitPos_i is null.");
690 return StatusCode::SUCCESS;
706 idHelper.
isStrip(channelIdOut),
715 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
716 coincollection->push_back(newCoinData);
722 return StatusCode::SUCCESS;
738 bool isForward = (rd.
slbId()%2==0);
747 int slot = ((rd.
slbId()/2) + (rd.
rodId()-2)*2 + 23)%24 + 1;
749 bool isBackward =
false;
753 isBackward = !isAside;
754 }
else if(slot==16) {
755 isBackward = isAside;
759 if(isAside) isBackward = (slot%3==2);
760 else isBackward = (slot%3!=2);
763 isBackward = isAside;
773 int tmpsubMatrix =
static_cast<int>(rd.
subMatrix());
775 if(tmpsubMatrix==3) {
776 if(slot== 1 || slot== 3 || slot== 4 || slot== 5 || slot== 6 || slot== 7 || slot== 8 ||
777 slot==10 || slot==11 || slot==13 || slot==18 || slot==19 || slot==20) {
781 }
else if(tmpsubMatrix==2) {
782 if(slot== 2 || slot==12 || slot==14 || slot==15 || slot==16 || slot==22 || slot==23 || slot==24) {
802 bool o_found = cinfo->
m_tgcCabling->getOfflineIDfromReadoutID(channelIdIn,
807 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI OfflineID not found for "
809 <<
" sswId=" << rd.
sswId()<<
" slbId=" << rd.
slbId() <<
" slbType=" << rd.
slbType()
810 <<
" subMatrix=" << rd.
subMatrix() <<
" bitpos=" << bitpos <<
" isStrip=" << isStrip
811 <<
" isAside=" << isAside<<
" isForward=" << isForward<<
" slot=" << slot
812 <<
" isBackward=" << isBackward);
813 return StatusCode::SUCCESS;
822 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
823 if (!coincollection) {
824 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
825 coincollection->setIdentifier(
m_idHelperSvc->chamberId(channelIdIn));
829 for (
const TgcCoinData* tgcCoinData : *coincollection) {
831 channelIdIn==tgcCoinData->channelIdIn() &&
832 static_cast<int>(rd.
subMatrix())==tgcCoinData->sub()) {
834 return StatusCode::SUCCESS;
840 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI descriptor doesn't contain "
842 return StatusCode::SUCCESS;
851 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::decodeTrackletEIFI Amg::Vector2D* hitPos is null.");
852 return StatusCode::SUCCESS;
856 int gasGap = idHelper.
gasGap(channelIdIn);
857 int channel = idHelper.
channel(channelIdIn);
860 double localZ = (descriptor->
transform(channelIdIn).inverse()*descriptor->
channelPos(channelIdIn)).z();
863 width = std::abs(stripMaxX - stripMinX);
865 int positiveOffset = +4;
866 if(isForward && (slot%3==2) && channel==28) positiveOffset = +2;
867 double gangMaxZ = descriptor->
gangLongWidth(gasGap, channel+positiveOffset);
869 width = std::abs(gangMaxZ - gangMinZ);
885 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
886 coincollection->push_back(newCoinData);
890 return StatusCode::SUCCESS;
909 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
910 return StatusCode::SUCCESS;
915 ATH_MSG_DEBUG(
"Invalid hitId_rdo_hipt, hitId == 0!! skip to convert this RDO to PRD");
916 return StatusCode::SUCCESS;
918 int slbsubMatrix = 0;
925 std::array<Identifier, 2> channelIdOut{};
926 std::array<int, 2> bitpos_o{}, slbchannel_o{};
927 int sswId_o{0}, sbLoc_o{0}, slbId_o{0};
930 std::array<Identifier, 4> channelIdIn{};
931 std::array<int, 4> bitpos_i{}, slbchannel_i{};
932 int sswId_i{0}, sbLoc_i{0};
934 std::array<int, 4> slbId_in {}, sbLoc_in{};
936 std::array<int, 4> gasGap_i{}, channel_i{};
937 double width_i{0.},hit_position_i{0};
940 std::array<int, 2> gasGap_o{}, channel_o{};
941 double width_o{0.}, hit_position_o{0.};
949 found =
getHiPtIds(rd, sswId_o, sbLoc_o, slbId_o);
951 return StatusCode::SUCCESS;
960 for(
int i=0; i<2; i++) {
962 sswId_o, sbLoc_o, bitpos_o[i]);
964 ATH_MSG_DEBUG(
"Failed to get OfflineID from ReadoutID for Pivot " << (rd.
isStrip() ?
"Strip" :
"Wire") <<
".");
965 return StatusCode::SUCCESS;
975 getBitPosInWire(rd, deltaBeforeConvert, bitpos_i, slbchannel_i, slbId_in, sbLoc_in, sswId_i, bitpos_o,
976 slbchannel_o, slbId_o);
978 getBitPosInStrip(rd, deltaBeforeConvert, bitpos_i, slbchannel_i, sbLoc_i, sswId_i, bitpos_o, slbchannel_o);
980 for(
int i=0; i<4; i++) {
982 rd.
isStrip() ? sbLoc_i : sbLoc_in[i],
985 ATH_MSG_DEBUG(
"Failed to get OfflineID from ReadoutID for Pivot "
986 << (rd.
isStrip() ?
"Strip" :
"Wire") <<
".");
987 return StatusCode::SUCCESS;
999 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
1000 if (!coincollection) {
1001 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1002 coincollection->setIdentifier(
m_idHelperSvc->chamberId(channelIdOut[1]));
1009 for(
int i=0; i<2; i++) {
1011 return StatusCode::SUCCESS;
1016 for(
int i=0; i<2; i++) {
1017 gasGap_o[i] = idHelper.
gasGap(channelIdOut[i]);
1018 channel_o[i] = idHelper.
channel(channelIdOut[i]);
1023 gasGap_o, channel_o,
1024 width_o, hit_position_o, tmp_hitPos_o,
1028 gasGap_o, channel_o,
1029 width_o, hit_position_o, tmp_hitPos_o,
1034 return StatusCode::SUCCESS;
1037 return StatusCode::SUCCESS;
1042 return StatusCode::SUCCESS;
1053 for(
int i=0; i<4; i++) {
1055 return StatusCode::SUCCESS;
1058 for(
int i=0; i<4; i++) {
1059 gasGap_i[i] = idHelper.
gasGap(channelIdIn[i]);
1060 channel_i[i] = idHelper.
channel(channelIdIn[i]);
1065 gasGap_i, channel_i,
1066 width_i, hit_position_i, tmp_hitPos_i,
1070 gasGap_i, channel_i,
1071 width_i, hit_position_i, tmp_hitPos_i,
1076 return StatusCode::SUCCESS;
1079 return StatusCode::SUCCESS;
1084 return StatusCode::SUCCESS;
1089 int trackletId = 2*sbLoc_o + slbsubMatrix;
1090 int delta =
static_cast<int>(rd.
delta());
1091 int hsub =
static_cast<int>(rd.
hsub());
1092 int inner =
static_cast<int>(rd.
inner());
1095 for (
const TgcCoinData* tgcCoinData : *coincollection) {
1097 (channelIdOut_tmp==tgcCoinData->identify()) &&
1098 (channelIdIn_tmp==tgcCoinData->channelIdIn()) &&
1099 (trackletId==tgcCoinData->trackletId()) &&
1100 (delta==tgcCoinData->delta()) &&
1101 (hsub==tgcCoinData->sub()) &&
1102 (inner==tgcCoinData->inner())) {
1103 if(38<=trackletId && trackletId<=41) {
1108 return StatusCode::SUCCESS;
1112 auto hitPos_o = std::make_unique<Amg::Vector2D>(tmp_hitPos_o);
1113 auto hitPos_i = std::make_unique<Amg::Vector2D>(tmp_hitPos_i);
1135 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1136 coincollection->push_back(newCoinData);
1142 return StatusCode::SUCCESS;
1150 return StatusCode::FAILURE;
1155 if(subDetectorId!=
ASIDE && subDetectorId!=
CSIDE) {
1156 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::decodeHiPt::Unknown subDetectorId!!");
1157 return StatusCode::SUCCESS;
1160 bool isInner = ((rd.
sector() & 4) != 0 );
1166 int sbLoc_o = rd.
sector() & 3;
1167 int inner = rd.
inner();
1170 int phi = 0;
bool isAside =
false;
bool isEndcap =
false;
1171 if(rd.
rodId() < 13){
1172 cinfo->
m_tgcCabling->getSLIDfromReadoutID(
phi, isAside, isEndcap, subDetectorId,
1173 rd.
rodId(), sswId_o, sbLoc_o);
1179 isInner =
true; isStrip =
false;
1189 isInner =
true; isStrip =
true;
1197 isInner =
false; isStrip =
false;
1202 isInner =
false; isStrip =
true;
1210 auto hitPos_o = std::make_unique< Amg::Vector2D >(Amg::Vector2D::Zero());
1211 auto hitPos_i = std::make_unique< Amg::Vector2D >(Amg::Vector2D::Zero());
1216 std::string stationName =
"T3E";
1223 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
1224 if (!coincollection) {
1225 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1226 coincollection->setIdentifier(elementId);
1229 ATH_MSG_DEBUG(
"Inner Data Word, phi: " <<
phi <<
" isAside: " << isAside <<
" isEndcap: " << isEndcap
1230 <<
" subDetectorId: " << subDetectorId <<
" isStrip: " << rd.
isStrip()
1231 <<
" rodId: " << rd.
rodId() <<
" slbId: " << sbLoc_o <<
" inner:"<< rd.
inner());
1253 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1254 coincollection->push_back(newCoinData);
1256 ATH_MSG_DEBUG(
"coincollection->push_back done (for Inner)");
1260 return StatusCode::SUCCESS;
1275 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::decodeSL::Unknown subDetectorId!!");
1276 return StatusCode::SUCCESS;
1281 std::array<Identifier, 3> channelId_wire{};
1282 int index_w{0}, chip_w{0}, hitId_w{0}, sub_w{0}, sswId_w{0}, sbLoc_w{0}, subMatrix_w{0};
1283 std::array<int, 3> bitpos_w{};
1286 found =
getSLIds(
false, rd, channelId_wire, index_w, chip_w, hitId_w, sub_w, sswId_w, sbLoc_w,
1287 subMatrix_w, bitpos_w);
1289 return StatusCode::SUCCESS;
1292 std::array<Identifier, 3> channelId_strip{};
1293 int index_s{0}, chip_s{0}, hitId_s{0}, sub_s{0}, sswId_s{0}, sbLoc_s{0}, subMatrix_s{0};
1294 std::array<int, 3> bitpos_s{};
1297 found =
getSLIds(
true, rd, channelId_strip, index_s, chip_s, hitId_s, sub_s, sswId_s, sbLoc_s, subMatrix_s,
1300 return StatusCode::SUCCESS;
1310 std::unique_ptr<Muon::TgcCoinDataCollection>& coincollection = state.
tgcCoinDataCollections[locId][tgcHashId];
1311 if (!coincollection) {
1312 coincollection = std::make_unique<Muon::TgcCoinDataCollection>(tgcHashId);
1313 coincollection->setIdentifier(
m_idHelperSvc->chamberId(channelId_wire[1]));
1317 int trackletId = 2*sbLoc_w + subMatrix_w;
1318 int trackletIdStrip = 2*sbLoc_s + subMatrix_s;
1319 int roi =
static_cast<int>(rd.
roi());
1322 pt += (
static_cast<int>( rd.
coinflag() ) << 4 );
1326 bool isPositiveDeltaR = rd.
isMuplus();
1329 for (
const TgcCoinData* tgcCoinData : *coincollection) {
1331 trackletId==tgcCoinData->trackletId() && trackletIdStrip==tgcCoinData->trackletIdStrip() &&
1332 roi==tgcCoinData->roi() &&
pt==tgcCoinData->pt() &&
veto==tgcCoinData->veto() &&
1333 isPositiveDeltaR==tgcCoinData->isPositiveDeltaR()) {
1336 return StatusCode::SUCCESS;
1341 double width_w{0.}, tmp_r{0.}, tmp_wire_z{0.};
1344 return StatusCode::SUCCESS;
1347 return StatusCode::SUCCESS;
1350 double tmp_eta = 0.;
1351 bool isGoodEta =
getEtafromRZ(tmp_r, tmp_wire_z, tmp_eta);
1353 ATH_MSG_WARNING(
"Conversion from r and z to eta by Muon::TgcRdoToPrepDataToolMT::getEtafromRZ failed.");
1354 return StatusCode::SUCCESS;
1356 if(tmp_wire_z<0.) tmp_eta *= -1.;
1360 double width_s{0.}, tmp_phi{0.};
1363 return StatusCode::SUCCESS;
1366 return StatusCode::SUCCESS;
1371 return StatusCode::SUCCESS;
1374 Amg::Vector3D tmp_gp(tmp_r*std::cos(tmp_phi), tmp_r*std::sin(tmp_phi), tmp_wire_z);
1376 bool onSurface = descriptor_w2->
surface(channelId_wire[2]).
globalToLocal(tmp_gp,tmp_gp,tmp_hitPos);
1409 newCoinData->
setHashAndIndex(coincollection->identifyHash(), coincollection->size());
1410 coincollection->push_back(newCoinData);
1414 return StatusCode::SUCCESS;
1426 return bitpos + channel/3;
1433 return bitpos + channel/2;
1439 return bitpos + channel/2;
1460 channel = 3*(bitpos - channel) + input;
1467 channel = 2*(bitpos - channel) + input-1;
1486 double r_tmp = std::abs(
r);
1487 double z_tmp = std::abs(
z);
1489 if((r_tmp<std::numeric_limits<double>::epsilon()) && (z_tmp<std::numeric_limits<double>::epsilon()))
return false;
1491 eta = std::abs(atan2(r_tmp,z_tmp));
1500 if(!descriptor || !descriptor->
containsId(channelId)) {
1508 int& tmp_subMatrix,
int& tmp_position)
const {
1510 if(tmp_subMatrix!=0 && tmp_subMatrix!=1) {
1511 ATH_MSG_DEBUG(
"getTrackletInfo: subMatrix " << tmp_subMatrix <<
" is invalid.");
1515 int tmp_sswId = rd.
sswId();
1516 tmp_slbId = rd.
slbId();
1519 int tmp_position_delta = tmp_position + rd.
delta();
1520 int tmp_slbType = rd.
slbType();
1524 if(tmp_subMatrix==1) {
1527 ATH_MSG_DEBUG(
"Expected TGC2 Strip position (" << tmp_position_delta <<
1528 ") does not exist and is changed to the edge position " << tmp_position);
1531 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId+1 <<
" doesn't exist for FWD!! (upper edge SLB of FWD:sbLoc3,11)");
1535 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId+1 <<
" doesn't exist for EWD!! (upper edge SLB of EWD:sbLoc9)");
1545 }
else if(tmp_position_delta<0) {
1547 if(tmp_subMatrix==0) {
1550 ATH_MSG_DEBUG(
"Expected TGC2 Strip position (" << tmp_position_delta <<
1551 ") does not exist and is changed to the edge position " << tmp_position);
1554 if(tmp_position_delta==-1) {
1557 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId-1 <<
" doesn't exist for FWD!! (bottom edge SLB of FWD:sbLoc0,8)");
1562 if(tmp_position_delta==-1) {
1565 ATH_MSG_DEBUG(
"sbLoc " << tmp_slbId-1 <<
" doesn't exist for EWD!! (bottom edge SLB of EWD:sbLoc0)");
1577 tmp_position = tmp_position_delta;
1585 int RoiRow =
static_cast<int>(rd.
roi()/4);
1594 (RoiRow== 3 || RoiRow== 4 ||
1595 RoiRow== 7 || RoiRow== 8 ||
1596 RoiRow==11 || RoiRow==12 ||
1597 RoiRow==23 || RoiRow==24
1605 std::array<int, 2>& bitpos_o) {
1607 if((rd.
hitId()%2)==1) {
1609 if((rd.
hsub())==0) {
1612 }
else if((rd.
hsub())==1) {
1618 if((rd.
hsub())==0) {
1621 }
else if((rd.
hsub())==1) {
1639 }
else if((rd.
chip()==3) && (rd.
hitId()==6) && (rd.
hsub()==1)) {
1647 }
else if((rd.
chip()==1) && (rd.
hitId()==2) && (rd.
hsub()==1)) {
1656 const int deltaBeforeConvert,
1657 std::array<int,4>& bitpos_i,
1658 std::array<int,4>& slbchannel_i,
1659 std::array<int,4>& slbId_in,
1660 std::array<int,4>& sbLoc_in,
1662 const std::array<int, 2>& bitpos_o,
1663 std::array<int, 2>& slbchannel_o,
const int slbId_o)
const {
1665 const int NUM_SLBID_SBLOC_OFFSET_WT = 8;
1669 int rdochIn_max = 0;
1670 int rdochIn_min = 0;
1682 int tmp_rdochannel_i = 0;
1683 int tmp_rdochannel_i2 = 0;
1684 for(
int i=0; i<2; i++) {
1686 tmp_rdochannel_i =
WD_MAP_SIZE*slbId_o + slbchannel_o[i] + deltaBeforeConvert + offset_dt;
1687 if(tmp_rdochannel_i>rdochIn_max) {
1688 tmp_rdochannel_i = rdochIn_max;
1689 }
else if(tmp_rdochannel_i<rdochIn_min) {
1690 tmp_rdochannel_i = rdochIn_min;
1706 tmp_rdochannel_i2 = (tmp_rdochannel_i/3)*3 + 2;
1708 tmp_rdochannel_i2 = ((tmp_rdochannel_i + 1)/3)*3 - 1;
1711 if(tmp_rdochannel_i2>rdochIn_max) {
1712 tmp_rdochannel_i2 = rdochIn_max;
1713 }
else if(tmp_rdochannel_i2<rdochIn_min) {
1714 tmp_rdochannel_i2 = rdochIn_min + 2;
1720 sbLoc_in[i] = slbId_in[i];
1721 sbLoc_in[i+2] = slbId_in[i+2];
1725 sbLoc_in[i] += NUM_SLBID_SBLOC_OFFSET_WT;
1726 sbLoc_in[i+2] += NUM_SLBID_SBLOC_OFFSET_WT;
1730 slbchannel_i[i+2] = tmp_rdochannel_i2%
WT_MAP_SIZE;
1737 sswId_i =
static_cast<int>(rd.
sector()/2);
1745 std::array<int,2 >& bitpos_o) {
1747 if((rd.
hitId()%2)==1) {
1749 if((rd.
hsub())==0) {
1752 }
else if((rd.
hsub())==1) {
1758 if((rd.
hsub())==0) {
1761 }
else if((rd.
hsub())==1) {
1769 const int deltaBeforeConvert,
1770 std::array<int, 4>& bitpos_i,
1771 std::array<int, 4>& slbchannel_i,
1774 const std::array<int,2>& bitpos_o,
1775 std::array<int,2>& slbchannel_o)
const {
1780 int rdochIn_min = 0;
1785 }
else if(rd.
chip()==1) {
1791 }
else if(rd.
chip()==1) {
1796 for(
int i=0; i<2; i++) {
1798 slbchannel_i[i] = slbchannel_o[i] + deltaBeforeConvert;
1799 if(slbchannel_i[i]>rdochIn_max) {
1800 slbchannel_i[i] = rdochIn_max;
1801 }
else if(slbchannel_i[i]<rdochIn_min) {
1802 slbchannel_i[i] = rdochIn_min;
1806 slbchannel_i[i+2] = slbchannel_i[i] + 1;
1808 slbchannel_i[i+2] = slbchannel_i[i] - 1;
1811 if(slbchannel_i[i+2] > rdochIn_max) {
1812 slbchannel_i[i+2] = rdochIn_max;
1813 }
else if(slbchannel_i[i+2] < rdochIn_min) {
1814 slbchannel_i[i+2] = rdochIn_min;
1822 sswId_i =
static_cast<int>(rd.
sector()/2);
1832 std::array<int, 3>& bitpos_w)
const
1845 if(RoiRow==0 && !isForward) {
1850 }
else if(RoiRow==36 && !isForward) {
1855 }
else if(RoiRow==0 && isForward) {
1860 }
else if(RoiRow==15 && isForward) {
1866 if((hitId_w%2)==0) {
1872 }
else if(sub_w==1) {
1883 }
else if(sub_w==1) {
1895 std::array<int, 3>& bitpos_s)
1902 if((hitId_s%2)==0) {
1908 }
else if(sub_s==1) {
1913 }
else if((hitId_s%2)==1) {
1919 }
else if(sub_s==1) {
1929 int deltaBeforeConvert = 0;
1932 switch(rd.
delta()) {
1933 case 5: deltaBeforeConvert = 6;
break;
1934 case 6: deltaBeforeConvert = 8;
break;
1935 case 7: deltaBeforeConvert = 10;
break;
1936 case -4: deltaBeforeConvert = -5;
break;
1937 case -5: deltaBeforeConvert = -7;
break;
1938 case -6: deltaBeforeConvert = -9;
break;
1939 case -7: deltaBeforeConvert = -12;
break;
1940 default: deltaBeforeConvert = rd.
delta();
break;
1943 switch (rd.
delta()) {
1944 case 11: deltaBeforeConvert = 12;
break;
1945 case 12: deltaBeforeConvert = 14;
break;
1946 case 13: deltaBeforeConvert = 16;
break;
1947 case 14: deltaBeforeConvert = 18;
break;
1948 case 15: deltaBeforeConvert = 20;
break;
1949 case -12: deltaBeforeConvert = -13;
break;
1950 case -13: deltaBeforeConvert = -15;
break;
1951 case -14: deltaBeforeConvert = -17;
break;
1952 case -15: deltaBeforeConvert = -19;
break;
1953 default: deltaBeforeConvert = rd.
delta();
break;
1957 return deltaBeforeConvert;
1962 bool isBackward =
false;
1985 double& width_wire,
double& r_wire,
double& z_wire)
const
1989 std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_w{muDetMgr->
getTgcReadoutElement(channelId_wire[0]),
1992 for(
int i=0; i<3; i++) {
1998 Amg::Vector3D position_w = descriptor_w[2]->channelPos(channelId_wire[2]);
2000 bool onSurface_w = descriptor_w[2]->surface(channelId_wire[2]).globalToLocal(position_w,position_w,loc_hitPos_w);
2002 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getSLWireGeometry Amg::Vector2D* loc_hitPos_w is null.");
2007 std::array<int, 3> gasGap_w{}, channel_w{};
2008 for(
int i=0; i<3; i++) {
2009 gasGap_w[i] =
m_idHelperSvc->tgcIdHelper().gasGap(channelId_wire[i]);
2010 channel_w[i] =
m_idHelperSvc->tgcIdHelper().channel(channelId_wire[i]);
2013 std::array<double,3> tmp_r_w{}, tmp_phi_w{}, tmp_eta_w{};
2016 for(
int i=0; i<3; i+=2) {
2017 tmp_position_w[i] = descriptor_w[i]->channelPos(channelId_wire[i]);
2018 tmp_r_w[i] = tmp_position_w[i].perp();
2019 tmp_phi_w[i] = tmp_position_w[i].phi();
2020 tmp_eta_w[i] = tmp_position_w[i].eta();
2022 double half_width = descriptor_w[i]->gangRadialLength(gasGap_w[i], channel_w[i])/2.;
2028 tmp_r_w[0] += half_width;
2030 tmp_r_w[2] -= half_width;
2034 bool flag_geteta_w =
getEtafromRZ(tmp_r_w[0], tmp_position_w[0].
z(), tmp_eta_w[0]);
2035 bool flag_getr_w =
getRfromEtaZ(tmp_eta_w[0], tmp_position_w[2].
z(), tmp_r_w[0]);
2036 if(!flag_geteta_w || !flag_getr_w) {
2037 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getSLWireGeometry::failed to getR on L7!!");
2040 width_wire = tmp_r_w[0] - tmp_r_w[2];
2041 double gang = descriptor_w[2]->gangShortWidth(gasGap_w[2],channel_w[2]) + width_wire/2.;
2046 descriptor_w[2]->surface(channelId_wire[2]).localToGlobal(tmp_hitPos_w,tmp_wire_gp,tmp_wire_gp);
2047 z_wire = tmp_wire_gp.z();
2048 r_wire = tmp_r_w[2] + width_wire/2.;
2054 const bool isBackward,
const bool isAside,
2055 double& width_strip,
double& theta_strip)
const
2059 std::array<const MuonGM::TgcReadoutElement*, 3> descriptor_s{muDetMgr->
getTgcReadoutElement(channelId_strip[0]),
2062 for(
int i=0; i<3; i++) {
2070 bool onSurface_s = descriptor_s[1]->surface(channelId_strip[1]).globalToLocal(position_s,position_s,loc_hitPos_s);
2072 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getSLStripGeometry Amg::Vector2D* loc_hitPos_s is null.");
2077 std::array<int, 3> gasGap_s, channel_s{};
2078 for(
int i=0; i<3; i++) {
2079 gasGap_s[i] =
m_idHelperSvc->tgcIdHelper().gasGap(channelId_strip[i]);
2080 channel_s[i] =
m_idHelperSvc->tgcIdHelper().channel(channelId_strip[i]);
2083 std::array<Amg::Vector3D, 3> localPos{Amg::Vector3D::Zero()};
2084 for(
int i=0; i<3; i+=2) {
2085 localPos[i] = descriptor_s[i]->transform(channelId_strip[i]).inverse()
2086 *descriptor_s[i]->channelPos(channelId_strip[i]);
2089 bool flag_reverse =
false;
2090 std::array<int, 2> index_strip{};
2094 index_strip[0] = 2; index_strip[1] = 0; flag_reverse =
true;
2096 index_strip[0] = 0; index_strip[1] = 2; flag_reverse =
false;
2100 index_strip[0] = 0; index_strip[1] = 2; flag_reverse =
true;
2102 index_strip[0] = 2; index_strip[1] = 0; flag_reverse =
false;
2106 double stripMaxX = descriptor_s[index_strip[0]]->stripHighEdgeLocX(gasGap_s[index_strip[0]], channel_s[index_strip[0]],
2107 localPos[index_strip[0]].
z());
2108 double stripMinX = descriptor_s[index_strip[1]]->stripLowEdgeLocX(gasGap_s[index_strip[1]], channel_s[index_strip[1]],
2109 localPos[index_strip[1]].
z());
2110 width_strip = stripMaxX - stripMinX;
2111 double strip = stripMinX + width_strip/2.;
2112 if(flag_reverse)
strip *= -1.;
2117 int index_strip_gp = 0;
2118 if(!isBackward) index_strip_gp = 0;
2119 else index_strip_gp = 2;
2121 descriptor_s[index_strip_gp]->surface(channelId_strip[index_strip_gp]).localToGlobal(tmp_hitPos_s,tmp_strip_gp,tmp_strip_gp);
2122 theta_strip = atan2(tmp_strip_gp.y(), tmp_strip_gp.x());
2129 const std::array<Identifier, 2>& channelIdOut,
2130 const std::array<int, 2>& gasGap_o,
2131 const std::array<int, 2>& channel_o,
2133 double& hit_position_o,
2139 std::array<double, 2> tmp_phi_o{}, tmp_eta_o{}, tmp_r_o {};
2141 for(
int i=0; i<2; i++) {
2142 position_o[i] = descriptor_o[i]->channelPos(channelIdOut[i]);
2143 tmp_r_o[i] = position_o[i].perp();
2144 tmp_phi_o[i] = position_o[i].phi();
2145 tmp_eta_o[i] = position_o[i].phi();
2147 double half_width = descriptor_o[i]->gangRadialLength(gasGap_o[i], channel_o[i])/2.;
2151 if(i==0) tmp_r_o[0] += half_width;
2152 else tmp_r_o[1] -= half_width;
2155 bool flag_geteta_o =
getEtafromRZ(tmp_r_o[0], position_o[0].
z(), tmp_eta_o[0]);
2156 bool flag_getr_o =
getRfromEtaZ(tmp_eta_o[0], position_o[1].
z(), tmp_r_o[0]);
2157 if(!flag_geteta_o || !flag_getr_o) {
2158 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireOut::failed to getR on L7!!");
2162 width_o = tmp_r_o[0] - tmp_r_o[1];
2164 hit_position_o = descriptor_o[1]->gangShortWidth(gasGap_o[1], channel_o[1]) + width_o/2;
2165 tmp_hitPos_o[
Trk::locX] = (hit_position_o);
2170 bool onSurface_o = descriptor_o[1]->surface(channelIdOut[1]).globalToLocal(position_out,position_out,loc_hitPos_o);
2172 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireOut Amg::Vector2D* loc_hitPos_o is null.");
2177 channelIdOut_tmp = channelIdOut[1];
2183 const std::array<Identifier, 2>& channelIdOut,
2184 const std::array<int, 2>& gasGap_o,
2185 const std::array<int, 2>& channel_o,
2187 double& hit_position_o,
2190 const bool isBackward,
const bool isAside)
const
2195 for(
int i=0; i<2; i++) {
2196 localpos_o[i] = descriptor_o[i]->transform(channelIdOut[i]).inverse()*descriptor_o[i]->channelPos(channelIdOut[i]);
2199 std::array<int, 3>
index{};
2200 bool flag_reverse =
false;
2204 index[0] = 1;
index[1] = 0; flag_reverse =
true;
2206 index[0] = 0;
index[1] = 1; flag_reverse =
false;
2211 index[0] = 0;
index[1] = 1; flag_reverse =
true;
2213 index[0] = 1;
index[1] = 0; flag_reverse =
false;
2217 double stripMax = descriptor_o[
index[0]]->stripHighEdgeLocX(gasGap_o[
index[0]], channel_o[
index[0]],
2218 localpos_o[
index[0]].
z());
2219 double stripMin = descriptor_o[
index[1]]->stripLowEdgeLocX(gasGap_o[
index[1]], channel_o[
index[1]],
2220 localpos_o[
index[1]].
z());
2221 width_o = stripMax - stripMin;
2223 hit_position_o = stripMin + width_o/2.;
2224 if(flag_reverse) hit_position_o *= -1.;
2225 tmp_hitPos_o[
Trk::locX] = hit_position_o;
2230 bool onSurface_o = descriptor_o[1]->surface(channelIdOut[1]).globalToLocal(position_out,position_out,loc_hitPos_o);
2232 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripOut Amg::Vector2D* loc_hitPos_o is null.");
2237 channelIdOut_tmp = channelIdOut[
index[2]];
2243 const std::array<Identifier, 4>& channelIdIn,
2244 const std::array<int, 4>& gasGap_i,
2245 const std::array<int, 4>& channel_i,
2246 double& width_i,
double& hit_position_i,
2251 int flag_boundary_i = 0;
2252 if(descriptor_i[1]->chamberType()==descriptor_i[3]->chamberType()) {
2254 if(gasGap_i[1]==gasGap_i[3]) {
2255 flag_boundary_i = 1;
2257 flag_boundary_i = 3;
2259 }
else if(descriptor_i[0]->chamberType()==descriptor_i[2]->chamberType()) {
2261 if(gasGap_i[0]==gasGap_i[2]) {
2262 flag_boundary_i = 0;
2264 flag_boundary_i = 2;
2267 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::ROI has 3 readout elements!!");
2271 channelIdIn_tmp = channelIdIn[flag_boundary_i];
2279 std::array<double, 3> tmp_r_i{}, tmp_phi_i{}, tmp_eta_i{};
2281 std::array<Amg::Vector3D, 3> position_i {descriptor_i[0]->channelPos(channelIdIn[0]),
2282 descriptor_i[1]->channelPos(channelIdIn[1]),
2285 for(
int i=0; i<3; i++) {
2286 tmp_r_i[i] =position_i[i].perp();
2287 tmp_phi_i[i] = position_i[i].phi();
2288 tmp_eta_i[i] = position_i[i].eta();
2292 double half_width = descriptor_i[i]->gangRadialLength(gasGap_i[i], channel_i[i])/2.;
2296 if(i==0) tmp_r_i[0] += half_width;
2297 else tmp_r_i[1] -= half_width;
2299 bool flag_geteta_i =
getEtafromRZ(tmp_r_i[i], position_i[i].
z(), tmp_eta_i[i]);
2300 bool flag_getr_i =
getRfromEtaZ(tmp_eta_i[i], position_i[2].
z(), tmp_r_i[i]);
2302 if(!flag_geteta_i || !flag_getr_i) {
2303 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::failed to getRIn" << i <<
" on L3!!");
2309 width_i = tmp_r_i[0] - tmp_r_i[1];
2311 ATH_MSG_DEBUG(
"TgcRdoToPrepDataToolMT::getPosAndIdWireIn::minus value width_i = " << width_i);
2315 int gasGap_tmp =
m_idHelperSvc->tgcIdHelper().gasGap(channelIdIn_tmp);
2316 int channel_tmp =
m_idHelperSvc->tgcIdHelper().channel(channelIdIn_tmp);
2317 double half_width = descriptor_iw->
gangRadialLength(gasGap_tmp, channel_tmp)/2.;
2321 if((flag_boundary_i%2)==1) {
2322 tmp_r_i[2] -= half_width;
2323 hit_position_i = descriptor_iw->
gangShortWidth(gasGap_tmp, channel_tmp)
2324 - (tmp_r_i[2] - tmp_r_i[1]) + width_i/2.;
2326 tmp_r_i[2] += half_width;
2327 hit_position_i = descriptor_iw->
gangLongWidth(gasGap_tmp, channel_tmp)
2328 + (tmp_r_i[0] - tmp_r_i[2]) - width_i/2.;
2332 tmp_hitPos_i[
Trk::locX] = hit_position_i;
2333 Amg::Vector3D position_in = descriptor_i[1]->channelPos(channelIdIn[1]);
2336 bool onSurface_i = descriptor_i[1]->surface(channelIdIn[1]).globalToLocal(position_in,position_in,loc_hitPos_i);
2338 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdWireIn Amg::Vector2D* loc_hitPos_i is null.");
2348 const std::array<Identifier, 4>& channelIdIn,
2349 const std::array<int, 4>& gasGap_i,
2350 const std::array<int, 4>& channel_i,
2352 double& hit_position_i,
2355 const bool isBackward,
const bool isAside)
const
2360 for(
int i=0; i<4; i++) {
2361 if(gasGap_i[i]==3) {
2366 if(flag_isL3<0 || flag_isL3>=4) {
2367 ATH_MSG_DEBUG(
"getPosAndIdStripIn: Any bitpos is not at Layer3!");
2371 channelIdIn_tmp = channelIdIn[flag_isL3];
2379 std::array<double, 3> tmp_r_i{}, tmp_phi_i{}, tmp_eta_i{};
2381 for(
int i=0; i<3; i++) {
2383 position_is[i] = descriptor_i[i]->channelPos(channelIdIn[i]);
2385 position_is[i] = descriptor_is->
channelPos(channelIdIn_tmp);
2387 tmp_r_i[i] = position_is[i].perp();
2388 tmp_phi_i[i] = position_is[i].phi();
2389 tmp_eta_i[i] = position_is[i].eta();
2392 std::array<int, 2>
index{};
2393 bool flag_reverse =
false;
2396 index[0] = 1;
index[1] = 0; flag_reverse =
true;
2398 index[0] = 0;
index[1] = 1; flag_reverse =
false;
2402 index[0] = 0;
index[1] = 1; flag_reverse =
true;
2404 index[0] = 1;
index[1] = 0; flag_reverse =
false;
2409 for(
int i=0; i<2; i++) {
2410 localpos_i[i] = descriptor_i[i]->transform(channelIdIn[i]).inverse()*descriptor_i[i]->channelPos(channelIdIn[i]);
2412 double stripMaxX = descriptor_i[
index[0]]->stripHighEdgeLocX(gasGap_i[
index[0]], channel_i[
index[0]],
2413 localpos_i[
index[0]].
z());
2414 double stripMinX = descriptor_i[
index[1]]->stripLowEdgeLocX(gasGap_i[
index[1]], channel_i[
index[1]],
2415 localpos_i[
index[1]].
z());
2416 width_i = stripMaxX - stripMinX;
2418 hit_position_i = stripMinX + width_i/2.;
2419 if(flag_reverse) hit_position_i *= -1.;
2420 tmp_hitPos_i[
Trk::locX] = hit_position_i;
2425 bool onSurface_i = descriptor_i[1]->surface(channelIdIn[1]).globalToLocal(position_in,position_in,loc_hitPos_i);
2427 ATH_MSG_WARNING(
"Muon::TgcRdoToPrepDataToolMT::getPosAndIdStripIn Amg::Vector2D* loc_hitPos_i is null.");
2444 int chip =
static_cast<int>(rd.
chip());
2445 int hitId =
static_cast<int>(rd.
hitId());
2450 ATH_MSG_DEBUG(
"Failed to get SimHighPtID from RDOHighPtID for Pivot "
2451 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2461 found = cinfo->
m_tgcCabling->getOfflineIDfromHighPtID(dummyId,
2464 chip, hitId, rd.
hsub());
2466 found = cinfo->
m_tgcCabling->getOfflineIDfromHighPtID(dummyId,
2469 chip, hitId, rd.
hsub());
2473 ATH_MSG_DEBUG(
"Failed to get offlineID from HighPtID for Pivot "
2474 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2478 std::array<int, 3> dummy_i{};
2479 found = cinfo->
m_tgcCabling->getReadoutIDfromOfflineID(dummyId, dummy_i[0], dummy_i[1], sswId_o, sbLoc_o, dummy_i[2]);
2481 ATH_MSG_DEBUG(
"Failed to get ReadoutID from OfflineID for Pivot "
2482 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2486 std::array<int, 2> i_o{};
2487 std::array<bool, 2> b_o{
false,
false};
2489 found = cinfo->
m_tgcCabling->getSLBIDfromReadoutID(i_o[0], b_o[0], b_o[1], i_o[1], slbId_o,
2492 found = cinfo->
m_tgcCabling->getSLBIDfromReadoutID(i_o[0], b_o[0], b_o[1], i_o[1], slbId_o,
2496 ATH_MSG_DEBUG(
"Failed to get SLBID from ReadoutID for Pivot "
2497 << (rd.
isStrip() ?
"Strip" :
"Wire"));
2505 std::array<Identifier, 3>& channelId,
2506 int&
index,
int& chip,
int& hitId,
int& sub,
int& sswId,
int& sbLoc,
2508 std::array<int, 3>& bitpos,
2509 const bool isBoundary,
const TgcRdo* rdoColl,
2510 const int index_w,
const int chip_w,
const int hitId_w,
const int sub_w)
const
2527 << (!isStrip ?
"Wire" :
"Strip"));
2537 ATH_MSG_DEBUG(
"Failed to get SimHighPtID from RDOHighPtID for "
2538 << (!isStrip ?
"Wire" :
"Strip"));
2543 found = cinfo->
m_tgcCabling->getOfflineIDfromHighPtID(offlineId,
2555 << (!isStrip ?
"Wire" :
"Strip"));
2559 if(!isStrip || !isBoundary) {
2560 channelId[1] = offlineId;
2561 std::array<int, 3> dummy_i{};
2562 found = cinfo->
m_tgcCabling->getReadoutIDfromOfflineID(channelId[1],
2570 << (!isStrip ?
"Wire" :
"Strip"));
2581 if(!exist_tracklet_s) {
2582 ATH_MSG_DEBUG(
"Failed to find correspond Tracklet_strip for SL!!");
2594 for(
int i=0; i<3; i++) {
2595 if(i==1 && (!isStrip || !isBoundary))
continue;
2597 found = cinfo->
m_tgcCabling->getOfflineIDfromReadoutID(channelId[i],
2605 << (!isStrip ?
"Wire" :
"Strip"));
2606 if(!isStrip || i==1) {
2608 <<
", rodId = " << rd.
rodId()
2609 <<
", sswId = " << sswId
2610 <<
", slbId = " << sbLoc
2611 <<
", bitpos_" << (!isStrip ?
"w" :
"s")
2612 <<
"[" << i <<
"] = " << bitpos[i]);
2624 const int index_w,
const int chip_w,
const int hitId_w,
const int sub_w)
const
2631 bool exist_hipt_s =
false;
2634 int trackletIdStripFirst{-1}, trackletIdStripSecond{-1}, trackletIdStripThird{-1};
2636 trackletIdStripSecond, trackletIdStripThird);
2644 const TgcRawData rdH(rdH0->bcTag(), rdH0->subDetectorId(), tmprodId,
2645 rdH0->l1Id(), rdH0->bcId(), rdH0->isStrip(),
2646 rdH0->isForward(), tmpsector, rdH0->chip(),
2647 rdH0->index(),rdH0->isHipt(), rdH0->hitId(),
2648 rdH0->hsub(), rdH0->delta(), rdH0->inner());
2661 int sswId_o{0}, sbLoc_o{0}, slbId_o{0};
2662 bool found =
getHiPtIds(rdH, sswId_o, sbLoc_o, slbId_o);
2668 int slbsubMatrix = 0;
2669 std::array<int, 2> bitpos_o{};
2673 int trackletIdStrip = 2*sbLoc_o + slbsubMatrix;
2676 if(trackletIdStrip!=trackletIdStripFirst && trackletIdStrip!=trackletIdStripSecond &&
2677 trackletIdStrip!=trackletIdStripThird)
continue;
2680 if(exist_hipt_s && trackletIdStrip==trackletIdStripThird)
continue;
2683 int index_w_tmp = index_w;
2684 int chip_w_tmp = chip_w;
2685 int hitId_w_tmp = hitId_w;
2687 found = cinfo->
m_tgcCabling->getRDOHighPtIDfromSimHighPtID(
false,
2693 ATH_MSG_DEBUG(
"Failed to get RDOHighPtID from SimHighPtID for Wire");
2698 int chip_s =
static_cast<int>(rdH.
chip());
2699 int hitId_s =
static_cast<int>(rdH.
hitId());
2700 int hsub_s =
static_cast<int>(rdH.
hsub());
2703 found = cinfo->
m_tgcCabling->getROINumberfromHighPtID(roi,
2713 ATH_MSG_DEBUG(
"Failed to get ROINumber from HighPtID for Strip");
2719 exist_hipt_s =
true;
2720 if(trackletIdStrip==trackletIdStripFirst)
break;
2725 return exist_hipt_s;
2730 const int index_w,
const int chip_w,
2731 const int hitId_w,
const int sub_w)
const
2735 bool exist_tracklet_s =
false;
2738 int trackletIdStripFirst{-1}, trackletIdStripSecond{-1}, trackletIdStripThird{-1};
2740 trackletIdStripSecond, trackletIdStripThird);
2746 uint16_t tmprodId{0}, tmpsector{0};
2748 const TgcRawData rdS(rdS0->bcTag(), rdS0->subDetectorId(), tmprodId,
2749 rdS0->sswId(), rdS0->slbId(), rdS0->l1Id(),
2750 rdS0->bcId(), rdS0->slbType(), rdS0->delta(),
2751 rdS0->segment(), rdS0->subMatrix(), rdS0->position());
2753 bool isForward_s = (rdS.
sswId()==7);
2754 if(isForward_s)
continue;
2765 int trackletIdStrip =
static_cast<int>(2*rdS.
slbId()+rdS.
subMatrix());
2766 if(trackletIdStrip!=trackletIdStripFirst &&
2767 trackletIdStrip!=trackletIdStripSecond &&
2768 trackletIdStrip!=trackletIdStripThird)
continue;
2771 if(exist_tracklet_s && trackletIdStrip==trackletIdStripThird)
continue;
2778 ATH_MSG_DEBUG(
"Failed to get OfflineID from LowPtCoincidenceID for Strip");
2782 std::array<int, 7> i{};
2783 std::array<bool, 2> b{};
2784 found = cinfo->
m_tgcCabling->getHighPtIDfromOfflineID(offlineId,i[0],i[1],i[2],b[0],b[1],i[3],i[4],i[5],i[6]);
2789 ATH_MSG_DEBUG(
"Failed to get HighPtID from OfflineID for Strip");
2794 int index_w_tmp = index_w;
2795 int chip_w_tmp = chip_w;
2796 int hitId_w_tmp = hitId_w;
2803 ATH_MSG_DEBUG(
"Failed to get RDOHighPtID from SimHighPtID for Wire");
2813 ATH_MSG_DEBUG(
"Failed to get RDOHighPtID from SimHighPtID for Strip");
2818 found = cinfo->
m_tgcCabling->getROINumberfromHighPtID(roi,
2828 ATH_MSG_DEBUG(
"Failed to get ROINumber from HighPtID for Strip");
2833 sbLoc = rdS.
slbId();
2834 exist_tracklet_s =
true;
2835 if(trackletIdStrip==trackletIdStripFirst)
break;
2840 return exist_tracklet_s;
2844 int &trackletIdStripSecond,
2845 int &trackletIdStripThird) {
2846 constexpr int T9SscMax = 2;
2847 constexpr int T8SscMax = 4;
2848 constexpr int T7SscMax = 6;
2849 constexpr int T6SscMax = 12;
2850 constexpr int T5SscMax = 18;
2852 constexpr int T9Offset = 32 + 0;
2853 constexpr int T8Offset = 32 + 2;
2854 constexpr int T7Offset = 32 + 4;
2855 constexpr int T6Offset = 32 + 6;
2856 constexpr int T5Offset = 32 + 8;
2861 int ssc = (roi+4)/8;
2862 int halfSsc = (roi%4)/2;
2864 if( ssc< T9SscMax) {
2865 trackletIdStripFirst = T9Offset + halfSsc;
2866 trackletIdStripSecond = -1;
2867 trackletIdStripThird = -1;
2868 }
else if(ssc==T9SscMax) {
2869 trackletIdStripFirst = T8Offset + halfSsc;
2870 trackletIdStripSecond = T9Offset + halfSsc;
2871 trackletIdStripThird = -1;
2872 }
else if(ssc< T8SscMax) {
2873 trackletIdStripFirst = T8Offset + halfSsc;
2874 trackletIdStripSecond = -1;
2875 trackletIdStripThird = -1;
2876 }
else if(ssc==T8SscMax) {
2877 trackletIdStripFirst = T7Offset + halfSsc;
2878 trackletIdStripSecond = T8Offset + halfSsc;
2879 trackletIdStripThird = -1;
2880 }
else if(ssc< T7SscMax) {
2881 trackletIdStripFirst = T7Offset + halfSsc;
2882 trackletIdStripSecond = -1;
2883 trackletIdStripThird = -1;
2884 }
else if(ssc==T7SscMax) {
2885 trackletIdStripFirst = T6Offset + halfSsc;
2886 trackletIdStripSecond = T7Offset + halfSsc;
2887 trackletIdStripThird = T5Offset + halfSsc;
2888 }
else if(ssc< T6SscMax) {
2889 trackletIdStripFirst = T6Offset + halfSsc;
2890 trackletIdStripSecond = T5Offset + halfSsc;
2891 trackletIdStripThird = -1;
2892 }
else if(ssc==T6SscMax) {
2893 trackletIdStripFirst = T6Offset + halfSsc;
2894 trackletIdStripSecond = T5Offset + halfSsc;
2895 trackletIdStripThird = -1;
2896 }
else if(ssc<=T5SscMax) {
2897 trackletIdStripFirst = T5Offset + halfSsc;
2898 trackletIdStripSecond = T6Offset + halfSsc;
2899 trackletIdStripThird = -1;
2901 trackletIdStripFirst = -1;
2902 trackletIdStripSecond = -1;
2903 trackletIdStripThird = -1;
2924 unsigned int hashId_max =
m_idHelperSvc->tgcIdHelper().module_hash_max();
2928 int subDetectorId = 0;
2931 for(
unsigned int hashId=0; hashId<hashId_max; hashId++) {
2933 m_idHelperSvc->tgcIdHelper().get_id(hash, elementId, &tgcContext);
2934 cinfo.
m_tgcCabling->getReadoutIDfromElementID(elementId, subDetectorId, rodId);
2951 if(!readout)
return nullptr;
2954 constexpr double length = 100.;
2955 constexpr unsigned int nRep = 10;
2956 constexpr double dRAccuracy = 1.0E-20;
2957 constexpr double maxLocR = 10000.;
2961 for(
unsigned int iRep=0; iRep<nRep; iRep++) {
2967 double glob_eta_c = glob_hitPos_c.eta();
2968 double glob_phi_c = glob_hitPos_c.phi();
2987 matrix(0,0) = glob_hitPos_w.eta() - glob_eta_c;
2988 matrix(1,0) =
deltaPhi(glob_hitPos_w.phi(), glob_phi_c);
2989 matrix(0,1) = glob_hitPos_s.eta() - glob_eta_c;
2990 matrix(1,1) =
deltaPhi(glob_hitPos_s.phi(), glob_phi_c);
2992 bool invertible = matrix.determinant();
2996 locX +=
length * solution(0,0);
2997 locY +=
length * solution(1,0);
2999 double locR = sqrt(locX*locX + locY*locY);
3001 locX *= maxLocR/locR;
3002 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...
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
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()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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
@ 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.