ATLAS Offline Software
Loading...
Searching...
No Matches
MuonTrackSteeringStrategy.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUON_MUONTRACKSTEERINGSTRATEGY_H
6#define MUON_MUONTRACKSTEERINGSTRATEGY_H
7
8#include <bitset>
9#include <iostream>
10#include <string>
11#include <vector>
12
13#include "GaudiKernel/MsgStream.h"
15
16namespace Muon {
18 public:
30
31 MuonTrackSteeringStrategy(const std::string & name, const std::bitset<Last> & bits,
32 std::vector<std::vector<MuonStationIndex::ChIndex> >& path, std::vector<unsigned int>& seedOrder) :
33 m_name(name), m_bits(bits), m_path(path), m_seeds(seedOrder) {}
34
36 MuonTrackSteeringStrategy(const std::string & name, std::vector<std::string> & options,
37 std::vector<std::vector<MuonStationIndex::ChIndex> >& path) :
38 m_name(name), m_path(path) {
39 for (unsigned int i = 0; i < Last; ++i) m_bits.set(i, 0);
40 for (unsigned int i = 0; i < options.size(); ++i) setOption(options[i], true);
41 }
42
43 MuonTrackSteeringStrategy(const std::string & name, std::vector<std::string> & options,
44 std::vector<std::vector<MuonStationIndex::ChIndex> >& path, std::vector<unsigned int>& seedOrder) :
45 m_name(name), m_path(path), m_seeds(seedOrder) {
46 for (unsigned int i = 0; i < Last; ++i) m_bits.set(i, 0);
47 for (unsigned int i = 0; i < options.size(); ++i) setOption(options[i], true);
48 }
49
50 void setOption(Option, bool value);
51 void setOption(const std::string&, bool value);
52 bool option(Option) const;
53 const std::bitset<Last>& allOptions() const { return m_bits; }
54
55 // Set methods
56 void setCh(const std::vector<MuonStationIndex::ChIndex>& val, const unsigned int layer);
57 void setCh(const std::vector<std::vector<MuonStationIndex::ChIndex> >& val) { m_path = val; }
58
59 // Get methods
60 const std::vector<std::vector<MuonStationIndex::ChIndex> >& getAll() const { return m_path; }
61 const std::vector<MuonStationIndex::ChIndex>& getCh(const unsigned int) const;
62
63 // for the name
64 const std::string& getName() const { return m_name; }
65 void setName(const std::string& name) { m_name = name; }
66
67 const std::vector<unsigned int>& seeds() const { return m_seeds; }
68 void setSeeds(const std::vector<unsigned int>& val) { m_seeds = val; }
69
70 private:
71 std::string m_name;
72 std::bitset<Last> m_bits;
73 std::vector<std::vector<MuonStationIndex::ChIndex> > m_path;
74 std::vector<unsigned int> m_seeds;
75 };
76} // namespace Muon
77
78inline void Muon::MuonTrackSteeringStrategy::setOption(const std::string& opt, bool value) {
79 if (opt == "CutSeedsOnTracks")
81 else if (opt == "CombineSegInStation")
83 else if (opt == "DynamicSeeding")
85 else if (opt == "PreferOutsideIn")
87 else if (opt == "AllowOneSharedHit")
89 else if (opt == "DoRefinement")
90 setOption(DoRefinement, value);
91 else if (opt == "DoAmbiSolving")
93 else if (opt == "BarrelEndcapFilter")
95 else {
96 // Attempt to interpret the string as a seed sequence
97 std::vector<unsigned int> seeds;
98 bool success = true;
99 for (unsigned int i = 0; i < opt.size() && success; ++i) {
100 int holder = int(opt[i]) - 48;
101 if (holder < 0 || holder > 9)
102 success = false;
103 else
104 seeds.push_back(holder);
105 }
106 if (success) setSeeds(seeds);
107 }
108}
109
110inline void Muon::MuonTrackSteeringStrategy::setOption(const Option opt, bool value) {
111 if (opt == Last) return;
112 m_bits[opt] = value;
113}
114
115inline void Muon::MuonTrackSteeringStrategy::setCh(const std::vector<MuonStationIndex::ChIndex>& val, const unsigned int layer) {
116 if (layer < m_path.size())
117 m_path[layer] = val;
118 else { // assume the user knows what he or she is doing
119 m_path.resize(layer + 1);
120 m_path[layer] = val;
121 }
122}
123
124inline const std::vector<Muon::MuonStationIndex::ChIndex>& Muon::MuonTrackSteeringStrategy::getCh(const unsigned int layer = 0) const {
125 if (layer >= m_path.size()) {
126 throw std::range_error("MuonTrackSteering a path beyond the possible paths is chosen");
127 }
128 return m_path[layer];
129}
130
132 return m_bits[static_cast<unsigned int>(op)];
133}
134
135inline std::ostream& operator<<(std::ostream& sl, const Muon::MuonTrackSteeringStrategy& mtss) {
136 sl << "MuonTrackSteeringStrategy " << mtss.getName() << " with options: " << mtss.allOptions() << " with seeds";
137 if (mtss.seeds().size()) {
138 for (unsigned int i = 0; i < mtss.seeds().size(); ++i) { sl << " " << mtss.seeds()[i]; }
139 } else
140 sl << " <none>";
141 sl << " and chambers are: " << std::endl;
142 for (unsigned int i = 0; i < mtss.getAll().size(); ++i) {
143 sl << "\t Step " << i << " : ( ";
144 for (unsigned int j = 0; j < mtss.getCh(i).size() - 1; ++j) {
145 sl << Muon::MuonStationIndex::chName(mtss.getCh(i)[j]) << " , ";
146 }
147 if (mtss.getCh(i).size()) {
148 sl << Muon::MuonStationIndex::chName(mtss.getCh(i)[mtss.getCh(i).size() - 1]);
149 }
150 sl << " ) " << std::endl;
151 }
152 return sl;
153}
154
155inline MsgStream& operator<<(MsgStream& sl, const Muon::MuonTrackSteeringStrategy& mtss) {
156 sl << "MuonTrackSteeringStrategy " << mtss.getName() << " with options: " << mtss.allOptions() << " with seeds";
157 if (mtss.seeds().size()) {
158 for (unsigned int i = 0; i < mtss.seeds().size(); ++i) { sl << " " << mtss.seeds()[i]; }
159 } else
160 sl << " <none>";
161 sl << " and chambers are: " << std::endl;
162 for (unsigned int i = 0; i < mtss.getAll().size(); ++i) {
163 sl << "\t Step " << i << " : ( ";
164 for (unsigned int j = 0; j < mtss.getCh(i).size() - 1; ++j) {
165 sl << Muon::MuonStationIndex::chName(mtss.getCh(i)[j]) << " , ";
166 }
167 if (mtss.getCh(i).size()) {
168 sl << Muon::MuonStationIndex::chName(mtss.getCh(i)[mtss.getCh(i).size() - 1]);
169 }
170 sl << " ) " << std::endl;
171 }
172 return sl;
173}
174
175#endif
const std::bitset< Last > & allOptions() const
MuonTrackSteeringStrategy(const std::string &name, std::vector< std::string > &options, std::vector< std::vector< MuonStationIndex::ChIndex > > &path, std::vector< unsigned int > &seedOrder)
std::vector< std::vector< MuonStationIndex::ChIndex > > m_path
std::bitset< Last > m_bits
List of all of the options available.
MuonTrackSteeringStrategy(const std::string &name, std::vector< std::string > &options, std::vector< std::vector< MuonStationIndex::ChIndex > > &path)
Constructor that assumes the seed order could come as part of the options.
const std::vector< MuonStationIndex::ChIndex > & getCh(const unsigned int) const
const std::vector< std::vector< MuonStationIndex::ChIndex > > & getAll() const
MuonTrackSteeringStrategy(const std::string &name, const std::bitset< Last > &bits, std::vector< std::vector< MuonStationIndex::ChIndex > > &path, std::vector< unsigned int > &seedOrder)
void setCh(const std::vector< std::vector< MuonStationIndex::ChIndex > > &val)
void setName(const std::string &name)
void setCh(const std::vector< MuonStationIndex::ChIndex > &val, const unsigned int layer)
void setSeeds(const std::vector< unsigned int > &val)
const std::vector< unsigned int > & seeds() const
const std::string & chName(ChIndex index)
convert ChIndex into a string
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
std::ostream & operator<<(std::ostream &ostr, const Muon::HedgehogBoard &board)