00001
00002 #ifndef XAODMISSINGET_VERSIONS_MISSINGETBASE_H
00003 #define XAODMISSINGET_VERSIONS_MISSINGETBASE_H
00004
00005
00006 #define EXTRACT_PX( _T_, _V_, _P_ ) \
00007 _T_ _V_(_P_.p4().Px())
00008
00009 #define EXTRACT_PY( _T_, _V_, _P_ ) \
00010 _T_ _V_(_P_.p4().Py())
00011
00012 #define EXTRACT_SCALED_PX( _T_, _V_, _P_, _S_ ) \
00013 _T_ _V_(_P_.p4().Px()*_S_)
00014
00015 #define EXTRACT_SCALED_PY( _T_, _V_, _P_, _S_ ) \
00016 _T_ _V_(_P_.p4().Py()*_S_)
00017
00018 #include <cstddef>
00019 #include <cmath>
00020 #include <vector>
00021 #include <string>
00022
00023 #include <boost/tuple/tuple.hpp>
00024
00026 namespace MissingETBase
00027 {
00029 namespace Types
00030 {
00031 typedef unsigned long long bitmask_t;
00032 typedef std::vector<bitmask_t> bitmask_vector_t;
00033 typedef boost::tuples::tuple<size_t,size_t> indexedlink_t;
00034 }
00035
00036 namespace Constants
00037 {
00040 static
00041 #if __cplusplus < 201100
00042 const
00043 #else
00044 constexpr
00045 #endif // C++11
00046 double precision = 0.00001;
00048 static
00049 #if __cplusplus < 201100
00050 const
00051 #else
00052 constexpr
00053 #endif // C++11
00054 size_t invalidIndex = size_t(-1);
00055 static
00056 #if __cplusplus < 201100
00057 const
00058 #else
00059 constexpr
00060 #endif // C++11
00061 size_t unknownIndex = size_t(-1);
00063 static
00064 #if __cplusplus < 201100
00065 const
00066 #else
00067 constexpr
00068 #endif // C++11
00069 double wpxDefault = 1.0;
00070 static
00071 #if __cplusplus < 201100
00072 const
00073 #else
00074 constexpr
00075 #endif // C++11
00076 double wpyDefault = 1.0;
00077 static
00078 #if __cplusplus < 201100
00079 const
00080 #else
00081 constexpr
00082 #endif // C++11
00083 double wetDefault = 1.0;
00084 static
00085 #if __cplusplus < 201100
00086 const
00087 #else
00088 constexpr
00089 #endif // C++11
00090 double wpxError = 0.0;
00091 static
00092 #if __cplusplus < 201100
00093 const
00094 #else
00095 constexpr
00096 #endif // C++11
00097 double wpyError = 0.0;
00098 static
00099 #if __cplusplus < 201100
00100 const
00101 #else
00102 constexpr
00103 #endif // C++11
00104 double wetError = 0.0;
00106 static
00107 #if __cplusplus < 201100
00108 const
00109 #else
00110 constexpr
00111 #endif // C++11
00112 double cpxDefault = 0.0;
00113 static
00114 #if __cplusplus < 201100
00115 const
00116 #else
00117 constexpr
00118 #endif // C++11
00119 double cpyDefault = 0.0;
00120 static
00121 #if __cplusplus < 201100
00122 const
00123 #else
00124 constexpr
00125 #endif // C++11
00126 double cpzDefault = 0.0;
00127 static
00128 #if __cplusplus < 201100
00129 const
00130 #else
00131 constexpr
00132 #endif // C++11
00133 double ceDefault = 0.0;
00134 static
00135 #if __cplusplus < 201100
00136 const
00137 #else
00138 constexpr
00139 #endif // C++11
00140 double sumptDefault = 0.0;
00141 static
00142 #if __cplusplus < 201100
00143 const
00144 #else
00145 constexpr
00146 #endif // C++11
00147 double cpxError = -9999999;
00148 static
00149 #if __cplusplus < 201100
00150 const
00151 #else
00152 constexpr
00153 #endif // C++11
00154 double cpyError = -9999999;
00155 static
00156 #if __cplusplus < 201100
00157 const
00158 #else
00159 constexpr
00160 #endif // C++11
00161 double cpzError = -9999999;
00162 static
00163 #if __cplusplus < 201100
00164 const
00165 #else
00166 constexpr
00167 #endif // C++11
00168 double ceError = -9999999;
00169 static
00170 #if __cplusplus < 201100
00171 const
00172 #else
00173 constexpr
00174 #endif // C++11
00175 double sumptError = -9999999;
00180 static const std::string invalidString = "INVALID";
00181 static const std::string unknownString = "UNKNOWN";
00182 static const std::string emptyString = "EMPTY";
00183 static const std::string nullString = "NULL";
00185 }
00186
00188 struct Numerical
00189 {
00192 static double precision() { return Constants::precision; }
00193 static double wpxDefault() { return Constants::wpxDefault; }
00194 static double wpyDefault() { return Constants::wpyDefault; }
00195 static double wetDefault() { return Constants::wetDefault; }
00196 static double wpxError() { return Constants::wpxError; }
00197 static double wpyError() { return Constants::wpyError; }
00198 static double wetError() { return Constants::wetError; }
00199 static double cpxDefault() { return Constants::cpxDefault; }
00200 static double cpyDefault() { return Constants::cpyDefault; }
00201 static double cpzDefault() { return Constants::cpzDefault; }
00202 static double ceDefault() { return Constants::ceDefault; }
00203 static double sumptDefault() { return Constants::sumptDefault; }
00204 static double cpxError() { return Constants::cpxError; }
00205 static double cpyError() { return Constants::cpyError; }
00206 static double cpzError() { return Constants::cpzError; }
00207 static double ceError() { return Constants::ceError; }
00208 static double sumptError() { return Constants::sumptError; }
00209 static size_t invalidIndex() { return Constants::invalidIndex; }
00210 static size_t unknownIndex() { return Constants::unknownIndex; }
00211 static Types::indexedlink_t invalidLink() { return Types::indexedlink_t(Constants::invalidIndex,Constants::invalidIndex); }
00225 static bool isEqual(double x,double y) { return std::abs(x-y) < precision(); }
00231 static double divide(double x,double y) { return y != 0. ? x/y : 0.; }
00233 };
00234
00236 struct Strings
00237 {
00240 static const std::string& invalidString() { return Constants::invalidString; }
00241 static const std::string& unknownString() { return Constants::unknownString; }
00242 static const std::string& emptyString() { return Constants::emptyString; }
00243 static const std::string& nullString() { return Constants::nullString; }
00244 };
00245
00266 struct Source
00267 {
00271 enum Category { Refined = 0x10000,
00272 Truth = 0x20000,
00273 Calo = 0x40000,
00274 ID = 0x80000,
00275 UnknownCategory = 0x00000 };
00277 enum Type { Electron = 0x00001,
00278 Photon = 0x00002,
00279 Tau = 0x00004,
00280 Muon = 0x00008,
00281 Jet = 0x00010,
00282 SoftEvent = 0x00020,
00284 Total = 0x00040,
00285 UnknownType = 0x00000 };
00291 enum Region { Central = 0x00100,
00292 Endcap = 0x00200,
00293 Forward = 0x00400,
00294 FullAcceptance = 0x00000,
00295 UnknownRegion = 0x00000 };
00300 enum TruthType { NonInt = 0x21000,
00301 Int = 0x22000,
00302 IntOut = 0x24000,
00304 TruthMuons = 0x28000,
00305 UnknownTruth = 0x00000 };
00307 enum Signal { LCTopo = 0x01000,
00308 EMTopo = 0x02000,
00309 Track = 0x04000,
00310 UnknownSignal = 0x00000 };
00311
00320 static Types::bitmask_t electron(Region reg=FullAcceptance) { return ( Refined | Electron ) | reg; }
00327 static Types::bitmask_t photon(Region reg=FullAcceptance) { return ( Refined | Photon ) | reg; }
00334 static Types::bitmask_t tau(Region reg=FullAcceptance) { return ( Refined | Tau ) | reg; }
00341 static Types::bitmask_t muon(Region reg=FullAcceptance) { return ( Refined | Muon ) | reg; }
00348 static Types::bitmask_t jet(Region reg=FullAcceptance) { return ( Refined | Jet ) | reg; }
00355 static Types::bitmask_t softEvent(Region reg=FullAcceptance) { return ( Refined | SoftEvent ) | reg; }
00362 static Types::bitmask_t total(Region reg=FullAcceptance) { return ( Refined | Total ) | reg; }
00373 static Types::bitmask_t signal(Types::bitmask_t sig=(LCTopo|Track),Region reg=FullAcceptance) { return ( Refined | sig ) | reg; }
00382 static Types::bitmask_t track(Region reg=FullAcceptance) { return signal(Track,reg); }
00389 static Types::bitmask_t clusterLC(Region reg=FullAcceptance) { return signal(LCTopo,reg); }
00396 static Types::bitmask_t clusterEM(Region reg=FullAcceptance) { return signal(EMTopo,reg); }
00403 static Types::bitmask_t cluster(Region reg=FullAcceptance) { return signal(LCTopo|EMTopo,reg); }
00412 static Types::bitmask_t truthNonInt() { return NonInt; }
00419 static Types::bitmask_t truthInt(Region reg=FullAcceptance) { return Int | reg; }
00425 static Types::bitmask_t truthIntOut() { return IntOut; }
00432 static Types::bitmask_t truthMuons(Region reg=FullAcceptance) { return TruthMuons | reg; }
00443 static Types::bitmask_t caloLCTopo(Region reg=FullAcceptance) { return ( Calo | LCTopo ) | reg; }
00450 static Types::bitmask_t caloEMTopo(Region reg=FullAcceptance) { return ( Calo | EMTopo ) | reg; }
00457 static Types::bitmask_t idTrack(Region reg=FullAcceptance) { return ( ID | Track ) | reg; }
00472 static bool hasPattern(Types::bitmask_t bits,Types::bitmask_t mask) { return ( bits & mask) == mask; }
00480 static bool hasCategory(Types::bitmask_t bits,Category cat) { return hasPattern(bits,cat); }
00481 static bool hasType(Types::bitmask_t bits,Type type) { return hasPattern(bits,type); }
00482 static bool hasTruthType(Types::bitmask_t bits,TruthType type) { return hasPattern(bits,type); }
00483 static bool hasSignal(Types::bitmask_t bits,Signal sig) { return hasPattern(bits,sig);}
00486 static bool isElectronTerm(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,electron(reg)); }
00487 static bool isPhotonTerm(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,photon(reg)); }
00488 static bool isTauTerm(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,tau(reg)); }
00489 static bool isMuonTerm(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,muon(reg)); }
00490 static bool isJetTerm(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,jet(reg)); }
00491 static bool isSoftTerm(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,softEvent(reg)); }
00492 static bool isTrackTerm(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,track(reg)); }
00493 static bool isTotalTerm(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,total(reg)); }
00494
00495 static bool isTruthNonInt(Types::bitmask_t bits) { return hasPattern(bits,truthNonInt()); }
00496 static bool isTruthInt(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,truthInt(reg)); }
00497 static bool isTruthIntOut(Types::bitmask_t bits) { return hasPattern(bits,truthIntOut()); }
00498 static bool isTruthMuons(Types::bitmask_t bits,Region reg=FullAcceptance) { return hasPattern(bits,truthMuons(reg)); }
00499
00500 static bool unknown() { return UnknownCategory; }
00501 };
00502
00503 }
00504
00505
00506
00507
00508
00510 bool operator==(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1);
00511 bool operator!=(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1);
00512 bool operator>=(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1);
00513 bool operator<=(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1);
00514 bool operator>(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1);
00515 bool operator<(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1);
00518 inline bool operator==(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1)
00519 { return l0.get<0>() == l1.get<0>() && l0.get<1>() == l1.get<1>(); }
00520
00521 inline bool operator!=(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1)
00522 { return !operator==(l0,l1); }
00523
00524 inline bool operator>=(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1)
00525 { return l0.get<0>() == l1.get<0>() ? l0.get<1>() >= l1.get<1>() : l0.get<0>() > l1.get<0>(); }
00526
00527 inline bool operator<=(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1)
00528 { return l0.get<0>() == l1.get<0>() ? l0.get<1>() <= l1.get<1>() : l0.get<0>() < l1.get<0>(); }
00529
00530 inline bool operator>(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1)
00531 { return l0.get<0>() == l1.get<0>() ? l0.get<1>() > l1.get<1>() : l0.get<0>() > l1.get<0>(); }
00532
00533 inline bool operator<(MissingETBase::Types::indexedlink_t l0,MissingETBase::Types::indexedlink_t l1)
00534 { return l0.get<0>() == l1.get<0>() ? l0.get<1>() < l1.get<1>() : l0.get<0>() < l1.get<0>(); }
00535
00536 #endif