Belle II Software  release-06-01-15
VXDDedxPIDModule.h
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 #pragma once
10 
11 #include <framework/core/Module.h>
12 #include <framework/gearbox/Const.h>
13 #include <framework/datastore/StoreArray.h>
14 
15 #include <reconstruction/dataobjects/VXDDedxTrack.h>
16 #include <reconstruction/dataobjects/VXDDedxLikelihood.h>
17 #include <reconstruction/dataobjects/DedxConstants.h>
18 
19 #include <mdst/dataobjects/Track.h>
20 #include <mdst/dataobjects/MCParticle.h>
21 #include <tracking/dataobjects/RecoTrack.h>
22 #include <svd/dataobjects/SVDCluster.h>
23 #include <pxd/dataobjects/PXDCluster.h>
24 
25 #include <framework/database/DBObjPtr.h>
26 #include <reconstruction/dbobjects/DedxPDFs.h>
27 
28 #include <vector>
29 
30 
31 namespace Belle2 {
36  class HelixHelper;
37 
51  class VXDDedxPIDModule : public Module {
52 
53  public:
54 
57 
59  virtual ~VXDDedxPIDModule();
60 
62  virtual void initialize() override;
63 
66  virtual void event() override;
67 
69  virtual void terminate() override;
70 
71  private:
72 
73  // required input
77  // optional input
82  // output
88  int m_eventID;
90  int m_trackID;
91 
99  void calculateMeans(double* mean, double* truncatedMean, double* truncatedMeanErr, const std::vector<double>& dedx) const;
100 
102  static double getTraversedLength(const PXDCluster* hit, const HelixHelper* helix);
103 
105  static double getTraversedLength(const SVDCluster* hit, const HelixHelper* helix);
106 
108  template <class HitClass> void saveSiHits(VXDDedxTrack* track, const HelixHelper& helix, const std::vector<HitClass*>& hits) const;
109 
117  void savePXDLogLikelihood(double(&logl)[Const::ChargedStable::c_SetSize], double p, float dedx) const;
118 
126  void saveSVDLogLikelihood(double(&logl)[Const::ChargedStable::c_SetSize], double p, float dedx) const;
127 
129  bool detectorEnabled(Dedx::Detector d) const
130  {
131  return (d == Dedx::c_PXD and m_usePXD) or (d == Dedx::c_SVD and m_useSVD);
132  }
133 
135  void checkPDFs();
136 
137  // pdfs for PID
140  // parameters: full likelihood vs. truncated mean
142  //no need to define highest and lowest truncated value as we laways remove highest 2 dE/dx values from 8 dE/dx value.
143 
144  //parameters: technical stuff
148  //parameters: which particles and detectors to use
150  bool m_usePXD;
151  bool m_useSVD;
153  //parameters: PDF configuration
156  };
158 } // Belle2 namespace
static const unsigned int c_SetSize
Number of elements (for use in array bounds etc.)
Definition: Const.h:496
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Helper class representing a helical track.
Definition: HelixHelper.h:28
Base class for Modules.
Definition: Module.h:72
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:28
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Extract dE/dx from fitted tracks.
void saveSVDLogLikelihood(double(&logl)[Const::ChargedStable::c_SetSize], double p, float dedx) const
for all particles in the SVD, save log-likelihood values into 'logl'.
int m_trackID
counter for tracks in this event
virtual void initialize() override
Initialize the module.
StoreArray< SVDCluster > m_svdClusters
Optional array of SVDClusters.
bool m_usePXD
use PXD hits for likelihood
virtual void event() override
This method is called for each event.
StoreArray< MCParticle > m_mcparticles
Optional array of MCParticles.
StoreArray< VXDDedxLikelihood > m_dedxLikelihoods
Output array of VXDDedxLikelihoods.
void checkPDFs()
Check the pdfs for consistency everytime they change in the database.
virtual void terminate() override
End of the event processing.
void saveSiHits(VXDDedxTrack *track, const HelixHelper &helix, const std::vector< HitClass * > &hits) const
save energy loss and hit information from SVD/PXDHits to track
void calculateMeans(double *mean, double *truncatedMean, double *truncatedMeanErr, const std::vector< double > &dedx) const
Save arithmetic and truncated mean for the 'dedx' values.
StoreArray< VXDDedxTrack > m_dedxTracks
Output array of VXDDedxTracks.
virtual ~VXDDedxPIDModule()
Destructor.
int m_eventID
counter for events
bool m_useSVD
use SVD hits for likelihood
bool detectorEnabled(Dedx::Detector d) const
should info from this detector be included in likelihood?
bool m_ignoreMissingParticles
Ignore particles for which no PDFs are found.
StoreArray< Track > m_tracks
Required array of Tracks.
bool m_onlyPrimaryParticles
Only save data for primary particles (as determined by MC truth)
StoreArray< PXDCluster > m_pxdClusters
Optional array of PXDClusters.
static double getTraversedLength(const PXDCluster *hit, const HelixHelper *helix)
returns traversed length through active medium of given PXDCluster.
StoreArray< RecoTrack > m_recoTracks
Required array of input RecoTracks.
bool m_useIndividualHits
Include PDF value for each hit in likelihood.
VXDDedxPIDModule()
Default constructor.
bool m_enableDebugOutput
Whether to save information on tracks and associated hits and dE/dx values in VXDDedxTrack objects.
double m_trackDistanceThreshhold
Use a faster helix parametrisation, with corrections as soon as the approximation is more than ....
void savePXDLogLikelihood(double(&logl)[Const::ChargedStable::c_SetSize], double p, float dedx) const
for all particles in the PXD, save log-likelihood values into 'logl'.
DBObjPtr< DedxPDFs > m_DBDedxPDFs
DB object for dedx:momentum PDFs.
Debug output for VXDDedxPID module.
Definition: VXDDedxTrack.h:27
Abstract base class for different kinds of events.