1110 {
1111 ATH_MSG_DEBUG(
"Creating pattern combinations from eta/phi combinations " << phiEtaAssociations.size());
1112
1113
1114 std::map<MuonHough::MuonPhiLayerHough::Maximum*, MaximumVec>::const_iterator pit = phiEtaAssociations.begin();
1115 std::map<MuonHough::MuonPhiLayerHough::Maximum*, MaximumVec>::const_iterator pit_end = phiEtaAssociations.end();
1116 for (; pit != pit_end; ++pit) {
1117 if (pit->second.empty()) continue;
1118
1119
1120 std::map<Identifier, std::set<const Trk::PrepRawData*>> phiHitsPerChamber;
1121
1122
1123 for (const auto& hit : pit->first->hits) {
1124 if (hit->tgc) {
1125 const Identifier chId =
m_idHelperSvc->chamberId(hit->tgc->phiCluster.front()->identify());
1126 phiHitsPerChamber[chId].insert(hit->tgc->phiCluster.begin(), hit->tgc->phiCluster.end());
1127 } else if (hit->prd) {
1128 const Identifier chId =
m_idHelperSvc->chamberId(hit->prd->identify());
1129 phiHitsPerChamber[chId].insert(hit->prd);
1130 }
1131 }
1132
1133
1134 std::vector<MuonPatternChamberIntersect> chamberData;
1135 std::set<Identifier> addedPhiHits;
1136
1137
1138 std::map<Identifier, std::set<const Trk::PrepRawData*>> prdsPerChamber;
1139
1140
1141 std::map<MuonStationIndex::ChIndex, std::pair<Amg::Vector3D, Amg::Vector3D>> directionsPerChamberLayer;
1142
1143
1144 for (
const auto&
max : pit->second) {
1146
1148
1149
1150 if (
max->hits.empty()) {
1152 continue;
1153 }
1155
1156
1157 for (
const auto& hit :
max->hits) {
1158 Identifier chId;
1159 if (hit->tgc) {
1160 chId =
m_idHelperSvc->chamberId(hit->tgc->etaCluster.front()->identify());
1161 prdsPerChamber[chId].insert(hit->tgc->etaCluster.begin(), hit->tgc->etaCluster.end());
1162 } else if (hit->prd) {
1164 prdsPerChamber[chId].insert(hit->prd);
1165 } else {
1167 continue;
1168 }
1169
1171 if (!directionsPerChamberLayer.count(
chIndex)) {
1172
1173 double maxpos =
max->pos;
1174 double refPlane = 0.;
1177 refPlane =
max->hough->m_descriptor.referencePosition;
1178 else if (hit->tgc)
1179 refPlane = hit->tgc->getEdge(TgcEdge::LowEtaLowPhi).z();
1181 refPlane = hit->prd->detectorElement()->surface(hit->prd->identify()).center().perp();
1182 else
1183 refPlane = hit->prd->detectorElement()->surface(hit->prd->identify()).center().z();
1184
1185 double r =
isBarrel ? refPlane : maxpos;
1186 double z =
isBarrel ? maxpos : refPlane;
1188
1189
1194 }
1195
1196
1197 double phi = pit->first->pos;
1198
1199 CxxUtils::sincos scphi(
phi);
1200 double sinphi = scphi.sn;
1201 double cosphi = scphi.cs;
1202
1203 CxxUtils::sincos sctheta(
theta);
1204 double sintheta = sctheta.sn;
1205 double costheta = sctheta.cs;
1206
1207 std::pair<Amg::Vector3D, Amg::Vector3D>& posDir = directionsPerChamberLayer[
chIndex];
1211 << " setting position: perp " << posDir.first.perp() << " z " << posDir.first.z() << " phi pos "
1212 << posDir.first.phi() << " direction phi " << posDir.second.phi() << " theta pos "
1213 << posDir.first.theta() <<
" direction theta " << posDir.second.theta() <<
" ref perp " <<
r <<
" z "
1214 <<
z <<
" phi " <<
phi <<
" theta " <<
theta);
1215 if (posDir.first.dot(posDir.second) < 0.) {
1216 ATH_MSG_WARNING(
" direction not pointing to IP " << posDir.first.unit().dot(posDir.second));
1217 }
1218 }
1219
1220 std::map<Identifier, std::set<const Trk::PrepRawData*>>::iterator
pos = phiHitsPerChamber.find(chId);
1221 if (pos != phiHitsPerChamber.end()) {
1222 std::pair<std::set<Identifier>::iterator, bool> ipos = addedPhiHits.insert(chId);
1223 if (ipos.second) { prdsPerChamber[chId].insert(
pos->second.begin(),
pos->second.end()); }
1224 }
1225 }
1226 }
1227
1228 auto sortPrdIds = [](const Trk::PrepRawData* prd1, const Trk::PrepRawData* prd2) {
1229 return prd1->
identify() < prd2->identify();
1230 };
1231 std::map<Identifier, std::set<const Trk::PrepRawData*>>::iterator chit = prdsPerChamber.begin();
1232 std::map<Identifier, std::set<const Trk::PrepRawData*>>::iterator chit_end = prdsPerChamber.end();
1233 for (; chit != chit_end; ++chit) {
1235 std::vector<const Trk::PrepRawData*> prds;
1236 prds.insert(prds.end(), chit->second.begin(), chit->second.end());
1238 const Trk::PrepRawData& prd = **prds.begin();
1239
1241 std::map<MuonStationIndex::ChIndex, std::pair<Amg::Vector3D, Amg::Vector3D>>::const_iterator
pos =
1242 directionsPerChamberLayer.find(
chIndex);
1245 if (pos != directionsPerChamberLayer.end()) {
1246 gpos =
pos->second.first;
1247 gdir =
pos->second.second;
1248 } else {
1249 ATH_MSG_WARNING(
"No global position and direction found, calculating from surface");
1251 gdir = -1 * gpos.unit();
1252 }
1253
1255 << " z " << gpos.z() << " phi pos " << gpos.phi() << " direction phi " << gdir.phi()
1256 << " theta pos " << gpos.theta() << " theta " << gdir.theta() << " hits "
1257 << prds.size());
1258
1259
1260 MuonPatternChamberIntersect
intersect(gpos, gdir, prds);
1261 chamberData.push_back(intersect);
1262
1263 }
1264 if (chamberData.empty()) continue;
1265 if (addedPhiHits.empty()) {
1267 continue;
1268 }
1269 MuonPatternCombination* combi = new MuonPatternCombination(nullptr, chamberData);
1270 ATH_MSG_DEBUG(
"adding pattern combination with chambers " << chamberData.size() <<
" phi layers " << addedPhiHits.size()
1271 << std::endl
1274 }
1275 }
Scalar phi() const
phi method
Scalar theta() const
theta method
value_type push_back(value_type pElem)
Add an element to the end of the collection.
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
Identifier identify() const
return the identifier
const Amg::Vector3D & center() const
Returns the center position of the Surface.
virtual const Surface & surface() const =0
Return surface associated with this detector element.
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
Eigen::Matrix< double, 3, 1 > Vector3D
bool isBarrel(const ChIndex index)
Returns true if the chamber index points to a barrel chamber.
const std::string & chName(ChIndex index)
convert ChIndex into a string