Belle II Software  release-05-02-19
ObserverCheckFilters.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Lueck *
7  * *
8  * this is a modified copy of *
9  * tracking/trackFindingVXD/filterTools/include/ObserverCheckMCPurity.h *
10  * *
11  * *
12  * This software is provided "as is" without any warranty. *
13  **************************************************************************/
14 
15 #pragma once
16 
17 //#include <framework/logging/Logger.h>
18 #include <framework/datastore/StoreArray.h>
19 
20 // contains also the helper struct SpacePointInfo
21 #include <tracking/dataobjects/ObserverInfo.h>
22 
23 #include <tracking/spacePointCreation/SpacePoint.h>
24 
25 // #include <memory> // unique_ptr
26 
27 
28 namespace Belle2 {
37  class ObserverCheckFilters {
38  public:
39 
42  static ObserverInfo s_observerInfo;
43 
45  static StoreArray<ObserverInfo> s_storeArray;
46 
49 
50 
51 
53  static bool initialize(const StoreArray<ObserverInfo>& aStoreArray)
54  {
56  return true;
57  }
58 
60  template <class Var, class Range, typename ... types >
61  static bool initialize(Var , Range, const types& ...)
62  {
63  return true;
64  }
65 
66 
68  static SpacePointInfo convertSpacePoint(const SpacePoint& aSpacePoint)
69  {
70  SpacePointInfo spInfo;
71  spInfo.setPosition(aSpacePoint.getPosition());
72  spInfo.setPositionError(aSpacePoint.getPositionError());
74  spInfo.setNormalizedLocalV(aSpacePoint.getNormalizedLocalV());
75  spInfo.setClustersAssignedU(aSpacePoint.getIfClustersAssigned().first);
76  spInfo.setClustersAssignedV(aSpacePoint.getIfClustersAssigned().second);
77  spInfo.setVxdID(aSpacePoint.getVxdID());
78  spInfo.setSensorType((int)aSpacePoint.getType());
79  spInfo.setQualityIndicator(aSpacePoint.getQualityEstimation());
80  spInfo.setIsAssigned(aSpacePoint.getAssignmentState());
81  return spInfo;
82  }
83 
84 
87  static void prepare(const SpacePoint& outerHit,
88  const SpacePoint& innerHit)
89  {
90  // discard all previous data
92  std::vector<SpacePointInfo> hitsinfo = { ObserverCheckFilters::convertSpacePoint(outerHit),
94  };
95  s_observerInfo.setHits(hitsinfo);
96 
97 
98  // collect purity for each particle attached to the hits
99  // TODO: this is code used in the ObserverCheckMCPurity check if the following code
100  /*
101  std::vector<const Belle2::SpacePoint*> hits = {&outerHit, &innerHit};
102  std::vector<Belle2::MCVXDPurityInfo> particlesFound;
103  // TODO: check if it can cope with real data (no MC particles)!
104  particlesFound = createPurityInfosVec(hits);
105  // the dominating-particle is the uppermost one:
106  auto purityPack = particlesFound.at(0).getPurity(); //that part does not look safe to be used on data!
107  s_mainMCParticleID = purityPack.first;
108  s_mainPurity = purityPack.second;
109  */
110  }
111 
114  template < typename ... types >
115  static void terminate(const types& ...)
116  {
117  }
118 
119 
121  template < typename ... types >
122  static void collect(const types& ...)
123  {
124  // append a copy to the storearray
125  s_storeArray.appendNew(s_observerInfo);
126  }
127 
128 
130  template<class Var, class RangeType>
131  static void notify(const Var&,
132  typename Var::variableType fResult,
133  const RangeType& range,
134  const typename Var::argumentType&,
135  const typename Var::argumentType&,
136  const typename Var::argumentType&)
137  {
138  // create input-container for purity-check:
139  // std::vector<const Belle2::SpacePoint*> spacePoints = {&outerHit, &centerHit, &innerHit};
140 
141  generalNotify<Var, RangeType>(fResult, range);
142  }
143 
144 
146  template<class Var, class RangeType>
147  static void notify(const Var&,
148  typename Var::variableType fResult,
149  const RangeType& range,
150  const typename Var::argumentType&,
151  const typename Var::argumentType&)
152  {
153  // // create input-container for purity-check:
154  // std::vector<const Belle2::SpacePoint*> spacePoints = {&outerHit, &innerHit};
155 
156  generalNotify<Var, RangeType>(fResult, range);
157  }
158 
159 
160 
161 
162 
163 
164  protected:
165 
169  template<class Var, class RangeType>
170  static void generalNotify(typename Var::variableType fResult,
171  const RangeType& range)
172  {
173  // store the data retrieved:
174  FilterInfo info(Var().name() , double(fResult), range.contains(fResult), true);
176  }
177  };
178 
179 
181 }
182 
183 
Belle2::SpacePointInfo::setVxdID
void setVxdID(Belle2::VxdID::baseType anId)
setter for the VxdID:
Definition: SpacePointInfo.h:118
Belle2::ObserverCheckFilters::s_observerInfo
static ObserverInfo s_observerInfo
container that stores the results calculated for a selectionVariableName, has to be static due to the...
Definition: ObserverCheckFilters.h:54
Belle2::ObserverCheckFilters::s_storeArray
static StoreArray< ObserverInfo > s_storeArray
hold a storearray to have access to the datastore
Definition: ObserverCheckFilters.h:57
Belle2::SpacePointInfo::setIsAssigned
void setIsAssigned(bool ia)
setter for is assigned
Definition: SpacePointInfo.h:142
Belle2::ObserverInfo::addFilterInfo
void addFilterInfo(FilterInfo info)
add a new filter info:
Definition: ObserverInfo.h:96
Belle2::ObserverCheckFilters::collect
static void collect(const types &...)
fill the storearray
Definition: ObserverCheckFilters.h:134
Belle2::ObserverInfo::setHits
void setHits(std::vector< SpacePointInfo > &newHits)
sets the hits the filter has been evaluated with
Definition: ObserverInfo.h:113
Belle2::SpacePoint::getIfClustersAssigned
std::pair< bool, bool > getIfClustersAssigned() const
Returns, if u(v)-coordinate is based on cluster information.
Definition: SpacePoint.h:172
Belle2::FilterInfo
helper class to store the information for a Filter
Definition: FilterInfo.h:30
Belle2::SpacePointInfo::setClustersAssignedU
void setClustersAssignedU(bool b)
setter for is u cluster assigned
Definition: SpacePointInfo.h:102
Belle2::SpacePointInfo::setClustersAssignedV
void setClustersAssignedV(bool b)
setter for is v cluster assigned
Definition: SpacePointInfo.h:110
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::SpacePoint::getPosition
const B2Vector3< double > & getPosition() const
return the position vector in global coordinates
Definition: SpacePoint.h:148
Belle2::ObserverCheckFilters::notify
static void notify(const Var &, typename Var::variableType fResult, const RangeType &range, const typename Var::argumentType &, const typename Var::argumentType &, const typename Var::argumentType &)
notifier which finds the mcParticles attached to given triplet of spacePoints and determines the puri...
Definition: ObserverCheckFilters.h:143
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SpacePoint::getQualityEstimation
float getQualityEstimation() const
Getter for the quality of this SpacePoint.
Definition: SpacePoint.h:201
Belle2::Range
Represents a range of arithmetic types.
Definition: Range.h:39
Belle2::SpacePoint::getAssignmentState
bool getAssignmentState() const
Getter for status of assignment to a track.
Definition: SpacePoint.h:195
Belle2::SpacePointInfo::setPositionError
void setPositionError(TVector3 v)
setter for the uncertainty on the position
Definition: SpacePointInfo.h:69
Belle2::SpacePointInfo::setQualityIndicator
void setQualityIndicator(double qi)
setter for the quality indicator
Definition: SpacePointInfo.h:134
Belle2::SpacePoint::getNormalizedLocalV
double getNormalizedLocalV() const
Return normalized local coordinates of the cluster in v (0 <= posV <= 1).
Definition: SpacePoint.h:164
Belle2::ObserverCheckFilters::prepare
static void prepare(const SpacePoint &outerHit, const SpacePoint &innerHit)
static method used by the observed object to reset the stored values of the observer.
Definition: ObserverCheckFilters.h:99
Belle2::SpacePointInfo::setNormalizedLocalU
void setNormalizedLocalU(double val)
setter for the normalized u coordinate
Definition: SpacePointInfo.h:83
Belle2::ObserverCheckFilters::generalNotify
static void generalNotify(typename Var::variableType fResult, const RangeType &range)
unified part of the notifier function.
Definition: ObserverCheckFilters.h:182
Belle2::SpacePointInfo::setSensorType
void setSensorType(int type)
setter for sensor type:
Definition: SpacePointInfo.h:126
Belle2::ObserverInfo::clear
void clear()
resets all member variables
Definition: ObserverInfo.h:42
Belle2::ObserverCheckFilters::convertSpacePoint
static SpacePointInfo convertSpacePoint(const SpacePoint &aSpacePoint)
convert a SpacePiont into a version that can be stored in the datastore
Definition: ObserverCheckFilters.h:80
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::SpacePointInfo::setNormalizedLocalV
void setNormalizedLocalV(double val)
setter for the normalized v coordinate
Definition: SpacePointInfo.h:91
Belle2::ObserverCheckFilters::initialize
static bool initialize(const StoreArray< ObserverInfo > &aStoreArray)
get a copy of a storearray
Definition: ObserverCheckFilters.h:65
Belle2::SpacePointInfo
helper class to store the SpacePoint information as coding convention prohibits to use the SpacePoint...
Definition: SpacePointInfo.h:32
Belle2::ObserverCheckFilters::terminate
static void terminate(const types &...)
static method used by the observed object to terminate the observer.
Definition: ObserverCheckFilters.h:127
Belle2::SpacePointInfo::setPosition
void setPosition(TVector3 v)
setter for the position.
Definition: SpacePointInfo.h:55
Belle2::SpacePoint::getType
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the SpacePoint lives.
Definition: SpacePoint.h:155
Belle2::ObserverCheckFilters::ObserverCheckFilters
ObserverCheckFilters()
empty constructor:
Definition: ObserverCheckFilters.h:60
Belle2::SpacePoint::getPositionError
const B2Vector3< double > & getPositionError() const
return the hitErrors in sigma of the global position
Definition: SpacePoint.h:151
Belle2::SpacePoint::getVxdID
VxdID getVxdID() const
Return the VxdID of the sensor on which the the cluster of the SpacePoint lives.
Definition: SpacePoint.h:158
Belle2::SpacePoint::getNormalizedLocalU
double getNormalizedLocalU() const
Return normalized local coordinates of the cluster in u (0 <= posU <= 1).
Definition: SpacePoint.h:161