ATLAS Offline Software
ClusterSplitProbabilityContainer.h
Go to the documentation of this file.
1 /* Dear emacs, this is -*-c++-*- */
2 #ifndef _ClusterSplitProbabilityContainer_H_
3 #define _ClusterSplitProbabilityContainer_H_
4 
5 #include "Identifier/Identifier.h"
7 #include <unordered_map>
8 #include <algorithm>
9 #include <stdexcept>
10 
11 namespace Trk {
12  class ClusterSplitProbabilityContainerCnv_p1;
13 
17  {
19  public:
20  using ClusterIdentifier=unsigned int;
21 
22  struct ProbabilityInfo : public std::pair<float,float> {
23  ProbabilityInfo(float prob1, float prob2) : std::pair<float,float>(prob1,prob2) {}
24  float splitProbability1() const { return isTooBigToBeSplit() ? 0.f : this->first; }
25  float splitProbability2() const { return isTooBigToBeSplit() ? 0.f : this->second; }
26  bool isTooBigToBeSplit() const { return first<0; }
27  bool isSplit() const { return m_isSplit;}
28  void setSplit(bool split) { m_isSplit=split;}
29  void updateSplitProbabilities(float prob1, float prob2) { this->first=prob1; this->second=prob2; m_isSplit=false;}
30  private:
31  bool m_isSplit = false;
32  };
33  static const ProbabilityInfo &getNoSplitProbability() {return s_unset; }
34 
35  const ProbabilityInfo &splitProbability(const PrepRawData*cluster) const {
36  assert(cluster);
37  std::unordered_map<ClusterIdentifier, ProbabilityInfo>::const_iterator iter = m_splitProbMap.find(cluster->getHashAndIndex().hashAndIndex());
38  return (iter != m_splitProbMap.end()) ? iter->second : s_unset;
39  }
41  assert(cluster);
43  return (iter != m_splitProbMap.end()) ? &iter->second : nullptr;
44  }
45  ProbabilityInfo &setSplitInformation(const PrepRawData*cluster, float prob1, float prob2) {
46  assert(cluster);
47  // @TODO remove the precision clipping, which is currently implemented here to produce identical results wrt. the current version.
48  constexpr int splitmask = 0x7fff;
49  prob1 = int(prob1 * splitmask)/(1.*splitmask);
50  prob2 = int(prob2 * splitmask)/(1.*splitmask);
52  ret = m_splitProbMap.insert( std::make_pair( cluster->getHashAndIndex().hashAndIndex(), ProbabilityInfo(prob1, prob2) ) );
53  if (!ret.second) {
55  if (iter == m_splitProbMap.end()) {
56  throw std::runtime_error("Failed to set cluster splitting probability.");
57  }
58  iter->second.updateSplitProbabilities(prob1,prob2);
59  return iter->second;
60  }
61  else {
62  return ret.first->second;
63  }
64  }
65  void setTooBigToBeSplit(const PrepRawData*cluster) {
66  assert(cluster);
67  m_splitProbMap.insert( std::make_pair( cluster->getHashAndIndex().hashAndIndex(), ProbabilityInfo(-1.,-1.) ) );
68  }
69 
70  const std::unordered_map<ClusterIdentifier, ProbabilityInfo>&
71  splitProbMap() const
72  {
73  return m_splitProbMap;
74  }
75 
76  protected:
77  std::unordered_map<ClusterIdentifier, ProbabilityInfo> m_splitProbMap;
78  static const ProbabilityInfo s_unset;
79  };
80 }
81 #ifndef CLIDSVC_CLASSDEF_H
82 # include "AthenaKernel/CLASS_DEF.h"
84 #endif
85 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
Trk::ClusterSplitProbabilityContainer::ClusterIdentifier
unsigned int ClusterIdentifier
Definition: ClusterSplitProbabilityContainer.h:20
Trk::ClusterSplitProbabilityContainer::s_unset
static const ProbabilityInfo s_unset
Definition: ClusterSplitProbabilityContainer.h:78
Trk::ClusterSplitProbabilityContainer::ProbabilityInfo::isSplit
bool isSplit() const
Definition: ClusterSplitProbabilityContainer.h:27
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Trk::ClusterSplitProbabilityContainer::setSplitInformation
ProbabilityInfo & setSplitInformation(const PrepRawData *cluster, float prob1, float prob2)
Definition: ClusterSplitProbabilityContainer.h:45
Trk::ClusterSplitProbabilityContainer::ProbabilityInfo
Definition: ClusterSplitProbabilityContainer.h:22
Trk::ClusterSplitProbabilityContainerCnv_p1
Definition: ClusterSplitProbabilityContainerCnv_p1.h:16
PrepRawData.h
Trk::ClusterSplitProbabilityContainer::setTooBigToBeSplit
void setTooBigToBeSplit(const PrepRawData *cluster)
Definition: ClusterSplitProbabilityContainer.h:65
Trk::ClusterSplitProbabilityContainer::getSplitProbability
ProbabilityInfo * getSplitProbability(const PrepRawData *cluster)
Definition: ClusterSplitProbabilityContainer.h:40
Trk::ClusterSplitProbabilityContainer::ProbabilityInfo::updateSplitProbabilities
void updateSplitProbabilities(float prob1, float prob2)
Definition: ClusterSplitProbabilityContainer.h:29
Trk::ClusterSplitProbabilityContainer::ProbabilityInfo::setSplit
void setSplit(bool split)
Definition: ClusterSplitProbabilityContainer.h:28
Trk::ClusterSplitProbabilityContainer::m_splitProbMap
std::unordered_map< ClusterIdentifier, ProbabilityInfo > m_splitProbMap
Definition: ClusterSplitProbabilityContainer.h:77
Trk::PrepRawData
Definition: PrepRawData.h:62
IdentContIndex::hashAndIndex
unsigned int hashAndIndex() const
combined index
Definition: IdentContIndex.h:99
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::ClusterSplitProbabilityContainer::ProbabilityInfo::m_isSplit
bool m_isSplit
Definition: ClusterSplitProbabilityContainer.h:31
Trk::ClusterSplitProbabilityContainer
Container to associate Cluster with cluster splitting probabilities.
Definition: ClusterSplitProbabilityContainer.h:17
Trk::ClusterSplitProbabilityContainer::ProbabilityInfo::isTooBigToBeSplit
bool isTooBigToBeSplit() const
Definition: ClusterSplitProbabilityContainer.h:26
Trk::PrepRawData::getHashAndIndex
const IdentContIndex & getHashAndIndex() const
Trk::ClusterSplitProbabilityContainer::ProbabilityInfo::ProbabilityInfo
ProbabilityInfo(float prob1, float prob2)
Definition: ClusterSplitProbabilityContainer.h:23
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
DeMoScan.first
bool first
Definition: DeMoScan.py:536
Trk::ClusterSplitProbabilityContainer::splitProbMap
const std::unordered_map< ClusterIdentifier, ProbabilityInfo > & splitProbMap() const
Definition: ClusterSplitProbabilityContainer.h:71
Trk::ClusterSplitProbabilityContainer::ProbabilityInfo::splitProbability1
float splitProbability1() const
Definition: ClusterSplitProbabilityContainer.h:24
Trk::ClusterSplitProbabilityContainer::splitProbability
const ProbabilityInfo & splitProbability(const PrepRawData *cluster) const
Definition: ClusterSplitProbabilityContainer.h:35
Trk::ClusterSplitProbabilityContainer::getNoSplitProbability
static const ProbabilityInfo & getNoSplitProbability()
Definition: ClusterSplitProbabilityContainer.h:33
CLASS_DEF.h
macros to associate a CLID to a type
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
Trk::ClusterSplitProbabilityContainer::ProbabilityInfo::splitProbability2
float splitProbability2() const
Definition: ClusterSplitProbabilityContainer.h:25