ATLAS Offline Software
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 
17 namespace xAOD {
18 
19 
21  : TruthEventBase_v1() {
22 
23  }
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 ) ) {
280  beamParticle2LinkAcc( *this ).toPersistent();
281  }
282  if( signalProcessVertexLinkAcc.isAvailableWritable( *this ) ) {
283  signalProcessVertexLinkAcc( *this ).toPersistent();
284  }
285 
287  return;
288  }
289 
290 } // namespace xAOD
xAOD::AUXSTORE_PRIMITIVE_SETTER_AND_GETTER
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
xAOD::TruthEvent_v1::pdfInfoParameter
bool pdfInfoParameter(int &value, PdfParam parameter) const
Read an integer PDF info parameter.
Definition: TruthEvent_v1.cxx:51
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
xAOD::TruthEvent_v1::PdfInfo::xf1
float xf1
Definition: TruthEvent_v1.h:115
xAOD::TruthEvent_v1::X2
@ X2
[float]
Definition: TruthEvent_v1.h:80
xAOD::TruthEvent_v1::PdfInfo::PdfInfo
PdfInfo()
Constructor to set (invalid) defaults.
Definition: TruthEvent_v1.cxx:99
xAOD::TruthEvent_v1::toPersistent
void toPersistent()
Function making sure that the object is ready for persistification.
Definition: TruthEvent_v1.cxx:274
xAOD::TruthEvent_v1::XF2
@ XF2
[float]
Definition: TruthEvent_v1.h:86
xAOD::TruthEvent_v1::setSignalProcessVertexLink
void setSignalProcessVertexLink(const TruthVertexLink_t &link)
Set pointer to a vertex representing the primary beam interaction point.
xAOD::TruthEventBase_v1::toPersistent
void toPersistent()
Function making sure that the object is ready for persistification.
Definition: TruthEventBase_v1.cxx:143
xAOD::heavyIonAccessorV1Float
const SG::AuxElement::Accessor< float > * heavyIonAccessorV1Float(TruthEvent_v1::HIParam type)
Helper function for getting accessors for floating point HI information.
Definition: TruthAccessors_v1.cxx:105
ObjectType
ObjectType
Definition: BaseObject.h:11
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:66
AuxStoreAccessorMacros.h
xAOD::TruthEvent_v1::PdfInfo::pdfId1
int pdfId1
Definition: TruthEvent_v1.h:110
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
xAOD::TruthEvent_v1::PDFID2
@ PDFID2
[int]
Definition: TruthEvent_v1.h:78
xAOD::TruthEvent_v1::setBeamParticle2Link
void setBeamParticle2Link(const TruthParticleLink_t &pcl2)
Set one incoming beam particle.
xAOD::TruthEvent_v1::heavyIonParameter
bool heavyIonParameter(int &value, HIParam parameter) const
Read an integer HI parameter.
Definition: TruthEvent_v1.cxx:138
xAOD::TruthEvent_v1::setHeavyIonParameter
bool setHeavyIonParameter(int value, HIParam parameter)
Set an integer HI parameter.
Definition: TruthEvent_v1.cxx:162
athena.value
value
Definition: athena.py:122
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::TruthEvent_v1::PdfInfo::pdgId1
int pdgId1
Definition: TruthEvent_v1.h:108
xAOD::TruthEvent_v1::TruthEvent_v1
TruthEvent_v1()
Default constructor.
Definition: TruthEvent_v1.cxx:20
xAOD::TruthEvent_v1::signalProcessVertexLink
const TruthVertexLink_t & signalProcessVertexLink() const
Link to the vertex representing the primary beam interaction point.
TruthEvent
HepMC::GenEvent TruthEvent
Definition: Simulation/G4Sim/MCTruth/MCTruth/TruthEvent.h:11
xAOD::TruthEvent_v1::pdfInfo
PdfInfo pdfInfo() const
Retrieve a full PdfInfo with a single call.
Definition: TruthEvent_v1.cxx:114
xAOD::TruthEvent_v1::PdfInfo::x2
float x2
Definition: TruthEvent_v1.h:113
xAOD::TruthEvent_v1::PdfParam
PdfParam
Accessor enums for PDF info parameter lookup.
Definition: TruthEvent_v1.h:74
xAOD::TruthEvent_v1::beamParticle2Link
const TruthParticleLink_t & beamParticle2Link() const
Get the link to the second incoming beam particle.
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
xAOD::TruthEvent_v1::setPdfInfoParameter
bool setPdfInfoParameter(int value, PdfParam parameter)
Set an integer PDF info parameter.
Definition: TruthEvent_v1.cxx:75
xAOD::TruthEvent_v1::PdfInfo::pdfId2
int pdfId2
Definition: TruthEvent_v1.h:111
xAOD::TruthEvent_v1
Class describing a signal truth event in the MC record.
Definition: TruthEvent_v1.h:35
TruthEvent_v1.h
xAODType
Definition: ObjectType.h:13
xAOD::TruthEvent_v1::XF1
@ XF1
[float]
Definition: TruthEvent_v1.h:85
xAOD::pdfInfoAccessorV1Float
const SG::AuxElement::Accessor< float > * pdfInfoAccessorV1Float(TruthEvent_v1::PdfParam type)
Helper function for getting accessors for floating point PDF information.
Definition: TruthAccessors_v1.cxx:61
xAOD::TruthEvent_v1::PdfInfo::valid
bool valid() const
Check if all the variables in the object are valid.
Definition: TruthEvent_v1.cxx:105
TruthAccessors_v1.h
xAOD::TruthEvent_v1::PdfInfo
Helper struct holding a full set of PDF info values.
Definition: TruthEvent_v1.h:100
xAOD::TruthEventBase_v1
Base class describing a pile-up or signal truth event in the MC record.
Definition: TruthEventBase_v1.h:36
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:41
xAOD::pdfInfoAccessorV1Int
const SG::AuxElement::Accessor< int > * pdfInfoAccessorV1Int(TruthEvent_v1::PdfParam type)
Helper function for getting accessors for integer type PDF information.
Definition: TruthAccessors_v1.cxx:42
xAOD::TruthEvent_v1::signalProcessVertex
const TruthVertex * signalProcessVertex() const
Pointer to a vertex representing the primary beam interaction point.
Definition: TruthEvent_v1.cxx:195
SG::AuxElement::isAvailable
bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for reading.
xAOD::TruthEvent_v1::beamParticle1Link
const TruthParticleLink_t & beamParticle1Link() const
Get the link to the first incoming beam particle.
xAOD::heavyIonAccessorV1Int
const SG::AuxElement::Accessor< int > * heavyIonAccessorV1Int(TruthEvent_v1::HIParam type)
Helper function for getting accessors for integer type HI information.
Definition: TruthAccessors_v1.cxx:81
xAOD::TruthEvent_v1::PdfInfo::pdgId2
int pdgId2
Definition: TruthEvent_v1.h:109
xAOD::TruthEvent_v1::PDGID1
@ PDGID1
[int]
Definition: TruthEvent_v1.h:75
xAOD::TruthEvent_v1::PdfInfo::x1
float x1
Definition: TruthEvent_v1.h:112
xAOD::crossSection
crossSection
Definition: TruthEvent_v1.cxx:33
xAOD::TruthEvent_v1::setBeamParticleLinks
void setBeamParticleLinks(const TruthParticleLink_t &pcl1, const TruthParticleLink_t &pcl2)
Set incoming beam particles.
Definition: TruthEvent_v1.cxx:250
xAOD::TruthEvent_v1::X1
@ X1
[float]
Definition: TruthEvent_v1.h:79
xAOD::TruthEvent_v1::PDGID2
@ PDGID2
[int]
Definition: TruthEvent_v1.h:76
SG::AuxElement::isAvailableWritable
bool isAvailableWritable(const std::string &name, const std::string &clsname="")
Check if an aux variable is available for writing.
xAOD::TruthEvent_v1::PdfInfo::Q
float Q
Definition: TruthEvent_v1.h:114
xAOD::TruthEvent_v1::beamParticles
std::pair< const TruthParticle *, const TruthParticle * > beamParticles() const
Pair of pointers to the two incoming beam particles.
Definition: TruthEvent_v1.cxx:226
xAOD::TruthEvent_v1::PdfInfo::xf2
float xf2
Definition: TruthEvent_v1.h:116
xAOD::TruthEvent_v1::Q
@ Q
[float]
Definition: TruthEvent_v1.h:82
error
Definition: IImpactPoint3dEstimator.h:70
xAOD::TruthEvent_v1::type
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
Definition: TruthEvent_v1.cxx:269
xAOD::TruthEvent_v1::PDFID1
@ PDFID1
[int]
Definition: TruthEvent_v1.h:77
xAOD::TruthEvent_v1::HIParam
HIParam
Heavy ion parameter enum.
Definition: TruthEvent_v1.h:130
xAOD::TruthEvent_v1::setBeamParticle1Link
void setBeamParticle1Link(const TruthParticleLink_t &pcl1)
Set one incoming beam particle.
xAOD::AUXSTORE_OBJECT_SETTER_AND_GETTER
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1
Definition: CaloRings_v1.cxx:27