EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BeamPipeGeoParData.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BeamPipeGeoParData.h
1 //
2 // AYK (ayk@bnl.gov), 2014/08/13
3 //
4 // Beam pipe geometry description (around IP, so that a PCON structure will work);
5 //
6 // NB: internal storage is ROOT TGeoPcon-oriented; it does not make sense to
7 // arrange inherited classes for pure cylindric and pure conical pieces;
8 // user however can define cylindric and conical pieces as well (interface
9 // functions are provided); representation in ROOT will be done via either
10 // TGeoPcon or (if polycone has one section only) TGeoTube/TGeoCone shapes;
11 //
12 // NB: it is assumed, that single piece has a constant thickness; rationale: to
13 // simplify user interface; so if beam pipe with the same material changes
14 // wall thickness at some Z along the beam line, a separate piece should be
15 // arranged in beampipe.C; these pieces will be represented as different
16 // TGeoPcon volumes (see beampipe.C code); if this ever becomes a
17 // performance problem, one can modify code and merge neighboring pieces
18 // in a single TGeoPcon volume;
19 //
20 // NB: elliptic pieces are not implemented as of yet; rationale: TGeoEltu with
21 // variable profile (which would allow to arrange a smooth transition to
22 // an asimuthally-symmetric pieces) is not available in ROOT (and I do not
23 // want to hack hermetic transition by hand); then, it is not clear
24 // yet, whether elliptic tube profile is needed at EIC at all; once it
25 // becomes needed, the hope is that CAD drawings will become available;
26 // and: in worst case just extend this set of classes by whatever crap needed;
27 //
28 
29 #include <cmath>
30 
31 #include <EicGeoParData.h>
32 
33 #ifndef _BEAM_PIPE_GEO_PAR_DATA_
34 #define _BEAM_PIPE_GEO_PAR_DATA_
35 
36 class BeamPipeSection: public TObject
37 {
38  // Really no reason to hide anything from the "master" classes;
39  friend class BeamPipeElement;
40  friend class BeamPipeGeoParData;
41 
42  public:
44  BeamPipeSection(double offset, double outerDiameter): mOffset(offset),
45  mOuterDiameter(outerDiameter) {};
47 
48  private:
49  void ResetVars() {
50  mOffset = mOuterDiameter = 0.0;
51  };
52 
53  Double_t mOffset; // offset along the beam line
54  Double_t mOuterDiameter; // outer diameter
55 
57 };
58 
59 class BeamPipeElement: public TObject
60 {
61  friend class BeamPipeGeoParData;
62 
63  public:
64  enum SwapSign {NoSwap, Swap};
65 
67  BeamPipeElement(TString &material, double thickness):
68  mMaterial(material), mThickness(thickness), mIpElement(false), mSwapped(NoSwap), mAccuOffset(0.0) {};
69  BeamPipeElement(BeamPipeElement *source, Bool_t ipElement = false, SwapSign swapped = NoSwap) {
70  *this = *source;
71  mIpElement = ipElement;
72  mSwapped = swapped;
73  };
75 
76  void AddSection(double offset, double outerDiameter) {
77  mSections.push_back(new BeamPipeSection(offset, outerDiameter));
78  };
79 
80  private:
81  void ResetVars() {
82  mThickness = mAccuOffset = 0.0;
83  mSwapped = NoSwap;
84 
85  mIpElement = false;
86  };
87 
89  if (!mSections.size()) return 0;
90 
91  return /*mSwapped == Swap ? mSections[mSections.size()-1] :*/ mSections[0];
92  };
94  if (!mSections.size()) return 0;
95 
96  return mSwapped == Swap ? mSections[mSections.size()-1] : mSections[0];
97  };
99  if (!mSections.size()) return 0;
100 
101  return /*mSwapped == Swap ? mSections[0] :*/ mSections[mSections.size()-1];
102  };
104  if (!mSections.size()) return 0;
105 
106  return mSwapped == Swap ? mSections[0] : mSections[mSections.size()-1];
107  };
108 #if 0
109  const BeamPipeSection* GetOrderedSection(unsigned id) const {
110  if (id >= mSections.size()) return 0;
111 
112  return mSwapped == Swap ? mSections[mSections.size()-id-1] : mSections[id];
113  };
114 #endif
115 
116  double GetLength() const {
117  return fabs(GetFirstSection()->mOffset - GetLastSection()->mOffset);
118  };
119 
120  TString mMaterial; // material in geometry/media.geo
121  Double_t mThickness; // thickness
122 
123  // It may be more convenient to define local section coordinates
124  // in Z+ sequence, even for beam pipe pieces at negative Z;
125  SwapSign mSwapped; // natural of Z-swapped section order
126 
127  Bool_t mIpElement; // element at the IP location
128 
129  // Sections which define the ROOT TGeoPcon polycone;
130  std::vector<BeamPipeSection*> mSections; // sections to define TGeoPcon
131 
132  // Transient variable: accumulated offset;
133  Double_t mAccuOffset;
134 
136 };
137 
139 {
140  private:
141 
142  public:
143  BeamPipeGeoParData(int version = -1, int subVersion = 0):
144  EicGeoParData("BEAMPIPE", version, subVersion), mIpElementID(-1) {};
146 
147  // Pieces will go along the beam line just in the order of AddElement()
148  // calls in beampipe.C;
149  void AddElement(BeamPipeElement *element,
151  // Yes, want to create an independent copy (and prevent further access);
152  mElements.push_back(new BeamPipeElement(element, BeamPipeElement::NoSwap, swapped));
153  };
154  void AddIpElement(BeamPipeElement *element) {
155  mElements.push_back(new BeamPipeElement(element, true));
156  };
157 
158  //void Print(const char *option = 0) const {};
159  int ConstructGeometry();
160 
161  private:
162  bool CheckGeometry();
163 
164  Int_t mIpElementID;
165 
166  // Ordered along the hadron beam direction; element '0' is centered
167  // around the IP accoring to its section offsets; others are attached with proper
168  // offsets which are calculated on-the-fly (so that pieces can for convenience be
169  // defined with local offsets of 0.0 or whatever else); units are [mm];
170  std::vector<BeamPipeElement*> mElements; // beam pipe elements in this order
171 
173 };
174 
175 #endif