12 #include "Gaudi/Property.h"
28 using std::ostringstream;
38 std::string
chamber(
int istation,
int zsec,
int phi) {
42 else if (istation == 2)
57 std::string setaphi(
bool measphi) {
58 if (measphi)
return "phi";
67 const IInterface*
parent) :
69 declareInterface<ICscClusterBuilder>(
this);
109 ATH_MSG_DEBUG(
"Retrieved CSC precision cluster fitting tool");
119 return StatusCode::SUCCESS;
129 if (!givenIDs.empty()) {
130 for (
unsigned int i = 0;
i < givenIDs.size(); ++
i) {
131 if (
getClusters(givenIDs[
i], decodedIds,
object).isFailure()) {
132 ATH_MSG_ERROR(
"Unable to decode CSC RDO " <<
i <<
"th into CSC PrepRawData");
133 return StatusCode::RECOVERABLE;
139 ATH_MSG_ERROR(
"Unable to decode CSC RDO into CSC PrepRawData");
140 return StatusCode::RECOVERABLE;
143 return StatusCode::SUCCESS;
152 decodedIds.push_back(givenHashId);
153 ATH_MSG_DEBUG(
"A collection already exists in the container for offline id hash. " << (
int)givenHashId);
154 return StatusCode::SUCCESS;
163 return StatusCode::SUCCESS;
169 if (
nullptr ==
col) {
170 unsigned int coll_hash = givenHashId;
171 ATH_MSG_WARNING(
"Specific CSC Strip PrepData collection retrieving failed for collection hash = " << coll_hash);
172 return StatusCode::SUCCESS;
178 int istation =
m_idHelperSvc->cscIdHelper().stationName(colid) - 49;
185 vector<const CscStripPrepData*> strips[8];
186 int maxstrip[8] = {0, 0, 0, 0, 0, 0, 0, 0};
191 if (MuonDetMgr ==
nullptr) {
192 ATH_MSG_ERROR(
"Null pointer to the MuonDetectorManager conditions object");
193 return StatusCode::FAILURE;
198 for (CscStripPrepDataCollection::const_iterator idig =
col->begin(); idig !=
col->end(); ++idig) {
205 int idx = 2 * (wlay - 1) + measphi;
207 if (maxstrip[
idx] == 0) {
209 for (
int istrip = 0; istrip < maxstrip[
idx]; ++istrip) strips[
idx].push_back(
nullptr);
212 if (istrip < 0 || istrip >= maxstrip[
idx]) {
216 strips[
idx][istrip] = &dig;
221 for (
int measphi = 0; measphi < 2; ++measphi) {
222 for (
int wlay = 1; wlay < 5; ++wlay) {
223 int idx = 2 * (wlay - 1) + measphi;
232 ATH_MSG_ERROR(
"Couldn't add CscPrepdataCollection to container!");
233 return StatusCode::FAILURE;
235 decodedIds.push_back(
hash);
238 return StatusCode::SUCCESS;
251 return StatusCode::SUCCESS;
257 for (CscStripPrepDataContainer::const_iterator
icol = con.begin();
icol != con.end(); ++
icol) {
260 int istation =
m_idHelperSvc->cscIdHelper().stationName(colid) - 49;
266 vector<const CscStripPrepData*> strips[8];
267 int maxstrip[8] = {0, 0, 0, 0, 0, 0, 0, 0};
272 if (MuonDetMgr ==
nullptr) {
273 ATH_MSG_ERROR(
"Null pointer to the MuonDetectorManager conditions object");
274 return StatusCode::FAILURE;
279 for (CscStripPrepDataCollection::const_iterator idig =
col.begin(); idig !=
col.end(); ++idig) {
286 int idx = 2 * (wlay - 1) + measphi;
288 if (maxstrip[
idx] == 0) {
290 for (
int istrip = 0; istrip < maxstrip[
idx]; ++istrip) strips[
idx].push_back(
nullptr);
293 if (istrip < 0 || istrip >= maxstrip[
idx]) {
297 strips[
idx][istrip] = &dig;
302 for (
int measphi = 0; measphi < 2; ++measphi) {
303 for (
int wlay = 1; wlay < 5; ++wlay) {
304 int idx = 2 * (wlay - 1) + measphi;
313 ATH_MSG_ERROR(
"Couldn't add CscPrepdataCollection to container!");
314 return StatusCode::FAILURE;
316 decodedIds.push_back(
hash);
320 return StatusCode::SUCCESS;
326 return StatusCode::SUCCESS;
343 unsigned int maxstrip = strips.size();
345 ATH_MSG_DEBUG(
" Clustering for " << setaphi(measphi) <<
" plane with " << maxstrip <<
" strips");
351 std::vector<bool> astrip;
354 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
362 if (!newCollection) {
366 newCollection->setIdentifier(elementId);
375 ATH_MSG_DEBUG(
" Strip " << setw(3) << istrip + 1 <<
": charge= " << setw(7) <<
int(
res.charge) <<
" time=" << setw(3)
376 <<
int(
res.time + 0.5));
385 stripfits.push_back(
res);
390 bool incluster =
false;
394 std::vector<const CscStripPrepData*> clusterStrips;
395 std::vector<Identifier> prd_digit_ids;
396 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
402 if (!astrip[istrip])
continue;
409 first_strip = istrip;
411 clusterStrips.clear();
412 prd_digit_ids.clear();
417 sfits.push_back(sfit);
418 clusterStrips.push_back(pstrip);
419 prd_digit_ids.push_back(pstrip->
identify());
420 if (
q > qpeak) qpeak =
q;
424 if (istrip != maxstrip - 1 && astrip[istrip + 1])
continue;
438 std::vector<ICscClusterFitter::Result>
results;
477 res.clusterStatus = oldclustatus;
486 if (MuonDetMgr ==
nullptr) {
487 ATH_MSG_ERROR(
"Null pointer to the MuonDetectorManager conditions object");
492 unsigned int nresults =
results.size();
493 for (
unsigned int ire = 0; ire < nresults; ++ire) {
502 unsigned int id_strip =
results[ire].strip;
503 double cluster_charge =
results[ire].charge;
504 double cluster_time =
results[ire].time;
507 if (id_strip >= sfits.size()) {
513 if (id_strip < clusterStrips.size()) pstrip_id = clusterStrips[id_strip];
522 int zsec =
m_idHelperSvc->cscIdHelper().stationEta(cluster_id);
523 int wlay =
m_idHelperSvc->cscIdHelper().wireLayer(cluster_id);
530 Amg::Vector2D plpos(measphi ? local_pos.y() : local_pos.z(), measphi ? local_pos.z() : local_pos.y());
534 ATH_MSG_DEBUG(
" ID strip: " << first_strip + id_strip <<
"(" << first_strip <<
":" << id_strip <<
")");
535 ATH_MSG_DEBUG(
" local position: " << plpos.x() <<
" " << plpos.y());
541 std::vector<Identifier> prd_digit_ids_submit;
542 unsigned int fstrip =
results[ire].fstrip;
543 unsigned int lstrip =
results[ire].lstrip;
544 prd_digit_ids_submit.reserve(lstrip + 1);
545 for (
unsigned int ids_index = fstrip; ids_index < lstrip + 1; ++ids_index) {
546 if (ids_index >= prd_digit_ids.size())
547 ATH_MSG_WARNING(
" bad index " << ids_index <<
" maximum " << prd_digit_ids.size());
549 prd_digit_ids_submit.push_back(prd_digit_ids[ids_index]);
555 prd_digit_ids_submit,
558 int(cluster_charge + 0.5),
563 newCollection->size());
565 newCollection->push_back(pclus);