ATLAS Offline Software
Loading...
Searching...
No Matches
IDAlignMonPVBiasesAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4
5// **********************************************************************
6// IDAlignMonPVBiases.cxx
7// AUTHORS: Ambrosius Vermeulen, Pierfrancesco Butti
8// Adapted to new AthenaMT Monitoring 2022 by Per Johansson
9// **********************************************************************
10
11//main header
13
18
21
24
27
28
29#include "CLHEP/GenericFunctions/CumulativeChiSquare.hh"
30
32
33#include <cmath>
34#include <memory>
35
36// *********************************************************************
37// Public Methods
38// *********************************************************************
39
40IDAlignMonPVBiasesAlg::IDAlignMonPVBiasesAlg(const std::string& name, ISvcLocator* pSvcLocator ) :
41 AthMonitorAlgorithm(name, pSvcLocator){}
42
44
46
47 ATH_CHECK( m_trackParticleName.initialize() );
48 ATH_CHECK( m_vxContainerName.initialize(not m_vxContainerName.key().empty()));
50
52}
53
54
55StatusCode IDAlignMonPVBiasesAlg::fillHistograms( const EventContext& ctx ) const {
56 using namespace Monitored;
57
58 // For histogram naming
59 auto pvGroup = getGroup("PVBiases");
60
61 /******************************************************************
62 ** Retrieve Trackparticles
63 ******************************************************************/
64 auto trackParticles = SG::makeHandle(m_trackParticleName, ctx);
65
66 if ( !(trackParticles.isValid()) ) {
67 ATH_MSG_ERROR("IDAlignMonPVBiasesAlg: Track container "<< m_trackParticleName.key() << " could not be found.");
68 return StatusCode::RECOVERABLE;
69 } else {
70 ATH_MSG_DEBUG("IDAlignMonPVBiasesAlg: Track container "<< trackParticles.name() <<" is found.");
71 }
72
73 // Retrieve Vertices
74 auto vertices = SG::makeHandle(m_vxContainerName, ctx);
75
76 if (!vertices.isPresent()) {
77 ATH_MSG_DEBUG ("IDAlignPVBiasesAlg: StoreGate doesn't contain primary vertex container with key "+m_vxContainerName.key());
78 return StatusCode::SUCCESS;
79 }
80 if (not vertices.isValid()) {
81 ATH_MSG_WARNING("IDAlignPVBiasesAlg: Failed to retrieve vertex container with key " << m_vxContainerName.key());
82 return StatusCode::RECOVERABLE;
83 }
84
85
86 /******************************************************************
87 ** Trackparticle Loop
88 *******************************************************************/
89 for (const auto trackPart: *trackParticles) {
90 if ( !trackPart )
91 {
92 ATH_MSG_DEBUG( "InDetAlignPVBiasesAlg: NULL track pointer in collection" );
93 continue;
94 }
95
96 const xAOD::Vertex* foundVertex { nullptr };
97 for (const auto* const vx : *vertices) {
98 for (const auto& tpLink : vx->trackParticleLinks()) {
99 if (*tpLink == trackPart) {
100 foundVertex = vx;
101 break;
102 }
103 if (foundVertex) break;
104 }
105 }
106 // require having vertex
107 if (!foundVertex) continue;
108 // require associated with primary vertex
109 if (foundVertex->vertexType() != 1) continue;
110 // require at least 10 tracks associated
111 if (foundVertex->nTrackParticles() < 10) continue;
112
113 std::unique_ptr<const Trk::ImpactParametersAndSigma> myIPandSigma(m_trackToVertexIPEstimator->estimate(trackPart, foundVertex, true));
114
115 // require d0_pv to be smaller than 4
116 if(myIPandSigma.get()==nullptr || std::abs(myIPandSigma->IPd0) > 4.0) continue;
117
118 double charge = trackPart->charge();
119
120 /******************************************************************
121 ** Fill Histograms
122 *******************************************************************/
123 double pt = trackPart->pt() * 0.001;
124
125 if (pt > 0.4 && pt < 0.6) {
126
127 if (charge == 1){
128 auto phi_46p_m = Monitored::Scalar<float>( "m_Phi_46p", trackPart->phi() );
129 auto eta_46p_m = Monitored::Scalar<float>( "m_Eta_46p", trackPart->eta() );
130 auto d0_46p_m = Monitored::Scalar<float>( "m_d0_46p", myIPandSigma->IPd0 );
131 fill(pvGroup, phi_46p_m, d0_46p_m);
132 fill(pvGroup, eta_46p_m, d0_46p_m);
133 }
134 else if (charge == -1){
135 auto phi_46n_m = Monitored::Scalar<float>( "m_Phi_46n", trackPart->phi() );
136 auto eta_46n_m = Monitored::Scalar<float>( "m_Eta_46n", trackPart->eta() );
137 auto d0_46n_m = Monitored::Scalar<float>( "m_d0_46n", myIPandSigma->IPd0 );
138 fill(pvGroup, phi_46n_m, d0_46n_m);
139 fill(pvGroup, eta_46n_m, d0_46n_m);
140 }
141 }
142
143 if (pt > 0.6 && pt < 1) {
144 if (charge == 1){
145 auto phi_61p_m = Monitored::Scalar<float>( "m_Phi_61p", trackPart->phi() );
146 auto eta_61p_m = Monitored::Scalar<float>( "m_Eta_61p", trackPart->eta() );
147 auto d0_61p_m = Monitored::Scalar<float>( "m_d0_61p", myIPandSigma->IPd0 );
148 fill(pvGroup, phi_61p_m, d0_61p_m);
149 fill(pvGroup, eta_61p_m, d0_61p_m);
150 }
151
152 else if (charge == -1){
153 auto phi_61n_m = Monitored::Scalar<float>( "m_Phi_61n", trackPart->phi() );
154 auto eta_61n_m = Monitored::Scalar<float>( "m_Eta_61n", trackPart->eta() );
155 auto d0_61n_m = Monitored::Scalar<float>( "m_d0_61n", myIPandSigma->IPd0 );
156 fill(pvGroup, phi_61n_m, d0_61n_m);
157 fill(pvGroup, eta_61n_m, d0_61n_m);
158 }
159 }
160
161 if (pt > 1 && pt < 2) {
162 if (charge == 1){
163 auto phi_12p_m = Monitored::Scalar<float>( "m_Phi_12p", trackPart->phi() );
164 auto eta_12p_m = Monitored::Scalar<float>( "m_Eta_12p", trackPart->eta() );
165 auto d0_12p_m = Monitored::Scalar<float>( "m_d0_12p", myIPandSigma->IPd0 );
166 fill(pvGroup, phi_12p_m, d0_12p_m);
167 fill(pvGroup, eta_12p_m, d0_12p_m);
168 }
169 else if (charge == -1){
170 auto phi_12n_m = Monitored::Scalar<float>( "m_Phi_12n", trackPart->phi() );
171 auto eta_12n_m = Monitored::Scalar<float>( "m_Eta_12n", trackPart->eta() );
172 auto d0_12n_m = Monitored::Scalar<float>( "m_d0_12n", myIPandSigma->IPd0 );
173 fill(pvGroup, phi_12n_m, d0_12n_m);
174 fill(pvGroup, eta_12n_m, d0_12n_m);
175 }
176 }
177
178 if (pt > 2 && pt < 5) {
179 if (charge == 1){
180 auto phi_25p_m = Monitored::Scalar<float>( "m_Phi_25p", trackPart->phi() );
181 auto eta_25p_m = Monitored::Scalar<float>( "m_Eta_25p", trackPart->eta() );
182 auto d0_25p_m = Monitored::Scalar<float>( "m_d0_25p", myIPandSigma->IPd0 );
183 fill(pvGroup, phi_25p_m, d0_25p_m);
184 fill(pvGroup, eta_25p_m, d0_25p_m);
185 }
186 else if (charge == -1){
187 auto phi_25n_m = Monitored::Scalar<float>( "m_Phi_25n", trackPart->phi() );
188 auto eta_25n_m = Monitored::Scalar<float>( "m_Eta_25n", trackPart->eta() );
189 auto d0_25n_m = Monitored::Scalar<float>( "m_d0_25n", myIPandSigma->IPd0 );
190 fill(pvGroup, phi_25n_m, d0_25n_m);
191 fill(pvGroup, eta_25n_m, d0_25n_m);
192 }
193 }
194
195 if (pt > 5 && pt < 10) {
196 if (charge == 1){
197 auto phi_510p_m = Monitored::Scalar<float>( "m_Phi_510p", trackPart->phi() );
198 auto eta_510p_m = Monitored::Scalar<float>( "m_Eta_510p", trackPart->eta() );
199 auto d0_510p_m = Monitored::Scalar<float>( "m_d0_510p", myIPandSigma->IPd0 );
200 fill(pvGroup, phi_510p_m, d0_510p_m);
201 fill(pvGroup, eta_510p_m, d0_510p_m);
202 }
203 else if (charge == -1){
204 auto phi_510n_m = Monitored::Scalar<float>( "m_Phi_510n", trackPart->phi() );
205 auto eta_510n_m = Monitored::Scalar<float>( "m_Eta_510n", trackPart->eta() );
206 auto d0_510n_m = Monitored::Scalar<float>( "m_d0_510n", myIPandSigma->IPd0 );
207 fill(pvGroup, phi_510n_m, d0_510n_m);
208 fill(pvGroup, eta_510n_m, d0_510n_m);
209 }
210 }
211
212 if (pt > 10) {
213 if (charge == 1){
214 auto phi_g10p_m = Monitored::Scalar<float>( "m_Phi_g10p", trackPart->phi() );
215 auto eta_g10p_m = Monitored::Scalar<float>( "m_Eta_g10p", trackPart->eta() );
216 auto d0_g10p_m = Monitored::Scalar<float>( "m_d0_g10p", myIPandSigma->IPd0 );
217 fill(pvGroup, phi_g10p_m, d0_g10p_m);
218 fill(pvGroup, eta_g10p_m, d0_g10p_m);
219 }
220 else if (charge == -1){
221 auto phi_g10n_m = Monitored::Scalar<float>( "m_Phi_g10n", trackPart->phi() );
222 auto eta_g10n_m = Monitored::Scalar<float>( "m_Eta_g10n", trackPart->eta() );
223 auto d0_g10n_m = Monitored::Scalar<float>( "m_d0_g10n", myIPandSigma->IPd0 );
224 fill(pvGroup, phi_g10n_m, d0_g10n_m);
225 fill(pvGroup, eta_g10n_m, d0_g10n_m);
226 }
227 }
228
229 } // End of track selection loop
230
231 return StatusCode::SUCCESS;
232}
233
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
double charge(const T &p)
Definition AtlasPID.h:997
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
This is an Identifier helper class for the TRT subdetector.
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadHandleKey< xAOD::VertexContainer > m_vxContainerName
virtual StatusCode initialize() override
initialize
IDAlignMonPVBiasesAlg(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< Trk::ITrackToVertexIPEstimator > m_trackToVertexIPEstimator
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleName
Declare a monitored scalar variable.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
VxType::VertexType vertexType() const
The type of the vertex.
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.
Generic monitoring tool for athena components.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Vertex_v1 Vertex
Define the latest version of the vertex class.