33{
34
35 ATH_MSG_DEBUG(
"Size of the input vector: " << stripsVect.size());
36
37 if (stripsVect.empty()) {
39 return StatusCode::SUCCESS;
40 }
41
45 return StatusCode::FAILURE;
46 }
47
48 Muon::STgcClusterBuilderCommon stgcClusterCommon(
m_idHelperSvc->stgcIdHelper(), **errorCalibDB);
49
50
51 Identifier chanId = stripsVect.at(0).identify();
53
54 int channelType =
m_idHelperSvc->stgcIdHelper().channelType(stripsVect.at(0).identify());
56 ATH_MSG_DEBUG(
"ChannelType: " << channelType <<
" Single channel resolution: " << resolution);
57
58
59 std::array<std::vector<Muon::sTgcPrepData>, 8> stgcPrdsPerLayer = stgcClusterCommon.sortSTGCPrdPerLayer(std::move(stripsVect));
60
63 ATH_MSG_ERROR(
"Null pointer to the read MuonDetectorManager conditions object");
64 return StatusCode::FAILURE;
65 }
66
67
68 for (std::vector<sTgcPrepData>& unmerged : stgcPrdsPerLayer) {
69
70 std::vector<std::vector<Muon::sTgcPrepData>> layerClusters = stgcClusterCommon.findStripCluster(std::move(unmerged),
72
73
74 for (std::vector<Muon::sTgcPrepData>& cluster: layerClusters) {
76 std::vector<Identifier> rdoList;
77
78 std::vector<int> elementsCharge;
79 std::vector<short int> elementsTime;
80 std::vector<uint16_t> elementsChannel;
81 std::vector<double> elementsLocalPositions;
82 std::vector<Identifier> elementsIdentifier;
83 double posY = (cluster.at(0)).localPosition().y();
84
85
86 for (const sTgcPrepData& it : cluster ){
87 rdoList.push_back(
it.identify());
88 elementsCharge.push_back(
it.charge());
89 elementsChannel.push_back(
m_idHelperSvc->stgcIdHelper().channel(
it.identify()));
90 elementsTime.push_back(
it.time());
91 elementsLocalPositions.push_back(
it.localPosition().x());
92 elementsIdentifier.push_back(
it.identify());
93 }
94
95
96
97 Identifier clusterId;
98 double reconstructedPosX{0};
99 double sigmaSq{0};
100 std::optional<Muon::STgcClusterPosition> optStripCluster = stgcClusterCommon.caruanaGaussianFitting(cluster,
104 if (optStripCluster.has_value()) {
105 clusterId = (*optStripCluster).getClusterId();
106 reconstructedPosX = (*optStripCluster).getMeanPosition();
107 sigmaSq = (*optStripCluster).getErrorSquared();
109 } else {
110 ATH_MSG_DEBUG(
"sTGC cluster reconstruction using the Caruana method failed, reversing to the weighted average");
111
112
114
115 std::optional<Muon::STgcClusterPosition> optClusterWA = stgcClusterCommon.weightedAverage(cluster, resolution, isStrip);
116
117 if (!optClusterWA) {
118 if (
msgLvl(MSG::VERBOSE)) {
119 std::stringstream sstr{};
120 for (const Muon::sTgcPrepData& prd : cluster) {
121 sstr <<
m_idHelperSvc->stgcIdHelper().print_to_string(prd.identify())
122 << ", local pos: ("<< prd.localPosition().x() << "," << prd.localPosition().y()
123 << "), charge: " << prd.charge() << ", time: " << static_cast<int>(prd.time())
124 << std::endl;
125 }
126 ATH_MSG_VERBOSE(
"Reject invalid cluster..." << std::endl << std::endl << sstr.str());
127 }
128 continue;
129 }
131
132 clusterId = (*optClusterWA).getClusterId();
133 reconstructedPosX = (*optClusterWA).getMeanPosition();
134 sigmaSq = (*optClusterWA).getErrorSquared();
135 }
136
139 covN(0,0) = sigmaSq;
141 << " with error on cluster: " << std::sqrt((covN)(0,0)));
142
143 std::unique_ptr<sTgcPrepData> prdN = std::make_unique<sTgcPrepData>(clusterId,
144 hash,
145 std::move(localPosition),
146 std::move(rdoList),
147 std::move(covN),
148 cluster.at(0).detectorElement(),
149 std::accumulate(elementsCharge.begin(), elementsCharge.end(), 0),
150 (short int)0,
151 std::move(elementsChannel),
152 std::move(elementsTime),
153 std::move(elementsCharge));
154 prdN->setAuthor(author);
155 clustersVect.push_back(std::move(prdN));
156 }
157 }
158
159 ATH_MSG_DEBUG(
"Size of the output cluster vector: " << clustersVect.size());
160
161 return StatusCode::SUCCESS;
162}
#define ATH_MSG_VERBOSE(x)
bool msgLvl(const MSG::Level lvl) const
const_pointer_type cptr()
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Matrix< double, 2, 1 > Vector2D
double resolution[nGasTypes][nParametersResolution]