Belle II Software development
ObserverCheckMCPurity Class Reference

this observer searches for mcParticles attached to the hits given and stores the information found to be retrieved later. More...

#include <ObserverCheckMCPurity.h>

Public Member Functions

 ObserverCheckMCPurity ()
 empty constructor:
 

Static Public Member Functions

template<class Var , class RangeType >
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 purities for them.
 
template<class Var , class RangeType >
static void notify (const Var &, typename Var::variableType fResult, const RangeType &range, const typename Var::argumentType &, const typename Var::argumentType &)
 notifier which finds the mcParticles attached to given pair of spacePoints and determines the purities for them.
 
template<class Var , class Range , typename ... types>
static bool initialize (Var var, Range, const types &...)
 static method used by the observed object to initialize the observer.
 
static bool initialize (TTree *attree)
 version for 2-hit-combinations.
 
static void prepare (const SpacePoint &outerHit, const SpacePoint &innerHit)
 static method used by the observed object to reset the stored values of the observer.
 
template<typename ... types>
static void terminate (const types &...)
 static method used by the observed object to terminate the observer.
 
template<typename ... types>
static void collect (const types &...)
 fill the tree.
 

Static Public Attributes

static std::map< std::string, double * > s_results
 stores the results calculated (->value) for a selectionVariableName (->Key).
 
static std::map< std::string, bool * > s_wasAccepted
 stores if hits were accepted (->value) for a selectionVariableName (->Key).
 
static std::map< std::string, bool * > s_wasUsed
 stores if the filter was actually used this time (->value) for a selectionVariableName (->Key).
 
static TTree * s_ttree = nullptr
 a ttree to store all the collected data.
 
static SpacePoint s_outerHitOfTwo
 stores the outer hit of a two-hit-combination.
 
static SpacePoint s_innerHitOfTwo
 stores the inner hit of a two-hit-combination.
 
static SpacePoint s_outerHitOfThree
 stores the outer hit of a three-hit-combination.
 
static SpacePoint s_centerHitOfThree
 stores the center hit of a three-hit-combination.
 
static SpacePoint s_innerHitOfThree
 stores the inner hit of a three-hit-combination.
 
static int s_mainMCParticleID = 0
 dominating mcParticleID.
 
static double s_mainPurity = -1.
 purity for the dominating particleID.
 

Static Protected Member Functions

template<class Var , class RangeType >
static void generalNotify (typename Var::variableType fResult, const RangeType &range)
 unified part of the notifier function.
 

Detailed Description

this observer searches for mcParticles attached to the hits given and stores the information found to be retrieved later.

Definition at line 30 of file ObserverCheckMCPurity.h.

Constructor & Destructor Documentation

◆ ObserverCheckMCPurity()

empty constructor:

Definition at line 104 of file ObserverCheckMCPurity.h.

104{};

Member Function Documentation

◆ collect()

static void collect ( const types &  ...)
inlinestatic

fill the tree.

Definition at line 198 of file ObserverCheckMCPurity.h.

199 {
200 // TODO:
201// // // // collect purity for each particle attached to the hits
202// // // std::vector<Belle2::MCVXDPurityInfo> particlesFound;
203// // // particlesFound = createPurityInfosVec(hits);
204
205 s_ttree->Fill();
206 }
static TTree * s_ttree
a ttree to store all the collected data.

◆ generalNotify()

static void generalNotify ( typename Var::variableType  fResult,
const RangeType &  range 
)
inlinestaticprotected

unified part of the notifier function.

Stores filter-specific things.

Definition at line 215 of file ObserverCheckMCPurity.h.

217 {
218 // store the data retrieved:
219 auto varName = Var().name();
220 *(s_results.at(varName)) = double(fResult);
221 *(s_wasUsed.at(varName)) = true;
222 *(s_wasAccepted.at(varName)) = range.contains(fResult);
223 }
static std::map< std::string, bool * > s_wasAccepted
stores if hits were accepted (->value) for a selectionVariableName (->Key).
static std::map< std::string, double * > s_results
stores the results calculated (->value) for a selectionVariableName (->Key).
static std::map< std::string, bool * > s_wasUsed
stores if the filter was actually used this time (->value) for a selectionVariableName (->Key).

◆ initialize() [1/2]

static bool initialize ( TTree *  attree)
inlinestatic

version for 2-hit-combinations.

Definition at line 134 of file ObserverCheckMCPurity.h.

135 {
136 s_ttree = attree;
137
138 if (s_ttree != nullptr) {
139 // added some protection for creating branches twice, as the observer is initialized recursively
140 if (!s_ttree->GetBranch("outerHit")) s_ttree->Branch("outerHit", &s_outerHitOfTwo);
141 if (!s_ttree->GetBranch("innerHit")) s_ttree->Branch("innerHit", &s_innerHitOfTwo);
142
143 if (!s_ttree->GetBranch("mcParticleID")) s_ttree->Branch("mcParticleID", &s_mainMCParticleID);
144 if (!s_ttree->GetBranch("mcPurity")) s_ttree->Branch("mcPurity", &s_mainPurity);
145 } else {
146 return false;
147 }
148
149 return true;
150 }
static SpacePoint s_innerHitOfTwo
stores the inner hit of a two-hit-combination.
static int s_mainMCParticleID
dominating mcParticleID.
static double s_mainPurity
purity for the dominating particleID.
static SpacePoint s_outerHitOfTwo
stores the outer hit of a two-hit-combination.

◆ initialize() [2/2]

static bool initialize ( Var  var,
Range  ,
const types &  ... 
)
inlinestatic

static method used by the observed object to initialize the observer.

will be called once per Filter containing a single SelectionVariable and its range.

Definition at line 113 of file ObserverCheckMCPurity.h.

114 {
115 auto varName = var.name();
116
117 auto newResult = new double;
118 s_results.insert(std::make_pair(varName, newResult));
119 if (s_ttree != nullptr) s_ttree->Branch((varName + std::string("_val")).c_str(), newResult, TBranchLeafType(newResult));
120
121 auto newAccepted = new bool(false);
122 s_wasAccepted.insert(std::make_pair(varName, newAccepted));
123 if (s_ttree != nullptr) s_ttree->Branch((varName + std::string("_accepted")).c_str(), newAccepted, TBranchLeafType(newAccepted));
124
125 auto newWasUsed = new bool;
126 s_wasUsed.insert(std::make_pair(varName, newWasUsed));
127 if (s_ttree != nullptr) s_ttree->Branch((varName + std::string("_used")).c_str(), newWasUsed, TBranchLeafType(newWasUsed));
128
129 return true;
130 }
char TBranchLeafType(const char *)
Overloading TBranchLeafType to be able to get identifier 'C' for type char*.

◆ notify() [1/2]

static void notify ( const Var &  ,
typename Var::variableType  fResult,
const RangeType &  range,
const typename Var::argumentType &  ,
const typename Var::argumentType &   
)
inlinestatic

notifier which finds the mcParticles attached to given pair of spacePoints and determines the purities for them.

Definition at line 90 of file ObserverCheckMCPurity.h.

95 {
96// // create input-container for purity-check:
97// std::vector<const Belle2::SpacePoint*> spacePoints = {&outerHit, &innerHit};
98
99 generalNotify<Var, RangeType>(fResult, range);
100 }

◆ notify() [2/2]

static void notify ( const Var &  ,
typename Var::variableType  fResult,
const RangeType &  range,
const typename Var::argumentType &  ,
const typename Var::argumentType &  ,
const typename Var::argumentType &   
)
inlinestatic

notifier which finds the mcParticles attached to given triplet of spacePoints and determines the purities for them.

Definition at line 74 of file ObserverCheckMCPurity.h.

80 {
81 // create input-container for purity-check:
82// std::vector<const Belle2::SpacePoint*> spacePoints = {&outerHit, &centerHit, &innerHit};
83
84 generalNotify<Var, RangeType>(fResult, range);
85 }

◆ prepare()

static void prepare ( const SpacePoint outerHit,
const SpacePoint innerHit 
)
inlinestatic

static method used by the observed object to reset the stored values of the observer.

Definition at line 160 of file ObserverCheckMCPurity.h.

162 {
163 // store the hits:
165 s_innerHitOfTwo = innerHit;
166
167 // collect purity for each particle attached to the hits
168 std::vector<const Belle2::SpacePoint*> hits = {&outerHit, &innerHit};
169// hits.push_back(&outerHit);
170// hits.push_back(&innerHit);
171 std::vector<Belle2::MCVXDPurityInfo> particlesFound;
172 particlesFound = createPurityInfosVec(hits);
173 // the dominating-particle is the uppermost one:
174 auto purityPack = particlesFound.at(0).getPurity();
175 s_mainMCParticleID = purityPack.first;
176 s_mainPurity = purityPack.second;
177
178 // reset the wasUsed-flag to catch when filters are not triggered.
179 for (auto& entry : s_wasUsed) {
180 *(entry.second) = false;
181 }
182 }
static std::vector< Belle2::MCVXDPurityInfo > createPurityInfosVec(const std::vector< const Belle2::SpacePoint * > &spacePoints)
create a vector of MCVXDPurityInfos objects for a std::vector<Belle2::SpacePoints>.
B2Vector3D outerHit(0, 0, 0)
testing out of range behavior

◆ terminate()

static void terminate ( const types &  ...)
inlinestatic

static method used by the observed object to terminate the observer.

Definition at line 188 of file ObserverCheckMCPurity.h.

189 {
190 s_results.clear();
191 s_wasAccepted.clear();
192 s_wasUsed.clear();
193 }

Member Data Documentation

◆ s_centerHitOfThree

SpacePoint s_centerHitOfThree
static

stores the center hit of a three-hit-combination.

Definition at line 60 of file ObserverCheckMCPurity.h.

◆ s_innerHitOfThree

SpacePoint s_innerHitOfThree
static

stores the inner hit of a three-hit-combination.

Definition at line 63 of file ObserverCheckMCPurity.h.

◆ s_innerHitOfTwo

SpacePoint s_innerHitOfTwo
static

stores the inner hit of a two-hit-combination.

Definition at line 54 of file ObserverCheckMCPurity.h.

◆ s_mainMCParticleID

int s_mainMCParticleID = 0
static

dominating mcParticleID.

Definition at line 66 of file ObserverCheckMCPurity.h.

◆ s_mainPurity

double s_mainPurity = -1.
static

purity for the dominating particleID.

Definition at line 69 of file ObserverCheckMCPurity.h.

◆ s_outerHitOfThree

SpacePoint s_outerHitOfThree
static

stores the outer hit of a three-hit-combination.

Definition at line 57 of file ObserverCheckMCPurity.h.

◆ s_outerHitOfTwo

SpacePoint s_outerHitOfTwo
static

stores the outer hit of a two-hit-combination.

Definition at line 51 of file ObserverCheckMCPurity.h.

◆ s_results

std::map< std::string, double * > s_results
static

stores the results calculated (->value) for a selectionVariableName (->Key).

defining member s_results of the ObserverCheckMCPurity.

Definition at line 35 of file ObserverCheckMCPurity.h.

◆ s_ttree

TTree * s_ttree = nullptr
static

a ttree to store all the collected data.

Definition at line 48 of file ObserverCheckMCPurity.h.

◆ s_wasAccepted

std::map< std::string, bool * > s_wasAccepted
static

stores if hits were accepted (->value) for a selectionVariableName (->Key).

defining member s_results of the ObserverCheckMCPurity.

Definition at line 40 of file ObserverCheckMCPurity.h.

◆ s_wasUsed

std::map< std::string, bool * > s_wasUsed
static

stores if the filter was actually used this time (->value) for a selectionVariableName (->Key).

defining member s_results of the ObserverCheckMCPurity.

Definition at line 45 of file ObserverCheckMCPurity.h.


The documentation for this class was generated from the following files: