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;
 
   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   double sum1[5000],sumx[5000];
 
   89   const double inv_rint = 1. / rint;
 
   90   const double dt=
dl * inv_rint;
 
   91   const double inv_dt = 1. / 
dt;
 
   97   for (
int i=0;
i<15;
i++) {
 
  102   for (
int i=0; 
i<15; 
i++) {
 
  124      int nstep=
int((phi1-
phi0) * inv_dt)+1;
 
  125      for (
int ii=0;ii<nstep;ii++) {
 
  141         double dx=cenx[
i+1]-cenx[
i];
 
  142         double dy=ceny[
i+1]-ceny[
i];
 
  143         double along=
dx*
dx+
dy*
dy-4.*rint*rint;
 
  145         double x0=0.5*(cenx[
i+1]+cenx[
i]);
 
  146         double y0=0.5*(ceny[
i+1]+ceny[
i]);
 
  152         int nstep=
int(along * inv_dl)+1;
 
  153         for (
int ii=0;ii<nstep;ii++) {
 
  183   double phi_hit=atan2(yhit,xhit);  
 
  184   double dphi=phi_hit-phi_0;
 
  186   if (dphi<0) dphi=dphi+m2pi;
 
  187   if (dphi>=m2pi) dphi=dphi-m2pi;
 
  188   dphi=dphi*(1024/m2pi);
 
  189   int ngap=((
int) dphi);
 
  198   ISvcLocator *svcLocator = Gaudi::svcLocator();
 
  200   SmartIF<IGeoModelSvc> geoModel{svcLocator->service(
"GeoModelSvc")};
 
  201   if(!geoModel.isValid())
 
  202     throw std::runtime_error(
"Error in HECDetectorManager, cannot access GeoModelSvc");
 
  204   SmartIF<IGeoDbTagSvc> geoDbTagSvc{svcLocator->service(
"GeoDbTagSvc")};
 
  205   if(!geoDbTagSvc.isValid())
 
  206     throw std::runtime_error(
"Error in HECDetectorManager, cannot access GeoDbTagSvc");
 
  208   SmartIF<IRDBAccessSvc> rdbAccess{svcLocator->service(geoDbTagSvc->getParamSvcName())};
 
  209   if(!rdbAccess.isValid())
 
  210     throw std::runtime_error(
"Error in HECDetectorManager, cannot access RDBAccessSvc");
 
  213       throw std::runtime_error(
"Error in HECDetectorManager, cannot access DetectorStore");
 
  215   std::string detectorKey, detectorNode;
 
  217   if(geoDbTagSvc->getSqliteReader()==
nullptr) {  
 
  219     std::string LArVersion = geoModel->LAr_VersionOverride();
 
  221     detectorKey  = LArVersion.empty() ? 
AtlasVersion : LArVersion;
 
  222     detectorNode = LArVersion.empty() ? 
"ATLAS" : 
"LAr";
 
  225   IRDBRecordset_ptr barrelGeometry = rdbAccess->getRecordsetPtr(
"BarrelGeometry",detectorKey,detectorNode);
 
  226   if (barrelGeometry->size()==0) {
 
  227     throw std::runtime_error(
"Cannot find the BarrelGeometry Table");
 
  230   IRDBRecordset_ptr barrelLongDiv = rdbAccess->getRecordsetPtr(
"BarrelLongDiv",detectorKey,detectorNode);
 
  231   if (barrelLongDiv->size()==0) {
 
  232     throw std::runtime_error(
"Cannot find the BarrelLongDiv Table");
 
  236   m_c->
Nbrt = (*barrelGeometry)[0]->getInt(
"NBRT");
 
  240   m_c->
gam0 = (*barrelGeometry)[0]->getDouble(
"PHIFIRST");
 
  245   for (
int idat = 0; idat < 
m_c->
Nbrt1 ; idat++) 
 
  261   m_c->
NCellTot =         (*barrelGeometry)[0]->getInt(
"NCELMX"); 
 
  296     if (
status != StatusCode::SUCCESS) 
throw std::runtime_error (
"Cannot locate Straight Absorbers");
 
  311     if (
status != StatusCode::SUCCESS) 
throw std::runtime_error (
"Cannot locate Straight Electrodes");
 
  342                                                     const double &yhit, 
const int &PhiCell, 
int &Num_Straight,
 
  343                                                     const int &Num_Coude, 
double &xl)
 
  358     Xc[0] = m_coudeelec->XCentCoude(Num_Coude, PhiCell);
 
  359     Xc[1] = m_coudeelec->YCentCoude(Num_Coude, PhiCell);
 
  360     double radfold = sqrt(Xc[0]*Xc[0]+Xc[1]*Xc[1]);
 
  361     double radhit = sqrt(xhit*xhit+yhit*yhit);
 
  365   if (Num_Coude == Num_Straight && radhit <radfold) {
 
  366      if (Num_Straight>0) Num_Straight = Num_Straight-1;
 
  369   if (Num_Coude == (Num_Straight+1) && radhit > radfold) {
 
  370      if (Num_Straight<12) Num_Straight = Num_Straight+1;
 
  376   u[0] = m_electrode->Cosu(Num_Straight, PhiCell);
 
  377   u[1] = m_electrode->Sinu(Num_Straight, PhiCell);
 
  380   Xm[0] = m_electrode->XCentEle(Num_Straight, PhiCell);
 
  381   Xm[1] = m_electrode->YCentEle(Num_Straight, PhiCell);
 
  383   dx = xhit - Xm[0];  
dy = yhit - Xm[1];
 
  387   double m_hit = 
dx*
u[0] + 
dy*
u[1];
 
  393   Half_Elec = m_electrode->HalfLength(Num_Straight,PhiCell); 
 
  395   if(fabs(m_hit) < Half_Elec) {
 
  397     DistEle = 
u[0]*
dy - 
u[1]*
dx;
 
  404     DistEle = (Num_Coude%2 == 0) ? (rint_eleFib-
dr) : (
dr - rint_eleFib);
 
  405     if (Num_Coude==Num_Straight) xl=-1.;