31{
32 MsgStream log(msgSvc, "buildElStraightSections");
33
34 GeoGenfun::Sqrt Sqrt;
35 GeoGenfun::ATan ATan;
36
41
42 double Moth_Z_min = (*barrelGeometryRec)[0]->getDouble("ZMIN")*SYSTEM_OF_UNITS::cm;
43 double Moth_Z_max = (*barrelGeometryRec)[0]->getDouble("ZMAX")*SYSTEM_OF_UNITS::cm;
44 double Moth_inner_radius = (*barrelGeometryRec)[0]->getDouble("RMIN")*SYSTEM_OF_UNITS::cm;
45
46
47 int Nbrt = (*barrelGeometryRec)[0]->getInt("NBRT");
48
49
50 double Bar_Z_min = Moth_Z_min;
51 double Bar_Z_max = Moth_Z_max;
52
53 double Bar_Rcmx = (*barrelGeometryRec)[0]->getDouble("RMINHIGHZ")*SYSTEM_OF_UNITS::cm;
54
55
56
57
58
59
60 double Rhocen[15], Phicen[15], Delta[15], deltay[15], deltax[15], TetaTrans[15];
61 for (int idat=0; idat<15; idat++) {
62 std::string strIdat = std::to_string(idat);
63 Rhocen[idat] = (*barrelGeometryRec)[0]->getDouble("RHOCEN_"+strIdat)*SYSTEM_OF_UNITS::cm;
64 Phicen[idat] = (*barrelGeometryRec)[0]->getDouble("PHICEN_"+strIdat)*SYSTEM_OF_UNITS::deg;
65 Delta[idat] = (*barrelGeometryRec)[0]->getDouble("DELTA_"+strIdat)*SYSTEM_OF_UNITS::deg;
66 if(idat == 14) {
67 Delta[idat] = (90.0) * SYSTEM_OF_UNITS::deg;
68 }
69
70
71
72
73 if (sagging) {
74 deltay[idat] = (*barrelSaggingRec)[0]->getDouble("SAG_"+strIdat)*SYSTEM_OF_UNITS::cm;
75 deltax[idat] = (*barrelSaggingRec)[0]->getDouble("SAG_"+strIdat+"_X")*SYSTEM_OF_UNITS::cm;
76 }
77 else {
78 deltay[idat]=0.;
79 deltax[idat]=0.;
80 }
81
82
83 double etaTrans = (*barrelEtaTransRec)[idat]->getDouble("ETATRANS");
84 TetaTrans[idat] = 2.*
atan(
exp(-etaTrans));
85 }
86
87
88 int checkParity = (Phicen[0]<0. ? 1 : 0);
89
90
91 int Ncell = (*barrelGeometryRec)[0]->getInt("NCELMX");
92 int Nabsorber = (Ncell==64) ? Ncell + 1 : Ncell;
93 int Nelectrode = Ncell;
94
95
96 double z1 = (*barrelGeometryRec)[0]->getDouble("G10FRONTDELTAZ")*SYSTEM_OF_UNITS::cm + Moth_Z_min;
97
98 const double r1 = Moth_inner_radius
99 + (*barrelGeometryRec)[0]->getDouble("XEL1")*SYSTEM_OF_UNITS::cm
100 + (*barrelGeometryRec)[0]->getDouble("XG10")*SYSTEM_OF_UNITS::cm;
101
102 const double r2 = (*barrelGeometryRec)[0]->getDouble(
"RMINHIGHZ")*SYSTEM_OF_UNITS::cm;
103 const double inv_r2_r1 = 1. / (
r2-
r1);
104
105 {
106
107 double Thgl = (*barrelGeometryRec)[0]->getDouble("THGL")*SYSTEM_OF_UNITS::cm;
108 double Thfe = (*barrelGeometryRec)[0]->getDouble("THFE")*SYSTEM_OF_UNITS::cm;
109 double Thpb = (*barrelGeometryRec)[0]->getDouble("THPB")*SYSTEM_OF_UNITS::cm;
110 double Thcu = (*barrelGeometryRec)[0]->getDouble("THCU")*SYSTEM_OF_UNITS::cm;
111 double Thfg = (*barrelGeometryRec)[0]->getDouble("THFG")*SYSTEM_OF_UNITS::cm;
112
113 double Contract = (*coldContractionRec)[0]->getDouble("ABSORBERCONTRACTION");
114
115 double Thce = (Thpb+Thgl+Thfe)*Contract;
116 double Thel = Thcu+Thfg;
117
118 double Zmin = Bar_Z_min;
119 double Zmax = Bar_Z_max;
120 double Along[14];
121
122 double Zcp1l[14],Zcp1h[14],Zcp2l[14],Zcp2h[14];
123 double Rhol[14],Rhoh[14];
124
125 double safety_along = 0.007*SYSTEM_OF_UNITS::mm;
126
127
128 double Cenx[15]={0}, Ceny[15]={0} ;
129 for (int jf=0; jf<(Nbrt+1); jf++) {
130 Cenx[jf] = Rhocen[jf]*
cos(Phicen[jf]);
131 Ceny[jf] = Rhocen[jf]*
sin(Phicen[jf]);
132 }
133
134
135 double Rint = (*barrelGeometryRec)[0]->getDouble("RINT")*SYSTEM_OF_UNITS::cm;
136 for (int jl=0; jl<Nbrt; jl++) {
137 double Adisc2 = (Cenx[jl+1]-Cenx[jl])*(Cenx[jl+1]-Cenx[jl])+
138 (Ceny[jl+1]-Ceny[jl])*(Ceny[jl+1]-Ceny[jl]);
139 double Along2 = Adisc2 - 4.*Rint*Rint;
140 Along[jl] = sqrt(Along2);
141
142 double ddelta =
M_PI/2.-Delta[jl];
143
144 if (checkParity==0) {
145 if (jl%2==1) {
146 ddelta=-1.*ddelta;
147 }
148 } else {
149 if (jl%2==0) {
150 ddelta=-1.*ddelta;
151 }
152 }
153 double xlong=Along[jl]-2.*safety_along;
154 double x2=0.5*(Cenx[jl+1]+Cenx[jl])+0.5*xlong*
cos(ddelta);
155 double y2=0.5*(Ceny[jl+1]+Ceny[jl])+0.5*xlong*
sin(ddelta);
156 double x1=0.5*(Cenx[jl+1]+Cenx[jl])-0.5*xlong*
cos(ddelta);
157 double y1=0.5*(Ceny[jl+1]+Ceny[jl])-0.5*xlong*
sin(ddelta);
158 Rhol[jl] = sqrt(x1*x1+y1*y1);
159 Rhoh[jl] = sqrt(x2*x2+y2*y2);
160 Zcp1l[jl] = Rhol[jl]/
tan(TetaTrans[jl]);
161 Zcp1h[jl] = Rhoh[jl]/
tan(TetaTrans[jl+1]);
162 if (Rhol[jl] < r2) {
163 Zcp2l[jl] = z1 + (Rhol[jl]-
r1)*inv_r2_r1*(Moth_Z_max-z1);
164 }
165 else {
166 Zcp2l[jl]=Moth_Z_max;
167 }
168 if (Rhoh[jl] < r2) {
169 Zcp2h[jl] = z1 + (Rhoh[jl]-
r1)*inv_r2_r1*(Moth_Z_max-z1);
170 }
171 else {
172 Zcp2h[jl]=Moth_Z_max;
173 }
174 }
175
176 double Psi = (*barrelGeometryRec)[0]->getDouble("ALFA")*SYSTEM_OF_UNITS::deg;
177 double Gama0 = (*barrelGeometryRec)[0]->getDouble("PHIFIRST");
179
180 GeoGenfun::Variable icopy;
181 GeoGenfun::GENFUNCTION Game = Gama0 + Psi/2 +
Alfa*icopy;
182 GeoGenfun::GENFUNCTION Gama = Gama0 +
Alfa*icopy;
183
184 GeoStraightAccSection* gStraightElectrodes{nullptr};
185 GeoStraightAccSection* gStraightAbsorbers{nullptr};
186
187
188
189
190
191
192 double safety_zlen=0.050*SYSTEM_OF_UNITS::mm;
193
194 for(int irl=0; irl<Nbrt; irl++) {
195 int iparit;
196
197 if (checkParity==0) {
198 iparit= (1-2*(irl%2));
199 }
200 else {
201 iparit=(2*(irl%2)-1);
202 }
203
204
205
206 int ndivi=1;
207 if (Rhocen[irl] < Bar_Rcmx && Rhocen[irl+1] > Bar_Rcmx) {
208 ndivi=2;
209 }
210
211 for (int idivi=0;idivi<ndivi;idivi++) {
212
213
214 double bl1,tl1;
216 if (ndivi==1) {
217 bl1 = (std::min(Zcp2l[irl],Zmax)-Zmin)/2.;
218 tl1 = (std::min(Zcp2h[irl],Zmax)-Zmin)/2.;
220 }
221 else {
222 if (idivi==0) {
223 bl1 = (std::min(Zcp2l[irl],Zmax)-Zmin)/2.;
224 tl1 = (
Zmax-Zmin)/2.;
225 frac=(Bar_Rcmx-Rhol[irl])/(Rhoh[irl]-Rhol[irl]);
226 }
227 else {
228 bl1 = (
Zmax-Zmin)/2.;
229 tl1 = (
Zmax-Zmin)/2.;
230 frac=(Rhoh[irl]-Bar_Rcmx)/(Rhoh[irl]-Rhol[irl]);
231 }
232 }
233
234 tl1=tl1-safety_zlen;
235 bl1=bl1-safety_zlen;
236
237
238 {
239
240 double Dz = Thce/2.;
241
242
243 GeoGenfun::GENFUNCTION x1a =
LArGeo::Fx(irl+0., Gama, Cenx, Ceny)
246 GeoGenfun::GENFUNCTION x2a =
LArGeo::Fx(irl+1., Gama, Cenx, Ceny)
249 GeoGenfun::GENFUNCTION y1a =
LArGeo::Fy(irl+0., Gama, Cenx, Ceny)
252 GeoGenfun::GENFUNCTION y2a =
LArGeo::Fy(irl+1., Gama, Cenx, Ceny)
255 GeoGenfun::GENFUNCTION
dx = x2a - x1a;
256 GeoGenfun::GENFUNCTION
dy = y2a - y1a;
257
258
259
260 GeoGenfun::GENFUNCTION Da = Sqrt ( dx*dx + dy*dy );
261 GeoGenfun::GENFUNCTION da = Sqrt ( (Da - 2.*Rint)*(Da + 2.*Rint) );
262
263
264 GeoGenfun::GENFUNCTION cosalfa = (da*
dx -iparit*2.*Rint*
dy)/Da/Da;
265 GeoGenfun::GENFUNCTION sinalfa = (da*
dy +iparit*2.*Rint*
dx)/Da/Da;
266 GeoGenfun::GENFUNCTION newalpha =
LArGeo::ATan2(sinalfa,cosalfa);
267
268 GeoGenfun::GENFUNCTION
h1 = da/2. *
frac - .007*SYSTEM_OF_UNITS::mm;
269
270
271
272
273 double Xb1,Xt1;
274 if (ndivi==1) {
275 Xb1 = (Zcp1l[irl]-Zmin)/2.;
276 Xt1 = (Zcp1h[irl]-Zmin)/2.;
277 }
278 else {
279 double xfrac=(Bar_Rcmx-Rhol[irl])/(Rhoh[irl]-Rhol[irl]);
280 if (idivi==0) {
281 Xb1 = (Zcp1l[irl]-Zmin)/2.;
282 Xt1 = (xfrac*Zcp1h[irl]+(1.-xfrac)*Zcp1l[irl]-Zmin)/2.;
283 }
284 else {
285 Xb1 = (xfrac*Zcp1h[irl]+(1.-xfrac)*Zcp1l[irl]-Zmin)/2.;
286 Xt1 = (Zcp1h[irl]-Zmin)/2.;
287 }
288 }
289
290
291 double Xt2 = tl1-Xt1;
292 double Xb2 = bl1-Xb1;
293
294 Xt2 = Xt2 -0.007*SYSTEM_OF_UNITS::mm;
295 Xb2 = Xb2 -0.007*SYSTEM_OF_UNITS::mm;
296
297
298 GeoGenfun::GENFUNCTION
alpha = ATan(0.5*(bl1-tl1)/h1);
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314 GeoGenfun::GENFUNCTION alfrot = -
M_PI/2. - newalpha;
315
316 GeoGenfun::GENFUNCTION Xcd = (x1a + x2a)/2. + (2.*idivi-1.)*(1.-
frac)*da/2.*cosalfa;
317 GeoGenfun::GENFUNCTION Ycd = (y1a + y2a)/2. + (2.*idivi-1.)*(1.-
frac)*da/2.*sinalfa;
318 GeoGenfun::GENFUNCTION Zcd = GeoGenfun::FixedConstant(Zmin+(tl1+bl1)/2.+safety_zlen);
319
320 GeoXF::TRANSFUNCTION TX =
321 GeoXF::Pow(GeoTrf::TranslateX3D(1.0),Xcd) *
322 GeoXF::Pow(GeoTrf::TranslateY3D(1.0),Ycd) *
323 GeoXF::Pow(GeoTrf::TranslateZ3D(1.0),Zcd) *
324 GeoXF::Pow(GeoTrf::RotateZ3D(1.0),-alfrot)*
325 GeoTrf::RotateY3D(-90*SYSTEM_OF_UNITS::deg);
326
328
331 if (sagging) {
332 if (!gStraightAbsorbers) {
333 gStraightAbsorbers = new GeoStraightAccSection();
334 }
340 }
341 else {
342 if (!gStraightAbsorbers) {
343 gStraightAbsorbers = new GeoStraightAccSection();
344 }
347 break;
348 }
349 }
350 }
351
352
353 {
354
355 double Dze = Thel/2.;
356
357
358 GeoGenfun::GENFUNCTION x1e =
LArGeo::Fx(irl+0., Game, Cenx, Ceny)
361 GeoGenfun::GENFUNCTION x2e =
LArGeo::Fx(irl+1., Game, Cenx, Ceny)
364 GeoGenfun::GENFUNCTION y1e =
LArGeo::Fy(irl+0., Game, Cenx, Ceny)
367 GeoGenfun::GENFUNCTION y2e =
LArGeo::Fy(irl+1., Game, Cenx, Ceny)
370 GeoGenfun::GENFUNCTION dxe = x2e - x1e;
371 GeoGenfun::GENFUNCTION dye = y2e - y1e;
372
373 GeoGenfun::GENFUNCTION De = Sqrt ( dxe*dxe + dye*dye );
374 GeoGenfun::GENFUNCTION de = Sqrt ( (De - 2.*Rint)*(De + 2.*Rint) );
375
376
377 GeoGenfun::GENFUNCTION cosalfae = (de*dxe -iparit*2.*Rint*dye)/De/De;
378 GeoGenfun::GENFUNCTION sinalfae = (de*dye +iparit*2.*Rint*dxe)/De/De;
379 GeoGenfun::GENFUNCTION newalphe =
LArGeo::ATan2(sinalfae,cosalfae);
380
381
382
383
384 GeoGenfun::GENFUNCTION alfrote = -
M_PI/2. - newalphe;
385
386 GeoGenfun::GENFUNCTION Xcde = (x1e + x2e)/2.+ (2.*idivi-1.)*(1.-
frac)*de/2.*cosalfae;
387 GeoGenfun::GENFUNCTION Ycde = (y1e + y2e)/2.+ (2.*idivi-1.)*(1.-
frac)*de/2.*sinalfae;
388 GeoGenfun::GENFUNCTION Zcde = GeoGenfun::FixedConstant(Zmin+(tl1+bl1)/2.+safety_zlen);
389
390 GeoGenfun::GENFUNCTION h1e = de/2.*
frac - .007*SYSTEM_OF_UNITS::mm;
391 GeoGenfun::GENFUNCTION alpha_e = ATan(0.5*(bl1-tl1)/h1e);
392
393 GeoXF::TRANSFUNCTION TXE =
394 GeoXF::Pow(GeoTrf::TranslateX3D(1.0),Xcde) *
395 GeoXF::Pow(GeoTrf::TranslateY3D(1.0),Ycde) *
396 GeoXF::Pow(GeoTrf::TranslateZ3D(1.0),Zcde) *
397 GeoXF::Pow(GeoTrf::RotateZ3D(1.0),-alfrote)*
398 GeoTrf::RotateY3D(-90*SYSTEM_OF_UNITS::deg);
399
401
402 GeoIntrusivePtr<GeoTrap> trap{
new GeoTrap(Dze,0.,0.,h1e(
instance),tl1,bl1,alpha_e(
instance),
404 if (sagging) {
405 if (!gStraightElectrodes) {
406 gStraightElectrodes = new GeoStraightAccSection();
407 }
413
414 }
415 else {
416 if (!gStraightElectrodes) {
417 gStraightElectrodes = new GeoStraightAccSection();
418 }
421 break;
422 }
423 }
424 }
425 }
426 }
427
428 if(!
detStore->record(gStraightElectrodes,
"STRAIGHTELECTRODES").isSuccess()) {
429 log << MSG::FATAL <<
"Cannot store STRAIGHTELECTRODES structure" <<
endmsg;
430 return StatusCode::FAILURE;
431 }
432
433 if(!
detStore->record(gStraightAbsorbers,
"STRAIGHTABSORBERS").isSuccess()) {
434 log << MSG::FATAL <<
"Cannot store STRAIGHTABSORBERS structure" <<
endmsg;
435 return StatusCode::FAILURE;
436 }
437 }
438 return StatusCode::SUCCESS;
439}
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
const double & YCent(int stackid, int cellid) const
void setHalfLength(int stackid, double halfLength)
const double & Cosu(int stackid, int cellid) const
const double & HalfLength(int stackid, int cellid) const
void setTransform(int stackid, GeoXF::TRANSFUNCTION TXE)
const double & Sinu(int stackid, int cellid) const
const double & XCent(int stackid, int cellid) const
virtual IRDBRecordset_ptr getRecordsetPtr(const std::string &node, const std::string &tag, const std::string &tag2node="", const std::string &connName="ATLASDD")=0
Provides access to the Recordset object containing HVS-tagged data.
GeoGenfun::FunctionNoop Fy(double r, GeoGenfun::GENFUNCTION G, const double Cenx[], const double Ceny[])
GeoGenfun::FunctionNoop ATan2(GeoGenfun::GENFUNCTION y, GeoGenfun::GENFUNCTION x)
GeoGenfun::FunctionNoop Fx(double r, GeoGenfun::GENFUNCTION G, const double Cenx[], const double Ceny[])
GeoGenfun::FunctionNoop Del1(GeoGenfun::GENFUNCTION G)
GeoGenfun::FunctionNoop Del2(GeoGenfun::GENFUNCTION G)