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