ATLAS Offline Software
Loading...
Searching...
No Matches
TruthEvent_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: TruthEvent_v1.cxx 761798 2016-07-14 08:15:01Z krasznaa $
6
7// System include(s):
8#include <cmath>
9
10// EDM include(s):
12
13// Local include(s):
15#include "TruthAccessors_v1.h"
16
17namespace xAOD {
18
19
24
26 // Simple, always-present event properties
27
31 weights, setWeights )
32
34 setCrossSection )
36 crossSectionError,
37 setCrossSectionError )
38
39 void TruthEvent_v1::setCrossSection( float value, float error ) {
40
41 setCrossSection( value );
42 setCrossSectionError( error );
43 return;
44 }
45
47
49 // Optional PDF info accessors
50
52 PdfParam information ) const {
53
54 // Look for the accessor object:
55 const auto * acc = pdfInfoAccessorV1Int( information );
56 if( ! acc ) return false;
57
58 // Get the value:
59 value = ( *acc )( *this );
60 return true;
61 }
62
64 PdfParam information ) const {
65
66 // Look for the accessor object:
67 const auto * acc = pdfInfoAccessorV1Float( information );
68 if( ! acc ) return false;
69
70 // Get the value:
71 value = ( *acc )( *this );
72 return true;
73 }
74
76 PdfParam information ) {
77
78 // Look for the accessor object:
79 const auto * acc = pdfInfoAccessorV1Int( information );
80 if( ! acc ) return false;
81
82 // Set the value:
83 ( *acc )( *this ) = value;
84 return true;
85 }
86
88 PdfParam information ) {
89
90 // Look for the accessor object:
91 const auto * acc = pdfInfoAccessorV1Float( information );
92 if( ! acc ) return false;
93
94 // Set the value:
95 ( *acc )( *this ) = value;
96 return true;
97 }
98
100 : pdgId1( 0 ), pdgId2( 0 ), pdfId1( -1 ), pdfId2( -1 ),
101 x1( NAN ), x2( NAN ), Q( NAN ), xf1( NAN ), xf2( NAN ) {
102
103 }
104
106
107 return ( ( pdgId1 != 0 ) && ( pdgId2 != 0 ) &&
108 ( pdfId1 >= 0 ) && ( pdfId2 >= 0 ) &&
109 ( ! std::isnan( x1 ) ) && ( ! std::isnan( x2 ) ) &&
110 ( ! std::isnan( Q ) ) &&
111 ( ! std::isnan( xf1 ) ) && ( ! std::isnan( xf2 ) ) );
112 }
113
115
116 // The result object:
117 PdfInfo rtn;
118
119 // Retrieve all of its elements:
124 pdfInfoParameter( rtn.x1, X1 );
125 pdfInfoParameter( rtn.x2, X2 );
126 pdfInfoParameter( rtn.Q, Q );
127 pdfInfoParameter( rtn.xf1, XF1 );
128 pdfInfoParameter( rtn.xf2, XF2 );
129
130 return rtn;
131 }
132
134
136 // Optional heavy ion accessors
137
139 HIParam information ) const {
140
141 // Look for the accessor object:
142 const auto * acc = heavyIonAccessorV1Int( information );
143 if( ! acc ) return false;
144
145 // Get the value:
146 value = ( *acc )( *this );
147 return true;
148 }
149
151 HIParam information ) const {
152
153 // Look for the accessor object:
154 const auto * acc = heavyIonAccessorV1Float( information );
155 if( ! acc ) return false;
156
157 // Get the value:
158 value = ( *acc )( *this );
159 return true;
160 }
161
163 HIParam information ) {
164
165 // Look for the accessor object:
166 const auto * acc = heavyIonAccessorV1Int( information );
167 if( ! acc ) return false;
168
169 // Set the value:
170 ( *acc )( *this ) = value;
171 return true;
172 }
173
175 HIParam information ) {
176
177 // Look for the accessor object:
178 const auto * acc = heavyIonAccessorV1Float( information );
179 if( ! acc ) return false;
180
181 // Set the value:
182 ( *acc )( *this ) = value;
183 return true;
184 }
185
187
189 // Implementation for the links to truth particles/vertices
190
191 // Accessor for the signal vertex
193 signalProcessVertexLinkAcc( "signalProcessVertexLink" );
194
196
197 // Check if the link variable is available:
198 if( ! signalProcessVertexLinkAcc.isAvailable( *this ) ) {
199 return nullptr;
200 }
201
202 // Get the link:
203 const TruthVertexLink_t& vertLink = signalProcessVertexLinkAcc( *this );
204
205 // Check if it's valid:
206 if( ! vertLink.isValid() ) {
207 return nullptr;
208 }
209
210 // Return the de-referenced link:
211 return *vertLink;
212 }
213
218
219 // Accessors for the beam particles
221 beamParticle1LinkAcc( "beamParticle1Link" );
223 beamParticle2LinkAcc( "beamParticle2Link" );
224
225 std::pair< const TruthParticle*, const TruthParticle* >
227
228 // Get the pointer to the first beam particle:
229 const TruthParticle* p1 = nullptr;
230 if( beamParticle1LinkAcc.isAvailable( *this ) ) {
231 const TruthParticleLink_t& link = beamParticle1LinkAcc( *this );
232 if( link.isValid() ) {
233 p1 = *link;
234 }
235 }
236
237 // Get the pointer to the second beam particle:
238 const TruthParticle* p2 = nullptr;
239 if( beamParticle2LinkAcc.isAvailable( *this ) ) {
240 const TruthParticleLink_t& link = beamParticle2LinkAcc( *this );
241 if( link.isValid() ) {
242 p2 = *link;
243 }
244 }
245
246 // Construct the returned object:
247 return std::make_pair( p1, p2 );
248 }
249
251 const TruthParticleLink_t& pcl2 ) {
252
253 setBeamParticle1Link( pcl1 );
254 setBeamParticle2Link( pcl2 );
255 return;
256 }
257
266
267
268
270
271 return Type::TruthEvent;
272 }
273
275
276 if( beamParticle1LinkAcc.isAvailableWritable( *this ) ) {
277 beamParticle1LinkAcc( *this ).toPersistent();
278 }
279 if( beamParticle2LinkAcc.isAvailableWritable( *this ) ) {
281 }
282 if( signalProcessVertexLinkAcc.isAvailableWritable( *this ) ) {
283 signalProcessVertexLinkAcc( *this ).toPersistent();
284 }
285
287 return;
288 }
289
290} // namespace xAOD
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
ObjectType
Definition BaseObject.h:11
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
TruthEventBase_v1()
Default constructor.
void toPersistent()
Function making sure that the object is ready for persistification.
Class describing a signal truth event in the MC record.
PdfInfo pdfInfo() const
Retrieve a full PdfInfo with a single call.
ElementLink< TruthParticleContainer > TruthParticleLink_t
Type of the links pointing at truth particles.
const TruthVertex * signalProcessVertex() const
Pointer to a vertex representing the primary beam interaction point.
void setBeamParticleLinks(const TruthParticleLink_t &pcl1, const TruthParticleLink_t &pcl2)
Set incoming beam particles.
void setSignalProcessVertexLink(const TruthVertexLink_t &link)
Set pointer to a vertex representing the primary beam interaction point.
ElementLink< TruthVertexContainer > TruthVertexLink_t
Type of the links pointing at truth vertices.
PdfParam
Accessor enums for PDF info parameter lookup.
TruthEvent_v1()
Default constructor.
const TruthVertexLink_t & signalProcessVertexLink() const
Link to the vertex representing the primary beam interaction point.
bool pdfInfoParameter(int &value, PdfParam parameter) const
Read an integer PDF info parameter.
void toPersistent()
Function making sure that the object is ready for persistification.
bool setHeavyIonParameter(int value, HIParam parameter)
Set an integer HI parameter.
bool heavyIonParameter(int &value, HIParam parameter) const
Read an integer HI parameter.
bool setPdfInfoParameter(int value, PdfParam parameter)
Set an integer PDF info parameter.
std::pair< const TruthParticle *, const TruthParticle * > beamParticles() const
Pair of pointers to the two incoming beam particles.
HIParam
Heavy ion parameter enum.
void setBeamParticle1Link(const TruthParticleLink_t &pcl1)
Set one incoming beam particle.
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
const TruthParticleLink_t & beamParticle1Link() const
Get the link to the first incoming beam particle.
void setBeamParticle2Link(const TruthParticleLink_t &pcl2)
Set one incoming beam particle.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
const SG::AuxElement::Accessor< int > * pdfInfoAccessorV1Int(TruthEvent_v1::PdfParam type)
Helper function for getting accessors for integer type PDF information.
static AUXSTORE_OBJECT_SETTER_AND_GETTER(TruthEvent_v1, TruthEvent_v1::TruthVertexLink_t, signalProcessVertexLink, setSignalProcessVertexLink) static const SG const SG::AuxElement::Accessor< TruthEvent_v1::TruthParticleLink_t > beamParticle2LinkAcc("beamParticle2Link")
const SG::AuxElement::Accessor< int > * heavyIonAccessorV1Int(TruthEvent_v1::HIParam type)
Helper function for getting accessors for integer type HI information.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
const SG::AuxElement::Accessor< float > * pdfInfoAccessorV1Float(TruthEvent_v1::PdfParam type)
Helper function for getting accessors for floating point PDF information.
TruthParticle_v1 TruthParticle
Typedef to implementation.
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
const SG::AuxElement::Accessor< float > * heavyIonAccessorV1Float(TruthEvent_v1::HIParam type)
Helper function for getting accessors for floating point HI information.
static const SG::AuxElement::Accessor< TruthEvent_v1::TruthVertexLink_t > signalProcessVertexLinkAcc("signalProcessVertexLink")
Helper struct holding a full set of PDF info values.
bool valid() const
Check if all the variables in the object are valid.
PdfInfo()
Constructor to set (invalid) defaults.