Belle II Software  release-08-01-10
MCParticleTag.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 // Own header.
10 #include <analysis/variables/MCParticleTag.h>
11 
12 // include VariableManager
13 #include <analysis/VariableManager/Manager.h>
14 
15 // analysis dataobjects
16 #include <analysis/dataobjects/Particle.h>
17 
18 // analysis utilities
19 #include <analysis/utility/GenBplusTag.h>
20 #include <analysis/utility/GenB0Tag.h>
21 #include <analysis/utility/GenBsTag.h>
22 #include <analysis/utility/GenDTag.h>
23 #include <analysis/utility/GenTauTag.h>
24 
25 // mdst dataobjects
26 #include <mdst/dataobjects/MCParticle.h>
27 
28 // framework
29 #include <framework/datastore/StoreArray.h>
30 #include <framework/gearbox/Const.h>
31 #include <framework/logging/Logger.h>
32 
33 #include <vector>
34 #include <iostream>
35 #include <cmath>
36 
37 
38 namespace Belle2 {
43  namespace Variable {
44 
45  double BplusMode(const Particle*)
46  {
47  GenBplusTag gBtag;
48  StoreArray<MCParticle> MC_Particle_list;
49  if (!MC_Particle_list) {
50  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
51  return Const::doubleNaN;
52  }
53  int modeB = -99;
54 
55  for (const auto& iMCParticle : MC_Particle_list) {
56  if (iMCParticle.getPDG() != 521) continue;
57 
58  std::vector<int> DauPDG;
59  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
60  DauPDG.push_back(mcDaughter->getPDG());
61  }
62  modeB = gBtag.Mode_B_plus(DauPDG);
63  break;
64  }
65 
66  return modeB;
67  }
68 
69  double BminusMode(const Particle*)
70  {
71  GenBplusTag gBtag;
72  StoreArray<MCParticle> MC_Particle_list;
73  if (!MC_Particle_list) {
74  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
75  return Const::doubleNaN;
76  }
77  int modeB = -99;
78 
79  for (const auto& iMCParticle : MC_Particle_list) {
80  if (iMCParticle.getPDG() != -521) continue;
81 
82  std::vector<int> DauPDG;
83  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
84  DauPDG.push_back(mcDaughter->getPDG());
85  }
86  modeB = gBtag.Mode_B_minus(DauPDG);
87  break;
88  }
89 
90  return modeB;
91  }
92 
93  double B0Mode(const Particle*)
94  {
95  GenB0Tag gBtag;
96  StoreArray<MCParticle> MC_Particle_list;
97  if (!MC_Particle_list) {
98  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
99  return Const::doubleNaN;
100  }
101  int modeB1 = -99, modeB2 = -99, modeB = -99, nb1 = 0, nb2 = 0;
102 
103  for (const auto& iMCParticle : MC_Particle_list) {
104  if (iMCParticle.getPDG() == 511) {
105  nb1++;
106  if (nb1 == 1) {
107  std::vector<int> DauPDG1;
108  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
109  DauPDG1.push_back(mcDaughter->getPDG());
110  }
111  modeB1 = gBtag.Mode_B0(DauPDG1);
112  break;
113  }
114  }
115  if (iMCParticle.getPDG() == -511) {
116  nb2++;
117  if (nb2 == 2) {
118  std::vector<int> DauPDG2;
119  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
120  DauPDG2.push_back(mcDaughter->getPDG());
121  }
122  modeB2 = gBtag.Mode_anti_B0(DauPDG2);
123  break;
124  }
125  }
126  }
127 
128  if (modeB1 != -99) { modeB = modeB1;}
129  else if (modeB2 != -99) { modeB = modeB2;}
130 
131  return modeB;
132  }
133 
134  double Bbar0Mode(const Particle*)
135  {
136  GenB0Tag gBtag;
137  StoreArray<MCParticle> MC_Particle_list;
138  if (!MC_Particle_list) {
139  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
140  return Const::doubleNaN;
141  }
142  int modeB1 = -99, modeB2 = -99, modeB = -99, nb1 = 0, nb2 = 0;
143 
144  for (const auto& iMCParticle : MC_Particle_list) {
145  if (iMCParticle.getPDG() == -511) {
146  nb1++;
147  if (nb1 == 1) {
148  std::vector<int> DauPDG1;
149  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
150  DauPDG1.push_back(mcDaughter->getPDG());
151  }
152  modeB1 = gBtag.Mode_anti_B0(DauPDG1);
153  break;
154  }
155  }
156  if (iMCParticle.getPDG() == 511) {
157  nb2++;
158  if (nb2 == 2) {
159  std::vector<int> DauPDG2;
160  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
161  DauPDG2.push_back(mcDaughter->getPDG());
162  }
163  modeB2 = gBtag.Mode_B0(DauPDG2);
164  break;
165  }
166  }
167  }
168 
169  if (modeB1 != -99) { modeB = modeB1;}
170  else if (modeB2 != -99) { modeB = modeB2;}
171 
172  return modeB;
173  }
174 
175  double Bs0Mode(const Particle*)
176  {
177  GenBsTag gBtag;
178  StoreArray<MCParticle> MC_Particle_list;
179  if (!MC_Particle_list) {
180  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
181  return Const::doubleNaN;
182  }
183  int modeB1 = -99, modeB2 = -99, modeB = -99, nb1 = 0, nb2 = 0;
184 
185  for (const auto& iMCParticle : MC_Particle_list) {
186  if (iMCParticle.getPDG() == 531) {
187  nb1++;
188  if (nb1 == 1) {
189  std::vector<int> DauPDG1;
190  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
191  DauPDG1.push_back(mcDaughter->getPDG());
192  }
193  modeB1 = gBtag.Mode_Bs0(DauPDG1);
194  break;
195  }
196  }
197  if (iMCParticle.getPDG() == -531) {
198  nb2++;
199  if (nb2 == 2) {
200  std::vector<int> DauPDG2;
201  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
202  DauPDG2.push_back(mcDaughter->getPDG());
203  }
204  modeB2 = gBtag.Mode_anti_Bs0(DauPDG2);
205  break;
206  }
207  }
208  }
209 
210  if (modeB1 != -99) { modeB = modeB1;}
211  else if (modeB2 != -99) { modeB = modeB2;}
212 
213  return modeB;
214  }
215 
216  double Bsbar0Mode(const Particle*)
217  {
218  GenBsTag gBtag;
219  StoreArray<MCParticle> MC_Particle_list;
220  if (!MC_Particle_list) {
221  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
222  return Const::doubleNaN;
223  }
224  int modeB1 = -99, modeB2 = -99, modeB = -99, nb1 = 0, nb2 = 0;
225 
226  for (const auto& iMCParticle : MC_Particle_list) {
227  if (iMCParticle.getPDG() == -531) {
228  nb1++;
229  if (nb1 == 1) {
230  std::vector<int> DauPDG1;
231  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
232  DauPDG1.push_back(mcDaughter->getPDG());
233  }
234  modeB1 = gBtag.Mode_anti_Bs0(DauPDG1);
235  break;
236  }
237  }
238  if (iMCParticle.getPDG() == 531) {
239  nb2++;
240  if (nb2 == 2) {
241  std::vector<int> DauPDG2;
242  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
243  DauPDG2.push_back(mcDaughter->getPDG());
244  }
245  modeB2 = gBtag.Mode_Bs0(DauPDG2);
246  break;
247  }
248  }
249  }
250 
251  if (modeB1 != -99) { modeB = modeB1;}
252  else if (modeB2 != -99) { modeB = modeB2;}
253 
254  return modeB;
255  }
256 
257  double DstplusMode(const Particle*)
258  {
259  GenDTag gDtag;
260  StoreArray<MCParticle> MC_Particle_list;
261  if (!MC_Particle_list) {
262  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
263  return Const::doubleNaN;
264  }
265  int modeD = -99;
266 
267  for (const auto& iMCParticle : MC_Particle_list) {
268  if (iMCParticle.getPDG() != 413) continue;
269 
270  std::vector<int> DauPDG;
271  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
272  DauPDG.push_back(mcDaughter->getPDG());
273  }
274  modeD = gDtag.Mode_Dst_plus(DauPDG);
275  break;
276  }
277 
278  return modeD;
279  }
280 
281  double DstminusMode(const Particle*)
282  {
283  GenDTag gDtag;
284  StoreArray<MCParticle> MC_Particle_list;
285  if (!MC_Particle_list) {
286  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
287  return Const::doubleNaN;
288  }
289  int modeD = -99;
290 
291  for (const auto& iMCParticle : MC_Particle_list) {
292  if (iMCParticle.getPDG() != -413) continue;
293 
294  std::vector<int> DauPDG;
295  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
296  DauPDG.push_back(mcDaughter->getPDG());
297  }
298  modeD = gDtag.Mode_Dst_minus(DauPDG);
299  break;
300  }
301 
302  return modeD;
303  }
304 
305  double DsplusMode(const Particle*)
306  {
307  GenDTag gDtag;
308  StoreArray<MCParticle> MC_Particle_list;
309  if (!MC_Particle_list) {
310  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
311  return Const::doubleNaN;
312  }
313  int modeD = -99;
314 
315  for (const auto& iMCParticle : MC_Particle_list) {
316  if (iMCParticle.getPDG() != 431) continue;
317 
318  std::vector<int> DauPDG;
319  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
320  DauPDG.push_back(mcDaughter->getPDG());
321  }
322  modeD = gDtag.Mode_Ds_plus(DauPDG);
323  break;
324  }
325 
326  return modeD;
327  }
328 
329  double DsminusMode(const Particle*)
330  {
331  GenDTag gDtag;
332  StoreArray<MCParticle> MC_Particle_list;
333  if (!MC_Particle_list) {
334  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
335  return Const::doubleNaN;
336  }
337  int modeD = -99;
338 
339  for (const auto& iMCParticle : MC_Particle_list) {
340  if (iMCParticle.getPDG() != -431) continue;
341 
342  std::vector<int> DauPDG;
343  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
344  DauPDG.push_back(mcDaughter->getPDG());
345  }
346  modeD = gDtag.Mode_Ds_minus(DauPDG);
347  break;
348  }
349 
350  return modeD;
351  }
352 
353  double DplusMode(const Particle*)
354  {
355  GenDTag gDtag;
356  StoreArray<MCParticle> MC_Particle_list;
357  if (!MC_Particle_list) {
358  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
359  return Const::doubleNaN;
360  }
361  int modeD = -99;
362 
363  for (const auto& iMCParticle : MC_Particle_list) {
364  if (iMCParticle.getPDG() != 411) continue;
365 
366  std::vector<int> DauPDG;
367  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
368  DauPDG.push_back(mcDaughter->getPDG());
369  }
370  modeD = gDtag.Mode_D_plus(DauPDG);
371  break;
372  }
373 
374  return modeD;
375  }
376 
377  double DminusMode(const Particle*)
378  {
379  GenDTag gDtag;
380  StoreArray<MCParticle> MC_Particle_list;
381  if (!MC_Particle_list) {
382  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
383  return Const::doubleNaN;
384  }
385  int modeD = -99;
386 
387  for (const auto& iMCParticle : MC_Particle_list) {
388  if (iMCParticle.getPDG() != -411) continue;
389 
390  std::vector<int> DauPDG;
391  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
392  DauPDG.push_back(mcDaughter->getPDG());
393  }
394  modeD = gDtag.Mode_D_minus(DauPDG);
395  break;
396  }
397 
398  return modeD;
399  }
400 
401  double D0Mode(const Particle*)
402  {
403  GenDTag gDtag;
404  StoreArray<MCParticle> MC_Particle_list;
405  if (!MC_Particle_list) {
406  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
407  return Const::doubleNaN;
408  }
409  int modeD = -99;
410 
411  for (const auto& iMCParticle : MC_Particle_list) {
412  if (iMCParticle.getPDG() != 421) continue;
413 
414  std::vector<int> DauPDG;
415  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
416  DauPDG.push_back(mcDaughter->getPDG());
417  }
418  modeD = gDtag.Mode_D0(DauPDG);
419  break;
420  }
421 
422  return modeD;
423  }
424 
425  double Dbar0Mode(const Particle*)
426  {
427  GenDTag gDtag;
428  StoreArray<MCParticle> MC_Particle_list;
429  if (!MC_Particle_list) {
430  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
431  return Const::doubleNaN;
432  }
433  int modeD = -99;
434 
435  for (const auto& iMCParticle : MC_Particle_list) {
436  if (iMCParticle.getPDG() != -421) continue;
437 
438  std::vector<int> DauPDG;
439  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
440  DauPDG.push_back(mcDaughter->getPDG());
441  }
442  modeD = gDtag.Mode_anti_D0(DauPDG);
443  break;
444  }
445 
446  return modeD;
447  }
448 
449  double TauplusMode(const Particle*)
450  {
451  GenTauTag gTKtag;
452  StoreArray<MCParticle> MC_Particle_list;
453  if (!MC_Particle_list) {
454  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
455  return Const::doubleNaN;
456  }
457  int modeTau = -1;
458 
459  for (const auto& iMCParticle : MC_Particle_list) {
460  if (iMCParticle.getPDG() != -15) continue;
461 
462  std::vector<int> DauPDG;
463  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
464  if (mcDaughter->getPDG() == 24) {
465  for (auto const& WDaughter : mcDaughter->getDaughters()) {
466  DauPDG.push_back(WDaughter->getPDG());
467  }
468  } else DauPDG.push_back(mcDaughter->getPDG());
469  }
470  modeTau = gTKtag.Mode_tau_plus(DauPDG);
471  break;
472  }
473 
474  return modeTau;
475  }
476 
477  double TauminusMode(const Particle*)
478  {
479  GenTauTag gTKtag;
480  StoreArray<MCParticle> MC_Particle_list;
481  if (!MC_Particle_list) {
482  B2WARNING("GenMCTagTool::eval - missing MCParticles array");
483  return Const::doubleNaN;
484  }
485  int modeTau = -1;
486 
487  for (const auto& iMCParticle : MC_Particle_list) {
488  if (iMCParticle.getPDG() != 15) continue;
489 
490  std::vector<int> DauPDG;
491  for (auto const& mcDaughter : iMCParticle.getDaughters()) {
492  if (mcDaughter->getPDG() == -24) {
493  for (auto const& WDaughter : mcDaughter->getDaughters()) {
494  DauPDG.push_back(WDaughter->getPDG());
495  }
496  } else DauPDG.push_back(mcDaughter->getPDG());
497  }
498  modeTau = gTKtag.Mode_tau_minus(DauPDG);
499  break;
500  }
501 
502  return modeTau;
503  }
504 
505  VARIABLE_GROUP("MCParticle tag variables");
506  REGISTER_VARIABLE("BplusMode", BplusMode, "[Eventbased] It will return the decays mode of B+ particles");
507  REGISTER_VARIABLE("BminusMode", BminusMode, "[Eventbased] It will return the decays mode of B- particles");
508  REGISTER_VARIABLE("B0Mode", B0Mode, "[Eventbased] It will return the decays mode of B0 particles");
509  REGISTER_VARIABLE("Bbar0Mode", Bbar0Mode, "[Eventbased] It will return the decays mode of anti-B0 particles");
510  REGISTER_VARIABLE("Bs0Mode", Bs0Mode, "[Eventbased] It will return the decays mode of B_s0 particles");
511  REGISTER_VARIABLE("Bsbar0Mode", Bsbar0Mode, "[Eventbased] It will return the decays mode of anti-B_s0 particles");
512  REGISTER_VARIABLE("DstplusMode", DstplusMode, "[Eventbased] It will return the decays mode of D*+ particles");
513  REGISTER_VARIABLE("DstminusMode", DstminusMode, "[Eventbased] It will return the decays mode of D*- particles");
514  REGISTER_VARIABLE("DsplusMode", DsplusMode, "[Eventbased] It will return the decays mode of D_s+ particles");
515  REGISTER_VARIABLE("DsminusMode", DsminusMode, "[Eventbased] It will return the decays mode of D_s- particles");
516  REGISTER_VARIABLE("DplusMode", DplusMode, "[Eventbased] It will return the decays mode of D+ particles");
517  REGISTER_VARIABLE("DminusMode", DminusMode, "[Eventbased] It will return the decays mode of D- particles");
518  REGISTER_VARIABLE("D0Mode", D0Mode, "[Eventbased] It will return the decays mode of D0 particles");
519  REGISTER_VARIABLE("Dbar0Mode", Dbar0Mode, "[Eventbased] It will return the decays mode of anti-D0 particles");
520  REGISTER_VARIABLE("TauplusMode", TauplusMode, "[Eventbased] It will return the decays mode of tau+ particles");
521  REGISTER_VARIABLE("TauminusMode", TauminusMode, "[Eventbased] It will return the decays mode of tau- particles");
522  }
524 }
static const double doubleNaN
quiet_NaN
Definition: Const.h:694
Abstract base class for different kinds of events.