KaliVeda
Toolkit for HIC analysis
KVFAZIA3D.cpp
1 //Author: gruyer,,,
2 
3 #include "KVFAZIA3D.h"
4 #include "KVUnits.h"
5 #include "KVFAZIA3DBlock.h"
6 #include <map>
7 
8 #include <KVDataSet.h>
9 
11 
12 // BEGIN_HTML <!--
14 /* -->
15 <h2>KVFAZIA3D</h2>
16 <h4>description of the FAZIA-12B demonstrator</h4>
17 <!-- */
18 // --> END_HTML
20 
21 
22 
26  : KVFAZIA()
27 {
28  // Default constructor
29  SetTitle(ClassName());
30 }
31 
32 
33 
78 
79 void KVFAZIA3D::MakeConfigFile(const char* filename)
80 {
81 // Read a csv file with the quartet coordinates to generate the FAZIA3D.Quartet.Position.env file
82 // used to build the FAZIA detector.
83 //
84 // the csv file structure should be (no header):
85 // quartet_index,corner_index,quartet_index*100+corner_index,X,Y(Z),Z
86 //
87 // example for the first quartet of Block 0:
88 // 1,11,111,-66.8,887.2,114.3
89 // 1,12,112,-46.8,887.9,114.2
90 // 1,13,113,-47.0,889.9,94.3
91 // 1,14,114,-67.0,889.2,94.4
92 // 1,21,121,-44.6,888.0,114.2
93 // 1,22,122,-24.6,888.7,114.0
94 // 1,23,123,-24.8,890.7,94.2
95 // 1,24,124,-44.8,890.0,94.3
96 // 1,31,131,-44.8,890.2,92.1
97 // 1,32,132,-24.8,890.9,92.0
98 // 1,33,133,-25.0,893.0,72.1
99 // 1,34,134,-45.0,892.3,72.2
100 // 1,41,141,-67.0,889.5,92.2
101 // 1,42,142,-47.0,890.2,92.1
102 // 1,43,143,-47.2,892.2,72.2
103 // 1,44,144,-67.2,891.5,72.3
104 // example for the last quartet of Block 11:
105 // 114,11,11411,-207.0,876.4,-19.4
106 // 114,12,11412,-187.3,880.0,-19.6
107 // 114,13,11413,-187.4,879.3,-39.6
108 // 114,14,11414,-207.0,875.7,-39.4
109 // 114,21,11421,-185.2,880.4,-19.6
110 // 114,22,11422,-165.5,884.1,-19.8
111 // 114,23,11423,-165.5,883.3,-39.8
112 // 114,24,11424,-185.2,879.7,-39.6
113 // 114,31,11431,-185.2,879.6,-41.8
114 // 114,32,11432,-165.5,883.2,-42.0
115 // 114,33,11433,-165.6,882.5,-62.0
116 // 114,34,11434,-185.3,878.8,-61.8
117 // 114,41,11441,-207.0,875.6,-41.6
118 // 114,42,11442,-187.4,879.2,-41.8
119 // 114,43,11443,-187.4,878.4,-61.8
120 // 114,44,11444,-207.1,874.8,-61.6
121 //
122 // The output file contains, for each quartet, the center coordinates (X,Y,Z)
123 // and the three rotation angles (Psi,Theta,Phi)
124 
125  KVFileReader rd;
127 
128  KVEnv fout;
129  fout.AddCommentLine("File containing the position and orientation of the FAZIA quartets");
130  fout.AddCommentLine("as measured by the GANIL geometers");
131  fout.AddCommentLine(Form("Created from '%s' using KVFAZIA3D::MakeConfigFile()", filename));
132 
133  std::map<int, TVector3> pos;
134 
135  while (rd.IsOK()) {
136  rd.ReadLine(",");
137  if (!rd.GetNparRead()) continue;
138  int idp = rd.GetReadPar(2).Atoi();
139  int idt = idp / 10;
140  int idq = idt / 10;
141  pos[idp] = {rd.GetReadPar(5).Atof() / 10, rd.GetReadPar(3).Atof() / 10, rd.GetReadPar(4).Atof() / 10}; //-89.74
142  }
143 
144  for (int bb = 0; bb < 12; bb++) {
145  for (auto qq : {
146  1, 2, 3, 4
147  }) {
148  int id = 10 * bb + qq;
149 
150  // vector to the external corners of the silicon detectors
151  TVector3 v1 = pos[id * 100 + 11];
152  TVector3 v2 = pos[id * 100 + 22];
153  TVector3 v3 = pos[id * 100 + 33];
154  TVector3 v4 = pos[id * 100 + 44];
155 
156  // vector to the center of the quartet for translation
157  TVector3 center = v1 + v2 + v3 + v4;
158  center *= .25;
159  fout.SetValue(Form("B%03d-Q%d.X", bb, qq), center.X());
160  fout.SetValue(Form("B%03d-Q%d.Y", bb, qq), center.Y());
161  fout.SetValue(Form("B%03d-Q%d.Z", bb, qq), center.Z());
162 
163  // bring the quartet center at (0,0,0)
164  v1 -= center;
165  v2 -= center;
166  v3 -= center;
167  v4 -= center;
168 
169  TVector3 e1 = v2 - v1;
170  TVector3 e2 = v3 - v2;
171 
172  // vector normal to the quartet surface for rotation
173  TVector3 normal = e1.Cross(e2).Unit();
174 
175  double theta = normal.Theta() * TMath::RadToDeg();
176  double phi = normal.Phi() * TMath::RadToDeg();
177 
178  // bring the quartet in the XY plane
179  TRotation rr;
180  rr.RotateZ(-normal.Phi());
181  TRotation rr2;
182  rr2.RotateY(-normal.Theta());
183 
184  v1 = rr * v1;
185  v2 = rr * v2;
186  v1 = rr2 * v1;
187  v2 = rr2 * v2;
188 
189  // recompute the upper edge of the quartet to find the final rotation
190  e1 = v2 - v1;
191  TVector3 oy(0, 1, 0);
192 
193  // compute the final rotation angle
194  double psi = TMath::Sign(oy.Angle(e1), e1.X()) * TMath::RadToDeg();
195  fout.SetValue(Form("B%03d-Q%d.Psi", bb, qq), -psi);
196  fout.SetValue(Form("B%03d-Q%d.Theta", bb, qq), theta);
197  fout.SetValue(Form("B%03d-Q%d.Phi", bb, qq), phi);
198  }
199  }
200  fout.WriteFile("FAZIA3D.Quartet.Position.env");
201 
202 }
203 
204 
205 
208 
210 {
211  //defined configuration of the blocks
212  fNblocks = KVBase::GetDataSetEnv(fDataSet, "FAZIA.NBlocks", 12.0);
213  fFDist = KVBase::GetDataSetEnv(fDataSet, "FAZIA.DistanceZ", 100.0);
214  SetGeometryImportParameters(.25, 1, 1, 0, 14, 360,
215  KVBase::GetDataSetEnv(fDataSet, "FAZIA.DistanceX", 0.0),
216  KVBase::GetDataSetEnv(fDataSet, "FAZIA.DistanceY", 0.0),
217  fFDist - 100.0);
218 }
219 
220 
221 
222 
223 
240 
242 {
243  // Build the FAZIA demonstrator geometry.
244  //
245  // Distance from target and minimum polar angle between innermost blocks
246  // can be changed for different datasets using:
247  //
248  // [dataset].FAZIA.DistanceZ: 95.4
249  // [dataset].FAZIA.DistanceX: 1.
250  // [dataset].FAZIA.DistanceY: 0.
251  //
252  // Number of blocks in demonstrator, their numbers, and positions can be modified for
253  // different datasets using the following environment variables:
254  //
255  // [dataset].FAZIA.NBlocks: 12
256  // [dataset].FAZIA.BlockNumbers: 0,1,2,3,4,5,6,7,8,9,10,11
257  // [dataset].FAZIA.BlockPositions: 0,1,2,3,4,5,6,7,8,9,10,11
258 
259  Info("BuildFAZIA", "Exact geometry using 'FAZIA3D.Quartet.Position.env', %f cm from target.", fFDist);
260 
262 
263  // block numbering and positions
264  auto block_numbers = KVBase::GetDataSetEnv<KVString>(fDataSet, "FAZIA.BlockNumbers", "0,1,2,3,4,5,6,7,8,9,10,11");
265  block_numbers.Begin(",");
266  auto block_positions = KVBase::GetDataSetEnv<KVString>(fDataSet, "FAZIA.BlockPositions", "0,1,2,3,4,5,6,7,8,9,10,11");
267  block_positions.Begin(",");
268 
269  for (Int_t i = 0; i < fNblocks; i += 1) {
270 
271  Int_t block_number = block_numbers.Next().Atoi();
272  Int_t bb = block_positions.Next().Atoi();
273 
274  KVFAZIA3DBlock* block = new KVFAZIA3DBlock(block_number);
275  block->Build();
276 
277  TGeoTranslation final_trans;
278  final_trans.SetDz(fFDist * KVUnits::cm);
279  if (KVBase::GetDataSetEnv(fDataSet, "FAZIETO.DistanceX", 0.0) != 0.) final_trans.SetDx(KVBase::GetDataSetEnv(fDataSet, "FAZIETO.DistanceX", 0.0));
280  if (KVBase::GetDataSetEnv(fDataSet, "FAZIETO.DistanceY", 0.0) != 0.) final_trans.SetDy(KVBase::GetDataSetEnv(fDataSet, "FAZIETO.DistanceY", 0.0));
281 
282  TGeoHMatrix* ph = new TGeoHMatrix(final_trans);
283  top->AddNode(block, block_number, ph);
284  }
285 
286 }
287 
288 
289 
int Int_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
R__EXTERN TGeoManager * gGeoManager
char * Form(const char *fmt,...)
static ValType GetDataSetEnv(const KVString &dataset, const KVString &type, const ValType &defval={})
Definition: KVBase.h:305
Extension of TEnv to allow the writing of comments in the file.
Definition: KVEnv.h:18
void AddCommentLine(const Char_t *line)
Definition: KVEnv.cpp:70
Int_t WriteFile(const char *fname, EEnvLevel level=kEnvAll) override
Definition: KVEnv.cpp:140
Geometry of 16-telescope FAZIA block where each quartet is placed in absolute using [DATASET]/FAZIA3D...
void Build() override
FAZIA 12-block demonstrator.
Definition: KVFAZIA3D.h:16
void GetGeometryParameters() override
defined configuration of the blocks
Definition: KVFAZIA3D.cpp:209
static void MakeConfigFile(const char *filename)
Definition: KVFAZIA3D.cpp:79
void BuildFAZIA() override
Definition: KVFAZIA3D.cpp:241
Description of a FAZIA detector geometry.
Definition: KVFAZIA.h:33
Double_t fFDist
distance of FAZIA detectors from target (in cm)
Definition: KVFAZIA.h:36
void SetGeometryImportParameters(Double_t dt=0.25, Double_t dp=1.0, Double_t tmin=2., Double_t pmin=0, Double_t tmax=20., Double_t pmax=360., Double_t xorg=0, Double_t yorg=0, Double_t zorg=0)
Definition: KVFAZIA.h:243
Int_t fNblocks
number of blocks
Definition: KVFAZIA.h:38
Handle reading columns of numeric data in text files.
Definition: KVFileReader.h:121
ReadStatus ReadLine(const KVString &pattern="")
Definition: KVFileReader.h:243
Int_t GetNparRead() const
Definition: KVFileReader.h:325
Bool_t IsOK()
Definition: KVFileReader.h:231
KVString GetReadPar(Int_t pos) const
Definition: KVFileReader.h:342
Bool_t OpenFileToRead(const KVString &filename)
Definition: KVFileReader.h:210
TString fDataSet
name of associated dataset, used with MakeMultiDetector()
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
TGeoVolume * GetTopVolume() const
void SetDy(Double_t dy) override
void SetDz(Double_t dz) override
void SetDx(Double_t dx) override
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
virtual void Info(const char *method, const char *msgfmt,...) const
TRotation & RotateY(Double_t)
TRotation & RotateZ(Double_t)
Int_t Atoi() const
Double_t Atof() const
Double_t Z() const
Double_t Phi() const
Double_t Y() const
Double_t X() const
TVector3 Unit() const
Double_t Angle(const TVector3 &) const
Double_t Theta() const
TVector3 Cross(const TVector3 &) const
RooCmdArg ClassName(const char *name)
Double_t Sign(Double_t a, Double_t b)
constexpr Double_t RadToDeg()
v2
v4
v3
v1
ClassImp(TPyArg)