Belle II Software development
B2BIIFixMdstModule_trk.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_trk.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.47 2006/05/29
17// scale_error for exp. 45,47,49
18//
19// Revision 1.46 2005/07/28 09:55:00 hitoshi
20// for exp43 run700-1149 (by Senyo)
21//
22// Revision 1.45 2005/07/02 08:07:48 hitoshi
23// for exp43 run300-699 (by Senyo)
24//
25// Revision 1.44 2005/06/06 04:28:01 katayama
26// New for exp. 43 run - 300 from Miyabayasi and Senyo san
27//
28// Revision 1.43 2005/05/14 03:47:34 hitoshi
29// scale error for exp39 and 41 (by Kusaka)
30//
31// Revision 1.42 2005/04/17 09:43:56 hitoshi
32// for Exp41 r1200-end (by Senyo)
33//
34// Revision 1.41 2005/04/15 05:49:28 hitoshi
35// for Exp41 r800-1199 (by Senyo)
36//
37// Revision 1.40 2005/03/31 10:45:30 hitoshi
38// for Exp41 runno<=799 (by Senyo)
39//
40// Revision 1.39 2005/03/08 06:10:02 hitoshi
41// scale_momenta for Exp39 (by Senyo)
42//
43// Revision 1.38 2004/07/26 03:29:46 katayama
44// scale_error for exp. 37
45//
46// Revision 1.37 2004/07/14 07:34:17 katayama
47// added cassert
48//
49// Revision 1.36 2004/07/12 08:27:04 hitoshi
50// scale error for svd2 (by kusaka)
51//
52// Revision 1.35 2004/07/12 05:25:06 hitoshi
53// scale momenta for exp37 r1400-end (by senyo)
54//
55// Revision 1.34 2004/07/09 05:39:37 hitoshi
56// protection for mis-use for exp>=30
57//
58// Revision 1.33 2004/07/09 04:36:07 hitoshi
59// scale momenta for exp37 run1-1399 (by senyo)
60//
61// Revision 1.32 2004/06/23 19:06:55 hitoshi
62// scale momenta for exp31 (by Senyo)
63//
64// Revision 1.31 2004/06/16 06:48:36 hitoshi
65// scale momenta for exp35 (by Senyo san)
66//
67// Revision 1.30 2004/06/06 03:20:47 hitoshi
68// scale momenta for exp33 (by senyo)
69//
70// Revision 1.29 2004/04/25 16:33:33 hitoshi
71// modified to be able to handle output from low p finder (by kakuno). modified
72// Benergy to fetch data from DB (by Shibata).
73//
74// Revision 1.28 2004/03/09 04:46:00 hitoshi
75// scale momenta for exp31 run1100-end by Senyo
76//
77// Revision 1.27 2004/03/01 03:12:42 hitoshi
78// scale_momenta for exp31 upto run1099 (by Senyo).
79//
80// Revision 1.26 2003/07/31 07:47:58 katayama
81// New version from Higuhi san
82//
83// Revision 1.25 2003/07/11 08:41:23 hitoshi
84// fixed a bug.
85//
86// Revision 1.24 2003/07/11 06:41:22 katayama
87// for exp. 27 continuum
88//
89// Revision 1.23 2003/07/10 13:45:38 hitoshi
90// update for exp27 run700- (by Sanjay and Senyo).
91//
92// Revision 1.22 2003/06/30 22:16:29 hitoshi
93// update for exp27 (by Miyabayashi, Sanjay, Senyo).
94//
95// Revision 1.21 2003/06/24 07:55:17 katayama
96// Remived unused parameters
97//
98// Revision 1.20 2003/06/24 07:38:25 katayama
99// added cstdio
100//
101// Revision 1.19 2003/06/18 12:22:02 katayama
102// cannot compile with gcc3
103//
104// Revision 1.18 2003/06/12 13:25:43 hitoshi
105// scale_error implemented last year (by Higuchi; valid up to exp19) is incorporated
106//
107// Revision 1.17 2003/05/31 09:22:54 hitoshi
108// update for exp25 (ny Miyabayashi and Senyo).
109//
110// Revision 1.16 2002/12/26 13:35:01 katayama
111// scale_momenta for exp. 21 and 23 from Senyo san
112//
113// Revision 1.15 2002/10/12 15:33:07 hitoshi
114// A bug fix: 1.46 -> 14.6kG (pointed out by N.root). Negligible effect on V0 mass.
115//
116// Revision 1.14 2002/07/04 21:06:44 katayama
117// Final version
118//
119// Revision 1.13 2002/07/03 04:50:54 hitoshi
120// scale_momenta for exp19 run900 - 1499 (by Senyo san).
121//
122// Revision 1.12 2002/06/22 09:40:59 katayama
123// From Senyo san, for exp. 9 and exp.19 899
124//
125// Revision 1.11 2002/06/19 12:10:36 katayama
126// New for exp. 7 from Senyo and Miyabayashi sans
127//
128// Revision 1.10 2002/06/13 00:40:08 hitoshi
129// added scale momenta factors (from Senyo) for run1000 - end.
130//
131// Revision 1.9 2002/06/07 11:54:42 hitoshi
132// added scale_momenta for run 1 - 999 in e11.
133//
134// Revision 1.8 2002/06/04 06:36:34 hitoshi
135// added scale momenta for e19 runs300-459 (by Senyo).
136//
137// Revision 1.7 2002/05/29 07:15:14 hitoshi
138// added scale momnta factors for exp19 run1-280.
139//
140// Revision 1.6 2002/05/24 13:27:45 hitoshi
141// added scale_momenta for exp13 reprocessed data (by Senyo san).
142//
143// Revision 1.5 2002/05/08 12:12:54 hitoshi
144// added scale_momenta factors for exp17 (by Senyo san).
145//
146// Revision 1.4 2002/04/23 15:11:55 hitoshi
147// new scale factors for e15 mdst reprocessed with 20020405.
148//
149// Revision 1.3 2002/04/19 07:24:39 katayama
150// Added pi0/vertex, calibdedx
151//
152// Revision 1.2 2002/04/05 01:19:33 katayama
153// templates for ecl_primary_vertex
154//
155// Revision 1.1 2002/03/13 02:55:20 katayama
156// First version
157//
158//
159
160#include <b2bii/modules/B2BIIMdstInput/B2BIIFixMdstModule.h>
161
162#include <cstdio>
163#include <cmath>
164#include <cfloat>
165#include <cassert>
166
167#include "CLHEP/Vector/ThreeVector.h"
168#include "CLHEP/Matrix/Vector.h"
169#include <TRandom.h>
170
171#include "belle_legacy/helix/Helix.h"
172
173#include "belle_legacy/tables/mdst.h"
174#include "belle_legacy/tables/belletdf.h"
175#include "belle_legacy/tables/evtvtx.h"
176#include "belle_legacy/ip/IpProfile.h"
177
178// kfitter
179#include <analysis/VertexFitting/KFit/VertexFitKFit.h>
180
181namespace Belle2 {
188//==========================================================
189 double B2BIIFixMdstModule::vee_mass_nofit(const Belle::Mdst_vee2& vee2, float scale)
190 {
191//==========================================================
192// Calculates V^0 mass with non-constraint fit results.
193//==========================================================
194
195 HepPoint3D vtx(vee2.vx(), vee2.vy(), vee2.vz());
196
197 const double pion_mass = 0.13956995;
198 const double proton_mass = 0.93827231;
199 const double electron_mass = 0.000511;
200
201 double massp(0.0), massm(0.0);
202 if (1 == vee2.kind()) {
203 massp = pion_mass;
204 massm = pion_mass;
205 } else if (2 == vee2.kind()) {
206 massp = proton_mass;
207 massm = pion_mass;
208 } else if (3 == vee2.kind()) {
209 massp = pion_mass;
210 massm = proton_mass;
211 } else if (4 == vee2.kind()) {
212 massp = electron_mass;
213 massm = electron_mass;
214 }
215
216//Calculate mass
217//in case where decay vtx is outside of beam pipe
218 // if(BsCouTab(MDST_VEE_DAUGHTERS)) {
219 if (vee2.daut()) {
220
221 Belle::Mdst_vee_daughters& vdau = vee2.daut();
222
223 CLHEP::HepVector a(5);
224 a[0] = vdau.helix_p(0); a[1] = vdau.helix_p(1);
225 a[2] = vdau.helix_p(2) / scale;
226 a[3] = vdau.helix_p(3); a[4] = vdau.helix_p(4);
227 Belle::Helix helixp(vtx, a);
228
229 a[0] = vdau.helix_m(0); a[1] = vdau.helix_m(1);
230 a[2] = vdau.helix_m(2) / scale;
231 a[3] = vdau.helix_m(3); a[4] = vdau.helix_m(4);
232 Belle::Helix helixm(vtx, a);
233 // dout(Debugout::DDEBUG,"B2BIIFixMdst_trk") << "outside bp" << std::endl;
234 CLHEP::HepLorentzVector v0 = helixp.momentum(0., massp) + helixm.momentum(0., massm);
235 return v0.mag();
236
237//in case where decay vtx is inside of beam pipe
238 } else {
239
240 Belle::Mdst_charged& chargedp = vee2.chgd(0);
241 Belle::Mdst_trk& trkp = chargedp.trk();
242 Belle::Mdst_trk_fit& trkfp = trkp.mhyp(2);
243 HepPoint3D pvtp(trkfp.pivot_x(), trkfp.pivot_y(), trkfp.pivot_z());
244 CLHEP::HepVector a(5);
245 a[0] = trkfp.helix(0); a[1] = trkfp.helix(1);
246 a[2] = trkfp.helix(2);
247 a[3] = trkfp.helix(3); a[4] = trkfp.helix(4);
248 Belle::Helix helixp(pvtp, a);
249 helixp.bFieldZ(14.6);
250 helixp.pivot(vtx);
251 a = helixp.a();
252 a[2] = a[2] / scale;
253 helixp.a(a);
254
255 Belle::Mdst_charged& chargedm = vee2.chgd(1);
256 Belle::Mdst_trk& trkm = chargedm.trk();
257 Belle::Mdst_trk_fit& trkfm = trkm.mhyp(2);
258 HepPoint3D pvtm(trkfm.pivot_x(), trkfm.pivot_y(), trkfm.pivot_z());
259 a[0] = trkfm.helix(0); a[1] = trkfm.helix(1);
260 a[2] = trkfm.helix(2);
261 a[3] = trkfm.helix(3); a[4] = trkfm.helix(4);
262 Belle::Helix helixm(pvtm, a);
263 helixm.bFieldZ(14.6);
264 helixm.pivot(vtx);
265 a = helixm.a();
266 a[2] = a[2] / scale;
267 helixm.a(a);
268 // dout(Debugout::DDEBUG,"B2BIIFixMdst_trk") << "inside bp" << std::endl;
269 CLHEP::HepLorentzVector v0 = helixp.momentum(0., massp) + helixm.momentum(0., massm);
270 return v0.mag();
271
272 }
273
274 }
275
276//===============================================================
277 void B2BIIFixMdstModule::scale_momenta(float scale_data, float scale_mc, int mode)
278 {
279//===============================================================
280// Scales charged track momenta, track params. and error
281// matrices.
282//======================================================
283
284 // dout(Debugout::DDEBUG,"B2BIIFixMdst_trk") << "sacel momenta is called" << std::endl;
285
286//Check existence of belle_event
287 Belle::Belle_event_Manager& evtmgr = Belle::Belle_event_Manager::get_manager();
288 // dout(Debugout::DDEBUG,"B2BIIFixMdst_trk") << evtmgr.count() << std::endl;
289 if (0 == evtmgr.count()) return; //do nothing if not exist
290 // dout(Debugout::DDEBUG,"B2BIIFixMdst_trk") << "after check" << std::endl;
291
292 Belle::Mdst_event_add_Manager& mevtmgr = Belle::Mdst_event_add_Manager::get_manager();
293 if (mevtmgr.count() > 0 && 1 == mevtmgr[0].flag_scale()) return; //do nothing if already scaled
294
295//check mode
296 if (mode < 0 || mode > 2) {
297 B2ERROR("scale_momenta: invalid mode specified;");
298 B2ERROR("mode must be 0, 1, 2");
299 return;
300 }
301
302//set scale factor
303 int expmc = evtmgr[0].ExpMC();
304 int expno = evtmgr[0].ExpNo();
305 int runno = evtmgr[0].RunNo();
306
307 double scale = 1.;
308 if (1 == expmc) {
309 if (mode == 0) {
310 scale = scale_data;
311 } else {
312 // scale_momenta_set( mode, expno, runno, scale);
313 if (m_reprocess_version == 0) {
314 scale_momenta_set_v1(mode, expno, runno, scale);
315 } else if (m_reprocess_version == 1) {
316 scale_momenta_set_v2(mode, expno, runno, scale);
317 }
318 }
319 } else if (2 == expmc) {
320 scale = scale_mc;
321 }
322
323 if (1. == scale) return; //do nothing if scale=1
324 // dout(Debugout::DDEBUG,"B2BIIFixMdst_trk") << scale << std::endl;
325
326//Turn on flag, save scale factor
327 if (mevtmgr.count() > 0) {
328 mevtmgr[0].flag_scale(1);
329 mevtmgr[0].scale(scale);
330 } else {
331 Belle::Mdst_event_add& meadd = mevtmgr.add();
332 meadd.flag_scale(1);
333 meadd.scale(scale);
334 }
335 // dout(Debugout::DDEBUG,"B2BIIFixMdst_trk") << mevtmgr[0].flag_scale() << std::endl;
336 // dout(Debugout::DDEBUG,"B2BIIFixMdst_trk") << mevtmgr[0].scale() << std::endl;
337
338
339//Scale momenta in mdst_charged
340 Belle::Mdst_charged_Manager& chgmgr = Belle::Mdst_charged_Manager::get_manager();
341 for (std::vector<Belle::Mdst_charged>::iterator it = chgmgr.begin();
342 it != chgmgr.end(); ++it) {
343 Belle::Mdst_charged& charged = *it;
344 charged.px(scale * charged.px());
345 charged.py(scale * charged.py());
346 charged.pz(scale * charged.pz());
347 }
348
349//Scale momenta in mdst_vee2
350 Belle::Mdst_vee2_Manager& vee2mgr = Belle::Mdst_vee2_Manager::get_manager();
351 for (std::vector<Belle::Mdst_vee2>::iterator it = vee2mgr.begin();
352 it != vee2mgr.end(); ++it) {
353 Belle::Mdst_vee2& vee2 = *it;
354 double v0mass_scale = vee_mass_nofit(vee2, scale);
355 double v0mass_noscl = vee_mass_nofit(vee2);
356 double esq_scale =
357 (v0mass_scale - v0mass_noscl) * (v0mass_scale + v0mass_noscl)
358 + vee2.energy() * vee2.energy() +
359 (scale - 1.) * (scale + 1.) * (vee2.px() * vee2.px() +
360 vee2.py() * vee2.py() +
361 vee2.pz() * vee2.pz());
362 vee2.energy(std::sqrt(esq_scale));
363 vee2.px(scale * vee2.px());
364 vee2.py(scale * vee2.py());
365 vee2.pz(scale * vee2.pz());
366 }
367
368//Scale error matrices in mdst_trk_fit
369 double scalei = 1. / scale;
370 double scalei2 = scalei / scale;
371
372 Belle::Mdst_trk_fit_Manager& trkfmgr = Belle::Mdst_trk_fit_Manager::get_manager();
373 for (std::vector<Belle::Mdst_trk_fit>::iterator it = trkfmgr.begin();
374 it != trkfmgr.end(); ++it) {
375 Belle::Mdst_trk_fit& trkf = *it;
376 trkf.helix(2, scalei * trkf.helix(2));
377 trkf.error(3, scalei * trkf.error(3));
378 trkf.error(4, scalei * trkf.error(4));
379 trkf.error(5, scalei2 * trkf.error(5));
380 trkf.error(8, scalei * trkf.error(8));
381 trkf.error(12, scalei * trkf.error(12));
382 }
383
384//Scale error matrices in mdst_daughters
385 Belle::Mdst_vee_daughters_Manager& vdaumgr = Belle::Mdst_vee_daughters_Manager::get_manager();
386 for (std::vector<Belle::Mdst_vee_daughters>::iterator it = vdaumgr.begin();
387 it != vdaumgr.end(); ++it) {
388 Belle::Mdst_vee_daughters& vdau = *it;
389 vdau.helix_p(2, scalei * vdau.helix_p(2));
390 vdau.error_p(3, scalei * vdau.error_p(3));
391 vdau.error_p(4, scalei * vdau.error_p(4));
392 vdau.error_p(5, scalei2 * vdau.error_p(5));
393 vdau.error_p(8, scalei * vdau.error_p(8));
394 vdau.error_p(12, scalei * vdau.error_p(12));
395
396 vdau.helix_m(2, scalei * vdau.helix_m(2));
397 vdau.error_m(3, scalei * vdau.error_m(3));
398 vdau.error_m(4, scalei * vdau.error_m(4));
399 vdau.error_m(5, scalei2 * vdau.error_m(5));
400 vdau.error_m(8, scalei * vdau.error_m(8));
401 vdau.error_m(12, scalei * vdau.error_m(12));
402 }
403 }
404
405//=====================================================================
406 void B2BIIFixMdstModule::scale_momenta_set(const int mode, const int expno,
407 const int runno, double& scale)
408 {
409//=====================================================================
410
411 scale = 1.;
412
413 if (mode == 1) {
414 //factors for 2001 summer confs. analyses
415 if (expno == 7) {scale = 1.001932; return;}
416 if (expno == 9) {scale = 1.001413; return;}
417 if (expno == 11) {scale = 1.001366; return;}
418 // if(expno==13) {scale = 1.000909; return;} //for '01 summer conf. papers; using up to run400
419 if (expno == 13) {scale = 1.001460; return;} //updated factor using up to run1599
420 if (expno >= 15) {B2ERROR("scale_momenta mode=1: not ready for exp >=15");}
421 }
422
423 if (mode == 2) {
424 if (expno == 7) {
425 if (runno >= 0 && runno <= 99) {scale = 1.00262126; return;}
426 if (runno >= 100 && runno <= 199) {scale = 1.00253537; return;}
427 if (runno >= 200 && runno <= 299) {scale = 1.00246555; return;}
428 if (runno >= 300 && runno <= 399) {scale = 1.0026452 ; return;}
429 if (runno >= 400 && runno <= 499) {scale = 1.00290386; return;}
430 if (runno >= 500 && runno <= 599) {scale = 1.00287753; return;}
431 if (runno >= 600 && runno <= 699) {scale = 1.00266845; return;}
432 if (runno >= 700 && runno <= 799) {scale = 1.00184472; return;}
433 if (runno >= 800 && runno <= 899) {scale = 1.00200021; return;}
434 if (runno >= 900 && runno <= 999) {scale = 1.00178485; return;}
435 if (runno >= 1000 && runno <= 1099) {scale = 1.00196071; return;}
436 if (runno >= 1100 && runno <= 1199) {scale = 1.00224453; return;}
437 if (runno >= 1200 && runno <= 1299) {scale = 1.00209138; return;}
438 if (runno >= 1300 && runno <= 1399) {scale = 1.00145455; return;}
439 if (runno >= 1400 && runno <= 1499) {scale = 1.00119243; return;}
440 if (runno >= 1500 && runno <= 1599) {scale = 1.00115572; return;}
441 if (runno >= 1600 && runno <= 1699) {scale = 1.00133916; return;}
442 if (runno >= 1700 && runno <= 1799) {scale = 1.00186441; return;}
443 if (runno >= 1800 && runno <= 1899) {scale = 1.00206786; return;}
444 if (runno >= 1900 && runno <= 1999) {scale = 1.00184794; return;}
445 if (runno >= 2000 && runno <= 2099) {scale = 1.00187219; return;}
446 if (runno >= 2100 && runno <= 2199) {scale = 1.00214844; return;}
447 if (runno >= 2200 && runno <= 2299) {scale = 1.00154502; return;}
448 if (runno >= 2300 && runno <= 2399) {scale = 1.00179518; return;}
449 if (runno >= 2400 && runno <= 2499) {scale = 1.00198983; return;}
450 if (runno >= 2500 && runno <= 2599) {scale = 1.00219242; return;}
451 if (runno >= 2600 && runno <= 2699) {scale = 1.00227363; return;}
452 if (runno >= 2700 && runno <= 2799) {scale = 1.00202328; return;}
453 if (runno >= 2800 && runno <= 2899) {scale = 1.00193147; return;}
454 } else if (expno == 9) {
455 if (runno >= 0 && runno <= 99) {scale = 1.00126754; return;}
456 if (runno >= 100 && runno <= 199) {scale = 1.00119683; return;}
457 if (runno >= 200 && runno <= 299) {scale = 1.00123771; return;}
458 if (runno >= 300 && runno <= 399) {scale = 1.00142625; return;}
459 if (runno >= 400 && runno <= 499) {scale = 1.00134481; return;}
460 if (runno >= 500 && runno <= 599) {scale = 1.00131973; return;}
461 if (runno >= 600 && runno <= 699) {scale = 1.00145963; return;}
462 if (runno >= 700 && runno <= 799) {scale = 1.00161304; return;}
463 if (runno >= 800 && runno <= 899) {scale = 1.00141795; return;}
464 if (runno >= 900 && runno <= 999) {scale = 1.00137157; return;}
465 if (runno >= 1000 && runno <= 1099) {scale = 1.00126209; return;}
466 if (runno >= 1100 && runno <= 1199) {scale = 1.00147941; return;}
467 if (runno >= 1200 && runno <= 1299) {scale = 1.00145555; return;}
468 } else if (expno == 11) {
469 if (runno >= 0 && runno <= 99) {scale = 1.00149576; return;}
470 if (runno >= 100 && runno <= 199) {scale = 1.00155153; return;}
471 if (runno >= 200 && runno <= 299) {scale = 1.0013597 ; return;}
472 if (runno >= 300 && runno <= 399) {scale = 1.00147504; return;}
473 if (runno >= 400 && runno <= 499) {scale = 1.00138242; return;}
474 if (runno >= 500 && runno <= 599) {scale = 1.00144554; return;}
475 if (runno >= 600 && runno <= 699) {scale = 1.00136961; return;}
476 if (runno >= 700 && runno <= 799) {scale = 1.00141443; return;}
477 if (runno >= 800 && runno <= 899) {scale = 1.00136617; return;}
478 if (runno >= 900 && runno <= 999) {scale = 1.00126262; return;}
479 if (runno >= 1000 && runno <= 1099) {scale = 1.00133337; return;}
480 if (runno >= 1100 && runno <= 1199) {scale = 1.00137906; return;}
481 if (runno >= 1200 && runno <= 1299) {scale = 1.00127944; return;}
482 //assume same factor for runno>=1300
483 if (runno >= 1300 && runno <= 1399) {scale = 1.00127944; return;}
484 } else if (expno == 13) {
485 if (runno >= 0 && runno <= 99) {scale = 1.00110691; return;}
486 if (runno >= 100 && runno <= 199) {scale = 1.00106123; return;}
487 if (runno >= 200 && runno <= 299) {scale = 1.00109934; return;}
488 if (runno >= 300 && runno <= 399) {scale = 1.00105759; return;}
489 if (runno >= 400 && runno <= 499) {scale = 1.000986887; return;}
490 if (runno >= 500 && runno <= 599) {scale = 1.000928764; return;}
491 if (runno >= 600 && runno <= 699) {scale = 1.00103925; return;}
492 if (runno >= 700 && runno <= 799) {scale = 1.0010591 ; return;}
493 if (runno >= 800 && runno <= 899) {scale = 1.00127043; return;}
494 if (runno >= 900 && runno <= 999) {scale = 1.00154033; return;}
495 if (runno >= 1000 && runno <= 1099) {scale = 1.00180656; return;}
496 if (runno >= 1100 && runno <= 1199) {scale = 1.00202059; return;}
497 if (runno >= 1200 && runno <= 1299) {scale = 1.00184308; return;}
498 if (runno >= 1300 && runno <= 1399) {scale = 1.00180153; return;}
499 if (runno >= 1400 && runno <= 1499) {scale = 1.00189577; return;}
500 if (runno >= 1500 && runno <= 1599) {scale = 1.00176026; return;}
501 //assume same factor for runno>=1600
502 if (runno >= 1600 && runno <= 1699) {scale = 1.00176026; return;}
503
504 } else if (expno == 15) {
505 if (runno >= 0 && runno <= 99) {scale = 1.00178719; return;}
506 if (runno >= 100 && runno <= 199) {scale = 1.00205712; return;}
507 if (runno >= 200 && runno <= 299) {scale = 1.00197622; return;}
508 if (runno >= 300 && runno <= 399) {scale = 1.00191558; return;}
509 if (runno >= 400 && runno <= 499) {scale = 1.00207795; return;}
510 if (runno >= 500 && runno <= 599) {scale = 1.00191871; return;}
511 if (runno >= 600 && runno <= 699) {scale = 1.00187917; return;}
512 if (runno >= 700 && runno <= 799) {scale = 1.0019573 ; return;}
513 if (runno >= 800 && runno <= 899) {scale = 1.00196562; return;}
514 if (runno >= 900 && runno <= 999) {scale = 1.00205215; return;}
515 if (runno >= 1000 && runno <= 1099) {scale = 1.00200559; return;}
516 if (runno >= 1100 && runno <= 1199) {scale = 1.00198568; return;}
517 if (runno >= 1200 && runno <= 1299) {scale = 1.00212539; return;}
518 if (runno >= 1300 && runno <= 1399) {scale = 1.00199158; return;}
519 if (runno >= 1400 && runno <= 1499) {scale = 1.00208257; return;}
520
521 } else if (expno >= 17) { B2ERROR("scale_momenta mode=2: not ready for exp >=17");}
522
523 }
524 return;
525 }
526
527//=====================================================================
528 void B2BIIFixMdstModule::scale_momenta_set_v1(const int mode, const int expno,
529 const int runno, double& scale)
530 {
531//=====================================================================
532
533 //for e15 mdst processed with b20020405
534
535 scale = 1.;
536
537 if (mode == 1) {
538 B2ERROR("scale_momenta mode=1 not ready for exp " << expno);
539 return;
540 }
541
542 if (mode == 2) {
543 if (expno == 7) {
544 if (runno >= 0 && runno <= 99) {scale = 1.00284313; return;}
545 if (runno >= 100 && runno <= 199) {scale = 1.00272563; return;}
546 if (runno >= 200 && runno <= 299) {scale = 1.00276953; return;}
547 if (runno >= 300 && runno <= 399) {scale = 1.00286722; return;}
548 if (runno >= 400 && runno <= 499) {scale = 1.00318492; return;}
549 if (runno >= 500 && runno <= 599) {scale = 1.00304208; return;}
550 if (runno >= 600 && runno <= 699) {scale = 1.00292413; return;}
551 if (runno >= 700 && runno <= 799) {scale = 1.00201286; return;}
552 if (runno >= 800 && runno <= 899) {scale = 1.00225237; return;}
553 if (runno >= 900 && runno <= 999) {scale = 1.00210375; return;}
554 if (runno >= 1000 && runno <= 1099) {scale = 1.00213222; return;}
555 if (runno >= 1100 && runno <= 1199) {scale = 1.00253683; return;}
556 if (runno >= 1200 && runno <= 1299) {scale = 1.00234023; return;}
557 if (runno >= 1300 && runno <= 1399) {scale = 1.00168421; return;}
558 if (runno >= 1400 && runno <= 1499) {scale = 1.00136169; return;}
559 if (runno >= 1500 && runno <= 1599) {scale = 1.00138431; return;}
560 if (runno >= 1600 && runno <= 1699) {scale = 1.00154521; return;}
561 if (runno >= 1700 && runno <= 1799) {scale = 1.00204405; return;}
562 if (runno >= 1800 && runno <= 1899) {scale = 1.00223498; return;}
563 if (runno >= 1900 && runno <= 1999) {scale = 1.00198975; return;}
564 if (runno >= 2000 && runno <= 2099) {scale = 1.00201868; return;}
565 if (runno >= 2100 && runno <= 2199) {scale = 1.00233875; return;}
566 if (runno >= 2200 && runno <= 2299) {scale = 1.00175269; return;}
567 if (runno >= 2300 && runno <= 2399) {scale = 1.00192858; return;}
568 if (runno >= 2400 && runno <= 2499) {scale = 1.00217693; return;}
569 if (runno >= 2500 && runno <= 2599) {scale = 1.00209337; return;}
570 if (runno >= 2600 && runno <= 2699) {scale = 1.00244277; return;}
571 if (runno >= 2700 && runno <= 2799) {scale = 1.00221485; return;}
572 if (runno >= 2800 && runno <= 2899) {scale = 1.00214678; return;}
573 } else if (expno == 9) {
574 if (runno >= 0 && runno <= 99) {scale = 1.00127702; return;}
575 if (runno >= 100 && runno <= 199) {scale = 1.00119957; return;}
576 if (runno >= 200 && runno <= 299) {scale = 1.00132677; return;}
577 if (runno >= 300 && runno <= 399) {scale = 1.0014785 ; return;}
578 if (runno >= 400 && runno <= 499) {scale = 1.00144872; return;}
579 if (runno >= 500 && runno <= 599) {scale = 1.00145376; return;}
580 if (runno >= 600 && runno <= 699) {scale = 1.00151659; return;}
581 if (runno >= 700 && runno <= 799) {scale = 1.00167384; return;}
582 if (runno >= 800 && runno <= 899) {scale = 1.00153754; return;}
583 if (runno >= 900 && runno <= 999) {scale = 1.0014984 ; return;}
584 if (runno >= 1000 && runno <= 1099) {scale = 1.0013764 ; return;}
585 if (runno >= 1100 && runno <= 1199) {scale = 1.00145545; return;}
586 if (runno >= 1200 && runno <= 1299) {scale = 1.0017164 ; return;}
587 } else if (expno == 11) {
588 if (runno >= 0 && runno <= 99) {scale = 1.00159624; return;}
589 if (runno >= 100 && runno <= 199) {scale = 1.00153365; return;}
590 if (runno >= 200 && runno <= 299) {scale = 1.00143809; return;}
591 if (runno >= 300 && runno <= 399) {scale = 1.00148495; return;}
592 if (runno >= 400 && runno <= 499) {scale = 1.00143193; return;}
593 if (runno >= 500 && runno <= 599) {scale = 1.00141905; return;}
594 if (runno >= 600 && runno <= 699) {scale = 1.0013992 ; return;}
595 if (runno >= 700 && runno <= 799) {scale = 1.00148836; return;}
596 if (runno >= 800 && runno <= 899) {scale = 1.00139019; return;}
597 if (runno >= 900 && runno <= 999) {scale = 1.00151389; return;}
598 if (runno >= 1000 && runno <= 1099) {scale = 1.00142988; return;}
599 if (runno >= 1100 && runno <= 1199) {scale = 1.00143519; return;}
600 if (runno >= 1200 && runno <= 1299) {scale = 1.00132641; return;}
601 } else if (expno == 13) {
602 if (runno >= 0 && runno <= 99) {scale = 1.00126317; return;}
603 if (runno >= 100 && runno <= 199) {scale = 1.00118837; return;}
604 if (runno >= 200 && runno <= 299) {scale = 1.00122276; return;}
605 if (runno >= 300 && runno <= 399) {scale = 1.00113233; return;}
606 if (runno >= 400 && runno <= 499) {scale = 1.00111677; return;}
607 if (runno >= 500 && runno <= 599) {scale = 1.00100963; return;}
608 if (runno >= 600 && runno <= 699) {scale = 1.0011474 ; return;}
609 if (runno >= 700 && runno <= 799) {scale = 1.00116245; return;}
610 if (runno >= 800 && runno <= 899) {scale = 1.00139826; return;}
611 if (runno >= 900 && runno <= 999) {scale = 1.0017014 ; return;}
612 if (runno >= 1000 && runno <= 1099) {scale = 1.00190706; return;}
613 if (runno >= 1100 && runno <= 1199) {scale = 1.00214688; return;}
614 if (runno >= 1200 && runno <= 1299) {scale = 1.00207336; return;}
615 if (runno >= 1300 && runno <= 1399) {scale = 1.00192885; return;}
616 if (runno >= 1400 && runno <= 1499) {scale = 1.00196289; return;}
617 if (runno >= 1500 && runno <= 1599) {scale = 1.00185017; return;}
618 if (runno >= 1600 && runno <= 1699) {scale = 1.00191256; return;}
619 } else if (expno == 15) {
620 if (runno >= 0 && runno <= 99) {scale = 1.001953; return;}
621 if (runno >= 100 && runno <= 199) {scale = 1.00210508; return;}
622 if (runno >= 200 && runno <= 299) {scale = 1.002139; return;}
623 if (runno >= 300 && runno <= 399) {scale = 1.00207803; return;}
624 if (runno >= 400 && runno <= 499) {scale = 1.0022331; return;}
625 if (runno >= 500 && runno <= 599) {scale = 1.00206421; return;}
626 if (runno >= 600 && runno <= 699) {scale = 1.00205153; return;}
627 if (runno >= 700 && runno <= 799) {scale = 1.00214664; return;}
628 if (runno >= 800 && runno <= 899) {scale = 1.0021456; return;}
629 if (runno >= 900 && runno <= 999) {scale = 1.00221055; return;}
630 if (runno >= 1000 && runno <= 1099) {scale = 1.00216472; return;}
631 if (runno >= 1100 && runno <= 1199) {scale = 1.00214208; return;}
632 if (runno >= 1200 && runno <= 1299) {scale = 1.00228874; return;}
633 if (runno >= 1300 && runno <= 1399) {scale = 1.00215047; return;}
634 if (runno >= 1400 && runno <= 1499) {scale = 1.00219808; return;}
635 } else if (expno == 17) {
636 if (runno >= 0 && runno <= 99) {scale = 1.00216742; return;}
637 if (runno >= 100 && runno <= 199) {scale = 1.00229433; return;}
638 if (runno >= 200 && runno <= 299) {scale = 1.0022749 ; return;}
639 if (runno >= 300 && runno <= 399) {scale = 1.00231283; return;}
640 if (runno >= 400 && runno <= 499) {scale = 1.00223654; return;}
641 if (runno >= 500 && runno <= 599) {scale = 1.00236524; return;}
642 if (runno >= 600 && runno <= 699) {scale = 1.00229312; return;}
643 if (runno >= 700 && runno <= 799) {scale = 1.002262 ; return;}
644 if (runno >= 800 && runno <= 899) {scale = 1.00220104; return;}
645 if (runno >= 900 && runno <= 999) {scale = 1.00215475; return;}
646 } else if (expno == 19) {
647 if (runno >= 0 && runno <= 99) {scale = 1.00227682; return;}
648 if (runno >= 100 && runno <= 199) {scale = 1.00235795; return;}
649 if (runno >= 200 && runno <= 299) {scale = 1.00251509; return;}
650 if (runno >= 300 && runno <= 399) {scale = 1.0022106 ; return;}
651 if (runno >= 400 && runno <= 499) {scale = 1.00230963; return;}
652 if (runno >= 500 && runno <= 599) {scale = 1.002229 ; return;}
653 if (runno >= 600 && runno <= 699) {scale = 1.00215402; return;}
654 if (runno >= 700 && runno <= 799) {scale = 1.00217892; return;}
655 if (runno >= 800 && runno <= 899) {scale = 1.0022305 ; return;}
656 if (runno >= 900 && runno <= 999) {scale = 1.0021458 ; return;}
657 if (runno >= 1000 && runno <= 1099) {scale = 1.00215792; return;}
658 if (runno >= 1100 && runno <= 1199) {scale = 1.0022667 ; return;}
659 if (runno >= 1200 && runno <= 1299) {scale = 1.00219581; return;}
660 if (runno >= 1300 && runno <= 1399) {scale = 1.00218378; return;}
661 if (runno >= 1400 && runno <= 1499) {scale = 1.00232172; return;}
662 if (runno >= 1500 && runno <= 1599) {scale = 1.00217172; return;}
663 if (runno >= 1600 && runno <= 1700) {scale = 1.00208639; return;}
664 if (runno >= 1700 && runno <= 1799) {scale = 1.00188253; return;}
665 if (runno >= 1800) {
666 B2ERROR("scale_momenta not ready for this exp,run "
667 << expno << "," << runno);
668 }
669 } else if (expno == 21) {
670 if (runno >= 0 && runno <= 99) {scale = 1.00228182; return;}
671 if (runno >= 100 && runno <= 199) {scale = 1.00233446; return;}
672 if (runno >= 200 && runno <= 299) {scale = 1.00238846; return;}
673 if (runno >= 300 && runno <= 399) {scale = 1.00238061 ; return;}
674 if (runno >= 400) {
675 B2ERROR("scale_momenta not ready for this exp,run "
676 << expno << "," << runno);
677 }
678 } else if (expno == 23) {
679 if (runno >= 0 && runno <= 99) {scale = 1.00216089; return;}
680 if (runno >= 100 && runno <= 199) {scale = 1.0019783; return;}
681 if (runno >= 200 && runno <= 299) {scale = 1.00172162; return;}
682 if (runno >= 300 && runno <= 399) {scale = 1.0017938 ; return;}
683 if (runno >= 400 && runno <= 499) {scale = 1.00177832 ; return;}
684 if (runno >= 500 && runno <= 599) {scale = 1.0017609 ; return;}
685 if (runno >= 600 && runno <= 699) {scale = 1.0017756 ; return;}
686 if (runno >= 700) {
687 B2ERROR("scale_momenta not ready for this exp,run "
688 << expno << "," << runno);
689 }
690 } else if (expno == 25) {
691 if (runno >= 0 && runno <= 99) {scale = 1.00190068; return;}
692 if (runno >= 100 && runno <= 199) {scale = 1.00199038; return;}
693 if (runno >= 200 && runno <= 299) {scale = 1.00196171; return;}
694 if (runno >= 300 && runno <= 399) {scale = 1.00200167; return;}
695 if (runno >= 400 && runno <= 499) {scale = 1.0019667 ; return;}
696 if (runno >= 500 && runno <= 599) {scale = 1.00212109; return;}
697 if (runno >= 600 && runno <= 699) {scale = 1.00202115; return;}
698 if (runno >= 700 && runno <= 799) {scale = 1.00196456; return;}
699 if (runno >= 800 && runno <= 899) {scale = 1.00200392; return;}
700 if (runno >= 900 && runno <= 999) {scale = 1.00199495; return;}
701 if (runno >= 1000 && runno <= 1099) {scale = 1.00202212; return;}
702 if (runno >= 1100 && runno <= 1199) {scale = 1.00205312; return;}
703 if (runno >= 1200 && runno <= 1299) {scale = 1.00200891; return;}
704 if (runno >= 1300 && runno <= 1399) {scale = 1.00196866; return;}
705 if (runno >= 1400 && runno <= 1499) {scale = 1.0020257 ; return;}
706 if (runno >= 1500 && runno <= 1599) {scale = 1.00196995; return;}
707 if (runno >= 1600 && runno <= 1699) {scale = 1.00189232; return;}
708 if (runno >= 1700 && runno <= 1799) {scale = 1.00179028; return;}
709 if (runno >= 1800 && runno <= 1899) {scale = 1.00179459; return;}
710 if (runno >= 1900 && runno <= 1999) {scale = 1.001762 ; return;}
711 if (runno >= 2000 && runno <= 2099) {scale = 1.00179514; return;}
712 if (runno >= 2100 && runno <= 2199) {scale = 1.00175211; return;}
713 if (runno >= 2200) {
714 B2ERROR("scale_momenta not ready for this exp,run "
715 << expno << "," << runno);
716 }
717 } else if (expno == 27) {
718 if (runno >= 0 && runno <= 99) {scale = 1.00192647; return;}
719 if (runno >= 100 && runno <= 199) {scale = 1.0019717 ; return;}
720 if (runno >= 200 && runno <= 299) {scale = 1.00196428; return;}
721 if (runno >= 300 && runno <= 399) {scale = 1.00190998; return;}
722 if (runno >= 400 && runno <= 499) {scale = 1.00204645; return;}
723 if (runno >= 500 && runno <= 599) {scale = 1.0020687 ; return;}
724 if (runno >= 600 && runno <= 699) {scale = 1.00198209; return;}
725
726 if (runno >= 700 && runno <= 800) {scale = 1.00187505; return;}
727 if (runno >= 801 && runno <= 900) {scale = 1.00186805; return;}
728 if (runno >= 901 && runno <= 1000) {scale = 1.00185576; return;}
729 if (runno >= 1001 && runno <= 1079) {scale = 1.00177176; return;}
730 if (runno >= 1080 && runno <= 1100) {scale = 1.00177184; return;}
731 if (runno >= 1101 && runno <= 1200) {scale = 1.00174057; return;}
732 if (runno >= 1201 && runno <= 1251) {scale = 1.00189649; return;}
733 if (runno >= 1252 && runno <= 1300) {scale = 1.00189999; return;}
734 if (runno >= 1301 && runno <= 1400) {scale = 1.0018818 ; return;}
735 if (runno >= 1401 && runno <= 1500) {scale = 1.00200148; return;}
736 if (runno >= 1501 && runno <= 1600) {scale = 1.00220137; return;}
737 if (runno >= 1601 && runno <= 1632) {scale = 1.00217034; return;}
738 if (runno >= 1633) {
739 B2ERROR("scale_momenta not ready for this exp,run "
740 << expno << "," << runno);
741 }
742 } else if (expno == 31) {
743 if (runno >= 0 && runno <= 99) {scale = 1.000373374; return;}
744 if (runno >= 100 && runno <= 199) {scale = 1.000684843; return;}
745 if (runno >= 200 && runno <= 299) {scale = 1.000741216; return;}
746 if (runno >= 300 && runno <= 399) {scale = 1.00092523 ; return;}
747 if (runno >= 400 && runno <= 499) {scale = 1.00104576 ; return;}
748 if (runno >= 500 && runno <= 599) {scale = 1.00103982 ; return;}
749 if (runno >= 600 && runno <= 699) {scale = 1.0010601 ; return;}
750 if (runno >= 700 && runno <= 799) {scale = 1.000982515; return;}
751 if (runno >= 800 && runno <= 899) {scale = 1.00101577 ; return;}
752 if (runno >= 900 && runno <= 999) {scale = 1.000972193; return;}
753 if (runno >= 1000 && runno <= 1099) {scale = 1.00102536 ; return;}
754 if (runno >= 1100 && runno <= 1199) {scale = 1.00127571 ; return;}
755 if (runno >= 1200 && runno <= 1299) {scale = 1.00117938 ; return;}
756 if (runno >= 1300 && runno <= 1399) {scale = 1.00121084 ; return;}
757 if (runno >= 1400 && runno <= 1499) {scale = 1.00125911 ; return;}
758 if (runno >= 1500 && runno <= 1599) {scale = 1.0012907 ; return;}
759 if (runno >= 1600 && runno <= 1699) {scale = 1.00125362 ; return;}
760 if (runno >= 1700 && runno <= 1799) {scale = 1.00131686 ; return;}
761 if (runno >= 1800) {
762 B2ERROR("scale_momenta not ready for this exp,run "
763 << expno << "," << runno);
764 }
765 } else if (expno == 33) {
766 if (runno >= 0 && runno <= 99) {scale = 1.00136407; return;}
767 if (runno >= 100 && runno <= 199) {scale = 1.0013701 ; return;}
768 if (runno >= 200 && runno <= 299) {scale = 1.00156244; return;}
769 if (runno >= 300 && runno <= 399) {scale = 1.00138501; return;}
770 if (runno >= 400 && runno <= 499) {scale = 1.00148468; return;}
771 if (runno >= 500 && runno <= 599) {scale = 1.0013797 ; return;}
772 if (runno >= 600 && runno <= 699) {scale = 1.00152298; return;}
773 if (runno >= 700 && runno <= 799) {scale = 1.001524 ; return;}
774 if (runno >= 800 && runno <= 899) {scale = 1.0014635 ; return;}
775 if (runno >= 900) {
776 B2ERROR("scale_momenta not ready for this exp,run "
777 << expno << "," << runno);
778 }
779 } else if (expno == 35) {
780 if (runno >= 0 && runno <= 99) {scale = 1.00135452; return;}
781 if (runno >= 100 && runno <= 199) {scale = 1.00135798; return;}
782 if (runno >= 200 && runno <= 299) {scale = 1.00139979; return;}
783 if (runno >= 300 && runno <= 399) {scale = 1.00136061; return;}
784 if (runno >= 400 && runno <= 499) {scale = 1.00135776; return;}
785 if (runno >= 500 && runno <= 599) {scale = 1.00118666; return;}
786 if (runno >= 600 && runno <= 699) {scale = 1.0011346 ; return;}
787 if (runno >= 700) {
788 B2ERROR("scale_momenta not ready for this exp,run "
789 << expno << "," << runno);
790 }
791 } else if (expno == 37) {
792 if (runno >= 0 && runno <= 99) {scale = 1.00076522 ; return;}
793 if (runno >= 100 && runno <= 199) {scale = 1.000875154; return;}
794 if (runno >= 200 && runno <= 299) {scale = 1.000946763; return;}
795 if (runno >= 300 && runno <= 399) {scale = 1.000868444; return;}
796 if (runno >= 400 && runno <= 499) {scale = 1.000781409; return;}
797 if (runno >= 500 && runno <= 599) {scale = 1.000781171; return;}
798 if (runno >= 600 && runno <= 699) {scale = 1.000857962; return;}
799 if (runno >= 700 && runno <= 799) {scale = 1.000756082; return;}
800 if (runno >= 800 && runno <= 899) {scale = 1.000727355; return;}
801 if (runno >= 900 && runno <= 999) {scale = 1.000740236; return;}
802 if (runno >= 1000 && runno <= 1099) {scale = 1.000499606; return;}
803 if (runno >= 1100 && runno <= 1199) {scale = 1.000481664; return;}
804 if (runno >= 1200 && runno <= 1299) {scale = 1.000706924; return;}
805 if (runno >= 1300 && runno <= 1399) {scale = 1.000673738; return;}
806 if (runno >= 1400 && runno <= 1499) {scale = 1.000662648; return;}
807 if (runno >= 1500 && runno <= 1599) {scale = 1.000671198; return;}
808 if (runno >= 1600 && runno <= 1699) {scale = 1.000604364; return;}
809 if (runno >= 1700 && runno <= 1799) {scale = 1.000717372; return;}
810 if (runno >= 1800 && runno <= 1899) {scale = 1.000512399; return;}
811 if (runno >= 1900 && runno <= 1999) {scale = 1.000436958; return;}
812 if (runno >= 2000) {
813 B2ERROR("scale_momenta not ready for this exp,run "
814 << expno << "," << runno);
815 }
816 } else if (expno == 39) {
817 if (runno >= 0 && runno <= 99) {scale = 1.000504342; return;}
818 if (runno >= 100 && runno <= 199) {scale = 1.000704544; return;}
819 if (runno >= 200 && runno <= 299) {scale = 1.00094335 ; return;}
820 if (runno >= 300 && runno <= 399) {scale = 1.000928819; return;}
821 if (runno >= 400 && runno <= 499) {scale = 1.000884638; return;}
822 if (runno >= 500 && runno <= 599) {scale = 1.00083459 ; return;}
823 if (runno >= 600 && runno <= 699) {scale = 1.000767604; return;}
824 if (runno >= 700 && runno <= 799) {scale = 1.000882219; return;}
825 if (runno >= 800 && runno <= 899) {scale = 1.000781437; return;}
826 if (runno >= 900 && runno <= 999) {scale = 1.000853168; return;}
827 if (runno >= 1000 && runno <= 1099) {scale = 1.000926527; return;}
828 if (runno >= 1100 && runno <= 1199) {scale = 1.000942882; return;}
829 if (runno >= 1200 && runno <= 1299) {scale = 1.000932802; return;}
830 if (runno >= 1300 && runno <= 1399) {scale = 1.000898892; return;}
831 if (runno >= 1400) {
832 B2ERROR("scale_momenta not ready for this exp,run "
833 << expno << "," << runno);
834 }
835 } else if (expno == 41) {
836 if (runno >= 0 && runno <= 99) {scale = 1.00178427; return;}
837 if (runno >= 100 && runno <= 199) {scale = 1.00188559; return;}
838 if (runno >= 200 && runno <= 299) {scale = 1.0019292 ; return;}
839 if (runno >= 300 && runno <= 399) {scale = 1.00196352; return;}
840 if (runno >= 400 && runno <= 499) {scale = 1.0019078 ; return;}
841 if (runno >= 500 && runno <= 599) {scale = 1.00185598; return;}
842 if (runno >= 600 && runno <= 699) {scale = 1.00191314; return;}
843 if (runno >= 700 && runno <= 799) {scale = 1.00179647; return;}
844 if (runno >= 800 && runno <= 899) {scale = 1.00189776; return;}
845 if (runno >= 900 && runno <= 999) {scale = 1.00184798; return;}
846 if (runno >= 1000 && runno <= 1099) {scale = 1.00177963; return;}
847 if (runno >= 1100 && runno <= 1199) {scale = 1.00176408; return;}
848 if (runno >= 1200 && runno <= 1299) {scale = 1.00171371; return;}
849 if (runno >= 1300) {
850 B2ERROR("scale_momenta not ready for this exp,run "
851 << expno << "," << runno);
852 }
853 } else if (expno == 43) {
854 if (runno >= 0 && runno <= 99) {scale = 1.00142307; return;}
855 if (runno >= 100 && runno <= 199) {scale = 1.000979455; return;}
856 if (runno >= 200 && runno <= 299) {scale = 1.000974458; return;}
857 if (runno >= 300 && runno <= 399) {scale = 1.00103301; return;}
858 if (runno >= 400 && runno <= 499) {scale = 1.001111994; return;}
859 if (runno >= 500 && runno <= 599) {scale = 1.00100635; return;}
860 if (runno >= 600 && runno <= 699) {scale = 1.00105078; return;}
861 if (runno >= 700 && runno <= 799) {scale = 1.00103593; return;}
862 if (runno >= 800 && runno <= 899) {scale = 1.00105158; return;}
863 if (runno >= 900 && runno <= 999) {scale = 1.000955608; return;}
864 if (runno >= 1000 && runno <= 1099) {scale = 1.00099199; return;}
865 if (runno >= 1100 && runno <= 1199) {scale = 1.0011439; return;}
866 if (runno >= 1200) {
867 B2ERROR("scale_momenta not ready for this exp,run "
868 << expno << "," << runno);
869 }
870 } else if (expno == 45) {
871 if (runno >= 0 && runno <= 99) {scale = 1.00126261; return;}
872 if (runno >= 100 && runno <= 199) {scale = 1.00138601; return;}
873 if (runno >= 200 && runno <= 299) {scale = 1.00135372; return;}
874 if (runno >= 300 && runno <= 399) {scale = 1.00141286; return;}
875 if (runno >= 400 && runno <= 499) {scale = 1.00147822; return;}
876 if (runno >= 500) {
877 B2ERROR("scale_momenta not ready for this exp,run "
878 << expno << "," << runno);
879 }
880 } else if (expno == 47) {
881 if (runno >= 0 && runno <= 99) {scale = 1.00156977; return;}
882 if (runno >= 100 && runno <= 199) {scale = 1.00155614; return;}
883 if (runno >= 200 && runno <= 299) {scale = 1.0016555; return;}
884 if (runno >= 300 && runno <= 399) {scale = 1.00167046; return;}
885 if (runno >= 400 && runno <= 499) {scale = 1.00168705; return;}
886 if (runno >= 500 && runno <= 599) {scale = 1.00169555; return;}
887 if (runno >= 600 && runno <= 699) {scale = 1.00175653; return;}
888 if (runno >= 700 && runno <= 799) {scale = 1.00174358; return;}
889 if (runno >= 800 && runno <= 899) {scale = 1.00174004; return;}
890 if (runno >= 900) {
891 B2ERROR("scale_momenta not ready for this exp,run "
892 << expno << "," << runno);
893 }
894 } else if (expno == 49) {
895 if (runno >= 0 && runno <= 99) {scale = 1.00158837; return;}
896 if (runno >= 100 && runno <= 199) {scale = 1.00163884; return;}
897 if (runno >= 200 && runno <= 299) {scale = 1.00160595; return;}
898 if (runno >= 300 && runno <= 399) {scale = 1.00149916; return;}
899 if (runno >= 400 && runno <= 499) {scale = 1.0014956 ; return;}
900 if (runno >= 500 && runno <= 599) {scale = 1.00156212; return;}
901 if (runno >= 600 && runno <= 699) {scale = 1.00121868; return;}
902 if (runno >= 700 && runno <= 799) {scale = 1.00134613; return;}
903 if (runno >= 800 && runno <= 899) {scale = 1.00138985; return;}
904 if (runno >= 900 && runno <= 999) {scale = 1.00129356; return;}
905 if (runno >= 1000 && runno <= 1099) {scale = 1.00119732; return;}
906 if (runno >= 1100 && runno <= 1199) {scale = 1.00121481; return;}
907 if (runno >= 1200 && runno <= 1299) {scale = 1.00121108; return;}
908 if (runno >= 1300) {
909 B2ERROR("scale_momenta not ready for this exp,run "
910 << expno << "," << runno);
911 }
912 } else if (expno == 51) {
913 if (runno >= 0 && runno <= 99) {scale = 1.00160252; return;}
914 if (runno >= 100 && runno <= 199) {scale = 1.00156099; return;}
915 if (runno >= 200 && runno <= 299) {scale = 1.00154760; return;}
916 if (runno >= 300 && runno <= 399) {scale = 1.00146316; return;}
917 if (runno >= 400 && runno <= 499) {scale = 1.00145525; return;}
918 if (runno >= 500 && runno <= 599) {scale = 1.00134429; return;}
919 if (runno >= 600 && runno <= 699) {scale = 1.00135581; return;}
920 if (runno >= 700 && runno <= 799) {scale = 1.00134382; return;}
921 if (runno >= 800 && runno <= 899) {scale = 1.00126462; return;}
922 if (runno >= 900 && runno <= 999) {scale = 1.00130752; return;}
923 if (runno >= 1000 && runno <= 1099) {scale = 1.00130452; return;}
924 if (runno >= 1100 && runno <= 1199) {scale = 1.00131440; return;}
925 if (runno >= 1200 && runno <= 1299) {scale = 1.00130864; return;}
926 if (runno >= 1300 && runno <= 1399) {scale = 1.00105290; return;}
927 if (runno >= 1400 && runno <= 1499) {scale = 1.00126645; return;}
928 if (runno >= 1500 && runno <= 1599) {scale = 1.00126383; return;}
929 if (runno >= 1600 && runno <= 1699) {scale = 1.00141111; return;}
930 if (runno >= 1700 && runno <= 1799) {scale = 1.00126220; return;}
931 if (runno >= 1800 && runno <= 1899) {scale = 1.00105098; return;}
932 if (runno >= 1900) {
933 B2ERROR("scale_momenta not ready for this exp,run "
934 << expno << "," << runno);
935 }
936 } else if (expno == 53) {
937 if (runno >= 0 && runno <= 99) {scale = 1.0011516; return;}
938 if (runno >= 100 && runno <= 199) {scale = 1.00115527; return;}
939 if (runno >= 200 && runno <= 299) {scale = 1.00114844; return;}
940 if (runno >= 300) {
941 B2ERROR("scale_momenta not ready for this exp,run "
942 << expno << "," << runno);
943 }
944 } else if (expno == 55) {
945 if (runno >= 0 && runno <= 99) {scale = 1.00114284; return;}
946 if (runno >= 100 && runno <= 199) {scale = 1.00111458; return;}
947 if (runno >= 200 && runno <= 299) {scale = 1.00109686; return;}
948 if (runno >= 300 && runno <= 399) {scale = 1.00119475; return;}
949 if (runno >= 400 && runno <= 499) {scale = 1.00117818; return;}
950 if (runno >= 500 && runno <= 599) {scale = 1.00115789; return;}
951 if (runno >= 600 && runno <= 699) {scale = 1.00122261; return;}
952 if (runno >= 700 && runno <= 799) {scale = 1.00118454; return;}
953 if (runno >= 800 && runno <= 899) {scale = 1.00118042; return;}
954 if (runno >= 900 && runno <= 999) {scale = 1.00124759; return;}
955 if (runno >= 1000 && runno <= 1099) {scale = 1.00128055; return;}
956 if (runno >= 1100 && runno <= 1199) {scale = 1.00119131; return;}
957 if (runno >= 1200 && runno <= 1299) {scale = 1.00122238; return;}
958 if (runno >= 1300 && runno <= 1399) {scale = 1.00129538; return;}
959 if (runno >= 1400 && runno <= 1499) {scale = 1.00130387; return;}
960 if (runno >= 1500 && runno <= 1599) {scale = 1.00130858; return;}
961 if (runno >= 1600 && runno <= 1699) {scale = 1.00111854; return;}
962 if (runno >= 1700 && runno <= 1799) {scale = 1.00136261; return;}
963 if (runno >= 1800) {
964 B2ERROR("scale_momenta not ready for this exp,run "
965 << expno << "," << runno);
966 }
967 } else if (expno == 61) {
968 if (runno >= 0 && runno <= 99) {scale = 1.0009992; return;}
969 if (runno >= 100 && runno <= 199) {scale = 1.00113704; return;}
970 if (runno >= 200 && runno <= 299) {scale = 1.00129904; return;}
971 if (runno >= 300 && runno <= 399) {scale = 1.00141879; return;}
972 if (runno >= 400 && runno <= 499) {scale = 1.00146707; return;}
973 if (runno >= 500 && runno <= 599) {scale = 1.00150101; return;}
974 if (runno >= 600 && runno <= 699) {scale = 1.00147322; return;}
975 if (runno >= 700 && runno <= 799) {scale = 1.00153929; return;}
976 if (runno >= 800 && runno <= 899) {scale = 1.00159997; return;}
977 if (runno >= 900 && runno <= 999) {scale = 1.00164032; return;}
978 if (runno >= 1000 && runno <= 1099) {scale = 1.00165878; return;}
979 if (runno >= 1100 && runno <= 1199) {scale = 1.00163475; return;}
980 if (runno >= 1200 && runno <= 1207) {scale = 1.00166193; return;}
981 if (runno >= 1208 && runno <= 1299) {scale = 1.00235824; return;}
982 if (runno >= 1300 && runno <= 1399) {scale = 1.00242282; return;}
983 if (runno >= 1400) {
984 B2ERROR("scale_momenta not ready for this exp,run "
985 << expno << "," << runno);
986 }
987 } else if (expno == 65) {
988 if (runno <= 999) {
989 B2ERROR("scale_momenta not ready for this exp,run "
990 << expno << "," << runno);
991 }
992 if (runno >= 1000 && runno <= 1336) {scale = 1.00145234; return;}
993 if (runno >= 1336) {
994 B2ERROR("scale_momenta not ready for this exp,run "
995 << expno << "," << runno);
996 }
997 } else
998 B2ERROR("scale_momenta mode=2 not ready for exp " << expno);
999 }
1000 return;
1001 }
1002
1003//=====================================================================
1004 void B2BIIFixMdstModule::scale_momenta_set_v2(const int mode, const int expno,
1005 const int runno, double& scale)
1006 {
1007//=====================================================================
1008
1009 //for e15 mdst processed with b20020405
1010
1011 scale = 1.;
1012
1013 if (mode == 1) {
1014 B2ERROR("scale_momenta mode=1 not ready for exp " << expno);
1015 return;
1016 }
1017
1018 if (mode == 2) {
1019 if (expno == 7) {
1020
1021 } else if (expno == 9) {
1022
1023 } else if (expno == 11) {
1024
1025 } else if (expno == 13) {
1026
1027 } else if (expno == 15) {
1028
1029 } else if (expno == 17) {
1030
1031 } else if (expno == 19) {
1032 B2ERROR("scale_momenta not ready for this exp,run "
1033 << expno << "," << runno);
1034
1035 } else if (expno == 21) {
1036 B2ERROR("scale_momenta not ready for this exp,run "
1037 << expno << "," << runno);
1038
1039 } else if (expno == 23) {
1040 B2ERROR("scale_momenta not ready for this exp,run "
1041 << expno << "," << runno);
1042
1043 } else if (expno == 25) {
1044 B2ERROR("scale_momenta not ready for this exp,run "
1045 << expno << "," << runno);
1046
1047 } else if (expno == 27) {
1048 B2ERROR("scale_momenta not ready for this exp,run "
1049 << expno << "," << runno);
1050
1051 } else if (expno == 31) {
1052 if (runno >= 0 && runno <= 137) {
1053 B2ERROR("scale_momenta not ready for this exp,run "
1054 << expno << "," << runno);
1055 }
1056 if (runno >= 138 && runno <= 199) {scale = 1.000931841; return;}
1057 if (runno >= 200 && runno <= 299) {scale = 1.000916397; return;}
1058 if (runno >= 300 && runno <= 399) {scale = 1.00108023 ; return;}
1059 if (runno >= 400 && runno <= 499) {scale = 1.00118662 ; return;}
1060 if (runno >= 500 && runno <= 599) {scale = 1.00117739 ; return;}
1061 if (runno >= 600 && runno <= 699) {scale = 1.00119542 ; return;}
1062 if (runno >= 700 && runno <= 799) {scale = 1.00110396 ; return;}
1063 if (runno >= 800 && runno <= 899) {scale = 1.00109603 ; return;}
1064 if (runno >= 900 && runno <= 999) {scale = 1.00112795 ; return;}
1065 if (runno >= 1000 && runno <= 1099) {scale = 1.00118365 ; return;}
1066 if (runno >= 1100 && runno <= 1199) {scale = 1.00142214 ; return;}
1067 if (runno >= 1200 && runno <= 1299) {scale = 1.00133150 ; return;}
1068 if (runno >= 1300 && runno <= 1399) {scale = 1.00132831 ; return;}
1069 if (runno >= 1400 && runno <= 1499) {scale = 1.00136554 ; return;}
1070 if (runno >= 1500 && runno <= 1599) {scale = 1.00141187 ; return;}
1071 if (runno >= 1600 && runno <= 1699) {scale = 1.00136628 ; return;}
1072 if (runno >= 1700 && runno <= 1799) {scale = 1.00139273 ; return;}
1073 if (runno >= 1800) {
1074 B2ERROR("scale_momenta not ready for this exp,run "
1075 << expno << "," << runno);
1076 }
1077 } else if (expno == 33) {
1078 if (runno >= 0 && runno <= 99) {scale = 1.00149319; return;}
1079 if (runno >= 100 && runno <= 199) {scale = 1.00150915; return;}
1080 if (runno >= 200 && runno <= 299) {scale = 1.00173040; return;}
1081 if (runno >= 300 && runno <= 399) {scale = 1.00150449; return;}
1082 if (runno >= 400 && runno <= 499) {scale = 1.00161519; return;}
1083 if (runno >= 500 && runno <= 599) {scale = 1.00151670; return;}
1084 if (runno >= 600 && runno <= 699) {scale = 1.00164347; return;}
1085 if (runno >= 700 && runno <= 799) {scale = 1.00164165; return;}
1086 if (runno >= 800 && runno <= 899) {scale = 1.00161369; return;}
1087 if (runno >= 900) {
1088 B2ERROR("scale_momenta not ready for this exp,run "
1089 << expno << "," << runno);
1090 }
1091 } else if (expno == 35) {
1092 if (runno >= 0 && runno <= 99) {scale = 1.00147034; return;}
1093 if (runno >= 100 && runno <= 199) {scale = 1.00148523; return;}
1094 if (runno >= 200 && runno <= 299) {scale = 1.00153372; return;}
1095 if (runno >= 300 && runno <= 399) {scale = 1.00148256; return;}
1096 if (runno >= 400 && runno <= 499) {scale = 1.00144902; return;}
1097 if (runno >= 500 && runno <= 599) {scale = 1.00131501; return;}
1098 if (runno >= 600 && runno <= 699) {scale = 1.00126371; return;}
1099 if (runno >= 700) {
1100 B2ERROR("scale_momenta not ready for this exp,run "
1101 << expno << "," << runno);
1102 }
1103 } else if (expno == 37) {
1104 if (runno >= 0 && runno <= 99) {scale = 1.000916277; return;}
1105 if (runno >= 100 && runno <= 199) {scale = 1.001035310; return;}
1106 if (runno >= 200 && runno <= 299) {scale = 1.001123403; return;}
1107 if (runno >= 300 && runno <= 399) {scale = 1.001017718; return;}
1108 if (runno >= 400 && runno <= 499) {scale = 1.000932890; return;}
1109 if (runno >= 500 && runno <= 599) {scale = 1.000928479; return;}
1110 if (runno >= 600 && runno <= 699) {scale = 1.000997938; return;}
1111 if (runno >= 700 && runno <= 799) {scale = 1.000899663; return;}
1112 if (runno >= 800 && runno <= 899) {scale = 1.000860910; return;}
1113 if (runno >= 900 && runno <= 999) {scale = 1.000882920; return;}
1114 if (runno >= 1000 && runno <= 1099) {scale = 1.000616966; return;}
1115 if (runno >= 1100 && runno <= 1199) {scale = 1.000613018; return;}
1116 if (runno >= 1200 && runno <= 1299) {scale = 1.000832338; return;}
1117 if (runno >= 1300 && runno <= 1399) {scale = 1.000803640; return;}
1118 if (runno >= 1400 && runno <= 1499) {scale = 1.000770454; return;}
1119 if (runno >= 1500 && runno <= 1599) {scale = 1.000786608; return;}
1120 if (runno >= 1600 && runno <= 1699) {scale = 1.000718089; return;}
1121 if (runno >= 1700 && runno <= 1799) {scale = 1.000826042; return;}
1122 if (runno >= 1800 && runno <= 1899) {scale = 1.000638150; return;}
1123 if (runno >= 1900 && runno <= 1999) {scale = 1.000529173; return;}
1124 if (runno >= 2000) {
1125 B2ERROR("scale_momenta not ready for this exp,run "
1126 << expno << "," << runno);
1127 }
1128 } else if (expno == 39) {
1129 if (runno >= 0 && runno <= 99) {scale = 1.000610857; return;}
1130 if (runno >= 100 && runno <= 199) {scale = 1.000838583; return;}
1131 if (runno >= 200 && runno <= 299) {scale = 1.00105918 ; return;}
1132 if (runno >= 300 && runno <= 399) {scale = 1.00105841 ; return;}
1133 if (runno >= 400 && runno <= 499) {scale = 1.001025523; return;}
1134 if (runno >= 500 && runno <= 599) {scale = 1.000967373; return;}
1135 if (runno >= 600 && runno <= 699) {scale = 1.000898585; return;}
1136 if (runno >= 700 && runno <= 799) {scale = 1.001003199; return;}
1137 if (runno >= 800 && runno <= 899) {scale = 1.000897072; return;}
1138 if (runno >= 900 && runno <= 999) {scale = 1.000972551; return;}
1139 if (runno >= 1000 && runno <= 1099) {scale = 1.001044677; return;}
1140 if (runno >= 1100 && runno <= 1199) {scale = 1.00106451 ; return;}
1141 if (runno >= 1200 && runno <= 1299) {scale = 1.00108570 ; return;}
1142 if (runno >= 1300 && runno <= 1399) {scale = 1.00102381 ; return;}
1143 if (runno >= 1400) {
1144 B2ERROR("scale_momenta not ready for this exp,run "
1145 << expno << "," << runno);
1146 }
1147 } else if (expno == 41) {
1148 if (runno >= 0 && runno <= 99) {scale = 1.00189378; return;}
1149 if (runno >= 100 && runno <= 199) {scale = 1.00197304; return;}
1150 if (runno >= 200 && runno <= 299) {scale = 1.00204049; return;}
1151 if (runno >= 300 && runno <= 399) {scale = 1.00205065; return;}
1152 if (runno >= 400 && runno <= 499) {scale = 1.00199205; return;}
1153 if (runno >= 500 && runno <= 599) {scale = 1.00195618; return;}
1154 if (runno >= 600 && runno <= 699) {scale = 1.00200889; return;}
1155 if (runno >= 700 && runno <= 799) {scale = 1.00190365; return;}
1156 if (runno >= 800 && runno <= 899) {scale = 1.00204192; return;}
1157 if (runno >= 900 && runno <= 999) {scale = 1.00196542; return;}
1158 if (runno >= 1000 && runno <= 1099) {scale = 1.00189706; return;}
1159 if (runno >= 1100 && runno <= 1199) {scale = 1.00187422; return;}
1160 if (runno >= 1200 && runno <= 1299) {scale = 1.00183714; return;}
1161 if (runno >= 1300) {
1162 B2ERROR("scale_momenta not ready for this exp,run "
1163 << expno << "," << runno);
1164 }
1165 } else if (expno == 43) {
1166 if (runno >= 0 && runno <= 99) {scale = 1.00151737; return;}
1167 if (runno >= 100 && runno <= 199) {scale = 1.00110489; return;}
1168 if (runno >= 200 && runno <= 299) {scale = 1.00108144; return;}
1169 if (runno >= 300 && runno <= 399) {scale = 1.00114918; return;}
1170 if (runno >= 400 && runno <= 499) {scale = 1.00122723; return;}
1171 if (runno >= 500 && runno <= 599) {scale = 1.00111069; return;}
1172 if (runno >= 600 && runno <= 699) {scale = 1.00115667; return;}
1173 if (runno >= 700 && runno <= 799) {scale = 1.00113759; return;}
1174 if (runno >= 800 && runno <= 899) {scale = 1.00115609; return;}
1175 if (runno >= 900 && runno <= 999) {scale = 1.00105426; return;}
1176 //tentative for quality check of 5S mdst in 2009 Ang.-Sep.
1177 // if (runno>=1000 && runno <=1034) {scale = 1.00099199; return;}
1178 // if (runno>=1035 && runno <=1099) {scale = 1.00111222; return;}
1179 if (runno >= 1000 && runno <= 1099) {scale = 1.00111210; return;}
1180 if (runno >= 1100 && runno <= 1199) {scale = 1.00123104; return;}
1181 if (runno >= 1200) {
1182 B2ERROR("scale_momenta not ready for this exp,run "
1183 << expno << "," << runno);
1184 }
1185 } else if (expno == 45) {
1186 if (runno >= 0 && runno <= 99) {scale = 1.00136477; return;}
1187 if (runno >= 100 && runno <= 199) {scale = 1.00151600; return;}
1188 if (runno >= 200 && runno <= 299) {scale = 1.00146757; return;}
1189 if (runno >= 300 && runno <= 399) {scale = 1.00153299; return;}
1190 if (runno >= 400 && runno <= 499) {scale = 1.00159018; return;}
1191 if (runno >= 500) {
1192 B2ERROR("scale_momenta not ready for this exp,run "
1193 << expno << "," << runno);
1194 }
1195 } else if (expno == 47) {
1196 if (runno >= 0 && runno <= 99) {scale = 1.00166672; return;}
1197 if (runno >= 100 && runno <= 199) {scale = 1.00165120; return;}
1198 if (runno >= 200 && runno <= 299) {scale = 1.00175597; return;}
1199 if (runno >= 300 && runno <= 399) {scale = 1.00177319; return;}
1200 if (runno >= 400 && runno <= 499) {scale = 1.00179552; return;}
1201 if (runno >= 500 && runno <= 599) {scale = 1.00179413; return;}
1202 if (runno >= 600 && runno <= 699) {scale = 1.00186237; return;}
1203 if (runno >= 700 && runno <= 799) {scale = 1.00183016; return;}
1204 if (runno >= 800 && runno <= 899) {scale = 1.00184324; return;}
1205 if (runno >= 900) {
1206 B2ERROR("scale_momenta not ready for this exp,run "
1207 << expno << "," << runno);
1208 }
1209 } else if (expno == 49) {
1210 if (runno >= 0 && runno <= 99) {scale = 1.00171645; return;}
1211 if (runno >= 100 && runno <= 199) {scale = 1.00177728; return;}
1212 if (runno >= 200 && runno <= 299) {scale = 1.00173301; return;}
1213 if (runno >= 300 && runno <= 399) {scale = 1.00162075; return;}
1214 if (runno >= 400 && runno <= 499) {scale = 1.00163153; return;}
1215 if (runno >= 500 && runno <= 599) {scale = 1.00168559; return;}
1216 if (runno >= 600 && runno <= 699) {scale = 1.00139227; return;}
1217 if (runno >= 700 && runno <= 799) {scale = 1.00148583; return;}
1218 if (runno >= 800 && runno <= 899) {scale = 1.00150403; return;}
1219 if (runno >= 900 && runno <= 999) {scale = 1.00142759; return;}
1220 if (runno >= 1000 && runno <= 1099) {scale = 1.00134573; return;}
1221 if (runno >= 1100 && runno <= 1199) {scale = 1.00138313; return;}
1222 if (runno >= 1200 && runno <= 1299) {scale = 1.00151369; return;}
1223 if (runno >= 1300) {
1224 B2ERROR("scale_momenta not ready for this exp,run "
1225 << expno << "," << runno);
1226 }
1227 } else if (expno == 51) {
1228 if (runno >= 0 && runno <= 99) {scale = 1.00165035; return;}
1229 if (runno >= 100 && runno <= 199) {scale = 1.00161504; return;}
1230 if (runno >= 200 && runno <= 299) {scale = 1.00160162; return;}
1231 if (runno >= 300 && runno <= 399) {scale = 1.00152725; return;}
1232 if (runno >= 400 && runno <= 499) {scale = 1.00149943; return;}
1233 if (runno >= 500 && runno <= 599) {scale = 1.00141294; return;}
1234 if (runno >= 600 && runno <= 699) {scale = 1.00140154; return;}
1235 if (runno >= 700 && runno <= 799) {scale = 1.00140759; return;}
1236 if (runno >= 800 && runno <= 899) {scale = 1.00133671; return;}
1237 if (runno >= 900 && runno <= 999) {scale = 1.00136792; return;}
1238 if (runno >= 1000 && runno <= 1099) {scale = 1.00135251; return;}
1239 if (runno >= 1100 && runno <= 1199) {scale = 1.00138229; return;}
1240 if (runno >= 1200 && runno <= 1299) {scale = 1.00134938; return;}
1241 if (runno >= 1300 && runno <= 1399) {scale = 1.00106240; return;}
1242 if (runno >= 1400 && runno <= 1499) {scale = 1.00132666; return;}
1243 if (runno >= 1500 && runno <= 1599) {scale = 1.00132654; return;}
1244 if (runno >= 1600 && runno <= 1699) {scale = 1.00146619; return;}
1245 if (runno >= 1700 && runno <= 1799) {scale = 1.00131902; return;}
1246 if (runno >= 1800 && runno <= 1899) {scale = 1.00114243; return;}
1247 if (runno >= 1900) {
1248 B2ERROR("scale_momenta not ready for this exp,run "
1249 << expno << "," << runno);
1250 }
1251 } else if (expno == 53) {
1252 if (runno >= 0 && runno <= 99) {scale = 1.00125475; return;}
1253 if (runno >= 100 && runno <= 199) {scale = 1.00124954; return;}
1254 if (runno >= 200 && runno <= 299) {scale = 1.00122914; return;}
1255 if (runno >= 300) {
1256 B2ERROR("scale_momenta not ready for this exp,run "
1257 << expno << "," << runno);
1258 }
1259 } else if (expno == 55) {
1260 if (runno >= 0 && runno <= 99) {scale = 1.00119352; return;}
1261 if (runno >= 100 && runno <= 199) {scale = 1.00117130; return;}
1262 if (runno >= 200 && runno <= 299) {scale = 1.00115825; return;}
1263 if (runno >= 300 && runno <= 399) {scale = 1.00125005; return;}
1264 if (runno >= 400 && runno <= 499) {scale = 1.00124720; return;}
1265 if (runno >= 500 && runno <= 599) {scale = 1.00122234; return;}
1266 if (runno >= 600 && runno <= 699) {scale = 1.00128709; return;}
1267 if (runno >= 700 && runno <= 799) {scale = 1.00123081; return;}
1268 if (runno >= 800 && runno <= 899) {scale = 1.00124198; return;}
1269 if (runno >= 900 && runno <= 999) {scale = 1.00131118; return;}
1270 if (runno >= 1000 && runno <= 1099) {scale = 1.00132496; return;}
1271 if (runno >= 1100 && runno <= 1199) {scale = 1.00126186; return;}
1272 if (runno >= 1200 && runno <= 1299) {scale = 1.00127849; return;}
1273 if (runno >= 1300 && runno <= 1399) {scale = 1.00135312; return;}
1274 if (runno >= 1400 && runno <= 1499) {scale = 1.00136637; return;}
1275 if (runno >= 1500 && runno <= 1599) {scale = 1.00136270; return;}
1276 if (runno >= 1600 && runno <= 1699) {scale = 1.00118422; return;}
1277 if (runno >= 1700 && runno <= 1799) {scale = 1.00142667; return;}
1278 if (runno >= 1800) {
1279 B2ERROR("scale_momenta not ready for this exp,run "
1280 << expno << "," << runno);
1281 }
1282 } else if (expno == 61) {
1283 if (runno >= 0 && runno <= 99) {scale = 1.00103013; return;}
1284 if (runno >= 100 && runno <= 199) {scale = 1.00116185; return;}
1285 if (runno >= 200 && runno <= 299) {scale = 1.00133560; return;}
1286 if (runno >= 300 && runno <= 399) {scale = 1.00145027; return;}
1287 if (runno >= 400 && runno <= 499) {scale = 1.00147949; return;}
1288 if (runno >= 500 && runno <= 599) {scale = 1.00151022; return;}
1289 if (runno >= 600 && runno <= 699) {scale = 1.00150439; return;}
1290 if (runno >= 700 && runno <= 799) {scale = 1.00155006; return;}
1291 if (runno >= 800 && runno <= 899) {scale = 1.00162396; return;}
1292 if (runno >= 900 && runno <= 999) {scale = 1.00168542; return;}
1293 if (runno >= 1000 && runno <= 1099) {scale = 1.00168249; return;}
1294 if (runno >= 1100 && runno <= 1207) {scale = 1.00166891; return;}
1295 if (runno >= 1208 && runno <= 1299) {scale = 1.00249956; return;}
1296 if (runno >= 1300 && runno <= 1399) {scale = 1.00255134; return;}
1297 if (runno >= 1400) {
1298 B2ERROR("scale_momenta not ready for this exp,run "
1299 << expno << "," << runno);
1300 }
1301 } else if (expno == 63) {
1302 if (runno >= 0 && runno <= 99) {scale = 1.00129667; return;}
1303 if (runno >= 100 && runno <= 199) {scale = 1.00123725; return;}
1304 if (runno >= 200 && runno <= 299) {scale = 1.00126795; return;}
1305 if (runno >= 300 && runno <= 399) {scale = 1.00122458; return;}
1306 if (runno >= 400 && runno <= 499) {scale = 1.00116489; return;}
1307 if (runno >= 500 && runno <= 599) {scale = 1.00116968; return;}
1308 if (runno >= 600 && runno <= 699) {scale = 1.000918379; return;}
1309 if (runno >= 700 && runno <= 799) {scale = 1.0010429; return;}
1310 if (runno >= 800) {
1311 B2ERROR("scale_momenta not ready for this exp,run "
1312 << expno << "," << runno);
1313 }
1314 } else if (expno == 65) {
1315 if (runno >= 0 && runno <= 99) {scale = 1.00116975; return;}
1316 if (runno >= 100 && runno <= 199) {scale = 1.00111926; return;}
1317 if (runno >= 200 && runno <= 299) {scale = 1.00110162; return;}
1318 if (runno >= 300 && runno <= 399) {scale = 1.00109524; return;}
1319 if (runno >= 400 && runno <= 499) {scale = 1.00106913; return;}
1320 if (runno >= 500 && runno <= 599) {scale = 1.00110941; return;}
1321 if (runno >= 600 && runno <= 699) {scale = 1.000897865; return;}
1322 if (runno >= 700 && runno <= 999) {scale = 1.00104385; return;}
1323 if (runno >= 1000 && runno <= 1299) {scale = 1.000876489; return;}
1324 if (runno >= 1000) {
1325 B2ERROR("scale_momenta not ready for this exp,run "
1326 << expno << "," << runno);
1327 }
1328 } else if (expno == 67) {
1329 if (runno >= 0 && runno <= 199) {scale = 1.000826364; return;}
1330 if (runno >= 200 && runno <= 299) {scale = 1.000836576; return;}
1331 if (runno >= 300 && runno <= 399) {scale = 1.000904815; return;}
1332 if (runno >= 400 && runno <= 499) {scale = 1.000966045; return;}
1333 if (runno >= 500 && runno <= 599) {scale = 1.000988147; return;}
1334 if (runno >= 600 && runno <= 699) {scale = 1.000988147; return;}
1335 if (runno >= 700 && runno <= 742) {scale = 1.000837414; return;}
1336 if (runno >= 1000 && runno <= 1099) {scale = 1.000984865; return;}
1337 if (runno >= 1100 && runno <= 1123) {scale = 1.00105248 ; return;}
1338 if (runno >= 1124) {
1339 B2ERROR("scale_momenta not ready for this exp,run "
1340 << expno << "," << runno);
1341 }
1342 } else if (expno == 69) {
1343 if (runno >= 0 && runno <= 99) {scale = 1.000791450; return;}
1344 if (runno >= 100 && runno <= 199) {scale = 1.000891748; return;}
1345 if (runno >= 200 && runno <= 299) {scale = 1.000866165; return;}
1346 if (runno >= 300 && runno <= 399) {scale = 1.000838834; return;}
1347 if (runno >= 400 && runno <= 499) {scale = 1.000811878; return;}
1348 if (runno >= 500 && runno <= 599) {scale = 1.000779810; return;}
1349 if (runno >= 600 && runno <= 699) {scale = 1.000799086; return;}
1350 if (runno >= 700 && runno <= 799) {scale = 1.000833797; return;}
1351 if (runno >= 800 && runno <= 899) {scale = 1.000875203; return;}
1352 if (runno >= 900 && runno <= 999) {scale = 1.000891998; return;}
1353 if (runno >= 1000 && runno <= 1099) {scale = 1.000921074; return;}
1354 if (runno >= 1100 && runno <= 1199) {scale = 1.000900829; return;}
1355 if (runno >= 1200 && runno <= 1299) {scale = 1.000958405; return;}
1356 if (runno >= 1300 && runno <= 1399) {scale = 1.000836841; return;}
1357 if (runno >= 1400) {
1358 B2ERROR("scale_momenta not ready for this exp,run "
1359 << expno << "," << runno);
1360 }
1361 } else if (expno == 71) {
1362 if (runno >= 0 && runno <= 99) {scale = 1.000962999; return;}
1363 if (runno >= 100 && runno <= 199) {scale = 1.001478932; return;}
1364 if (runno >= 200 && runno <= 300) {scale = 1.001486524; return;}
1365 if (runno >= 301 && runno <= 384) {scale = 1.001430843; return;}
1366 if (runno >= 385 && runno <= 499) {scale = 1.001505696; return;}
1367 if (runno >= 500 && runno <= 599) {scale = 1.001523980; return;}
1368 if (runno >= 600 && runno <= 699) {scale = 1.001480830; return;}
1369 if (runno >= 1000 && runno <= 1013) {scale = 1.001480830; return;}
1370 if (runno >= 2000 && runno <= 2099) {scale = 1.001617882; return;}
1371 if (runno >= 2100 && runno <= 2199) {scale = 1.001644395; return;}
1372 if (runno >= 2200 && runno <= 2299) {scale = 1.001722184; return;}
1373 if (runno >= 700 && runno <= 999) {
1374 B2ERROR("scale_momenta not ready for this exp,run "
1375 << expno << "," << runno);
1376 }
1377 if (runno >= 1014 && runno <= 1999) {
1378 B2ERROR("scale_momenta not ready for this exp,run "
1379 << expno << "," << runno);
1380 }
1381 if (runno >= 2299) {
1382 B2ERROR("scale_momenta not ready for this exp,run "
1383 << expno << "," << runno);
1384 }
1385 } else if (expno == 73) {
1386 if (runno >= 0 && runno <= 99) {scale = 1.000721587; return;}
1387 if (runno >= 100 && runno <= 199) {scale = 1.000707089; return;}
1388 if (runno >= 200 && runno <= 299) {scale = 1.000722517; return;}
1389 if (runno >= 300 && runno <= 399) {scale = 1.000722517; return;} //nodata
1390 if (runno >= 400 && runno <= 499) {scale = 1.000750776; return;}
1391 if (runno >= 500 && runno <= 599) {scale = 1.000729771; return;}
1392 if (runno >= 600 && runno <= 699) {scale = 1.000751190; return;}
1393 if (runno >= 700 && runno <= 799) {scale = 1.000702455; return;}
1394 if (runno >= 800 && runno <= 899) {scale = 1.000771074; return;}
1395 if (runno >= 900 && runno <= 999) {scale = 1.000868463; return;}
1396 if (runno >= 1000) {
1397 B2ERROR("scale_momenta not ready for this exp,run "
1398 << expno << "," << runno);
1399 }
1400
1401 } else
1402 B2ERROR("scale_momenta mode=2 not ready for exp " << expno);
1403 }
1404 return;
1405 }
1406
1407//=====================================================================
1408
1409// Scale values are obtained from cosmic data.
1410//
1411// [EXP]
1412// EXP15: 20011205_2146
1413// EXP : 20010507_0455
1414// EXP7 : 20000517_1555
1415// EXP7 : 20001015_1102
1416// EXP9 : 20001228_1026
1417// [MC]
1418// 20011214_0817
1419// 20010523_0725
1420// 20001228_1026
1421// 20000911_2205
1422// 20000517_1555
1423// 20000430_1200
1424
1425// SE_REMOVE_BELLE_HEADER=1 is used for debug. --> normally 0!!!
1426//#define SE_REMOVE_BELLE_HEADER 0
1427
1428
1429
1431// Begin of scale_error() implementation
1433
1434 static int SE_Message_Level;
1435 static int SE_Reprocess_Version = 0;
1438 typedef void (*cal_scale_error_func_t)(double scale[5], const double pt, const double tanl);
1445 };
1446
1449 {
1450 return (lhs.m_hadMC == rhs.m_hadMC) && (lhs.m_cosMC == rhs.m_cosMC) && (lhs.m_cosDATA == rhs.m_cosDATA);
1451 }
1452
1453 /*static bool operator!=(const cal_scale_error_func_set_t& lhs, const cal_scale_error_func_set_t& rhs)
1454 {
1455 return !(lhs == rhs);
1456 }*/
1457
1459 static void null_scale(double[5], double, double)
1460 {
1461 return;
1462 }
1463
1464 /***** *****/
1465 /***** misc functions *****/
1466 /***** *****/
1468 static void
1469 get_event_id(int* no_exp, int* no_run, int* no_evt, int* no_frm, int* expmc)
1470 {
1471 *no_exp = -1, *no_run = -1, *no_evt = -1, *no_frm = -1;
1472
1473 belle_event* belle_event;
1474 belle_event = (struct belle_event*)BsGetEnt(BELLE_EVENT, 1, BBS_No_Index);
1475 if (belle_event) {
1476 *no_exp = belle_event->m_ExpNo;
1477 *no_run = belle_event->m_RunNo;
1478 *no_evt = belle_event->m_EvtNo & 0x0fffffff;
1479 *no_frm = (unsigned int)belle_event->m_EvtNo >> 28;
1480 *expmc = belle_event->m_ExpMC;
1481 }
1482 }
1483
1485 static bool
1487 {
1488 Belle::Mdst_event_add_Manager& addmgr = Belle::Mdst_event_add_Manager::get_manager();
1489 if (addmgr.count() >= 1) {
1490
1491 if (addmgr[0].flag_error() == 1) {
1492 if (SE_Message_Level >= 1) B2ERROR("scale_error: already applied");
1493 return true;
1494 } else {
1495 if (SE_Message_Level >= 2) B2ERROR("scale_error: to be applied");
1496 addmgr[0].flag_error(1);
1497 return false;
1498 }
1499
1500 } else {
1501
1502 static int first = 1;
1503 B2ERROR("scale_error: no Mdst_event_add");
1504 if (first) {
1505 B2ERROR("scale_error: analysis continues");
1506 B2ERROR("scale_error: scale_error will not be applied");
1507 first = 0;
1508 }
1509 return true;
1510 }
1511 }
1512
1513
1514 /***** *****/
1515 /***** misc math functions *****/
1516 /***** *****/
1518 inline double
1519 vfunc(const double x, const double x1, const double yc, const double a1, const double a2)
1520 {
1521 return x < x1 ? (x - x1) * a1 + yc :
1522 (x - x1) * a2 + yc ;
1523 }
1525 inline double
1526 cupfunc(const double x, const double x1, const double x2, const double yc, const double a1, const double a2)
1527 {
1528 return x < x1 ? (x - x1) * a1 + yc :
1529 x > x2 ? (x - x2) * a2 + yc : yc;
1530 }
1532 inline double
1533 rootfunc(const double x, const double x1, const double x2, const double yc, const double a1, const double a2)
1534 {
1535 return x < x1 ? (x - x1) * a1 + yc :
1536 x > x2 ? (x2 - x1) * a2 + yc : (x - x1) * a2 + yc;
1537 }
1538
1540 inline double
1541 lambdafunc(const double x, const double x1, const double x2, const double yc, const double a1, const double a2, const double a3)
1542 {
1543 return x < x1 ? (x - x1) * a1 + yc :
1544 x < x2 ? (x - x1) * a2 + yc : (x - x2) * a3 + (x2 - x1) * a2 + yc;
1545 }
1546
1547
1548
1549 /***** *****/
1550 /***** scaling parameters for EXP07-EXP23 *****/
1551 /***** *****/
1552
1553//
1554// Scale error for Exp.7-23 Cosmic MC
1555// old day by somebody
1556//
1558 static void
1559 cal_scale_error_EXP0723_cosmic_mc(double scale[5], const double pt, const double /*tanl*/)
1560 {
1561 // pt
1562 scale[0] = +1.0115E+00 - 3.6966E-02 * pt;
1563 scale[1] = +9.8369E-01 + 3.2783E-02 * pt;
1564 scale[2] = +6.8401E-01 + 1.0190E-01 * pt;
1565 scale[3] = +1.0968E+00 - 3.3011E-02 * pt;
1566 scale[4] = +1.0992E+00 - 2.7929E-02 * pt;
1567 }
1568
1569//
1570// Scale error for Exp.25-27 Cosmic MC
1571// old day by somebody
1572//
1574 static void
1575 cal_scale_error_EXP2527_cosmic_mc(double scale[5], const double pt, const double /*tanl*/)
1576 {
1577 // pt
1578 scale[0] = +1.0257E+00 - 0.30671E-01 * pt;
1579 scale[1] = +1.0503E+00 + 0.97257E-02 * pt;
1580 scale[2] = +0.70751E+00 + 0.93039E-01 * pt;
1581 scale[3] = +1.0720E+00 - 0.15976E-01 * pt;
1582 scale[4] = +1.0530E+00 + 0.63696E-02 * pt;
1583 }
1584
1585//
1586// Scale error for Exp.31 Cosmic MC
1587// July 09th, 2004, by KUSAKA Akito
1588//
1590 static void
1591 cal_scale_error_EXP31_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1592 {
1593 // pt
1594 scale[0] = 1.0874 - 0.26640E-01 * pt;
1595 scale[1] = 1.0320 + 0.18869E-01 * pt;
1596 scale[2] = 0.75302 + 0.89109E-01 * pt;
1597 scale[3] = 1.1435 - 0.73830E-01 * pt;
1598 scale[4] = 1.1227 - 0.19112E-01 * pt;
1599 }
1600
1601//
1602// Scale error for Exp.33 Cosmic MC for caseA
1603// June 21th, 2004, by KUSAKA Akito
1604// July 07th, 2004, modification on scale[3], by KUSAKA Akito
1605//
1606//
1607// Scale error for Exp.35 Cosmic MC for caseB
1608// February 3rd, 2010, by Takeo Higuchi
1609//
1611 static void
1612 cal_scale_error_EXP33_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1613 {
1614 if (SE_Reprocess_Version == 0) {
1615 // pt
1616 scale[0] = 1.1197 - 0.15104E-01 * pt;
1617 scale[1] = 1.0502 + 0.22138E-01 * pt;
1618 scale[2] = 0.75267 + 0.85377E-01 * pt;
1619 // Change to linear fit for robustness (Jul. 07th, 2004. KUSAKA Akito)
1620 // scale[3] = 1.3726 +(-0.31170 + 0.74074E-01*pt)*pt;
1621 scale[3] = 1.1608 - 0.43478E-01 * pt;
1622 scale[4] = 1.0936 + 0.18447E-01 * pt;
1623 } else {
1624 // pt
1625 scale[0] = 0.98971 - 0.12162E-01 * pt;
1626 scale[1] = 1.0132 + 0.22283E-01 * pt;
1627 scale[2] = 0.74947 + 0.81233E-01 * pt;
1628 scale[3] = 1.0601 - 0.54626E-01 * pt;
1629 scale[4] = 1.0454 - 0.33036E-02 * pt;
1630 }
1631 }
1632
1633//
1634// Scale error for Exp.35 Cosmic MC for caseA
1635// June 21th, 2004, by KUSAKA Akito
1636//
1637//
1638// Scale error for Exp.35 Cosmic MC for caseB
1639// February 3rd, 2010, by Takeo Higuchi
1640//
1642 static void
1643 cal_scale_error_EXP35_cosmic_mc(double scale[5], double pt, double tanl)
1644 {
1645 if (SE_Reprocess_Version == 0) {
1646 // pt
1647 scale[0] = 1.0835 + 0.79781E-02 * pt;
1648 scale[1] = 1.0685 + 0.13339E-01 * pt;
1649 scale[2] = 0.72615 + 0.96936E-01 * pt;
1650 scale[3] = 1.1298 - 0.35734E-01 * pt;
1651 scale[4] = 1.0994 + 0.13150E-01 * pt;
1652 } else {
1653 // pt
1654 cal_scale_error_EXP33_cosmic_mc(scale, pt, tanl);
1655 }
1656 }
1657
1658//
1659// Scale error for Exp.37 Cosmic MC
1660// July 21st, 2004, by KUSAKA Akito
1661//
1663 static void
1664 cal_scale_error_EXP37_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1665 {
1666 // pt
1667 scale[0] = 1.0694 - 0.19048E-01 * pt;
1668 scale[1] = 1.0732 + 0.95531E-02 * pt;
1669 scale[2] = 0.74888 + 0.89957E-01 * pt;
1670 scale[3] = 1.1107 - 0.57216E-01 * pt;
1671 scale[4] = 1.1098 - 0.13305E-01 * pt;
1672 }
1673
1674//
1675// Scale error for Exp.39,41 Cosmic MC
1676// (Made from Exp.39 Cosmic MC. Confirmed for exp39,41)
1677// April, 20th, 2005, by KUSAKA Akito
1678//
1680 static void
1681 cal_scale_error_EXP3941_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1682 {
1683 // pt
1684 scale[0] = 1.055465 - 0.2863498E-01 * pt;
1685 scale[1] = 1.005986 + 0.2709512E-01 * pt;
1686 scale[2] = 0.7459061 + 0.8352030E-01 * pt;
1687 scale[3] = 1.056039 - 0.6258768E-01 * pt;
1688 scale[4] = 1.043329 - 0.2975207E-03 * pt;
1689 }
1690
1691//
1692// Scale error for Exp.43 Cosmic MC
1693// Sep., 12th, 2005, by KUSAKA Akito
1694//
1696 static void
1697 cal_scale_error_EXP43_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1698 {
1699 // pt
1700 scale[0] = 1.013759 - 0.8743831E-02 * pt;
1701 scale[1] = 1.071626 - 0.1333353E-01 * pt;
1702 scale[2] = 0.7507483 + 0.8399138E-01 * pt;
1703 scale[3] = 1.054345 - 0.5644758E-01 * pt;
1704 scale[4] = 1.020721 + 0.1323117E-01 * pt;
1705 }
1706
1707//
1708// Scale error for Exp.45 Cosmic MC
1709// May., 27th, 2006, by fmiyuki
1710//
1712 static void
1713 cal_scale_error_EXP45_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1714 {
1715 // pt
1716 scale[0] = 1.011008 - 0.2272887E-01 * pt;
1717 scale[1] = 1.030603 + 0.8892579E-02 * pt;
1718 scale[2] = 0.7181793 + 0.9717058E-01 * pt;
1719 scale[3] = 1.065804 - 0.6852337E-01 * pt;
1720 scale[4] = 1.085136 - 0.2324515E-01 * pt;
1721 }
1722
1723//
1724// Scale error for Exp.47 Cosmic MC
1725// May., 27th, 2006, by fmiyuki
1726//
1728 static void
1729 cal_scale_error_EXP47_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1730 {
1731 // pt
1732 scale[0] = 0.9806778 - 0.2010826E-02 * pt;
1733 scale[1] = 0.9996797 + 0.2633917E-01 * pt;
1734 scale[2] = 0.7450445 + 0.7637244E-01 * pt;
1735 scale[3] = 1.084419 - 0.6828102E-01 * pt;
1736 scale[4] = 1.013550 + 0.1201861E-01 * pt;
1737 }
1738
1739//
1740// Scale error for Exp.49 Cosmic MC
1741// May., 27th, 2006, by fmiyuki
1742//
1744 static void
1745 cal_scale_error_EXP49_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1746 {
1747 // pt
1748 scale[0] = 1.000635 - 0.1659129E-01 * pt;
1749 scale[1] = 1.046513 - 0.2994663E-02 * pt;
1750 scale[2] = 0.7241409 + 0.9558808E-01 * pt;
1751 scale[3] = 1.062597 - 0.6663921E-01 * pt;
1752 scale[4] = 1.076486 - 0.2023062E-01 * pt;
1753 }
1754
1755//
1756// Scale error for Exp.51 Cosmic MC
1757// May 24th, 2007 by higuchit
1758//
1760 static void
1761 cal_scale_error_EXP51_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1762 {
1763 // pt
1764 scale[0] = 0.98242 - 0.71780E-02 * pt;
1765 scale[1] = 1.0465 + 0.44401E-03 * pt;
1766 scale[2] = 0.71433 + 0.10176 * pt;
1767 scale[3] = 1.0875 - 0.80972E-01 * pt;
1768 scale[4] = 1.0777 - 0.20428E-01 * pt;
1769 }
1770
1771//
1772// Scale error for Exp.53 Cosmic MC
1773// May 24th, 2007 by higuchit
1774//
1776 static void
1777 cal_scale_error_EXP53_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1778 {
1779 // pt
1780 scale[0] = 0.99832 - 0.17290E-01 * pt;
1781 scale[1] = 1.0434 + 0.47995E-02 * pt;
1782 scale[2] = 0.72111 + 0.10093 * pt;
1783 scale[3] = 1.1022 - 0.87951E-01 * pt;
1784 scale[4] = 1.0643 - 0.11962E-01 * pt;
1785 }
1786
1787//
1788// Scale error for Exp.55 Cosmic MC
1789// June 21st, 2007 by higuchit
1790//
1792 static void
1793 cal_scale_error_EXP55_cosmic_mc(double scale[5], double pt, double /*tanl*/)
1794 {
1795 // pt
1796 scale[0] = 0.98871 - 0.88399E-02 * pt;
1797 scale[1] = 1.0159 + 0.16468E-01 * pt;
1798 scale[2] = 0.72813 + 0.94737E-01 * pt;
1799 scale[3] = 1.1060 - 0.88323E-01 * pt;
1800 scale[4] = 1.0914 - 0.30607E-01 * pt;
1801 }
1802
1803//
1804// Scale error for Exp.61-65 Cosmic MC
1805// March 4th, 2009 by higuchit
1806//
1808 static void
1809 cal_scale_error_EXP6165_cosmic_mc(double scale[5], double pt, double tanl)
1810 {
1811 // pt
1812 scale[0] = 0.97322 - 0.29003E-02 * pt;
1813 scale[1] = 0.94704 + 0.44719E-01 * pt;
1814 scale[2] = 0.73547 + 0.98431E-01 * pt;
1815 scale[3] = 1.0752 - 0.77818E-01 * pt;
1816 scale[4] = 1.0759 - 0.27057E-01 * pt;
1817
1818 // tanl
1819 scale[0] *= 0.99600 - 0.97573E-02 * tanl;
1820 scale[1] *= 1.0080 - 0.37122E-01 * tanl;
1821 scale[2] *= 0.99150 - 0.13390E-01 * tanl;
1822 scale[3] *= 0.99758 - 0.43508E-01 * tanl;
1823 scale[4] *= 0.99913 + 0.34211E-01 * tanl;
1824 }
1825
1826//
1827// Scale error for Exp.67 Cosmic MC
1828// October 8th, 2009 by higuchit
1829//
1831 static void
1832 cal_scale_error_EXP67_cosmic_mc(double scale[5], double pt, double tanl)
1833 {
1834 // pt
1835 scale[0] = 0.99845 - 0.18739E-01 * pt;
1836 scale[1] = 1.0024 + 0.17833E-01 * pt;
1837 scale[2] = 0.72369 + 0.96994E-01 * pt;
1838 scale[3] = 1.0605 - 0.64072E-01 * pt;
1839 scale[4] = 1.0623 - 0.14320E-01 * pt;
1840
1841 // tanl
1842 scale[0] *= 0.99597 - 0.13069E-01 * tanl;
1843 scale[1] *= 1.0072 - 0.18622E-01 * tanl;
1844 scale[2] *= 0.99515 - 0.16591E-01 * tanl;
1845 scale[3] *= 0.99466 - 0.14489E-02 * tanl;
1846 scale[4] *= 1.0036 - 0.15095E-01 * tanl;
1847 }
1848
1849
1850//
1851// Scale error for Exp.69 Cosmic MC
1852// January 29th, 2010 by higuchit
1853// Scale error for Exp.71 Cosmic MC
1854// May 12th, 2010 by higuchit
1855//
1857 static void
1858 cal_scale_error_EXP6971_cosmic_mc(double scale[5], double pt, double tanl)
1859 {
1860 // pt
1861 scale[0] = 0.96783 - 0.37174E-02 * pt;
1862 scale[1] = 0.97888 + 0.34689E-01 * pt;
1863 scale[2] = 0.80870 + 0.68302E-01 * pt;
1864 scale[3] = 1.0615 - 0.60750E-01 * pt;
1865 scale[4] = 1.0372 - 0.52332E-03 * pt;
1866
1867 // tanl
1868 scale[0] *= 0.99897 + 0.62207E-02 * tanl;
1869 scale[1] *= 1.0037 + 0.10714E-01 * tanl;
1870 scale[2] *= 0.99129 - 0.92521E-02 * tanl;
1871 scale[3] *= 0.99483 - 0.43402E-02 * tanl;
1872 scale[4] *= 1.0062 + 0.15306E-01 * tanl;
1873 }
1874
1875
1876//
1877// Scale error for Exp.7-23 Cosmic data
1878// old day by somebody
1879//
1881 static void
1882 cal_scale_error_EXP0723_cosmic_data(double scale[5], const double pt, const double /*tanl*/)
1883 {
1884 // pt
1885 scale[0] = +1.1280E+00 - 7.6839E-03 * pt;
1886 scale[1] = +1.1368E+00 + 2.8106E-02 * pt;
1887 scale[2] = +7.6448E-01 + 1.1248E-01 * pt;
1888 scale[3] = +1.1396E+00 - 3.6738E-02 * pt;
1889 scale[4] = +1.1766E+00 - 2.7477E-02 * pt;
1890 }
1891
1892//
1893// Scale error for Exp.25-27 Cosmic data
1894// old day by somebody
1895//
1897 static void
1898 cal_scale_error_EXP2527_cosmic_data(double scale[5], const double pt, const double /*tanl*/)
1899 {
1900 // pt
1901 scale[0] = +1.1002E+00 + 3.9852E-02 * pt;
1902 scale[1] = rootfunc(pt, 1.0015, 1.6591, 1.0420, -0.31809, 0.17149);
1903 scale[2] = +8.4706E-01 + 0.8914E-01 * pt;
1904 scale[3] = +1.1067E+00 + 1.0304E-02 * pt;
1905 scale[4] = +1.0495E+00 + 3.9923E-02 * pt;
1906 }
1907
1908//
1909// Scale error for Exp.31 Cosmic data
1910// July 9th, 2004, by KUSAKA Akito
1911//
1913 static void
1914 cal_scale_error_EXP31_cosmic_data(double scale[5], double pt, double /*tanl*/)
1915 {
1916 // pt
1917 scale[0] = 1.1908 + 0.20678E-02 * pt;
1918 scale[1] = 1.0304 + 0.54826E-01 * pt;
1919 scale[2] = 1.0806 + 0.33829E-01 * pt;
1920 scale[3] = 1.1325 - 0.34811E-01 * pt;
1921 scale[4] = 1.1549 - 0.20974E-01 * pt;
1922 }
1923
1924//
1925// Scale error for Exp.33 Cosmic data for caseA
1926// June 21th, 2004, by KUSAKA Akito
1927//
1928//
1929// Scale error for Exp.35 Cosmic data for caseB
1930// February 3rd, 2010, by Takeo Higuchi
1931//
1933 static void
1934 cal_scale_error_EXP33_cosmic_data(double scale[5], double pt, double /*tanl*/)
1935 {
1936 if (SE_Reprocess_Version == 0) {
1937 // pt
1938 scale[0] = 1.2175 + 0.14290E-01 * pt;
1939 scale[1] = 1.0362 + 0.80614E-01 * pt;
1940 scale[2] = 1.0313 + 0.12930E-01 * pt;
1941 scale[3] = 1.0411 + 0.17319E-01 * pt;
1942 scale[4] = 1.0445 + 0.27526E-01 * pt;
1943 } else {
1944 // pt
1945 scale[0] = 1.2712 - 0.42098E-01 * pt;
1946 scale[1] = 1.0634 - 0.13652E-01 * pt;
1947 scale[2] = 0.95435 + 0.64895E-01 * pt;
1948 scale[3] = 1.0758 + 0.10778E-01 * pt;
1949 scale[4] = 1.0892 - 0.75700E-02 * pt;
1950 }
1951 }
1952
1953//
1954// Scale error for Exp.35 Cosmic data for caseA
1955// June 21th, 2004, by KUSAKA Akito
1956// July 07th, 2004, modification on scale[3], by KUSAKA Akito
1957//
1958//
1959// Scale error for Exp.35 Cosmic data for caseB
1960// February 3rd, 2010, by Takeo Higuchi
1961//
1963 static void
1964 cal_scale_error_EXP35_cosmic_data(double scale[5], double pt, double tanl)
1965 {
1966 if (SE_Reprocess_Version == 0) {
1967 // pt
1968 scale[0] = 1.1084 + 0.45825E-01 * pt;
1969 scale[1] = 1.1014 + 0.14211E-01 * pt;
1970 scale[2] = 0.99716 + 0.52509E-01 * pt;
1971 scale[3] = 1.1361 - 0.25355E-01 * pt;
1972 scale[4] = 1.1079 - 0.92563E-02 * pt;
1973 } else {
1974 cal_scale_error_EXP33_cosmic_data(scale, pt, tanl);
1975 }
1976 }
1977
1978//
1979// Scale error for Exp.37 Cosmic data
1980// July 21st, 2004, by KUSAKA Akito
1981//
1983 static void
1984 cal_scale_error_EXP37_cosmic_data(double scale[5], double pt, double /*tanl*/)
1985 {
1986 // pt
1987 scale[0] = 1.2129 + 0.36787E-01 * pt;
1988 scale[1] = 1.0750 + 0.32722E-01 * pt;
1989 scale[2] = 0.98340 + 0.39096E-01 * pt;
1990 scale[3] = 1.1768 - 0.43894E-01 * pt;
1991 scale[4] = 1.1275 - 0.12562E-02 * pt;
1992 }
1993
1994//
1995// Scale error for Exp.39,41 Cosmic data
1996// April 20th, 2004, by KUSAKA Akito
1997//
1999 static void
2000 cal_scale_error_EXP3941_cosmic_data(double scale[5], double pt, double /*tanl*/)
2001 {
2002 // pt
2003 scale[0] = 1.182285 + 0.4142677E-01 * pt;
2004 scale[1] = 1.090022 + 0.2995044E-01 * pt;
2005 scale[2] = 0.9581690 + 0.5764173E-01 * pt;
2006 scale[3] = 1.119173 - 0.2177483E-01 * pt;
2007 scale[4] = 1.126323 - 0.3786523E-02 * pt;
2008 }
2009
2010//
2011// Scale error for Exp.43 Cosmic data
2012// Sep., 12th, 2005 by KUSAKA Akito
2013//
2015 static void
2016 cal_scale_error_EXP43_cosmic_data(double scale[5], double pt, double /*tanl*/)
2017 {
2018 // pt
2019 scale[0] = 1.262359 + 0.1411302E-01 * pt;
2020 scale[1] = 1.051793 + 0.6225422E-01 * pt;
2021 scale[2] = 0.9668697 + 0.5492099E-01 * pt;
2022 scale[3] = 1.110838 - 0.2386986E-01 * pt;
2023 scale[4] = 1.106516 + 0.1239970E-01 * pt;
2024 }
2025
2026//
2027// Scale error for Exp.45+47 Cosmic data
2028// May., 29th, 2006 by fmiyuki
2029//
2031 static void
2032 cal_scale_error_EXP4547_cosmic_data(double scale[5], double pt, double /*tanl*/)
2033 {
2034 // pt 8bin
2035 scale[0] = 1.164526 + 0.7671143E-01 * pt;
2036 scale[1] = 1.094987 + 0.2949413E-01 * pt;
2037 scale[2] = 1.084826 + 0.2513991E-01 * pt;
2038 scale[3] = 1.099221 - 0.2389658E-02 * pt;
2039 scale[4] = 1.146892 + 0.2682884E-02 * pt;
2040 }
2041
2042//
2043// Scale error for Exp.49 Cosmic data
2044// May., 27th, 2006 by fmiyuki
2045//
2047 static void
2048 cal_scale_error_EXP49_cosmic_data(double scale[5], double pt, double /*tanl*/)
2049 {
2050 // pt 8bin
2051 scale[0] = 1.243211 + 0.5776083E-01 * pt;
2052 scale[1] = 1.209483 - 0.3366023E-01 * pt;
2053 scale[2] = 1.059087 + 0.4300838E-01 * pt;
2054 scale[3] = 1.123665 + 0.6342933E-02 * pt;
2055 scale[4] = 1.208850 - 0.3171053E-01 * pt;
2056 }
2057
2058//
2059// Scale error for Exp.51 Cosmic data
2060// May 24th, 2007 by higuchit
2061//
2063 static void
2064 cal_scale_error_EXP51_cosmic_data(double scale[5], double pt, double tanl)
2065 {
2066 // pt 5bin
2067 scale[0] = 1.2097 + 0.36177E-01 * pt;
2068 scale[1] = 1.2218 - 0.84772E-02 * pt;
2069 scale[2] = 0.97937 + 0.26397E-01 * pt;
2070 scale[3] = 1.0944 - 0.12745E-02 * pt;
2071 scale[4] = 1.2140 - 0.56809E-01 * pt;
2072
2073 // tanl
2074 scale[0] *= 1.0492 + 0.72972E-01 * tanl;
2075 scale[1] *= 1.0298 + 0.40625E-02 * tanl;
2076 scale[2] *= 0.93367 + 0.11969E-01 * tanl;
2077 scale[3] *= 1.0170 + 0.41039E-01 * tanl;
2078 scale[4] *= 1.0677 - 0.41684E-01 * tanl;
2079 }
2080
2081//
2082// Scale error for Exp.53 Cosmic data
2083// May 24th, 2007 by higuchit
2084//
2086 static void
2087 cal_scale_error_EXP53_cosmic_data(double scale[5], double pt, double /*tanl*/)
2088 {
2089 // pt 5bin
2090 scale[0] = 1.2587 + 0.32782E-01 * pt;
2091 scale[1] = 1.2413 - 0.36535E-01 * pt;
2092 scale[2] = 0.97465 + 0.22937E-01 * pt;
2093 scale[3] = 1.1197 - 0.59050E-02 * pt;
2094 scale[4] = 1.1877 - 0.32893E-01 * pt;
2095 }
2096
2097//
2098// Scale error for Exp.55 Cosmic data
2099// June 21st, 2007 by higuchit
2100//
2102 static void
2103 cal_scale_error_EXP55_cosmic_data(double scale[5], double pt, double tanl)
2104 {
2105 // pt 5bin
2106 scale[0] = 1.2654 + 0.15660E-01 * pt;
2107 scale[1] = 1.0278 + 0.81680E-01 * pt;
2108 scale[2] = 0.94291 + 0.54575E-01 * pt;
2109 scale[3] = 1.1151 - 0.52387E-02 * pt;
2110 scale[4] = 1.1020 + 0.10518E-01 * pt;
2111
2112 // tanl 5bin
2113 scale[0] *= 1.0334 + 0.10236E-01 * tanl;
2114 scale[1] *= 1.0346 + 0.11024E-01 * tanl;
2115 // scale[2] *= 0.91773 -0.52276E-02*tanl;
2116 scale[3] *= 1.0140 + 0.19030E-01 * tanl;
2117 scale[4] *= 1.0345 - 0.90291E-01 * tanl;
2118 }
2119
2120//
2121// Scale error for Exp.61-65 Cosmic data
2122// March 4th, 2009 by higuchit
2123//
2125 static void
2126 cal_scale_error_EXP6165_cosmic_data(double scale[5], double pt, double tanl)
2127 {
2128 // pt 5bin
2129 scale[0] = 1.1184 + 0.55671E-01 * pt;
2130 scale[1] = 1.1142 + 0.74526E-02 * pt;
2131 scale[2] = 0.93626 + 0.66670E-01 * pt;
2132 scale[3] = 1.1003 - 0.11587E-01 * pt;
2133 scale[4] = 1.1589 - 0.40223E-01 * pt;
2134
2135 // tanl 5bin
2136 scale[0] *= 1.0442 - 0.46775E-01 * tanl;
2137 scale[1] *= 1.0337 + 0.44071E-01 * tanl;
2138 // scale[2] *= 0.91898 -0.28268E-02*tanl;
2139 scale[3] *= 1.0037 + 0.29736E-01 * tanl;
2140 scale[4] *= 1.0378 - 0.73239E-01 * tanl;
2141 }
2142
2143//
2144// Scale error for Exp.67 Cosmic data
2145// October 8th, 2009 by higuchit
2146//
2148 static void
2149 cal_scale_error_EXP67_cosmic_data(double scale[5], double pt, double tanl)
2150 {
2151 // pt 5bin
2152 scale[0] = 1.1598 + 0.28880E-01 * pt;
2153 scale[1] = 1.0844 + 0.23384E-01 * pt;
2154 scale[2] = 0.94566 + 0.53157E-01 * pt;
2155 scale[3] = 1.1578 - 0.31156E-01 * pt;
2156 scale[4] = 1.0725 + 0.13714E-01 * pt;
2157
2158 // tanl 5bin
2159 scale[0] *= 1.0223 - 0.56165E-02 * tanl;
2160 scale[1] *= 1.0203 - 0.81857E-02 * tanl;
2161 // scale[2] *= 0.90812 +0.15679E-01*tanl;
2162 scale[3] *= 0.99703 + 0.14976E-01 * tanl;
2163 scale[4] *= 1.0212 + 0.41300E-01 * tanl;
2164 }
2165
2166
2167//
2168// Scale error for Exp.69 Cosmic data
2169// January 29th, 2010 by higuchit
2170// Scale error for Exp.71 Cosmic data
2171// May 12th, 2010 by higuchit
2172//
2174 static void
2175 cal_scale_error_EXP6971_cosmic_data(double scale[5], double pt, double tanl)
2176 {
2177 // pt 5bin
2178 scale[0] = 1.2101 + 0.29496E-01 * pt;
2179 scale[1] = 1.0723 + 0.13773E-01 * pt;
2180 scale[2] = 0.90988 + 0.78667E-01 * pt;
2181 scale[3] = 1.1444 - 0.20780E-01 * pt;
2182 scale[4] = 1.0962 + 0.83309E-02 * pt;
2183
2184 // tanl 5bin
2185 scale[0] *= 1.0207 - 0.17810E-01 * tanl;
2186 scale[1] *= 1.0272 + 0.61498E-01 * tanl;
2187 // scale[2] *= 0.91584 +0.16138E-01*tanl;
2188 scale[3] *= 0.99766 + 0.32434E-01 * tanl;
2189 scale[4] *= 1.0200 - 0.14935E-01 * tanl;
2190 }
2191
2192
2193//
2194// Scale error for Exp.7-23 Hadron MC
2195// old day by somebody
2196//
2198 static void
2199 cal_scale_error_EXP0723_hadronic_mc(double scale[5], const double pt, const double tanl)
2200 {
2201 // pt
2202 scale[0] = vfunc(pt, 0.34602, 1.0605, -0.36011, 0.38189E-01);
2203 scale[1] = 1.0612;
2204 scale[2] = cupfunc(pt, 0.44599, 1.2989, 0.85646, -0.73968, 0.17425);
2205 scale[3] = 1.1460 - 0.57101E-01 * pt;
2206 scale[4] = 1.0859;
2207
2208 // tanl
2209 scale[0] *= +1.0122E+00 + 1.3568E-04 * tanl + 1.9856E-02 * tanl * tanl;
2210 scale[1] *= +1.0002E+00 - 4.5128E-03 * tanl + 1.6211E-02 * tanl * tanl;
2211 scale[2] *= +9.7051E-01 + 2.6876E-02 * tanl + 8.2365E-02 * tanl * tanl;
2212 scale[3] *= +9.7198E-01 + 3.8373E-02 * tanl + 4.9111E-02 * tanl * tanl;
2213 scale[4] *= +9.8880E-01 + 2.2090E-02 * tanl + 2.2701E-02 * tanl * tanl;
2214 }
2215
2216//
2217// Scale error for Exp.25-27 Hadron MC
2218// old day by somebody
2219//
2221 static void
2222 cal_scale_error_EXP2527_hadronic_mc(double scale[5], const double pt, const double tanl)
2223 {
2224 // pt
2225 scale[0] = 1.092E+00 - 0.86138E-01 * pt;
2226 scale[1] = 1.0448E+00 - 0.26158E-01 * pt;
2227 scale[2] = 1.1942E+00 - 1.0025E+00 * pt + 0.85334 * pt * pt - 0.20305 * pt * pt * pt;
2228 scale[3] = 1.1260E+00 - 0.46048E-01 * pt;
2229 scale[4] = 1.0378E+00 + 0.5109E-01 * pt;
2230
2231 // tanl
2232 scale[0] *= +1.0136E+00 + 0.15293E-01 * tanl;
2233 scale[1] *= +0.9936E+00 + 0.71983E-02 * tanl + 0.14004E-01 * tanl * tanl;
2234 scale[2] *= +0.97532E+00 + 0.22718E-01 * tanl + 0.73556E-01 * tanl * tanl;
2235 scale[3] *= vfunc(tanl, -0.26650, 0.92765, -0.13393, 0.11704);
2236 scale[4] *= +0.98203E+00 + 0.21612E-01 * tanl + 0.32751E-01 * tanl * tanl;
2237 }
2238
2239//
2240// Scale error for Exp.31 Hadron MC
2241// July 9th, 2004, by KUSAKA Akito
2242//
2244 static void
2245 cal_scale_error_EXP31_hadronic_mc(double scale[5], double pt, double tanl)
2246 {
2247 // pt
2248 scale[0] = 1.2619 - 0.11170 * pt;
2249 scale[1] = 1.2263 - 0.24619E-01 * pt;
2250 scale[2] = vfunc(pt, 1.1432, 0.87555, -0.24211, 0.10876);
2251 scale[3] = 1.3254 - 0.21162 * pt;
2252 scale[4] = 1.1609 + 0.73808E-02 * pt;
2253
2254 // tanl
2255 scale[3] *= vfunc(tanl, -0.12026, 0.95892, -0.71461E-01, 0.69535E-01);
2256 }
2257
2258//
2259// Scale error for Exp.33, 35 Hadron MC
2260// June 19th, 2004, by KUSAKA Akito
2261// July 09th, 2004, modification on scale[2](pt) for low pt.
2262// July 09th, 2004, modification on scale[3](tanl) for high tanl.
2263//
2265 static void
2266 cal_scale_error_EXP33_hadronic_mc(double scale[5], double pt, double tanl)
2267 {
2268 if (SE_Reprocess_Version == 0) {
2269 // pt
2270 scale[0] = 1.3083 - 0.10894 * pt;
2271 scale[1] = 1.2471 - 0.30959E-01 * pt;
2272 // scale[2] = 0.94594 -0.21216E-01*pt;
2273 scale[2] = vfunc(pt, 0.79736, 0.90954, -0.45673, 0.37072E-02);
2274 scale[3] = 1.3307 - 0.17559 * pt;
2275 scale[4] = 1.2408 - 0.29914E-01 * pt;
2276
2277 // tanl
2278 // scale[3] *= 0.95593 + (0.39351E-01 + 0.10450*tanl)*tanl;
2279 scale[3] *= vfunc(tanl, -0.63864E-01, 0.95936, -0.11035, 0.10057);
2280 } else {
2281 // pt
2282 scale[0] = vfunc(pt, 1.4506, 1.0599, -0.10534, -0.14118);
2283 scale[1] = lambdafunc(pt, 0.23691, 0.47860, 1.1996, -0.39938E-01, 0.23518, -0.62661E-01);
2284 scale[2] = lambdafunc(pt, 0.45865, 0.92603, 0.95622, -0.51715, -0.12868, 0.45187E-01);
2285 scale[3] = 1.2555 - 0.19038 * pt;
2286 scale[4] = vfunc(pt, 0.68946, 1.1772, 0.15927, -0.79017E-01);
2287 }
2288 }
2289
2290//
2291// Scale error for Exp.35 Hadron MC
2292// February 3rd, 2010, by Takeo Higuchi for caseB
2293//
2295 static void
2296 cal_scale_error_EXP35_hadronic_mc(double scale[5], double pt, double tanl)
2297 {
2298 cal_scale_error_EXP33_hadronic_mc(scale, pt, tanl);
2299 }
2300
2301//
2302// Scale error for Exp.37 Hadron MC
2303// July 21st, 2004, by KUSAKA Akito
2304//
2306 static void
2307 cal_scale_error_EXP37_hadronic_mc(double scale[5], double pt, double tanl)
2308 {
2309 // pt
2310 scale[0] = 1.2548 - 0.87786E-01 * pt;
2311 scale[1] = 1.2562 - 0.89296E-03 * pt;
2312 scale[2] = vfunc(pt, 0.67905, 0.91705, -0.57837, -0.37276E-02);
2313 scale[3] = 1.3180 - 0.19459 * pt;
2314 scale[4] = 1.1652 + 0.33812E-01 * pt;
2315
2316 // tanl
2317 scale[3] *= vfunc(tanl, -0.47522E-01, 0.96537, -0.41720E-01, 0.68031E-01);
2318 }
2319
2320//
2321// Scale error for Exp.39,41 Hadron MC
2322// (Made from Exp.39 Hadron MC. Confirmed for exp39,41)
2323// April 20th, by KUSAKA Akito
2324//
2326 static void
2327 cal_scale_error_EXP3941_hadronic_mc(double scale[5], double pt, double /*tanl*/)
2328 {
2329 // pt
2330 scale[0] = 1.236096 - 0.1015809 * pt;
2331 scale[1] = 1.248921 - 0.1130577E-01 * pt;
2332 scale[2] = vfunc(pt, 0.5129282, 0.9300365, -0.9450958, -0.1157168E-01);
2333 scale[3] = vfunc(pt, 1.650362, 0.9371865, -0.2142342, 0.7384746E-01);
2334 scale[4] = vfunc(pt, 0.7497343, 1.204451, 0.1333454, -0.7826934E-01);
2335 }
2336
2337//
2338// Scale error for Exp.43 Hadron MC
2339// Sep. 12th, 2005 by KUSAKA Akito
2340//
2342 static void
2343 cal_scale_error_EXP43_hadronic_mc(double scale[5], double pt, double /*tanl*/)
2344 {
2345 // pt
2346 scale[0] = 1.240166 - 0.1051634 * pt;
2347 scale[1] = 1.257180 - 0.3122512E-01 * pt;
2348 scale[2] = vfunc(pt, 0.5272015, 0.9386514, -0.9648152, -0.1623573E-01);
2349 scale[3] = 1.280515 - 0.1991213 * pt;
2350 scale[4] = vfunc(pt, 0.6579201, 1.192409, 0.1197880, -0.5404800E-01);
2351 }
2352
2353//
2354// Scale error for Exp.45 Hadron MC
2355// May. 27th, 2006 by fmiyuki
2356//
2358 static void
2359 cal_scale_error_EXP45_hadronic_mc(double scale[5], double pt, double tanl)
2360 {
2361 // pt
2362 scale[0] = 1.213823 - .1029683 * pt;
2363 scale[1] = 1.239279 - .3706657E-01 * pt;
2364 scale[2] = vfunc(pt, 0.6145123, 0.8834459, -.4620622, 0.2099150E-01);
2365 scale[3] = 1.253126 - .1884352 * pt;
2366 scale[4] = vfunc(pt, 0.4928604, 1.169158, 0.2063893, -.5428730E-01);
2367
2368 // tanl
2369 scale[2] *= vfunc(tanl, -.1240821, 0.9274375, -.8750933E-01, 0.8611448E-01);
2370 }
2371
2372//
2373// Scale error for Exp.47 Hadron MC
2374// May. 27th, 2006 by fmiyuki
2375//
2377 static void
2378 cal_scale_error_EXP47_hadronic_mc(double scale[5], double pt, double /*tanl*/)
2379 {
2380 // pt
2381 scale[0] = 1.218633 - .1078999 * pt;
2382 scale[1] = 1.237288 - .2890434E-01 * pt;
2383 scale[2] = vfunc(pt, 0.4334312, 0.9027213, -.7119852, 0.1031877E-01);
2384 scale[3] = 1.252394 - .1835607 * pt;
2385 scale[4] = vfunc(pt, 0.6194937, 1.168190, 0.1285120, -.5815693E-01);
2386 }
2387
2388//
2389// Scale error for Exp.49 Hadron MC
2390// May. 27th, 2006 by fmiyuki
2391//
2393 static void
2394 cal_scale_error_EXP49_hadronic_mc(double scale[5], double pt, double /*tanl*/)
2395 {
2396 // pt
2397 scale[0] = 1.217751 - .1075724 * pt;
2398 scale[1] = 1.233774 - .3122749E-01 * pt;
2399 scale[2] = vfunc(pt, 0.5276512, 0.8852152, -.7025786, 0.3136450E-01);
2400 scale[3] = 1.258038 - .1949899 * pt;
2401 scale[4] = vfunc(pt, 0.5924365, 1.162905, 0.9632715E-01, -.6221822E-01);
2402
2403 }
2404
2405//
2406// Scale error for Exp.51 Hadron MC
2407// May 24th, 2007 by higuchit
2408//
2410 static void
2411 cal_scale_error_EXP51_hadronic_mc(double scale[5], double pt, double tanl)
2412 {
2413 // pt
2414 scale[0] = vfunc(pt, 0.35776, 1.1919, 0.84229E-01, -0.88550E-01);
2415 scale[1] = vfunc(pt, 0.37833, 1.2394, 0.34089, -0.54440E-01);
2416 scale[2] = lambdafunc(pt, 0.87688, 1.4065, 0.86733, -0.23657, 0.21714E-01, 0.20876);
2417 scale[3] = lambdafunc(pt, 0.39825, 1.0950, 1.2104, 0.11718E-01, -0.21145, -0.89681E-01);
2418 scale[4] = vfunc(pt, 0.48051, 1.1672, 0.19241, -0.32273E-01);
2419
2420 // tanl
2421 scale[2] *= vfunc(tanl, -0.40697, 0.92948, -0.29453, 0.59416E-01);
2422 }
2423
2424//
2425// Scale error for Exp.53 Hadron MC
2426// May 24th, 2007 by higuchit
2427//
2429 static void
2430 cal_scale_error_EXP53_hadronic_mc(double scale[5], double pt, double /*tanl*/)
2431 {
2432 // pt
2433 scale[0] = lambdafunc(pt, 0.50681, 1.2150, 1.2266, 0.99662E-01, -0.23508, -0.52268E-01);
2434 scale[1] = lambdafunc(pt, 0.50787, 1.2308, 1.3108, 0.42334, -0.25502, -0.13522E-01);
2435 scale[2] = vfunc(pt, 1.2149, 0.88700, -0.15323, 0.97993E-01);
2436 scale[3] = lambdafunc(pt, 0.45595, 1.1561, 1.2383, 0.17605, -0.34753, -0.97049E-01);
2437 scale[4] = vfunc(pt, 0.55269, 1.2261, 0.39706, -0.12333);
2438 }
2439
2440//
2441// Scale error for Exp.55 Hadron MC
2442// June 21st, 2007 by higuchit
2443//
2445 static void
2446 cal_scale_error_EXP55_hadronic_mc(double scale[5], double pt, double /*tanl*/)
2447 {
2448 // pt
2449 scale[0] = vfunc(pt, 0.34925, 1.1780, 0.89069E-01, -0.10090);
2450 scale[1] = vfunc(pt, 0.35168, 1.2380, 0.41479, -0.63250E-01);
2451 scale[2] = vfunc(pt, 1.2497, 0.88495, -0.14338, 0.94307E-01);
2452 scale[3] = lambdafunc(pt, 0.29565, 1.4502, 1.2139, 0.14353, -0.21211, -0.82968E-01);
2453 scale[4] = vfunc(pt, 1.2496, 1.1216, 0.97174E-02, -0.41166E-01);
2454 }
2455
2456//
2457// Scale error for Exp.61-65 Hadron MC
2458// March 4th, 2009 by higuchit
2459//
2461 static void
2462 cal_scale_error_EXP6165_hadronic_mc(double scale[5], double pt, double /*tanl*/)
2463 {
2464 // pt
2465 scale[0] = vfunc(pt, 1.4501, 1.0348, -0.12125, -0.27519E-01);
2466 scale[1] = lambdafunc(pt, 0.48988, 1.5501, 1.2544, 0.21014, -0.10419, 0.74755E-01);
2467 scale[2] = lambdafunc(pt, 0.44993, 1.3616, 0.93316, -0.58441, -0.30814E-01, 0.90806E-01);
2468 scale[3] = 1.2385 - 0.17733 * pt;
2469 scale[4] = vfunc(pt, 0.75590, 1.1726, 0.12749, -0.75183E-01);
2470 }
2471
2472//
2473// Scale error for Exp.67 Hadron MC
2474// October 8th, 2009 by higuchit
2475//
2477 static void
2478 cal_scale_error_EXP67_hadronic_mc(double scale[5], double pt, double /*tanl*/)
2479 {
2480 // pt
2481 scale[0] = vfunc(pt, 1.0501, 1.0852, -0.14604, -0.66317E-01);
2482 scale[1] = lambdafunc(pt, 0.37538, 2.5672, 1.2362, 0.14203, -0.58242E-01, 0.28431E-02);
2483 scale[2] = lambdafunc(pt, 0.52700, 1.3506, 0.90327, -0.55627, 0.13131E-02, 0.11059);
2484 scale[3] = 1.2577 - 0.19572 * pt;
2485 scale[4] = vfunc(pt, 0.69484, 1.1636, 0.96169E-01, -0.80421E-01);
2486 }
2487
2488
2489//
2490// Scale error for Exp.69 Hadron MC
2491// January 29th, 2010 by higuchit
2492// Scale error for Exp.71 Hadron MC
2493// May 12th, 2010 by higuchit
2494//
2496 static void
2497 cal_scale_error_EXP6971_hadronic_mc(double scale[5], double pt, double /*tanl*/)
2498 {
2499 // pt
2500 scale[0] = vfunc(pt, 1.7258, 1.0126, -0.12693, 0.31924E-01);
2501 scale[1] = lambdafunc(pt, 0.37552, 1.2217, 1.2532, 0.37276, -0.77830E-01, -0.31378E-01);
2502 scale[2] = lambdafunc(pt, 0.40176, 1.1748, 0.95524, -0.72331, -0.53213E-01, 0.90074E-01);
2503 scale[3] = 1.2644 - 0.19783 * pt;
2504 scale[4] = vfunc(pt, 0.56934, 1.1649, 0.13098, -0.52232E-01);
2505 }
2506
2507
2508 /***** *****/
2509 /***** scale error core *****/
2510 /***** *****/
2511 static const struct cal_scale_error_func_set_t
2517 },
2523 },
2529 },
2535 },
2541 },
2547 },
2553 },
2559 },
2565 },
2571 },
2577 },
2583 },
2589 },
2595 },
2601 },
2607 },
2613 },
2616 null_scale,
2617 null_scale,
2619 };
2620
2621
2623 static cal_scale_error_func_set_t
2624 get_scale_error_func_for_exprun(const int no_exp, const int /*no_run*/)
2625 {
2626 return
2627 (7 <= no_exp && no_exp <= 23) ? EXP0723_scale :
2628 (25 <= no_exp && no_exp <= 27) ? EXP2527_scale :
2629 (31 == no_exp) ? EXP31_scale :
2630 (33 == no_exp) ? EXP33_scale :
2631 (35 == no_exp) ? EXP35_scale :
2632 (37 == no_exp) ? EXP37_scale :
2633 (39 == no_exp || 41 == no_exp) ? EXP3941_scale :
2634 (43 == no_exp) ? EXP43_scale :
2635 (45 == no_exp) ? EXP45_scale :
2636 (47 == no_exp) ? EXP47_scale :
2637 (49 == no_exp) ? EXP49_scale :
2638 (51 == no_exp) ? EXP51_scale :
2639 (53 == no_exp) ? EXP53_scale :
2640 (55 == no_exp) ? EXP55_scale :
2641 (61 <= no_exp && no_exp <= 65) ? EXP6165_scale :
2642 (67 == no_exp) ? EXP67_scale :
2643 // ( 69==no_exp || 71==no_exp ) ? EXP6971_scale : DUMMY_scale;
2644 (69 <= no_exp && 73 >= no_exp) ? EXP6971_scale : DUMMY_scale;
2645 }
2647 static void
2649 (double scale[5],
2650 const double pt, const double tanl,
2651 const int expmc, const int no_exp, const int no_run)
2652 {
2653 double scale_error_hadronic_mc[5] = {1.0, 1.0, 1.0, 1.0, 1.0};
2654 double scale_error_cosmic_mc[5] = {1.0, 1.0, 1.0, 1.0, 1.0};
2655 double scale_error_cosmic_data[5] = {1.0, 1.0, 1.0, 1.0, 1.0};
2656
2657
2658 struct cal_scale_error_func_set_t cal_func = get_scale_error_func_for_exprun(no_exp, no_run);
2659 if (cal_func == DUMMY_scale) {
2660 B2ERROR("!!!! scale_error: FATAL: FATAL ERROR occurred. Abort !!!!");
2661 // Scale error is not prepared for this EXP number!
2662 assert(0);
2663 }
2664
2665
2666 static bool first = true;
2667 static int belle_scale_error_debug_mode = 0;
2668 if (first) {
2669 first = false;
2670 char* belle_scale_error_debug = getenv("BELLE_SCALE_ERROR_DEBUG");
2671 // one of NULL, "none", "cosmic_mc", "cosmic_data", "hadronic_mc"
2672
2673 if (!belle_scale_error_debug)
2674 belle_scale_error_debug_mode = 0;
2675 else if (!strcasecmp(belle_scale_error_debug, "none"))
2676 belle_scale_error_debug_mode = 1;
2677 else if (!strcasecmp(belle_scale_error_debug, "cosmic_mc"))
2678 belle_scale_error_debug_mode = 2;
2679 else if (!strcasecmp(belle_scale_error_debug, "cosmic_data"))
2680 belle_scale_error_debug_mode = 3;
2681 else if (!strcasecmp(belle_scale_error_debug, "hadron_mc") || !strcasecmp(belle_scale_error_debug, "hadronic_mc"))
2682 belle_scale_error_debug_mode = 4;
2683 else {
2684 B2ERROR("BELLE_SCALE_ERROR_DEBUG=" << belle_scale_error_debug << ": bad directive");
2685 assert(0);
2686 }
2687
2688 if (belle_scale_error_debug)
2689 B2ERROR("BELLE_SCALE_ERROR_DEBUG=" << belle_scale_error_debug << ": applied");
2690 }
2691
2692
2693 switch (belle_scale_error_debug_mode) {
2694 case 0:
2695 (cal_func.m_hadMC)(scale_error_hadronic_mc, pt, tanl);
2696 if (expmc == 1) { // Experiment
2697 if (SE_Message_Level >= 2) B2ERROR("scale_error: info: scale on real data");
2698 (cal_func.m_cosMC)(scale_error_cosmic_mc, pt, tanl);
2699 (cal_func.m_cosDATA)(scale_error_cosmic_data, pt, tanl);
2700 } else {
2701 if (SE_Message_Level >= 2) B2ERROR("scale_error: info: scale on MC data");
2702 }
2703 break;
2704
2705 case 1:
2706 //1;
2707 break;
2708
2709 case 2:
2710 (cal_func.m_cosMC)(scale_error_hadronic_mc, pt, tanl);
2711 break;
2712
2713 case 3:
2714 (cal_func.m_cosDATA)(scale_error_hadronic_mc, pt, tanl);
2715 break;
2716
2717 case 4:
2718 (cal_func.m_hadMC)(scale_error_hadronic_mc, pt, tanl);
2719 break;
2720 }
2721
2722
2723 /* compute scaling factor */
2724 for (int i = 0; i < 5; i++)
2725 scale[i] = scale_error_hadronic_mc[i] * scale_error_cosmic_data[i] / scale_error_cosmic_mc[i];
2726
2727
2728 /* message out */
2729 if (SE_Message_Level >= 2) {
2730 B2ERROR("scale_error: info: hadronic MC: "
2731 << scale_error_hadronic_mc[0] << " " << scale_error_hadronic_mc[1] << " "
2732 << scale_error_hadronic_mc[2] << " " << scale_error_hadronic_mc[3] << " "
2733 << scale_error_hadronic_mc[4]);
2734
2735 B2ERROR("scale_error: info: cosmic MC: "
2736 << scale_error_cosmic_mc[0] << " " << scale_error_cosmic_mc[1] << " "
2737 << scale_error_cosmic_mc[2] << " " << scale_error_cosmic_mc[3] << " "
2738 << scale_error_cosmic_mc[4]);
2739
2740 B2ERROR("scale_error: info: cosmic data: "
2741 << scale_error_cosmic_data[0] << " " << scale_error_cosmic_data[1] << " "
2742 << scale_error_cosmic_data[2] << " " << scale_error_cosmic_data[3] << " "
2743 << scale_error_cosmic_data[4]);
2744
2745 B2ERROR("scale_error: info: final scale: "
2746 << scale[0] << " " << scale[1] << " " << scale[2] << " "
2747 << scale[3] << " " << scale[4]);
2748 }
2749 /* check parameter limit */
2750 const double scale_lo = 0.5, scale_hi = 4.0;
2751 bool too_lo = false, too_hi = false;
2752 for (int i = 0; i < 5; i++) {
2753 if (scale[i] < scale_lo) { scale[i] = scale_lo; too_lo = true;}
2754 if (scale[i] > scale_hi) { scale[i] = scale_hi; too_hi = true;}
2755 }
2756
2757 if (SE_Message_Level >= 1 && (too_lo || too_hi)) {
2758 B2ERROR("scale_error: warning: scale factor beyond the limit: "
2759 << scale_error_hadronic_mc[0] * scale_error_cosmic_data[0] / scale_error_cosmic_mc[0] << " "
2760 << scale_error_hadronic_mc[1] * scale_error_cosmic_data[1] / scale_error_cosmic_mc[1] << " "
2761 << scale_error_hadronic_mc[2] * scale_error_cosmic_data[2] / scale_error_cosmic_mc[2] << " "
2762 << scale_error_hadronic_mc[3] * scale_error_cosmic_data[3] / scale_error_cosmic_mc[3] << " "
2763 << scale_error_hadronic_mc[4] * scale_error_cosmic_data[4] / scale_error_cosmic_mc[4]);
2764 }
2765 }
2766
2767
2775 static int scale_error_impl(const int message_level, const int reprocess_version)
2776 {
2777 SE_Message_Level = message_level;
2778 SE_Reprocess_Version = reprocess_version;
2779
2780 int no_exp{0}, no_run{0}, no_evt{0}, no_frm{0}, expmc{0};
2781 get_event_id(&no_exp, &no_run, &no_evt, &no_frm, &expmc);
2782
2783 if (DUMMY_scale == get_scale_error_func_for_exprun(no_exp, no_run)) return 2;
2784 if (is_already_scaled()) return 1;
2785
2786 static int first_exp73 = true;
2787 if (no_exp == 73 && first_exp73) {
2788 first_exp73 = false;
2789 B2ERROR(
2790 "scale_error: warning: scale parameters for exp#71 are tentatively used for exp#73.");
2791 }
2792
2793 double scale[5] = { // ... temporary
2794 1.0, // dr
2795 1.0, // phi0
2796 1.0, // kappa
2797 1.0, // dz
2798 1.0, // tanl
2799 };
2800
2801
2802 // scale error matrices in mdst_trk_fit
2803 Belle::Mdst_trk_fit_Manager& fitmgr = Belle::Mdst_trk_fit_Manager::get_manager();
2804 for (std::vector<Belle::Mdst_trk_fit>::iterator it = fitmgr.begin(); it != fitmgr.end(); ++it) {
2805 Belle::Mdst_trk_fit& fit = *it;
2806 if (fit.helix(2) == 0.) continue;
2807
2808 const double pt = 1. / fabs(fit.helix(2));
2809 const double tanl = fit.helix(4);
2810
2811 cal_scale_error(scale, pt, tanl, expmc, no_exp, no_run);
2812
2813 fit.error(0, scale[0]*scale[0]*fit.error(0));
2814 fit.error(1, scale[1]*scale[0]*fit.error(1));
2815 fit.error(2, scale[1]*scale[1]*fit.error(2));
2816 fit.error(3, scale[2]*scale[0]*fit.error(3));
2817 fit.error(4, scale[2]*scale[1]*fit.error(4));
2818 fit.error(5, scale[2]*scale[2]*fit.error(5));
2819 fit.error(6, scale[3]*scale[0]*fit.error(6));
2820 fit.error(7, scale[3]*scale[1]*fit.error(7));
2821 fit.error(8, scale[3]*scale[2]*fit.error(8));
2822 fit.error(9, scale[3]*scale[3]*fit.error(9));
2823 fit.error(10, scale[4]*scale[0]*fit.error(10));
2824 fit.error(11, scale[4]*scale[1]*fit.error(11));
2825 fit.error(12, scale[4]*scale[2]*fit.error(12));
2826 fit.error(13, scale[4]*scale[3]*fit.error(13));
2827 fit.error(14, scale[4]*scale[4]*fit.error(14));
2828 }
2829
2830
2831 // scale error matrices in mdst_daughters
2832 Belle::Mdst_vee_daughters_Manager& daumgr = Belle::Mdst_vee_daughters_Manager::get_manager();
2833 for (std::vector<Belle::Mdst_vee_daughters>::iterator it = daumgr.begin(); it != daumgr.end(); ++it) {
2834 Belle::Mdst_vee_daughters& dau = *it;
2835 if (dau.helix_p(2) == 0. || dau.helix_m(2) == 0.) continue;
2836
2837 // positive track
2838 const double pt_p = 1. / fabs(dau.helix_p(2));
2839 const double tanl_p = dau.helix_p(4);
2840
2841 cal_scale_error(scale, pt_p, tanl_p, expmc, no_exp, no_run);
2842
2843 dau.error_p(0, scale[0]*scale[0]*dau.error_p(0));
2844 dau.error_p(1, scale[1]*scale[0]*dau.error_p(1));
2845 dau.error_p(2, scale[1]*scale[1]*dau.error_p(2));
2846 dau.error_p(3, scale[2]*scale[0]*dau.error_p(3));
2847 dau.error_p(4, scale[2]*scale[1]*dau.error_p(4));
2848 dau.error_p(5, scale[2]*scale[2]*dau.error_p(5));
2849 dau.error_p(6, scale[3]*scale[0]*dau.error_p(6));
2850 dau.error_p(7, scale[3]*scale[1]*dau.error_p(7));
2851 dau.error_p(8, scale[3]*scale[2]*dau.error_p(8));
2852 dau.error_p(9, scale[3]*scale[3]*dau.error_p(9));
2853 dau.error_p(10, scale[4]*scale[0]*dau.error_p(10));
2854 dau.error_p(11, scale[4]*scale[1]*dau.error_p(11));
2855 dau.error_p(12, scale[4]*scale[2]*dau.error_p(12));
2856 dau.error_p(13, scale[4]*scale[3]*dau.error_p(13));
2857 dau.error_p(14, scale[4]*scale[4]*dau.error_p(14));
2858
2859 // negative track
2860 const double pt_m = 1. / fabs(dau.helix_m(2));
2861 const double tanl_m = dau.helix_m(4);
2862
2863 cal_scale_error(scale, pt_m, tanl_m, expmc, no_exp, no_run);
2864
2865 dau.error_m(0, scale[0]*scale[0]*dau.error_m(0));
2866 dau.error_m(1, scale[1]*scale[0]*dau.error_m(1));
2867 dau.error_m(2, scale[1]*scale[1]*dau.error_m(2));
2868 dau.error_m(3, scale[2]*scale[0]*dau.error_m(3));
2869 dau.error_m(4, scale[2]*scale[1]*dau.error_m(4));
2870 dau.error_m(5, scale[2]*scale[2]*dau.error_m(5));
2871 dau.error_m(6, scale[3]*scale[0]*dau.error_m(6));
2872 dau.error_m(7, scale[3]*scale[1]*dau.error_m(7));
2873 dau.error_m(8, scale[3]*scale[2]*dau.error_m(8));
2874 dau.error_m(9, scale[3]*scale[3]*dau.error_m(9));
2875 dau.error_m(10, scale[4]*scale[0]*dau.error_m(10));
2876 dau.error_m(11, scale[4]*scale[1]*dau.error_m(11));
2877 dau.error_m(12, scale[4]*scale[2]*dau.error_m(12));
2878 dau.error_m(13, scale[4]*scale[3]*dau.error_m(13));
2879 dau.error_m(14, scale[4]*scale[4]*dau.error_m(14));
2880 }
2881
2882 return 0;
2883 }
2884
2885
2886 void B2BIIFixMdstModule::scale_error(const int message_level)
2887 {
2888 static int result_before = -1;
2889
2890 const int result = scale_error_impl(message_level, this->m_reprocess_version);
2891
2892 if (result != result_before) {
2893 switch (result) {
2894 case 0: {
2895 B2INFO(
2896 "scale_error: info: scale error is properly applied.");
2897 break;
2898 }
2899
2900 case 1: {
2901 B2ERROR(
2902 "scale_error: warning: scale error is not applied. Reason: it has been already applied.");
2903 break;
2904 }
2905
2906 case 2: {
2907 int no_exp, no_run, no_evt, no_frm, expmc;
2908 get_event_id(&no_exp, &no_run, &no_evt, &no_frm, &expmc);
2909 B2ERROR(
2910 "scale_error: error: scale error is not applied. Reason: it is not available for exp " << no_exp << ". Exit! (I'll crash job.)");
2911 exit(-1);
2912// break; // redundant
2913 }
2914
2915 default: assert(0); // Should not be here!
2916 }
2917
2918 result_before = result;
2919 }
2920 }
2921
2922
2924// End of scale_error() implementation
2926
2927
2929 CLHEP::HepSymMatrix& epvtx_err)
2930 {
2931
2932 Belle::Evtvtx_primary_vertex_Manager& evtvtx_mgr
2933 = Belle::Evtvtx_primary_vertex_Manager::get_manager();
2934
2935 Belle::Evtvtx_trk_Manager& evttrk_mgr = Belle::Evtvtx_trk_Manager::get_manager();
2936
2937 Belle::Evtvtx_primary_vertex_Manager::iterator itvtx = evtvtx_mgr.begin();
2938 if (itvtx == evtvtx_mgr.end()) return 4;
2939
2940 if (!(itvtx->quality() == 2 || itvtx->quality() == 3)) return 3;
2941
2942 // TKECK fit primary vertex with our kfitter!
2943
2945 HepPoint3D pvtx(itvtx->PV_x(), itvtx->PV_y(), itvtx->PV_z());
2946
2947 kv.setInitialVertex(pvtx);
2948
2949 unsigned int nchrgd(0);
2950 for (Belle::Evtvtx_trk_Manager::iterator i = evttrk_mgr.begin(); i != evttrk_mgr.end(); ++i) {
2951
2952 const Belle::Mdst_charged& p = i->charged();
2953 if (p.trk().mhyp(2).nhits(3) < 2) continue;
2954 if (p.trk().mhyp(2).nhits(4) < 2) continue;
2955
2956 int hyp = 2;
2957 const HepPoint3D pivot(p.trk().mhyp(hyp).pivot_x(),
2958 p.trk().mhyp(hyp).pivot_y(),
2959 p.trk().mhyp(hyp).pivot_z());
2960 CLHEP::HepVector a(5);
2961 a[0] = p.trk().mhyp(hyp).helix(0);
2962 a[1] = p.trk().mhyp(hyp).helix(1);
2963 a[2] = p.trk().mhyp(hyp).helix(2);
2964 a[3] = p.trk().mhyp(hyp).helix(3);
2965 a[4] = p.trk().mhyp(hyp).helix(4);
2966 CLHEP::HepSymMatrix Ea(5, 0);
2967 Ea[0][0] = p.trk().mhyp(hyp).error(0);
2968 Ea[1][0] = p.trk().mhyp(hyp).error(1);
2969 Ea[1][1] = p.trk().mhyp(hyp).error(2);
2970 Ea[2][0] = p.trk().mhyp(hyp).error(3);
2971 Ea[2][1] = p.trk().mhyp(hyp).error(4);
2972 Ea[2][2] = p.trk().mhyp(hyp).error(5);
2973 Ea[3][0] = p.trk().mhyp(hyp).error(6);
2974 Ea[3][1] = p.trk().mhyp(hyp).error(7);
2975 Ea[3][2] = p.trk().mhyp(hyp).error(8);
2976 Ea[3][3] = p.trk().mhyp(hyp).error(9);
2977 Ea[4][0] = p.trk().mhyp(hyp).error(10);
2978 Ea[4][1] = p.trk().mhyp(hyp).error(11);
2979 Ea[4][2] = p.trk().mhyp(hyp).error(12);
2980 Ea[4][3] = p.trk().mhyp(hyp).error(13);
2981 Ea[4][4] = p.trk().mhyp(hyp).error(14);
2982 Belle::Helix helix(pivot, a, Ea);
2983
2984 CLHEP::HepLorentzVector mom;
2985 CLHEP::HepSymMatrix err(7, 0);
2986 HepPoint3D pos(0, 0, 0);
2987 if (pivot.x() != 0. ||
2988 pivot.y() != 0. ||
2989 pivot.z() != 0.) {
2990 helix.pivot(HepPoint3D(0., 0., 0.));
2991 mom = helix.momentum(0., 0.13957f, pos, err);
2992 } else {
2993 mom = helix.momentum(0., 0.13957f, pos, err);
2994 }
2995
2996 kv.addTrack(mom, pos, err, p.charge());
2997 ++nchrgd;
2998 }
2999
3000 if (Belle::IpProfile::usable()) {
3001 // event depend. IP position and error matrix
3002 HepPoint3D ip_position = Belle::IpProfile::e_position();
3003 CLHEP::HepSymMatrix ip_err = Belle::IpProfile::e_position_err();
3004 kv.setIpProfile(ip_position, ip_err);
3005 }
3006 // Fit
3007 unsigned int err(1);
3008 if (nchrgd > 2 || (nchrgd > 0 && Belle::IpProfile::usable())) err = kv.doFit();
3009 if (err == 0) {
3010 epvtx = kv.getVertex();
3011 epvtx_err = kv.getVertexError();
3012 }
3013 return err;
3014
3015 /*
3016 kvertexfitter kv;
3017
3018 HepPoint3D pvtx(itvtx->PV_x(), itvtx->PV_y(), itvtx->PV_z());
3019
3020 kv.initialVertex(pvtx);
3021
3022 Ptype ptype_pi_plus("PI+");
3023 Ptype ptype_pi_minus("PI-");
3024
3025 unsigned int nchrgd(0);
3026 for(Belle::Evtvtx_trk_Manager::iterator i = evttrk_mgr.begin();
3027 i != evttrk_mgr.end(); ++i){
3028 // if(!good_charged(i->charged())) continue;
3029
3030 if(i->charged().trk().mhyp(2).nhits(3) < 2) continue;
3031 if(i->charged().trk().mhyp(2).nhits(4) < 2) continue;
3032
3033 Particle tmp(i->charged(),
3034 (i->charged().charge()>0.0 ? ptype_pi_plus : ptype_pi_minus));
3035 addTrack2fit(kv, tmp);
3036 ++nchrgd;
3037 }
3038
3039 if(Belle::IpProfile::usable()){
3040
3041 // event depend. IP position and error matrix
3042 HepPoint3D ip_position = Belle::IpProfile::e_position();
3043 HepSymMatrix ip_err = Belle::IpProfile::e_position_err();
3044 // HepSymMatrix m_ip_err_b = Belle::IpProfile::e_position_err_b_life_smeared();
3045
3046 // Add IP profile information
3047 addBeam2fit(kv, ip_position, ip_err);
3048 }
3049 // Fit
3050 unsigned int err(1);
3051 if(nchrgd>2||(nchrgd>0&&Belle::IpProfile::usable())) err = kv.fit();
3052 if(err==0) {
3053 epvtx = kv.get_vertex();
3054 epvtx_err = kv.get_err_vertex();
3055 }
3056 return err;
3057 */
3058 }
3059
3060
3061//========================================================
3062// Add Mdst_trk_extra and Mdst_vee_extra
3063// to Mdst_trk and Mdst_vee2, respectively.
3064//=======================================================
3066 extern "C"
3067 void recsim_mdst_propgt_(float*, float[], float[], float[],
3068 float[], float[], int*);
3069
3070 int
3072 {
3073 Belle::Mdst_event_add_Manager& mevtmgr = Belle::Mdst_event_add_Manager::get_manager();
3074 if (mevtmgr.count() == 0) { // no Belle::Mdst_event_add table
3075 return -2;
3076 } else if (mevtmgr.count() == 1) { // no second entity in Belle::Mdst_event_add table
3077 mevtmgr.add();
3078 }
3079 unsigned flag(mevtmgr[1].flag(0));
3080 if (flag != 0) return -1; // do nothing if already added
3081 Belle::Mdst_trk_extra_Manager& teMgr(Belle::Mdst_trk_extra_Manager::get_manager());
3082 Belle::Mdst_trk_Manager& tMgr(Belle::Mdst_trk_Manager::get_manager());
3083 Belle::Mdst_charged_Manager& chMgr(Belle::Mdst_charged_Manager::get_manager());
3084 const int i_ch(chMgr.count() + 1);
3085 const int i_trk(tMgr.count() + 1);
3086 for (std::vector<Belle::Mdst_trk_extra>::const_iterator i = teMgr.begin();
3087 i != teMgr.end(); ++i) {
3088 Belle::Mdst_trk& trk(tMgr.add());
3089 trk.quality((*i).quality());
3090 for (int j = 0; j < 5; j++) trk.mhyp(j, (*i).mhyp(j));
3091
3092 // Commented out by A. Zupanc: see below
3093 // Belle::Mdst_trk_fit& tf(trk.mhyp(2));
3094 if (!(trk.quality() & 15u)) {
3095 B2FATAL("recsim_mdst_propgt_ is missing");
3096
3097 /*
3098 Commented by A.Zupanc: the recsim_mdst_propgt_ is missing therefore this part of the code
3099 can not be executed
3100
3101 Belle::Mdst_charged& ch(chMgr.add());
3102 ch.charge((tf.helix(2) >= 0) ? 1. : -1.);
3103
3104 float pivot[3], helix[5], error[15], helix0[5], error0[15];
3105 for (int k = 0; k < 3; k++) pivot[k] = tf.pivot(k);
3106 for (int k = 0; k < 5; k++) helix[k] = tf.helix(k);
3107 for (int k = 0; k < 15; k++) error[k] = tf.error(k);
3108
3109 float amass = tf.mass();
3110
3111 // propagate helix to origin
3112 int iret;
3113
3114 //recsim_mdst_propgt_(&amass, pivot, helix, error,
3115 // helix0, error0, &iret);
3116 if (iret == 0) {
3117 ch.px(-sin(helix0[1]) / fabs(helix0[2]));
3118 ch.py(cos(helix0[1]) / fabs(helix0[2]));
3119 ch.pz(helix0[4] / fabs(helix0[2]));
3120 }
3121 ch.mass(amass);
3122 ch.trk(trk);
3123 */
3124 } else {
3125 B2ERROR("Warning from B2BIIFixMdst: strange track in Belle::Mdst_trk_extra: quality="
3126 << trk.quality());
3127 }
3128 }
3129
3130
3131 Belle::Mdst_sim_trk_extra_Manager& steMgr
3132 (Belle::Mdst_sim_trk_extra_Manager::get_manager());
3133 Belle::Mdst_sim_trk_Manager& stMgr(Belle::Mdst_sim_trk_Manager::get_manager());
3134 int ist(0);
3135 for (std::vector<Belle::Mdst_sim_trk_extra>::const_iterator i = steMgr.begin();
3136 i != steMgr.end(); ++i) {
3137 Belle::Mdst_sim_trk& strk(stMgr.add());
3138 int argn = tMgr.count() - teMgr.count() + ist;
3139 if (argn < tMgr.count()) {
3140 strk.trk(tMgr[argn]);
3141 }
3142 ist++;
3143 strk.hepevt((*i).hepevt());
3144 strk.relation(0, (*i).relation(0));
3145 strk.relation(1, (*i).relation(1));
3146 strk.relation(2, (*i).relation(2));
3147 }
3148
3149
3150 Belle::Mdst_svd_hit_extra_Manager& sheMgr
3151 (Belle::Mdst_svd_hit_extra_Manager::get_manager());
3152 Belle::Mdst_svd_hit_Manager& shMgr(Belle::Mdst_svd_hit_Manager::get_manager());
3153 for (std::vector<Belle::Mdst_svd_hit_extra>::iterator it = sheMgr.begin();
3154 it != sheMgr.end(); ++it) {
3155 Belle::Mdst_svd_hit_extra& she = *it;
3156 Belle::Mdst_svd_hit& sh(shMgr.add());
3157 sh.lsa(she.lsa());
3158 sh.width(she.width());
3159 sh.electrons(she.electrons());
3160 sh.dssd(she.dssd());
3161 sh.type(she.type());
3162 int argn = tMgr.count() - teMgr.count() + she.trk().get_ID() - 1;
3163 if (argn < tMgr.count()) {
3164 sh.trk(tMgr[argn]);
3165 }
3166 }
3167
3168
3169 Belle::Mdst_vee2_Manager& vMgr(Belle::Mdst_vee2_Manager::get_manager());
3170 Belle::Mdst_vee2_extra_Manager& veMgr(Belle::Mdst_vee2_extra_Manager::get_manager());
3171 const int i_vee2(vMgr.count() + 1);
3172 for (std::vector<Belle::Mdst_vee2_extra>::const_iterator i = veMgr.begin();
3173 i != veMgr.end(); ++i) {
3174 Belle::Mdst_vee2& vee(vMgr.add());
3175 vee.kind((*i).kind());
3176
3177 if ((*i).extra_ID(0)) {
3178 Belle::Mdst_charged& tmp(chMgr[(*i).extra_ID(0) + i_ch - 2]);
3179 vee.chgd(0, tmp);
3180 } else {
3181 vee.chgd(0, (*i).chgd());
3182 }
3183
3184 if ((*i).extra_ID(1)) {
3185 Belle::Mdst_charged& tmp(chMgr[(*i).extra_ID(1) + i_ch - 2]);
3186 vee.chgd(1, tmp);
3187 } else {
3188 vee.chgd(1, (*i).chgd());
3189 }
3190
3191 vee.px((*i).px());
3192 vee.py((*i).py());
3193 vee.pz((*i).pz());
3194 vee.energy((*i).energy());
3195 vee.vx((*i).vx());
3196 vee.vy((*i).vy());
3197 vee.vz((*i).vz());
3198 vee.z_dist((*i).z_dist());
3199 vee.chisq((*i).chisq());
3200 vee.type((*i).type());
3201 vee.daut((*i).daut());
3202 }
3203 teMgr.remove();
3204 steMgr.remove();
3205 sheMgr.remove();
3206 veMgr.remove();
3207 if (i_ch & 0xffffff00) B2ERROR("Warning from B2BIIFixMdst: overflow! i_ch = " << i_ch);
3208 if (i_trk & 0xffffff00) B2ERROR("Warning from B2BIIFixMdst: overflow! i_trk = " << i_trk);
3209 if (i_vee2 & 0xffffff00) B2ERROR("Warning from B2BIIFixMdst: overflow! i_vee2 = " << i_vee2);
3210 flag = i_ch & 0xff;
3211 flag |= ((i_trk & 0xff) << 8);
3212 flag |= ((i_vee2 & 0xff) << 16);
3213 mevtmgr[1].flag(0, flag);
3214 return (int)flag;
3215 }
3216#if 0
3217 int
3219 {
3220 Belle::Mdst_event_add_Manager& mevtmgr = Belle::Mdst_event_add_Manager::get_manager();
3221 if (mevtmgr.count() <= 1) { // no Belle::Mdst_event_add table
3222 return -2;
3223 }
3224 unsigned flag(mevtmgr[1].flag(0));
3225 if (0 == flag) return -1; // do nothing if no extra tracks in Belle::Mdst_charged etc.
3226 const int i_ch(flag & 0xff);
3227 const int i_trk((flag >> 8) & 0xff);
3228 const int i_vee2((flag >> 16) & 0xff);
3229 Belle::Mdst_charged_Manager& chMgr(Belle::Mdst_charged_Manager::get_manager());
3230 Belle::Mdst_trk_Manager& tMgr(Belle::Mdst_trk_Manager::get_manager());
3231 Belle::Mdst_vee2_Manager& veeMgr(Belle::Mdst_vee2_Manager::get_manager());
3232 if (i_ch) {
3233 while (chMgr.count() >= i_ch) chMgr.remove(chMgr[chMgr.count() - 1]);
3234 }
3235 if (i_trk) {
3236 while (tMgr.count() >= i_trk) tMgr.remove(tMgr[tMgr.count() - 1]);
3237 }
3238 if (i_vee2) {
3239 while (veeMgr.count() >= i_vee2) veeMgr.remove(veeMgr[veeMgr.count() - 1]);
3240 }
3241 flag = 0;
3242 mevtmgr[1].flag(0, flag);
3243 return 0;
3244 }
3245#else
3246 int
3248 {
3249 Belle::Mdst_event_add_Manager& mevtmgr = Belle::Mdst_event_add_Manager::get_manager();
3250 if (mevtmgr.count() <= 1) { // no Belle::Mdst_event_add table
3251 return -2;
3252 }
3253 unsigned flag(mevtmgr[1].flag(0));
3254 if (0 == flag) return -1; // do nothing if no extra tracks in Belle::Mdst_charged etc.
3255 const int i_ch(flag & 0xff);
3256 const int i_trk((flag >> 8) & 0xff);
3257 const int i_vee2((flag >> 16) & 0xff);
3258 //Belle::Mdst_charged_Manager////& chMgr(Belle::Mdst_charged_Manager::get_manager());
3259 Belle::Mdst_trk_Manager& tMgr(Belle::Mdst_trk_Manager::get_manager());
3260 Belle::Mdst_vee2_Manager& veeMgr(Belle::Mdst_vee2_Manager::get_manager());
3261 Belle::Mdst_trk_extra_Manager& teMgr(Belle::Mdst_trk_extra_Manager::get_manager());
3262 Belle::Mdst_vee2_extra_Manager& veeeMgr(Belle::Mdst_vee2_extra_Manager::get_manager());
3263 if (i_trk) {
3264 std::vector<int> extra_ID;
3265 if (teMgr.count()) teMgr.remove();
3266 for (std::vector<Belle::Mdst_trk>::iterator i = tMgr.begin();
3267 i != tMgr.end(); ++i) {
3268 if ((*i).get_ID() < i_trk) {
3269 extra_ID.push_back(0);
3270 continue;
3271 }
3272 if (!((*i).quality() & 16u)) {
3273 B2ERROR("Warning from B2BIIFixMdst: inconsistency between Belle::Mdst_trk and Belle::Mdst_evet_add"
3274 );
3275 }
3276 Belle::Mdst_trk_extra& trk(teMgr.add());
3277 for (int j = 0; j < 5; j++) trk.mhyp(j, (*i).mhyp(j));
3278 trk.quality((*i).quality());
3279 extra_ID.push_back(trk.get_ID());
3280 }
3281 if (i_vee2) {
3282 if (veeeMgr.count()) veeeMgr.remove();
3283 for (std::vector<Belle::Mdst_vee2>::iterator i = veeMgr.begin();
3284 i != veeMgr.end(); ++i) {
3285 if ((*i).get_ID() < i_vee2) continue;
3286 if (!((*i).chgd(0).trk().quality() & 16u) && !((*i).chgd(1).trk().quality() & 16u)) {
3287 B2ERROR("Warning from B2BIIFixMdst: inconsistency between Belle::Mdst_vee2 and Belle::Mdst_evet_add"
3288 );
3289 }
3290 Belle::Mdst_vee2_extra& vee(veeeMgr.add());
3291 vee.kind((*i).kind());
3292 const int extra_id0(extra_ID[(*i).chgd(0).trk_ID() - 1]);
3293 const int extra_id1(extra_ID[(*i).chgd(1).trk_ID() - 1]);
3294 if (extra_id0) {
3295 vee.extra(0, teMgr[extra_id0 - 1]);
3296 } else {
3297 vee.chgd((*i).chgd(0));
3298 }
3299 if (extra_id1) {
3300 vee.extra(1, teMgr[extra_id1 - 1]);
3301 } else {
3302 if (vee.chgd_ID()) {
3303 B2ERROR("Warning from B2BIIFixMdst: both tracks of Belle::Mdst_vee2_extra are good track"
3304 );
3305 }
3306 vee.chgd((*i).chgd(1));
3307 }
3308
3309 vee.px((*i).px());
3310 vee.py((*i).py());
3311 vee.pz((*i).pz());
3312 vee.energy((*i).energy());
3313 vee.vx((*i).vx());
3314 vee.vy((*i).vy());
3315 vee.vz((*i).vz());
3316 vee.z_dist((*i).z_dist());
3317 vee.chisq((*i).chisq());
3318 vee.type((*i).type());
3319 vee.daut((*i).daut());
3320 }
3321 int id = BsCouTab(MDST_VEE2);
3322 while (id >= i_vee2) BsDelEnt(MDST_VEE2, id--);
3323 }
3324 int id = BsCouTab(MDST_TRK);
3325 while (id >= i_trk) BsDelEnt(MDST_TRK, id--);
3326 }
3327 if (i_ch) {
3328 int id = BsCouTab(MDST_CHARGED);
3329 while (id >= i_ch) BsDelEnt(MDST_CHARGED, id--);
3330 }
3331 flag = 0;
3332 mevtmgr[1].flag(0, flag);
3333 return 0;
3334 }
3335
3336//=======================================================================
3337//Perform extra-smearing for MC tracks. The relevant code is extracted
3338//from the module smear_trk originally coded by Marko Staric.
3339//=======================================================================
3340
3341 static void scale_err_ms(Belle::Mdst_trk_fit& fit, const double scale[]);
3342 static void smear_trk_ms(Belle::Mdst_trk_fit& fit, const double scale[]);
3343 static void smear_charged();
3345//==========================
3347 {
3348//==========================
3349 int expNo = 0, runNo = 0, expmc = 1;
3350 Belle::Belle_event_Manager& evtMgr = Belle::Belle_event_Manager::get_manager();
3351 if (evtMgr.count()) {
3352 expNo = evtMgr[0].ExpNo();
3353 runNo = evtMgr[0].RunNo();
3354 expmc = evtMgr[0].ExpMC();
3355 }
3356 if (expmc == 1) return; // nothing done for real data
3357
3358 Belle::Mdst_event_add_Manager& addmgr = Belle::Mdst_event_add_Manager::get_manager();
3359 if (addmgr.count() == 0) {
3360 B2ERROR("No Belle::Mdst_event_add table -> kill the job");
3361 exit(-1);
3362 } else if (addmgr.count() >= 2) {
3363 if (addmgr[1].flag(1) != 0) return; //do nothing if already smeared
3364 }
3365
3366 int flag_err = addmgr[0].flag_error();
3367
3368 static bool start = true;
3369 if (start) {
3370 start = false;
3371 B2INFO("smear_trk: MC events -> track smearing is ON\n");
3372 }
3373
3374 double scale_mc[5] = {1, 1, 1, 1, 1};
3375 double scale_rd[5] = {1, 1, 1, 1, 1};
3376 double scale[5];
3377
3378 Belle::Mdst_trk_fit_Manager& fitmgr = Belle::Mdst_trk_fit_Manager::get_manager();
3379 for (std::vector<Belle::Mdst_trk_fit>::iterator it = fitmgr.begin(); it != fitmgr.end(); ++it) {
3380 Belle::Mdst_trk_fit& fit = *it;
3381 if (fit.helix(2) == 0.) continue;
3382
3383 double pt = 1. / fabs(fit.helix(2));
3384 double tanl = fit.helix(4);
3385
3386 cal_scale_error(scale_mc, pt, tanl, 0, expNo, runNo);
3387 cal_scale_error(scale_rd, pt, tanl, 1, expNo, runNo);
3388 for (int i = 0; i < 5; i++) scale[i] = scale_rd[i] / scale_mc[i];
3389
3390 if (flag_err == 0) scale_err_ms(fit, scale_mc);
3391 smear_trk_ms(fit, scale);
3392 scale_err_ms(fit, scale);
3393 }
3394
3395 if (m_smear_trk == 2) smear_charged();
3396
3397 //set flag indicating already-err-scaled
3398 addmgr[0].flag_error(1);
3399
3400 //set flag indicating already-smeared
3401 if (addmgr.count() == 1) {
3402 Belle::Mdst_event_add& meadd = addmgr.add();
3403 meadd.flag(1, 1);
3404 } else if (addmgr.count() >= 2) {
3405 addmgr[1].flag(1, 1);
3406 }
3407
3408 }
3409
3410//====================================================
3411 void scale_err_ms(Belle::Mdst_trk_fit& fit, const double scale[])
3412 {
3413//====================================================
3414 fit.error(0, scale[0]*scale[0]*fit.error(0));
3415 fit.error(1, scale[1]*scale[0]*fit.error(1));
3416 fit.error(2, scale[1]*scale[1]*fit.error(2));
3417 fit.error(3, scale[2]*scale[0]*fit.error(3));
3418 fit.error(4, scale[2]*scale[1]*fit.error(4));
3419 fit.error(5, scale[2]*scale[2]*fit.error(5));
3420 fit.error(6, scale[3]*scale[0]*fit.error(6));
3421 fit.error(7, scale[3]*scale[1]*fit.error(7));
3422 fit.error(8, scale[3]*scale[2]*fit.error(8));
3423 fit.error(9, scale[3]*scale[3]*fit.error(9));
3424 fit.error(10, scale[4]*scale[0]*fit.error(10));
3425 fit.error(11, scale[4]*scale[1]*fit.error(11));
3426 fit.error(12, scale[4]*scale[2]*fit.error(12));
3427 fit.error(13, scale[4]*scale[3]*fit.error(13));
3428 fit.error(14, scale[4]*scale[4]*fit.error(14));
3429
3430 }
3431
3432//====================================================
3433 void smear_trk_ms(Belle::Mdst_trk_fit& fit, const double scale[])
3434 {
3435//====================================================
3436 const int n = 5;
3437 double a[n][n];
3438 int k = 0;
3439 for (int i = 0; i < n; i++) {
3440 for (int j = 0; j <= i; j++) {
3441 a[i][j] = fit.error(k) * (scale[i] * scale[j] - 1.0);
3442 if (i != j) a[j][i] = a[i][j];
3443 k++;
3444 }
3445 }
3446
3447 double u[n][n];
3448 //int pozdef = 1;
3449 for (int j = 0; j < n; j++) {
3450 double s = a[j][j];
3451 for (int k2 = 0; k2 < j; k2++) s -= u[j][k2] * u[j][k2];
3452 if (s > 0) {
3453 u[j][j] = sqrt(s);
3454 for (int i = j + 1; i < n; i++) {
3455 s = a[i][j];
3456 for (int k3 = 0; k3 < j; k3++) s -= u[i][k3] * u[j][k3];
3457 u[i][j] = s / u[j][j];
3458 }
3459 } else {
3460 for (int i = j; i < n; i++) u[i][j] = 0;
3461 //pozdef = 0;
3462 }
3463 }
3464
3465 double g[n];
3466 for (int i = 0; i < n; i++) g[i] = gRandom->Gaus();
3467 double x[n];
3468 for (int i = 0; i < n; i++) {
3469 x[i] = 0;
3470 if (u[i][i] > 0) {
3471 for (int j = 0; j <= i; j++) x[i] += u[i][j] * g[j];
3472 }
3473 }
3474 for (int i = 0; i < n; i++) fit.helix(i, fit.helix(i) + x[i]);
3475
3476 }
3477
3478//====================
3480 {
3481//====================
3482 Belle::Mdst_charged_Manager& chgmgr = Belle::Mdst_charged_Manager::get_manager();
3483 for (std::vector<Belle::Mdst_charged>::iterator it = chgmgr.begin(); it != chgmgr.end(); ++it) {
3484 Belle::Mdst_charged& c = *it;
3485 Belle::Mdst_trk_fit& t = c.trk().mhyp(2);
3486
3487 double kp = std::abs(t.helix(2));
3488 kp = std::max(kp, 1.e-10);
3489 kp = std::min(kp, 1.e10);
3490 c.px(-sin(t.helix(1)) / kp);
3491 c.py(cos(t.helix(1)) / kp);
3492 c.pz(t.helix(4) / kp);
3493 }
3494
3495 }
3496
3497#endif
3499} // namespace Belle
int m_smear_trk
Do extra-smearing for MC tracks.
int m_reprocess_version
Reprocess version (=0:old; =1:new)
enum KFitError::ECode addTrack(const KFitTrack &kp)
Add a track to the fitter object.
Definition: KFitBase.cc:38
VertexFitKFit is a derived class from KFitBase to perform vertex-constraint kinematical fit.
Definition: VertexFitKFit.h:34
enum KFitError::ECode setInitialVertex(const HepPoint3D &v)
Set an initial vertex point for the vertex-vertex constraint fit.
const CLHEP::HepSymMatrix getVertexError(void) const
Get a fitted vertex error matrix.
enum KFitError::ECode doFit(void)
Perform a vertex-constraint fit.
enum KFitError::ECode setIpProfile(const HepPoint3D &ip, const CLHEP::HepSymMatrix &ipe)
Set an IP-ellipsoid shape for the vertex constraint fit.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
bool operator==(const DecayNode &node1, const DecayNode &node2)
Compare two Decay Nodes: They are equal if All daughter decay nodes are equal or one of the daughter ...
Definition: DecayNode.cc:48
static const struct cal_scale_error_func_set_t EXP6165_scale
Scale error for Exp.61-65.
static void smear_trk_ms(Belle::Mdst_trk_fit &fit, const double scale[])
Smear MC tracks.
static void cal_scale_error_EXP55_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.55 Cosmic MC.
void scale_momenta_set_v2(const int, const int, const int, double &)
Return scale factors set_v2.
static void cal_scale_error_EXP43_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.43 Cosmic MC.
static void cal_scale_error_EXP31_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.31 Cosmic MC.
static const struct cal_scale_error_func_set_t EXP2527_scale
Scale error for Exp.25-27.
static void cal_scale_error_EXP0723_cosmic_data(double scale[5], const double pt, const double)
Scale error for Exp.7-23 Cosmic data.
static void cal_scale_error_EXP51_hadronic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.51 Hadron MC.
static const struct cal_scale_error_func_set_t EXP45_scale
Scale error for Exp.45.
double lambdafunc(const double x, const double x1, const double x2, const double yc, const double a1, const double a2, const double a3)
lambdafunc
static void cal_scale_error_EXP35_hadronic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.33,35 Hadron MC.
static void null_scale(double[5], double, double)
Dummy function.
static void get_event_id(int *no_exp, int *no_run, int *no_evt, int *no_frm, int *expmc)
Get event ID.
static void cal_scale_error_EXP31_cosmic_data(double scale[5], double pt, double)
Scale error for Exp.31 Cosmic data.
static const struct cal_scale_error_func_set_t EXP3941_scale
Scale error for Exp.39,41.
static const struct cal_scale_error_func_set_t EXP31_scale
Scale error for Exp.31.
double rootfunc(const double x, const double x1, const double x2, const double yc, const double a1, const double a2)
rootfunc
static void cal_scale_error_EXP2527_cosmic_data(double scale[5], const double pt, const double)
Scale error for Exp.25-27 Cosmic data.
static void cal_scale_error_EXP43_hadronic_mc(double scale[5], double pt, double)
Scale error for Exp.43 Hadron MC.
static const struct cal_scale_error_func_set_t EXP6971_scale
Scale error for Exp.69-71.
static int SE_Reprocess_Version
Reprocess version used in scale_error()
static void smear_charged()
Smear tracks in Mdst_Charged.
static void cal_scale_error_EXP47_hadronic_mc(double scale[5], double pt, double)
Scale error for Exp.47 Hadron MC.
void smear_trk()
Apply track smearing (on MC)
static void cal_scale_error_EXP53_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.53 Cosmic MC.
static void cal_scale_error_EXP6165_hadronic_mc(double scale[5], double pt, double)
Scale error for Exp.61-65 Hadron MC.
double vfunc(const double x, const double x1, const double yc, const double a1, const double a2)
vfunc
static void cal_scale_error_EXP53_hadronic_mc(double scale[5], double pt, double)
Scale error for Exp.53 Hadron MC.
static void cal_scale_error_EXP3941_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.39,41 Cosmic MC.
static void cal_scale_error_EXP67_hadronic_mc(double scale[5], double pt, double)
Scale error for Exp.67 Hadron MC.
static const struct cal_scale_error_func_set_t EXP43_scale
Scale error for Exp.43.
int remove_extra_trk_vee2()
Remove extra tracks from Mdst_trk and Mdst_vee2.
static const struct cal_scale_error_func_set_t EXP47_scale
Scale error for Exp.47.
double cupfunc(const double x, const double x1, const double x2, const double yc, const double a1, const double a2)
cupfunc
static void cal_scale_error_EXP35_cosmic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.35 Cosmic MC.
static void cal_scale_error_EXP43_cosmic_data(double scale[5], double pt, double)
Scale error for Exp.43 Cosmic data.
static const struct cal_scale_error_func_set_t EXP53_scale
Scale error for Exp.53.
static void cal_scale_error_EXP0723_cosmic_mc(double scale[5], const double pt, const double)
Scale error for Exp.7-23 Cosmic MC.
static void cal_scale_error_EXP3941_hadronic_mc(double scale[5], double pt, double)
Scale error for Exp.39,41 Hadron MC.
static void cal_scale_error_EXP55_cosmic_data(double scale[5], double pt, double tanl)
Scale error for Exp.55 Cosmic data.
static void cal_scale_error_EXP55_hadronic_mc(double scale[5], double pt, double)
Scale error for Exp.55 Hadron MC.
static const struct cal_scale_error_func_set_t EXP0723_scale
Scale error for Exp.7-23.
static const struct cal_scale_error_func_set_t EXP51_scale
Scale error for Exp.51.
static void cal_scale_error_EXP35_cosmic_data(double scale[5], double pt, double tanl)
Scale error for Exp.35 Cosmic data.
static const struct cal_scale_error_func_set_t EXP67_scale
Scale error for Exp.67.
static void cal_scale_error_EXP4547_cosmic_data(double scale[5], double pt, double)
Scale error for Exp.45,47 Cosmic data.
void scale_momenta_set_v1(const int, const int, const int, double &)
Return scale factors set_v1.
static void cal_scale_error_EXP0723_hadronic_mc(double scale[5], const double pt, const double tanl)
Scale error for Exp.7-23 Hadron MC.
static void cal_scale_error_EXP6971_hadronic_mc(double scale[5], double pt, double)
Scale error for Exp.69,71 Hadron MC.
static void cal_scale_error_EXP37_hadronic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.37 Hadron MC.
static void cal_scale_error_EXP49_cosmic_data(double scale[5], double pt, double)
Scale error for Exp.49 Cosmic data.
static void cal_scale_error_EXP6971_cosmic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.69-71 Cosmic MC.
static void cal_scale_error_EXP67_cosmic_data(double scale[5], double pt, double tanl)
Scale error for Exp.67 Cosmic data.
int add_extra_trk_vee2()
Add Mdst_trk_extra and Mdst_vee_extra to Mdst_trk and Mdst_vee2, respectively.
static void cal_scale_error_EXP33_cosmic_data(double scale[5], double pt, double)
Scale error for Exp.33 Cosmic data.
static void cal_scale_error_EXP49_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.49 Cosmic MC.
static int SE_Message_Level
Message level of scale_error().
static const struct cal_scale_error_func_set_t DUMMY_scale
Dummy scale.
static void cal_scale_error_EXP2527_cosmic_mc(double scale[5], const double pt, const double)
Scale error for Exp.25-27 Cosmic MC.
static void cal_scale_error_EXP37_cosmic_data(double scale[5], double pt, double)
Scale error for Exp.37 Cosmic data.
void(* cal_scale_error_func_t)(double scale[5], const double pt, const double tanl)
Function pointer type.
int set_primary_vertex(HepPoint3D &v, CLHEP::HepSymMatrix &ve)
Set primary vertex assuming all tracks are pions.
static const struct cal_scale_error_func_set_t EXP35_scale
Scale error for Exp.35.
static void cal_scale_error_EXP53_cosmic_data(double scale[5], double pt, double)
Scale error for Exp.53 Cosmic data.
static void cal_scale_error_EXP31_hadronic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.31 Hadron MC.
static void cal_scale_error(double scale[5], const double pt, const double tanl, const int expmc, const int no_exp, const int no_run)
Calculate scale error.
void scale_momenta(float scale_data=1.0, float scale_mc=1.0, int mode=0)
Scale momenta of Mdst_trk.
static void cal_scale_error_EXP2527_hadronic_mc(double scale[5], const double pt, const double tanl)
Scale error for Exp.25-27 Hadron MC.
static void cal_scale_error_EXP51_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.51 Cosmic MC.
static void cal_scale_error_EXP33_hadronic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.33,35 Hadron MC.
static void scale_err_ms(Belle::Mdst_trk_fit &fit, const double scale[])
Scale error.
static const struct cal_scale_error_func_set_t EXP49_scale
Scale error for Exp.49.
void scale_error(const int message_level=0)
Apply scale error.
static void cal_scale_error_EXP33_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.33 Cosmic MC.
static int scale_error_impl(const int message_level, const int reprocess_version)
The implementation of B2BIIFixMdstModule::scale_error()
static const struct cal_scale_error_func_set_t EXP37_scale
Scale error for Exp.37.
void scale_momenta_set(const int, const int, const int, double &)
Return scale factors for 2001 summer confs.
static cal_scale_error_func_set_t get_scale_error_func_for_exprun(const int no_exp, const int)
Get scale error function for different Exp.
static void cal_scale_error_EXP47_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.47 Cosmic MC.
static void cal_scale_error_EXP37_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.37 Cosmic MC.
static const struct cal_scale_error_func_set_t EXP33_scale
Scale error for Exp.33.
static void cal_scale_error_EXP6165_cosmic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.61-65 Cosmic MC.
static void cal_scale_error_EXP49_hadronic_mc(double scale[5], double pt, double)
Scale error for Exp.49 Hadron MC.
static void cal_scale_error_EXP67_cosmic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.67 Cosmic MC.
static void cal_scale_error_EXP45_hadronic_mc(double scale[5], double pt, double tanl)
Scale error for Exp.45 Hadron MC.
double vee_mass_nofit(const Belle::Mdst_vee2 &vee2, float scale=1.0)
Calculates V0 mass with non-constraint fit results.
static const struct cal_scale_error_func_set_t EXP55_scale
Scale error for Exp.55.
static void cal_scale_error_EXP6971_cosmic_data(double scale[5], double pt, double tanl)
Scale error for Exp.69,71 Cosmic data.
static void cal_scale_error_EXP51_cosmic_data(double scale[5], double pt, double tanl)
Scale error for Exp.51 Cosmic data.
void recsim_mdst_propgt_(float *, float[], float[], float[], float[], float[], int *)
recsim_mdst_propgt from legacy C code
static bool is_already_scaled(void)
Check if event is already scaled.
static void cal_scale_error_EXP6165_cosmic_data(double scale[5], double pt, double tanl)
Scale error for Exp.61-65 Cosmic data.
static void cal_scale_error_EXP3941_cosmic_data(double scale[5], double pt, double)
Scale error for Exp.39-41 Cosmic data.
static void cal_scale_error_EXP45_cosmic_mc(double scale[5], double pt, double)
Scale error for Exp.45 Cosmic MC.
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.
Structure type cal_scale_error_func_set_t.
cal_scale_error_func_t m_cosMC
For cosmic MC.
cal_scale_error_func_t m_cosDATA
For cosmic data.
cal_scale_error_func_t m_hadMC
For hadronic MC.