ATLAS Offline Software
ForwardTracker/src/Beamline.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "ForwardTracker/Point.h"
8 #include <cmath> //fabs
9 #include <iostream> //<<, ostream
10 #include <iomanip> //setw
11 #include <sstream> //stringstream
12 #include <ios> //std::fixed
13 #include <algorithm> //std::find_if
14 #include <stdexcept> //std::runtime_error
15 
16 
17 namespace ForwardTracker {
18 
19  bool isEndMarker(const IBeamElement::ConstPtr_t& be) { return be->isEndElement(); }
20 
22 
23  IBeamElement::Iter_t ei = std::find_if(container.begin(), container.end(), isEndMarker);
24 
25  if (ei != container.end()) ++ei;
26  else throw std::runtime_error("Could not find the end of the beamline.");
27 
28  return ei;
29  }
30 
32 
33  public:
34 
35  bool operator() (const IBeamElement::ConstPtr_t& be, double zpos) { return std::fabs(zpos) > std::fabs(be->position().z()); }
36  };
37 
39 
41  IBeamElement::Iter_t tempIter = findBeamLineEnd(temp);
42  IBeamElement::Container_t temp2(temp.begin(), tempIter);
43  m_elements.swap(temp2);
44  }
45 
47 
49  m_elements.swap(temp);
50  }
51 
53 
54  public:
55 
57 
59 
60  be->track(m_particle);
61 
62  if (m_particle.debug()) std::cout << std::setw(12) << be->label() << m_particle << std::endl;
63 
64  return m_particle.isOutOfAperture();
65  }
66 
67  private:
68 
70  };
71 
72  void Beamline::track(IParticle& particle) const { // Pass the particle to beam elements until out of aperture or endPlane
73 
74  IBeamElement::ConstIter_t nextElement = std::lower_bound(m_elements.begin(), m_elements.end(), particle.z(), zPosNextElement());
75 
76  [[maybe_unused]]const auto & firstOutOfAperture = std::find_if(nextElement, m_elements.end(), ParticleTracker(particle));
77  }
78 
79  class Stringer {
80 
81  public:
82 
83  Stringer(): m_ost(new std::stringstream) { (*m_ost) << "----------------- Beamline -----------------\n"; }
84 
86 
87  (*m_ost) << std::fixed << std::left
88  << std::setw(15) << be->label()
89  << std::setw(10) << be->side() << std::right
90  << std::setw(12) << be->frontFace()
91  << std::setw(12) << be->rearFace()
92  << " pos" << be->position()
93  << "\n";
94  }
95 
96  std::string str() const { return m_ost->str(); }
97 
98  private:
99 
100  std::shared_ptr<std::stringstream> m_ost;
101  };
102 
103  std::string Beamline::str() const { return (std::for_each(m_elements.begin(), m_elements.end(), Stringer())).str(); }
104 
105  std::ostream& operator<<(std::ostream& os, const Beamline& bl) { os << bl.str(); return os; }
106 }
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
ForwardTracker::ParticleTracker::ParticleTracker
ParticleTracker(IParticle &particle)
Definition: ForwardTracker/src/Beamline.cxx:56
ForwardTracker::Beamline
Definition: ForwardTracker/ForwardTracker/Beamline.h:16
ForwardTracker::Beamline::Beamline
Beamline()
Definition: ForwardTracker/ForwardTracker/Beamline.h:20
ForwardTracker::IBeamElement::Container_t
std::vector< ConstPtr_t > Container_t
Definition: ForwardTracker/ForwardTracker/IBeamElement.h:40
ForwardTracker::ParticleTracker
Definition: ForwardTracker/src/Beamline.cxx:52
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
ForwardTracker::IBeamElement::ConstPtr_t
std::shared_ptr< const IBeamElement > ConstPtr_t
Definition: ForwardTracker/ForwardTracker/IBeamElement.h:39
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
ForwardTracker::Beamline::str
std::string str() const
Definition: ForwardTracker/src/Beamline.cxx:103
ForwardTracker::IBeamElement::ConstListIter_t
List_t::const_iterator ConstListIter_t
Definition: ForwardTracker/ForwardTracker/IBeamElement.h:45
ForwardTracker::zPosNextElement
Definition: ForwardTracker/src/Beamline.cxx:31
IParticle.h
ForwardTracker::operator<<
std::ostream & operator<<(std::ostream &, const Beamline &)
Definition: ForwardTracker/src/Beamline.cxx:105
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
ForwardTracker::IBeamElement::ConstIter_t
Container_t::const_iterator ConstIter_t
Definition: ForwardTracker/ForwardTracker/IBeamElement.h:42
ForwardTracker::Stringer
Definition: ForwardTracker/src/Beamline.cxx:79
ForwardTracker::IParticle
Definition: ForwardDetectors/ForwardTracker/ForwardTracker/IParticle.h:16
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
ForwardTracker::IBeamElement::Iter_t
Container_t::iterator Iter_t
Definition: ForwardTracker/ForwardTracker/IBeamElement.h:41
ForwardTracker::zPosNextElement::operator()
bool operator()(const IBeamElement::ConstPtr_t &be, double zpos)
Definition: ForwardTracker/src/Beamline.cxx:35
ForwardTracker::IParticle::debug
virtual bool debug() const =0
ForwardTracker::Stringer::str
std::string str() const
Definition: ForwardTracker/src/Beamline.cxx:96
ForwardTracker::Stringer::m_ost
std::shared_ptr< std::stringstream > m_ost
Definition: ForwardTracker/src/Beamline.cxx:100
ForwardTracker::Stringer::Stringer
Stringer()
Definition: ForwardTracker/src/Beamline.cxx:83
ForwardTracker::Beamline::track
void track(IParticle &) const
Definition: ForwardTracker/src/Beamline.cxx:72
ForwardTracker::isEndMarker
bool isEndMarker(const IBeamElement::ConstPtr_t &be)
Definition: ForwardTracker/src/Beamline.cxx:19
ForwardTracker::IParticle::isOutOfAperture
virtual bool isOutOfAperture() const =0
ForwardTracker::Beamline::m_elements
IBeamElement::Container_t m_elements
Definition: ForwardTracker/ForwardTracker/Beamline.h:32
ForwardTracker::ParticleTracker::m_particle
IParticle & m_particle
Definition: ForwardTracker/src/Beamline.cxx:69
Point.h
ForwardTracker::Stringer::operator()
void operator()(const IBeamElement::ConstPtr_t &be)
Definition: ForwardTracker/src/Beamline.cxx:85
ForwardTracker::ParticleTracker::operator()
bool operator()(const IBeamElement::ConstPtr_t &be)
Definition: ForwardTracker/src/Beamline.cxx:58
PlotCalibFromCool.be
be
Definition: PlotCalibFromCool.py:398
ForwardTracker
Definition: ForwardTracker/ForwardTracker/Beamline.h:12
Beamline.h
ForwardTracker::findBeamLineEnd
IBeamElement::Iter_t findBeamLineEnd(IBeamElement::Container_t &container)
Definition: ForwardTracker/src/Beamline.cxx:21