BeamlineGeometry.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 /// \file BeamlineGeometry.h
3 /// \brief Definition of the beamline offline geometry.
4 /// Also implementation of a service to obtain this information.
5 /// \author Mike Wallbank (University of Cincinnati) <wallbank@fnal.gov>
6 /// \date August 2019
7 ////////////////////////////////////////////////////////////////////////////
8 
9 #ifndef BeamlineGeometry_H
10 #define BeamlineGeometry_H
11 
12 // framework
15 
16 // stl
17 
18 // root
19 #include "TVector3.h"
20 
21 // -----------------------------------------------------------------------
22 namespace beamlinegeo {
23 
24  // -----------------------------------------------------------------------
25  struct SystemID {
26  SystemID() { }
27  SystemID(unsigned int system) {
28  System = system;
29  }
30  inline bool operator==(const SystemID& sid) const {
31  return (sid.System == System);
32  }
33  inline bool operator<(const SystemID& sid) const {
34  if (sid.System >= System) return false;
35  return true;
36  }
37  inline bool operator>(const SystemID& sid) const {
38  if (sid.System <= System) return false;
39  return true;
40  }
41  unsigned int System;
42  };
43  inline std::ostream& operator<<(std::ostream& os, const SystemID& system) {
44  os << "SystemID: System " << system.System << std::endl;
45  return os;
46  }
47 
48  // -----------------------------------------------------------------------
49  struct DetectorID : SystemID {
50  DetectorID() : SystemID() { }
51  DetectorID(SystemID system, unsigned int detector) : SystemID(system), Detector(detector) {
52  }
53  DetectorID(unsigned int system, unsigned int detector) : SystemID(system), Detector(detector) {
54  }
55  SystemID GetSystemID() const { return *this; }
56  inline bool operator==(const DetectorID& did) const {
57  return (did.System == System and did.Detector == Detector);
58  }
59  inline bool operator<(const DetectorID& did) const {
60  if (did.System >= System) return false;
61  if (did.Detector >= Detector) return false;
62  return true;
63  }
64  inline bool operator>(const DetectorID& did) const {
65  if (did.System <= System) return false;
66  if (did.Detector <= Detector) return false;
67  return true;
68  }
69  unsigned int Detector;
70  };
71  inline std::ostream& operator<<(std::ostream& os, const DetectorID& detector) {
72  os << "DetectorID: System " << detector.System
73  << ", Detector " << detector.Detector << std::endl;
74  return os;
75  }
76 
77  // -----------------------------------------------------------------------
78  struct ChannelID : DetectorID {
80  ChannelID(DetectorID detector, unsigned int channel) : DetectorID(detector), Channel(channel) {
81  }
82  ChannelID(unsigned int system, unsigned int detector, unsigned int channel) : DetectorID(system, detector), Channel(channel) {
83  }
84  SystemID GetSystemID() const { return *this; }
85  DetectorID GetDetectorID() const { return *this; }
86  inline bool operator==(const ChannelID& cid) const {
87  return (cid.System == System and cid.Detector == Detector and cid.Channel == Channel);
88  }
89  inline bool operator<(const ChannelID& cid) const {
90  if (cid.System > System) return false;
91  if (cid.System == System and cid.Detector > Detector) return false;
92  if (cid.System == System and cid.Detector == Detector and cid.Channel >= Channel) return false;
93  return true;
94  }
95  inline bool operator>(const ChannelID& cid) const {
96  if (cid.System < System) return false;
97  if (cid.System == System and cid.Detector < Detector) return false;
98  if (cid.System == System and cid.Detector == Detector and cid.Channel <= Channel) return false;
99  return true;
100  }
101  unsigned int Channel;
102  };
103  inline std::ostream& operator<<(std::ostream& os, const ChannelID& channel) {
104  os << "ChannelID: System " << channel.System << ", Detector "
105  << channel.Detector << ", Channel " << channel.Channel << std::endl;
106  return os;
107  }
108 
109  // -----------------------------------------------------------------------
110  enum class BeamlineCoordSystem {
111  Beamline = 0,
112  NOvADetector = 1
113  };
114 
115  // -----------------------------------------------------------------------
116  enum class BeamlineComponent {
117  Target = 0,
118  ToFUS = 1,
119  ToFDS = 2,
120  ToFDSSiPM = 3,
121  WC1 = 4,
122  WC2 = 5,
123  WC3 = 6,
124  WC4 = 7,
125  Cherenkov = 8,
126  NOvA = 9,
127  Magnet = 10,
128  CollimatorUS = 11,
129  CollimatorDS = 12,
130  Shielding1 = 13,
131  Shielding2 = 14,
132  Shielding3 = 15,
133  HeliumPipe1 = 16,
134  HeliumPipe2 = 17,
135  HeliumPipe3 = 18,
136  HeliumPipe4 = 19,
137  TotalNumber = 20
138  };
139 
140  struct BeamlineObject {
142  TVector3 Position;
143  TVector3 Dimensions;
144  float Angle;
145  BeamlineObject() = default;
147  Component = component;
148  }
149  };
150 
151  // -----------------------------------------------------------------------
153  Trigger = 0,
155  ToF = 2,
156  WC = 3,
158  Paddle = 5,
159  WCDigit = 6,
160  Other = 7
161  };
162 
163  // -----------------------------------------------------------------------
164  enum ToFCounter {
165  US = 0,
166  DS = 1,
167  DSSiPM = 2,
168  };
169 
170  // -----------------------------------------------------------------------
171  const std::map<ToFCounter, std::string> ToFCounterNames = {
172  {ToFCounter::US, "US"},
173  {ToFCounter::DS, "DS"},
174  {ToFCounter::DSSiPM, "DSSiPM"}
175  };
176 
177  // -----------------------------------------------------------------------
178  enum ToFChannel {
183  };
184 
185  // -----------------------------------------------------------------------
186  const std::map<ToFChannel, std::string> ToFChannelNames = {
187  {ToFChannel::UpperLeft, "UpperLeft"},
188  {ToFChannel::LowerLeft, "LowerLeft"},
189  {ToFChannel::UpperRight, "UpperRight"},
190  {ToFChannel::LowerRight, "LowerRight"},
191  };
192 
193  // -----------------------------------------------------------------------
195 
196  public:
197 
200 
201  void MakeObjects();
202  void ConfigureGeometry(const fhicl::ParameterSet& pset);
203 
204  /// Number of ToF counters in beamline
205  unsigned int NumToFs() const;
206 
207  /// Number of WCs in beamline
208  unsigned int NumWCs() const;
209 
210  /// Number of Cherenkov detectors in beamline
211  unsigned int NumCherenkov() const;
212 
213  /// Number of counter of this ToF
214  unsigned int NumToFCounters(DetectorID tof) const;
215 
216  /// Number of channels on this WC
217  unsigned int NumWCChannels(DetectorID wc) const;
218 
219  /// Return beamline object for a BeamlineComponent
220  BeamlineObject GetBeamlineObject(BeamlineComponent component) const;
221 
222  /// Return beamline object for a ChannelID
223  BeamlineObject GetBeamlineObject(ChannelID channel) const;
224 
225  /// Return beamline object for a DetectorID
226  BeamlineObject GetBeamlineObject(DetectorID detector) const;
227 
228  /// Return DetectorID for a beamline object
229  DetectorID GetDetectorID(BeamlineObject object) const;
230 
231  /// Return DetectorID for a BeamlineComponent
232  DetectorID GetDetectorID(BeamlineComponent component) const;
233 
234  /// Magnet angle
235  float MagnetAngle() const;
236 
237  /// Effective length of the magnet
238  float MagnetEffectiveLength() const;
239 
240  /// Intercept of the magnet midplane?
241  float MagnetMidplaneIntercept() const;
242 
243  /// Number of wires on each WC plane
244  unsigned int NumWCPlaneWires() const;
245 
246  /// Wire chamber wire pitch
247  float WCWirePitch() const;
248 
249  /// WC angle
250  float WCAngle(unsigned int wc) const;
251 
252  /// Convert a position vector in beamline coordinates
253  /// to NOvA detector coordinates
254  TVector3 BeamlineToNOvADetectorCoords(TVector3 vec) const;
255 
256  /// Convert a position vector in NOvA detector coordinates
257  /// to beamline coordinates
258  TVector3 NOvADetectorToBeamlineCoords(TVector3 vec) const;
259 
260  /// Get the position of a beamline component in the specified
261  /// coordinate system
262  TVector3 BeamlineComponentPos(BeamlineComponent component,
264 
265  /// SystemIDs
266  std::vector<SystemID> SystemIDs() const;
267 
268  /// DetectorIDs
269  std::vector<DetectorID> DetectorIDs() const;
270 
271  /// ChannelIDs
272  std::vector<ChannelID> ChannelIDs() const;
273 
274  private:
275 
276  // Number of beamline components
277  unsigned int fNumToFs;
278  unsigned int fNumWCs;
279  unsigned int fNumCherenkov;
280 
281  // Information about ToF
282  std::vector<unsigned int> fNumToFCounters;
283 
284  // Information about magnet
288 
289  // Information about WCs
290  unsigned int fNumWCPlaneWires;
292  std::vector<float> fWCAngles;
293 
294  // Container of beamline objects
295  std::map<BeamlineComponent, BeamlineObject> fBeamlineObjects;
296 
297  // Origin of the NOvA coordinate system in Beamline coordinates
298  // Used for translating between the two systems
300 
301  };
302 
303 }
304 
305 // -----------------------------------------------------------------------
307 
308 #endif
SystemID GetSystemID() const
system("rm -rf microbeam.root")
DetectorID GetDetectorID() const
std::vector< unsigned int > fNumToFCounters
bool operator==(const ChannelID &cid) const
#define DECLARE_ART_SERVICE(svc, scope)
Definition: ServiceMacros.h:91
bool operator<(const SystemID &sid) const
bool operator<(const ChannelID &cid) const
bool operator==(const SystemID &sid) const
DetectorID(SystemID system, unsigned int detector)
SystemID GetSystemID() const
Eigen::VectorXd vec
SystemID(unsigned int system)
DetectorID(unsigned int system, unsigned int detector)
ChannelID(DetectorID detector, unsigned int channel)
bool operator>(const SystemID &sid) const
bool operator<(const DetectorID &did) const
std::vector< float > fWCAngles
bool operator>(const ChannelID &cid) const
bool operator==(const DetectorID &did) const
ChannelID(unsigned int system, unsigned int detector, unsigned int channel)
std::map< BeamlineComponent, BeamlineObject > fBeamlineObjects
BeamlineObject(BeamlineComponent component)
const std::map< ToFChannel, std::string > ToFChannelNames
const std::map< ToFCounter, std::string > ToFCounterNames
std::ostream & operator<<(std::ostream &os, const SystemID &system)
bool operator>(const DetectorID &did) const