154 const double &yhit,
const int &PhiCell,
int &Num_Straight,
155 const int &Num_Coude,
double &xl)
const
167 const G4double Xc[2] = {
m_coudeelec->XCentCoude(Num_Coude, PhiCell),
m_coudeelec->YCentCoude(Num_Coude, PhiCell) };
168 const G4double radfold = sqrt(Xc[0]*Xc[0]+Xc[1]*Xc[1]);
169 const G4double radhit = sqrt(xhit*xhit+yhit*yhit);
173 if (Num_Coude == Num_Straight && radhit <radfold) {
174 if (Num_Straight>0) { Num_Straight = Num_Straight-1; }
177 if (Num_Coude == (Num_Straight+1) && radhit > radfold) {
178 if (Num_Straight<12) { Num_Straight = Num_Straight+1; }
183 const double u[2] = {
m_electrode->Cosu(Num_Straight, PhiCell),
m_electrode->Sinu(Num_Straight, PhiCell) };
185 const double Xm[2] = {
m_electrode->XCentEle(Num_Straight, PhiCell),
m_electrode->YCentEle(Num_Straight, PhiCell) };
187 double dx = xhit - Xm[0];
188 double dy = yhit - Xm[1];
192 const double hit = dx*u[0] + dy*u[1];
197 const G4double Half_Elec(
m_electrode->HalfLength(Num_Straight,PhiCell));
199 if(std::fabs(hit) < Half_Elec) {
202 return u[0]*dy - u[1]*dx;
209 const double dr = sqrt( dx*dx + dy*dy);
210 if (Num_Coude==Num_Straight) { xl=-1.; }
228 const double &yhit,
const int &PhiCell,
const int &Num_Straight,
229 const int &Num_Coude)
const
241 const G4double u[2] = {
m_absorber->Cosu(Num_Straight, PhiCell),
m_absorber->Sinu(Num_Straight, PhiCell) };
243 const G4double Xm[2] = {
m_absorber->XCentAbs(Num_Straight, PhiCell),
m_absorber->YCentAbs(Num_Straight, PhiCell) };
245 double dx = xhit - Xm[0];
double dy = yhit - Xm[1];
249 const double hit = dx*u[0] + dy*u[1];
254 if(std::fabs(hit) <
m_absorber->HalfLength(Num_Straight,PhiCell)) {
256 return u[0]*dy - u[1]*dx;
260 const G4double Xc[2] = {
m_coudeabs->XCentCoude(Num_Coude, PhiCell),
m_coudeabs->YCentCoude(Num_Coude, PhiCell) };
264 const double dr = sqrt( dx*dx + dy*dy);
295 G4int& iregion, G4int& isampling, G4int& ieta,
296 G4int& isamp2, G4int& ieta2)
const
300 G4double Eta_max,R_max_acc,Z_max_acc,R_min_acc,Z_max_lowr,dzdr;
301 G4double zmax1,zmax2,zmax3,zmax4,zmax5,zmax6,zmax7,rmax1,rmax2,rmax3,rmax4;
305 static const Geo g = []() {
310 g.Eta_max = parameters->GetValue(
"LArEMBMaxEtaAcceptance");
312 g.R_min_acc= parameters->GetValue(
"LArEMBRadiusInnerAccordion");
314 g.R_max_acc = parameters->GetValue(
"LArEMBFiducialRmax");
317 g.Z_max_acc = parameters->GetValue(
"LArEMBfiducialMothZmax");
319 const G4double R_min_highz=1548.;
322 const G4double deltaz=7.;
323 g.zmax1=g.Z_max_acc-deltaz;
324 g.zmax2=g.Z_max_acc-2.*deltaz;
325 g.zmax3=g.Z_max_acc-3.*deltaz;
326 g.zmax4=g.Z_max_acc-4.*deltaz;
327 g.zmax5=g.Z_max_acc-5.*deltaz;
328 g.zmax6=g.Z_max_acc-6.*deltaz;
329 g.zmax7=g.Z_max_acc-7.*deltaz;
330 g.rmax1=g.R_max_acc-deltaz;
331 g.rmax2=g.R_max_acc-2.*deltaz;
332 g.rmax3=g.R_max_acc-3.*deltaz;
333 g.rmax4=g.R_max_acc-4.*deltaz;
336 g.Z_max_lowr = sinh(g.Eta_max)*g.R_min_acc;
338 g.dzdr = (g.Z_max_acc-g.Z_max_lowr)/(R_min_highz-g.R_min_acc);
349 const G4double Dr_s12=1.1;
350 const G4double Eta_max_s1=1.4;
351 const G4double Eta_max_s3=1.325;
352 const G4double deta=0.025;
358 const G4double aeta=std::fabs(
eta);
369 if (aeta<Eta_max_s1) {
372 istrip=(int) (aeta/deta*8.);
373 if (istrip<0 || istrip >=448) {
374 ATH_MSG_ERROR(
" Problem aeta,istrip " << aeta <<
" " << istrip);
380 imid = (int) (aeta/deta);
381 if (imid <0 || imid >=56) {
393 if (ieta==0) iactive=0;
399 else if (radius < (r12+Dr_s12)) {
410 if (aeta<Eta_max_s3) {
425 else if (
z>g.zmax2) {
429 else if (
z>g.zmax3) {
433 else if (
z>g.zmax4) {
437 else if (aeta<1.3 && z>g.zmax5) {
441 else if (aeta<1.3 && z>g.zmax6) {
446 if (radius>g.rmax1) {
450 else if(radius>g.rmax2) {
454 else if (radius>g.rmax3) {
486 if (isampling==3 &&
z<g.zmax4 && (radius<g.rmax4 || aeta<1.2) ) {
487 const double etastr = (imid%2==0) ? 0.025*imid : 0.025*(imid+1);
488 const double delta=radius*(sinh(etastr)-sinh(aeta))/cosh(etastr);
490 if (aeta<0.475) { deltastr=1.5;}
491 else if (aeta<0.80) { deltastr=2.75;}
492 else if (aeta<0.85) { deltastr=1.5;}
493 else if (aeta<1.1) { deltastr=2.75;}
494 else { deltastr=3.25;}
496 if (std::fabs(delta)<deltastr) {
508 else if (
z>g.zmax2 && aeta<1.375) {
519 if (aeta>=Eta_max_s1 && aeta<g.Eta_max) {
521 r23=g.Z_max_acc/sinh(aeta);
523 const double zmax = g.Z_max_lowr + g.dzdr*(radius-g.R_min_acc);
528 ieta=int((aeta-Eta_max_s1)/deta);
529 if (
z>zmax) { iactive=0; }
531 else if (radius < (r12+Dr_s12)) {
533 ieta=int((aeta-Eta_max_s1)/deta);
536 else if (radius <= r23) {
539 if (
z>zmax) { iactive=0; }
551 if (aeta>g.Eta_max) {
568 if (
z>g.Z_max_acc || radius>g.R_max_acc || radius<g.R_min_acc || aeta > g.Eta_max) iactive=0;
581 const double &xPosition,
582 const double &yPosition,
583 const double &zPosition,
584 const double &aRadius,
587 const bool MapDetail)
const
590 currentCellData.
cellID = 0;
602 if (
m_rc[i] > aRadius) {
break; }
612 if (std::fabs(aRadius-
m_rc[currentCellData.
nfold]) > std::fabs(aRadius-
m_rc[currentCellData.
nfold+1]) ) {
613 currentCellData.
nfold +=1;
622 ATH_MSG_VERBOSE(
" BarrelGeometry: radius,eta,phi " << aRadius <<
" " << anEta <<
" ");
627 G4int ireg,isamp,ieta,isamp2,ieta2;
628 currentCellData.
cellID = this->
SampSeg(anEta,aRadius,zPosition,ireg,isamp,ieta,isamp2,ieta2);
630 currentCellData.
etaBin = ieta;
632 currentCellData.
region = ireg;
633 currentCellData.
etaMap = ieta2;
634 currentCellData.
sampMap = isamp2;
637 int phicell = this->
PhiGap(aRadius,xPosition,yPosition);
638 if (phicell<0) phicell=0;
653 int sampling_phi_nGaps=4;
654 if (currentCellData.
region==0 && currentCellData.
sampling==1) { sampling_phi_nGaps=16; }
656 if (currentCellData.
cellID==0) {
657 currentCellData.
phiBin = (G4int) ( phicell/sampling_phi_nGaps );
665 const G4double distElec = this->
Distance_Ele(xPosition,yPosition,phicell,nstr,currentCellData.
nfold,xl);
672 if (std::fabs(distElec) > 2.5) {
674 double dElecMin=distElec;
676 int phicellmin=phicell;
677 for (
int ii=-2;ii<3;ii++) {
678 if (ii==0) {
continue; }
679 int phicellnew = phicell+ii;
682 if (phicellnew < 0) { phicellnew +=
m_NCellTot; }
686 double dElec =
Distance_Ele(xPosition,yPosition,phicellnew,nstr2,currentCellData.
nfold,xln);
687 if (std::fabs(dElec)<std::fabs(dElecMin)) {
688 phicellmin=phicellnew;
694 currentCellData.
phiGap = phicellmin;
695 currentCellData.
distElec = dElecMin;
696 currentCellData.
xl = xlmin;
700 currentCellData.
phiGap=phicell;
702 currentCellData.
xl=xl;
708 << currentCellData.
xl);
715 else nabs=currentCellData.
phiGap+1;
728 if (std::fabs(currentCellData.
distElec)>std::fabs(currentCellData.
distAbs)) {
729 if (currentCellData.
distAbs>0) { currentCellData.
phiGap += 1; }
730 if (currentCellData.
distAbs<0) { currentCellData.
phiGap -= 1; }
732 if (currentCellData.
phiGap <0) { currentCellData.
phiGap=0; }
744 currentCellData.
phiBin = (G4int) ( currentCellData.
phiGap/sampling_phi_nGaps );
752 const G4double dx1=dx*cos(alpha)-dy*sin(alpha);
753 const G4double dy1=dx*sin(alpha)+dy*cos(alpha);
754 currentCellData.
x0 = dx1 +
m_xc[currentCellData.
nfold];
755 currentCellData.
y0 = dy1 +
m_yc[currentCellData.
nfold];
756 if (
m_parity==1) { currentCellData.
y0 = -1*currentCellData.
y0; }
766 const G4double dl=0.001;
767 const G4double inv_dl = 1. / dl;
768 G4double cenx[15],ceny[15];
770 std::vector<G4double> sum1(5000);
771 std::vector<G4double> sumx(5000);
780 const G4double inv_rint = 1. / rint;
781 const G4double dt=dl * inv_rint;
782 const G4double inv_dt = 1. / dt;
784 for (G4int i=0;i<
m_NRphi;i++) {
788 for (G4int i=0;i<15;i++) {
793 for (G4int i=0; i<15; i++) {
830 const G4int nstep=int((phi1-phi0)*inv_dt)+1;
831 for (
int ii=0;ii<nstep;ii++) {
833 const G4double
phi=phi0+dt*((G4double)ii);
834 const G4double
x=cenx[i]+rint*cos(
phi);
835 const G4double
y=ceny[i]+rint*sin(
phi);
836 const G4double radius=sqrt(
x*
x+
y*
y);
838 const G4double phid=atan(
y/
x);
848 const G4double dx=cenx[i+1]-cenx[i];
849 const G4double dy=ceny[i+1]-ceny[i];
850 const G4double along=std::sqrt(dx*dx+dy*dy-4.*rint*rint);
851 const G4double x0=0.5*(cenx[i+1]+cenx[i]);
852 const G4double y0=0.5*(ceny[i+1]+ceny[i]);
854 const G4double x1=x0-0.5*along*cos(
phi);
855 const G4double y1=y0-0.5*along*sin(
phi);
857 const int nstep=int(along*inv_dl)+1;
858 for (
int ii=0;ii<nstep;ii++) {
860 const G4double
x=x1+dl*((G4double)ii)*cos(
phi);
861 const G4double
y=y1+dl*((G4double)ii)*sin(
phi);
862 const G4double radius=sqrt(
x*
x+
y*
y);
864 const G4double phid=atan(
y/
x);
875 for (
int i=0; i<
m_NRphi; i++) {
877 m_Rphi[i]=sumx[i]/sum1[i];
1010 const G4StepPoint *thisStepPoint = a_step->GetPreStepPoint();
1011 const G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint();
1012 const G4ThreeVector startPoint = thisStepPoint->GetPosition();
1013 const G4ThreeVector endPoint = thisStepBackPoint->GetPosition();
1014 const G4ThreeVector p = (thisStepPoint->GetPosition() + thisStepBackPoint->GetPosition()) * 0.5;
1017 ATH_MSG_VERBOSE(
"Position of the step in the ATLAS frame (x,y,z) --> " << p.x() <<
" " << p.y() <<
" " << p.z());
1018 ATH_MSG_VERBOSE(
"Eta and Phi in the ATLAS frame --> " << p.eta() <<
" " << p.phi());
1023 const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory();
1024 const G4AffineTransform transformation = g4navigation->GetTransform(indECAM);
1025 const G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint);
1026 const G4ThreeVector endPointinLocal = transformation.TransformPoint (endPoint);
1027 const G4ThreeVector midinLocal = (startPointinLocal+endPointinLocal)*0.5;
1030 ATH_MSG_VERBOSE(
"Position of the step in the LOCAL frame (x,y,z) --> " << midinLocal.x() <<
" " << midinLocal.y() <<
" " << midinLocal.z());
1031 ATH_MSG_VERBOSE(
"Eta and Phi of the step in LOCAL frame --> " << midinLocal.eta() <<
" " << midinLocal.phi());
1036 const G4double xZpos = midinLocal.x();
1037 const G4double yZpos = midinLocal.y();
1038 const G4double zZpos = midinLocal.z();
1039 const G4double etaZpos = midinLocal.pseudoRapidity();
1040 const G4double phiZpos = (midinLocal.phi()<0.) ? midinLocal.phi() + 2.*
M_PI : midinLocal.phi();
1041 const G4double radius2Zpos = xZpos*xZpos + yZpos*yZpos;
1042 const G4double radiusZpos = sqrt(radius2Zpos);
1046 currentCellData.
zSide = 1;
1049 currentCellData.
zSide = zside;
1066 const bool MapDetail(
false);
1067 this->
findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail );
1071 if( currentCellData.
zSide == -1 )
1073 if( currentCellData.
sampling == 1 && currentCellData.
region ==0 )
1076 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 64;
1078 if( currentCellData.
sampling == 1 && currentCellData.
region ==1 )
1081 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 256;
1083 if( currentCellData.
sampling >= 2 )
1086 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 256;
1094 currentCellData.
etaBin=1;
1099 << currentCellData.
zSide
1101 << currentCellData.
region
1102 << currentCellData.
etaBin
1103 << currentCellData.
phiBin;
1113 ATH_MSG_VERBOSE(
"And also etafirst ----> " << thisStepPoint->GetPosition().pseudoRapidity());
1130 const G4int numDeadPhiBins = 64;
1131 double abs_eta = std::fabs(etaZpos);
1132 const double DM1EtaWidth = 0.1 ;
1133 const double DM1PhiWidth = 2.*
M_PI / numDeadPhiBins ;
1134 currentCellData.
etaBin = (G4int) ( abs_eta * (1./DM1EtaWidth) ) ;
1135 currentCellData.
phiBin = (G4int) (phiZpos/ DM1PhiWidth );
1138 if (currentCellData.
phiBin==numDeadPhiBins) currentCellData.
phiBin=currentCellData.
phiBin-1;
1142 if ( currentCellData.
zSide == -1 ) {
1144 if (currentCellData.
phiBin < 0 ) currentCellData.
phiBin +=64 ;
1151 if (currentCellData.
etaBin > 14) currentCellData.
etaBin=14;
1154 ATH_MSG_VERBOSE(
"This hit is in the ECAM volume in front of the accordion (DEAD MATERIAL) !!!!! ");
1160 if (abs_eta < 1.0 ) {
1163 ATH_MSG_VERBOSE(
"This hit is in the ECAM volume behind accordion (DEAD MATERIAL 0) !!!!! ");
1165 }
else if ( abs_eta >= 1.0 && abs_eta < 1.5) {
1169 ATH_MSG_VERBOSE(
"This hit is in the ECAM volume behind accordion (DEAD MATERIAL 2) !!!!! ");
1172 ATH_MSG_ERROR(
" LArBarrelGeometry: hit behind accordion at eta>1.5 !!! ");
1174 currentCellData.
etaBin = 4;
1180 const G4int phisave=currentCellData.
phiBin;
1181 const G4bool MapDetail(
false);
1182 this->
findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail );
1183 sampling = currentCellData.
sampling;
1184 currentCellData.
etaBin=0;
1185 currentCellData.
phiBin=phisave;
1188 if (abs_eta >1.0 && abs_eta < 1.5) {
1192 }
else if (abs_eta < 1.6) {
1195 currentCellData.
etaBin=0;
1200 currentCellData.
etaBin=0;
1204 const G4double thisStepEnergyDeposit = a_step->GetTotalEnergyDeposit() * a_step->GetTrack()->GetWeight();
1205 std::ostringstream dmLog;
1206 dmLog <<
"LArBarrelGeometry: cannot find region for DM hit..." << std::endl;
1207 dmLog <<
"LArBarrelGeometry: cannot find region for DM hit..." << std::endl;
1208 dmLog <<
"m_zMinBarrel: " <<
m_zMinBarrel << std::endl;
1209 dmLog <<
"m_zMaxBarrel: " <<
m_zMaxBarrel << std::endl;
1212 dmLog <<
"r,z,eta,phi " << radiusZpos <<
" " << zZpos <<
" " << etaZpos <<
" " << phiZpos << std::endl;
1213 dmLog <<
"x,y,z (Atlas) " << p.x() <<
" " << p.y() <<
" " << p.z() << std::endl;
1214 dmLog <<
" inSTAC " << inSTAC << std::endl;
1215 dmLog <<
" eDeposited " << thisStepEnergyDeposit << std::endl;
1216 const G4VPhysicalVolume* vol = thisStepPoint->GetPhysicalVolume();
1217 const G4String volName = vol->GetName();
1218 dmLog <<
" volName " << volName << std::endl;
1219 const G4int ndep = g4navigation->GetDepth();
1220 for (G4int ii=0;ii<=ndep;ii++) {
1221 const G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii);
1222 const G4String vname = v1->GetName();
1223 dmLog <<
"vname " << vname << std::endl;
1225 if (thisStepEnergyDeposit > 1.*CLHEP::MeV) {
1235 G4bool MapDetail=
false;
1236 this->
findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail );
1242 currentCellData.
etaBin=1;
1248 << currentCellData.
zSide
1250 << currentCellData.
region
1251 << currentCellData.
etaBin
1252 << currentCellData.
phiBin;
1258 << currentCellData.
zSide * 4
1262 << currentCellData.
etaBin
1263 << currentCellData.
phiBin;
1266 ATH_MSG_VERBOSE(
"Here the identifier for the barrel DEAD materials ---->");