12#include "Gaudi/Property.h"
28using 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;
182 ATH_MSG_DEBUG(
" Strip collection " << chamber(istation, zsec, phisec) <<
" has " << col->
size() <<
" strips");
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;
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;
231 if (pclusters->
addCollection(newCollection, hash).isFailure()) {
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;
260 int istation =
m_idHelperSvc->cscIdHelper().stationName(colid) - 49;
263 ATH_MSG_DEBUG(
" Strip collection " << chamber(istation, zsec, phisec) <<
" has " << col.
size() <<
" strips");
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;
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;
312 if (pclusters->
addCollection(newCollection, hash).isFailure()) {
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) {
373 active =
res.charge > 0.0;
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);
386 astrip.push_back(active);
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;
444 fitresult = results[0].fitStatus;
449 if (fitresult == 6) {
453 fitresult = results[0].fitStatus;
455 for (
unsigned int i = 0; i < results.size(); ++i)
ATH_MSG_VERBOSE(
" Split fit result return=" << results[i].fitStatus);
461 if (measphi || (fitresult > 0 && fitresult < 20)) {
464 if (!measphi)
res = results[0];
468 fitresult = results[0].fitStatus;
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) {
495 double q3sum = results[ire].qleft + results[ire].qpeak + results[ire].qright;
500 double pos = results[ire].position;
501 double err = results[ire].dposition;
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);
529 (cov)(0, 0) = err * err;
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());
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::pair< std::vector< unsigned int >, bool > res
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
value_type push_back(value_type pElem)
const_iterator end() const noexcept
const_iterator begin() const noexcept
size_type size() const noexcept
ICscStripFitter::Result StripFit
std::vector< StripFit > StripFitList
const_iterator end() const
return const_iterator for end of container
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
const_iterator begin() const
return const_iterator for first entry
This is a "hash" representation of an Identifier.
Amg::Vector3D nominalLocalClusterPos(int eta, int wireLayer, int measPhi, double x0) const
ignores internal alignment parameters, hence gives generally incorrect answer (local here is the stat...
int maxNumberOfStrips(int measuresPhi) const
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Class representing clusters from the CSC.
Class representing the raw data of one CSC strip (for clusters look at Muon::CscPrepData).
virtual const IdentifierHash collectionHash() const final
returns the IdentifierHash corresponding to the channel.
virtual Identifier identify() const override final
virtual void setIdentifier(Identifier id)
virtual IdentifierHash identifyHash() const override final
const_pointer_type cptr()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Identifier identify() const
return the identifier
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
MuonPrepDataCollection< CscPrepData > CscPrepDataCollection
MuonPrepDataCollection< CscStripPrepData > CscStripPrepDataCollection
MuonPrepDataContainerT< CscStripPrepData > CscStripPrepDataContainer
std::string toString(CscStripStatus cstat)
Return a string description of a CSC cluster status flag.
CscClusterStatus
Enum to represent the cluster status - see the specific enum values for more details.
@ CscStatusUndefined
Undefined, should not happen, most likely indicates a problem.
MuonPrepDataContainerT< CscPrepData > CscPrepDataContainer
CscTimeStatus
Enum to represent the cluster time measurement status - see the specific enum values for more details...