Belle II Software development
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
48
49 public:
50
51
52
55
56
61 virtual void initialize() override;
62
64 void beginRun() override;
65
70 virtual void event() override;
71
72
73 protected:
74
78 // Data members
79 std::string m_svdClustersName;
80 std::string m_svdEventInfoName;
87
98
103
109
110 // helper functions
111
117 void createAndFillHistorgram(TH1D& hist);
118
127 void searchGausPeaksInHistogram(TH1D& hist, std::vector<GroupInfo>& groupInfoVector);
128
130 void resizeToMaxSize(std::vector<GroupInfo>& groupInfoVector)
131 {
132 groupInfoVector.resize(m_usedPars.maxGroups, GroupInfo(0., 0., 0.));
133 }
134
140 void sortBackgroundGroups(std::vector<GroupInfo>& groupInfoVector);
141
148 void sortSignalGroups(std::vector<GroupInfo>& groupInfoVector);
149
157 void assignGroupIdsToClusters(TH1D& hist, std::vector<GroupInfo>& groupInfoVector);
158
159 };
160
161
162
164 inline double myGaus(const double* x, const double* par)
165 {
166 return par[0] * TMath::Gaus(x[0], par[1], par[2], true);
167 }
168
169
174 inline void addGausToHistogram(TH1D& hist,
175 const double& integral, const double& center, const double& sigma,
176 const double& sigmaN, const bool& isAddition = true)
177 {
178 int startBin = hist.FindBin(center - sigmaN * sigma);
179 int endBin = hist.FindBin(center + sigmaN * sigma);
180 if (startBin < 1) startBin = 1;
181 if (endBin > (hist.GetNbinsX())) endBin = hist.GetNbinsX();
182
183 for (int ijx = startBin; ijx <= endBin; ijx++) {
184 double tbinc = hist.GetBinCenter(ijx);
185 double tbincontent = hist.GetBinContent(ijx);
186
187 if (isAddition) tbincontent += integral * TMath::Gaus(tbinc, center, sigma, true);
188 else tbincontent -= integral * TMath::Gaus(tbinc, center, sigma, true);
189
190 hist.SetBinContent(ijx, tbincontent);
191 }
192 }
193
194
199 inline void subtractGausFromHistogram(TH1D& hist,
200 const double& integral, const double& center, const double& sigma,
201 const double& sigmaN)
202 {
203 addGausToHistogram(hist, integral, center, sigma, sigmaN, false);
204 }
205
207 inline int getSensorType(const VxdID& sensorID)
208 {
209 int layer = sensorID.getLayerNumber();
210 int sensor = sensorID.getSensorNumber();
211 if (layer == 3)
212 return 0;
213 else {
214 if (sensor == 1)
215 return 1;
216 else
217 return 2;
218 }
219 }
220
221
223} // 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.