ComPWA
Common Partial-Wave-Analysis Framework
ParticleStateTransitionKinematicsInfo.cpp
Go to the documentation of this file.
1 // Copyright (c) 2015, 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 namespace ComPWA {
8 namespace Physics {
9 
11  std::vector<pid> InitialState_, std::vector<pid> FinalState_,
12  ComPWA::ParticleList ParticleList_, ComPWA::FourMomentum InitialStateP4_,
13  std::vector<unsigned int> FinalStateEventPositionMapping_)
14  : InitialState(InitialState_), FinalState(FinalState_),
15  ParticleList(ParticleList_), InitialStateP4(InitialStateP4_),
16  FinalStateEventPositionMapping(FinalStateEventPositionMapping_) {
17  // If the cms four-momentum is not set of set it here
18  if (InitialStateP4 == FourMomentum(0, 0, 0, 0) && InitialState.size() == 1) {
19  double sqrtS =
20  findParticle(ParticleList, InitialState.at(0)).getMass().Value;
21  InitialStateP4 = ComPWA::FourMomentum(0, 0, 0, sqrtS);
22  } // Make sure cms momentum is set
23  else if (InitialStateP4 == FourMomentum(0, 0, 0, 0))
24  assert(false);
25 }
26 
28  std::vector<pid> InitialState_, std::vector<pid> FinalState_,
29  ComPWA::ParticleList ParticleList_,
30  std::vector<unsigned int> FinalStateEventPositionMapping_)
32  InitialState_, FinalState_, ParticleList_,
33  [&]() {
34  if (InitialState_.size() == 1) {
35  double sqrtS = findParticle(ParticleList_, InitialState_.at(0))
36  .getMass()
37  .Value;
38  return ComPWA::FourMomentum(0, 0, 0, sqrtS);
39  } // Make sure cms momentum is set
40  else {
41  throw std::runtime_error(
42  "ParticleStateTransitionKinematicsInfo(): constructing the "
43  "info without a initial state four momentum is only possible "
44  "with a single particle initial state!");
45  }
46  }(),
47  FinalStateEventPositionMapping_) {}
48 
49 unsigned int
51  unsigned int fs_id) const {
52  const auto &fsepMapping(FinalStateEventPositionMapping);
53  auto result = std::find(fsepMapping.begin(), fsepMapping.end(), fs_id);
54  return std::distance(fsepMapping.begin(), result);
55 }
56 
57 std::vector<unsigned int>
59  const std::vector<unsigned int> &fs_ids) const {
60  std::vector<unsigned int> pos_indices;
61  pos_indices.reserve(fs_ids.size());
62  for (auto fs_id : fs_ids) {
63  pos_indices.push_back(convertFinalStateIDToPositionIndex(fs_id));
64  }
65  return pos_indices;
66 }
67 
68 unsigned int
70  unsigned int pos) const {
72 }
73 
74 std::vector<unsigned int>
76  const std::vector<unsigned int> &pos) const {
77  std::vector<unsigned int> fsids;
78  for (auto x : pos)
79  fsids.push_back(convertPositionIndexToFinalStateID(x));
80  return fsids;
81 }
82 
84  const std::vector<unsigned int> ids) const {
85  double MassSum(0.0);
86  for (auto i : ids) {
87  unsigned int index = convertFinalStateIDToPositionIndex(i);
88  MassSum += findParticle(ParticleList, FinalState.at(index)).getMass().Value;
89  }
90  return MassSum;
91 }
92 
93 std::vector<double>
95  std::vector<double> FinalStateMasses;
96  for (auto ParticlePid : FinalState) { // particle 0 is mother particle
97  FinalStateMasses.push_back(
98  findParticle(ParticleList, ParticlePid).getMass().Value);
99  }
100  return FinalStateMasses;
101 }
102 
103 double
105  const {
107 }
108 
111  return InitialStateP4;
112 }
113 
114 unsigned int
116  return FinalState.size();
117 }
118 
119 std::map<unsigned int, std::string>
121  std::map<unsigned int, std::string> mapping;
122  for (unsigned int i = 0; i < FinalState.size(); ++i) {
123  mapping[FinalStateEventPositionMapping[i]] =
125  }
126  return mapping;
127 }
128 
129 std::ostream &operator<<(std::ostream &outstream,
130  const ParticleStateTransitionKinematicsInfo &kininfo) {
131  // Create title
132  outstream << "( ";
133  for (auto i : kininfo.InitialState)
134  outstream << findParticle(kininfo.ParticleList, i).getName() << " ";
135  outstream << ")->( ";
136  for (unsigned int i = 0; i < kininfo.FinalState.size(); ++i)
137  outstream
138  << findParticle(kininfo.ParticleList, kininfo.FinalState[i]).getName()
139  << "[ID=" << kininfo.FinalStateEventPositionMapping[i] << "] ";
140  outstream << ")";
141 
142  outstream << "\nEvent position to final state ID mapping:\n";
143  for (unsigned int i = 0; i < kininfo.FinalStateEventPositionMapping.size();
144  ++i) {
145  outstream << i << ": " << kininfo.FinalStateEventPositionMapping[i] << "\n";
146  }
147 
148  return outstream;
149 }
150 
151 } // namespace Physics
152 } // namespace ComPWA
ComPWA four momentum class.
double calculateFinalStateIDMassSum(const std::vector< unsigned int > ids) const
ComPWA::FourMomentum InitialStateP4
Four momentum of the initial particle reaction.
const ParticleProperties & findParticle(const ParticleList &list, pid Pid)
Definition: Properties.hpp:93
ParticleStateTransitionKinematicsInfo(std::vector< pid > InitialState_, std::vector< pid > FinalState_, ComPWA::ParticleList ParticleList_, ComPWA::FourMomentum InitialStateP4_, std::vector< unsigned int > FinalStateEventPositionMapping_)
std::map< unsigned int, std::string > getFinalStateIDToNameMapping() const
std::set< ParticleProperties > ParticleList
Definition: Properties.hpp:84
std::string getName() const
Definition: Properties.hpp:31
friend std::ostream & operator<<(std::ostream &outstream, const ParticleStateTransitionKinematicsInfo &kininfo)
double invariantMassSquared() const