Belle II Software  release-05-02-19
ParticleExtraInfoMap.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Christian Pulvermacher *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 #include <TObject.h>
13 #include <map>
14 #include <vector>
15 #include <string>
16 
17 namespace Belle2 {
31  class ParticleExtraInfoMap : public TObject {
32  public:
34  typedef std::map<std::string, unsigned int> IndexMap;
35 
36  ParticleExtraInfoMap(): TObject() { }
37 
39  const IndexMap& getMap(unsigned int mapID) const { return m_maps[mapID]; }
40 
42  unsigned int getIndex(unsigned int mapID, const std::string& name) const;
43 
48  unsigned int getMapForNewVar(const std::string& name);
49 
54  unsigned int getMapForNewVar(const std::string& name, unsigned int oldMapID, unsigned int insertIndex);
55 
57  unsigned int getNMaps() const { return m_maps.size(); }
58 
59  private:
61  static bool isCompatible(const IndexMap& oldMap, const IndexMap& map, unsigned int insertIndex);
62 
63  std::vector<IndexMap> m_maps;
66  };
68 }
Belle2::ParticleExtraInfoMap::IndexMap
std::map< std::string, unsigned int > IndexMap
string -> index map.
Definition: ParticleExtraInfoMap.h:42
Belle2::ParticleExtraInfoMap::ClassDef
ClassDef(ParticleExtraInfoMap, 1)
Internal class to store string -> index maps for user-defined variables in Particle.
Belle2::ParticleExtraInfoMap::getMapForNewVar
unsigned int getMapForNewVar(const std::string &name)
Return map ID to a map that has 'name' as first entry.
Definition: ParticleExtraInfoMap.cc:17
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ParticleExtraInfoMap::getMap
const IndexMap & getMap(unsigned int mapID) const
Return reference to map with given ID.
Definition: ParticleExtraInfoMap.h:47
Belle2::ParticleExtraInfoMap::m_maps
std::vector< IndexMap > m_maps
List of string -> index maps.
Definition: ParticleExtraInfoMap.h:71
Belle2::ParticleExtraInfoMap
Internal class to store string -> index maps for extra info stored in Particle.
Definition: ParticleExtraInfoMap.h:39
Belle2::ParticleExtraInfoMap::getNMaps
unsigned int getNMaps() const
How many maps do we use?
Definition: ParticleExtraInfoMap.h:65
Belle2::ParticleExtraInfoMap::getIndex
unsigned int getIndex(unsigned int mapID, const std::string &name) const
Find index for name in the given map, or return 0 if not found.
Definition: ParticleExtraInfoMap.cc:6
Belle2::ParticleExtraInfoMap::isCompatible
static bool isCompatible(const IndexMap &oldMap, const IndexMap &map, unsigned int insertIndex)
check if all entries in 'oldMap' prior to insertIndex are found in 'map' (with same idx).
Definition: ParticleExtraInfoMap.cc:77