20 #include "qft++/Vector4.h" 24 namespace HelicityFormalism {
27 std::vector<pid> initialState,
28 std::vector<pid> finalState,
31 initialState, finalState, partL, cmsP4, [&finalState]() {
32 std::vector<unsigned int> FinalStateEventPositionMapping;
33 for (
unsigned int i = 0; i < finalState.size(); ++i) {
34 FinalStateEventPositionMapping.push_back(i);
36 return FinalStateEventPositionMapping;
48 LOG(INFO) <<
"HelicityKinematics::" 49 "HelicityKinematics() | Initialized kinematics " 59 LOG(INFO) <<
"HelicityKinematics::reduceToPhaseSpace(): " 60 "Remove all events outside PHSP boundary from data sample.";
62 std::copy_if(DataSample.
Events.begin(), DataSample.
Events.end(),
63 std::back_inserter(PhspSample.Events), [
this](
auto evt) {
68 if (mass < bounds.first || mass > bounds.second)
73 if (angles.first < 0 || angles.first > M_PI)
75 if (angles.second < -M_PI || angles.second > M_PI)
81 LOG(INFO) <<
"reduceToPhaseSpace(): Removed " 82 << DataSample.
Events.size() - PhspSample.Events.size() <<
" from " 83 << DataSample.
Events.size() <<
" Events (" 84 << (1.0 - PhspSample.Events.size() / DataSample.
Events.size()) * 100
90 std::pair<double, double>
107 QFT::Vector4<double> DecayingState(State);
108 QFT::Vector4<double> Daughter(FinalA);
115 Daughter.Boost(DecayingState);
117 if (RecoilState.size() > 0) {
119 for (
auto s : RecoilState) {
123 QFT::Vector4<double> Recoil(TempRecoil);
125 Recoil.Boost(DecayingState);
128 Daughter.RotateZ(-Recoil.Phi());
129 Daughter.RotateY(M_PI - Recoil.Theta());
133 QFT::Vector4<double> ParentRecoil(0.0, 0.0, 0.0, 1.0);
134 if (ParentRecoilState.size() > 0) {
136 for (
auto s : ParentRecoilState) {
141 ParentRecoil = TempParentRecoil;
144 ParentRecoil.Boost(DecayingState);
145 ParentRecoil.RotateZ(-Recoil.Phi());
146 ParentRecoil.RotateY(M_PI - Recoil.Theta());
150 Daughter.RotateZ(M_PI - ParentRecoil.Phi());
153 double cosTheta = Daughter.CosTheta();
154 double phi = Daughter.Phi();
156 return std::make_pair(std::acos(cosTheta), phi);
162 for (
auto s : FinalStateIDs) {
174 LOG(ERROR) <<
"HelicityKinematics::convert() | No variables were requested " 175 "before. Therefore this function is doing nothing!";
179 std::stringstream Message;
180 Message <<
"Pids in EventCollection and in Kinematics do not match";
181 Message << std::endl <<
" ";
182 Message << DataSample.
Pids.size() <<
" PIDs in EventCollection:";
183 for (
auto Pid : DataSample.
Pids)
184 Message <<
" " << Pid;
185 Message << std::endl <<
" ";
187 <<
" PIDs in Kinematics:";
189 Message <<
" " << Pid;
194 "not equal to number of four-momenta");
198 Dataset.
Data.insert(std::make_pair(Masses.second, std::vector<double>()));
201 Dataset.
Data.at(Masses.second).push_back(Mass);
206 std::make_pair(
SubSystem.second.first, std::vector<double>()));
208 std::make_pair(
SubSystem.second.second, std::vector<double>()));
209 for (
auto const &event : DataSample.
Events) {
211 Dataset.
Data.at(
SubSystem.second.first).push_back(Angles.first);
212 Dataset.
Data.at(
SubSystem.second.second).push_back(Angles.second);
223 std::sort(MomentaIDs.begin(), MomentaIDs.end());
224 std::stringstream Name;
226 std::string comma(
"");
227 for (
auto x : MomentaIDs) {
239 std::pair<std::string, std::string>
241 std::stringstream ss;
244 std::string ThetaName(
"theta" + ss.str());
245 std::string PhiName(
"phi" + ss.str());
247 Subsystems.insert(std::make_pair(SubSys, std::make_pair(ThetaName, PhiName)));
248 return std::make_pair(ThetaName, PhiName);
251 std::vector<std::pair<ComPWA::IndexList, ComPWA::IndexList>>
254 std::vector<std::pair<IndexList, IndexList>> NewIndexLists;
255 if (A.size() < B.size())
256 throw std::runtime_error(
"HelicityKinematics::redistributeIndexLists(): A " 257 "cannot have less content than B!");
258 if (A.size() == 2 && B.size() == 0) {
260 }
else if (A.size() - B.size() > 1) {
261 for (
unsigned int i = 0; i < A.size(); ++i) {
263 TempB.push_back(A[i]);
265 TempA.erase(TempA.begin() + i);
266 NewIndexLists.push_back(std::make_pair(TempA, TempB));
269 return NewIndexLists;
275 IndexList FinalStateA(std::get<0>(SubSys));
276 IndexList FinalStateB(std::get<1>(SubSys));
277 IndexList RecoilState(std::get<2>(SubSys));
278 IndexList ParentRecoilState(std::get<3>(SubSys));
281 std::sort(FinalStateA.begin(), FinalStateA.end());
282 std::sort(FinalStateB.begin(), FinalStateB.end());
283 std::sort(RecoilState.begin(), RecoilState.end());
284 std::sort(ParentRecoilState.begin(), ParentRecoilState.end());
287 if (FinalStateA > FinalStateB)
288 SortedTuple = std::make_tuple(FinalStateB, FinalStateA, RecoilState,
291 SortedTuple = std::make_tuple(FinalStateA, FinalStateB, RecoilState,
297 std::vector<IndexListTuple> CurrentSubsystems;
298 LOG(INFO) <<
"creating all Subsystems!";
300 std::vector<IndexListTuple> AllSubsystems;
303 AllSubsystems.push_back(
305 SubSys.first.getFinalStates()[0]),
307 SubSys.first.getFinalStates()[1]),
309 SubSys.first.getRecoilState()),
311 SubSys.first.getParentRecoilState())));
317 [&i]() ->
unsigned int {
return i++; });
319 CurrentSubsystems.push_back(
323 while (CurrentSubsystems.size() > 0) {
324 auto TempSubsystems(CurrentSubsystems);
325 CurrentSubsystems.clear();
326 for (
auto const &x : TempSubsystems) {
330 IndexList CurrentParentRecoil(std::get<3>(x));
332 auto result = std::find_if(
333 AllSubsystems.begin(), AllSubsystems.end(),
337 if (result == AllSubsystems.end()) {
338 AllSubsystems.push_back(SortedEntry);
343 CurrentSubsystems.push_back(std::make_tuple(
344 ABNew.first, ABNew.second, CurrentRecoil, CurrentParentRecoil));
347 if (CurrentA.size() > 1) {
348 for (
auto const &ABNew :
352 CurrentSubsystems.push_back(std::make_tuple(ABNew.first, ABNew.second,
353 CurrentB, CurrentRecoil));
357 if (CurrentB.size() > 1) {
358 for (
auto const &ABNew :
360 CurrentSubsystems.push_back(std::make_tuple(ABNew.first, ABNew.second,
361 CurrentA, CurrentRecoil));
366 for (
auto const &x : AllSubsystems) {
372 std::tuple<std::string, std::string, std::string>
376 std::stringstream ss;
377 ss <<
"HelicityKinematics::registerSubSystem(const SubSystem " 378 "&subSys): Number of final state particles = " 380 throw std::runtime_error(ss.str());
385 FS1.insert(FS1.end(), FS2.begin(), FS2.end());
390 return std::make_tuple(MassName, AngleNames.first, AngleNames.second);
393 std::tuple<std::string, std::string, std::string>
395 const std::vector<unsigned int> &FinalA,
396 const std::vector<unsigned int> &FinalB,
397 const std::vector<unsigned int> &Recoil,
398 const std::vector<unsigned int> &ParentRecoil) {
399 std::vector<std::vector<unsigned int>> ConvertedFinalStates;
400 ConvertedFinalStates.push_back(
403 ConvertedFinalStates.push_back(
406 std::vector<unsigned int> ConvertedRecoil =
408 std::vector<unsigned int> ConvertedParentRecoil =
412 SubSystem(ConvertedFinalStates, ConvertedRecoil, ConvertedParentRecoil));
416 const std::string &InvariantMassName)
const {
424 std::pair<double, double> lim(0.0, 0.0);
429 double RemainderMass(0.0);
432 RemainderMass -= lim.first;
434 lim.first *= lim.first;
437 S - 2 * std::sqrt(S) * RemainderMass + RemainderMass * RemainderMass;
443 lim.first -= std::numeric_limits<double>::epsilon() * lim.first;
444 lim.second += std::numeric_limits<double>::epsilon() * lim.second;
ComPWA four momentum class.
const std::vector< pid > & getFinalStatePIDs() const
virtual const std::vector< unsigned int > & getParentRecoilState() const
unsigned int convertFinalStateIDToPositionIndex(unsigned int fs_id) const
double calculateFinalStateIDMassSum(const std::vector< unsigned int > ids) const
unsigned int getFinalStateParticleCount() const
std::vector< double > Weights
virtual const std::vector< unsigned int > & getRecoilState() const
double getInitialStateInvariantMassSquared() const
std::vector< unsigned int > IndexList
std::vector< Event > Events
std::set< ParticleProperties > ParticleList
unsigned int convertPositionIndexToFinalStateID(unsigned int pos) const
virtual const std::vector< std::vector< unsigned int > > & getFinalStates() const
std::vector< double > getFinalStateMasses() const
std::vector< FourMomentum > FourMomenta
EventCollection generate(unsigned int NumberOfEvents, const ComPWA::Kinematics &Kinematics, const ComPWA::PhaseSpaceEventGenerator &Generator, ComPWA::Intensity &Intensity, ComPWA::UniformRealNumberGenerator &RandomGenerator)
Data structure containing all kinematic information of a physics event.
double invariantMassSquared() const
bool checkPidMatchesEvents() const
Definition of a two-body decay node within a sequential decay tree.