ATLAS Offline Software
Loading...
Searching...
No Matches
MissingETBase.h
Go to the documentation of this file.
1// -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef XAODMISSINGET_VERSIONS_MISSINGETBASE_H
8#define XAODMISSINGET_VERSIONS_MISSINGETBASE_H
9
10
11#define EXTRACT_PX( _T_, _V_, _P_ ) \
12 _T_ _V_(_P_.p4().Px())
13
14#define EXTRACT_PY( _T_, _V_, _P_ ) \
15 _T_ _V_(_P_.p4().Py())
16
17#define EXTRACT_SCALED_PX( _T_, _V_, _P_, _S_ ) \
18 _T_ _V_(_P_.p4().Px()*_S_)
19
20#define EXTRACT_SCALED_PY( _T_, _V_, _P_, _S_ ) \
21 _T_ _V_(_P_.p4().Py()*_S_)
22
23#include "CxxUtils/bitmask.h"
24
25#include <cstddef>
26#include <cmath>
27#include <vector>
28#include <string>
29#include <cstdint>
30
31#include <tuple>
32
34namespace MissingETBase
35 {
37 namespace Types
38 {
39 typedef uint64_t bitmask_t;
40 typedef std::vector<bitmask_t> bitmask_vector_t;
41 typedef std::tuple<size_t,size_t> indexedlink_t;
42 } // namespace MissingETBase::Types
43
44 namespace Constants
45 {
48 static constexpr double precision = 0.00001;
49
50 static constexpr size_t invalidIndex = size_t(-1);
51 static constexpr size_t unknownIndex = size_t(-1);
52
53 static const constexpr double wpxDefault = 1.0;
54 static constexpr double wpyDefault = 1.0;
55 static constexpr double wetDefault = 1.0;
56 static constexpr double wpxError = 0.0;
57 static constexpr double wpyError = 0.0;
58 static constexpr double wetError = 0.0;
59
60 static const constexpr double cpxDefault = 0.0;
61 static constexpr double cpyDefault = 0.0;
62 static constexpr double cpzDefault = 0.0;
63 static constexpr double ceDefault = 0.0;
64 static constexpr double sumptDefault = 0.0;
65 static constexpr double cpxError = -9999999;
66 static constexpr double cpyError = -9999999;
67 static constexpr double cpzError = -9999999;
68 static constexpr double ceError = -9999999;
69 static constexpr double sumptError = -9999999;
70
74 static const std::string invalidString = "INVALID";
75 static const std::string unknownString = "UNKNOWN";
76 static const std::string emptyString = "EMPTY";
77 static const std::string nullString = "NULL";
79 } // namespace MissingETBase::Constants
80
82 struct Numerical
83 {
86 static double precision() { return Constants::precision; }
87 static double wpxDefault() { return Constants::wpxDefault; }
88 static double wpyDefault() { return Constants::wpyDefault; }
89 static double wetDefault() { return Constants::wetDefault; }
90 static double wpxError() { return Constants::wpxError; }
91 static double wpyError() { return Constants::wpyError; }
92 static double wetError() { return Constants::wetError; }
93 static double cpxDefault() { return Constants::cpxDefault; }
94 static double cpyDefault() { return Constants::cpyDefault; }
95 static double cpzDefault() { return Constants::cpzDefault; }
96 static double ceDefault() { return Constants::ceDefault; }
97 static double sumptDefault() { return Constants::sumptDefault; }
98 static double cpxError() { return Constants::cpxError; }
99 static double cpyError() { return Constants::cpyError; }
100 static double cpzError() { return Constants::cpzError; }
101 static double ceError() { return Constants::ceError; }
102 static double sumptError() { return Constants::sumptError; }
103 static size_t invalidIndex() { return Constants::invalidIndex; }
104 static size_t unknownIndex() { return Constants::unknownIndex; }
119 static bool isEqual(double x,double y) { return std::abs(x-y) < precision(); }
125 static double divide(double x,double y) { return y != 0. ? x/y : 0.; }
127 }; // struct Numerical
128
130 struct Strings
131 {
134 static const std::string& invalidString() { return Constants::invalidString; }
135 static const std::string& unknownString() { return Constants::unknownString; }
136 static const std::string& emptyString() { return Constants::emptyString; }
137 static const std::string& nullString() { return Constants::nullString; }
138 }; // struct String
139
160 struct Source
161 {
166 Refined = 0x10000,
167 Truth = 0x20000,
168 Calo = 0x40000,
169 ID = 0x80000,
170 UnknownCategory = 0x00000,
172 };
173
174 enum class Type : Types::bitmask_t {
175 Electron = 0x00001,
176 Photon = 0x00002,
177 Tau = 0x00004,
178 Muon = 0x00008,
179 Jet = 0x00010,
180 SoftEvent = 0x00020,
182 Total = 0x00040,
183 UnknownType = 0x00000,
185 };
186
192 Central = 0x00100,
193 Endcap = 0x00200,
194 Forward = 0x00400,
195 FullAcceptance = 0x00000,
196 UnknownRegion = 0x00000,
198 };
199
204 NonInt = 0x21000,
205 Int = 0x22000,
206 IntOut = 0x24000,
208 TruthMuons = 0x28000,
209 UnknownTruth = 0x00000,
211 };
212
214 LCTopo = 0x01000,
215 EMTopo = 0x02000,
216 Track = 0x04000,
217 UnknownSignal = 0x00000,
219 };
220
229 static Types::bitmask_t electron(Region reg=Region::FullAcceptance) { return ( Category::Refined | Type::Electron ) | reg; }
236 static Types::bitmask_t photon(Region reg=Region::FullAcceptance) { return ( Category::Refined | Type::Photon ) | reg; }
243 static Types::bitmask_t tau(Region reg=Region::FullAcceptance) { return ( Category::Refined | Type::Tau ) | reg; }
250 static Types::bitmask_t muon(Region reg=Region::FullAcceptance) { return ( Category::Refined | Type::Muon ) | reg; }
257 static Types::bitmask_t jet(Region reg=Region::FullAcceptance) { return ( Category::Refined | Type::Jet ) | reg; }
264 static Types::bitmask_t softEvent(Region reg=Region::FullAcceptance) { return ( Category::Refined | Type::SoftEvent ) | reg; }
271 static Types::bitmask_t total(Region reg=Region::FullAcceptance) { return ( Category::Refined | Type::Total ) | reg; }
314
343
368
381 template <class E, class F>
382 static bool hasPattern(E bits, F mask)
383 { return static_cast<Types::bitmask_t>( bits & mask) == static_cast<Types::bitmask_t>(mask); }
384
392 static bool hasCategory(Types::bitmask_t bits,Category cat) { return hasPattern(bits,cat); }
393 static bool hasType(Types::bitmask_t bits,Type type) { return hasPattern(bits,type); }
394 static bool hasTruthType(Types::bitmask_t bits,TruthType type) { return hasPattern(bits,type); }
395 static bool hasSignal(Types::bitmask_t bits,Signal sig) { return hasPattern(bits,sig);}
397
399 static bool isPhotonTerm(Types::bitmask_t bits,Region reg=Region::FullAcceptance) { return hasPattern(bits,photon(reg)); }
400 static bool isTauTerm(Types::bitmask_t bits,Region reg=Region::FullAcceptance) { return hasPattern(bits,tau(reg)); }
401 static bool isMuonTerm(Types::bitmask_t bits,Region reg=Region::FullAcceptance) { return hasPattern(bits,muon(reg)); }
402 static bool isJetTerm(Types::bitmask_t bits,Region reg=Region::FullAcceptance) { return hasPattern(bits,jet(reg)); }
404 static bool isTrackTerm(Types::bitmask_t bits,Region reg=Region::FullAcceptance) { return hasPattern(bits,track(reg)); }
405 static bool isTotalTerm(Types::bitmask_t bits,Region reg=Region::FullAcceptance) { return hasPattern(bits,total(reg)); }
406
407 static bool isTruthNonInt(Types::bitmask_t bits) { return hasPattern(bits,truthNonInt()); }
408 static bool isTruthInt(Types::bitmask_t bits,Region reg=Region::FullAcceptance) { return hasPattern(bits,truthInt(reg)); }
409 static bool isTruthIntOut(Types::bitmask_t bits) { return hasPattern(bits,truthIntOut()); }
411
413 };
414
415} // namespace MissingETBase
416
417/* @file MissingETBase.h
418 *
419 * @name Globalnamespace operators
420 */
429
431{ return std::get<0>(l0) == std::get<0>(l1) && std::get<1>(l0) == std::get<1>(l1); }
432
435
437{ return std::get<0>(l0) == std::get<0>(l1) ? std::get<1>(l0) >= std::get<1>(l1) : std::get<0>(l0) > std::get<0>(l1); }
438
440{ return std::get<0>(l0) == std::get<0>(l1) ? std::get<1>(l0) <= std::get<1>(l1) : std::get<0>(l0) < std::get<0>(l1); }
441
443{ return std::get<0>(l0) == std::get<0>(l1) ? std::get<1>(l0) > std::get<1>(l1) : std::get<0>(l0) > std::get<0>(l1); }
444
446{ return std::get<0>(l0) == std::get<0>(l1) ? std::get<1>(l0) < std::get<1>(l1) : std::get<0>(l0) < std::get<0>(l1); }
447
448#endif
#define F(x, y, z)
Definition MD5.cxx:112
bool operator<=(MissingETBase::Types::indexedlink_t l0, MissingETBase::Types::indexedlink_t l1)
bool operator>(MissingETBase::Types::indexedlink_t l0, MissingETBase::Types::indexedlink_t l1)
bool operator==(MissingETBase::Types::indexedlink_t l0, MissingETBase::Types::indexedlink_t l1)
bool operator<(MissingETBase::Types::indexedlink_t l0, MissingETBase::Types::indexedlink_t l1)
bool operator>=(MissingETBase::Types::indexedlink_t l0, MissingETBase::Types::indexedlink_t l1)
bool operator!=(MissingETBase::Types::indexedlink_t l0, MissingETBase::Types::indexedlink_t l1)
#define y
#define x
Helpers for treating a class enum as a bitmask.
static const std::string emptyString
Empty string indicator.
static constexpr double sumptError
Error constituent vector .
static const std::string unknownString
Unknown string indicator.
static constexpr double ceDefault
Default constituent vector .
static constexpr double cpxError
Error constituent vector .
static const std::string invalidString
Invalid string indicator.
static const constexpr double cpxDefault
Default constituent vector .
static constexpr double wetError
Error return value for kinematic weight .
static constexpr size_t unknownIndex
Unknown index indicator.
static const constexpr double wpxDefault
Default kinematic weight .
static constexpr double wpxError
Error return value for kinematic weight .
static constexpr double ceError
Error constituent vector .
static constexpr double cpyDefault
Default constituent vector .
static constexpr double wetDefault
Default kinematic weight .
static constexpr double cpyError
Error constituent vector .
static constexpr double sumptDefault
Default constituent sumpt.
static constexpr double wpyError
Error return value for kinematic weight .
static const std::string nullString
NULL string indicator.
static constexpr size_t invalidIndex
Invalid index indicator.
static constexpr double wpyDefault
Default kinematic weight .
static constexpr double precision
Maximum numerical distance up to which two double precision variables are considered to be identical.
static constexpr double cpzError
Error constituent vector .
static constexpr double cpzDefault
Default constituent vector .
uint64_t bitmask_t
Type for status word bit mask.
std::tuple< size_t, size_t > indexedlink_t
Type for links defined as index pairs.
std::vector< bitmask_t > bitmask_vector_t
Type for vector of status word bit masks.
General namespace for MET EDM software.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Numerical constants and operations.
static double sumptDefault()
Access default constituent vector sumpt.
static double cpyError()
Access error return value for constituent vector .
static double precision()
Access precision of numerical distance measure for equality.
static double wpxDefault()
Access default kinematic weight .
static double wpyError()
Access error return value for kinematic weight .
static double wpxError()
Access error return value for kinematic weight .
static double wetDefault()
Access default kinematic weight .
static double cpxError()
Access error return value for constituent vector .
static double cpxDefault()
Access default constituent vector .
static double divide(double x, double y)
Failsafe division.
static double cpzDefault()
Access default constituent vector .
static double cpyDefault()
Access default constituent vector .
static size_t unknownIndex()
Access unknown index indicator.
static double ceError()
Access error return value for constituent vector .
static bool isEqual(double x, double y)
Test of equality.
static size_t invalidIndex()
Access invalid index indicator.
static double cpzError()
Access error return value for constituent vector .
static double sumptError()
Access error return value for constituent vector sumpt.
static double wetError()
Access error return value for kinematic weight .
static double ceDefault()
Access default constituent vector .
static Types::indexedlink_t invalidLink()
Access invaalid link tag.
static double wpyDefault()
Access default kinematic weight .
MET source indicators.
static bool isTruthNonInt(Types::bitmask_t bits)
static Types::bitmask_t total(Region reg=Region::FullAcceptance)
Standard full reconstructed MET.
static Types::bitmask_t signal(Signal sig=(Signal::LCTopo|Signal::Track), Region reg=Region::FullAcceptance)
Bit mask for MET term from any (or mixed) signal objects.
static Types::bitmask_t caloLCTopo(Region reg=Region::FullAcceptance)
Bit pattern indicating a LCTopo MET term.
static Types::bitmask_t muon(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed muons.
static Types::bitmask_t clusterEM(Region reg=Region::FullAcceptance)
Bit mask for MET term from EMTopo signal objects.
static Types::bitmask_t jet(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed jets.
Category
Source category tag.
@ Calo
Indicator for MET terms reconstructed from calorimeter signals alone.
@ ID
Indicator for MET terms reconstructed from inner detector (ID) tracks alone.
@ UnknownCategory
Indicator for an unknown category.
@ Refined
Indicator for genuine reconstructed MET terms.
static bool isTauTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static Types::bitmask_t idTrack(Region reg=Region::FullAcceptance)
Bit pattern indicating a ID Track MET term.
static Types::bitmask_t unknown()
static Types::bitmask_t truthInt(Region reg=Region::FullAcceptance)
Standard bit pattern indicating effective true MET.
static bool hasSignal(Types::bitmask_t bits, Signal sig)
static bool isSoftTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static Types::bitmask_t caloEMTopo(Region reg=Region::FullAcceptance)
Bit pattern indicating a EMTopo MET term.
static bool isElectronTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static bool hasType(Types::bitmask_t bits, Type type)
static Types::bitmask_t track(Region reg=Region::FullAcceptance)
Bit mask for MET term from Track signal objects.
TruthType
Truth type indicators.
@ Int
Indicator for MET from interacting particles within the nominal acceptance of the detector.
@ TruthMuons
Indicator for muons from MC truth (muons from the interaction)
@ NonInt
Indicator for MET from non-interacting particles generated in the collision.
@ UnknownTruth
Unknown truth type indicator.
@ IntOut
Indicator for MET contributions from particles outside of the acceptance of the detector (typically ...
static bool isTrackTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static bool hasTruthType(Types::bitmask_t bits, TruthType type)
static Types::bitmask_t tau(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed tau leptons.
static Types::bitmask_t electron(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed electrons.
static Types::bitmask_t cluster(Region reg=Region::FullAcceptance)
Bit mask for MET term from any cluster signal objects.
static Types::bitmask_t softEvent(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed soft event.
static bool isMuonTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static bool isTruthInt(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static bool isTruthMuons(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static Types::bitmask_t photon(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed photons.
@ Central
Indicator for MET contribution from the central region.
@ Forward
Indicator for MET contribution from the forward region.
@ FullAcceptance
Indicator for full detector acceptance contribution.
@ Endcap
Indicator for MET contribution from the endcap region.
@ UnknownRegion
Indicator for unknown region (same as full acceptance contribution)
static Types::bitmask_t truthNonInt()
Standard bit pattern indicating genuine true MET.
Signal
Signal contribution types.
@ LCTopo
Indicator for MET contribution from TopoClusters with LCW calibration applied.
@ Track
Indicator for MET contribution from reconstructed charged particle tracks.
@ EMTopo
Indicator for MET contribution from TopoClusters with EM (basic signal) calibration applied.
@ UnknownSignal
Unknown signal contribution.
static bool hasPattern(E bits, F mask)
Generic check for given pattern.
static Types::bitmask_t truthIntOut()
Standard bit pattern indicating a true MET contribution from particles outside of the detector accep...
static bool hasCategory(Types::bitmask_t bits, Category cat)
Check if bit pattern includes a given category.
static Types::bitmask_t truthMuons(Region reg=Region::FullAcceptance)
Standard bit pattern indicating the true muon contribution to MET truth.
static bool isTotalTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static bool isJetTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static bool isPhotonTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static Types::bitmask_t clusterLC(Region reg=Region::FullAcceptance)
Bit mask for MET term from LCTopo (locally calibrated calorimeter cell clusters) signal objects.
Type
Physics contribution types category.
@ Electron
Indicator for the MET term from reconstructed or MC truth electrons.
@ Jet
Indicator for the MET term from reconstructed or MC truth particle jets.
@ SoftEvent
Indicator for the MET term from reconstructed soft event signals (tracks, clusters) or MC truth parti...
@ UnknownType
Indicator for an unknown MET term source.
@ Total
Indicator for the total reconstructed MET (sum of MET terms from reconstruction and MC truth particle...
@ Photon
Indicator for the MET term from reconstructed or MC truth electrons.
static bool isTruthIntOut(Types::bitmask_t bits)
String constants, tags, and handling.
static const std::string & emptyString()
Access empty string indicator.
static const std::string & unknownString()
Access unknown string indicator.
static const std::string & invalidString()
Access invalid string indicator.
static const std::string & nullString()
Access NULL string indicator.