Belle II Software light-2609-luna
ROEVariables.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/ROEVariables.h>
11
12#include <analysis/variables/Variables.h>
13
14// framework - DataStore
15#include <framework/datastore/StoreArray.h>
16#include <framework/datastore/StoreObjPtr.h>
17
18// dataobjects
19#include <analysis/dataobjects/Particle.h>
20#include <analysis/dataobjects/ParticleList.h>
21#include <mdst/dataobjects/MCParticle.h>
22#include <mdst/dataobjects/ECLCluster.h>
23
24// framework aux
25#include <framework/logging/Logger.h>
26#include <framework/utilities/Conversion.h>
27#include <framework/gearbox/Const.h>
28
29// utility
30#include <analysis/utility/PCmsLabTransform.h>
31#include <analysis/utility/ReferenceFrame.h>
32
33#include <TRandom.h>
34#include <TMath.h>
35#include <Math/AxisAngle.h>
36#include <Math/VectorUtil.h>
37
38#include <iostream>
39
40using namespace std;
41
42namespace Belle2 {
47 namespace Variable {
48
49 bool isInRestOfEvent(const Particle* particle)
50 {
51
52 StoreObjPtr<RestOfEvent> roeobjptr;
53 if (not roeobjptr.isValid())
54 return 0;
55
56 const RestOfEvent* roe = &(*roeobjptr);
57
58 return isInThisRestOfEvent(particle, roe);
59 }
60
61 bool isCloneOfSignalSide(const Particle* particle)
62 {
63
64 StoreObjPtr<RestOfEvent> roe;
65 if (not roe.isValid()) {
66 B2ERROR("Please use isCloneOfSignalSide variable in for_each ROE loop!");
67 return 0;
68 }
69 auto* particleMC = particle->getMCParticle();
70 if (!particleMC) {
71 return 0;
72 }
73 auto* signal = roe->getRelatedFrom<Particle>();
74 auto signalFSPs = signal->getFinalStateDaughters();
75 for (auto* daughter : signalFSPs) {
76 auto* daughterMC = daughter->getMCParticle();
77 if (daughterMC == particleMC) {
78 return 1;
79 }
80 }
81 return 0;
82 }
83
84 bool hasAncestorFromSignalSide(const Particle* particle)
85 {
86 StoreObjPtr<RestOfEvent> roe;
87 if (!roe.isValid()) {
88 B2ERROR("Please use hasAncestorFromSignalSide variable in for_each ROE loop!");
89 return 0;
90 }
91 auto* particleMC = particle->getMCParticle();
92 if (!particleMC) {
93 return 0;
94 }
95 auto* signalReco = roe->getRelatedFrom<Particle>();
96 auto* signalMC = signalReco->getMCParticle();
97 const MCParticle* ancestorMC = particleMC->getMother();
98 while (ancestorMC) {
99 if (ancestorMC == signalMC) {
100 return 1;
101 }
102 ancestorMC = ancestorMC->getMother();
103 }
104 return 0;
105 }
106
107 Manager::FunctionPtr currentROEIsInList(const std::vector<std::string>& arguments)
108 {
109 if (arguments.size() != 1)
110 B2FATAL("Wrong number of arguments (1 required) for meta function currentROEIsInList");
111
112 std::string listName = arguments[0];
113
114 auto func = [listName](const Particle*) -> bool {
115
116 StoreObjPtr<ParticleList> particleList(listName);
117 if (!(particleList.isValid()))
118 {
119 B2FATAL("Invalid Listname " << listName << " given to currentROEIsInList!");
120 }
121 StoreObjPtr<RestOfEvent> roe("RestOfEvent");
122
123 if (not roe.isValid())
124 return 0;
125
126 auto* particle = roe->getRelatedFrom<Particle>();
127 if (particle == nullptr)
128 {
129 B2ERROR("Relation between particle and ROE doesn't exist! currentROEIsInList variable has to be called from ROE loop");
130 return 0;
131 }
132 return particleList->contains(particle) ? 1 : 0;
133
134 };
135 return func;
136 }
137
138 Manager::FunctionPtr particleRelatedToCurrentROE(const std::vector<std::string>& arguments)
139 {
140 if (arguments.size() != 1)
141 B2FATAL("Wrong number of arguments (1 required) for meta function particleRelatedToCurrentROE");
142
143 const Variable::Manager::Var* var = Manager::Instance().getVariable(arguments[0]);
144 auto func = [var](const Particle*) -> double {
145
146 StoreObjPtr<RestOfEvent> roe("RestOfEvent");
147
148 if (not roe.isValid())
149 return Const::doubleNaN;
150
151 auto* particle = roe->getRelatedFrom<Particle>();
152 if (particle == nullptr)
153 {
154 B2ERROR("Relation between particle and ROE doesn't exist! particleRelatedToCurrentROE variable has to be called from ROE loop");
155 return Const::doubleNaN;
156 }
157 if (std::holds_alternative<double>(var->function(particle)))
158 {
159 return std::get<double>(var->function(particle));
160 } else if (std::holds_alternative<int>(var->function(particle)))
161 {
162 return std::get<int>(var->function(particle));
163 } else if (std::holds_alternative<bool>(var->function(particle)))
164 {
165 return std::get<bool>(var->function(particle));
166 } else return Const::doubleNaN;
167
168 };
169 return func;
170 }
171
172 Manager::FunctionPtr useROERecoilFrame(const std::vector<std::string>& arguments)
173 {
174 if (arguments.size() == 1) {
175 const Variable::Manager::Var* var = Manager::Instance().getVariable(arguments[0]);
176 auto func = [var](const Particle * particle) -> double {
177 // Here we prioritize old variable behaviour first:
178 const RestOfEvent* roe = particle->getRelatedTo<RestOfEvent>();
179 // if related ROE not found, get the StoreArray pointer
180 if (roe == nullptr)
181 {
182 StoreObjPtr<RestOfEvent> roeObjPtr("RestOfEvent");
183 if (roeObjPtr.isValid()) {
184 roe = &*roeObjPtr;
185 }
186 }
187 if (roe == nullptr)
188 {
189 B2ERROR("Neither relation between particle and ROE exists nor ROE object has been found!");
190 return Const::doubleNaN;
191 }
192 PCmsLabTransform T;
193 ROOT::Math::PxPyPzEVector pRecoil = T.getBeamFourMomentum() - roe->get4Vector();
194 Particle tmp(pRecoil, 0);
195 UseReferenceFrame<RestFrame> frame(&tmp);
196 if (std::holds_alternative<double>(var->function(particle)))
197 {
198 return std::get<double>(var->function(particle));
199 } else if (std::holds_alternative<int>(var->function(particle)))
200 {
201 return std::get<int>(var->function(particle));
202 } else if (std::holds_alternative<bool>(var->function(particle)))
203 {
204 return std::get<bool>(var->function(particle));
205 } else return Const::doubleNaN;
206 };
207 return func;
208 } else {
209 B2FATAL("Wrong number of arguments for meta function useROERecoilFrame");
210 return nullptr;
211 }
212 }
213
214 // only the helper function
215 int nRemainingTracksInROE(const Particle* particle, const std::string& maskName)
216 {
217 StoreObjPtr<RestOfEvent> roe("RestOfEvent");
218 if (not roe.isValid())
219 return -1;
220 int n_roe_tracks = roe->getNTracks(maskName);
221 int n_par_tracks = 0;
222 const auto& daughters = particle->getFinalStateDaughters();
223 for (const auto& daughter : daughters) {
224 if (daughter->getParticleSource() == Particle::EParticleSourceObject::c_Track && roe->hasParticle(daughter, maskName)) {
225 n_par_tracks++;
226 }
227 }
228 return n_roe_tracks - n_par_tracks;
229 }
230
231 Manager::FunctionPtr nROE_RemainingTracksWithMask(const std::vector<std::string>& arguments)
232 {
233 std::string maskName = RestOfEvent::c_defaultMaskName;
234
235 if (arguments.size() == 1)
236 maskName = arguments[0];
237 else if (arguments.size() > 1)
238 B2FATAL("At most 1 argument (name of mask) accepted for meta function nROE_RemainingTracks");
239
240 auto func = [maskName](const Particle * particle) -> int {
241 return nRemainingTracksInROE(particle, maskName);
242 };
243 return func;
244 }
245
246 int nROE_RemainingTracks(const Particle* particle)
247 {
248 return nRemainingTracksInROE(particle);
249 }
250
251 int nROE_KLMClusters(const Particle* particle)
252 {
253 // Get related ROE object
254 const RestOfEvent* roe = getRelatedROEObject(particle);
255
256 if (!roe) {
257 B2ERROR("Relation between particle and ROE doesn't exist!");
258 return -1;
259 }
260
261 return roe->getNKLMClusters();
262 }
263
264 double ROE_MC_E(const Particle* particle)
265 {
266 const MCParticle* mcp = particle->getMCParticle();
267
268 if (!mcp)
269 return Const::doubleNaN;
270
271 PCmsLabTransform T;
272 ROOT::Math::PxPyPzEVector boostvec = T.getBeamFourMomentum();
273 auto mcroe4vector = boostvec - mcp->get4Vector();
274 const auto& frame = ReferenceFrame::GetCurrent();
275 auto frameMCRoe4Vector = frame.getMomentum(mcroe4vector);
276 return frameMCRoe4Vector.energy();
277 }
278
279 double ROE_MC_P(const Particle* particle)
280 {
281 const MCParticle* mcp = particle->getMCParticle();
282
283 if (!mcp)
284 return Const::doubleNaN;
285
286 PCmsLabTransform T;
287 ROOT::Math::PxPyPzEVector boostvec = T.getBeamFourMomentum();
288 auto mcroe4vector = boostvec - mcp->get4Vector();
289 const auto& frame = ReferenceFrame::GetCurrent();
290 auto frameMCRoe4Vector = frame.getMomentum(mcroe4vector);
291 return frameMCRoe4Vector.P();
292 }
293
294 double ROE_MC_Px(const Particle* particle)
295 {
296 const MCParticle* mcp = particle->getMCParticle();
297
298 if (!mcp)
299 return Const::doubleNaN;
300
301 PCmsLabTransform T;
302 ROOT::Math::PxPyPzEVector boostvec = T.getBeamFourMomentum();
303 auto mcroe4vector = boostvec - mcp->get4Vector();
304 const auto& frame = ReferenceFrame::GetCurrent();
305 auto frameMCRoe4Vector = frame.getMomentum(mcroe4vector);
306
307 return frameMCRoe4Vector.px();
308 }
309
310 double ROE_MC_Py(const Particle* particle)
311 {
312 const MCParticle* mcp = particle->getMCParticle();
313
314 if (!mcp)
315 return Const::doubleNaN;
316
317 PCmsLabTransform T;
318 ROOT::Math::PxPyPzEVector boostvec = T.getBeamFourMomentum();
319 auto mcroe4vector = boostvec - mcp->get4Vector();
320 const auto& frame = ReferenceFrame::GetCurrent();
321 auto frameMCRoe4Vector = frame.getMomentum(mcroe4vector);
322
323 return frameMCRoe4Vector.py();
324 }
325
326 double ROE_MC_Pz(const Particle* particle)
327 {
328 const MCParticle* mcp = particle->getMCParticle();
329
330 if (!mcp)
331 return Const::doubleNaN;
332
333 PCmsLabTransform T;
334 ROOT::Math::PxPyPzEVector boostvec = T.getBeamFourMomentum();
335 auto mcroe4vector = boostvec - mcp->get4Vector();
336 const auto& frame = ReferenceFrame::GetCurrent();
337 auto frameMCRoe4Vector = frame.getMomentum(mcroe4vector);
338
339 return frameMCRoe4Vector.pz();
340 }
341
342 double ROE_MC_Pt(const Particle* particle)
343 {
344 const MCParticle* mcp = particle->getMCParticle();
345
346 if (!mcp)
347 return Const::doubleNaN;
348
349 PCmsLabTransform T;
350 ROOT::Math::PxPyPzEVector boostvec = T.getBeamFourMomentum();
351 auto mcroe4vector = boostvec - mcp->get4Vector();
352 const auto& frame = ReferenceFrame::GetCurrent();
353 auto frameMCRoe4Vector = frame.getMomentum(mcroe4vector);
354
355 return frameMCRoe4Vector.pt();
356 }
357
358 double ROE_MC_PTheta(const Particle* particle)
359 {
360 const MCParticle* mcp = particle->getMCParticle();
361
362 if (!mcp)
363 return Const::doubleNaN;
364
365 PCmsLabTransform T;
366 ROOT::Math::PxPyPzEVector boostvec = T.getBeamFourMomentum();
367 auto mcroe4vector = boostvec - mcp->get4Vector();
368 const auto& frame = ReferenceFrame::GetCurrent();
369 auto frameMCRoe4Vector = frame.getMomentum(mcroe4vector);
370
371 return frameMCRoe4Vector.Theta();
372 }
373
374 double ROE_MC_M(const Particle* particle)
375 {
376 const MCParticle* mcp = particle->getMCParticle();
377
378 if (!mcp)
379 return Const::doubleNaN;
380
381 PCmsLabTransform T;
382 ROOT::Math::PxPyPzEVector boostvec = T.getBeamFourMomentum();
383
384 return (boostvec - mcp->get4Vector()).M();
385 }
386
387 Manager::FunctionPtr ROE_MC_MissingFlags(const std::vector<std::string>& arguments)
388 {
389 std::string maskName = RestOfEvent::c_defaultMaskName;
390
391 if (arguments.size() == 1)
392 maskName = arguments[0];
393 else if (arguments.size() > 1)
394 B2FATAL("At most 1 argument (name of mask) accepted for meta function roeMC_MissFlags");
395
396 auto func = [maskName](const Particle * particle) -> double {
397
398 StoreArray<Particle> particles;
399
400 //Get MC Particle of the B meson
401 const MCParticle* mcParticle = particle->getMCParticle();
402
403 if (!mcParticle)
404 return Const::doubleNaN;
405
406 // Get Mother
407 const MCParticle* mcMother = mcParticle->getMother();
408
409 if (!mcMother)
410 return Const::doubleNaN;
411
412 // Get daughters
413 std::vector<MCParticle*> mcDaughters = mcMother->getDaughters();
414
415 if (mcDaughters.size() != 2)
416 return Const::doubleNaN;
417
418 // Get the companion B meson
419 const MCParticle* mcROE = nullptr;
420 if (mcDaughters[0]->getArrayIndex() == mcParticle->getArrayIndex())
421 mcROE = mcDaughters[1];
422 else
423 mcROE = mcDaughters[0];
424
425 // Get related ROE object
426 const RestOfEvent* roe = getRelatedROEObject(particle);
427
428 std::set<const MCParticle*> mcROEObjects;
429
430 auto roeParticles = roe->getParticles(maskName);
431 for (const auto* roeParticle : roeParticles)
432 {
433 const auto* mcroeParticle = roeParticle->getMCParticle();
434 if (mcroeParticle != nullptr) {
435 mcROEObjects.insert(mcroeParticle);
436 }
437 }
438 int flags = 0;
439 checkMCParticleMissingFlags(mcROE, mcROEObjects, flags);
440
441 return flags;
442 };
443 return func;
444 }
445
446 Manager::FunctionPtr nROE_Tracks(const std::vector<std::string>& arguments)
447 {
448 std::string maskName = RestOfEvent::c_defaultMaskName;
449
450 if (arguments.size() == 1)
451 maskName = arguments[0];
452 else if (arguments.size() > 1)
453 B2FATAL("At most 1 argument (name of mask) accepted for meta function nROE_Tracks");
454
455 auto func = [maskName](const Particle * particle) -> int {
456
457 // Get related ROE object
458 const RestOfEvent* roe = getRelatedROEObject(particle);
459
460 if (!roe)
461 {
462 B2ERROR("Relation between particle and ROE doesn't exist!");
463 return -1;
464 }
465
466 return roe->getNTracks(maskName);
467 };
468 return func;
469 }
470
471 Manager::FunctionPtr nROE_ECLClusters(const std::vector<std::string>& arguments)
472 {
473 std::string maskName = RestOfEvent::c_defaultMaskName;
474
475 if (arguments.size() == 1)
476 maskName = arguments[0];
477 else if (arguments.size() > 1)
478 B2FATAL("At most 1 argument (name of mask) accepted for meta function nROE_ECLClusters");
479
480 auto func = [maskName](const Particle * particle) -> int {
481
482 // Get related ROE object
483 const RestOfEvent* roe = getRelatedROEObject(particle);
484
485 if (!roe)
486 {
487 B2ERROR("Relation between particle and ROE doesn't exist!");
488 return -1;
489 }
490
491 return roe->getNECLClusters(maskName);
492 };
493 return func;
494 }
495
496 Manager::FunctionPtr nROE_NeutralECLClusters(const std::vector<std::string>& arguments)
497 {
498 std::string maskName = RestOfEvent::c_defaultMaskName;
499
500 if (arguments.size() == 1)
501 maskName = arguments[0];
502 else if (arguments.size() > 1)
503 B2FATAL("At most 1 argument (name of mask) accepted for meta function nROE_NeutralECLClusters");
504
505 auto func = [maskName](const Particle * particle) -> int {
506
507 // Get related ROE object
508 const RestOfEvent* roe = getRelatedROEObject(particle);
509
510 if (!roe)
511 {
512 B2ERROR("Relation between particle and ROE doesn't exist!");
513 return -1;
514 }
515
516 return roe->getPhotons(maskName).size();
517 };
518 return func;
519 }
520
521 Manager::FunctionPtr nROE_Photons(const std::vector<std::string>& arguments)
522 {
523 std::string maskName = RestOfEvent::c_defaultMaskName;
524
525 if (arguments.size() == 1) {
526 maskName = arguments[0];
527 } else if (arguments.size() > 1) {
528 B2FATAL("At most 1 argument (name of mask) accepted for meta function nROE_Photons");
529 }
530 auto func = [maskName](const Particle * particle) -> int {
531
532 // Get related ROE object
533 const RestOfEvent* roe = getRelatedROEObject(particle);
534
535 if (!roe)
536 {
537 B2ERROR("Relation between particle and ROE doesn't exist!");
538 return -1;
539 }
540
541 // Get unused ECLClusters in ROE
542 auto roeClusters = roe->getPhotons(maskName);
543 int nPhotons = 0;
544
545 // Select ECLClusters with photon hypothesis
546 for (auto& roeCluster : roeClusters)
547 if (roeCluster->getECLClusterEHypothesisBit() == ECLCluster::EHypothesisBit::c_nPhotons)
548 nPhotons++;
549 return nPhotons;
550 };
551 return func;
552 }
553
554 Manager::FunctionPtr nROE_NeutralHadrons(const std::vector<std::string>& arguments)
555 {
556 std::string maskName = RestOfEvent::c_defaultMaskName;
557
558 if (arguments.size() == 1) {
559 maskName = arguments[0];
560 } else if (arguments.size() > 1) {
561 B2FATAL("At most 1 argument (name of mask) accepted for meta function nROE_NeutralHadrons");
562 }
563 auto func = [maskName](const Particle * particle) -> int {
564
565 // Get related ROE object
566 const RestOfEvent* roe = getRelatedROEObject(particle);
567
568 if (!roe)
569 {
570 B2ERROR("Relation between particle and ROE doesn't exist!");
571 return -1;
572 }
573
574 return roe->getHadrons(maskName).size();
575 };
576 return func;
577 }
578
579 Manager::FunctionPtr nROE_ChargedParticles(const std::vector<std::string>& arguments)
580 {
581 std::string maskName = RestOfEvent::c_defaultMaskName;
582 int pdgCode = 0;
583 if (arguments.size() == 1) {
584 maskName = arguments[0];
585 } else if (arguments.size() == 2) {
586 maskName = arguments[0];
587 try {
588 pdgCode = convertString<int>(arguments[1]);
589 } catch (std::invalid_argument&) {
590 B2ERROR("First argument of nROE_Charged must be a PDG code");
591 return nullptr;
592 }
593 } else if (arguments.size() > 2) {
594 B2FATAL("Wrong number of arguments (2 optional) for meta function nROE_Charged");
595 }
596 auto func = [maskName, pdgCode](const Particle * particle) -> int {
597
598 // Get related ROE object
599 const RestOfEvent* roe = getRelatedROEObject(particle);
600
601 if (!roe)
602 {
603 B2ERROR("Relation between particle and ROE doesn't exist!");
604 return -1;
605 }
606
607 return roe->getChargedParticles(maskName, abs(pdgCode)).size();
608 };
609 return func;
610 }
611
612 Manager::FunctionPtr nROE_Composites(const std::vector<std::string>& arguments)
613 {
614 std::string maskName = RestOfEvent::c_defaultMaskName;
615
616 if (arguments.size() == 1) {
617 maskName = arguments[0];
618 } else if (arguments.size() > 1) {
619 B2FATAL("At most 1 argument (name of mask) accepted for meta function nROE_Composites");
620 }
621 auto func = [maskName](const Particle * particle) -> int {
622
623 // Get related ROE object
624 const RestOfEvent* roe = getRelatedROEObject(particle);
625
626 if (!roe)
627 {
628 B2ERROR("Relation between particle and ROE doesn't exist!");
629 return -1;
630 }
631 int result = 0;
632 auto particles = roe->getParticles(maskName, false);
633
634 for (auto roeParticle : particles)
635 {
636 if (roeParticle->getParticleSource() == Particle::c_Composite or
637 roeParticle->getParticleSource() == Particle::c_V0) {
638 result++;
639 }
640 }
641 return result;
642 };
643 return func;
644 }
645
646 Manager::FunctionPtr nROE_ParticlesInList(const std::vector<std::string>& arguments)
647 {
648 std::string pListName;
649 std::string maskName = RestOfEvent::c_defaultMaskName;
650
651 if (arguments.size() == 1) {
652 pListName = arguments[0];
653 } else if (arguments.size() == 2) {
654 pListName = arguments[0];
655 maskName = arguments[1];
656 } else
657 B2FATAL("Wrong number of arguments (1 or 2 required) for meta function nROE_ParticlesInList");
658
659 auto func = [pListName, maskName](const Particle * particle) -> int {
660
661 // Get related ROE object
662 const RestOfEvent* roe = getRelatedROEObject(particle);
663
664 if (!roe)
665 {
666 B2ERROR("Relation between particle and ROE doesn't exist!");
667 return -1;
668 }
669
670 int nPart = 0;
671
672 // Get particle list
673 StoreObjPtr<ParticleList> pList(pListName);
674 if (!pList.isValid())
675 B2FATAL("ParticleList " << pListName << " could not be found or is not valid!");
676
677 for (unsigned int i = 0; i < pList->getListSize(); i++)
678 {
679 const Particle* part = pList->getParticle(i);
680 if (isInThisRestOfEvent(part, roe, maskName))
681 ++nPart;
682 }
683
684 return nPart;
685 };
686 return func;
687 }
688
689 Manager::FunctionPtr ROE_Charge(const std::vector<std::string>& arguments)
690 {
691 std::string maskName = RestOfEvent::c_defaultMaskName;
692
693 if (arguments.size() == 1)
694 maskName = arguments[0];
695 else if (arguments.size() > 1)
696 B2FATAL("At most 1 argument (name of mask) accepted for meta function roeCharge");
697
698 auto func = [maskName](const Particle * particle) -> double {
699
700 // Get related ROE object
701 const RestOfEvent* roe = getRelatedROEObject(particle);
702
703 if (!roe)
704 {
705 B2ERROR("Relation between particle and ROE doesn't exist!");
706 return Const::doubleNaN;
707 }
708
709 // Get tracks in ROE
710 auto roeParticles = roe->getParticles(maskName);
711 int roeCharge = 0;
712
713 for (auto* roeParticle : roeParticles)
714 {
715 roeCharge += roeParticle->getCharge();
716 }
717
718 return roeCharge;
719 };
720 return func;
721 }
722
723 Manager::FunctionPtr ROE_ExtraEnergy(const std::vector<std::string>& arguments)
724 {
725 std::string maskName = RestOfEvent::c_defaultMaskName;
726
727 if (arguments.size() == 1)
728 maskName = arguments[0];
729 else if (arguments.size() > 1)
730 B2FATAL("At most 1 argument (name of mask) accepted for meta function roeEextra");
731
732 auto func = [maskName](const Particle * particle) -> double {
733
734 // Get related ROE object
735 const RestOfEvent* roe = getRelatedROEObject(particle);
736
737 if (!roe)
738 {
739 B2ERROR("Relation between particle and ROE doesn't exist!");
740 return Const::doubleNaN;
741 }
742
743 double extraE = 0.0;
744
745 auto roeClusters = roe->getPhotons(maskName);
746
747 for (auto& roeCluster : roeClusters)
748 if (roeCluster->getECLClusterEHypothesisBit() == ECLCluster::EHypothesisBit::c_nPhotons)
749 extraE += roeCluster->getECLClusterEnergy();
750
751 auto roeChargedParticles = roe->getChargedParticles(maskName);
752
753 for (auto& roeChargedParticle : roeChargedParticles)
754 {
755 if (roeChargedParticle->getECLCluster())
756 extraE += roeChargedParticle->getECLClusterEnergy();
757 }
758
759 return extraE;
760 };
761 return func;
762 }
763
764 Manager::FunctionPtr ROE_NeutralExtraEnergy(const std::vector<std::string>& arguments)
765 {
766 std::string maskName = RestOfEvent::c_defaultMaskName;
767
768 if (arguments.size() == 1)
769 maskName = arguments[0];
770 else if (arguments.size() > 1)
771 B2FATAL("At most 1 argument (name of mask) accepted for meta function roeNeextra");
772
773 auto func = [maskName](const Particle * particle) -> double {
774
775 // Get related ROE object
776 const RestOfEvent* roe = getRelatedROEObject(particle);
777
778 if (!roe)
779 {
780 B2ERROR("Relation between particle and ROE doesn't exist!");
781 return Const::doubleNaN;
782 }
783 auto roephotons = roe->getPhotons(maskName);
784 ROOT::Math::PxPyPzEVector total4vector;
785 for (auto* photon : roephotons)
786 {
787 total4vector += photon->get4Vector();
788 }
789 const auto& frame = ReferenceFrame::GetCurrent();
790 auto frameRoe4Vector = frame.getMomentum(total4vector);
791 return frameRoe4Vector.energy();
792 };
793 return func;
794 }
795
796 Manager::FunctionPtr ROE_E(const std::vector<std::string>& arguments)
797 {
798 std::string maskName = RestOfEvent::c_defaultMaskName;
799
800 if (arguments.size() == 1)
801 maskName = arguments[0];
802 else if (arguments.size() > 1)
803 B2FATAL("At most 1 argument (name of mask) accepted for meta function roeE");
804
805 auto func = [maskName](const Particle * particle) -> double {
806 const RestOfEvent* roe = particle->getRelatedTo<RestOfEvent>();
807 if (!roe)
808 {
809 B2ERROR("Relation between particle and ROE doesn't exist!");
810 return Const::doubleNaN;
811 }
812 const auto& frame = ReferenceFrame::GetCurrent();
813 auto frameRoe4Vector = frame.getMomentum(roe->get4Vector(maskName));
814 return frameRoe4Vector.energy();
815 };
816 return func;
817 }
818
819 Manager::FunctionPtr ROE_M(const std::vector<std::string>& arguments)
820 {
821 std::string maskName = RestOfEvent::c_defaultMaskName;
822
823 if (arguments.size() == 1)
824 maskName = arguments[0];
825 else if (arguments.size() > 1)
826 B2FATAL("At most 1 argument (name of mask) accepted for meta function roeM");
827
828 auto func = [maskName](const Particle * particle) -> double {
829
830 // Get related ROE object
831 const RestOfEvent* roe = getRelatedROEObject(particle);
832
833 if (!roe)
834 {
835 B2ERROR("Relation between particle and ROE doesn't exist!");
836 return Const::doubleNaN;
837 }
838
839 return roe->get4Vector(maskName).M();
840 };
841 return func;
842 }
843
844 Manager::FunctionPtr ROE_P(const std::vector<std::string>& arguments)
845 {
846 std::string maskName = RestOfEvent::c_defaultMaskName;
847
848 if (arguments.size() == 1)
849 maskName = arguments[0];
850 else if (arguments.size() > 1)
851 B2FATAL("At most 1 argument (name of mask) accepted for meta function roeP");
852
853 auto func = [maskName](const Particle * particle) -> double {
854
855 // Get related ROE object
856 const RestOfEvent* roe = getRelatedROEObject(particle);
857
858 if (!roe)
859 {
860 B2ERROR("Relation between particle and ROE doesn't exist!");
861 return Const::doubleNaN;
862 }
863
864 const auto& frame = ReferenceFrame::GetCurrent();
865 auto frameRoe4Vector = frame.getMomentum(roe->get4Vector(maskName));
866 return frameRoe4Vector.P();
867 };
868 return func;
869 }
870
871 Manager::FunctionPtr ROE_Px(const std::vector<std::string>& arguments)
872 {
873 std::string maskName = RestOfEvent::c_defaultMaskName;
874
875 if (arguments.size() == 1)
876 maskName = arguments[0];
877 else if (arguments.size() > 1)
878 B2FATAL("At most 1 argument (name of mask) accepted for meta function roePx");
879
880 auto func = [maskName](const Particle * particle) -> double {
881
882 // Get related ROE object
883 const RestOfEvent* roe = getRelatedROEObject(particle);
884
885 if (!roe)
886 {
887 B2ERROR("Relation between particle and ROE doesn't exist!");
888 return Const::doubleNaN;
889 }
890
891 const auto& frame = ReferenceFrame::GetCurrent();
892 auto frameRoe4Vector = frame.getMomentum(roe->get4Vector(maskName));
893 return frameRoe4Vector.px();
894 };
895 return func;
896 }
897
898 Manager::FunctionPtr ROE_Py(const std::vector<std::string>& arguments)
899 {
900 std::string maskName = RestOfEvent::c_defaultMaskName;
901
902 if (arguments.size() == 1)
903 maskName = arguments[0];
904 else if (arguments.size() > 1)
905 B2FATAL("At most 1 argument (name of mask) accepted for meta function roePy");
906
907 auto func = [maskName](const Particle * particle) -> double {
908
909 // Get related ROE object
910 const RestOfEvent* roe = getRelatedROEObject(particle);
911
912 if (!roe)
913 {
914 B2ERROR("Relation between particle and ROE doesn't exist!");
915 return Const::doubleNaN;
916 }
917
918 const auto& frame = ReferenceFrame::GetCurrent();
919 auto frameRoe4Vector = frame.getMomentum(roe->get4Vector(maskName));
920 return frameRoe4Vector.py();
921 };
922 return func;
923 }
924
925 Manager::FunctionPtr ROE_Pt(const std::vector<std::string>& arguments)
926 {
927 std::string maskName = RestOfEvent::c_defaultMaskName;
928
929 if (arguments.size() == 1)
930 maskName = arguments[0];
931 else if (arguments.size() > 1)
932 B2FATAL("At most 1 argument (name of mask) accepted for meta function roePt");
933
934 auto func = [maskName](const Particle * particle) -> double {
935
936 // Get related ROE object
937 const RestOfEvent* roe = getRelatedROEObject(particle);
938
939 if (!roe)
940 {
941 B2ERROR("Relation between particle and ROE doesn't exist!");
942 return Const::doubleNaN;
943 }
944
945 const auto& frame = ReferenceFrame::GetCurrent();
946 auto frameRoe4Vector = frame.getMomentum(roe->get4Vector(maskName));
947 return frameRoe4Vector.pt();
948 };
949 return func;
950 }
951
952 Manager::FunctionPtr ROE_Pz(const std::vector<std::string>& arguments)
953 {
954 std::string maskName = RestOfEvent::c_defaultMaskName;
955
956 if (arguments.size() == 1)
957 maskName = arguments[0];
958 else if (arguments.size() > 1)
959 B2FATAL("At most 1 argument (name of mask) accepted for meta function roePz");
960
961 auto func = [maskName](const Particle * particle) -> double {
962
963 // Get related ROE object
964 const RestOfEvent* roe = getRelatedROEObject(particle);
965
966 if (!roe)
967 {
968 B2ERROR("Relation between particle and ROE doesn't exist!");
969 return Const::doubleNaN;
970 }
971
972 const auto& frame = ReferenceFrame::GetCurrent();
973 auto frameRoe4Vector = frame.getMomentum(roe->get4Vector(maskName));
974 return frameRoe4Vector.pz();
975 };
976 return func;
977 }
978
979 Manager::FunctionPtr ROE_PTheta(const std::vector<std::string>& arguments)
980 {
981 std::string maskName = RestOfEvent::c_defaultMaskName;
982
983 if (arguments.size() == 1)
984 maskName = arguments[0];
985 else if (arguments.size() > 1)
986 B2FATAL("At most 1 argument (name of mask) accepted for meta function roePTheta");
987
988 auto func = [maskName](const Particle * particle) -> double {
989
990 // Get related ROE object
991 const RestOfEvent* roe = getRelatedROEObject(particle);
992
993 if (!roe)
994 {
995 B2ERROR("Relation between particle and ROE doesn't exist!");
996 return Const::doubleNaN;
997 }
998
999 const auto& frame = ReferenceFrame::GetCurrent();
1000 auto frameRoe4Vector = frame.getMomentum(roe->get4Vector(maskName));
1001 return frameRoe4Vector.Theta();
1002 };
1003 return func;
1004 }
1005
1006 Manager::FunctionPtr ROE_DeltaE(const std::vector<std::string>& arguments)
1007 {
1008 std::string maskName = RestOfEvent::c_defaultMaskName;
1009
1010 if (arguments.size() == 1)
1011 maskName = arguments[0];
1012 else if (arguments.size() > 1)
1013 B2FATAL("At most 1 argument (name of mask) accepted for meta function roeDeltae");
1014
1015 auto func = [maskName](const Particle * particle) -> double {
1016
1017 // Get related ROE object
1018 const RestOfEvent* roe = getRelatedROEObject(particle);
1019
1020 if (!roe)
1021 {
1022 B2ERROR("Relation between particle and ROE doesn't exist!");
1023 return Const::doubleNaN;
1024 }
1025
1026 PCmsLabTransform T;
1027 ROOT::Math::PxPyPzEVector vec = T.rotateLabToCms() * roe->get4Vector(maskName);
1028 return vec.E() - T.getCMSEnergy() / 2;
1029 };
1030 return func;
1031 }
1032
1033 Manager::FunctionPtr ROE_Mbc(const std::vector<std::string>& arguments)
1034 {
1035 std::string maskName = RestOfEvent::c_defaultMaskName;
1036
1037 if (arguments.size() == 1)
1038 maskName = arguments[0];
1039 else if (arguments.size() > 1)
1040 B2FATAL("At most 1 argument (name of mask) accepted for meta function roeMbc");
1041
1042 auto func = [maskName](const Particle * particle) -> double {
1043
1044 // Get related ROE object
1045 const RestOfEvent* roe = getRelatedROEObject(particle);
1046
1047 if (!roe)
1048 {
1049 B2ERROR("Relation between particle and ROE doesn't exist!");
1050 return Const::doubleNaN;
1051 }
1052
1053 PCmsLabTransform T;
1054 ROOT::Math::PxPyPzEVector vec = T.rotateLabToCms() * roe->get4Vector(maskName);
1055
1056 double E = T.getCMSEnergy() / 2;
1057 double m2 = E * E - vec.P2();
1058 double mbc = m2 > 0 ? sqrt(m2) : 0;
1059
1060 return mbc;
1061 };
1062 return func;
1063 }
1064
1065 Manager::FunctionPtr bssMassDifference(const std::vector<std::string>& arguments)
1066 {
1067 std::string maskName = RestOfEvent::c_defaultMaskName;
1068
1069 if (arguments.size() == 1)
1070 maskName = arguments[0];
1071 else if (arguments.size() > 1)
1072 B2FATAL("At most 1 argument (name of mask) accepted for meta function bssMassDifference");
1073
1074 auto func = [maskName](const Particle * particle) -> double {
1075
1076 // Get related ROE object
1077 const auto& frame = ReferenceFrame::GetCurrent();
1078 ROOT::Math::PxPyPzEVector neutrino4vec = missing4Vector(particle->getDaughter(0), maskName, "1");
1079 ROOT::Math::PxPyPzEVector sig4vec = frame.getMomentum(particle->getDaughter(0)->get4Vector());
1080
1081 ROOT::Math::PxPyPzEVector bsMom = neutrino4vec + sig4vec;
1082 ROOT::Math::PxPyPzEVector bssMom = bsMom + frame.getMomentum(particle->getDaughter(1)->get4Vector());
1083
1084 return bssMom.M() - bsMom.M();
1085 };
1086 return func;
1087 }
1088
1089 Manager::FunctionPtr WE_DeltaE(const std::vector<std::string>& arguments)
1090 {
1091 std::string maskName = RestOfEvent::c_defaultMaskName;
1092
1093 if (arguments.size() == 1)
1094 maskName = arguments[0];
1095 else if (arguments.size() > 1)
1096 B2FATAL("At most 1 argument (name of mask) accepted for meta function weDeltae.");
1097
1098 auto func = [maskName](const Particle * particle) -> double {
1099
1100 PCmsLabTransform T;
1101 const auto& frame = ReferenceFrame::GetCurrent();
1102 ROOT::Math::PxPyPzEVector boostvec = frame.getMomentum(T.getBeamFourMomentum());
1103 ROOT::Math::PxPyPzEVector sig4vec = frame.getMomentum(particle->get4Vector());
1104 ROOT::Math::PxPyPzEVector neutrino4vec = missing4Vector(particle, maskName, "1");
1105
1106 double E = T.getCMSEnergy();
1107 double deltaE = (sig4vec + neutrino4vec).Dot(boostvec) / E - E / 2.0;
1108
1109 return deltaE;
1110 };
1111 return func;
1112 }
1113
1114 Manager::FunctionPtr WE_Mbc(const std::vector<std::string>& arguments)
1115 {
1116 std::string maskName = RestOfEvent::c_defaultMaskName;
1117
1118 if (arguments.size() == 1) {
1119 maskName = arguments[0];
1120 } else if (arguments.size() > 1)
1121 B2FATAL("At most 1 argument (name of mask) accepted for meta function weMbc");
1122
1123 auto func = [maskName](const Particle * particle) -> double {
1124
1125 PCmsLabTransform T;
1126 const auto& frame = ReferenceFrame::GetCurrent();
1127 ROOT::Math::PxPyPzEVector boostvec = frame.getMomentum(T.getBeamFourMomentum());
1128 ROOT::Math::PxPyPzEVector sig4vec = frame.getMomentum(particle->get4Vector());
1129 ROOT::Math::PxPyPzEVector neutrino4vec = missing4Vector(particle, maskName, "1");
1130
1131 ROOT::Math::PxPyPzEVector bmom = sig4vec + neutrino4vec;
1132 double Ecms = T.getCMSEnergy();
1133 double m2 = pow((Ecms* Ecms / 2.0 + bmom.Vect().Dot(boostvec.Vect())) / boostvec.energy(), 2.0) - bmom.P2();
1134 double mbc = m2 > 0 ? sqrt(m2) : 0;
1135
1136 return mbc;
1137 };
1138 return func;
1139 }
1140
1141 Manager::FunctionPtr WE_MbcWithdEZero(const std::vector<std::string>& arguments)
1142 {
1143 std::string maskName = RestOfEvent::c_defaultMaskName;
1144
1145 if (arguments.size() == 1) {
1146 maskName = arguments[0];
1147 } else if (arguments.size() > 1)
1148 B2FATAL("At most 1 argument (name of mask) accepted for meta function weMbc");
1149
1150 auto func = [maskName](const Particle * particle) -> double {
1151
1152 PCmsLabTransform T;
1153 ROOT::Math::PxPyPzEVector sig4vec = T.rotateLabToCms() * particle->get4Vector();
1154 ROOT::Math::PxPyPzEVector neutrino4vec = missing4Vector(particle, maskName, "7");
1155
1156 ROOT::Math::PxPyPzEVector bmom = sig4vec + neutrino4vec;
1157 double E = T.getCMSEnergy() / 2;
1158 double m2 = E * E - bmom.P2();
1159 double mbc = m2 > 0 ? sqrt(m2) : 0;
1160
1161 return mbc;
1162 };
1163 return func;
1164 }
1165
1166 Manager::FunctionPtr WE_MissM2(const std::vector<std::string>& arguments)
1167 {
1168 std::string maskName;
1169 std::string opt;
1170
1171 if (arguments.size() == 1) {
1172 B2WARNING("The single-argument form of weMissM2 is deprecated: the mask name will become a mandatory argument in a future release. Please call weMissM2(maskName, opt) instead.");
1174 opt = arguments[0];
1175 } else if (arguments.size() == 2) {
1176 maskName = arguments[0];
1177 opt = arguments[1];
1178 } else
1179 B2FATAL("Wrong number of arguments (2 required) for meta function weMissM2");
1180
1181 auto func = [maskName, opt](const Particle * particle) -> double {
1182
1183 return missing4Vector(particle, maskName, opt).M2();
1184 };
1185 return func;
1186 }
1187
1188 Manager::FunctionPtr WE_MissPTheta(const std::vector<std::string>& arguments)
1189 {
1190 std::string maskName;
1191 std::string opt;
1192
1193 if (arguments.size() == 1) {
1194 B2WARNING("The single-argument form of weMissPTheta is deprecated: the mask name will become a mandatory argument in a future release. Please call weMissPTheta(maskName, opt) instead.");
1196 opt = arguments[0];
1197 } else if (arguments.size() == 2) {
1198 maskName = arguments[0];
1199 opt = arguments[1];
1200 } else
1201 B2FATAL("Wrong number of arguments (2 required) for meta function weMissPTheta");
1202
1203 auto func = [maskName, opt](const Particle * particle) -> double {
1204
1205 // Get related ROE object
1206 const RestOfEvent* roe = getRelatedROEObject(particle);
1207
1208 if (!roe)
1209 {
1210 B2ERROR("Relation between particle and ROE doesn't exist!");
1211 return Const::doubleNaN;
1212 }
1213
1214 return missing4Vector(particle, maskName, opt).Theta();
1215 };
1216 return func;
1217 }
1218
1219 Manager::FunctionPtr WE_MissP(const std::vector<std::string>& arguments)
1220 {
1221 std::string maskName;
1222 std::string opt;
1223
1224 if (arguments.size() == 1) {
1225 B2WARNING("The single-argument form of weMissP is deprecated: the mask name will become a mandatory argument in a future release. Please call weMissP(maskName, opt) instead.");
1227 opt = arguments[0];
1228 } else if (arguments.size() == 2) {
1229 maskName = arguments[0];
1230 opt = arguments[1];
1231 } else
1232 B2FATAL("Wrong number of arguments (2 required) for meta function weMissP");
1233
1234 auto func = [maskName, opt](const Particle * particle) -> double {
1235
1236 // Get related ROE object
1237 const RestOfEvent* roe = getRelatedROEObject(particle);
1238
1239 if (!roe)
1240 {
1241 B2ERROR("Relation between particle and ROE doesn't exist!");
1242 return Const::doubleNaN;
1243 }
1244
1245 return missing4Vector(particle, maskName, opt).P();
1246 };
1247 return func;
1248 }
1249
1250 Manager::FunctionPtr WE_MissPx(const std::vector<std::string>& arguments)
1251 {
1252 std::string maskName;
1253 std::string opt;
1254
1255 if (arguments.size() == 1) {
1256 B2WARNING("The single-argument form of weMissPx is deprecated: the mask name will become a mandatory argument in a future release. Please call weMissPx(maskName, opt) instead.");
1258 opt = arguments[0];
1259 } else if (arguments.size() == 2) {
1260 maskName = arguments[0];
1261 opt = arguments[1];
1262 } else
1263 B2FATAL("Wrong number of arguments (2 required) for meta function weMissPx");
1264
1265 auto func = [maskName, opt](const Particle * particle) -> double {
1266
1267 // Get related ROE object
1268 const RestOfEvent* roe = getRelatedROEObject(particle);
1269
1270 if (!roe)
1271 {
1272 B2ERROR("Relation between particle and ROE doesn't exist!");
1273 return Const::doubleNaN;
1274 }
1275
1276 return missing4Vector(particle, maskName, opt).Px();
1277 };
1278 return func;
1279 }
1280
1281 Manager::FunctionPtr WE_MissPy(const std::vector<std::string>& arguments)
1282 {
1283 std::string maskName;
1284 std::string opt;
1285
1286 if (arguments.size() == 1) {
1287 B2WARNING("The single-argument form of weMissPy is deprecated: the mask name will become a mandatory argument in a future release. Please call weMissPy(maskName, opt) instead.");
1289 opt = arguments[0];
1290 } else if (arguments.size() == 2) {
1291 maskName = arguments[0];
1292 opt = arguments[1];
1293 } else
1294 B2FATAL("Wrong number of arguments (2 required) for meta function weMissPy");
1295
1296 auto func = [maskName, opt](const Particle * particle) -> double {
1297
1298 // Get related ROE object
1299 const RestOfEvent* roe = getRelatedROEObject(particle);
1300
1301 if (!roe)
1302 {
1303 B2ERROR("Relation between particle and ROE doesn't exist!");
1304 return Const::doubleNaN;
1305 }
1306
1307 return missing4Vector(particle, maskName, opt).Py();
1308 };
1309 return func;
1310 }
1311
1312 Manager::FunctionPtr WE_MissPz(const std::vector<std::string>& arguments)
1313 {
1314 std::string maskName;
1315 std::string opt;
1316
1317 if (arguments.size() == 1) {
1318 B2WARNING("The single-argument form of weMissPz is deprecated: the mask name will become a mandatory argument in a future release. Please call weMissPz(maskName, opt) instead.");
1320 opt = arguments[0];
1321 } else if (arguments.size() == 2) {
1322 maskName = arguments[0];
1323 opt = arguments[1];
1324 } else
1325 B2FATAL("Wrong number of arguments (2 required) for meta function weMissPz");
1326
1327 auto func = [maskName, opt](const Particle * particle) -> double {
1328
1329 // Get related ROE object
1330 const RestOfEvent* roe = getRelatedROEObject(particle);
1331
1332 if (!roe)
1333 {
1334 B2ERROR("Relation between particle and ROE doesn't exist!");
1335 return Const::doubleNaN;
1336 }
1337
1338 return missing4Vector(particle, maskName, opt).Pz();
1339 };
1340 return func;
1341 }
1342
1343 Manager::FunctionPtr WE_MissE(const std::vector<std::string>& arguments)
1344 {
1345 std::string maskName;
1346 std::string opt;
1347
1348 if (arguments.size() == 1) {
1349 B2WARNING("The single-argument form of weMissE is deprecated: the mask name will become a mandatory argument in a future release. Please call weMissE(maskName, opt) instead.");
1351 opt = arguments[0];
1352 } else if (arguments.size() == 2) {
1353 maskName = arguments[0];
1354 opt = arguments[1];
1355 } else
1356 B2FATAL("Wrong number of arguments (2 required) for meta function weMissE");
1357
1358 auto func = [maskName, opt](const Particle * particle) -> double {
1359
1360 // Get related ROE object
1361 const RestOfEvent* roe = getRelatedROEObject(particle);
1362
1363 if (!roe)
1364 {
1365 B2ERROR("Relation between particle and ROE doesn't exist!");
1366 return Const::doubleNaN;
1367 }
1368
1369 return missing4Vector(particle, maskName, opt).energy();
1370 };
1371 return func;
1372 }
1373
1374 Manager::FunctionPtr WE_xiZ(const std::vector<std::string>& arguments)
1375 {
1376 std::string maskName = RestOfEvent::c_defaultMaskName;
1377
1378 if (arguments.size() == 1)
1379 maskName = arguments[0];
1380 else if (arguments.size() > 1)
1381 B2FATAL("At most 1 argument (name of mask) accepted for meta function weXiZ");
1382
1383 auto func = [maskName](const Particle * particle) -> double {
1384
1385 // Get related ROE object
1386 const RestOfEvent* roe = getRelatedROEObject(particle);
1387
1388 if (!roe)
1389 {
1390 B2ERROR("Relation between particle and ROE doesn't exist!");
1391 return Const::doubleNaN;
1392 }
1393
1394 double pz = 0;
1395 double energy = 0;
1396 const auto& frame = ReferenceFrame::GetCurrent();
1397
1398 // Get all Tracks on reconstructed side
1399 std::vector<const Particle*> recTrackParticles = particle->getFinalStateDaughters();
1400
1401 // Loop the reconstructed side
1402 for (auto& recTrackParticle : recTrackParticles)
1403 {
1404 pz += frame.getMomentum(recTrackParticle->get4Vector()).Pz();
1405 energy += frame.getMomentum(recTrackParticle->get4Vector()).E();
1406 }
1407
1408 // Loop the ROE side
1409 auto roeParticles = roe->getChargedParticles(maskName);
1410 for (auto* roeParticle : roeParticles)
1411 {
1412 pz += frame.getMomentum(roeParticle->get4Vector()).Pz();
1413 energy += frame.getMomentum(roeParticle->get4Vector()).E();
1414 }
1415
1416 return pz / energy;
1417 };
1418 return func;
1419 }
1420
1421 Manager::FunctionPtr WE_MissM2OverMissE(const std::vector<std::string>& arguments)
1422 {
1423 std::string maskName = RestOfEvent::c_defaultMaskName;
1424
1425 if (arguments.size() == 1)
1426 maskName = arguments[0];
1427 else if (arguments.size() > 1)
1428 B2FATAL("At most 1 argument (name of mask) accepted for meta function weMissM2OverMissE");
1429
1430 auto func = [maskName](const Particle * particle) -> double {
1431
1432 // Get related ROE object
1433 const RestOfEvent* roe = getRelatedROEObject(particle);
1434
1435 if (!roe)
1436 {
1437 B2ERROR("Relation between particle and ROE doesn't exist!");
1438 return Const::doubleNaN;
1439 }
1440
1441 ROOT::Math::PxPyPzEVector neutrino4vec = missing4Vector(particle, maskName, "0");
1442 return neutrino4vec.M2() / (2.0 * neutrino4vec.energy());
1443 };
1444 return func;
1445 }
1446
1447 Manager::FunctionPtr WE_q2lnuSimple(const std::vector<std::string>& arguments)
1448 {
1449 std::string maskName(RestOfEvent::c_defaultMaskName);
1450 std::string option("1");
1451
1452 if (arguments.size() == 1) {
1453 maskName = arguments[0];
1454 } else if (arguments.size() == 2) {
1455 maskName = arguments[0];
1456 option = arguments[1];
1457 } else if (arguments.size() > 2) {
1458 B2FATAL("Too many arguments. At most two arguments are allowed for meta function weQ2lnuSimple");
1459 }
1460
1461 auto func = [maskName, option](const Particle * particle) -> double {
1462
1463 // Get related ROE object
1464 const RestOfEvent* roe = getRelatedROEObject(particle);
1465
1466 if (!roe)
1467 {
1468 B2ERROR("Relation between particle and ROE doesn't exist!");
1469 return Const::doubleNaN;
1470 }
1471
1472 int n = particle->getNDaughters();
1473
1474 if (n < 1)
1475 return Const::doubleNaN;
1476
1477 // Assumes lepton is the last particle in the reco decay chain!
1478 const Particle* lep = particle->getDaughter(n - 1);
1479 bool enforceCMSFrame = (option == "4" or option == "7");
1480 ROOT::Math::PxPyPzEVector lep4vec = transformVector(lep->get4Vector(), enforceCMSFrame);
1481 ROOT::Math::PxPyPzEVector nu4vec = missing4Vector(particle, maskName, option);
1482
1483 return (lep4vec + nu4vec).M2();
1484 };
1485 return func;
1486 }
1487
1488 Manager::FunctionPtr WE_q2lnu(const std::vector<std::string>& arguments)
1489 {
1490 std::string maskName(RestOfEvent::c_defaultMaskName);
1491 std::string option("7");
1492
1493 if (arguments.size() == 1) {
1494 maskName = arguments[0];
1495 } else if (arguments.size() == 2) {
1496 maskName = arguments[0];
1497 option = arguments[1];
1498 } else if (arguments.size() > 2) {
1499 B2FATAL("Too many arguments. At most two arguments are allowed for meta function weQ2lnu");
1500 }
1501
1502 auto func = [maskName, option](const Particle * particle) -> double {
1503
1504 // Get related ROE object
1505 const RestOfEvent* roe = getRelatedROEObject(particle);
1506
1507 if (!roe)
1508 {
1509 B2ERROR("Relation between particle and ROE doesn't exist!");
1510 return Const::doubleNaN;
1511 }
1512
1513 int n = particle->getNDaughters();
1514
1515 if (n < 1)
1516 return Const::doubleNaN;
1517
1518 PCmsLabTransform T;
1519 const Particle* lep = particle->getDaughter(n - 1);
1520 ROOT::Math::PxPyPzEVector lep_cm = T.rotateLabToCms() * lep->get4Vector();
1521
1522 ROOT::Math::PxPyPzEVector Y_cm = T.rotateLabToCms() * particle->get4Vector();
1523 ROOT::Math::PxPyPzEVector neu_cm = missing4Vector(particle, maskName, option);
1524
1525 double e_beam = T.getCMSEnergy() / 2.0;
1526
1527 //just to make the formula simpler
1528 double bmass = particle->getPDGMass();
1529 double pB2 = e_beam * e_beam - bmass * bmass;
1530
1531 //angle between the Y and the neutrino, from the Mbc=M_B constraint
1532 double cos_angle_nu = (pB2 - Y_cm.P2() - neu_cm.P2()) / (2.0 * Y_cm.P() * neu_cm.P());
1533 if (abs(cos_angle_nu) > 1)
1534 {
1535 return (lep_cm + neu_cm).M2();
1536 }
1537
1538 double angle_nu = TMath::ACos(cos_angle_nu);
1539 //first get one random neutrino, on the allowed cone for the constraint
1540 ROOT::Math::PtEtaPhiEVector rotated_neu(-Y_cm); //first get reverse Y
1541 rotated_neu.SetE(Y_cm.E());
1542
1543 double nu_eta = -log(tan((rotated_neu.Theta() + (TMath::Pi() - angle_nu)) / 2.));
1544 rotated_neu.SetEta(nu_eta);
1545 rotated_neu.SetPt(neu_cm.pt());
1546 rotated_neu.SetE(neu_cm.E());
1547
1548 ROOT::Math::XYZVector Yneu_norm = Y_cm.Vect().Cross(neu_cm.Vect());
1549 ROOT::Math::XYZVector Yrot_norm = Y_cm.Vect().Cross(rotated_neu.Vect());
1550 //angle between the two crossproducts -> angle between the two vectors perpendicular to the Y-p_inc and Y-B planes -> angle between the planes
1551 //this angle needs to come out as zero
1552
1553 double rot_angle = ROOT::Math::VectorUtil::Angle(Yneu_norm, Yrot_norm);
1554
1555 ROOT::Math::PxPyPzEVector rotated_neu2(rotated_neu);
1556 //unfortunately don't -and probably can't- know in which direction to rotate without trying
1557 //so create a copy of the vector, and later choose the correct one
1558 //However, rotation by 180 degrees is never needed, direction of the cross-product vector assures that when after rotation
1559 //the B-vector is in the plane, it always is on the side closer to pcm_lv_inc.
1560 //rotate around Y into the Y-neutrino-plane
1561 ROOT::Math::AxisAngle rotation(Y_cm.Vect(), rot_angle);
1562 rotation(rotated_neu);
1563 rotation.Invert();
1564 rotation(rotated_neu2);
1565
1566 double dot1 = rotated_neu.Vect().Dot(Yneu_norm);
1567 double dot2 = rotated_neu2.Vect().Dot(Yneu_norm);
1568
1569 if (abs(dot2) < abs(dot1)) rotated_neu = rotated_neu2;
1570
1571 return (lep_cm + rotated_neu).M2();
1572 };
1573 return func;
1574 }
1575
1576 Manager::FunctionPtr WE_cosThetaEll(const std::vector<std::string>& arguments)
1577 {
1578 std::string maskName = RestOfEvent::c_defaultMaskName;
1579
1580 if (arguments.size() == 1)
1581 maskName = arguments[0];
1582 else if (arguments.size() > 1)
1583 B2FATAL("At most 1 argument (name of mask) accepted for meta function weCosThetaEll");
1584
1585 auto func = [maskName](const Particle * particle) -> double {
1586
1587 ROOT::Math::PxPyPzEVector pNu = missing4Vector(particle, maskName, "1");
1588
1589 const auto& frame = ReferenceFrame::GetCurrent();
1590 ROOT::Math::PxPyPzEVector pLep;
1591 for (unsigned i = 0; i < particle->getNDaughters(); i++)
1592 {
1593 int absPDG = abs(particle->getDaughter(i)->getPDGCode());
1594 if (absPDG == Const::electron.getPDGCode() || absPDG == Const::muon.getPDGCode() || absPDG == 15) {
1595 pLep = frame.getMomentum(particle->getDaughter(i)->get4Vector());
1596 break;
1597 }
1598 }
1599
1600 ROOT::Math::PxPyPzEVector pW = pNu + pLep;
1601 ROOT::Math::PxPyPzEVector pB = frame.getMomentum(particle->get4Vector()) + pNu;
1602
1603 // boost lepton and B momentum to W frame
1604 ROOT::Math::XYZVector boost2W = pW.BoostToCM();
1605 pLep = ROOT::Math::Boost(boost2W) * pLep;
1606 pB = ROOT::Math::Boost(boost2W) * pB;
1607
1608 return ROOT::Math::VectorUtil::CosTheta(pLep, pB);
1609 };
1610 return func;
1611 }
1612
1613 Manager::FunctionPtr passesROEMask(const std::vector<std::string>& arguments)
1614 {
1615 std::string maskName = RestOfEvent::c_defaultMaskName;
1616
1617 if (arguments.size() == 1)
1618 maskName = arguments[0];
1619 else if (arguments.size() > 1)
1620 B2FATAL("At most 1 argument (name of mask) accepted for meta function passesROEMask");
1621
1622 auto func = [maskName](const Particle * particle) -> bool {
1623
1624 StoreObjPtr<RestOfEvent> roeObjPtr("RestOfEvent");
1625 if (not roeObjPtr.isValid())
1626 return 0;
1627
1628 const RestOfEvent* roe = &(*roeObjPtr);
1629
1630 return isInThisRestOfEvent(particle, roe, maskName);
1631 };
1632 return func;
1633 }
1634
1635 double printROE(const Particle* particle)
1636 {
1637 const RestOfEvent* roe = getRelatedROEObject(particle);
1638
1639 if (!roe) {
1640 B2ERROR("Relation between particle and ROE doesn't exist!");
1641 } else roe->print();
1642 return 0;
1643 }
1644
1645 bool hasCorrectROECombination(const Particle* particle)
1646 {
1647 unsigned nDaughters = particle->getNDaughters();
1648 if (nDaughters < 2) {
1649 B2ERROR("The particle must have at least two daughters.");
1650 return 0;
1651 }
1652
1653 for (unsigned i = 0; i < particle->getNDaughters(); i++) {
1654
1655 // Find a daughter that is loaded from a ROE object
1656 auto daughter = particle->getDaughter(i);
1657 auto roe = daughter->getRelatedFrom<RestOfEvent>();
1658 if (!roe)
1659 continue;
1660
1661 auto sourceParticle = roe->getRelatedFrom<Particle>();
1662 for (unsigned j = 0; j < particle->getNDaughters(); j++) {
1663 if (i == j) continue;
1664 const auto anotherDaughter = particle->getDaughter(j);
1665
1666 if (anotherDaughter == sourceParticle)
1667 return 1;
1668 }
1669 return 0;
1670 }
1671
1672 B2ERROR("There is no daughter particle loaded from the ROE object.");
1673 return 0;
1674 }
1675
1676 Manager::FunctionPtr pi0Prob(const std::vector<std::string>& arguments)
1677 {
1678 if (arguments.size() != 1)
1679 B2ERROR("Wrong number of arguments (1 required) for pi0Prob");
1680
1681 std::string mode;
1682 mode = arguments[0];
1683
1684 if (mode != "standard" and mode != "tight" and mode != "cluster" and mode != "both" and mode != "standardMC15rd"
1685 and mode != "tightMC15rd" and mode != "standardMC16rd" and mode != "tightMC16rd")
1686 B2ERROR("the given argument is not supported in pi0Prob!");
1687
1688 auto func = [mode](const Particle * particle) -> double {
1689 if (mode == "standard")
1690 {
1691 if (particle->hasExtraInfo("Pi0ProbOrigin")) {
1692 return particle->getExtraInfo("Pi0ProbOrigin");
1693 } else {
1694 B2WARNING("Pi0ProbOrigin is not registered in extraInfo! \n"
1695 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1696 return Const::doubleNaN;
1697 }
1698 } else if (mode == "tight")
1699 {
1700 if (particle->hasExtraInfo("Pi0ProbTightEnergyThreshold")) {
1701 return particle->getExtraInfo("Pi0ProbTightEnergyThreshold");
1702 } else {
1703 B2WARNING("Pi0ProbTightEnergyThreshold is not registered in extraInfo! \n"
1704 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1705 return Const::doubleNaN;
1706 }
1707 } else if (mode == "cluster")
1708 {
1709 if (particle->hasExtraInfo("Pi0ProbLargeClusterSize")) {
1710 return particle->getExtraInfo("Pi0ProbLargeClusterSize");
1711 } else {
1712 B2WARNING("Pi0ProbLargeClusterSize is not registered in extraInfo! \n"
1713 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1714 return Const::doubleNaN;
1715 }
1716 } else if (mode == "both")
1717 {
1718 if (particle->hasExtraInfo("Pi0ProbTightEnergyThresholdAndLargeClusterSize")) {
1719 return particle->getExtraInfo("Pi0ProbTightEnergyThresholdAndLargeClusterSize");
1720 } else {
1721 B2WARNING("Pi0ProbTightEnergyThresholdAndLargeClusterSize is not registered in extraInfo! \n"
1722 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1723 return Const::doubleNaN;
1724 }
1725 } else if (mode == "standardMC15rd")
1726 {
1727 if (particle->hasExtraInfo("Pi0ProbOriginMC15rd")) {
1728 return particle->getExtraInfo("Pi0ProbOriginMC15rd");
1729 } else {
1730 B2WARNING("Pi0ProbOriginMC15rd is not registered in extraInfo! \n"
1731 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1732 return Const::doubleNaN;
1733 }
1734 } else if (mode == "tightMC15rd")
1735 {
1736 if (particle->hasExtraInfo("Pi0ProbTightEnergyThresholdMC15rd")) {
1737 return particle->getExtraInfo("Pi0ProbTightEnergyThresholdMC15rd");
1738 } else {
1739 B2WARNING("Pi0ProbTightEnergyThresholdMC15rd is not registered in extraInfo! \n"
1740 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1741 return Const::doubleNaN;
1742 }
1743 } else if (mode == "standardMC16rd")
1744 {
1745 if (particle->hasExtraInfo("Pi0ProbOriginMC16rd")) {
1746 return particle->getExtraInfo("Pi0ProbOriginMC16rd");
1747 } else {
1748 B2WARNING("Pi0ProbOriginMC16rd is not registered in extraInfo! \n"
1749 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1750 return Const::doubleNaN;
1751 }
1752 } else if (mode == "tightMC16rd")
1753 {
1754 if (particle->hasExtraInfo("Pi0ProbTightEnergyThresholdMC16rd")) {
1755 return particle->getExtraInfo("Pi0ProbTightEnergyThresholdMC16rd");
1756 } else {
1757 B2WARNING("Pi0ProbTightEnergyThresholdMC16rd is not registered in extraInfo! \n"
1758 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1759 return Const::doubleNaN;
1760 }
1761 } else
1762 {
1763 return Const::doubleNaN;
1764 }
1765 };
1766 return func;
1767 }
1768
1769 Manager::FunctionPtr etaProb(const std::vector<std::string>& arguments)
1770 {
1771 if (arguments.size() != 1)
1772 B2ERROR("Wrong number of arguments (1 required) for etaProb");
1773
1774 std::string mode;
1775 mode = arguments[0];
1776
1777 if (mode != "standard" and mode != "tight" and mode != "cluster" and mode != "both" and mode != "standardMC15rd"
1778 and mode != "tightMC15rd" and mode != "standardMC16rd" and mode != "tightMC16rd")
1779 B2ERROR("the given argument is not supported in etaProb!");
1780
1781 auto func = [mode](const Particle * particle) -> double {
1782 if (mode == "standard")
1783 {
1784 if (particle->hasExtraInfo("EtaProbOrigin")) {
1785 return particle->getExtraInfo("EtaProbOrigin");
1786 } else {
1787 B2WARNING("EtaProbOrigin is not registered in extraInfo! \n"
1788 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1789 return Const::doubleNaN;
1790 }
1791 } else if (mode == "tight")
1792 {
1793 if (particle->hasExtraInfo("EtaProbTightEnergyThreshold")) {
1794 return particle->getExtraInfo("EtaProbTightEnergyThreshold");
1795 } else {
1796 B2WARNING("EtaProbTightEnergyThreshold is not registered in extraInfo! \n"
1797 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1798 return Const::doubleNaN;
1799 }
1800 } else if (mode == "cluster")
1801 {
1802 if (particle->hasExtraInfo("EtaProbLargeClusterSize")) {
1803 return particle->getExtraInfo("EtaProbLargeClusterSize");
1804 } else {
1805 B2WARNING("EtaProbLargeClusterSize is not registered in extraInfo! \n"
1806 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1807 return Const::doubleNaN;
1808 }
1809 } else if (mode == "both")
1810 {
1811 if (particle->hasExtraInfo("EtaProbTightEnergyThresholdAndLargeClusterSize")) {
1812 return particle->getExtraInfo("EtaProbTightEnergyThresholdAndLargeClusterSize");
1813 } else {
1814 B2WARNING("EtaProbTightEnergyThresholdAndLargeClusterSize is not registered in extraInfo! \n"
1815 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1816 return Const::doubleNaN;
1817 }
1818 } else if (mode == "standardMC15rd")
1819 {
1820 if (particle->hasExtraInfo("EtaProbOriginMC15rd")) {
1821 return particle->getExtraInfo("EtaProbOriginMC15rd");
1822 } else {
1823 B2WARNING("EtaProbOriginMC15rd is not registered in extraInfo! \n"
1824 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1825 return Const::doubleNaN;
1826 }
1827 } else if (mode == "tightMC15rd")
1828 {
1829 if (particle->hasExtraInfo("EtaProbTightEnergyThresholdMC15rd")) {
1830 return particle->getExtraInfo("EtaProbTightEnergyThresholdMC15rd");
1831 } else {
1832 B2WARNING("EtaProbTightEnergyThresholdMC15rd is not registered in extraInfo! \n"
1833 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1834 return Const::doubleNaN;
1835 }
1836 } else if (mode == "standardMC16rd")
1837 {
1838 if (particle->hasExtraInfo("EtaProbOriginMC16rd")) {
1839 return particle->getExtraInfo("EtaProbOriginMC16rd");
1840 } else {
1841 B2WARNING("EtaProbOriginMC16rd is not registered in extraInfo! \n"
1842 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1843 return Const::doubleNaN;
1844 }
1845 } else if (mode == "tightMC16rd")
1846 {
1847 if (particle->hasExtraInfo("EtaProbTightEnergyThresholdMC16rd")) {
1848 return particle->getExtraInfo("EtaProbTightEnergyThresholdMC16rd");
1849 } else {
1850 B2WARNING("EtaProbTightEnergyThresholdMC16rd is not registered in extraInfo! \n"
1851 "the function writePi0EtaVeto has to be executed to register this extraInfo.");
1852 return Const::doubleNaN;
1853 }
1854 } else
1855 {
1856 return Const::doubleNaN;
1857 }
1858 };
1859 return func;
1860 }
1861
1862 // ------------------------------------------------------------------------------
1863 // Below are some functions for ease of usage, they are not a part of variables
1864 // ------------------------------------------------------------------------------
1865
1866 ROOT::Math::PxPyPzEVector transformVector(const ROOT::Math::PxPyPzEVector& vec, bool enforceCMSFrame)
1867 {
1868 if (enforceCMSFrame) {
1869 UseReferenceFrame<CMSFrame> cmsFrame;
1870 const auto& frame = ReferenceFrame::GetCurrent();
1871 return frame.getMomentum(vec);
1872 } else {
1873 const auto& frame = ReferenceFrame::GetCurrent();
1874 return frame.getMomentum(vec);
1875 }
1876 }
1877
1878 ROOT::Math::PxPyPzEVector missing4Vector(const Particle* particle, const std::string& maskName, const std::string& opt)
1879 {
1880 // Get related ROE object
1881 const RestOfEvent* roe = getRelatedROEObject(particle);
1882
1883 if (!roe) {
1884 B2ERROR("Relation between particle and ROE doesn't exist!");
1885 ROOT::Math::PxPyPzEVector empty;
1886 return empty;
1887 }
1888
1889 bool enforceCMSFrame = (opt == "4" or opt == "7");
1890 PCmsLabTransform T;
1891 ROOT::Math::PxPyPzEVector boostvec = transformVector(T.getBeamFourMomentum(), enforceCMSFrame);
1892 ROOT::Math::PxPyPzEVector rec4vec = transformVector(particle->get4Vector(), enforceCMSFrame);
1893 ROOT::Math::PxPyPzEVector roe4vec = transformVector(roe->get4Vector(maskName), enforceCMSFrame);
1894
1895 ROOT::Math::PxPyPzEVector miss4vec;
1896 double E_beam_cms = T.getCMSEnergy() / 2.0;
1897
1898 // Definition 0: use energy and momentum of tracks and clusters
1899 if (opt == "0" or opt == "5") {
1900 miss4vec = boostvec - (rec4vec + roe4vec);
1901 }
1902
1903 // Definition 1: same as 0, fix Emiss = pmiss
1904 else if (opt == "1" or opt == "6") {
1905 miss4vec = boostvec - (rec4vec + roe4vec);
1906 miss4vec.SetE(miss4vec.P());
1907 }
1908
1909 // Definition 2: same as 0, fix Eroe = Ecms/2
1910 else if (opt == "2") {
1911 miss4vec = boostvec - (rec4vec + roe4vec);
1912 miss4vec.SetE(boostvec.E() / 2. - rec4vec.E());
1913 }
1914
1915 // Definition 3: use only energy and momentum of signal side
1916 else if (opt == "3") {
1917 miss4vec = boostvec - rec4vec;
1918 miss4vec.SetE(boostvec.E() / 2. - rec4vec.E());
1919 }
1920
1921 // Definition 4: same as 3, update with direction of ROE momentum
1922 else if (opt == "4") {
1923 ROOT::Math::XYZVector pB = - roe4vec.Vect();
1924 pB = 0.340 * pB.Unit();
1925 pB -= rec4vec.Vect();
1926 miss4vec.SetPxPyPzE(pB.X(), pB.Y(), pB.Z(), E_beam_cms - rec4vec.E());
1927 }
1928
1929 // Definition 7: correct pmiss 3-momentum vector with factor alpha so that dE = 0 (used for Mbc calculation)
1930 else if (opt == "7") {
1931 miss4vec = - (rec4vec + roe4vec);
1932 miss4vec.SetE(miss4vec.P());
1933 double factorAlpha = (E_beam_cms - rec4vec.E()) / miss4vec.E();
1934 miss4vec *= factorAlpha;
1935 miss4vec.SetE(miss4vec.P());
1936 }
1937
1938 return miss4vec;
1939 }
1940
1941 void checkMCParticleMissingFlags(const MCParticle* mcp, std::set<const MCParticle*> mcROEObjects, int& missingFlags)
1942 {
1943 std::vector<MCParticle*> daughters = mcp->getDaughters();
1944 for (auto& daughter : daughters) {
1945
1946 if (!daughter->hasStatus(MCParticle::c_PrimaryParticle))
1947 continue;
1948
1949 if (mcROEObjects.find(daughter) == mcROEObjects.end()) {
1950
1951 int pdg = abs(daughter->getPDG());
1952
1953 // photon
1954 if (pdg == Const::photon.getPDGCode() and (missingFlags & 1) == 0)
1955 missingFlags += 1;
1956
1957 // electrons
1958 else if (pdg == Const::electron.getPDGCode() and (missingFlags & 2) == 0)
1959 missingFlags += 2;
1960
1961 // muons
1962 else if (pdg == Const::muon.getPDGCode() and (missingFlags & 4) == 0)
1963 missingFlags += 4;
1964
1965 // pions
1966 else if (pdg == Const::pion.getPDGCode() and (missingFlags & 8) == 0)
1967 missingFlags += 8;
1968
1969 // kaons
1970 else if (pdg == Const::kaon.getPDGCode() and (missingFlags & 16) == 0)
1971 missingFlags += 16;
1972
1973 // protons
1974 else if (pdg == Const::proton.getPDGCode() and (missingFlags & 32) == 0)
1975 missingFlags += 32;
1976
1977 // neutrons
1978 else if (pdg == Const::neutron.getPDGCode() and (missingFlags & 64) == 0)
1979 missingFlags += 64;
1980
1981 // kshort
1982 else if (pdg == Const::Kshort.getPDGCode() and ((missingFlags & 128) == 0 or (missingFlags & 256) == 0)) {
1983 std::vector<MCParticle*> ksDaug = daughter->getDaughters();
1984 if (ksDaug.size() == 2) {
1985 // K_S0 -> pi+ pi-
1986 if (abs(ksDaug[0]->getPDG()) == Const::pion.getPDGCode() and abs(ksDaug[1]->getPDG()) == Const::pion.getPDGCode()
1987 and (missingFlags & 128) == 0) {
1988 if (mcROEObjects.find(ksDaug[0]) == mcROEObjects.end() or mcROEObjects.find(ksDaug[1]) == mcROEObjects.end())
1989 missingFlags += 128;
1990 }
1991 // K_S0 -> pi0 pi0
1992 else if (abs(ksDaug[0]->getPDG()) == Const::pi0.getPDGCode() and abs(ksDaug[1]->getPDG()) == Const::pi0.getPDGCode()
1993 and (missingFlags & 256) == 0) {
1994 std::vector<MCParticle*> pi0Daug0 = ksDaug[0]->getDaughters();
1995 std::vector<MCParticle*> pi0Daug1 = ksDaug[1]->getDaughters();
1996 if (mcROEObjects.find(pi0Daug0[0]) == mcROEObjects.end() or
1997 mcROEObjects.find(pi0Daug0[1]) == mcROEObjects.end() or
1998 mcROEObjects.find(pi0Daug1[0]) == mcROEObjects.end() or
1999 mcROEObjects.find(pi0Daug1[1]) == mcROEObjects.end())
2000 missingFlags += 256;
2001 }
2002 }
2003 }
2004
2005 // klong
2006 else if (pdg == Const::Klong.getPDGCode() and (missingFlags & 512) == 0)
2007 missingFlags += 512;
2008
2009 // neutrinos, which are not in the Const::
2010 else if ((pdg == 12 or pdg == 14 or pdg == 16) and (missingFlags & 1024) == 0)
2011 missingFlags += 1024;
2012 }
2013 checkMCParticleMissingFlags(daughter, mcROEObjects, missingFlags);
2014 }
2015 }
2016
2017 bool isInThisRestOfEvent(const Particle* particle, const RestOfEvent* roe, const std::string& maskName)
2018 {
2019 if (particle->getParticleSource() == Particle::c_Composite or
2020 particle->getParticleSource() == Particle::c_V0) {
2021 std::vector<const Particle*> fspDaug = particle->getFinalStateDaughters();
2022 for (auto& i : fspDaug) {
2023 if (isInThisRestOfEvent(i, roe, maskName) == 0)
2024 return 0;
2025 }
2026 return 1;
2027 }
2028 return roe->hasParticle(particle, maskName);
2029 }
2030
2031 const RestOfEvent* getRelatedROEObject(const Particle* particle, bool returnHostOnly)
2032 {
2033 // Get related ROE object
2034 const RestOfEvent* roe = particle->getRelatedTo<RestOfEvent>();
2035 if (!roe && !returnHostOnly) {
2036 roe = particle->getRelatedTo<RestOfEvent>("NestedRestOfEvents");
2037
2038 }
2039 return roe;
2040 }
2041
2042 VARIABLE_GROUP("Rest Of Event");
2043
2044 REGISTER_METAVARIABLE("useROERecoilFrame(variable)", useROERecoilFrame,
2045 "Returns the value of the variable using the rest frame of the ROE recoil as current reference frame.\n"
2046 "Can be used inside for_each loop or outside of it if the particle has associated Rest of Event.\n"
2047 "E.g. ``useROERecoilFrame(E)`` returns the energy of a particle in the ROE recoil frame.", Manager::VariableDataType::c_double);
2048
2049 REGISTER_VARIABLE("isInRestOfEvent", isInRestOfEvent,
2050 "Returns 1 if a track, ecl or klmCluster associated to particle is in the current RestOfEvent object, 0 otherwise."
2051 "One can use this variable only in a for_each loop over the RestOfEvent StoreArray.");
2052
2053 REGISTER_VARIABLE("isCloneOfSignalSide", isCloneOfSignalSide,
2054 "Returns 1 if a particle is a clone of signal side final state particles, 0 otherwise. "
2055 "Requires generator information and truth-matching. "
2056 "One can use this variable only in a ``for_each`` loop over the RestOfEvent StoreArray.");
2057
2058 REGISTER_VARIABLE("hasAncestorFromSignalSide", hasAncestorFromSignalSide,
2059 "Returns 1 if a particle has ancestor from signal side, 0 otherwise. "
2060 "Requires generator information and truth-matching. "
2061 "One can use this variable only in a ``for_each`` loop over the RestOfEvent StoreArray.");
2062
2063 REGISTER_METAVARIABLE("currentROEIsInList(particleList)", currentROEIsInList,
2064 "[Eventbased] Returns 1 the associated particle of the current ROE is contained in the given list or its charge-conjugated."
2065 "Useful to restrict the for_each loop over ROEs to ROEs of a certain ParticleList.", Manager::VariableDataType::c_bool);
2066
2067 REGISTER_VARIABLE("nROE_RemainingTracks", nROE_RemainingTracks,
2068 "Returns number of tracks in ROE - number of tracks of given particle"
2069 "One can use this variable only in a for_each loop over the RestOfEvent StoreArray.");
2070
2071 REGISTER_METAVARIABLE("nROE_RemainingTracks([maskName])", nROE_RemainingTracksWithMask,
2072 "Returns number of remaining tracks between the ROE (specified via a mask) and the given particle. For the given particle only tracks are counted which are in the RoE."
2073 "One can use this variable only in a for_each loop over the RestOfEvent StoreArray."
2074 "Is required for the specific FEI. The default mask name is ``all``. :noindex:", Manager::VariableDataType::c_int);
2075 // nROE_RemainingTracks is overloaded (two C++ functions sharing one
2076 // variable name) so one of the two needs to be made the indexed
2077 // variable in sphinx
2078
2079 REGISTER_VARIABLE("nROE_KLMClusters", nROE_KLMClusters,
2080 "Returns number of all remaining KLM clusters in the related RestOfEvent object. "
2081 "This variable takes no ROE mask and always uses the default mask; use ``nROE_NeutralHadrons([maskName])``, "
2082 "which counts the same candidates, if you need a specific mask.");
2083
2084 REGISTER_METAVARIABLE("nROE_Charged([maskName, PDGcode])", nROE_ChargedParticles,
2085 "Returns number of all charged particles in the related RestOfEvent object. First optional argument is ROE mask name. "
2086 "Second argument is a PDG code to count only one charged particle species, independently of charge. "
2087 "For example: ``nROE_Charged(cleanMask, 321)`` will output number of kaons in Rest Of Event with ``cleanMask``. "
2088 "The default mask name is ``all`` and the default PDG code is 0, which counts all charged particles",
2089 Manager::VariableDataType::c_int);
2090
2091 REGISTER_METAVARIABLE("nROE_Photons([maskName])", nROE_Photons,
2092 "Returns number of all photons in the related RestOfEvent object, accepts 1 optional argument of ROE mask name. "
2093 "Only ECL-cluster-based ROE particles with the photon (N1) hypothesis are counted, which makes this a subset of "
2094 "``nROE_NeutralECLClusters``: ``nROE_Photons`` <= ``nROE_NeutralECLClusters`` <= ``nROE_ECLClusters``. "
2095 "The default mask name is ``all``.",
2096 Manager::VariableDataType::c_int);
2097
2098 REGISTER_METAVARIABLE("nROE_NeutralHadrons([maskName])", nROE_NeutralHadrons,
2099 "Returns number of all neutral hadrons in the related RestOfEvent object, accepts 1 optional argument of ROE mask name. "
2100 "Note that only KLM-cluster-based candidates are counted, so this is the mask-aware equivalent of ``nROE_KLMClusters``; "
2101 "neutral hadron candidates built from ECL clusters are counted by ``nROE_NeutralECLClusters`` instead. "
2102 "The default mask name is ``all``.",
2103 Manager::VariableDataType::c_int);
2104
2105 REGISTER_METAVARIABLE("particleRelatedToCurrentROE(var)", particleRelatedToCurrentROE,
2106 "[Eventbased] Returns variable applied to the particle which is related to the current RestOfEvent object"
2107 "One can use this variable only in a for_each loop over the RestOfEvent StoreArray.", Manager::VariableDataType::c_double);
2108
2109 REGISTER_VARIABLE("roeMC_E", ROE_MC_E,
2110 "Returns true energy of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function.\n\n", "GeV");
2111
2112 REGISTER_VARIABLE("roeMC_M", ROE_MC_M,
2113 "Returns true invariant mass of unused tracks and clusters in ROE\n\n", "GeV/:math:`\\text{c}^2`");
2114
2115 REGISTER_VARIABLE("roeMC_P", ROE_MC_P,
2116 "Returns true momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function.\n\n", "GeV/c");
2117
2118 REGISTER_VARIABLE("roeMC_Px", ROE_MC_Px,
2119 "Returns x component of true momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function.\n\n",
2120 "GeV/c");
2121
2122 REGISTER_VARIABLE("roeMC_Py", ROE_MC_Py,
2123 "Returns y component of true momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function.\n\n",
2124 "GeV/c");
2125
2126 REGISTER_VARIABLE("roeMC_Pz", ROE_MC_Pz,
2127 "Returns z component of true momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function.\n\n",
2128 "GeV/c");
2129
2130 REGISTER_VARIABLE("roeMC_Pt", ROE_MC_Pt,
2131 "Returns transverse component of true momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function.\n\n",
2132 "GeV/c");
2133
2134 REGISTER_VARIABLE("roeMC_PTheta", ROE_MC_PTheta,
2135 "Returns polar angle of true momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function.\n\n",
2136 "rad");
2137
2138 REGISTER_METAVARIABLE("roeMC_MissFlags([maskName])", ROE_MC_MissingFlags,
2139 "Returns flags corresponding to missing particles on ROE side. The default mask name is ``all``.",
2140 Manager::VariableDataType::c_double);
2141
2142 REGISTER_METAVARIABLE("nROE_Tracks([maskName])", nROE_Tracks,
2143 "Returns number of tracks in the related RestOfEvent object that pass the selection criteria. The default mask name is ``all``.",
2144 Manager::VariableDataType::c_int);
2145
2146 REGISTER_METAVARIABLE("nROE_ECLClusters([maskName])", nROE_ECLClusters,
2147 "Returns number of ECL clusters in the related RestOfEvent object that pass the selection criteria. "
2148 "This counts the neutral (unmatched) clusters plus the clusters matched to charged ROE particles, so it is the "
2149 "widest of the three ECL counters: ``nROE_Photons`` <= ``nROE_NeutralECLClusters`` <= ``nROE_ECLClusters``. "
2150 "The default mask name is ``all``.",
2151 Manager::VariableDataType::c_int);
2152
2153 REGISTER_METAVARIABLE("nROE_NeutralECLClusters([maskName])", nROE_NeutralECLClusters,
2154 "Returns number of neutral ECL clusters in the related RestOfEvent object that pass the selection criteria. "
2155 "This counts every ECL-cluster-based ROE particle regardless of hypothesis, and is therefore the ECL counterpart of "
2156 "``nROE_NeutralHadrons``. It differs from ``nROE_Photons``, which counts only the subset with the photon (N1) "
2157 "hypothesis, and from ``nROE_ECLClusters``, which additionally counts clusters matched to charged ROE particles. "
2158 "The default mask name is ``all``.",
2159 Manager::VariableDataType::c_int);
2160
2161 REGISTER_METAVARIABLE("nROE_Composites([maskName])", nROE_Composites,
2162 "Returns number of composite particles or V0s in the related RestOfEvent object that pass the selection criteria. The default mask name is ``all``.",
2163 Manager::VariableDataType::c_int);
2164
2165 REGISTER_METAVARIABLE("nROE_ParticlesInList(pListName[, maskName])", nROE_ParticlesInList,
2166 "Returns the number of particles in ROE from the given particle list. If a mask name is provided the selection criteria are applied.\n"
2167 "The default mask name is ``all``.\n"
2168 "Use of variable aliases is advised.", Manager::VariableDataType::c_int);
2169
2170 REGISTER_METAVARIABLE("roeCharge([maskName])", ROE_Charge,
2171 "Returns total charge of the related RestOfEvent object. The unit of the charge is ``e``. The default mask name is ``all``.",
2172 Manager::VariableDataType::c_double);
2173
2174 REGISTER_METAVARIABLE("roeEextra([maskName])", ROE_ExtraEnergy,
2175 "Returns extra energy from ECLClusters in the calorimeter that is not associated to the given Particle. The unit of the energy is ``GeV``. The default mask name is ``all``.",
2176 Manager::VariableDataType::c_double);
2177
2178 REGISTER_METAVARIABLE("roeNeextra([maskName])", ROE_NeutralExtraEnergy,
2179 "Returns extra energy from neutral ECLClusters in the calorimeter that is not associated to the given Particle, can be used with ``use***Frame()`` function. The unit of the energy is ``GeV``. The default mask name is ``all``.",
2180 Manager::VariableDataType::c_double);
2181
2182 REGISTER_METAVARIABLE("roeE([maskName])", ROE_E,
2183 "Returns energy of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function. The unit of the energy is ``GeV``. The default mask name is ``all``.",
2184 Manager::VariableDataType::c_double);
2185
2186 REGISTER_METAVARIABLE("roeM([maskName])", ROE_M,
2187 "Returns invariant mass of unused tracks and clusters in ROE. The unit of the invariant mass is :math:`\\text{GeV/c}^2`. The default mask name is ``all``.",
2188 Manager::VariableDataType::c_double);
2189
2190 REGISTER_METAVARIABLE("roeP([maskName])", ROE_P,
2191 "Returns momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function. The unit of the momentum is ``GeV/c``. The default mask name is ``all``.",
2192 Manager::VariableDataType::c_double);
2193
2194 REGISTER_METAVARIABLE("roePt([maskName])", ROE_Pt,
2195 "Returns transverse component of momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function. The unit of the momentum is ``GeV/c``. The default mask name is ``all``.",
2196 Manager::VariableDataType::c_double);
2197
2198 REGISTER_METAVARIABLE("roePx([maskName])", ROE_Px,
2199 "Returns x component of momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function. The unit of the momentum is ``GeV/c``. The default mask name is ``all``.",
2200 Manager::VariableDataType::c_double);
2201
2202 REGISTER_METAVARIABLE("roePy([maskName])", ROE_Py,
2203 "Returns y component of momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function. The unit of the momentum is ``GeV/c``. The default mask name is ``all``.",
2204 Manager::VariableDataType::c_double);
2205
2206 REGISTER_METAVARIABLE("roePz([maskName])", ROE_Pz,
2207 "Returns z component of momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function. The unit of the momentum is ``GeV/c``. The default mask name is ``all``.",
2208 Manager::VariableDataType::c_double);
2209
2210 REGISTER_METAVARIABLE("roePTheta([maskName])", ROE_PTheta,
2211 "Returns theta angle of momentum of unused tracks and clusters in ROE, can be used with ``use***Frame()`` function. The unit of the angle is ``rad``. The default mask name is ``all``.",
2212 Manager::VariableDataType::c_double);
2213
2214 REGISTER_METAVARIABLE("roeDeltae([maskName])", ROE_DeltaE,
2215 "Returns energy difference of the related RestOfEvent object with respect to :math:`E_\\mathrm{cms}/2`. The unit of the energy is ``GeV``. The default mask name is ``all``.",
2216 Manager::VariableDataType::c_double);
2217
2218 REGISTER_METAVARIABLE("roeMbc([maskName])", ROE_Mbc,
2219 "Returns beam constrained mass of the related RestOfEvent object with respect to :math:`E_\\mathrm{cms}/2`. The unit of the beam constrained mass is :math:`\\text{GeV/c}^2`. The default mask name is ``all``.",
2220 Manager::VariableDataType::c_double);
2221
2222 REGISTER_METAVARIABLE("weDeltae([maskName])", WE_DeltaE, R"DOC(
2223 Returns the energy difference of the B meson, corrected with the missing neutrino momentum (reconstructed side + neutrino) with respect to :math:`E_{\mathrm{cms}}/2`.
2224 The variable can be used with the ``use***Frame()`` function. The unit of the energy is ``GeV``. The default mask name is ``all``.)DOC",
2225 Manager::VariableDataType::c_double);
2226
2227 REGISTER_METAVARIABLE("weMbc([maskName])", WE_Mbc, R"DOC(
2228 Returns beam constrained mass of B meson, corrected with the missing neutrino momentum (reconstructed side + neutrino) with respect to :math:`E_{\mathrm{cms}}/2`.
2229 The variable can be used with the ``use***Frame()`` function. The unit of the beam constrained mass is :math:`\text{GeV/c}^2`. The default mask name is ``all``.)DOC",
2230 Manager::VariableDataType::c_double);
2231
2232 REGISTER_METAVARIABLE("weMbcWithdEZero([maskName])", WE_MbcWithdEZero, R"DOC(
2233 Returns beam constrained mass of B meson, corrected with the missing neutrino momentum (reconstructed side + neutrino) with respect to :math:`E_{\mathrm{cms}}/2`.
2234 The missing neutrino momentum is scaled so that the energy difference :math:`d_E = 0`. The unit of the beam constrained mass is :math:`\text{GeV/c}^2`. The default mask name is ``all``.)DOC",
2235 Manager::VariableDataType::c_double);
2236
2237 REGISTER_METAVARIABLE("weMissM2(maskName, opt)", WE_MissM2, R"DOC(
2238 Returns the invariant mass squared of the missing momentum (see :b2:var:`weMissE` possible options).
2239 The variable can be used with the ``use***Frame()`` function.
2240 The unit of the invariant mass squared is :math:`[\text{GeV}/\text{c}^2]^2`. Providing only ``opt`` (relying on the default mask name ``all``) is deprecated; always provide both arguments.)DOC",
2241 Manager::VariableDataType::c_double);
2242
2243 REGISTER_METAVARIABLE("weMissPTheta(maskName, opt)", WE_MissPTheta, R"DOC(
2244 Returns the polar angle of the missing momentum (see possible :b2:var:`weMissE` options).
2245 The variable can be used with the ``use***Frame()`` function.
2246 The unit of the polar angle is ``rad``. Providing only ``opt`` (relying on the default mask name ``all``) is deprecated; always provide both arguments.)DOC",
2247 Manager::VariableDataType::c_double);
2248
2249 REGISTER_METAVARIABLE("weMissP(maskName, opt)", WE_MissP, R"DOC(
2250 Returns the magnitude of the missing momentum (see possible :b2:var:`weMissE` options).
2251 The variable can be used with the ``use***Frame()`` function.
2252 The unit of the magnitude of missing momentum is ``GeV/c``. Providing only ``opt`` (relying on the default mask name ``all``) is deprecated; always provide both arguments.)DOC",
2253 Manager::VariableDataType::c_double);
2254
2255 REGISTER_METAVARIABLE("weMissPx(maskName, opt)", WE_MissPx, R"DOC(
2256 Returns the x component of the missing momentum (see :b2:var:`weMissE` possible options).
2257 The variable can be used with the ``use***Frame()`` function.
2258 The unit of the missing momentum is ``GeV/c``. Providing only ``opt`` (relying on the default mask name ``all``) is deprecated; always provide both arguments.)DOC",
2259 Manager::VariableDataType::c_double);
2260
2261 REGISTER_METAVARIABLE("weMissPy(maskName, opt)", WE_MissPy, R"DOC(
2262 Returns the y component of the missing momentum (see :b2:var:`weMissE` possible options).
2263 The variable can be used with the ``use***Frame()`` function.
2264 The unit of the missing momentum is ``GeV/c``. Providing only ``opt`` (relying on the default mask name ``all``) is deprecated; always provide both arguments.)DOC",
2265 Manager::VariableDataType::c_double);
2266
2267 REGISTER_METAVARIABLE("weMissPz(maskName, opt)", WE_MissPz, R"DOC(
2268 Returns the z component of the missing momentum (see :b2:var:`weMissE` possible options).
2269 The variable can be used with the ``use***Frame()`` function.
2270 The unit of the missing momentum is ``GeV/c``. Providing only ``opt`` (relying on the default mask name ``all``) is deprecated; always provide both arguments.)DOC",
2271 Manager::VariableDataType::c_double);
2272
2273 REGISTER_METAVARIABLE("weMissE(maskName, opt)", WE_MissE,
2274 R"DOC(Returns the energy of the missing momentum. The variable can be used with the ``use***Frame()`` function. The unit of the Energy is ``GeV`` . Possible options ``opt`` are the following:
2275
2276- ``0``: use energy and momentum of charged particles and photons
2277- ``1``: same as ``0``, fix :math:`E_\mathrm{miss} = p_\mathrm{miss}`
2278- ``2``: same as ``0``, fix :math:`E_\mathrm{roe} = E_\mathrm{cms}/2`
2279- ``3``: use only energy and momentum of signal side
2280- ``4``: same as ``3``, update with direction of ROE momentum. Only works in CMS frame.
2281- ``7``: correct pmiss 3-momentum vector with factor alpha so that :math:`d_E = 0` (used for :math:`M_\mathrm{bc}` calculation). Only works in CMS frame. Providing only ``opt`` (relying on the default mask name ``all``) is deprecated; always provide both arguments.)DOC",
2282 Manager::VariableDataType::c_double);
2283
2284 REGISTER_METAVARIABLE("weXiZ([maskName])", WE_xiZ,
2285 "Returns Xi_z in event (for Bhabha suppression and two-photon scattering). The unit of this variable is ``1/c``. The default mask name is ``all``.",
2286 Manager::VariableDataType::c_double);
2287
2288 REGISTER_METAVARIABLE("bssMassDifference([maskName])", bssMassDifference,
2289 "Bs* - Bs mass difference. The unit of the mass is :math:`\\text{GeV/c}^2`. The default mask name is ``all``.",
2290 Manager::VariableDataType::c_double);
2291
2292 REGISTER_METAVARIABLE("weCosThetaEll([maskName])", WE_cosThetaEll, R"DOC(
2293
2294Returns the cosine of the angle between :math:`M` and lepton in :math:`W` rest frame in the decays of the type:
2295:math:`M \to h_1 ... h_n \ell`, where W 4-momentum is given as
2296
2297.. math::
2298 p_W = p_\ell + p_\nu.
2299
2300The neutrino momentum is calculated from ROE taking into account the specified mask, and setting
2301
2302.. math::
2303 E_{\nu} = |p_{miss}|.
2304
2305The default mask name is ``all``.
2306
2307)DOC", Manager::VariableDataType::c_double);
2308
2309 REGISTER_METAVARIABLE("weQ2lnuSimple([maskName, option])", WE_q2lnuSimple,
2310 "Returns the momentum transfer squared, :math:`q^2`, calculated in CMS as :math:`q^2 = (p_l + p_\\nu)^2`, \n"
2311 "where :math:`B \\to H_1\\dots H_n \\ell \\nu_\\ell`. Lepton is assumed to be the last reconstructed daughter. \n"
2312 "By default, option is set to ``1`` (see :b2:var:`weMissE`). Unless you know what you are doing, keep this default value. The default mask name is ``all``. The unit of the momentum transfer squared is :math:`[\\text{GeV}/\\text{c}]^2`.", Manager::VariableDataType::c_double);
2313
2314 REGISTER_METAVARIABLE("weQ2lnu([maskName, option])", WE_q2lnu,
2315 "Returns the momentum transfer squared, :math:`q^2`, calculated in CMS as :math:`q^2 = (p_l + p_\\nu)^2`, \n"
2316 "where :math:`B \\to H_1\\dots H_n \\ell \\nu_\\ell`. Lepton is assumed to be the last reconstructed daughter. \n"
2317 "This calculation uses constraints from dE = 0 and Mbc = Mb to correct the neutrino direction. \n"
2318 "By default, option is set to ``7`` (see :b2:var:`weMissE`). Unless you know what you are doing, keep this default value. The default mask name is ``all``. The unit of the momentum transfer squared is :math:`[\\text{GeV}/\\text{c}]^2`.", Manager::VariableDataType::c_double);
2319
2320 REGISTER_METAVARIABLE("weMissM2OverMissE([maskName])", WE_MissM2OverMissE,
2321 "Returns missing mass squared over missing energy. The unit of the missing mass squared is :math:`\\text{GeV/c}^4`. The default mask name is ``all``.", Manager::VariableDataType::c_double);
2322
2323 REGISTER_METAVARIABLE("passesROEMask([maskName])", passesROEMask,
2324 "Returns boolean value if a particle passes a certain mask or not. Only to be used in for_each path. The default mask name is ``all``.", Manager::VariableDataType::c_bool);
2325
2326 REGISTER_VARIABLE("printROE", printROE,
2327 "For debugging, prints indices of all particles in the ROE and all masks. Returns 0.");
2328
2329 REGISTER_VARIABLE("hasCorrectROECombination", hasCorrectROECombination,
2330 "Returns 1 if there is correct combination of daughter particles between the particle that is the basis of the ROE and the particle loaded from the ROE. "
2331 "Returns 0 if there is not correct combination or if there is no daughter particle loaded from the ROE.");
2332
2333 REGISTER_METAVARIABLE("pi0Prob(mode)", pi0Prob,
2334 "Returns pi0 probability, where mode is used to specify the selection criteria for soft photon. \n"
2335 "The following strings are available. \n\n"
2336 "- ``standard``: loose energy cut and no clusterNHits cut are applied to soft photon \n"
2337 "- ``tight``: tight energy cut and no clusterNHits cut are applied to soft photon \n"
2338 "- ``cluster``: loose energy cut and clusterNHits cut are applied to soft photon \n"
2339 "- ``both``: tight energy cut and clusterNHits cut are applied to soft photon \n"
2340 "- ``standardMC15rd``: loose energy cut is applied to soft photon and the weight files are trained using MC15rd \n"
2341 "- ``tightMC15rd``: tight energy cut is applied to soft photon and the weight files are trained using MC15rd \n"
2342 "- ``standardMC16rd``: loose energy cut is applied to soft photon and the weight files are trained using MC16rd \n"
2343 "- ``tightMC16rd``: tight energy cut is applied to soft photon and the weight files are trained using MC16rd \n\n"
2344 "You can find more details in `writePi0EtaVeto` function in modularAnalysis.py.", Manager::VariableDataType::c_double);
2345
2346 REGISTER_METAVARIABLE("etaProb(mode)", etaProb,
2347 "Returns eta probability, where mode is used to specify the selection criteria for soft photon. \n"
2348 "The following strings are available. \n\n"
2349 "- ``standard``: loose energy cut and no clusterNHits cut are applied to soft photon \n"
2350 "- ``tight``: tight energy cut and no clusterNHits cut are applied to soft photon \n"
2351 "- ``cluster``: loose energy cut and clusterNHits cut are applied to soft photon \n"
2352 "- ``both``: tight energy cut and clusterNHits cut are applied to soft photon \n"
2353 "- ``standardMC15rd``: loose energy cut is applied to soft photon and the weight files are trained using MC15rd \n"
2354 "- ``tightMC15rd``: tight energy cut is applied to soft photon and the weight files are trained using MC15rd \n"
2355 "- ``standardMC16rd``: loose energy cut is applied to soft photon and the weight files are trained using MC16rd \n"
2356 "- ``tightMC16rd``: tight energy cut is applied to soft photon and the weight files are trained using MC16rd \n\n"
2357 "You can find more details in `writePi0EtaVeto` function in modularAnalysis.py.", Manager::VariableDataType::c_double);
2358
2359 }
2361}
static const ParticleType neutron
neutron particle
Definition Const.h:676
static const ParticleType pi0
neutral pion particle
Definition Const.h:675
static const ChargedStable muon
muon particle
Definition Const.h:661
static const ChargedStable pion
charged pion particle
Definition Const.h:662
static const ParticleType Klong
K^0_L particle.
Definition Const.h:679
static const ChargedStable proton
proton particle
Definition Const.h:664
static const ParticleType Kshort
K^0_S particle.
Definition Const.h:678
static const double doubleNaN
quiet_NaN
Definition Const.h:704
static const ChargedStable kaon
charged kaon particle
Definition Const.h:663
static const ParticleType photon
photon particle
Definition Const.h:674
static const ChargedStable electron
electron particle
Definition Const.h:660
@ c_nPhotons
CR is split into n photons (N1)
Definition ECLCluster.h:41
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition MCParticle.h:47
static const ReferenceFrame & GetCurrent()
Get current rest frame.
static constexpr const char * c_defaultMaskName
Default mask name.
Definition RestOfEvent.h:58
std::function< VarVariant(const Particle *)> FunctionPtr
functions stored take a const Particle* and return VarVariant.
Definition Manager.h:112
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
Definition Manager.cc:58
static Manager & Instance()
get singleton instance.
Definition Manager.cc:26
T convertString(const std::string &str)
Converts a string to type T (one of float, double, long double, int, long int, unsigned long int).
Abstract base class for different kinds of events.
STL namespace.