BeamlineGeometry_service.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 /// \File BeamlineGeometry.h
3 /// \brief Implementation of beamline geometry service.
4 /// \author Mike Wallbank (University of Cincinnati) <wallbank@fnal.gov>
5 /// \date August 2019
6 ////////////////////////////////////////////////////////////////////////////
7 
8 #include "BeamlineGeometry.h"
9 
10 // -----------------------------------------------------------------------
12  this->MakeObjects();
13  this->ConfigureGeometry(pset);
14 }
15 
16 // -----------------------------------------------------------------------
18  : BeamlineGeometry(pset) {
19 }
20 
21 // -----------------------------------------------------------------------
23 
24  // Make beamline objects
45 
46 }
47 
48 // -----------------------------------------------------------------------
50 
51  fhicl::ParameterSet geometry = pset.get<fhicl::ParameterSet>("Geometry");
52 
53  unsigned int period = geometry.get<unsigned int>("DataTakingPeriod");
54  if (period < 1 or period > 3)
55  throw cet::exception("BeamlineGeometry")
56  << "Data-Taking Period " << period << " unknown. Valid options are 1,2,3.";
57 
58  fNumToFs = geometry.get<unsigned int>("NumToFs");
59  fNumWCs = geometry.get<unsigned int>("NumWCs");
60  fNumCherenkov = geometry.get<unsigned int>("NumCherenkov");
61 
62  fNumToFCounters = geometry.get<std::vector<unsigned int> >("NumToFCounters");
63 
64  fMagnetAngle = geometry.get<float>("MagnetAngle");
65  fMagnetEffectiveLength = geometry.get<float>("MagnetEffectiveLength");
66  fMagnetMidplaneIntercept = geometry.get<float>("MagnetMidplaneIntercept");
67 
68  fNumWCPlaneWires = geometry.get<unsigned int> ("NumWCPlaneWires");
69  fWCWirePitch = geometry.get<float> ("WCWirePitch");
70  fWCAngles = geometry.get<std::vector<float> >("WCAngles");
71 
72  fhicl::ParameterSet positions = geometry.get<fhicl::ParameterSet>(Form("Positions_Period%d", period));
74  = TVector3(&positions.get<std::vector<float> >("Target")[0]);
76  = TVector3(&positions.get<std::vector<float> >("ToFUS")[0]);
78  = TVector3(&positions.get<std::vector<float> >("ToFDS")[0]);
80  = TVector3(&positions.get<std::vector<float> >("ToFDSSiPM")[0]);
82  = TVector3(&positions.get<std::vector<float> >("WC1")[0]);
84  = TVector3(&positions.get<std::vector<float> >("WC2")[0]);
86  = TVector3(&positions.get<std::vector<float> >("WC3")[0]);
88  = TVector3(&positions.get<std::vector<float> >("WC4")[0]);
90  = TVector3(&positions.get<std::vector<float> >("Cherenkov")[0]);
92  = TVector3(&positions.get<std::vector<float> >("NOvA")[0]);
94  = TVector3(&positions.get<std::vector<float> >("Magnet")[0]);
96  = TVector3(&positions.get<std::vector<float> >("CollimatorUS")[0]);
98  = TVector3(&positions.get<std::vector<float> >("CollimatorDS")[0]);
100  = TVector3(&positions.get<std::vector<float> >("Shielding1")[0]);
102  = TVector3(&positions.get<std::vector<float> >("Shielding2")[0]);
104  = TVector3(&positions.get<std::vector<float> >("Shielding3")[0]);
106  = TVector3(&positions.get<std::vector<float> >("HeliumPipe1")[0]);
108  = TVector3(&positions.get<std::vector<float> >("HeliumPipe2")[0]);
110  = TVector3(&positions.get<std::vector<float> >("HeliumPipe3")[0]);
112  = TVector3(&positions.get<std::vector<float> >("HeliumPipe4")[0]);
113 
115 
116  // Calculate ToF path length
117  TVector3 uspos = fBeamlineObjects[BeamlineComponent::ToFUS].Position,
118  dspos = fBeamlineObjects[BeamlineComponent::ToFDS].Position,
119  dssipmpos = fBeamlineObjects[BeamlineComponent::ToFDSSiPM].Position,
120  magpos = fBeamlineObjects[BeamlineComponent::Magnet].Position;
121  float ustomag = sqrt(pow((magpos.X() - uspos.X()), 2) + pow((magpos.Z() - uspos.Z()), 2));
122  float magtods = sqrt(pow((dspos.X() - magpos.X()), 2) + pow((dspos.Z() - magpos.Z()), 2));
123  float magtodssipm = sqrt(pow((dssipmpos.X() - magpos.X()), 2) + pow((dssipmpos.Z() - magpos.Z()), 2));
124  fToFPathLength = ustomag + magtods;
125  fToFPathLengthSiPM = ustomag + magtodssipm;
126  std::cout << "ToF paths " << fToFPathLength << ", " << fToFPathLengthSiPM << std::endl;
127 
128  return;
129 
130 }
131 
132 // -----------------------------------------------------------------------
134  return fNumToFs;
135 }
136 
137 // -----------------------------------------------------------------------
139  return fNumWCs;
140 }
141 
142 // -----------------------------------------------------------------------
144  return fNumCherenkov;
145 }
146 
147 // -----------------------------------------------------------------------
149  if (tof.Detector >= fNumToFCounters.size()) {
150  std::cout << "ToF detector " << tof.Detector << " does not exist." << std::endl;
151  abort();
152  }
153  return fNumToFCounters.at(tof.Detector);
154 }
155 
156 // -----------------------------------------------------------------------
158  std::cout << "Warning: BeamlineGeometry::NumWCChannels not yet implemented" << std::endl;
159  return 0;
160 }
161 
162 // -----------------------------------------------------------------------
164  if (!fBeamlineObjects.count(component)) {
165  std::cout << "No beamline object " << static_cast<unsigned int>(component) << std::endl;
166  abort();
167  }
168  return fBeamlineObjects.at(component);
169 }
170 
171 // -----------------------------------------------------------------------
172 //BeamlineObject beamlinegeo::BeamlineGeometry::GetBeamlineObject(ChannelID channel) const;
173 
174 // -----------------------------------------------------------------------
175 //BeamlineObject beamlinegeo::BeamlineGeometry::GetBeamlineObject(DetectorID detector) const;
176 
177 // -----------------------------------------------------------------------
178 //DetectorID beamlinegeo::BeamlineGeometry::GetDetectorID(BeamlineObject object) const;
179 
180 // -----------------------------------------------------------------------
181 //DetectorID beamlinegeo::BeamlineGeometry::GetDetectorID(BeamlineComponent component) const;
182 
183 // -----------------------------------------------------------------------
185  return fMagnetAngle;
186 }
187 
188 // -----------------------------------------------------------------------
190  return fMagnetEffectiveLength;
191 }
192 
193 // -----------------------------------------------------------------------
196 }
197 
198 // -----------------------------------------------------------------------
200  return fNumWCPlaneWires;
201 }
202 
203 // -----------------------------------------------------------------------
205  return fWCWirePitch;
206 }
207 
208 // -----------------------------------------------------------------------
209 float beamlinegeo::BeamlineGeometry::WCAngle(unsigned int wc) const {
210  if (wc >= fWCAngles.size()) {
211  std::cout << "No WC " << wc << std::endl;
212  abort();
213  }
214  return fWCAngles.at(wc);
215 }
216 
217 // -----------------------------------------------------------------------
219  return vec-fNOvACoordOrigin;
220 }
221 
222 // -----------------------------------------------------------------------
224  return vec+fNOvACoordOrigin;
225 }
226 
227 // -----------------------------------------------------------------------
229  BeamlineCoordSystem system) const {
230  BeamlineObject obj = this->GetBeamlineObject(component);
231  TVector3 pos = obj.Position;
232  if (system == BeamlineCoordSystem::NOvADetector)
233  pos = this->BeamlineToNOvADetectorCoords(pos);
234  return pos;
235 }
236 
float WCAngle(unsigned int wc) const
WC angle.
float MagnetMidplaneIntercept() const
Intercept of the magnet midplane?
system("rm -rf microbeam.root")
TVector3 NOvADetectorToBeamlineCoords(TVector3 vec) const
unsigned int NumToFs() const
Number of ToF counters in beamline.
#define DEFINE_ART_SERVICE(svc)
Definition: ServiceMacros.h:93
unsigned int NumWCs() const
Number of WCs in beamline.
float MagnetEffectiveLength() const
Effective length of the magnet.
T sqrt(T number)
Definition: d0nt_math.hpp:156
constexpr T pow(T x)
Definition: pow.h:75
std::vector< unsigned int > fNumToFCounters
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
Definition of the beamline offline geometry. Also implementation of a service to obtain this informat...
TVector3 BeamlineComponentPos(BeamlineComponent component, BeamlineCoordSystem system) const
unsigned int NumToFCounters(DetectorID tof) const
Number of counter of this ToF.
TVector3 BeamlineToNOvADetectorCoords(TVector3 vec) const
T get(std::string const &key) const
Definition: ParameterSet.h:231
BeamlineObject GetBeamlineObject(BeamlineComponent component) const
Return beamline object for a BeamlineComponent.
Eigen::VectorXd vec
float MagnetAngle() const
Magnet angle.
float WCWirePitch() const
Wire chamber wire pitch.
OStream cout
Definition: OStream.cxx:6
void ConfigureGeometry(const fhicl::ParameterSet &pset)
BeamlineGeometry(const fhicl::ParameterSet &pset)
Implementation of beamline geometry service.
std::vector< float > fWCAngles
unsigned int NumWCChannels(DetectorID wc) const
Number of channels on this WC.
unsigned int NumWCPlaneWires() const
Number of wires on each WC plane.
std::map< BeamlineComponent, BeamlineObject > fBeamlineObjects
unsigned int NumCherenkov() const
Number of Cherenkov detectors in beamline.