Belle II Software release-09-00-00
SVDTimeGroupingModule.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// framework
12#include <framework/core/Module.h>
13#include <framework/database/DBObjPtr.h>
14#include <framework/datastore/StoreArray.h>
15
16// svd
17#include <vxd/dataobjects/VxdID.h>
18#include <svd/dbobjects/SVDRecoConfiguration.h>
19#include <svd/dbobjects/SVDTimeGroupingConfiguration.h>
20#include <svd/dataobjects/SVDCluster.h>
21
22// std
23#include <string>
24
25// root
26#include <TH1D.h>
27#include <TF1.h>
28#include <TMath.h>
29
30
31namespace Belle2 {
39 typedef std::tuple<double, double, double> GroupInfo;
40
41
42
51
52 public:
53
54
55
58
59
64 virtual void initialize() override;
65
67 void beginRun() override;
68
73 virtual void event() override;
74
75
76 protected:
77
81 // Data members
82 std::string m_svdClustersName;
83 std::string m_svdEventInfoName;
90
101
106
112
113 // helper functions
114
120 void createAndFillHistorgram(TH1D& hist);
121
130 void searchGausPeaksInHistogram(TH1D& hist, std::vector<GroupInfo>& groupInfoVector);
131
133 void resizeToMaxSize(std::vector<GroupInfo>& groupInfoVector)
134 {
135 groupInfoVector.resize(m_usedPars.maxGroups, GroupInfo(0., 0., 0.));
136 }
137
143 void sortBackgroundGroups(std::vector<GroupInfo>& groupInfoVector);
144
151 void sortSignalGroups(std::vector<GroupInfo>& groupInfoVector);
152
160 void assignGroupIdsToClusters(TH1D& hist, std::vector<GroupInfo>& groupInfoVector);
161
162 };
163
164
165
167 inline double myGaus(const double* x, const double* par)
168 {
169 return par[0] * TMath::Gaus(x[0], par[1], par[2], true);
170 }
171
172
177 inline void addGausToHistogram(TH1D& hist,
178 const double& integral, const double& center, const double& sigma,
179 const double& sigmaN, const bool& isAddition = true)
180 {
181 int startBin = hist.FindBin(center - sigmaN * sigma);
182 int endBin = hist.FindBin(center + sigmaN * sigma);
183 if (startBin < 1) startBin = 1;
184 if (endBin > (hist.GetNbinsX())) endBin = hist.GetNbinsX();
185
186 for (int ijx = startBin; ijx <= endBin; ijx++) {
187 double tbinc = hist.GetBinCenter(ijx);
188 double tbincontent = hist.GetBinContent(ijx);
189
190 if (isAddition) tbincontent += integral * TMath::Gaus(tbinc, center, sigma, true);
191 else tbincontent -= integral * TMath::Gaus(tbinc, center, sigma, true);
192
193 hist.SetBinContent(ijx, tbincontent);
194 }
195 }
196
197
202 inline void subtractGausFromHistogram(TH1D& hist,
203 const double& integral, const double& center, const double& sigma,
204 const double& sigmaN)
205 {
206 addGausToHistogram(hist, integral, center, sigma, sigmaN, false);
207 }
208
210 inline int getSensorType(const VxdID& sensorID)
211 {
212 int layer = sensorID.getLayerNumber();
213 int sensor = sensorID.getSensorNumber();
214 if (layer == 3)
215 return 0;
216 else {
217 if (sensor == 1)
218 return 1;
219 else
220 return 2;
221 }
222 }
223
224
226} // end namespace Belle2
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Base class for Modules.
Definition: Module.h:72
Imports Clusters of the SVD detector and converts them to spacePoints.
bool m_useParamFromDB
if true use the configuration from SVDTimeGroupingConfiguration DB.
std::string m_svdClustersName
SVDCluster collection name.
SVDTimeGroupingParameters m_usedParsIn3Samples
module parameter values for 3-sample DAQ taken from SVDTimeGroupingConfiguration dbobject.
SVDTimeGroupingParameters m_usedPars
module parameter values used.
virtual void initialize() override
Init the module.
StoreArray< SVDCluster > m_svdClusters
the storeArray for svdClusters as member, is faster than recreating link for each event
virtual void event() override
EventWise jobs.
SVDTimeGroupingParameters m_usedParsIn6Samples
module parameter values for 6-sample DAQ taken from SVDTimeGroupingConfiguration dbobject.
void resizeToMaxSize(std::vector< GroupInfo > &groupInfoVector)
increase the size of vector to max, this helps in sorting
void sortBackgroundGroups(std::vector< GroupInfo > &groupInfoVector)
Sort Background Groups.
bool m_forceGroupingFromDB
if true use configuration from the SVDRecConfiguration DB.
void beginRun() override
configure
void assignGroupIdsToClusters(TH1D &hist, std::vector< GroupInfo > &groupInfoVector)
Assign groupId to the clusters.
std::string m_svdEventInfoName
Name of the collection to use for the SVDEventInfo.
void createAndFillHistorgram(TH1D &hist)
Create Histogram and Fill cluster time in it.
void sortSignalGroups(std::vector< GroupInfo > &groupInfoVector)
Sort Signals.
void searchGausPeaksInHistogram(TH1D &hist, std::vector< GroupInfo > &groupInfoVector)
Find Gaussian components in a Histogram.
DBObjPtr< SVDRecoConfiguration > m_recoConfig
SVD Reconstruction Configuration payload.
bool m_isEnabledIn6Samples
Enables the module if true for 6-sample DAQ mode.
DBObjPtr< SVDTimeGroupingConfiguration > m_groupingConfig
SVDTimeGrouping Configuration payload.
bool m_isEnabledIn3Samples
Enables the module if true for 3-sample DAQ mode.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
baseType getSensorNumber() const
Get the sensor id.
Definition: VxdID.h:100
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
std::tuple< double, double, double > GroupInfo
typedef to be used to store Gauss parameters (integral, center, sigma)
int getSensorType(const VxdID &sensorID)
Get Sensor Type of SVD sensors.
double myGaus(const double *x, const double *par)
Gaus function to be used in the fit.
void subtractGausFromHistogram(TH1D &hist, const double &integral, const double &center, const double &sigma, const double &sigmaN)
Subtract a Gaussian from a histogram.
void addGausToHistogram(TH1D &hist, const double &integral, const double &center, const double &sigma, const double &sigmaN, const bool &isAddition=true)
Add (or Subtract) a Gaussian to (or from) a histogram.
Abstract base class for different kinds of events.
structure containing the relevant informations of SVDTimeGrouping module
Int_t maxGroups
maximum number of groups to be accepted.