Belle II Software development
CountAcceptedRejectedMCParticleObserver Class Reference

this observer identifies the McParticles responsible for creating underlying clusters for given spacePoints and counts how often a particle type was accepted and how often it was rejected More...

Inheritance diagram for CountAcceptedRejectedMCParticleObserver:
VoidObserver

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 &outerHit, const typename Var::argumentType &innerHit)
 notifier producing a info message if SelectionVariable was accepted and a Warning if otherwise
 
template<class hitType >
static void collectPDGs (const hitType &aHit, vector< pair< bool, int > > &collectedPDGs)
 collects all PDGs connected to given hit.
 
template<class hitType >
static void collectParticleIDs (const hitType &aHit, vector< pair< bool, int > > &collectedIDS)
 collects all particleIDs connected to given hit.
 
template<class hitType >
static CountContainer::Key createKey (const hitType &hitA, const hitType &hitB, bool usePDG)
 for two hits given, a key for the CountContainer is returned.
 
template<class hitType >
static void collectMCParticles (const hitType &aHit, std::vector< const MCParticle * > &collectedParticles)
 collects all mcParticles connected to given hit.
 
template<class Type >
static std::string vec2str (const vector< Type > &vec)
 small helper for easily printing vectors
 
template<typename ... types>
static void notify (const types &...)
 static method used by the observed object to notify the observer.
 
template<typename ... types>
static bool initialize (const types &...)
 static method used by the observed object to initialize the observer it is called once usually from the user.
 
template<typename ... types>
static void prepare (const types &...)
 static method used by the observed object to prepare the observer it is called by the boolean filter operator.
 
template<typename ... types>
static void collect (const types &...)
 static method used by the observed object to prepare the observer it is called by the boolean filter operator.
 
template<typename ... types>
static void terminate (const types &...)
 static method used by the observed object to terminate the observer.
 

Detailed Description

this observer identifies the McParticles responsible for creating underlying clusters for given spacePoints and counts how often a particle type was accepted and how often it was rejected

Definition at line 500 of file observers.cc.

Member Function Documentation

◆ collect()

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

static method used by the observed object to prepare the observer it is called by the boolean filter operator.

Definition at line 55 of file VoidObserver.h.

55{};

◆ collectMCParticles()

static void collectMCParticles ( const hitType &  aHit,
std::vector< const MCParticle * > &  collectedParticles 
)
inlinestatic

collects all mcParticles connected to given hit.

does only work, if hit has direct relations PXD/SVDCluster which have relations to MCParticle.

first parameter is a hit (e.g. spacePoint) which is related to MCParticles. second parameter is the vector for collecting the PDGcodes found.

Definition at line 621 of file observers.cc.

622 {
623 RelationVector<PXDCluster> relatedToPXDClusters = aHit.template getRelationsTo<PXDCluster>();
624 RelationVector<SVDCluster> relatedToSVDClusters = aHit.template getRelationsTo<SVDCluster>();
625
626 for (const PXDCluster& aCluster : relatedToPXDClusters) {
627 for (const MCParticle& aParticle : aCluster.getRelationsTo<MCParticle>()) {
628 collectedParticles.push_back(&aParticle);
629 }
630 }
631
632 for (const SVDCluster& aCluster : relatedToSVDClusters) {
633 for (const MCParticle& aParticle : aCluster.getRelationsTo<MCParticle>()) {
634 collectedParticles.push_back(&aParticle);
635 }
636 }
637 }
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
Class for type safe access to objects that are referred to in relations.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:29

◆ collectParticleIDs()

static void collectParticleIDs ( const hitType &  aHit,
vector< pair< bool, int > > &  collectedIDS 
)
inlinestatic

collects all particleIDs connected to given hit.

does only work, if hit has direct relations PXD/SVDCluster which have relations to MCParticle.

first parameter is a hit (e.g. spacePoint) which is related to MCParticles. second parameter is the vector for collecting the PDGcodes found.

Definition at line 567 of file observers.cc.

568 {
569
570 std::vector<const MCParticle*> collectedParticles;
571
572 collectMCParticles(aHit, collectedParticles);
573
574 for (const MCParticle* aParticle : collectedParticles) {
575 collectedIDS.push_back({aParticle->hasStatus(MCParticle::c_PrimaryParticle), aParticle->getIndex()});
576 }
577 }
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:47
static void collectMCParticles(const hitType &aHit, std::vector< const MCParticle * > &collectedParticles)
collects all mcParticles connected to given hit.
Definition: observers.cc:621

◆ collectPDGs()

static void collectPDGs ( const hitType &  aHit,
vector< pair< bool, int > > &  collectedPDGs 
)
inlinestatic

collects all PDGs connected to given hit.

does only work, if hit has direct relations PXD/SVDCluster which have relations to MCParticle.

first parameter is a hit (e.g. spacePoint) which is related to MCParticles. second parameter is the vector for collecting the PDGcodes found.

Definition at line 545 of file observers.cc.

546 {
547
548 std::vector<const MCParticle*> collectedParticles;
549
550 collectMCParticles(aHit, collectedParticles);
551
552 for (const MCParticle* aParticle : collectedParticles) {
553 collectedPDGs.push_back({aParticle->hasStatus(MCParticle::c_PrimaryParticle), aParticle->getPDG()});
554 }
555 }

◆ createKey()

static CountContainer::Key createKey ( const hitType &  hitA,
const hitType &  hitB,
bool  usePDG 
)
inlinestatic

for two hits given, a key for the CountContainer is returned.

if usePDG == true, PDGcode will be used as identifier, if false, the ParticleID will be used

Definition at line 581 of file observers.cc.

582 {
583 CountContainer::Key newKey;
584
585 vector< pair< bool, int> > collectedIDS;
586
587 if (usePDG) {
588 collectPDGs(hitA, collectedIDS);
589 collectPDGs(hitB, collectedIDS);
590 } else {
591 collectParticleIDs(hitA, collectedIDS);
592 collectParticleIDs(hitB, collectedIDS);
593 }
594
596
597 if (collectedIDS.size() == 1) {
598 newKey.first = collectedIDS[0].first;
599 newKey.second = { collectedIDS[0].second };
600 return newKey;
601 }
602
603 newKey.first = false;
604
605 for (auto& entry : collectedIDS) {
606 newKey.second.push_back(entry.second);
607 }
608
609 return newKey;
610 }
static void collectPDGs(const hitType &aHit, vector< pair< bool, int > > &collectedPDGs)
collects all PDGs connected to given hit.
Definition: observers.cc:545
static void collectParticleIDs(const hitType &aHit, vector< pair< bool, int > > &collectedIDS)
collects all particleIDs connected to given hit.
Definition: observers.cc:567
std::pair< bool, Particles > Key
key for the internal container of this map
Definition: observers.cc:217
static void uniqueIdentifier(ContainerType &particles)
cleans a container of double entries
Definition: observers.cc:250

◆ initialize()

static bool initialize ( const types &  ...)
inlinestaticinherited

static method used by the observed object to initialize the observer it is called once usually from the user.

Definition at line 43 of file VoidObserver.h.

43{ return true; };

◆ notify() [1/2]

static void notify ( const types &  ...)
inlinestaticinherited

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

it is called at each accept.

Definition at line 37 of file VoidObserver.h.

37{};

◆ notify() [2/2]

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

notifier producing a info message if SelectionVariable was accepted and a Warning if otherwise

Definition at line 505 of file observers.cc.

510 {
511 B2INFO("CountAcceptedRejectedMCParticleObserver called" << endl
512 << "range: ( " << range.getInf() << " , " << range.getSup() << " )" << endl
513 << "var = " << fResult << endl
514 << "outerHit: (" << outerHit.X() << " , "
515 << outerHit.Y() << " , "
516 << outerHit.Z() << " ) (x,y,z) " << endl
517 << "innerHit: (" << innerHit.X() << " , "
518 << innerHit.Y() << " , "
519 << innerHit.Z() << " ) (x,y,z) " << endl
520 );
521
522 // we use the pdgCodes of the particles as identifier (not unique, since more than one primary particle can have the same PDG-code) and count their acceptance rate:
523 CountContainer::Key myPDGs = createKey(outerHit, innerHit, true);
524
525 counterMC< Var >::pdGacceptedRejected.IncreaseCounter(myPDGs, range.contains(fResult));
526
527
528 // now we do the same but with mcParticleIDs:
529
530 CountContainer::Key myPIDs = createKey(outerHit, innerHit, false);
531
532 counterMC< Var >::mcIDacceptedRejected.IncreaseCounter(myPIDs, range.contains(fResult));
533 }
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
static CountContainer::Key createKey(const hitType &hitA, const hitType &hitB, bool usePDG)
for two hits given, a key for the CountContainer is returned.
Definition: observers.cc:581
bool IncreaseCounter(Key &aKey, bool accepted)
accepts a key (first parameter) and if given key was accepted by the filter (second parameter)
Definition: observers.cc:259
static CountContainer mcIDacceptedRejected
map for pdgCodes (key: vector of pdgCodes found for given hits, sorted) storing how often it was acce...
Definition: observers.cc:365
static CountContainer pdGacceptedRejected
counts nCases accepted/rejected for each pdgCode-combination occurred
Definition: observers.cc:363
B2Vector3D outerHit(0, 0, 0)
testing out of range behavior

◆ prepare()

static void prepare ( const types &  ...)
inlinestaticinherited

static method used by the observed object to prepare the observer it is called by the boolean filter operator.

Definition at line 49 of file VoidObserver.h.

49{};

◆ terminate()

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

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

Definition at line 67 of file VoidObserver.h.

67{};

◆ vec2str()

static std::string vec2str ( const vector< Type > &  vec)
inlinestatic

small helper for easily printing vectors

Definition at line 642 of file observers.cc.

643 {
644 string output;
645
646 for (const auto& entry : vec) {
647 output += " " + std::to_string(entry);
648 }
649
650 return output;
651 }

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