32 MsgStream log(msgSvc,
"buildElStraightSections");
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;
47 int Nbrt = (*barrelGeometryRec)[0]->getInt(
"NBRT");
50 double Bar_Z_min = Moth_Z_min;
51 double Bar_Z_max = Moth_Z_max;
53 double Bar_Rcmx = (*barrelGeometryRec)[0]->getDouble(
"RMINHIGHZ")*SYSTEM_OF_UNITS::cm;
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;
67 Delta[idat] = (90.0) * SYSTEM_OF_UNITS::deg;
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;
83 double etaTrans = (*barrelEtaTransRec)[idat]->getDouble(
"ETATRANS");
84 TetaTrans[idat] = 2.*atan(exp(-etaTrans));
88 int checkParity = (Phicen[0]<0. ? 1 : 0);
91 int Ncell = (*barrelGeometryRec)[0]->getInt(
"NCELMX");
92 int Nabsorber = (Ncell==64) ? Ncell + 1 : Ncell;
93 int Nelectrode = Ncell;
96 double z1 = (*barrelGeometryRec)[0]->getDouble(
"G10FRONTDELTAZ")*SYSTEM_OF_UNITS::cm + Moth_Z_min;
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;
102 const double r2 = (*barrelGeometryRec)[0]->getDouble(
"RMINHIGHZ")*SYSTEM_OF_UNITS::cm;
103 const double inv_r2_r1 = 1. / (r2-r1);
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;
113 double Contract = (*coldContractionRec)[0]->getDouble(
"ABSORBERCONTRACTION");
115 double Thce = (Thpb+Thgl+Thfe)*Contract;
116 double Thel = Thcu+Thfg;
118 double Zmin = Bar_Z_min;
119 double Zmax = Bar_Z_max;
122 double Zcp1l[14],Zcp1h[14],Zcp2l[14],Zcp2h[14];
123 double Rhol[14],Rhoh[14];
125 double safety_along = 0.007*SYSTEM_OF_UNITS::mm;
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]);
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);
142 double ddelta =
M_PI/2.-Delta[jl];
144 if (checkParity==0) {
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]);
163 Zcp2l[jl] = z1 + (Rhol[jl]-r1)*inv_r2_r1*(Moth_Z_max-z1);
166 Zcp2l[jl]=Moth_Z_max;
169 Zcp2h[jl] = z1 + (Rhoh[jl]-r1)*inv_r2_r1*(Moth_Z_max-z1);
172 Zcp2h[jl]=Moth_Z_max;
176 double Psi = (*barrelGeometryRec)[0]->getDouble(
"ALFA")*SYSTEM_OF_UNITS::deg;
177 double Gama0 = (*barrelGeometryRec)[0]->getDouble(
"PHIFIRST");
180 GeoGenfun::Variable icopy;
181 GeoGenfun::GENFUNCTION Game = Gama0 + Psi/2 +
Alfa*icopy;
182 GeoGenfun::GENFUNCTION Gama = Gama0 +
Alfa*icopy;
192 double safety_zlen=0.050*SYSTEM_OF_UNITS::mm;
194 for(
int irl=0; irl<Nbrt; irl++) {
197 if (checkParity==0) {
198 iparit= (1-2*(irl%2));
201 iparit=(2*(irl%2)-1);
207 if (Rhocen[irl] < Bar_Rcmx && Rhocen[irl+1] > Bar_Rcmx) {
211 for (
int idivi=0;idivi<ndivi;idivi++) {
217 bl1 = (std::min(Zcp2l[irl],Zmax)-Zmin)/2.;
218 tl1 = (std::min(Zcp2h[irl],Zmax)-Zmin)/2.;
223 bl1 = (std::min(Zcp2l[irl],Zmax)-Zmin)/2.;
224 tl1 = (Zmax-Zmin)/2.;
225 frac=(Bar_Rcmx-Rhol[irl])/(Rhoh[irl]-Rhol[irl]);
228 bl1 = (Zmax-Zmin)/2.;
229 tl1 = (Zmax-Zmin)/2.;
230 frac=(Rhoh[irl]-Bar_Rcmx)/(Rhoh[irl]-Rhol[irl]);
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;
260 GeoGenfun::GENFUNCTION Da = Sqrt ( dx*dx + dy*dy );
261 GeoGenfun::GENFUNCTION da = Sqrt ( (Da - 2.*Rint)*(Da + 2.*Rint) );
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);
268 GeoGenfun::GENFUNCTION h1 = da/2. * frac - .007*SYSTEM_OF_UNITS::mm;
275 Xb1 = (Zcp1l[irl]-Zmin)/2.;
276 Xt1 = (Zcp1h[irl]-Zmin)/2.;
279 double xfrac=(Bar_Rcmx-Rhol[irl])/(Rhoh[irl]-Rhol[irl]);
281 Xb1 = (Zcp1l[irl]-Zmin)/2.;
282 Xt1 = (xfrac*Zcp1h[irl]+(1.-xfrac)*Zcp1l[irl]-Zmin)/2.;
285 Xb1 = (xfrac*Zcp1h[irl]+(1.-xfrac)*Zcp1l[irl]-Zmin)/2.;
286 Xt1 = (Zcp1h[irl]-Zmin)/2.;
291 double Xt2 = tl1-Xt1;
292 double Xb2 = bl1-Xb1;
294 Xt2 = Xt2 -0.007*SYSTEM_OF_UNITS::mm;
295 Xb2 = Xb2 -0.007*SYSTEM_OF_UNITS::mm;
298 GeoGenfun::GENFUNCTION alpha = ATan(0.5*(bl1-tl1)/h1);
314 GeoGenfun::GENFUNCTION alfrot = -
M_PI/2. - newalpha;
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);
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);
329 GeoIntrusivePtr<GeoTrap> thinTrap{
new GeoTrap(Dz,0.,0.,h1(
instance),tl1,bl1,alpha(
instance),
332 if (!gStraightAbsorbers) {
342 if (!gStraightAbsorbers) {
355 double Dze = Thel/2.;
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;
373 GeoGenfun::GENFUNCTION De = Sqrt ( dxe*dxe + dye*dye );
374 GeoGenfun::GENFUNCTION de = Sqrt ( (De - 2.*Rint)*(De + 2.*Rint) );
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);
384 GeoGenfun::GENFUNCTION alfrote = -
M_PI/2. - newalphe;
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);
390 GeoGenfun::GENFUNCTION h1e = de/2.*frac - .007*SYSTEM_OF_UNITS::mm;
391 GeoGenfun::GENFUNCTION alpha_e = ATan(0.5*(bl1-tl1)/h1e);
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);
402 GeoIntrusivePtr<GeoTrap> trap{
new GeoTrap(Dze,0.,0.,h1e(
instance),tl1,bl1,alpha_e(
instance),
405 if (!gStraightElectrodes) {
416 if (!gStraightElectrodes) {
428 if(!detStore->record(gStraightElectrodes,
"STRAIGHTELECTRODES").isSuccess()) {
429 log << MSG::FATAL <<
"Cannot store STRAIGHTELECTRODES structure" <<
endmsg;
430 return StatusCode::FAILURE;
433 if(!detStore->record(gStraightAbsorbers,
"STRAIGHTABSORBERS").isSuccess()) {
434 log << MSG::FATAL <<
"Cannot store STRAIGHTABSORBERS structure" <<
endmsg;
435 return StatusCode::FAILURE;
438 return StatusCode::SUCCESS;