File indexing completed on 2024-04-06 12:03:47
0001 #include <algorithm>
0002 #include <functional>
0003 using namespace std;
0004
0005 #include "FWCore/Utilities/interface/EDMException.h"
0006 #include "DataFormats/BTauReco/interface/TaggingVariable.h"
0007
0008 namespace reco {
0009
0010 const char* const TaggingVariableDescription[] = {
0011 "jet energy",
0012 "jet transverse momentum",
0013 "track-based jet transverse momentum",
0014 "jet pseudorapidity",
0015 "jet absolute pseudorapidity",
0016 "jet polar angle",
0017 "tracks associated to jet",
0018 "selected tracks in the jet",
0019 "number of tracks for which etaRel is computed",
0020
0021 "track momentum",
0022 "track pseudorapidity",
0023 "track polar angle",
0024
0025 "track charge",
0026
0027 "track transverse momentum, relative to the jet axis",
0028 "track parallel momentum, along the jet axis",
0029 "track pseudorapidity, relative to the jet axis",
0030 "track pseudoangular distance from the jet axis",
0031
0032 "track transverse momentum, relative to the jet axis, normalized to its energy",
0033
0034 "track parallel momentum, along the jet axis, normalized to its energy",
0035
0036 "track 2D signed impact parameter",
0037 "track 2D signed impact parameter significance",
0038 "track 3D signed impact parameter",
0039 "track 3D signed impact parameter significance",
0040 "track decay length",
0041 "track decay length significance",
0042 "minimum track approach distance to jet axis",
0043 "minimum track approach distance to jet axis signifiance",
0044 "minimum approach distance to ghost track",
0045 "minimum approach distance to ghost track significance",
0046 "weight of track participation in ghost track fit",
0047
0048 "ratio of track sum transverse energy over jet energy",
0049
0050 "pseudoangular distance between jet axis and track fourvector sum",
0051
0052 "category of secondary vertex (Reco, Pseudo, No)",
0053
0054 "category of secondary vertex & soft lepton (RecoNo, PseudoNo, NoNo, RecoMu, PseudoMu, NoMu, RecoEl, PseudoEl, "
0055 "NoEl)",
0056
0057 "number of reconstructed possible secondary vertices in jet",
0058 "number of single-track ghost-track vertices",
0059
0060 "mass of track sum at secondary vertex",
0061 "number of tracks at secondary vertex",
0062 "vertex fit probability",
0063
0064 "ratio of energy at secondary vertex over total energy",
0065
0066 "pseudoangular distance between jet axis and secondary vertex direction",
0067
0068
0069 "Longitudinal distance along the z-axis between primary and secondary vertex",
0070
0071 "Longitudinal distance significance along the z-axis between primary and secondary vertex",
0072 "transverse distance between primary and secondary vertex",
0073
0074 "transverse distance significance between primary and secondary vertex",
0075 "distance between primary and secondary vertex",
0076 "distance significance between primary and secondary vertex",
0077
0078
0079 "track 2D signed impact parameter of first track lifting mass above charm",
0080
0081 "track 2D signed impact parameter significance of first track lifting mass above charm",
0082
0083 "track 3D signed impact parameter of first track lifting mass above charm",
0084
0085 "track 3D signed impact parameter significance of first track lifting mass above charm",
0086
0087 "track momentum along the jet axis, in the jet rest frame",
0088
0089 "track momentum along the jet axis, in the jet rest frame, normalized to its energy"
0090 "chi2 of the track fit",
0091 "number of valid total hits",
0092 "number of valid pixel hits",
0093
0094 "lepton identification quality",
0095 "lepton identification quality 2",
0096
0097 "fraction of the jet energy coming from charged hadrons",
0098 "fraction of the jet energy coming from neutral hadrons",
0099 "fraction of the jet energy coming from photons",
0100 "fraction of the jet energy coming from electrons",
0101 "fraction of the jet energy coming from muons",
0102 "number of charged hadrons in the jet",
0103 "number of neutral hadrons in the jet",
0104 "number of photons in the jet",
0105 "number of electrons in the jet",
0106 "number of muons in the jet",
0107 "total number of charged and neutral hadrons in the jet",
0108
0109 "total number of photons, charged and neutral hadrons in the jet",
0110
0111 "total number of photons, electrons, muons, charged and neutral hadrons in the jet",
0112
0113
0114 "vertexmass times fraction of the vertex energy w.r.t. the jet energy",
0115
0116 "variable related to the boost of the vertex system in flight direction",
0117
0118 "2D signed impact parameter of the soft lepton",
0119 "3D signed impact parameter of the soft lepton",
0120 "transverse momentum of the soft lepton wrt. the jet axis",
0121
0122 "momentum of the soft lepton along the jet direction, in the jet rest frame",
0123 "pseudo)rapidity of the soft lepton along jet axis",
0124 "pseudo)angular distance of the soft lepton to jet axis",
0125 "momentum of the soft lepton over jet energy",
0126
0127 "momentum of the soft lepton parallel to jet axis over jet energy",
0128 "mva output of the electron ID",
0129
0130 "1st largest track 3D signed impact parameter significance",
0131 "2nd largest track 3D signed impact parameter significance",
0132 "3rd largest track 3D signed impact parameter significance",
0133 "4th largest track 3D signed impact parameter significance",
0134
0135 "1st largest track 3D signed impact parameter significance associated to the 1st N-subjettiness axis",
0136
0137 "2nd largest track 3D signed impact parameter significance associated to the 1st N-subjettiness axis",
0138
0139 "1st largest track 3D signed impact parameter significance associated to the 2nd N-subjettiness axis",
0140
0141 "2nd largest track 3D signed impact parameter significance associated to the 2nd N-subjettiness axis",
0142
0143 "track 2D signed impact parameter significance of 1st track lifting mass above bottom",
0144
0145 "track 2D signed impact parameter significance of 2nd track lifting mass above bottom",
0146
0147 "1st smallest track pseudorapidity, relative to the jet axis, associated to the 1st N-subjettiness axis",
0148
0149 "2nd smallest track pseudorapidity, relative to the jet axis, associated to the 1st N-subjettiness axis",
0150
0151 "3rd smallest track pseudorapidity, relative to the jet axis, associated to the 1st N-subjettiness axis",
0152
0153 "1st smallest track pseudorapidity, relative to the jet axis, associated to the 2nd N-subjettiness axis",
0154
0155 "2nd smallest track pseudorapidity, relative to the jet axis, associated to the 2nd N-subjettiness axis",
0156
0157 "3rd smallest track pseudorapidity, relative to the jet axis, associated to the 2nd N-subjettiness axis",
0158
0159 "mass of track sum at secondary vertex associated to the 1st N-subjettiness axis",
0160
0161 "ratio of energy at secondary vertex over total energy associated to the 1st N-subjettiness axis",
0162
0163 "transverse distance significance between primary and secondary vertex associated to the 1st N-subjettiness axis",
0164
0165 "pseudoangular distance between the 1st N-subjettiness axis and secondary vertex direction",
0166
0167 "mass of track sum at secondary vertex associated to the 2nd N-subjettiness axis",
0168
0169 "ratio of energy at secondary vertex over total energy associated to the 2nd N-subjettiness axis",
0170
0171 "transverse distance significance between primary and secondary vertex associated to the 2nd N-subjettiness axis",
0172
0173 "pseudoangular distance between the 2nd N-subjettiness axis and secondary vertex direction",
0174 "z ratio",
0175 "SoftMu Tagger discriminator",
0176 "SoftEl Tagger discriminator",
0177 "JBP Tagger discriminator",
0178 "JP Tagger discriminator",
0179
0180 "discriminator output of an algorithm",
0181
0182 ""};
0183
0184 const char* const TaggingVariableTokens[] = {
0185 "jetEnergy",
0186 "jetPt",
0187 "trackJetPt",
0188 "jetEta",
0189 "jetAbsEta",
0190 "jetPhi",
0191 "jetNTracks",
0192 "jetNSelectedTracks",
0193 "jetNTracksEtaRel",
0194
0195 "trackMomentum",
0196 "trackEta",
0197 "trackPhi",
0198
0199 "trackCharge",
0200
0201 "trackPtRel",
0202 "trackPPar",
0203 "trackEtaRel",
0204 "trackDeltaR",
0205 "trackPtRatio",
0206 "trackPParRatio",
0207
0208 "trackSip2dVal",
0209 "trackSip2dSig",
0210 "trackSip3dVal",
0211 "trackSip3dSig",
0212 "trackDecayLenVal",
0213 "trackDecayLenSig",
0214 "trackJetDist",
0215 "trackJetDistSig",
0216 "trackGhostTrackDistVal",
0217 "trackGhostTrackDistSig",
0218 "trackGhostTrackWeight",
0219
0220 "trackSumJetEtRatio",
0221 "trackSumJetDeltaR",
0222
0223 "vertexCategory",
0224 "vertexLeptonCategory",
0225
0226 "jetNSecondaryVertices",
0227 "jetNSingleTrackVertices",
0228
0229 "vertexMass",
0230 "vertexNTracks",
0231 "vertexFitProb",
0232
0233 "vertexEnergyRatio",
0234 "vertexJetDeltaR",
0235
0236 "flightDistance1dVal",
0237 "flightDistance1dSig",
0238 "flightDistance2dVal",
0239 "flightDistance2dSig",
0240 "flightDistance3dVal",
0241 "flightDistance3dSig",
0242
0243 "trackSip2dValAboveCharm",
0244 "trackSip2dSigAboveCharm",
0245 "trackSip3dValAboveCharm",
0246 "trackSip3dSigAboveCharm",
0247
0248 "leptonQuality",
0249 "leptonQuality2",
0250
0251 "trackP0Par",
0252 "trackP0ParRatio",
0253 "trackChi2",
0254 "trackNTotalHits",
0255 "trackNPixelHits",
0256
0257 "chargedHadronEnergyFraction",
0258 "neutralHadronEnergyFraction",
0259 "photonEnergyFraction",
0260 "electronEnergyFraction",
0261 "muonEnergyFraction",
0262 "chargedHadronMultiplicity",
0263 "neutralHadronMultiplicity",
0264 "photonMultiplicity",
0265 "electronMultiplicity",
0266 "muonMultiplicity",
0267 "hadronMultiplicity",
0268 "hadronPhotonMultiplicity",
0269 "totalMultiplicity",
0270
0271 "massVertexEnergyFraction",
0272 "vertexBoostOverSqrtJetPt",
0273
0274 "leptonSip2d",
0275 "leptonSip3d",
0276 "leptonPtRel",
0277 "leptonP0Par",
0278 "leptonEtaRel",
0279 "leptonDeltaR",
0280 "leptonRatio",
0281 "leptonRatioRel",
0282 "electronMVA",
0283
0284 "trackSip3dSig_0",
0285 "trackSip3dSig_1",
0286 "trackSip3dSig_2",
0287 "trackSip3dSig_3",
0288 "tau1_trackSip3dSig_0",
0289 "tau1_trackSip3dSig_1",
0290 "tau2_trackSip3dSig_0",
0291 "tau2_trackSip3dSig_1",
0292 "trackSip2dSigAboveBottom_0",
0293 "trackSip2dSigAboveBottom_1",
0294 "tau1_trackEtaRel_0",
0295 "tau1_trackEtaRel_1",
0296 "tau1_trackEtaRel_2",
0297 "tau2_trackEtaRel_0",
0298 "tau2_trackEtaRel_1",
0299 "tau2_trackEtaRel_2",
0300 "tau1_vertexMass",
0301 "tau1_vertexEnergyRatio",
0302 "tau1_flightDistance2dSig",
0303 "tau1_vertexDeltaR",
0304 "tau2_vertexMass",
0305 "tau2_vertexEnergyRatio",
0306 "tau2_flightDistance2dSig",
0307 "tau2_vertexDeltaR",
0308 "z_ratio",
0309 "Jet_SoftMu",
0310 "Jet_SoftEl",
0311 "Jet_JBP",
0312 "Jet_JP",
0313
0314 "algoDiscriminator",
0315
0316 "lastTaggingVariable"};
0317
0318 btau::TaggingVariableName getTaggingVariableName(const std::string& name) {
0319 for (int i = 0; i <= reco::btau::lastTaggingVariable; i++)
0320 if (name == TaggingVariableTokens[i])
0321 return (reco::btau::TaggingVariableName)(i);
0322 return btau::lastTaggingVariable;
0323 }
0324
0325
0326 bool TaggingVariableList::checkTag(TaggingVariableName tag) const {
0327 return binary_search(m_list.begin(), m_list.end(), tag, TaggingVariableCompare());
0328 }
0329
0330 void TaggingVariableList::insert(const TaggingVariable& variable, bool delayed ) {
0331 m_list.push_back(variable);
0332 if (not delayed)
0333 finalize();
0334 }
0335
0336 void TaggingVariableList::insert(TaggingVariableName tag, TaggingValue value, bool delayed ) {
0337 m_list.push_back(TaggingVariable(tag, value));
0338 if (not delayed)
0339 finalize();
0340 }
0341
0342 void TaggingVariableList::insert(TaggingVariableName tag,
0343 const std::vector<TaggingValue>& values,
0344 bool delayed ) {
0345 for (std::vector<TaggingValue>::const_iterator i = values.begin(); i != values.end(); i++) {
0346 m_list.push_back(TaggingVariable(tag, *i));
0347 }
0348 if (not delayed)
0349 finalize();
0350 }
0351
0352 void TaggingVariableList::insert(const TaggingVariableList& list) {
0353 std::vector<TaggingVariable>::size_type size = m_list.size();
0354 m_list.insert(m_list.end(), list.m_list.begin(), list.m_list.end());
0355 inplace_merge(m_list.begin(), m_list.begin() + size, m_list.end(), TaggingVariableCompare());
0356 }
0357
0358 void TaggingVariableList::finalize(void) { stable_sort(m_list.begin(), m_list.end(), TaggingVariableCompare()); }
0359
0360 TaggingValue TaggingVariableList::get(TaggingVariableName tag) const {
0361 range r = getRange(tag);
0362 if (r.first == r.second)
0363 throw edm::Exception(edm::errors::InvalidReference)
0364 << "TaggingVariable " << tag << " is not present in the collection";
0365 return r.first->second;
0366 }
0367
0368 TaggingValue TaggingVariableList::get(TaggingVariableName tag, TaggingValue defaultValue) const {
0369 range r = getRange(tag);
0370 if (r.first == r.second)
0371 return defaultValue;
0372 return r.first->second;
0373 }
0374
0375 std::vector<TaggingValue> TaggingVariableList::getList(TaggingVariableName tag, bool throwOnEmptyList) const {
0376 range r = getRange(tag);
0377 if (throwOnEmptyList && r.first == r.second)
0378 throw edm::Exception(edm::errors::InvalidReference)
0379 << "TaggingVariable " << tag << " is not present in the collection";
0380 std::vector<TaggingValue> list(r.second - r.first);
0381 transform(r.first, r.second, list.begin(), [](TaggingVariable const& x) { return x.second; });
0382 return list;
0383 }
0384
0385 TaggingVariableList::range TaggingVariableList::getRange(TaggingVariableName tag) const {
0386 return equal_range(m_list.begin(), m_list.end(), tag, TaggingVariableCompare());
0387 }
0388
0389 }