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