ATLAS Offline Software
Classes | Typedefs | Enumerations | Functions
IDPVM Namespace Reference

Class to retrieve associated truth from a track, implementing a cached response. More...

Classes

class  CachedGetAssocTruth
 
class  ResolutionHelper
 
class  TrackTruthLookup
 Class for providing fast lookup of linked tracks and truth particles. More...
 

Typedefs

template<class ContainerType , class VariableType >
using WriteKeyAccessorPair = std::pair< SG::WriteDecorHandleKey< ContainerType >, SG::AuxElement::ConstAccessor< VariableType > >
 
template<class ContainerType , class VariableType >
using WriteAccessorRefPair = std::pair< SG::WriteDecorHandle< ContainerType, VariableType >, SG::AuxElement::ConstAccessor< VariableType > & >
 
template<class ContainerType , class VariableType >
using OptionalDecoration = std::pair< SG::WriteDecorHandle< ContainerType, VariableType >, bool >
 

Enumerations

enum  DuplicateBehaviour { DO_NOTHING, REJECT_QUIETLY, REJECT_WITH_WARNING, REJECT_WARN_IF_UNEQUAL }
 Behaviour in case of trying to add a decoration which previously exists. More...
 

Functions

constexpr float operator""_GeV (long double energy)
 Convert to GeV from the default MeV. More...
 
constexpr float operator""_GeV (unsigned long long energy)
 
template<class T >
bool inRange (const T &value, const T &minVal, const T &maxVal)
 general utility function to check value is in range More...
 
template<class T >
bool inRange (const T &value, const T &absoluteMax)
 
template<class T >
unsigned int binIndex (const T &val, const std::vector< T > &partitions)
 general utility function to return bin index given a value and the upper endpoints of each bin More...
 
template<class T >
float safelyGetEta (const T &pTrk, const float safePtThreshold=0.1)
 Safely get eta. More...
 
template<class T >
float safelyGetEta (const T *pTrk, const float safePtThreshold=0.1)
 
std::vector< double > logLinearBinning (const unsigned int nBins, const double absXmin, const double absXmax, const bool symmetriseAroundZero)
 
bool roughlyEqual (const int i, const int j)
 
bool roughlyEqual (const unsigned int i, const unsigned int j)
 
bool roughlyEqual (const float i, const float j)
 
template<class T_Parent , class T_Cont , class T >
void createDecoratorKeysAndAccessor (T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< WriteKeyAccessorPair< T_Cont, T > > &decor_out)
 
template<class T_Cont , class T >
std::vector< OptionalDecoration< T_Cont, T > > createDecoratorsIfNeeded (const T_Cont &container, const std::vector< WriteKeyAccessorPair< T_Cont, T > > &keys, const EventContext &ctx, bool verbose=false)
 
template<class T_Cont , class T >
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators (const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
 
template<class T_Parent , class T_Cont >
void createDecoratorKeys (T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::WriteDecorHandleKey< T_Cont > > &decor_out)
 
template<class T_Parent , class T_Cont >
void addReadDecoratorHandleKeys (T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::ReadDecorHandleKey< T_Cont > > &decor_out)
 
template<class T_Cont , class T_Cont_Elm , class T >
void decorateOrWarnIfUnequal (const T_Cont_Elm &particle, WriteAccessorRefPair< T_Cont, T > &decorator, const T &value)
 
template<class T_Cont , class T_Cont_Elm , class T >
void decorateOrRejectQuietly (const T_Cont_Elm &particle, OptionalDecoration< T_Cont, T > &decorator, const T &value)
 
template<class T_Cont , class T_Cont_Elm , class T >
void decorate (const T_Cont_Elm &particle, OptionalDecoration< T_Cont, T > &decorator, const T &value)
 
const xAOD::TruthParticlegetTruthPointer (const xAOD::TrackParticle &track)
 

Detailed Description

Class to retrieve associated truth from a track, implementing a cached response.

Typedef Documentation

◆ OptionalDecoration

template<class ContainerType , class VariableType >
using IDPVM::OptionalDecoration = typedef std::pair<SG::WriteDecorHandle<ContainerType, VariableType>, bool >

Definition at line 48 of file safeDecorator.h.

◆ WriteAccessorRefPair

template<class ContainerType , class VariableType >
using IDPVM::WriteAccessorRefPair = typedef std::pair<SG::WriteDecorHandle<ContainerType, VariableType>, SG::AuxElement::ConstAccessor<VariableType>& >

Definition at line 45 of file safeDecorator.h.

◆ WriteKeyAccessorPair

template<class ContainerType , class VariableType >
using IDPVM::WriteKeyAccessorPair = typedef std::pair<SG::WriteDecorHandleKey<ContainerType>, SG::AuxElement::ConstAccessor<VariableType> >

Definition at line 42 of file safeDecorator.h.

Enumeration Type Documentation

◆ DuplicateBehaviour

Behaviour in case of trying to add a decoration which previously exists.

Enumerator
DO_NOTHING 
REJECT_QUIETLY 
REJECT_WITH_WARNING 
REJECT_WARN_IF_UNEQUAL 

Definition at line 38 of file safeDecorator.h.

Function Documentation

◆ addReadDecoratorHandleKeys()

template<class T_Parent , class T_Cont >
void IDPVM::addReadDecoratorHandleKeys ( T_Parent &  parent,
const SG::ReadHandleKey< T_Cont > &  container_key,
const std::string &  prefix,
const std::vector< std::string > &  decor_names,
std::vector< SG::ReadDecorHandleKey< T_Cont > > &  decor_out 
)

Definition at line 145 of file safeDecorator.h.

149  {
150  decor_out.reserve(decor_out.size() + decor_names.size());
151  for (const std::string &a_decor_name : decor_names) {
152  decor_out.emplace_back( container_key.key()+"."+prefix+a_decor_name);
153  parent.declare(decor_out.back());
154  decor_out.back().setOwner(&parent);
155  decor_out.back().initialize().ignore();
156  }
157  }

◆ binIndex()

template<class T >
unsigned int IDPVM::binIndex ( const T &  val,
const std::vector< T > &  partitions 
)

general utility function to return bin index given a value and the upper endpoints of each bin

Definition at line 43 of file InDetPhysValMonitoringUtilities.h.

43  {// signature should allow other containers
44  unsigned int i(0);
45  bool nf = true;
46 
47  while (nf and i != partitions.size()) {
48  nf = (val > partitions[i++]);
49  }
50  return nf ? i : i - 1;
51  }

◆ createDecoratorKeys()

template<class T_Parent , class T_Cont >
void IDPVM::createDecoratorKeys ( T_Parent &  parent,
const SG::ReadHandleKey< T_Cont > &  container_key,
const std::string &  prefix,
const std::vector< std::string > &  decor_names,
std::vector< SG::WriteDecorHandleKey< T_Cont > > &  decor_out 
)

Definition at line 125 of file safeDecorator.h.

129  {
130  decor_out.clear();
131  decor_out.reserve(decor_names.size());
132  for (const std::string &a_decor_name : decor_names) {
133  assert( !a_decor_name.empty() );
134  decor_out.emplace_back(container_key.key()+"."+prefix+a_decor_name);
135  // need to declare handles, otherwise the scheduler would not pick up the data dependencies
136  // introduced by the decorations
137  parent.declare(decor_out.back());
138  decor_out.back().setOwner(&parent);
139  decor_out.back().initialize().ignore();
140  }
141  }

◆ createDecoratorKeysAndAccessor()

template<class T_Parent , class T_Cont , class T >
void IDPVM::createDecoratorKeysAndAccessor ( T_Parent &  parent,
const SG::ReadHandleKey< T_Cont > &  container_key,
const std::string &  prefix,
const std::vector< std::string > &  decor_names,
std::vector< WriteKeyAccessorPair< T_Cont, T > > &  decor_out 
)

Definition at line 52 of file safeDecorator.h.

56  {
57  decor_out.clear();
58  decor_out.reserve(decor_names.size());
59  for (const std::string &a_decor_name: decor_names) {
60  decor_out.emplace_back(SG::WriteDecorHandleKey<T_Cont>(container_key.key()+"."+prefix+a_decor_name),
62  parent.declare(decor_out.back().first);
63  decor_out.back().first.setOwner(&parent);
64  decor_out.back().first.initialize().ignore();
65  }
66  }

◆ createDecorators()

template<class T_Cont , class T >
std::vector<SG::WriteDecorHandle<T_Cont,T> > IDPVM::createDecorators ( const std::vector< SG::WriteDecorHandleKey< T_Cont > > &  keys,
const EventContext &  ctx 
)

Definition at line 107 of file safeDecorator.h.

108  {
109  std::vector<SG::WriteDecorHandle<T_Cont,T> > out;
110  out.reserve(keys.size());
111  for( const SG::WriteDecorHandleKey<T_Cont> &a_key : keys) {
112  out.emplace_back(a_key,ctx);
113  if (not out.back().isValid()) {
114  std::stringstream msg;
115  msg << "Failed to create decorator handdle " << a_key.key();
116  throw std::runtime_error( msg.str() );
117  }
118  }
119  return out;
120  }

◆ createDecoratorsIfNeeded()

template<class T_Cont , class T >
std::vector<OptionalDecoration<T_Cont,T> > IDPVM::createDecoratorsIfNeeded ( const T_Cont &  container,
const std::vector< WriteKeyAccessorPair< T_Cont, T > > &  keys,
const EventContext &  ctx,
bool  verbose = false 
)

Definition at line 70 of file safeDecorator.h.

73  {
74  std::vector<OptionalDecoration<T_Cont, T> > out;
75  bool all_available=true;
76  if (!container.empty()) {
77  std::vector<bool> decorate;
78  decorate.reserve(keys.size());
79  for( const WriteKeyAccessorPair<T_Cont, T> &a_key : keys) {
80  decorate.push_back(!a_key.second.isAvailable(*container[0]) );
81  all_available &= !decorate.back();
82  if (verbose && !decorate.back()) {
83  std::cout << "WARNING IDPVM::createDecoratorsIfNeeded: Decoration " << a_key.first.key() <<
84  " already exists; reject update.\n";
85  }
86  }
87  if (!all_available) {
88  std::size_t idx=0;
89  out.reserve(keys.size());
90  for( const WriteKeyAccessorPair<T_Cont, T> &a_key : keys) {
91  assert( idx < decorate.size());
92  out.emplace_back(SG::WriteDecorHandle<T_Cont,T>(a_key.first,ctx), decorate[idx++]);
93  if (not out.back().first.isPresent()) {
94  std::stringstream msg;
95  msg << "Container " << a_key.first.key() << " to be decorated does not exist.";
96  throw std::runtime_error( msg.str() );
97  }
98  }
99  }
100  }
101  return out;
102  }

◆ decorate()

template<class T_Cont , class T_Cont_Elm , class T >
void IDPVM::decorate ( const T_Cont_Elm &  particle,
OptionalDecoration< T_Cont, T > &  decorator,
const T &  value 
)

Definition at line 184 of file safeDecorator.h.

185  {
186  decorator.first(particle) = value;
187  }

◆ decorateOrRejectQuietly()

template<class T_Cont , class T_Cont_Elm , class T >
void IDPVM::decorateOrRejectQuietly ( const T_Cont_Elm &  particle,
OptionalDecoration< T_Cont, T > &  decorator,
const T &  value 
)

Definition at line 175 of file safeDecorator.h.

176  {
177  if (decorator.second) {
178  decorator.first(particle) = value;
179  }
180  }

◆ decorateOrWarnIfUnequal()

template<class T_Cont , class T_Cont_Elm , class T >
void IDPVM::decorateOrWarnIfUnequal ( const T_Cont_Elm &  particle,
WriteAccessorRefPair< T_Cont, T > &  decorator,
const T &  value 
)

Definition at line 161 of file safeDecorator.h.

162  {
163  if (!decorator.second.isAvailable(particle)) {
164  const T existing = decorator.second(particle);
165  if (not IDPVM::roughlyEqual(existing, value)) {
166  std::cout << "WARNING IDPVM::safeDecorator: " << decorator.first.decorKey() <<
167  " Already exists on this object with a different value.\n";
168  }
169  } else {
170  decorator.first(particle) = value;
171  }
172  }

◆ getTruthPointer()

const xAOD::TruthParticle* IDPVM::getTruthPointer ( const xAOD::TrackParticle track)

Definition at line 12 of file TrackTruthLookup.cxx.

12  {
13  using ElementTruthLink_t = ElementLink<xAOD::TruthParticleContainer>;
14  const xAOD::TruthParticle* result(nullptr);
15 
16  // Check whether truthParticleLink exists.
17  static const SG::ConstAccessor<ElementTruthLink_t> truthParticleLinkAcc("truthParticleLink");
18  if (truthParticleLinkAcc.isAvailable(track)) {
19  // If so, get linked xAOD::TruthParticle.
20  const ElementTruthLink_t ptruthContainer =
21  truthParticleLinkAcc(track);
22  if (ptruthContainer.isValid()) {
23  result = *ptruthContainer;
24  }
25  }
26  return result;
27  }

◆ inRange() [1/2]

template<class T >
bool IDPVM::inRange ( const T &  value,
const T &  absoluteMax 
)
inline

Definition at line 36 of file InDetPhysValMonitoringUtilities.h.

36  {
37  return not (std::abs(value) > absoluteMax);
38  }

◆ inRange() [2/2]

template<class T >
bool IDPVM::inRange ( const T &  value,
const T &  minVal,
const T &  maxVal 
)
inline

general utility function to check value is in range

Definition at line 30 of file InDetPhysValMonitoringUtilities.h.

30  {
31  return not ((value < minVal)or(value > maxVal));
32  }

◆ logLinearBinning()

std::vector< double > IDPVM::logLinearBinning ( const unsigned int  nBins,
const double  absXmin,
const double  absXmax,
const bool  symmetriseAroundZero 
)

Definition at line 16 of file logLinearBinning.cxx.

16  {
17  // some checks to ensure the user is requesting something sensible
18  if (absXmin <=0 or absXmax <=0){
19  throw std::range_error("absXmin or absXmax argument to logLinearBinning is out of range");
20  } else if (nBins ==0){
21  throw std::range_error("nBins argument to logLinearBinning is zero");
22  }
23  // reserve the vector space
24  const unsigned int asymVecSize = nBins + 1;
25  std::vector<double> theBinning(asymVecSize,0.);
26  // define our starting bin edge and step size in log space
27  const double logStart = std::log(absXmin);
28  const double logDist = std::log(absXmax) - logStart;
29  const double logStep = logDist / (double) nBins;
30  // then populate the bin array
31  double thisLog{logStart};
32  for (auto & thisBin:theBinning){
33  thisBin=std::exp(thisLog);
34  thisLog+=logStep;
35  }
36  //sroe: I think the following is logically incorrect, but for now will reproduce the original functionality
37  //pending testing
38  //
39  // if we want to symmetrise, we need one extra step to add the negative
40  // half axis (and the division at zero).
41  if (symmetriseAroundZero){
42  std::vector<double> aux_negative;
43  aux_negative.reserve(nBins+1);
44  // flip signs (and populate new vec)
45  std::transform(theBinning.begin(),theBinning.end(), std::back_inserter(aux_negative),
46  [](double & val){return -1. * val;});
47  // reorder
48  std::reverse(aux_negative.begin(),aux_negative.end());
49  // and add the split at zero
50  aux_negative.push_back(0.);
51  // then put it all together
52  theBinning.insert(theBinning.begin(), aux_negative.begin(), aux_negative.end());
53  }
54  return theBinning;
55  }

◆ operator""_GeV() [1/2]

constexpr float IDPVM::operator""_GeV ( long double  energy)
constexpr

Convert to GeV from the default MeV.

Definition at line 18 of file InDetPhysValMonitoringUtilities.h.

18  {
19  return energy * 0.001;
20  }

◆ operator""_GeV() [2/2]

constexpr float IDPVM::operator""_GeV ( unsigned long long  energy)
constexpr

Definition at line 23 of file InDetPhysValMonitoringUtilities.h.

23  {
24  return energy * 0.001;
25  }

◆ roughlyEqual() [1/3]

bool IDPVM::roughlyEqual ( const float  i,
const float  j 
)

Definition at line 27 of file safeDecorator.cxx.

27  {
28  const float epsilon = 0.001 * std::min(i, j);
29 
30  return(std::fabs(i - j) < epsilon);
31  }

◆ roughlyEqual() [2/3]

bool IDPVM::roughlyEqual ( const int  i,
const int  j 
)

Definition at line 17 of file safeDecorator.cxx.

17  {
18  return i == j;
19  }

◆ roughlyEqual() [3/3]

bool IDPVM::roughlyEqual ( const unsigned int  i,
const unsigned int  j 
)

Definition at line 22 of file safeDecorator.cxx.

22  {
23  return i == j;
24  }

◆ safelyGetEta() [1/2]

template<class T >
float IDPVM::safelyGetEta ( const T &  pTrk,
const float  safePtThreshold = 0.1 
)
inline

Safely get eta.

Definition at line 56 of file InDetPhysValMonitoringUtilities.h.

56  {
57  return (pTrk.pt() > safePtThreshold) ? (pTrk.eta()) : std::nan("");
58  }

◆ safelyGetEta() [2/2]

template<class T >
float IDPVM::safelyGetEta ( const T *  pTrk,
const float  safePtThreshold = 0.1 
)
inline

Definition at line 62 of file InDetPhysValMonitoringUtilities.h.

62  {
63  return (pTrk->pt() > safePtThreshold) ? (pTrk->eta()) : std::nan("");
64  }
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition: StoreGate/StoreGate/WriteDecorHandleKey.h:89
IDPVM::decorate
void decorate(const T_Cont_Elm &particle, OptionalDecoration< T_Cont, T > &decorator, const T &value)
Definition: safeDecorator.h:184
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
get_generator_info.result
result
Definition: get_generator_info.py:21
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
athena.value
value
Definition: athena.py:124
IDPVM::REJECT_WARN_IF_UNEQUAL
@ REJECT_WARN_IF_UNEQUAL
Definition: safeDecorator.h:39
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
DeMoScan.partitions
dictionary partitions
Definition: DeMoScan.py:67
min
#define min(a, b)
Definition: cfImp.cxx:40
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
IDPVM::REJECT_WITH_WARNING
@ REJECT_WITH_WARNING
Definition: safeDecorator.h:39
IDPVM::DO_NOTHING
@ DO_NOTHING
Definition: safeDecorator.h:39
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
IDPVM::roughlyEqual
bool roughlyEqual(const int i, const int j)
Definition: safeDecorator.cxx:17
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
IDPVM::REJECT_QUIETLY
@ REJECT_QUIETLY
Definition: safeDecorator.h:39
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35