Belle II Software development
B2BIIFixMdstModule.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// $Id: B2BIIFixMdst.h 11331 2011-07-25 11:58:12Z hitoshi $
10//
11// $Log$
12// Revision 1.16 2005/03/10 14:16:14 hitoshi
13// check table sizes
14//
15// Revision 1.15 2004/04/25 16:33:47 hitoshi
16// modified to be able to handle output from low p finder (by kakuno). modified
17// Benergy to fetch data from DB (by Shibata).
18//
19// Revision 1.14 2003/06/24 07:55:15 katayama
20// Remived unused parameters
21//
22// Revision 1.13 2003/06/12 13:25:24 hitoshi
23// scale_error implemented last year (by Higuchi; valid up to exp19) is incorporated
24//
25// Revision 1.12 2003/03/19 05:02:32 hitoshi
26// minor change (by Miyabayashi).
27//
28// Revision 1.11 2002/09/06 03:47:21 hitoshi
29// Endcap_MX_layer=11 is now the default (by muon group).
30//
31// Revision 1.9 2002/04/26 01:25:07 katayama
32// New correction from Perers san
33//
34// Revision 1.8 2002/04/24 00:58:36 hitoshi
35// new scale factors for e15 mdst reprocessed with 20020405.
36//
37// Revision 1.7 2002/04/19 07:24:38 katayama
38// Added pi0/vertex, calibdedx
39//
40// Revision 1.6 2002/04/05 01:19:32 katayama
41// templates for ecl_primary_vertex
42//
43// Revision 1.5 2002/03/31 06:54:39 katayama
44// fix_pi0
45//
46// Revision 1.4 2002/03/30 01:06:05 katayama
47// HadronB & L4passed events only
48//
49// Revision 1.3 2002/03/19 04:25:47 katayama
50// Add parameters for scale_momenta, set nominal b energy
51//
52// Revision 1.2 2002/03/13 02:55:19 katayama
53// First version
54//
55//
56
57#pragma once
58
59#define HEP_SHORT_NAMES
60
61/* Basf2 headers. */
62#include <framework/core/Module.h>
63#include <framework/dataobjects/EventExtraInfo.h>
64#include <framework/datastore/StoreObjPtr.h>
65#include <framework/logging/Logger.h>
66
67/* Belle headers. */
68#include <belle_legacy/belle.h>
69#include <belle_legacy/tables/run_info.h>
70
71/* CLHEP headers. */
72#include <CLHEP/Matrix/SymMatrix.h>
73#include <CLHEP/Geometry/Point3D.h>
74
75/* C++ headers. */
76#include <string>
77
79
80namespace Belle {
81
82 class Mdst_vee2;
83
84}
85
86namespace Belle2 {
92 class MuidProb;
93
99
100 static const int m_muid_version = 100;
102 public:
107
111 virtual void initialize() override;
112
116 virtual void beginRun() override;
117
121 virtual void event() override;
122
126 virtual void terminate() override;
127
131 static double get_Benergy()
132 {
133 return s_benergy_value;
134 };
135
139 static double get_pi0resol(double p, double theta, const char* side,
140 bool mcdata, int exp, int option)
141 {
142 return pi0resol(p, theta, side, mcdata, exp, option);
143 };
144
145 public: // BASF Parameters
146
168 static double s_benergy_value;
197
200
201 protected:
202
203 private:
204
205 int m_old_expno = 0;
214
215 bool good_event();
219 void scale_momenta(float scale_data = 1.0, float scale_mc = 1.0, int mode = 0);
221 void scale_momenta_set(const int, const int, const int,
222 double&);
223 void scale_momenta_set_v1(const int, const int, const int, double&);
224 void scale_momenta_set_v2(const int, const int, const int, double&);
226 double vee_mass_nofit(const Belle::Mdst_vee2& vee2, float scale = 1.0);
228 // Author: J.Tanaka (+T.Higuchi/2002,2003)
229 void scale_error(const int message_level = 0);
230 // void scale_error(void);
231
232 void smear_trk();
234 // Author: H.Kakuno
235 int add_extra_trk_vee2();
238 // Author: Miyabayashi
243 void make_pi0(int, double, double);
244 void correct_ecl(int, int);
246 int set_primary_vertex(HepPoint3D& v, CLHEP::HepSymMatrix& ve);
248 void make_pi0_primary_vertex(int, double, double, const HepPoint3D&,
249 const CLHEP::HepSymMatrix&);
251 const CLHEP::HepSymMatrix&);
253 static double pi0resol(double, double, const char*, bool, int, int);
254
255 // Author: T. Matsumoto
256 // based on dcpvrare_ml:0127, interface is modified by M. Nakao
257 //
259 double Benergy(int expnum = 0, int runnum = 0);
260
261 // Author: Kakuno
263 void fix_pi0_brecon(void);
264 // Author: Mike Peters
266 void shift_tof(const int mode);
268 void shift_tof_set(const int expno, const int runno,
269 const int mode, const int im,
270 const double pmom, const double sgn,
271 double& shift);
272 // Author: Leo Piilonen
273 void Muid_init(void);
274 void Muid_term(void);
275 void Muid_event(void);
276 void Muid_begin_run(const int, const int, const int);
277 void Muid_end_run(void);
279 };
280
282 class MuidProb {
283
284 public:
285
289 MuidProb(const char*, int&);
293 double prob(int, int, int, int, double) const;
295 double probRange(int, int, int, int) const;
297 double probRchisq(int, int, int, double) const;
299 double probECL(double, double) const;
301 void readDB(const char*, int&);
303
304 private:
305
306 // Array sizes as stored in input file
307
308 static const int kRange = 16;
309 static const int kRchisq = 50;
310 static const int kEEcl = 100;
311 static const int kPTrk = 50;
313 // Overflow value of reduced chi-squared, ECL energy, CDC momentum
314
315 static const double kRchisqMax;
316 static const double kEEclMax;
317 static const double kPTrkMax;
319 // Probability density arrays for range, reduced chi**2, and ECL energy
320 // (last one sliced by tracdk momentum in 100 MeV/c bins).
321 // One extra bin in chi-squared and ECL-energy distributions for overflows.
322 // For reduced chi-squared and ECL-energy, three extra arrays are stored for
323 // spline interpolation to eliminate binning artifacts.
324
325 double fRange[2][4][15][kRange];
326 double fRchisq[2][4][kRchisq + 1];
327 double fRchisqN[2][4][15];
328 double fRchisqD1[2][4][kRchisq + 1] = {{{0.0}}};
329 double fRchisqD2[2][4][kRchisq + 1] = {{{0.0}}};
330 double fRchisqD3[2][4][kRchisq + 1] = {{{0.0}}};
331 double fEEcl[kPTrk][kEEcl + 1];
332 double fEEclD1[kPTrk][kEEcl + 1] = {{0.0}};
333 double fEEclD2[kPTrk][kEEcl + 1] = {{0.0}};
334 double fEEclD3[kPTrk][kEEcl + 1] = {{0.0}};
336 };
337
339}
Declaration of class B2BIIFixMdst.
void Muid_end_run(void)
Called when the current run ends.
int m_expno
parameter ExpNo: Experiment number for muid (default=0) 0 ==> use experiment number stored in data fi...
std::string m_scale_error_dataset_name
Set scale_error_dataset name.
int m_benergy_db
Apply Benergy from DB or file.
void Muid_init(void)
Initialize the Muid module.
float m_scale_momenta_scale_mc
Set parameter scale_mc for scale_momenta.
bool m_saveResultExtraInfo
Whether to save result as EventExtraInfo.
int m_calib_dedx
Do dedx calibration.
int m_smear_trk
Do extra-smearing for MC tracks.
int m_scale_momenta
Apply scale_momenta.
void Muid_begin_run(const int, const int, const int)
Called for each new run.
int m_correct_ecl_option
Apply correct_ecl_option.
MuidProb * m_kaonprob
Pointer to kaons' prob-density object.
int m_use_ecl
parameter UseECL: Use (1) or don't use (0) ECL in muid (default=0)
int m_l4passed_only
Select level4-passed event only.
int m_correct_ecl
Apply correct_ecl.
double m_make_pi0_lower_limit
Set make_pi0 lower mass limit.
int m_make_pi0
Apply make_pi0 (after correct_ecl)
int m_shift_tof_mode
Do tof_correction.
int m_correct_ecl_primary_vertex
Apply correct_ecl_primary_vertex.
void Muid_event(void)
Called for each event.
static double get_Benergy()
Get Benergy.
int m_reprocess_version_specified
Specify reprocess version.
float m_scale_momenta_scale_data
Set parameter scale_data for scale_momenta.
int m_correct_ecl_version
Apply correct_ecl_version.
MuidProb * m_pionprob
Pointer to pions' prob-density object.
int m_scale_error
Apply scale_error.
int m_scale_momenta_mode
Set parameter mode for scale_momenta.
int m_check_version_consistency
Check consistency between environment variable and mdst version.
int m_table_size
Check table sizes.
void Muid_term(void)
Terminate the Muid module.
int m_limit_mdst_ecl_trk
Limit of mdst_ecl_trk table size.
int m_add_or_remove_extra_trk_vee2
(1) to add to Mdst_charged etc, (-1) to remove (move to Mdst_*_extra), (0) do nothing
int m_make_pi0_primary_vertex
Apply make_pi0_primary_vertex (after correct_ecl)
int m_correct_ecl_5s
For run indep.
int m_mapped_expno
Mapped value of m_old_exp_no.
int m_reprocess_version
Reprocess version (=0:old; =1:new)
int m_limit_mdst_klm_cluster_hit
Limit of mdst_klm_cluster_hit table size.
int m_hadron_b_only
Select Hadron B event only.
MuidProb * m_muonprob
Pointer to muons' prob-density object.
int m_old_expno
Most recently used experiment # in muid.
static double get_pi0resol(double p, double theta, const char *side, bool mcdata, int exp, int option)
Get pi0 resolution.
static const int m_muid_version
Version number of muid part.
int m_good_event
Select good event only.
int m_hadron_a_only
Select Hadron A event only.
int m_benergy_mcdb
Apply Benergy from DB or default value in MC.
double m_make_pi0_upper_limit
Set make_pi0 upper mass limit.
StoreObjPtr< EventExtraInfo > m_eventExtraInfo
Event ExtraInfo.
int m_5Srun
5S,2S,1S run or not
int m_eklm_max_layer
parameter Endcap_MX_layer: Max layer # of KLM endcap (default=11) 0 ==> use same value as was used by...
int m_make_pi0_option
Set make_pi0 option.
Base class for Modules.
Definition: Module.h:72
Class computes probability density for Muid calculation.
~MuidProb()
Destructor.
double fRchisq[2][4][kRchisq+1]
Reduced chi-squared pdf.
double fRchisqD2[2][4][kRchisq+1]
Second derivatives of Reduced chi-squared pdf.
static const int kRange
Array size of range.
double fRange[2][4][15][kRange]
Range pdf.
double probRange(int, int, int, int) const
Compute probability density for range.
double probECL(double, double) const
Compute probability density for ECL energy deposit.
double fRchisqD1[2][4][kRchisq+1]
First derivatives of Reduced chi-squared pdf.
double probRchisq(int, int, int, double) const
Compute probability density for reduced chi-squared.
static const int kRchisq
Array size of reduced chi-squared.
static const double kEEclMax
Overflow value of ECL energy.
double fEEclD1[kPTrk][kEEcl+1]
First derivatives of ECL energy pdf.
double fEEclD2[kPTrk][kEEcl+1]
Second derivatives of ECL energy pdf.
static const double kPTrkMax
Overflow value of CDC momentum.
double fEEclD3[kPTrk][kEEcl+1]
Third derivatives of ECL energy pdf.
double fRchisqN[2][4][15]
Non-overflow normalization.
static const int kEEcl
Array size of ECL energy.
double fRchisqD3[2][4][kRchisq+1]
Third derivatives of Reduced chi-squared pdf.
static const int kPTrk
Array size of CDC momentum.
static const double kRchisqMax
Overflow value of reduced chi-squared.
void readDB(const char *, int &)
Read in probability density functions from database.
double fEEcl[kPTrk][kEEcl+1]
ECL energy pdf.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
void fix_pi0_brecon(void)
Fix relation gamma<->pi0 in brecon table.
void scale_momenta_set_v2(const int, const int, const int, double &)
Return scale factors set_v2.
void make_pi0(int, double, double)
Create Mdst_pi0 from Mdst_gamma and Mdst_ecl to let people get mass-constraint fitted momentum of pi0...
void shift_tof(const int mode)
Shift tof times to account for residuals.
virtual void initialize() override
Initialize the module.
void make_pi0_primary_vertex(int, double, double, const HepPoint3D &, const CLHEP::HepSymMatrix &)
Fill Mdst_pi0 based on the fit result.
virtual void event() override
Called for each event.
void smear_trk()
Apply track smearing (on MC)
double Benergy(int expnum=0, int runnum=0)
Return Beam energy.
virtual void terminate() override
Terminates the module.
int remove_extra_trk_vee2()
Remove extra tracks from Mdst_trk and Mdst_vee2.
void correct_ecl_primary_vertex(const HepPoint3D &, const CLHEP::HepSymMatrix &)
Correct ecl using primary vertex.
void correct_ecl(int, int)
Correct photon's momenta and error matrix.
virtual void beginRun() override
Called when a new run is started.
void scale_momenta_set_v1(const int, const int, const int, double &)
Return scale factors set_v1.
int add_extra_trk_vee2()
Add Mdst_trk_extra and Mdst_vee_extra to Mdst_trk and Mdst_vee2, respectively.
void shift_tof_set(const int expno, const int runno, const int mode, const int im, const double pmom, const double sgn, double &shift)
Return time shifts for different exp.
int set_primary_vertex(HepPoint3D &v, CLHEP::HepSymMatrix &ve)
Set primary vertex assuming all tracks are pions.
static double s_benergy_value
Beam energy.
void scale_momenta(float scale_data=1.0, float scale_mc=1.0, int mode=0)
Scale momenta of Mdst_trk.
bool good_event()
Check if event corresponds to the period when Belle detector not in good condition.
void scale_error(const int message_level=0)
Apply scale error.
void scale_momenta_set(const int, const int, const int, double &)
Return scale factors for 2001 summer confs.
int get_reprocess_version()
Get reprocess version of input mdst.
double vee_mass_nofit(const Belle::Mdst_vee2 &vee2, float scale=1.0)
Calculates V0 mass with non-constraint fit results.
static double pi0resol(double, double, const char *, bool, int, int)
Treat pi0 mass width as a func.
Abstract base class for different kinds of events.