LBNESurveyor.hh
Go to the documentation of this file.
1 #ifndef LBNESurveyor_H
2 #define LBNESurveyor_H
3 /*
4 ** This class, and it's subclasses (SurveyedPt), is an attempt at describing the
5 ** the process of surveying the LBNE target and neutrino beam elements.
6 ** It is not mean to be a general tool: Qunatities are specific to the LBNE beam layout.
7 **
8 ** The main class is a singleton. It can be refered by the LBNEVolumePlacement class, when it comes to place
9 ** a sub volume. Unlike the SubVolume class, this class does not actively place volume in the hierarchy.
10 ** It simply manages the key surveyed points along the beam line.
11 **
12 ** It is expected to be interface to a LBNESurveyorMessenger, derived class from G4Messenger class
13 ** to set things up.
14 **
15 ** The constructor of this class (private, as it is a singleton class) simply sets all position to
16 ** (0. 0. 0.) and tolerance to a rediculously small number (i.e., by default things are perfectly aligned.)
17 **
18 ** Intended use: This would be a two step process:
19 **
20 ** 1. Prior to instantiatiated the G4 geometry, the container class LBNESurveyor is instantiated.
21 ** Surveyed Points are added, one by one, by name. This could be done in the LBNESurveyor contructor,
22 ** or else where in this package, provided that the G4Placement are not yet done. The goal is to
23 ** provide a survey "log book"
24 **
25 ** 2. Based on the above logbook, as one construct the G4 geometry, one enquire about the relative coordinates
26 ** of the surveyed points, relative to the nominal base line. From this points, a rotation matrix and vector displacement
27 ** for the relevant volume can be computed, either in the
28 ** LBNEVolumePlacement::PlaceFinal method, or any of the G4 geometry
29 ** construction process, where the G4Placement occured.
30 **
31 ** Example: See method LBNEVolumePlacement::PlaceFinal
32 **
33 ** Unlike LBNEDetectorConstruction class, the LBNESurveyor class has knowledge about the complete survey of the beam
34 ** line, and therefore can check relative alignment prior to the geometry construction. It could also contain
35 ** surveyed point (monuments) that would have some correspondance to a corner, or a center, of the G4Volume.
36 **
37 **
38 ** Paul L. G. Lebrun, June 2013. Revised Sept. 2013
39 */
40 #include <string>
41 #include <vector>
42 #include "G4String.hh"
43 #include "G4UImessenger.hh"
44 #include "G4UIcommand.hh"
45 #include "G4UIdirectory.hh"
46 #include "G4UIcmdWithABool.hh"
47 #include "G4UIcmdWith3Vector.hh"
48 #include "G4ThreeVector.hh"
49 #include "G4SystemOfUnits.hh"
50 
51 class LBNESurveyedPt;
52 
53 class LBNESurveyorMessenger: public G4UImessenger { // Abandonned
54 
55  public:
57  LBNESurveyorMessenger(LBNESurveyedPt* aPts, const G4String &aName, const G4String &description);
58  // This class has pointers, so the rule of three applies. Needs a copy constructor and assignmenr
62  void SetNewValue(G4UIcommand *cmd, G4String val);
63 //
64 // Make them public to avoid code bloat with accessors.
65 
67  LBNESurveyedPt* fPoint; // back pointer to the point in question... Could be null is this messenger is blank.
68  G4UIcmdWithABool* fSetPositionFromToleranceCmd;
69  G4UIcmdWith3Vector* fToleranceCmd;
70  G4UIcmdWith3Vector* fPositionCmd;
71 
72 };
73 
75  public:
77  LBNESurveyedPt(const std::string &aName);
78  LBNESurveyedPt(const std::string &aName, const G4ThreeVector &tolerance);
79 
80 private:
81  std::string fName; // e.g., Horn1UpstreamPinLeftSide
83  G4ThreeVector fTolerance; // The expected tolerance on placing the object.
84  // For instance, it is assumed the left side of the Horn1 alignment pin
85  // will be known (i.e., surveyed) to within a 500 microns accuracy.
86  G4ThreeVector fPosition; // The actual position with respect to the nominal alignment.
87  // That is, if the alignment is really really good, then fPosition goes towards the null vector.
88 
89 public:
90  inline const std::string& GetName() const {return fName;}
91  inline void SetTolerance(const G4ThreeVector &tolerance) { fTolerance = tolerance; }
92  inline void SetPosition(const G4ThreeVector &pos) { fPosition = pos;}
93  inline const G4ThreeVector& GetTolerance() const { return fTolerance; }
94  inline const G4ThreeVector& GetPosition() const { return fPosition; }
95  void SetPositionByTolerance(bool t);
96  inline bool IsPositionSetByTolerance() const { return fPositionSetByTolerance;}
97 
98 private:
99  void defineMessenger();
100 };
101 
102 //
103 // The surveyor knows about the basic layout of the LBNE beam: there is one only one target, preceded by a baffle,
104 // Two horns and so forth. This the methods for this class are specific to LBNE beam line.
105 //
108 {
109 
110 private:
111  LBNESurveyor();
113  std::vector<LBNESurveyedPt> fData;
114 
116 
117 public:
118  static LBNESurveyor* Instance();
119  LBNESurveyor(LBNESurveyor const &); // not implemented
120  LBNESurveyor& operator=(LBNESurveyor const&); // not implemented
121  inline void AddPoint(const std::string &aName) {
122  fData.push_back(LBNESurveyedPt(aName));
123  }
124  inline void AddPoint(const std::string &aName, const G4ThreeVector tolerance) {
125  fData.push_back(LBNESurveyedPt(aName, tolerance));
126  }
127  inline std::vector<LBNESurveyedPt>::const_iterator begin() const { return fData.begin();}
128  inline std::vector<LBNESurveyedPt>::const_iterator end() const { return fData.end();}
129  inline size_t size() const { return fData.size();}
130 
131  void SetIt(); // Compute all position by tolerance, when applicable,
133  for(std::vector<LBNESurveyedPt>::const_iterator it=fData.begin(); it!=fData.end(); ++it) {
134  if (aName == it->GetName()) return it;
135  }
136  return fData.end();
137  }
138  inline bool IsVolumeMisaligned(const std::string &vName) const {
139  for(std::vector<LBNESurveyedPt>::const_iterator it=fData.begin(); it!=fData.end(); ++it) {
140  if (it->GetName().find(vName) != std::string::npos) {
141  G4ThreeVector pp = it->GetPosition();
142  if (std::abs(pp[0]) > 1.0e-6*CLHEP::mm) return true;
143  if (std::abs(pp[1]) > 1.0e-6*CLHEP::mm) return true;
144  }
145  }
146  return false;
147  }
148  inline void setPointPosition(const std::string &aName, const G4ThreeVector &position) {
149  for(std::vector<LBNESurveyedPt>::iterator it=fData.begin(); it!=fData.end(); ++it) {
150  if (aName == it->GetName()) it->SetPosition(position);
151  }
152  }
153  inline void setPointTolerance(const std::string &aName, const G4ThreeVector &tolerance) {
154  for(std::vector<LBNESurveyedPt>::iterator it=fData.begin(); it!=fData.end(); ++it) {
155  if (aName == it->GetName()) it->SetTolerance(tolerance);
156  }
157  }
158  void setPointPositionWithinTolerance(const std::string &aName);
159 // void SetTargetSegments(bool upstreamSegment, int model); // Based on prescribed tolerances, and perhaps a model on how
160  // the target alignment get modified as it heats up,
161  // Now done in VolumePlacement.
162 // void MoveTargetInOutHorn(double deltaZ); // To adjust the longitudinal position of the target.
163 // Functionality moved to the VolumePlacement class.
164 
165 private:
166  void SetThings(); // Update and implement constraints.
167  // This one should perhaps move to the VolumePlacements class.
168  // bool TieTargetSegments(double maxRadialMove=50.);
169  // Functionality moved to the Placement clasee.
170  // Very specific to the LBNE beam secondary (pions) beam layout, where the upstream and
171  // downstream target segments, which are implemented in two distinct subvolumes, (targetHall and Horn1, respectively),
172  // must be, part of one continuous 3D object. The paramter maxRadialMove is the maximum allowed to adjust the
173  // transverse position of the elements. Default value is extremly large (5 cm.,), meaning that volume clashes are
174  // likely if the tolerance is larger then the inner diameter of the Horn1. To be negotiated.
175  // This maxRadial move applies to the downstream end of the target...
176 // void defineMessengerPosition(const char *name); does not work either...
177 
178 };
179 //
180 // The more elegant way to define all the associate messengers via the LBNESurveyedPt class does not work
181 // Do it the brute force way..
182 //
183 
184 class LBNEAllSurveyorMessenger: public G4UImessenger
185 {
186 public:
189 
190  void defineAllCommds();
191 
192  void SetNewValue(G4UIcommand* ,G4String );
193 
194 private:
195 
196  bool amDefined; // to avoid circular instantiation...
197  //
198  //NuMI/rndm
199  //
200  G4UIdirectory* fSurvDir;
209  G4UIcmdWith3Vector* fSurvPosUpstreamLeftBallHorn1;
210  G4UIcmdWith3Vector* fSurvPosUpstreamRightBallHorn1;
211  G4UIcmdWith3Vector* fSurvPosDownstreamLeftBallHorn1;
212  G4UIcmdWith3Vector* fSurvPosDownstreamRightBallHorn1;
213  G4UIcmdWith3Vector* fSurvPosUpstreamLeftBallHorn2;
214  G4UIcmdWith3Vector* fSurvPosUpstreamRightBallHorn2;
215  G4UIcmdWith3Vector* fSurvPosDownstreamLeftBallHorn2;
216  G4UIcmdWith3Vector* fSurvPosDownstreamRightBallHorn2;
217  G4UIcmdWith3Vector* fSurvPosUpstreamLeftBallHorn3;
218  G4UIcmdWith3Vector* fSurvPosUpstreamRightBallHorn3;
219  G4UIcmdWith3Vector* fSurvPosDownstreamLeftBallHorn3;
220  G4UIcmdWith3Vector* fSurvPosDownstreamRightBallHorn3;
221  G4UIcmdWith3Vector* fSurvPosUpstreamLeftDecayPipe;
222  G4UIcmdWith3Vector* fSurvPosUpstreamRightDecayPipe;
223  G4UIcmdWith3Vector* fSurvPosDownstreamLeftDecayPipe;
224  G4UIcmdWith3Vector* fSurvPosDownstreamRightDecayPipe;
225  //
226 
227 
228 
229 };
230 
231 #endif
232 
G4UIcmdWith3Vector * fSurvPosUpstreamRightPinTargetHeTube
G4UIcmdWith3Vector * fToleranceCmd
Definition: LBNESurveyor.hh:69
G4UIcmdWith3Vector * fSurvPosDownstreamLeftPinTargetHeTube
intermediate_table::iterator iterator
std::vector< LBNESurveyedPt >::const_iterator end() const
G4UIcmdWith3Vector * fSurvPosUpstreamRightDecayPipe
G4UIcmdWith3Vector * fSurvPosDownstreamLeftPinTargetCanister
LBNEAllSurveyorMessenger * fAllMessenger
G4UIcmdWith3Vector * fSurvPosUpstreamLeftBallHorn1
std::string string
Definition: nybbler.cc:12
std::vector< LBNESurveyedPt >::const_iterator GetPoint(const std::string &aName) const
double const tolerance
void SetNewValue(G4UIcommand *cmd, G4String val)
Definition: LBNESurveyor.cc:99
void AddPoint(const std::string &aName)
G4UIcmdWith3Vector * fSurvPosDownstreamRightBallHorn3
G4UIcmdWith3Vector * fSurvPosUpstreamLeftBallHorn3
void SetPosition(const G4ThreeVector &pos)
Definition: LBNESurveyor.hh:92
intermediate_table::const_iterator const_iterator
G4UIcmdWith3Vector * fSurvPosUpstreamRightBallHorn1
std::string fName
Definition: LBNESurveyor.hh:81
G4ThreeVector fPosition
Definition: LBNESurveyor.hh:86
G4UIcmdWith3Vector * fSurvPosDownstreamRightBallHorn1
G4UIcmdWith3Vector * fSurvPosDownstreamLeftDecayPipe
G4UIcmdWith3Vector * fSurvPosUpstreamRightPinTargetCanister
const std::string & GetName() const
Definition: LBNESurveyor.hh:90
G4UIcmdWith3Vector * fSurvPosUpstreamLeftDecayPipe
T abs(T value)
bool IsVolumeMisaligned(const std::string &vName) const
bool IsPositionSetByTolerance() const
Definition: LBNESurveyor.hh:96
G4UIcmdWith3Vector * fSurvPosUpstreamLeftPinTargetHeTube
G4UIcmdWith3Vector * fSurvPosDownstreamRightPinTargetCanister
LBNESurveyedPt * fPoint
Definition: LBNESurveyor.hh:67
size_t size() const
void AddPoint(const std::string &aName, const G4ThreeVector tolerance)
G4UIcmdWith3Vector * fSurvPosDownstreamLeftBallHorn1
G4UIcmdWith3Vector * fSurvPosDownstreamLeftBallHorn3
G4ThreeVector fTolerance
Definition: LBNESurveyor.hh:83
G4UIcmdWith3Vector * fSurvPosUpstreamRightBallHorn3
bool fPositionSetByTolerance
Definition: LBNESurveyor.hh:82
G4UIcmdWith3Vector * fPositionCmd
Definition: LBNESurveyor.hh:70
G4UIcmdWith3Vector * fSurvPosUpstreamRightBallHorn2
G4UIcmdWith3Vector * fSurvPosUpstreamLeftBallHorn2
void setPointPosition(const std::string &aName, const G4ThreeVector &position)
G4UIdirectory * fSurvDir
G4UIcmdWith3Vector * fSurvPosDownstreamRightBallHorn2
std::vector< LBNESurveyedPt > fData
list cmd
Definition: getreco.py:22
const G4ThreeVector & GetPosition() const
Definition: LBNESurveyor.hh:94
const G4ThreeVector & GetTolerance() const
Definition: LBNESurveyor.hh:93
LBNESurveyorMessenger & operator=(LBNESurveyorMessenger const &other)
Definition: LBNESurveyor.cc:70
void setPointTolerance(const std::string &aName, const G4ThreeVector &tolerance)
static LBNESurveyor * fInstance
G4UIcmdWith3Vector * fSurvPosDownstreamRightPinTargetHeTube
std::vector< LBNESurveyedPt >::const_iterator begin() const
void SetTolerance(const G4ThreeVector &tolerance)
Definition: LBNESurveyor.hh:91
G4UIcmdWith3Vector * fSurvPosUpstreamLeftPinTargetCanister
G4UIcmdWithABool * fSetPositionFromToleranceCmd
Definition: LBNESurveyor.hh:68
G4UIcmdWith3Vector * fSurvPosDownstreamRightDecayPipe
G4UIcmdWith3Vector * fSurvPosDownstreamLeftBallHorn2