ATLAS Offline Software
Loading...
Searching...
No Matches
CscDataPreparator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CscDataPreparator.h"
6
9
10// --------------------------------------------------------------------------------
11// --------------------------------------------------------------------------------
12
14
15// --------------------------------------------------------------------------------
16// --------------------------------------------------------------------------------
17
19 const std::string& name,
20 const IInterface* parent):
21 AthAlgTool(type,name,parent)
22{
23}
24
25// --------------------------------------------------------------------------------
26// --------------------------------------------------------------------------------
27
29{
30
31 ATH_CHECK(m_idHelperSvc.retrieve());
32
34
35 return StatusCode::SUCCESS;
36}
37
38// --------------------------------------------------------------------------------
39// --------------------------------------------------------------------------------
40
41StatusCode TrigL2MuonSA::CscDataPreparator::prepareData(const EventContext& ctx,
42 TrigL2MuonSA::MuonRoad& muonRoad,
43 TrigL2MuonSA::CscHits& cscHits) const
44{
45
46 // Clear the output
47 cscHits.clear();
48
49 // Get CSC container
50 if(!m_cscPrepContainerKey.empty()){
51 auto cscPrepContainerHandle = SG::makeHandle(m_cscPrepContainerKey, ctx);
52 const Muon::CscPrepDataContainer* cscPrepContainer = cscPrepContainerHandle.cptr();
53 if (!cscPrepContainerHandle.isValid()) {
54 ATH_MSG_ERROR("Cannot retrieve CSC PRD Container key: " << m_cscPrepContainerKey.key());
55 return StatusCode::FAILURE;
56 }
57
58 // Loop over collections
59 for( const Muon::CscPrepDataCollection* cscCol : *cscPrepContainer ){
60 if( cscCol==nullptr ) continue;
61 cscHits.reserve( cscHits.size() + cscCol->size() );
62 // Loop over data in the collection
63 for( const Muon::CscPrepData* prepData : *cscCol ) {
64 if( prepData==nullptr ) continue;
65
66 // Road info
68 double aw = muonRoad.aw[chamber][0];
69 double bw = muonRoad.bw[chamber][0];
70 //double rWidth = muonRoad.rWidth[chamber][0];
71 double phiw = muonRoad.phi[4][0];//roi_descriptor->phi(); //muonRoad.phi[chamber][0];
72
73 //cluster status
74 bool isunspoiled = IsUnspoiled (prepData->status());
75
76
77 // Create new digit
79 cscHit.StationName = m_idHelperSvc->cscIdHelper().stationName( prepData->identify() );
80 cscHit.StationEta = m_idHelperSvc->cscIdHelper().stationEta( prepData->identify() );
81 cscHit.StationPhi = m_idHelperSvc->cscIdHelper().stationPhi( prepData->identify() );
82 cscHit.ChamberLayer = (true==isunspoiled) ? 1 : 0;
83 cscHit.WireLayer = m_idHelperSvc->cscIdHelper().wireLayer( prepData->identify() );
84 cscHit.MeasuresPhi = m_idHelperSvc->cscIdHelper().measuresPhi( prepData->identify() );
85 cscHit.Strip = m_idHelperSvc->cscIdHelper().strip( prepData->identify() );
86 cscHit.Chamber = chamber;
87 cscHit.StripId = (cscHit.StationName << 18)
88 | ((cscHit.StationEta + 2) << 16) | (cscHit.StationPhi << 12)
89 | (cscHit.WireLayer << 9) | (cscHit.MeasuresPhi << 8) | (cscHit.Strip);
90 cscHit.eta = prepData->globalPosition().eta();
91 cscHit.phi = prepData->globalPosition().phi();
92 cscHit.r = prepData->globalPosition().perp();
93 cscHit.z = prepData->globalPosition().z();
94 cscHit.charge = prepData->charge();
95 cscHit.time = prepData->time();
96 cscHit.resolution = std::sqrt( prepData->localCovariance()(0,0) );
97 cscHit.Residual = ( cscHit.MeasuresPhi==0 ) ? calc_residual( aw, bw, cscHit.z, cscHit.r ) : calc_residual_phi( aw,bw,phiw, cscHit.phi, cscHit.z);
98 cscHit.isOutlier = 0;
99 /*if( std::abs(cscHit.Residual) > rWidth ) {
100 cscHit.isOutlier = 2;
101 }*/
102 double width = (cscHit.MeasuresPhi) ? 250. : 100.;
103 if( std::abs(cscHit.Residual)>width ){
104 cscHit.isOutlier=1;
105 if( std::abs(cscHit.Residual)>3.*width ){
106 cscHit.isOutlier=2;
107 }
108 }
109
110 cscHits.push_back( cscHit );
111
112 // Debug print
113 ATH_MSG_DEBUG("CSC Hits: "
114 << "SN=" << cscHit.StationName << ","
115 << "SE=" << cscHit.StationEta << ","
116 << "SP=" << cscHit.StationPhi << ","
117 << "CL=" << cscHit.ChamberLayer << ","
118 << "WL=" << cscHit.WireLayer << ","
119 << "MP=" << cscHit.MeasuresPhi << ","
120 << "St=" << cscHit.Strip << ","
121 << "ID=" << cscHit.StripId << ","
122 << "eta=" << cscHit.eta << ","
123 << "phi=" << cscHit.phi << ","
124 << "r=" << cscHit.r << ","
125 << "z=" << cscHit.z << ","
126 << "q=" << cscHit.charge << ","
127 << "t=" << cscHit.time << ","
128 << "Rs=" << cscHit.Residual << ","
129 << "OL=" << cscHit.isOutlier);
130 }
131 }
132 }
133
134 //
135 return StatusCode::SUCCESS;
136}
137
138// --------------------------------------------------------------------------------
139// --------------------------------------------------------------------------------
140
141double TrigL2MuonSA::CscDataPreparator::calc_residual(double aw,double bw,double x,double y) const
142{
143 const double ZERO_LIMIT = 1e-4;
144 if( std::abs(aw) < ZERO_LIMIT ) return y-bw;
145 double ia = 1/aw;
146 double iaq = ia*ia;
147 double dz = x - (y-bw)*ia;
148 return dz/std::sqrt(1.+iaq);
149
150}
151
152
153double TrigL2MuonSA::CscDataPreparator::calc_residual_phi( double aw, double bw, double phiw, double hitphi, double hitz) const
154{
155
156 double roadr = hitz*aw + bw;
157
158 return roadr*( std::cos(phiw)*std::sin(hitphi)-std::sin(phiw)*std::cos(hitphi) );
159
160}
161
162// --------------------------------------------------------------------------------
163// --------------------------------------------------------------------------------
164
165
168 return true;
169
170 return false;
171}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
bool IsUnspoiled(Muon::CscClusterStatus status)
const double width
#define y
#define x
const float ZERO_LIMIT
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Class representing clusters from the CSC.
Definition CscPrepData.h:39
double calc_residual_phi(double aw, double bw, double phiw, double hitphi, double hitz) const
virtual StatusCode initialize() override
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
double calc_residual(double aw, double bw, double x, double y) const
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_cscPrepContainerKey
CscDataPreparator(const std::string &type, const std::string &name, const IInterface *parent)
StatusCode prepareData(const EventContext &ctx, TrigL2MuonSA::MuonRoad &muonRoad, TrigL2MuonSA::CscHits &cscHits) const
double aw[N_STATION][N_SECTOR]
Definition MuonRoad.h:83
double bw[N_STATION][N_SECTOR]
Definition MuonRoad.h:84
double phi[N_STATION][N_SECTOR]
Definition MuonRoad.h:85
MuonPrepDataCollection< CscPrepData > CscPrepDataCollection
CscClusterStatus
Enum to represent the cluster status - see the specific enum values for more details.
@ CscStatusUnspoiled
Clean cluster with precision fit.
@ CscStatusSplitUnspoiled
Clean cluster with precision fit after split cluster.
MuonPrepDataContainerT< CscPrepData > CscPrepDataContainer
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
std::vector< CscHitData > CscHits
Definition CscData.h:40
@ CSC
CSC measurement point.
unsigned int StationName
Definition CscData.h:15