Juggler
Juggling algorithms and event processing using gaudi framework
Beam.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later
2 // Copyright (C) 2022 Wouter Deconinck
3 
4 #pragma once
5 
6 #include "Math/Vector4D.h"
7 using ROOT::Math::PxPyPzEVector;
8 
9 #include "edm4hep/MCParticleCollection.h"
10 #include "eicd/ReconstructedParticleCollection.h"
11 
12 namespace Jug::Base::Beam {
13 
14  template<class collection>
16  const collection& parts,
17  const std::set<int32_t>& pdg) {
18  std::vector<decltype(parts[0])> c;
19  for (const auto& p: parts) {
20  if (pdg.count(p.getPDG()) > 0) {
21  c.push_back(p);
22  break;
23  }
24  }
25  return c;
26  }
27 
28  template<class collection>
30  const collection& parts,
31  const std::set<int32_t>& status,
32  const std::set<int32_t>& pdg) {
33  std::vector<decltype(parts[0])> c;
34  for (const auto& p: parts) {
35  if (status.count(p.getGeneratorStatus()) > 0 &&
36  pdg.count(p.getPDG()) > 0) {
37  c.push_back(p);
38  break;
39  }
40  }
41  return c;
42  }
43 
44  inline auto find_first_beam_electron(const edm4hep::MCParticleCollection& mcparts) {
45  return find_first_with_status_pdg(mcparts, {4}, {11});
46  }
47 
48  inline auto find_first_beam_hadron(const edm4hep::MCParticleCollection& mcparts) {
49  return find_first_with_status_pdg(mcparts, {4}, {2212, 2112});
50  }
51 
52  inline auto find_first_scattered_electron(const edm4hep::MCParticleCollection& mcparts) {
53  return find_first_with_status_pdg(mcparts, {1}, {11});
54  }
55 
56  inline auto find_first_scattered_electron(const eicd::ReconstructedParticleCollection& rcparts) {
57  return find_first_with_pdg(rcparts, {11});
58  }
59 
60  inline
61  PxPyPzEVector
63  const edm4hep::Vector3f& p_in,
64  const float mass,
65  const std::vector<float>& pz_set,
66  const float crossing_angle = 0.0) {
67  PxPyPzEVector p_out;
68  for (const auto& pz : pz_set) {
69  if (fabs(p_in.z / pz - 1) < 0.1) {
70  p_out.SetPz(pz);
71  break;
72  }
73  }
74  p_out.SetPx(p_out.Pz() * sin(crossing_angle));
75  p_out.SetPz(p_out.Pz() * cos(crossing_angle));
76  p_out.SetE(std::hypot(p_out.Px(), p_out.Pz(), mass));
77  return p_out;
78  }
79 
80 } // namespace Jug::Base::Beam
Jug::Base::Beam::find_first_with_pdg
auto find_first_with_pdg(const collection &parts, const std::set< int32_t > &pdg)
Definition: Beam.h:15
Jug::Base::Beam::find_first_scattered_electron
auto find_first_scattered_electron(const edm4hep::MCParticleCollection &mcparts)
Definition: Beam.h:52
Jug::Base::Beam::find_first_with_status_pdg
auto find_first_with_status_pdg(const collection &parts, const std::set< int32_t > &status, const std::set< int32_t > &pdg)
Definition: Beam.h:29
Jug::Base::Beam::find_first_beam_electron
auto find_first_beam_electron(const edm4hep::MCParticleCollection &mcparts)
Definition: Beam.h:44
Jug::Base::Beam::find_first_beam_hadron
auto find_first_beam_hadron(const edm4hep::MCParticleCollection &mcparts)
Definition: Beam.h:48
Jug::Base::Beam::round_beam_four_momentum
PxPyPzEVector round_beam_four_momentum(const edm4hep::Vector3f &p_in, const float mass, const std::vector< float > &pz_set, const float crossing_angle=0.0)
Definition: Beam.h:62
Jug::Base::Beam
Definition: Beam.h:12