12#include "GaudiKernel/ISvcLocator.h"
13#include "GaudiKernel/Bootstrap.h"
14#include "GaudiKernel/PhysicalConstants.h"
15#include "GaudiKernel/ServiceHandle.h"
25 int phiGap(
double radius,
double xhit,
double yhit)
const;
35 double phi0(
double radius)
const;
41 const int &PhiC,
int &Num_Straight,
const int &Num_Coude,
47 const int &nabs,
const int &Num_Straight,
const int &Num_Coude);
79 const double dl=0.001;
80 const double inv_dl = 1 / dl;
81 double cenx[15],ceny[15];
82 std::vector<double> sum1(5000);
83 std::vector<double> sumx(5000);
90 const double inv_rint = 1. / rint;
91 const double dt=dl * inv_rint;
92 const double inv_dt = 1. / dt;
94 for (
int i=0;i<
NRphi;i++) {
98 for (
int i=0;i<15;i++) {
99 cenx[i]=
rc[i]*cos(
phic[i]);
100 ceny[i]=
rc[i]*sin(
phic[i]);
103 for (
int i=0; i<15; i++) {
125 int nstep=int((phi1-
phi0) * inv_dt)+1;
126 for (
int ii=0;ii<nstep;ii++) {
127 double phi=
phi0+dt*((double)ii);
128 double x=cenx[i]+rint*cos(
phi);
129 double y=ceny[i]+rint*sin(
phi);
130 double radius=sqrt(
x*
x+
y*
y);
132 double phid=atan(
y/
x);
142 double dx=cenx[i+1]-cenx[i];
143 double dy=ceny[i+1]-ceny[i];
144 double along=dx*dx+dy*dy-4.*rint*rint;
146 double x0=0.5*(cenx[i+1]+cenx[i]);
147 double y0=0.5*(ceny[i+1]+ceny[i]);
151 double x1=x0-0.5*along*cos(
phi);
152 double y1=y0-0.5*along*sin(
phi);
153 int nstep=int(along * inv_dl)+1;
154 for (
int ii=0;ii<nstep;ii++) {
155 double x=x1+dl*((double)ii)*cos(
phi);
156 double y=y1+dl*((double)ii)*sin(
phi);
157 double radius=sqrt(
x*
x+
y*
y);
159 double phid=atan(
y/
x);
168 for (
int i=0; i<
NRphi; i++) {
170 Rphi[i]=sumx[i]/sum1[i];
182 const double m2pi = 2.0*Gaudi::Units::pi;
184 double phi_hit=atan2(yhit,xhit);
185 double dphi=phi_hit-phi_0;
187 if (dphi<0) dphi=dphi+m2pi;
188 if (dphi>=m2pi) dphi=dphi-m2pi;
189 dphi=dphi*(1024/m2pi);
190 int ngap=((int) dphi);
199 ISvcLocator *svcLocator = Gaudi::svcLocator();
201 SmartIF<IGeoModelSvc> geoModel{svcLocator->service(
"GeoModelSvc")};
202 if(!geoModel.isValid())
203 throw std::runtime_error(
"Error in HECDetectorManager, cannot access GeoModelSvc");
205 SmartIF<IGeoDbTagSvc> geoDbTagSvc{svcLocator->service(
"GeoDbTagSvc")};
206 if(!geoDbTagSvc.isValid())
207 throw std::runtime_error(
"Error in HECDetectorManager, cannot access GeoDbTagSvc");
209 SmartIF<IRDBAccessSvc> rdbAccess{svcLocator->service(geoDbTagSvc->getParamSvcName())};
210 if(!rdbAccess.isValid())
211 throw std::runtime_error(
"Error in HECDetectorManager, cannot access RDBAccessSvc");
213 if(
m_c->detStore.retrieve().isFailure())
214 throw std::runtime_error(
"Error in HECDetectorManager, cannot access DetectorStore");
216 std::string detectorKey, detectorNode;
218 if(geoDbTagSvc->getSqliteReader()==
nullptr) {
219 std::string AtlasVersion = geoModel->atlasVersion();
220 std::string LArVersion = geoModel->LAr_VersionOverride();
222 detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion;
223 detectorNode = LArVersion.empty() ?
"ATLAS" :
"LAr";
226 IRDBRecordset_ptr barrelGeometry = rdbAccess->getRecordsetPtr(
"BarrelGeometry",detectorKey,detectorNode);
227 if (barrelGeometry->
size()==0) {
228 throw std::runtime_error(
"Cannot find the BarrelGeometry Table");
231 IRDBRecordset_ptr barrelLongDiv = rdbAccess->getRecordsetPtr(
"BarrelLongDiv",detectorKey,detectorNode);
232 if (barrelLongDiv->
size()==0) {
233 throw std::runtime_error(
"Cannot find the BarrelLongDiv Table");
237 m_c->Nbrt = (*barrelGeometry)[0]->getInt(
"NBRT");
239 m_c->Nbrt1 =
m_c->Nbrt + 1;
241 m_c->gam0 = (*barrelGeometry)[0]->getDouble(
"PHIFIRST");
243 m_c->rint_eleFib = (*barrelGeometry)[0]->getDouble(
"RINT")*Gaudi::Units::cm;
246 for (
int idat = 0; idat <
m_c->Nbrt1 ; idat++)
248 m_c->rc[idat] = (*barrelGeometry)[0]->getDouble(
"RHOCEN",idat)*Gaudi::Units::cm;
249 m_c->phic[idat] = (*barrelGeometry)[0]->getDouble(
"PHICEN",idat)*Gaudi::Units::deg;
250 m_c->delta[idat] = (*barrelGeometry)[0]->getDouble(
"DELTA",idat)*Gaudi::Units::deg;
251 m_c->xc[idat] =
m_c->rc[idat]*cos(
m_c->phic[idat]);
252 m_c->yc[idat] =
m_c->rc[idat]*sin(
m_c->phic[idat]);
255 m_c->rMinAccordion = (*barrelGeometry)[0]->getDouble(
"RIN_AC")*Gaudi::Units::cm;
256 m_c->rMaxAccordion = (*barrelGeometry)[0]->getDouble(
"ROUT_AC")*Gaudi::Units::cm;
257 m_c->etaMaxBarrel = (*barrelGeometry)[0]->getDouble(
"ETACUT");
258 m_c->zMinBarrel = (*barrelLongDiv)[0]->getDouble(
"ZMAXACT")*Gaudi::Units::cm;
259 m_c->zMaxBarrel = (*barrelLongDiv)[0]->getDouble(
"ZMINACT")*Gaudi::Units::cm;
262 m_c->NCellTot = (*barrelGeometry)[0]->getInt(
"NCELMX");
285 if (radius >
Rmax) radius=
Rmax-0.0001;
293 if (
m_c->absorberStraightSection==
nullptr) {
296 StatusCode status =
m_c->detStore->retrieve(sa,
"STRAIGHTABSORBERS");
297 if (status != StatusCode::SUCCESS)
throw std::runtime_error (
"Cannot locate Straight Absorbers");
299 m_c->absorberStraightSection = sa;
302 return m_c->absorberStraightSection;
308 if (
m_c->electrodeStraightSection==
nullptr) {
311 StatusCode status =
m_c->detStore->retrieve(sa,
"STRAIGHTELECTRODES");
312 if (status != StatusCode::SUCCESS)
throw std::runtime_error (
"Cannot locate Straight Electrodes");
314 m_c->electrodeStraightSection=sa;
317 return m_c->electrodeStraightSection;
343 const double &yhit,
const int &PhiCell,
int &Num_Straight,
344 const int &Num_Coude,
double &xl)
359 Xc[0] = m_coudeelec->XCentCoude(Num_Coude, PhiCell);
360 Xc[1] = m_coudeelec->YCentCoude(Num_Coude, PhiCell);
361 double radfold = sqrt(Xc[0]*Xc[0]+Xc[1]*Xc[1]);
362 double radhit = sqrt(xhit*xhit+yhit*yhit);
366 if (Num_Coude == Num_Straight && radhit <radfold) {
367 if (Num_Straight>0) Num_Straight = Num_Straight-1;
370 if (Num_Coude == (Num_Straight+1) && radhit > radfold) {
371 if (Num_Straight<12) Num_Straight = Num_Straight+1;
377 u[0] = m_electrode->Cosu(Num_Straight, PhiCell);
378 u[1] = m_electrode->Sinu(Num_Straight, PhiCell);
381 Xm[0] = m_electrode->XCentEle(Num_Straight, PhiCell);
382 Xm[1] = m_electrode->YCentEle(Num_Straight, PhiCell);
384 dx = xhit - Xm[0];
dy = yhit - Xm[1];
388 double m_hit =
dx*
u[0] +
dy*
u[1];
394 Half_Elec = m_electrode->HalfLength(Num_Straight,PhiCell);
396 if(fabs(m_hit) < Half_Elec) {
398 DistEle =
u[0]*
dy -
u[1]*
dx;
404 dx = xhit - Xc[0];
dy = yhit - Xc[1];
dr = sqrt( dx*dx + dy*dy);
405 DistEle = (Num_Coude%2 == 0) ? (rint_eleFib-dr) : (
dr - rint_eleFib);
406 if (Num_Coude==Num_Straight) xl=-1.;
Scalar phi() const
phi method
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
ServiceHandle< StoreGateSvc > detStore
double Distance_Ele(const double &x, const double &y, const int &PhiC, int &Num_Straight, const int &Num_Coude, double &xl)
Compute the distance to the electrode.
double phi0(double radius) const
phi of first absorber as function of radius for nominal accordion geometry (before sagging).
const GeoStraightAccSection * electrodeStraightSection
double Distance_Abs(const double &x, const double &y, const int &nabs, const int &Num_Straight, const int &Num_Coude)
Compute the distance to the absorber.
void getRPhi()
initialization routine
int phiGap(double radius, double xhit, double yhit) const
compute number (0 to 1023) of closest electrode according to nominal accordion geometry
const GeoStraightAccSection * absorberStraightSection
EMBAccordionDetails()
Destructor.
const GeoStraightAccSection * getElectrodeSections() const
Electrode position details:
~EMBAccordionDetails()
Destructor.
const GeoStraightAccSection * getAbsorberSections() const
Absorber position details:
double phiFirstAbsorber() const
Phi of the first absorber.
Record of All Electrode Straight Pieces.
virtual unsigned int size() const =0
int ir
counter of the current depth
@ u
Enums for curvilinear frames.