Belle II Software  release-05-01-25
B2BIIFixMdstModule.cc
1 //
2 // $Id: B2BIIFixMdst_impl.cc 11331 2011-07-25 11:58:12Z hitoshi $
3 //
4 // $Log$
5 //
6 // Revision 2.0 2015/03/11 tkeck
7 // Conversion to Belle II
8 //
9 // Revision 1.40 2005/08/25 10:08:40 hitoshi
10 // not try to update s_benergy_value in the begin_run in order to suppress the unwanted warning message
11 //
12 // Revision 1.39 2005/03/10 14:14:57 hitoshi
13 // check table sizes
14 //
15 // Revision 1.38 2005/01/27 13:29:09 katayama
16 // fixed a bug
17 //
18 // Revision 1.37 2004/07/27 08:55:48 hitoshi
19 // not to output a misleading warning message about benergy (by Matsumoto)
20 //
21 // Revision 1.36 2004/04/25 16:33:33 hitoshi
22 // modified to be able to handle output from low p finder (by kakuno). modified
23 // Benergy to fetch data from DB (by Shibata).
24 //
25 // Revision 1.35 2004/03/09 10:23:04 hitoshi
26 // beam energies for exp31 (by Sanjay/Hulya)
27 //
28 // Revision 1.34 2003/07/10 13:45:38 hitoshi
29 // update for exp27 run700- (by Sanjay and Senyo).
30 //
31 // Revision 1.33 2003/07/03 00:06:22 katayama
32 // aviod seg fault
33 //
34 // Revision 1.32 2003/07/01 07:15:18 hitoshi
35 // fixed typo in warning message.
36 //
37 // Revision 1.31 2003/06/30 22:16:29 hitoshi
38 // update for exp27 (by Miyabayashi, Sanjay, Senyo).
39 //
40 // Revision 1.30 2003/06/24 07:55:16 katayama
41 // Remived unused parameters
42 //
43 // Revision 1.29 2003/06/01 09:21:01 hitoshi
44 // update for exp25 (by Sanjay).
45 //
46 // Revision 1.28 2002/12/28 23:10:08 katayama
47 // ecl and benergy for exp. 21 and 32 from Sanjay and Miyavayashi san
48 //
49 // Revision 1.27 2002/09/06 03:47:03 hitoshi
50 // Endcap_MX_layer=11 is now the default (by muon group).
51 //
52 // Revision 1.25 2002/07/10 09:35:04 katayama
53 // Call check_beginrun and then call begin_run
54 //
55 // Revision 1.24 2002/07/03 04:14:51 hitoshi
56 // beam energies for run900 - 1643 in e19 (by Sanjay san)
57 //
58 // Revision 1.23 2002/06/27 01:38:11 katayama
59 // Call Calib_dEdx_begin_run
60 //
61 // Revision 1.22 2002/06/25 10:53:03 katayama
62 // good_event bug fixed
63 //
64 // Revision 1.21 2002/06/22 06:22:44 katayama
65 // New from Sanjay san (exp. 19 run 460-899)
66 //
67 //
68 // Revision 1.21 2002/06/22 12:48:50 sanjay
69 // added benergy for run460-900 in e19
70 //
71 // Revision 1.20 2002/06/10 23:31:42 hitoshi
72 // returns nominal benergy for MC data at begin_run.
73 //
74 // Revision 1.19 2002/06/10 22:43:58 katayama
75 // Benergy works at begin run time
76 //
77 // Revision 1.18 2002/06/07 10:31:47 hitoshi
78 // added benergy for runs300 - 459 in e19.
79 //
80 // Revision 1.17 2002/06/06 05:05:54 hitoshi
81 // returns status for events with no Belle_event table.
82 //
83 // Revision 1.16 2002/06/04 07:59:08 hitoshi
84 // added protection for bad events: i.e. events w/o Belle_event or mdst_event_addtable.
85 //
86 // Revision 1.15 2002/06/03 21:39:49 hitoshi
87 // added benergy for run64-299 in e19 (by Sanjay).
88 //
89 // Revision 1.14 2002/05/08 11:55:51 hitoshi
90 // added benergy for exp17 (by Sanjay san).
91 //
92 // Revision 1.13 2002/04/26 01:25:07 katayama
93 // New correction from Perers san
94 //
95 // Revision 1.12 2002/04/19 07:24:39 katayama
96 // Added pi0/vertex, calibdedx
97 //
98 // Revision 1.11 2002/04/05 01:19:33 katayama
99 // templates for ecl_primary_vertex
100 //
101 // Revision 1.10 2002/03/31 06:54:41 katayama
102 // fix_pi0
103 //
104 // Revision 1.9 2002/03/30 23:13:41 katayama
105 // typo
106 //
107 // Revision 1.8 2002/03/30 10:31:12 katayama
108 // fixed
109 //
110 // Revision 1.7 2002/03/30 01:06:05 katayama
111 // HadronB & L4passed events only
112 //
113 // Revision 1.6 2002/03/19 04:25:47 katayama
114 // Add parameters for scale_momenta, set nominal b energy
115 //
116 // Revision 1.5 2002/03/16 07:28:39 hitoshi
117 // modified to remove exp9 svd bad events (following Sumisawa).
118 //
119 // Revision 1.4 2002/03/14 01:06:33 katayama
120 // added s_benergy_value
121 //
122 // Revision 1.3 2002/03/13 14:27:12 hitoshi
123 // changed the default not to call scale_error.
124 //
125 // Revision 1.2 2002/03/13 02:55:20 katayama
126 // First version
127 //
128 //
129 
130 #include <b2bii/modules/B2BIIMdstInput/B2BIIFixMdstModule.h>
131 
132 #include "belle_legacy/panther/panther.h"
133 
134 #include <iostream>
135 #include <string>
136 
137 #include "belle_legacy/ip/IpProfile.h"
138 
139 #include "belle_legacy/benergy/BeamEnergy.h"
140 
141 #include "belle_legacy/tables/mdst.h"
142 #include "belle_legacy/tables/belletdf.h"
143 #include "belle_legacy/tables/evtcls.h"
144 #include "belle_legacy/kid/dEdxCalib.h"
145 #include "belle_legacy/tables/level4.h"
146 
147 namespace Belle2 {
153  REG_MODULE(B2BIIFixMdst)
155 #define NOMINAL_ENERGY 5.290024915
156 
158 
160  {
161 
162  setDescription("Used to fix the old Belle I mdst files before processing. This module was taken from the old Belle I code and converted into a basf2 module."
163  "There are a lot of magic numbers in this module, where do they come from? Noone knows..."
164  "Return value is -1 if something went wrong, do not use these events!");
165 
166  addParam("Scale_momenta", m_scale_momenta, "Apply scale_momenta", 1);
167  addParam("scale_momenta_scale_data", m_scale_momenta_scale_data, "scale_momenta scale_data", 0.0f);
168  addParam("scale_momenta_scale_mc", m_scale_momenta_scale_mc, "scale_momenta scale_mc", 1.0f);
169  addParam("scale_momenta_mode", m_scale_momenta_mode, "scale_momenta_mode", 2);
170  addParam("Scale_error", m_scale_error, "Apply scale_error", 1);
171 
172  addParam("Smear_trk", m_smear_trk, "Do extra-smearing for MC tracks", 2);
173  addParam("Extra_trk_vee2", m_add_or_remove_extra_trk_vee2,
174  "1: add to Mdst_charged etc, -1: remove (move to Mdst_*_extra), 0:do nothing", 0);
175 
176  addParam("Correct_ecl", m_correct_ecl, "Apply correct_ecl", 1);
177  addParam("Correct_ecl_pv", m_correct_ecl_primary_vertex, "Apply correct_ecl_pv", 0);
178  addParam("Correct_ecl_option", m_correct_ecl_option, "Set correct_ecl option", 0);
179  addParam("Correct_ecl_version", m_correct_ecl_version, "Set correct_ecl version", 2);
180  addParam("Correct_ecl_5s", m_correct_ecl_5s, "Correct_ecl flag for 5S runs", 0); // KM 20080608
181 
182  addParam("Make_pi0", m_make_pi0, "Apply make_pi0 (after correct_ecl)", 1);
183  addParam("Make_pi0_pv", m_make_pi0_primary_vertex, "Apply make_pi0_pv (after correct_ecl)", 0);
184  addParam("Make_pi0_option", m_make_pi0_option, "Set make_pi0 option", 0);
185  addParam("Make_pi0_lower_limit", m_make_pi0_lower_limit, "Set make_pi0 lower mass limit", 0.0);
186  addParam("Make_pi0_upper_limit", m_make_pi0_upper_limit, "Set make_pi0 upper mass limit", 0.0);
187 
188  addParam("Benergy", m_benergy, "Apply Benergy", 1);
189  addParam("BenergyDB", m_benergy_db, "Apply Benergy from DB or file ", 0);
190  addParam("BenergyMCDB", m_benergy_mcdb, "Apply Benergy from DB or default value in MC", 0);
191 
192  addParam("Good_event", m_good_event, "Select good event only", 1);
193  addParam("HadronA", m_hadron_a_only, "Select Hadron A event only", 1);
194  addParam("HadronB", m_hadron_b_only, "Select Hadron B event only", 1);
195  addParam("Level4passed", m_l4passed_only, "Select level4-passed event only", 1);
196 
197  addParam("Scale_error_dataset", m_scale_error_dataset_name, "Set scale_error_dataset name", std::string(""));
198  addParam("Calib_dedx", m_calib_dedx, "Do dedx calibration", 1);
199  addParam("Shift_tof_mode", m_shift_tof_mode, "Do tof_correction", 1);
200  addParam("Endcap_MX_layer", m_eklm_max_layer, "Max layer number of KLM endcap", 11);
201  addParam("UseECL", m_use_ecl, "Use (1) or don't use (0) ECL in muid", 0);
202  addParam("ExpNo", m_expno, "Use data's exp # (0) or this value (>0) in muid", 0);
203 
204  addParam("Table_size", m_table_size, "Check table sizes", 1);
205  addParam("Limit_mdst_ecl_trk", m_limit_mdst_ecl_trk, "Limit of mdst_ecl_trk table size", 600);
206  addParam("Limit_mdst_klm_cluster_hit", m_limit_mdst_klm_cluster_hit, "Limit of mdst_klm_cluster_hit table size", 450);
207 
209  addParam("Reprocess_version", m_reprocess_version_specified, "Specify reprocess version", -1);
210  addParam("5Srun", m_5Srun, "5S,2S,1S run or not", 0);
211  addParam("Check_version_consistency", m_check_version_consistency, "Check consistency betw. env. variable and mdst version", 1);
212  }
213 
215  {
216  Muid_init();
217  }
218 
220  {
221  Muid_term();
222  }
223 
225  {
226 
227  if ((BsCouTab(BELLE_EVENT) == 0) || (BsCouTab(MDST_EVENT_ADD) == 0)) {
228  B2INFO("Warning from B2BIIFixMdst: No Belle_event or Mdst_event_add table; no correction for event");
229  setReturnValue(-1);
230  return;
231  }
232 
235  } else if (m_add_or_remove_extra_trk_vee2 == -1) {
237  }
238 
242 
243  if (m_scale_error == 1) scale_error();
244 
245  if (m_smear_trk != 0) smear_trk();
246 
248 
249  HepPoint3D pv;
250  CLHEP::HepSymMatrix dpv(3, 0);
251  int err(1);
252  if (m_correct_ecl_primary_vertex == 1) {
253  err = set_primary_vertex(pv, dpv);
254  if (err == 0)correct_ecl_primary_vertex(pv, dpv);
255  }
256 
257  if (m_make_pi0 == 1 || m_make_pi0_primary_vertex == 1) {
258  if (m_make_pi0_primary_vertex == 1 && err == 0) {
260  } else {
262  }
263  fix_pi0_brecon();
264  }
265 
266  if (m_benergy == 1) s_benergy_value = Benergy();
267 
268  if (m_good_event == 1) {
269  if (good_event()) {
270  setReturnValue(1);
271  } else {
272  setReturnValue(-1);
273  B2DEBUG(99, "B2BIIFixMdst: Not a good event");
274  return;
275  }
276  } else {
277  setReturnValue(0);
278  }
279 
280  if (m_l4passed_only == 1) {
281  if (BsCouTab(L4_SUMMARY)) {
282  struct l4_summary* l =
283  (struct l4_summary*) BsGetEnt(L4_SUMMARY, 1, BBS_No_Index);
284  if (l->m_type == 0) {
285  setReturnValue(-1);
286  B2DEBUG(99, "B2BIIFixMdst: L4 cut");
287  return;
288  }
289  }
290  }
291 
292  if (m_hadron_a_only == 1) {
293  Belle::Evtcls_flag_Manager& EvtFlagMgr = Belle::Evtcls_flag_Manager::get_manager();
294  Belle::Evtcls_flag_Manager::iterator it1 = EvtFlagMgr.begin();
295  if (it1 != EvtFlagMgr.end() && *it1) {
296  if ((*it1).flag(0) < 10) {
297  setReturnValue(-1);
298  B2DEBUG(99, "B2BIIFixMdst: HadA cut");
299  return;
300  }
301  }
302  }
303 
304  if (m_hadron_b_only == 1) {
305  Belle::Evtcls_hadronic_flag_Manager& HadMgr
306  = Belle::Evtcls_hadronic_flag_Manager::get_manager();
307  Belle::Evtcls_hadronic_flag_Manager::iterator ith = HadMgr.begin();
308  if (ith != HadMgr.end() && *ith) {
309  if ((*ith).hadronic_flag(2) <= 0) {
310  setReturnValue(-1);
311  B2DEBUG(99, "B2BIIFixMdst: HadB cut");
312  return;
313  }
314  }
315  }
316 
317  if (m_table_size == 1) {
318  Belle::Belle_event_Manager& bevt = Belle::Belle_event_Manager::get_manager();
319  // if( bevt[0].ExpNo() >=39 ) {
320  if ((m_reprocess_version == 0 && bevt.count() > 0 && bevt[0].ExpNo() >= 39) ||
321  (m_reprocess_version >= 1)) {
322  if (Belle::Mdst_ecl_trk_Manager::get_manager().count() > m_limit_mdst_ecl_trk) {
323  setReturnValue(-1);
324  B2INFO("B2BIIFixMdst: " << Belle::Mdst_ecl_trk_Manager::get_manager().count() << " " << m_limit_mdst_ecl_trk);
325  return;
326  }
327  if (Belle::Mdst_klm_cluster_hit_Manager::get_manager().count()
329  setReturnValue(-1);
330  B2INFO("B2BIIFixMdst: " << Belle::Mdst_klm_cluster_hit_Manager::get_manager().count() << " " << m_limit_mdst_klm_cluster_hit);
331  return;
332  }
333  }
334  }
335 
336  if (m_calib_dedx != 0) {
337  Belle::Belle_event_Manager& bevt = Belle::Belle_event_Manager::get_manager();
338  if (bevt[0].ExpMC() == 1 || m_reprocess_version == 0 || m_calib_dedx == -1) Belle::Calib_dEdx();
339  }
340 
342 
343  if (m_mapped_expno > 0) Muid_event();
344 
345  return;
346  }
347 
349  {
350 
351  if (m_5Srun == 0 && m_correct_ecl_5s == 1) m_5Srun = 1;
352 
354  B2INFO("reprocess version= " << m_reprocess_version);
355 
356  Belle::IpProfile::begin_run();
357 
358  if (m_benergy_db == 0) Belle::BeamEnergy::begin_run();
359 
360  Belle::Belle_runhead_Manager& evtmgr = Belle::Belle_runhead_Manager::get_manager();
361  Belle::Belle_runhead_Manager::const_iterator belleevt = evtmgr.begin();
362  if (belleevt != evtmgr.end() && (*belleevt)) {
363  int expmc = belleevt->ExpMC();
364  int exp = belleevt->ExpNo();
365  int run = belleevt->RunNo();
366  //if(m_benergy==1 && expmc==1) s_benergy_value = Benergy(exp, run);
367 
368  if (((31 <= exp && exp <= 55) || (69 <= exp && exp <= 73)) && m_check_version_consistency == 1) {
369  char* env = std::getenv("USE_GRAND_REPROCESS_DATA");
370  if ((env && m_reprocess_version == 0) ||
371  (!env && m_reprocess_version == 1)) {
372  B2ERROR("Env. variable USE_GRAND_REPROCESS_DATA and input mdst reprocess version=" << m_reprocess_version <<
373  " (=0:old; =1:new) are inconsistent -> kill the job. Set USE_GRAND_REPROCESS_DATA or input mdst file properly and retry.");
374  exit(-1);
375  }
376  }
377 
378  if (m_calib_dedx != 0) {
379  if (expmc == 1 || m_reprocess_version == 0 || m_calib_dedx == -1)
380  Belle::Calib_dEdx_begin_run(m_reprocess_version, m_5Srun);
381  }
382 
383  if (m_mapped_expno > 0) Muid_begin_run(expmc, exp, run);
384 
385  } else {
386  B2ERROR("[B2BIIFixMdst] Error: Cannot read \"Belle::Belle_RunHead\".");
387  }
388  }
389 
390  int
392  {
393 
394  int version(0);
395  Belle::Belle_version_Manager& bvmgr = Belle::Belle_version_Manager::get_manager();
396 
398  //*** version set forcedly ***
400  B2INFO("reprocess version forcedly set to " << version);
401 
402  } else {
403  //*** version set based on info. in run-header ***
404  Belle::Belle_processing_Manager& bpmgr = Belle::Belle_processing_Manager::get_manager();
405  Belle::Belle_runhead_Manager& evtmgr = Belle::Belle_runhead_Manager::get_manager();
406  Belle::Belle_runhead_Manager::const_iterator belleevt = evtmgr.begin();
407 
408  int expmc(0), exp(0), run(0);
409  if (belleevt != evtmgr.end() && (*belleevt)) {
410  expmc = belleevt->ExpMC();
411  exp = belleevt->ExpNo();
412  run = belleevt->RunNo();
413  }
414 
415  int B_l_d = 0;
416  //int Date = 0;
417  if (bpmgr.count() > 0) {
418  int i = bpmgr.count() - 1;
419  B_l_d = bpmgr[i].Belle_level_date();
420  //Date = bpmgr[i].Date();
421  }
422 
423  if (bvmgr.count() > 0) {
424  //Belle::Belle_version is in run-header: MC or (DATA with level > 20081107)
425  // int j = bvmgr.count() - 1;
426  int j = 0;
427  int chk = std::abs(bvmgr[j].SVD())
428  + std::abs(bvmgr[j].CDC())
429  + std::abs(bvmgr[j].ECL());
430  if (chk == 0) {
431  version = 0;
432  } else {
433  version = 1;
434  }
435  } else {
436  //no Belle::Belle_version in run-header: DATA with level <= 20081107
437  if (expmc == 2 || (expmc == 1
438  && B_l_d > 20081107))
439  B2ERROR("No Belle::Belle_version table in run-header for MC or (Data processed with Belle_level > 20081107). Strange !");
440 
441  if (B_l_d == 20081107) {
442  version = 1;
443  //exception: U(1S) run w/old tracking & old ECL
444  // if( exp==65 && run >= 1000 && Date <= 20081130 ) version = 0;
445  if (exp == 65 && run >= 1000) version = 0;
446  } else {
447  version = 0;
448  }
449  }
450  }
451 
452  if (bvmgr.count() == 0) {
453  Belle::Belle_version& bv = bvmgr.add();
454  bv.SVD(version);
455  bv.CDC(version);
456  bv.ECL(version);
457  } else if (bvmgr.count() > 0) {
458  if (bvmgr[0].SVD() != version) {
459  B2WARNING("Belle::Belle_version_SVD(=" << bvmgr[0].SVD() << ") is inconsistent with version(=" << version <<
460  "); replace it anyway");
461  bvmgr[0].SVD(version);
462  }
463  if (bvmgr[0].CDC() != version) {
464  B2WARNING("Belle::Belle_version_CDC(=" << bvmgr[0].CDC() << ") is inconsistent with version(=" << version <<
465  "); replace it anyway");
466  bvmgr[0].CDC(version);
467  }
468  if (bvmgr[0].ECL() != version) {
469  B2WARNING("Belle::Belle_version_ECL(=" << bvmgr[0].ECL() << ") is inconsistent with version(=" << version <<
470  "); replace it anyway");
471  bvmgr[0].ECL(version);
472  }
473  }
474 
475  return version;
476  }
477 
479  {
480 
481  bool ret = true;
482 
483  Belle::Mdst_quality_Manager& qmgr = Belle::Mdst_quality_Manager::get_manager();
484  if (0 == qmgr.count()) return ret; //do nothing if not exist
485 
486  for (std::vector<Belle::Mdst_quality>::iterator it = qmgr.begin();
487  it != qmgr.end(); ++it) {
488  Belle::Mdst_quality& q = *it;
489  std::string c(q.name()());
490  // if((strcmp(c,"SVD ")==0) && (q.quality() & 0x02)) ret = false;
491  //also to remove exp9 bad svd events
492  if ((strcmp(c.c_str(), "SVD ") == 0) && (q.quality() & 0x8002)) ret = false;
493  }
494  return ret;
495  }
496 
497 //=====================================================================
498 //
499 // Author: T. Matsumoto
500 // based on dcpvrare_ml:0127, interface is modified by M. Nakao
501 //
502 // Modified by T.Shibata 2004.04.15
503 // Benergy value get from Database
504 //
505 
506 //#include <panther/panther.h>
507 //#include BELLETDF_H
508 
509  double B2BIIFixMdstModule::Benergy(int expnum, int runnum)
510  {
511 
512  double energy(NOMINAL_ENERGY);
513  double factor(0.001);
514 
515  // if( m_benergy_db == 0 && BsCouTab(BELLE_EVENT) > 0 ){
516  if (m_benergy_db == 0) {
517  Belle::Belle_event_Manager& bevt_mgr = Belle::Belle_event_Manager::get_manager();
518  Belle::Belle_event_Manager::const_iterator bevt = bevt_mgr.begin();
519  if (bevt != bevt_mgr.end() && (*bevt)) {
520  if (bevt->ExpMC() == 1) energy = Belle::BeamEnergy::E_beam2();
521  if (bevt->ExpMC() == 2) {
522  if (m_benergy_mcdb == 0) return energy; //energy = 5.290000;
523  if (m_benergy_mcdb != 0) energy = Belle::BeamEnergy::E_beam2();
524  }
525  return energy;
526  }
527  }
528 
529  if ((expnum == 0 || runnum == 0) && BsCouTab(BELLE_EVENT) > 0) {
530  Belle::Belle_event& bevt = Belle::Belle_event_Manager::get_manager()[0];
531  if (bevt.ExpMC() == 1) {
532  expnum = bevt.ExpNo();
533  runnum = bevt.RunNo();
534  }
535  }
536 
537  if (expnum == 5) {
538  if (runnum >= 74 && runnum <= 472) energy += -0.540 * factor;
539  } else if (expnum == 7) {
540  if (runnum >= 6 && runnum <= 475) energy += 0.305 * factor;
541  else if (runnum >= 538 && runnum <= 895) energy += -1.016 * factor;
542  else if (runnum >= 904 && runnum <= 1079) energy += -1.065 * factor;
543  else if (runnum >= 1101 && runnum <= 1248) energy += -0.608 * factor;
544  else if (runnum >= 1257 && runnum <= 1399) energy += -1.132 * factor;
545  else if (runnum >= 1400 && runnum <= 1599) energy += -1.446 * factor;
546  else if (runnum >= 1600 && runnum <= 1799) energy += -1.836 * factor;
547  else if (runnum >= 1800 && runnum <= 1999) energy += -1.829 * factor;
548  else if (runnum >= 2000 && runnum <= 2156) energy += -1.732 * factor;
549  else if (runnum >= 2294 && runnum <= 2599) energy += -2.318 * factor;
550  else if (runnum >= 2600 && runnum <= 2865) energy += -1.363 * factor;
551  } else if (expnum == 9) {
552  if (runnum >= 17 && runnum <= 399) energy += -2.767 * factor;
553  else if (runnum >= 400 && runnum <= 499) energy += -2.826 * factor;
554  else if (runnum >= 500 && runnum <= 593) energy += -2.311 * factor;
555  else if (runnum >= 601 && runnum <= 699) energy += -2.138 * factor;
556  else if (runnum >= 700 && runnum <= 899) energy += -2.267 * factor;
557  else if (runnum >= 900 && runnum <= 999) energy += -2.412 * factor;
558  else if (runnum >= 1000 && runnum <= 1099) energy += -2.229 * factor;
559  else if (runnum >= 1100 && runnum <= 1220) energy += -1.842 * factor;
560  //new(2001/06/23)
561  } else if (expnum == 11) {
562  if (runnum >= 1 && runnum <= 161) energy += -2.173 * factor;
563  if (runnum >= 261 && runnum <= 399) energy += -1.392 * factor;
564  if (runnum >= 400 && runnum <= 499) energy += -1.321 * factor;
565  if (runnum >= 500 && runnum <= 599) energy += -1.394 * factor;
566  if (runnum >= 600 && runnum <= 699) energy += -1.827 * factor;
567  if (runnum >= 700 && runnum <= 799) energy += -1.912 * factor;
568  if (runnum >= 800 && runnum <= 899) energy += -1.603 * factor;
569  if (runnum >= 900 && runnum <= 998) energy += -1.759 * factor;
570  if (runnum >= 1001 && runnum <= 1099) energy += -1.915 * factor;
571  if (runnum >= 1100 && runnum <= 1199) energy += -1.513 * factor;
572  if (runnum >= 1200 && runnum <= 1287) energy += -0.639 * factor;
573  } else if (expnum == 13) {
574  if (runnum >= 1 && runnum <= 99) energy += 0.279 * factor;
575  if (runnum >= 100 && runnum <= 198) energy += 0.140 * factor;
576  if (runnum >= 200 && runnum <= 297) energy += -0.095 * factor;
577  if (runnum >= 301 && runnum <= 440) energy += 0.232 * factor;
578  if (runnum >= 551 && runnum <= 699) energy += -0.385 * factor;
579  if (runnum >= 700 && runnum <= 799) energy += -0.654 * factor;
580  if (runnum >= 800 && runnum <= 899) energy += -0.972 * factor;
581  if (runnum >= 900 && runnum <= 999) energy += -0.770 * factor;
582  if (runnum >= 1000 && runnum <= 1099) energy += -0.353 * factor;
583  if (runnum >= 1100 && runnum <= 1199) energy += -0.490 * factor;
584  if (runnum >= 1200 && runnum <= 1299) energy += -0.687 * factor;
585  if (runnum >= 1300 && runnum <= 1399) energy += -0.545 * factor;
586  //if ( runnum >=1400 && runnum <=1523 ) energy += -0.783*factor;
587  if (runnum >= 1400) energy += -0.783 * factor;
588  // there isn't sufficient amount of data between 1589..1623 (0.1 fb-1),
589  // so we decided to take the value of last run range, which should be
590  // better than 0 correction. (c.f. dcpvrare_ml:0146 and 0147)
591 
592  } else if (expnum == 15) {
593  // // new February 15, 2002
594  // if(runnum < 764 ) energy = 5.288103;
595  // if(runnum > 763 && runnum < 951 ) energy = 5.286505;
596  // if(runnum > 950 ) energy = 5.287404;
597  // new February 20, 2002
598  if (runnum < 764) energy = 5.288103;
599  if (runnum > 763 && runnum < 951) energy = 5.287005;
600  if (runnum > 950 && runnum < 1251) energy = 5.287804;
601  if (runnum > 1250) energy = 5.288603;
602 
603  } else if (expnum == 17) {
604  if (runnum <= 199) energy = 5.288702;
605  if (runnum >= 200 && runnum <= 399) energy = 5.289202;
606  if (runnum >= 400 && runnum <= 485) energy = 5.289401;
607  if (runnum >= 545 && runnum <= 799) energy = 5.289501;
608  if (runnum >= 800 && runnum <= 937) energy = 5.289401;
609 
610  } else if (expnum == 19) {
611  if (runnum >= 64 && runnum <= 199) energy = 5.2887023;
612  if (runnum >= 200 && runnum <= 299) energy = 5.2886025;
613  if (runnum >= 300 && runnum <= 399) energy = 5.28830299;
614  if (runnum >= 400 && runnum <= 459) energy = 5.28820313;
615  if (runnum >= 461 && runnum <= 599) energy = 5.28830299;
616  if (runnum >= 600 && runnum <= 666) energy = 5.28780366;
617  if (runnum >= 763 && runnum <= 999) energy = 5.28820313;
618  if (runnum >= 1000 && runnum <= 1099) energy = 5.28780366;
619  if (runnum >= 1100 && runnum <= 1199) energy = 5.28770378;
620  if (runnum >= 1200 && runnum <= 1399) energy = 5.28750402;
621  if (runnum >= 1400 && runnum <= 1499) energy = 5.28740413;
622  if (runnum >= 1500 && runnum <= 1599) energy = 5.28720434;
623  if (runnum >= 1600 && runnum <= 1643) energy = 5.28760390;
624 
625 
626  // Dec 28th, 2002
627 
628  } else if (expnum == 21) {
629  if (runnum >= 0 && runnum <= 180) energy = 5.28650496;
630  if (runnum >= 181 && runnum <= 324) energy = 5.2880034;
631  } else if (expnum == 23) {
632  if (runnum >= 0 && runnum <= 238) energy = 5.28860254;
633  if (runnum >= 357 && runnum <= 607) energy = 5.28880222;
634 
635  //May 31st, 2003
636 
637  } else if (expnum == 25) {
638  if (runnum >= 0 && runnum <= 99) energy = 5.28950099;
639  if (runnum >= 100 && runnum <= 199) energy = 5.28870238;
640  if (runnum >= 200 && runnum <= 299) energy = 5.28910171;
641  if (runnum >= 300 && runnum <= 399) energy = 5.28890205;
642  if (runnum >= 400 && runnum <= 799) energy = 5.28850269;
643  if (runnum >= 800 && runnum <= 899) energy = 5.28790353;
644  if (runnum >= 900 && runnum <= 999) energy = 5.28810326;
645  if (runnum >= 1000 && runnum <= 1099) energy = 5.28830298;
646  if (runnum >= 1100 && runnum <= 1199) energy = 5.28820313;
647  if (runnum >= 1200 && runnum <= 1299) energy = 5.28780366;
648  if (runnum >= 1300 && runnum <= 1462) energy = 5.28820313;
649  if (runnum >= 1600 && runnum <= 1699) energy = 5.28830299;
650  if (runnum >= 1700 && runnum <= 1799) energy = 5.28780366;
651  if (runnum >= 1800 && runnum <= 1899) energy = 5.28810327;
652  if (runnum >= 1900 && runnum <= 2122) energy = 5.28830299;
653 
654  //June 30th , 2003
655 
656  } else if (expnum == 27) {
657  if (runnum >= 0 && runnum <= 180) energy = 5.28860254;
658  if (runnum >= 181 && runnum <= 288) energy = 5.28870238;
659  if (runnum >= 367 && runnum <= 499) energy = 5.28880222;
660  if (runnum >= 500 && runnum <= 590) energy = 5.28890206;
661  if (runnum >= 591 && runnum <= 699) energy = 5.28910172;
662  if (runnum >= 700 && runnum <= 1079) energy = 5.28900189;
663  if (runnum >= 1252 && runnum <= 1299) energy = 5.28850269;
664  if (runnum >= 1300 && runnum <= 1632) energy = 5.28870238;
665 
666  //March 9th , 2004
667 
668  } else if (expnum == 31) {
669  if (runnum >= 0 && runnum <= 166) energy = 5.287404131;
670  if (runnum >= 231 && runnum <= 470) energy = 5.287903534;
671  if (runnum >= 471 && runnum <= 698) energy = 5.28810327;
672  if (runnum >= 699 && runnum <= 804) energy = 5.288602541;
673  if (runnum >= 805 && runnum <= 936) energy = 5.288702384;
674  if (runnum >= 1071 && runnum <= 1440) energy = 5.288902;
675  if (runnum >= 1441 && runnum <= 1715) energy = 5.289301;
676 
677  } else if (expnum >= 32) {
678  B2ERROR("Warning: Benergy is not ready for exp >=32.");
679  }
680  return energy;
681  }
682 
684 } // namespace Belle
Belle2::B2BIIFixMdstModule::m_limit_mdst_klm_cluster_hit
int m_limit_mdst_klm_cluster_hit
Limit of mdst_klm_cluster_hit table size.
Definition: B2BIIFixMdstModule.h:167
Belle2::B2BIIFixMdstModule::m_mapped_expno
int m_mapped_expno
Mapped value of m_old_exp_no.
Definition: B2BIIFixMdstModule.h:193
Belle2::B2BIIFixMdstModule::m_correct_ecl_option
int m_correct_ecl_option
Apply correct_ecl_option.
Definition: B2BIIFixMdstModule.h:146
Belle2::B2BIIFixMdstModule::add_extra_trk_vee2
int add_extra_trk_vee2()
Add Mdst_trk_extra and Mdst_vee_extra to Mdst_trk and Mdst_vee2, respectively.
Definition: B2BIIFixMdstModule_trk.cc:3064
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::B2BIIFixMdstModule::m_scale_error_dataset_name
std::string m_scale_error_dataset_name
Set scale_error_dataset name.
Definition: B2BIIFixMdstModule.h:143
Belle2::B2BIIFixMdstModule::shift_tof
void shift_tof(const int mode)
Shift tof times to account for residuals.
Definition: B2BIIFixMdstModule_tof.cc:52
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::B2BIIFixMdstModule::initialize
virtual void initialize() override
Initialize the module.
Definition: B2BIIFixMdstModule.cc:214
Belle2::B2BIIFixMdstModule::m_reprocess_version_specified
int m_reprocess_version_specified
Specify reprocess version.
Definition: B2BIIFixMdstModule.h:169
Belle2::B2BIIFixMdstModule::s_benergy_value
static double s_benergy_value
Beam energy.
Definition: B2BIIFixMdstModule.h:158
Belle2::B2BIIFixMdstModule::remove_extra_trk_vee2
int remove_extra_trk_vee2()
Remove extra tracks from Mdst_trk and Mdst_vee2.
Definition: B2BIIFixMdstModule_trk.cc:3240
Belle2::B2BIIFixMdstModule::m_check_version_consistency
int m_check_version_consistency
Check consistency between environment variable and mdst version.
Definition: B2BIIFixMdstModule.h:171
Belle2::B2BIIFixMdstModule::m_scale_momenta_scale_data
float m_scale_momenta_scale_data
Set parameter scale_data for scale_momenta.
Definition: B2BIIFixMdstModule.h:138
Belle2::B2BIIFixMdstModule::Muid_event
void Muid_event(void)
Called for each event.
Definition: B2BIIFixMdstModule_muid.cc:129
Belle2::B2BIIFixMdstModule::m_scale_momenta_scale_mc
float m_scale_momenta_scale_mc
Set parameter scale_mc for scale_momenta.
Definition: B2BIIFixMdstModule.h:139
Belle2::B2BIIFixMdstModule::m_correct_ecl_primary_vertex
int m_correct_ecl_primary_vertex
Apply correct_ecl_primary_vertex.
Definition: B2BIIFixMdstModule.h:148
Belle2::B2BIIFixMdstModule::m_make_pi0
int m_make_pi0
Apply make_pi0 (after correct_ecl)
Definition: B2BIIFixMdstModule.h:150
Belle2::B2BIIFixMdstModule::m_reprocess_version
int m_reprocess_version
Reprocess version (=0:old; =1:new)
Definition: B2BIIFixMdstModule.h:168
Belle2::B2BIIFixMdstModule::m_correct_ecl
int m_correct_ecl
Apply correct_ecl.
Definition: B2BIIFixMdstModule.h:145
Belle2::B2BIIFixMdstModule::m_correct_ecl_version
int m_correct_ecl_version
Apply correct_ecl_version.
Definition: B2BIIFixMdstModule.h:147
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::B2BIIFixMdstModule::B2BIIFixMdstModule
B2BIIFixMdstModule()
Constructor.
Definition: B2BIIFixMdstModule.cc:159
Belle2::B2BIIFixMdstModule::m_correct_ecl_5s
int m_correct_ecl_5s
For run indep.
Definition: B2BIIFixMdstModule.h:149
Belle2::B2BIIFixMdstModule::m_benergy_mcdb
int m_benergy_mcdb
Apply Benergy from DB or default value in MC.
Definition: B2BIIFixMdstModule.h:157
Belle2::B2BIIFixMdstModule::m_make_pi0_option
int m_make_pi0_option
Set make_pi0 option.
Definition: B2BIIFixMdstModule.h:151
Belle2::B2BIIFixMdstModule::m_calib_dedx
int m_calib_dedx
Do dedx calibration.
Definition: B2BIIFixMdstModule.h:163
Belle2::B2BIIFixMdstModule::m_make_pi0_upper_limit
double m_make_pi0_upper_limit
Set make_pi0 upper mass limit.
Definition: B2BIIFixMdstModule.h:153
Belle2::B2BIIFixMdstModule::Muid_begin_run
void Muid_begin_run(const int, const int, const int)
Called for each new run.
Definition: B2BIIFixMdstModule_muid.cc:101
Belle2::B2BIIFixMdstModule::Benergy
double Benergy(int expnum=0, int runnum=0)
Return Beam energy.
Definition: B2BIIFixMdstModule.cc:509
Belle2::B2BIIFixMdstModule::Muid_init
void Muid_init(void)
Initialize the Muid module.
Definition: B2BIIFixMdstModule_muid.cc:59
Belle2::B2BIIFixMdstModule::correct_ecl
void correct_ecl(int, int)
Correct photon's momenta and error matrix.
Definition: B2BIIFixMdstModule_ecl.cc:1220
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
NOMINAL_ENERGY
#define NOMINAL_ENERGY
Nomial beam energy.
Definition: B2BIIFixMdstModule.cc:155
Belle2::B2BIIFixMdstModule::event
virtual void event() override
Called for each event.
Definition: B2BIIFixMdstModule.cc:224
Belle2::B2BIIFixMdstModule::m_use_ecl
int m_use_ecl
parameter UseECL: Use (1) or don't use (0) ECL in muid (default=0)
Definition: B2BIIFixMdstModule.h:180
Belle2::B2BIIFixMdstModule::m_scale_error
int m_scale_error
Apply scale_error.
Definition: B2BIIFixMdstModule.h:141
Belle2::B2BIIFixMdstModule::m_eklm_max_layer
int m_eklm_max_layer
parameter Endcap_MX_layer: Max layer # of KLM endcap (default=11) 0 ==> use same value as was used by...
Definition: B2BIIFixMdstModule.h:178
Belle2::B2BIIFixMdstModule::terminate
virtual void terminate() override
Terminates the module.
Definition: B2BIIFixMdstModule.cc:219
Belle2::B2BIIFixMdstModule::m_smear_trk
int m_smear_trk
Do extra-smearing for MC tracks.
Definition: B2BIIFixMdstModule.h:142
Belle2::B2BIIFixMdstModule::m_good_event
int m_good_event
Select good event only.
Definition: B2BIIFixMdstModule.h:159
Belle2::B2BIIFixMdstModule::fix_pi0_brecon
void fix_pi0_brecon(void)
Fix relation gamma<->pi0 in brecon table.
Definition: B2BIIFixMdstModule_brecon.cc:29
Belle2::Module::setReturnValue
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:222
Belle2::B2BIIFixMdstModule::get_reprocess_version
int get_reprocess_version()
Get reprocess version of input mdst.
Definition: B2BIIFixMdstModule.cc:391
Belle2::B2BIIFixMdstModule::scale_error
void scale_error(const int message_level=0)
Apply scale error.
Definition: B2BIIFixMdstModule_trk.cc:2879
Belle2::B2BIIFixMdstModule::Muid_term
void Muid_term(void)
Terminate the Muid module.
Definition: B2BIIFixMdstModule_muid.cc:88
Belle2::B2BIIFixMdstModule::m_add_or_remove_extra_trk_vee2
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
Definition: B2BIIFixMdstModule.h:144
Belle2::B2BIIFixMdstModule::m_hadron_b_only
int m_hadron_b_only
Select Hadron B event only.
Definition: B2BIIFixMdstModule.h:161
Belle2::B2BIIFixMdstModule::make_pi0
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...
Definition: B2BIIFixMdstModule_ecl.cc:1563
Belle2::B2BIIFixMdstModule::m_shift_tof_mode
int m_shift_tof_mode
Do tof_correction.
Definition: B2BIIFixMdstModule.h:164
Belle2::B2BIIFixMdstModule::m_make_pi0_lower_limit
double m_make_pi0_lower_limit
Set make_pi0 lower mass limit.
Definition: B2BIIFixMdstModule.h:152
Belle2::B2BIIFixMdstModule::m_benergy
int m_benergy
Apply Benergy.
Definition: B2BIIFixMdstModule.h:155
Belle2::Module::addParam
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:562
Belle2::B2BIIFixMdstModule::m_make_pi0_primary_vertex
int m_make_pi0_primary_vertex
Apply make_pi0_primary_vertex (after correct_ecl)
Definition: B2BIIFixMdstModule.h:154
Belle2::B2BIIFixMdstModule::m_limit_mdst_ecl_trk
int m_limit_mdst_ecl_trk
Limit of mdst_ecl_trk table size.
Definition: B2BIIFixMdstModule.h:166
Belle2::B2BIIFixMdstModule::set_primary_vertex
int set_primary_vertex(HepPoint3D &v, CLHEP::HepSymMatrix &ve)
Set primary vertex assuming all tracks are pions.
Definition: B2BIIFixMdstModule_trk.cc:2921
HepGeom::Point3D< double >
Belle2::B2BIIFixMdstModule::m_scale_momenta
int m_scale_momenta
Apply scale_momenta.
Definition: B2BIIFixMdstModule.h:133
Belle2::B2BIIFixMdstModule::m_5Srun
int m_5Srun
5S,2S,1S run or not
Definition: B2BIIFixMdstModule.h:170
Belle2::B2BIIFixMdstModule::correct_ecl_primary_vertex
void correct_ecl_primary_vertex(const HepPoint3D &, const CLHEP::HepSymMatrix &)
Correct ecl using primary vertex.
Definition: B2BIIFixMdstModule_ecl.cc:2270
Belle2::B2BIIFixMdstModule::good_event
bool good_event()
Check if event correspondes to the period when Belle detector not in good condition.
Definition: B2BIIFixMdstModule.cc:478
Belle2::B2BIIFixMdstModule::m_hadron_a_only
int m_hadron_a_only
Select Hadron A event only.
Definition: B2BIIFixMdstModule.h:160
Belle2::B2BIIFixMdstModule::scale_momenta
void scale_momenta(float scale_data=1.0, float scale_mc=1.0, int mode=0)
Scale momenta of Mdst_trk.
Definition: B2BIIFixMdstModule_trk.cc:270
Belle2::B2BIIFixMdstModule::m_table_size
int m_table_size
Check table sizes.
Definition: B2BIIFixMdstModule.h:165
Belle2::B2BIIFixMdstModule::m_benergy_db
int m_benergy_db
Apply Benergy from DB or file.
Definition: B2BIIFixMdstModule.h:156
Belle2::B2BIIFixMdstModule::m_expno
int m_expno
parameter ExpNo: Experiment number for muid (default=0) 0 ==> use experiment number stored in data fi...
Definition: B2BIIFixMdstModule.h:185
Belle2::B2BIIFixMdstModule::m_l4passed_only
int m_l4passed_only
Select level4-passed event only.
Definition: B2BIIFixMdstModule.h:162
Belle2::B2BIIFixMdstModule::smear_trk
void smear_trk()
Apply track smearing (on MC)
Definition: B2BIIFixMdstModule_trk.cc:3339
Belle2::B2BIIFixMdstModule::m_scale_momenta_mode
int m_scale_momenta_mode
Set parameter mode for scale_momenta.
Definition: B2BIIFixMdstModule.h:140
Belle2::B2BIIFixMdstModule::make_pi0_primary_vertex
void make_pi0_primary_vertex(int, double, double, const HepPoint3D &, const CLHEP::HepSymMatrix &)
Fill Mdst_pi0 based on the fit result.
Definition: B2BIIFixMdstModule_ecl.cc:1816
Belle2::B2BIIFixMdstModule::beginRun
virtual void beginRun() override
Called when a new run is started.
Definition: B2BIIFixMdstModule.cc:348