ComPWA
Common Partial-Wave-Analysis Framework
DalitzKinematics.cpp
Go to the documentation of this file.
1 // Copyright (c) 2013, 2017 The ComPWA Team.
2 // This file is part of the ComPWA framework, check
3 // https://github.com/ComPWA/ComPWA/license.txt for details.
4 
6 
7 #include "Core/Event.hpp"
8 #include "Core/Logging.hpp"
9 #include "Core/FourMomentum.hpp"
10 #include "Data/DataSet.hpp"
11 
12 #include "ThirdParty/qft++/include/qft++/Vector4.h"
13 
14 #include <algorithm>
15 #include <cmath>
16 #include <numeric>
17 #include <sstream>
18 
19 namespace ComPWA {
20 namespace Physics {
21 namespace EvtGen {
22 
24  std::vector<pid> initialState,
25  std::vector<pid> finalState,
28  initialState, finalState, partL, cmsP4, [&finalState]() {
29  std::vector<unsigned int> FinalStateEventPositionMapping;
30  for (unsigned int i = 0; i < finalState.size(); ++i) {
31  FinalStateEventPositionMapping.push_back(i);
32  }
33  return FinalStateEventPositionMapping;
34  }())) {}
35 
38  : DalitzKinematics(KinInfo, 1.0) {
41 }
42 
44  ParticleStateTransitionKinematicsInfo kininfo, double PhspVol)
45  : KinematicsInfo(kininfo), PhspVolume(PhspVol),
46  M2(kininfo.getInitialStateInvariantMassSquared()) {
47  LOG(INFO) << "DalitzKinematics::"
48  "DalitzKinematics() | Initialized kinematics "
49  "for reaction "
50  << KinematicsInfo;
51 }
52 
53 double DalitzKinematics::phspVolume() const { return PhspVolume; }
54 
57  EventCollection PhspSample{Events.Pids};
58 
59  auto Dataset = convert(Events);
60  auto mA = Dataset.Data["mA"];
61  auto mB = Dataset.Data["mB"];
62  auto mC = Dataset.Data["mC"];
63  auto qAB = Dataset.Data["qAB"];
64  auto qBC = Dataset.Data["qBC"];
65  auto qCA = Dataset.Data["qCA"];
66 
67  for (size_t i = 0; i < Events.Events.size(); ++i) {
68  double s2 = (qAB[i] + qBC[i] + qCA[i] - mA[i] * mA[i] - mB[i] * mB[i] -
69  mC[i] * mC[i]);
70 
71  if (s2 < M2)
72  PhspSample.Events.push_back(Events.Events[i]);
73  }
74  return PhspSample;
75 } // namespace EvtGen
76 
79 
80  ComPWA::Data::DataSet Dataset;
81  if (KinematicsInfo.getFinalStatePIDs() != DataSample.Pids) {
82  std::stringstream Message;
83  Message << "Pids in EventCollection and in Kinematics do not match";
84  Message << std::endl << " ";
85  Message << DataSample.Pids.size() << " PIDs in EventCollection:";
86  for (auto Pid : DataSample.Pids)
87  Message << " " << Pid;
88  Message << std::endl << " ";
89  Message << KinematicsInfo.getFinalStatePIDs().size()
90  << " PIDs in Kinematics:";
91  for (auto Pid : KinematicsInfo.getFinalStatePIDs())
92  Message << " " << Pid;
93  throw ComPWA::BadParameter(Message.str());
94  }
95  if (!DataSample.checkPidMatchesEvents()) {
96  throw ComPWA::BadParameter("DalitzKinematics::convert() | number of PIDs "
97  "not equal to number of four-momenta");
98  }
99 
100  std::vector<double> mA, mB, mC, qAB, qBC, qCA, Weights;
101  for (auto const &Event : DataSample.Events) {
102  mA.push_back(Event.FourMomenta[0].invariantMass());
103  mB.push_back(Event.FourMomenta[1].invariantMass());
104  mC.push_back(Event.FourMomenta[2].invariantMass());
105  qAB.push_back(
106  (Event.FourMomenta[0] + Event.FourMomenta[1]).invariantMass());
107  qBC.push_back(
108  (Event.FourMomenta[1] + Event.FourMomenta[2]).invariantMass());
109  qCA.push_back(
110  (Event.FourMomenta[2] + Event.FourMomenta[0]).invariantMass());
111  Weights.push_back(Event.Weight);
112  }
113 
114  Dataset.Data.insert(std::make_pair("mA", mA));
115  Dataset.Data.insert(std::make_pair("mB", mB));
116  Dataset.Data.insert(std::make_pair("mC", mC));
117  Dataset.Data.insert(std::make_pair("qAB", qAB));
118  Dataset.Data.insert(std::make_pair("qBC", qBC));
119  Dataset.Data.insert(std::make_pair("qCA", qCA));
120  Dataset.Data.insert(std::make_pair("weights", Weights));
121 
122  return Dataset;
123 }
124 
125 } // namespace EvtGen
126 } // namespace Physics
127 } // namespace ComPWA
ComPWA four momentum class.
Parameter not existing.
Definition: Exceptions.hpp:62
Implementation of the ComPWA::Kinematics interface for amplitude models using the helicity formalism...
ComPWA::Data::DataSet convert(const EventCollection &DataSample) const final
ComPWA::DataMap Data
Definition: DataSet.hpp:18
Contains DalitzKinematics class.
std::vector< Event > Events
Definition: Event.hpp:34
std::set< ParticleProperties > ParticleList
Definition: Properties.hpp:84
DalitzKinematics(ParticleStateTransitionKinematicsInfo KinInfo, double PhspVol)
ParticleStateTransitionKinematicsInfo KinematicsInfo
double Weight
Definition: Event.hpp:22
EventCollection reduceToPhaseSpace(const EventCollection &DataSample) const final
Returns a subset of events that are within phase space boundaries.
std::vector< FourMomentum > FourMomenta
Definition: Event.hpp:21
Data structure containing all kinematic information of a physics event.
Definition: Event.hpp:20
std::vector< pid > Pids
Definition: Event.hpp:33
bool checkPidMatchesEvents() const
Definition: Event.hpp:26