ATLAS Offline Software
Loading...
Searching...
No Matches
LabelIndex.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// LabelIndex.h
6
7#include "JetEDM/LabelIndex.h"
8#include <map>
9#include <utility>
10
11using jet::LabelIndex;
12
13using LIMap = std::map<std::string, LabelIndex *>;
16
17//**********************************************************************
18
19LabelIndex::LabelIndex(Label nam) : m_name(std::move(nam)) { }
20
21//**********************************************************************
22
24 Index idx = index(lab);
25 if ( idx ) return idx;
26 m_labs.push_back(lab);
28 if ( lab == "EMTopo" ) conscale = xAOD::UncalibratedJetConstituent;
29 m_constitScales.push_back(conscale);
30 return m_labs.size();
31}
32
33//**********************************************************************
34
35const Label& LabelIndex::name() const {
36 return m_name;
37}
38
39//**********************************************************************
40
42 if ( idx < 1 ) return "";
43 if ( idx-1 > m_labs.size() ) return "";
44 return m_labs[idx - 1];
45}
46
47//**********************************************************************
48
50 if ( idx < 1 ) return xAOD::CalibratedJetConstituent;
51 if ( idx-1 > m_constitScales.size() ) return xAOD::UncalibratedJetConstituent;
52 return m_constitScales[idx - 1];
53}
54
55//**********************************************************************
56
57Index LabelIndex::index(const Label& lab) const {
58 for ( Index jdx=0; jdx<m_labs.size(); ++jdx ) {
59 if ( m_labs[jdx] == lab ) return jdx + 1;
60 }
61 return 0;
62}
63
64//**********************************************************************
65
67
68//**********************************************************************
69
71 return *this;
72}
73
74//**********************************************************************
75
76Index LabelIndex::size() const { return m_labs.size() ; }
IndexedConstituentUserInfo::Index Index
IndexedConstituentUserInfo::Label Label
std::map< std::string, LabelIndex * > LIMap
std::string Label
Definition LabelIndex.h:26
unsigned int Index
Definition LabelIndex.h:27
LabelIndex(Label nam)
Ctor.
Index addLabel(const Label &lab)
Add a label and get its index.
std::vector< xAOD::JetConstitScale > m_constitScales
Definition LabelIndex.h:63
const Label & name() const
Return the name of this map.
Index size() const
Number of label stored in this map. WARNING the index starts at 1, so range is [1....
Index index(const Label &lab) const
Fetch the index for a label.
std::string Label
Definition LabelIndex.h:26
unsigned int Index
Definition LabelIndex.h:27
LabelIndex(Label nam)
Ctor.
Label label(Index idx) const
Fetch the label for an index.
LabelIndex & operator=(const Label &nam)
xAOD::JetConstitScale constitScale(Index idx) const
Fetch the constit scale corresponding to the index.
std::vector< Label > m_labs
Definition LabelIndex.h:62
Definition index.py:1
STL namespace.
JetConstitScale
Definition JetTypes.h:20
@ UncalibratedJetConstituent
Definition JetTypes.h:21
@ CalibratedJetConstituent
Definition JetTypes.h:22