ATLAS Offline Software
LabelIndex.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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 
11 using jet::LabelIndex;
12 
13 using LIMap = std::map<std::string, LabelIndex *>;
16 
17 //**********************************************************************
18 
19 LabelIndex::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 
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 
57 Index 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 
66 LabelIndex::LabelIndex(const LabelIndex&) : m_name("") { }
67 
68 //**********************************************************************
69 
71  return *this;
72 }
73 
74 //**********************************************************************
75 
76 Index LabelIndex::size() const { return m_labs.size() ; }
jet::LabelIndex::constitScale
xAOD::JetConstitScale constitScale(Index idx) const
Fetch the constit scale corresponding to the index.
Definition: LabelIndex.cxx:49
Label
IndexedConstituentUserInfo::Label Label
Definition: IndexedConstituentUserInfo.cxx:11
jet::LabelIndex
Definition: LabelIndex.h:22
jet::LabelIndex::m_name
Label m_name
Definition: LabelIndex.h:61
LIMap
std::map< std::string, LabelIndex * > LIMap
Definition: LabelIndex.cxx:13
jet::LabelIndex::Label
std::string Label
Definition: LabelIndex.h:26
Index
LabelIndex::Index Index
Definition: LabelIndex.cxx:14
jet::LabelIndex::label
Label label(Index idx) const
Fetch the label for an index.
Definition: LabelIndex.cxx:41
jet::LabelIndex::LabelIndex
LabelIndex(Label nam)
Ctor.
Definition: LabelIndex.cxx:19
jet::LabelIndex::m_labs
std::vector< Label > m_labs
Definition: LabelIndex.h:62
Index
IndexedConstituentUserInfo::Index Index
Definition: IndexedConstituentUserInfo.cxx:12
Label
LabelIndex::Label Label
Definition: LabelIndex.cxx:15
jet::LabelIndex::addLabel
Index addLabel(const Label &lab)
Add a label and get its index.
Definition: LabelIndex.cxx:23
jet::LabelIndex::m_constitScales
std::vector< xAOD::JetConstitScale > m_constitScales
Definition: LabelIndex.h:63
jet::LabelIndex::index
Index index(const Label &lab) const
Fetch the index for a label.
Definition: LabelIndex.cxx:57
xAOD::CalibratedJetConstituent
@ CalibratedJetConstituent
Definition: JetTypes.h:22
jet::LabelIndex::Index
unsigned int Index
Definition: LabelIndex.h:27
xAOD::JetConstitScale
JetConstitScale
Definition: JetTypes.h:20
LabelIndex.h
xAOD::UncalibratedJetConstituent
@ UncalibratedJetConstituent
Definition: JetTypes.h:21
jet::LabelIndex::name
Label name() const
Return the name of this map.
Definition: LabelIndex.cxx:35
jet::LabelIndex::size
Index size() const
Number of label stored in this map. WARNING the index starts at 1, so range is [1....
Definition: LabelIndex.cxx:76
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
jet::LabelIndex::operator=
LabelIndex & operator=(const Label &nam)
Definition: LabelIndex.cxx:70