Belle II Software release-09-00-00
VXDDedxPIDRemakerModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <reconstruction/modules/VXDDedxPID/VXDDedxPIDRemakerModule.h>
10#include <reconstruction/dataobjects/DedxConstants.h>
11
12namespace Belle2 {
18 using namespace Dedx;
19
20 //-----------------------------------------------------------------
22 //-----------------------------------------------------------------
23
24 REG_MODULE(VXDDedxPIDRemaker);
25
26 //-----------------------------------------------------------------
27 // Implementation
28 //-----------------------------------------------------------------
29
31 {
33
34 // Set module description
35 setDescription("Module that re-makes VXD PID likelihoods by taking dE/dx stored in VXDDedxTracks and lookup table PDF's from DB.");
36
37 // Parameter definitions
38 addParam("useIndividualHits", m_useIndividualHits,
39 "Use individual hits (true) or truncated mean (false) to determine likelihoods", false);
40 addParam("usePXD", m_usePXD, "Use dE/dx from PXD", false);
41 addParam("useSVD", m_useSVD, "Use dE/dx from SVD", true);
42 }
43
45 {
46 if (m_usePXD) {
47 if (not m_PXDDedxPDFs) B2FATAL("No PXD dE/dx PDF's available");
48 bool ok = m_PXDDedxPDFs->checkPDFs(not m_useIndividualHits);
49 if (not ok) B2FATAL("Binning or ranges of PXD dE/dx PDF's differ");
50 }
51 if (m_useSVD) {
52 if (not m_SVDDedxPDFs) B2FATAL("No SVD Dedx PDF's available");
53 bool ok = m_SVDDedxPDFs->checkPDFs(not m_useIndividualHits);
54 if (not ok) B2FATAL("Binning or ranges of SVD dE/dx PDF's differ");
55 }
56 }
57
59 {
60 // required inputs
61 m_tracks.isRequired();
62 m_dedxTracks.isRequired();
63
64 // register likelihoods
65 m_dedxLikelihoods.registerInDataStore();
66 m_tracks.registerRelationTo(m_dedxLikelihoods);
67
68 // check PDF's and add callback
69 m_SVDDedxPDFs.addCallback([this]() {checkPDFs();});
70 m_PXDDedxPDFs.addCallback([this]() {checkPDFs();});
71 checkPDFs();
72 }
73
75 {
76 m_dedxLikelihoods.clear();
77
78 for (const auto& track : m_tracks) {
79 auto* dedxTrack = track.getRelatedTo<VXDDedxTrack>();
80 if (not dedxTrack) continue;
81
82 // re-calculate log likelihoods
83 dedxTrack->clearLogLikelihoods();
84 bool truncated = not m_useIndividualHits;
85 if (m_usePXD) dedxTrack->addLogLikelihoods(m_PXDDedxPDFs->getPDFs(truncated), Dedx::c_PXD, truncated);
86 if (m_useSVD) dedxTrack->addLogLikelihoods(m_SVDDedxPDFs->getPDFs(truncated), Dedx::c_SVD, truncated);
87
88 // save log likelihoods
89 if (dedxTrack->areLogLikelihoodsAvailable()) {
90 auto* likelihoodObj = m_dedxLikelihoods.appendNew(dedxTrack->getLogLikelihoods());
91 track.addRelationTo(likelihoodObj);
92 }
93 }
94
95 }
96
98} // Belle2 namespace
99
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
DBObjPtr< SVDdEdxPDFs > m_SVDDedxPDFs
look-up tables of SVD PDF's
bool m_usePXD
use PXD data for likelihood
StoreArray< VXDDedxLikelihood > m_dedxLikelihoods
collection of VXDDedxLikelihoods
DBObjPtr< PXDdEdxPDFs > m_PXDDedxPDFs
look-up tables of PXD PDF's
StoreArray< VXDDedxTrack > m_dedxTracks
collection of VXDDedxTracks
bool m_useSVD
use SVD data for likelihood
StoreArray< Track > m_tracks
collection of Tracks
bool m_useIndividualHits
use individual hits (true) or truncated mean (false) to determine likelihoods
Debug output for VXDDedxPID module.
Definition: VXDDedxTrack.h:29
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
void clearLogLikelihoods()
Clear log likelihoods (set to zero) and reset the counter of added log likelihood values.
Definition: VXDDedxTrack.cc:56
virtual void initialize() override
Initialize the module.
virtual void event() override
This method is called for each event.
void checkPDFs()
Check the pdfs for consistency every time they change in the database.
VXDDedxPIDRemakerModule()
Default constructor.
Abstract base class for different kinds of events.