ATLAS Offline Software
Loading...
Searching...
No Matches
NSWDataMonAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5// Package : NSWRawDataMonAlg
6// Authors: M. Biglietti (Roma Tre)
7//
8// DESCRIPTION:
9// Subject: NSW-->Offline Muon Data Quality
11
12
13#include "NSWDataMonAlg.h"
18
20// *********************************************************************
21// Public Methods
22// *********************************************************************
23
24NSWDataMonAlg::NSWDataMonAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
25 AthMonitorAlgorithm(name,pSvcLocator)
26{ }
27
28/*---------------------------------------------------------*/
30/*---------------------------------------------------------*/
31{
32 //init message stream
33 ATH_MSG_DEBUG("initialize NSWDataMonAlg");
34
36 ATH_CHECK(m_muonKey.initialize());
37 ATH_CHECK(m_idHelperSvc.retrieve());
38
39
40
41 ATH_MSG_DEBUG(" end of initialize " );
42 ATH_MSG_INFO("NSWDataMonAlg initialization DONE " );
43
44 return StatusCode::SUCCESS;
45}
46
47StatusCode NSWDataMonAlg::fillHistograms(const EventContext& ctx) const
48{
49
50 ATH_MSG_DEBUG("NSWDataMonAlg::MM RawData Monitoring Histograms being filled" );
52 if (!muonContainer.isValid()) {
53 ATH_MSG_FATAL("Could not get muon container: " << m_muonKey.fullKey());
54 return StatusCode::FAILURE;
55 }
56
57 std::string NSWMonGroup = "NSWMonGroup";
58
59 int lumiblock = GetEventInfo(ctx)->lumiBlock();
60
61 auto lb = Monitored::Scalar<float>("lb", lumiblock);
62
63 for (const xAOD::Muon* mu : *muonContainer) {
64 if(mu -> pt() < m_cutPt) continue;
65
66
67 if(!(mu -> author() == xAOD::Muon::Author::MuidCo || (mu -> author() == xAOD::Muon::Author::MuidSA && std::abs(mu->eta()) > 2.5) ) ) continue;
68 const xAOD::TrackParticle* saTP = mu->primaryTrackParticle();
69 if(saTP == nullptr) continue;
70 const Trk::Track* saTrack = saTP->track();
71 if(!saTrack) continue;
72
73 float eta_mu=saTP->eta();
74
75 int ref_sector=-99;
76 float z_nsw=-99;
77 float theta_mu=saTP->theta();
78 float phi_mu=saTP->phi();
79
80
81
82 std::string side = "sideA";
83 int iside = 1;
84 if(eta_mu<0) {
85 side = "sideC";
86 iside=-1;
87 }
88
89 auto mu_phi = Monitored::Scalar<float>("phi_mu_"+side, phi_mu);
90
91
92
93 std::vector<int> layers_mm; std::vector<int> layers_stg;
94 int layer_max=-99;
95 float min_z_nsw=9999;
96
97 for(const Trk::TrackStateOnSurface* trkState : *saTrack->trackStateOnSurfaces()) {
98 if(!(trkState)) continue;
99
100 if (!trkState->type(Trk::TrackStateOnSurface::Measurement)) continue;
101 const Trk::MeasurementBase* meas = trkState->measurementOnTrack() ;
102 if(!meas) continue;
103
104 const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(meas);
105 if(!rot) continue;
106
107
108 Identifier rot_id = rot->identify();
109
110 int channelType = m_idHelperSvc->stgcIdHelper().channelType(rot_id);
111 if(!(m_idHelperSvc->isMM(rot_id) or channelType == sTgcIdHelper::sTgcChannelTypes::Strip)) continue;
112
113
114
115 const Muon::MuonClusterOnTrack* cluster = dynamic_cast<const Muon::MuonClusterOnTrack*>(rot);
116
117 if (!cluster) continue;
118
119 const Muon::MuonCluster* mmPrepData = cluster->prepRawData();
120 Amg::Vector3D pos = mmPrepData->globalPosition();
121 if(fabs(pos.z())<min_z_nsw){
122 z_nsw=pos.z();
123 min_z_nsw=fabs(z_nsw);
124 }
125 int multi_mm=0;
126 int gap_mm=0;
127 int multi_stg=0;
128 int gap_stg=0;
129
130 if(m_idHelperSvc->isMM(rot_id)) {
131 multi_mm = m_idHelperSvc->mmIdHelper().multilayer(rot_id);
132 gap_mm = m_idHelperSvc->mmIdHelper().gasGap(rot_id);
133 auto layer_mm=gap_mm+(multi_mm-1)*4;
134
135 if (std::find(layers_mm.begin(), layers_mm.end(), layer_mm) == layers_mm.end()) layers_mm.push_back(layer_mm);
136 if(layer_mm>layer_max){
137 layer_max=layer_mm;
138 ref_sector= m_idHelperSvc->sector(rot_id) ;
139 }
140 }
141 if(m_idHelperSvc->issTgc(rot_id)) {
142 if (channelType == sTgcIdHelper::sTgcChannelTypes::Strip) {
143 multi_stg = m_idHelperSvc -> stgcIdHelper().multilayer(rot_id);
144 gap_stg = m_idHelperSvc -> stgcIdHelper().gasGap(rot_id);
145 auto layer_stg=gap_stg+(multi_stg-1)*4;
146
147 if (std::find(layers_stg.begin(), layers_stg.end(), layer_stg) == layers_stg.end()) layers_stg.push_back(layer_stg);
148 if(layer_stg>layer_max) {
149 layer_max=layer_stg;
150 ref_sector= m_idHelperSvc->sector(rot_id) ;
151 }
152 }
153 }
154
155 }//loop trackStates
156
157 // --- fallback: assign sector from phi if no NSW hits and eta > 1.2
158 if (ref_sector < 0 && std::fabs(eta_mu) > 1.25) {
160 ref_sector = smapping.getSector(mu_phi);
161 }
162
163 float x_mu=z_nsw*tan(theta_mu)*cos(phi_mu);
164 float y_mu=z_nsw*tan(theta_mu)*sin(phi_mu);
165 auto x_trk = Monitored::Scalar<float>("x_trk_"+side, x_mu);
166 auto y_trk = Monitored::Scalar<float>("y_trk_"+side, y_mu);
167
168 int isEff= (layers_mm.size()>3 || layers_stg.size()>3);
169 auto hitcut = Monitored::Scalar<int>("hitcut", (int)isEff);
170 auto lb_side = Monitored::Scalar<float>("lb_"+side, lumiblock);
171 auto sector_phi = Monitored::Scalar<int>("sector_phi", ref_sector*iside);
172 if (ref_sector > 0) fill(NSWMonGroup, hitcut, mu_phi, lb, lb_side, sector_phi, x_trk, y_trk);
173 }
174
175
176 return StatusCode::SUCCESS;
177}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
xAOD::MuonContainer * muonContainer
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Declare a monitored scalar variable.
Base class for Muon cluster RIO_OnTracks.
virtual const MuonCluster * prepRawData() const override=0
Returns the Trk::PrepRawData - is a MuonCluster in this scope.
virtual const Amg::Vector3D & globalPosition() const =0
Returns the global position of the measurement (calculated on the fly)
int getSector(double phi) const
returns the sector corresponding to the phi position
virtual StatusCode initialize() override
initialize
NSWDataMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
DoubleProperty m_cutPt
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadHandleKey< xAOD::MuonContainer > m_muonKey
This class is the pure abstract base class for all fittable tracking measurements.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Identifier identify() const
return the identifier -extends MeasurementBase
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
float theta() const
Returns the parameter, which has range 0 to .
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
int lb
Definition globals.cxx:23
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
Eigen::Matrix< double, 3, 1 > Vector3D
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Muon_v1 Muon
Reference the current persistent version: