167 const double &yhit,
const int &PhiCell,
int &Num_Straight,
168 const int &Num_Coude,
double &xl)
const
180 const G4double Xc[2] = {
m_coudeelec->XCentCoude(Num_Coude, PhiCell),
m_coudeelec->YCentCoude(Num_Coude, PhiCell) };
181 const G4double radfold = sqrt(Xc[0]*Xc[0]+Xc[1]*Xc[1]);
182 const G4double radhit = sqrt(xhit*xhit+yhit*yhit);
186 if (Num_Coude == Num_Straight && radhit <radfold) {
187 if (Num_Straight>0) { Num_Straight = Num_Straight-1; }
190 if (Num_Coude == (Num_Straight+1) && radhit > radfold) {
191 if (Num_Straight<12) { Num_Straight = Num_Straight+1; }
196 const double u[2] = {
m_electrode->Cosu(Num_Straight, PhiCell),
m_electrode->Sinu(Num_Straight, PhiCell) };
198 const double Xm[2] = {
m_electrode->XCentEle(Num_Straight, PhiCell),
m_electrode->YCentEle(Num_Straight, PhiCell) };
200 double dx = xhit - Xm[0];
201 double dy = yhit - Xm[1];
205 const double hit = dx*u[0] + dy*u[1];
210 const G4double Half_Elec(
m_electrode->HalfLength(Num_Straight,PhiCell));
212 if(std::fabs(hit) < Half_Elec) {
215 return u[0]*dy - u[1]*dx;
222 const double dr = sqrt( dx*dx + dy*dy);
223 if (Num_Coude==Num_Straight) { xl=-1.; }
241 const double &yhit,
const int &PhiCell,
const int &Num_Straight,
242 const int &Num_Coude)
const
254 const G4double u[2] = {
m_absorber->Cosu(Num_Straight, PhiCell),
m_absorber->Sinu(Num_Straight, PhiCell) };
256 const G4double Xm[2] = {
m_absorber->XCentAbs(Num_Straight, PhiCell),
m_absorber->YCentAbs(Num_Straight, PhiCell) };
258 double dx = xhit - Xm[0];
double dy = yhit - Xm[1];
262 const double hit = dx*u[0] + dy*u[1];
267 if(std::fabs(hit) <
m_absorber->HalfLength(Num_Straight,PhiCell)) {
269 return u[0]*dy - u[1]*dx;
273 const G4double Xc[2] = {
m_coudeabs->XCentCoude(Num_Coude, PhiCell),
m_coudeabs->YCentCoude(Num_Coude, PhiCell) };
277 const double dr = sqrt( dx*dx + dy*dy);
308 G4int& iregion, G4int& isampling, G4int& ieta,
309 G4int& isamp2, G4int& ieta2)
const
313 G4double Eta_max,R_max_acc,Z_max_acc,R_min_acc,Z_max_lowr,dzdr;
314 G4double zmax1,zmax2,zmax3,zmax4,zmax5,zmax6,zmax7,rmax1,rmax2,rmax3,rmax4;
318 static const Geo g = []() {
323 g.Eta_max = parameters->GetValue(
"LArEMBMaxEtaAcceptance");
325 g.R_min_acc= parameters->GetValue(
"LArEMBRadiusInnerAccordion");
327 g.R_max_acc = parameters->GetValue(
"LArEMBFiducialRmax");
330 g.Z_max_acc = parameters->GetValue(
"LArEMBfiducialMothZmax");
332 const G4double R_min_highz=1548.;
335 const G4double deltaz=7.;
336 g.zmax1=g.Z_max_acc-deltaz;
337 g.zmax2=g.Z_max_acc-2.*deltaz;
338 g.zmax3=g.Z_max_acc-3.*deltaz;
339 g.zmax4=g.Z_max_acc-4.*deltaz;
340 g.zmax5=g.Z_max_acc-5.*deltaz;
341 g.zmax6=g.Z_max_acc-6.*deltaz;
342 g.zmax7=g.Z_max_acc-7.*deltaz;
343 g.rmax1=g.R_max_acc-deltaz;
344 g.rmax2=g.R_max_acc-2.*deltaz;
345 g.rmax3=g.R_max_acc-3.*deltaz;
346 g.rmax4=g.R_max_acc-4.*deltaz;
349 g.Z_max_lowr = sinh(g.Eta_max)*g.R_min_acc;
351 g.dzdr = (g.Z_max_acc-g.Z_max_lowr)/(R_min_highz-g.R_min_acc);
362 const G4double Dr_s12=1.1;
363 const G4double Eta_max_s1=1.4;
364 const G4double Eta_max_s3=1.325;
365 const G4double deta=0.025;
371 const G4double aeta=std::fabs(
eta);
382 if (aeta<Eta_max_s1) {
385 istrip=(int) (aeta/deta*8.);
386 if (istrip<0 || istrip >=448) {
387 ATH_MSG_ERROR(
" Problem aeta,istrip " << aeta <<
" " << istrip);
393 imid = (int) (aeta/deta);
394 if (imid <0 || imid >=56) {
406 if (ieta==0) iactive=0;
412 else if (radius < (r12+Dr_s12)) {
423 if (aeta<Eta_max_s3) {
438 else if (
z>g.zmax2) {
442 else if (
z>g.zmax3) {
446 else if (
z>g.zmax4) {
450 else if (aeta<1.3 && z>g.zmax5) {
454 else if (aeta<1.3 && z>g.zmax6) {
459 if (radius>g.rmax1) {
463 else if(radius>g.rmax2) {
467 else if (radius>g.rmax3) {
499 if (isampling==3 &&
z<g.zmax4 && (radius<g.rmax4 || aeta<1.2) ) {
500 const double etastr = (imid%2==0) ? 0.025*imid : 0.025*(imid+1);
501 const double delta=radius*(sinh(etastr)-sinh(aeta))/cosh(etastr);
503 if (aeta<0.475) { deltastr=1.5;}
504 else if (aeta<0.80) { deltastr=2.75;}
505 else if (aeta<0.85) { deltastr=1.5;}
506 else if (aeta<1.1) { deltastr=2.75;}
507 else { deltastr=3.25;}
509 if (std::fabs(delta)<deltastr) {
521 else if (
z>g.zmax2 && aeta<1.375) {
532 if (aeta>=Eta_max_s1 && aeta<g.Eta_max) {
534 r23=g.Z_max_acc/sinh(aeta);
536 const double zmax = g.Z_max_lowr + g.dzdr*(radius-g.R_min_acc);
541 ieta=int((aeta-Eta_max_s1)/deta);
542 if (
z>zmax) { iactive=0; }
544 else if (radius < (r12+Dr_s12)) {
546 ieta=int((aeta-Eta_max_s1)/deta);
549 else if (radius <= r23) {
552 if (
z>zmax) { iactive=0; }
564 if (aeta>g.Eta_max) {
581 if (
z>g.Z_max_acc || radius>g.R_max_acc || radius<g.R_min_acc || aeta > g.Eta_max) iactive=0;
594 const double &xPosition,
595 const double &yPosition,
596 const double &zPosition,
597 const double &aRadius,
600 const bool MapDetail)
const
603 currentCellData.
cellID = 0;
615 if (
m_rc[i] > aRadius) {
break; }
625 if (std::fabs(aRadius-
m_rc[currentCellData.
nfold]) > std::fabs(aRadius-
m_rc[currentCellData.
nfold+1]) ) {
626 currentCellData.
nfold +=1;
635 ATH_MSG_VERBOSE(
" BarrelGeometry: radius,eta,phi " << aRadius <<
" " << anEta <<
" ");
640 G4int ireg,isamp,ieta,isamp2,ieta2;
641 currentCellData.
cellID = this->
SampSeg(anEta,aRadius,zPosition,ireg,isamp,ieta,isamp2,ieta2);
643 currentCellData.
etaBin = ieta;
645 currentCellData.
region = ireg;
646 currentCellData.
etaMap = ieta2;
647 currentCellData.
sampMap = isamp2;
650 int phicell = this->
PhiGap(aRadius,xPosition,yPosition);
651 if (phicell<0) phicell=0;
666 int sampling_phi_nGaps=4;
667 if (currentCellData.
region==0 && currentCellData.
sampling==1) { sampling_phi_nGaps=16; }
669 if (currentCellData.
cellID==0) {
670 currentCellData.
phiBin = (G4int) ( phicell/sampling_phi_nGaps );
678 const G4double distElec = this->
Distance_Ele(xPosition,yPosition,phicell,nstr,currentCellData.
nfold,xl);
685 if (std::fabs(distElec) > 2.5) {
687 double dElecMin=distElec;
689 int phicellmin=phicell;
690 for (
int ii=-2;ii<3;ii++) {
691 if (ii==0) {
continue; }
692 int phicellnew = phicell+ii;
695 if (phicellnew < 0) { phicellnew +=
m_NCellTot; }
699 double dElec =
Distance_Ele(xPosition,yPosition,phicellnew,nstr2,currentCellData.
nfold,xln);
700 if (std::fabs(dElec)<std::fabs(dElecMin)) {
701 phicellmin=phicellnew;
707 currentCellData.
phiGap = phicellmin;
708 currentCellData.
distElec = dElecMin;
709 currentCellData.
xl = xlmin;
713 currentCellData.
phiGap=phicell;
715 currentCellData.
xl=xl;
721 << currentCellData.
xl);
728 else nabs=currentCellData.
phiGap+1;
741 if (std::fabs(currentCellData.
distElec)>std::fabs(currentCellData.
distAbs)) {
742 if (currentCellData.
distAbs>0) { currentCellData.
phiGap += 1; }
743 if (currentCellData.
distAbs<0) { currentCellData.
phiGap -= 1; }
745 if (currentCellData.
phiGap <0) { currentCellData.
phiGap=0; }
757 currentCellData.
phiBin = (G4int) ( currentCellData.
phiGap/sampling_phi_nGaps );
765 const G4double dx1=dx*cos(alpha)-dy*sin(alpha);
766 const G4double dy1=dx*sin(alpha)+dy*cos(alpha);
767 currentCellData.
x0 = dx1 +
m_xc[currentCellData.
nfold];
768 currentCellData.
y0 = dy1 +
m_yc[currentCellData.
nfold];
769 if (
m_parity==1) { currentCellData.
y0 = -1*currentCellData.
y0; }
779 const G4double dl=0.001;
780 const G4double inv_dl = 1. / dl;
781 G4double cenx[15],ceny[15];
783 std::vector<G4double> sum1(5000);
784 std::vector<G4double> sumx(5000);
793 const G4double inv_rint = 1. / rint;
794 const G4double dt=dl * inv_rint;
795 const G4double inv_dt = 1. / dt;
797 for (G4int i=0;i<
m_NRphi;i++) {
801 for (G4int i=0;i<15;i++) {
806 for (G4int i=0; i<15; i++) {
843 const G4int nstep=int((phi1-phi0)*inv_dt)+1;
844 for (
int ii=0;ii<nstep;ii++) {
846 const G4double
phi=phi0+dt*((G4double)ii);
847 const G4double
x=cenx[i]+rint*cos(
phi);
848 const G4double
y=ceny[i]+rint*sin(
phi);
849 const G4double radius=sqrt(
x*
x+
y*
y);
851 const G4double phid=atan(
y/
x);
861 const G4double dx=cenx[i+1]-cenx[i];
862 const G4double dy=ceny[i+1]-ceny[i];
863 const G4double along=std::sqrt(dx*dx+dy*dy-4.*rint*rint);
864 const G4double x0=0.5*(cenx[i+1]+cenx[i]);
865 const G4double y0=0.5*(ceny[i+1]+ceny[i]);
867 const G4double x1=x0-0.5*along*cos(
phi);
868 const G4double y1=y0-0.5*along*sin(
phi);
870 const int nstep=int(along*inv_dl)+1;
871 for (
int ii=0;ii<nstep;ii++) {
873 const G4double
x=x1+dl*((G4double)ii)*cos(
phi);
874 const G4double
y=y1+dl*((G4double)ii)*sin(
phi);
875 const G4double radius=sqrt(
x*
x+
y*
y);
877 const G4double phid=atan(
y/
x);
888 for (
int i=0; i<
m_NRphi; i++) {
890 m_Rphi[i]=sumx[i]/sum1[i];
970 const G4StepPoint *preStep = a_step->GetPreStepPoint();
971 const G4StepPoint *postStep = a_step->GetPostStepPoint();
972 G4ThreeVector midGlobal = (preStep->GetPosition() + postStep->GetPosition()) * 0.5;
974 const G4NavigationHistory* g4nav = preStep->GetTouchable()->GetHistory();
977 const G4int ndep = g4nav->GetDepth();
979 for (G4int ii = 0; ii <= ndep; ++ii) {
980 if (g4nav->GetVolume(ii)->GetName() ==
m_ecamName) {
991 G4AffineTransform localTrans = g4nav->GetTransform(indECAM);
992 G4ThreeVector midLocal = localTrans.TransformPoint(midGlobal);
994 double x = midLocal.x(),
y = midLocal.y(),
z = midLocal.z();
995 double radius = sqrt(
x*
x +
y*
y);
996 double eta = midLocal.pseudoRapidity();
997 double phi = midLocal.phi() < 0 ? midLocal.phi() + 2*
M_PI : midLocal.phi();
1001 bool MapDetail =
false;
1004 int etaBin = currentCellData.
etaBin;
1005 int phiBin = currentCellData.
phiBin;
1006 int sampling = currentCellData.
sampling;
1007 int region = currentCellData.
region;
1010 double eta_min = 0.0;
1011 double delta_eta = 0.025;
1012 if (sampling == 1) {
1014 delta_eta = 0.003125;
1015 eta_min = etaBin * delta_eta;
1018 eta_min = 1.4 + etaBin * delta_eta;
1020 }
else if (sampling == 2) {
1022 eta_min = etaBin * delta_eta;
1023 }
else if (sampling == 3) {
1025 eta_min = etaBin * delta_eta;
1028 double phiGranularity = (sampling == 1 && region == 0) ? (2*
M_PI/64) : (2*
M_PI/256);
1029 double phi_min = phiBin * phiGranularity;
1031 double radius_min = 0.0;
1032 double radius_max = 0.0;
1034 if (sampling == 1) {
1036 radius_max =
Rmax1[etaBin];
1037 }
else if (sampling == 2) {
1038 radius_min =
Rmax1[etaBin];
1039 radius_max =
Rmax2[etaBin];
1040 }
else if (sampling == 3) {
1041 radius_min =
Rmax2[etaBin];
1050 double delta_eta_SR = delta_eta / nBinsEtaSR;
1051 double delta_phi_SR = phiGranularity / nBinsPhiSR;
1052 double delta_r_SR = (radius_max - radius_min) / nBinsRadiusSR;
1054 auto computeBin = [](
double val,
double min_lr,
double delta_sr,
int maxBins) {
1055 const int overflow = maxBins - 1;
1056 if (delta_sr == 0.0)
return overflow;
1057 int bin = int((val - min_lr) / delta_sr);
1058 return std::clamp(
bin, 0, overflow);;
1062 int etaBinSR = computeBin(
eta, eta_min, delta_eta_SR, nBinsEtaSR);
1063 int phiBinSR = computeBin(
phi, phi_min, delta_phi_SR, nBinsPhiSR);
1064 int rBinSR = computeBin(radius, radius_min, delta_r_SR, nBinsRadiusSR);
1072 unsigned short int packedID = ( 0x8000 )
1073 | ( (etaBinSR & 0x3F) << 9 )
1074 | ( (phiBinSR & 0x3F) << 3 )
1075 | ( rBinSR & 0x07 );
1140 const G4StepPoint *thisStepPoint = a_step->GetPreStepPoint();
1141 const G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint();
1142 const G4ThreeVector startPoint = thisStepPoint->GetPosition();
1143 const G4ThreeVector endPoint = thisStepBackPoint->GetPosition();
1144 const G4ThreeVector p = (thisStepPoint->GetPosition() + thisStepBackPoint->GetPosition()) * 0.5;
1147 ATH_MSG_VERBOSE(
"Position of the step in the ATLAS frame (x,y,z) --> " << p.x() <<
" " << p.y() <<
" " << p.z());
1148 ATH_MSG_VERBOSE(
"Eta and Phi in the ATLAS frame --> " << p.eta() <<
" " << p.phi());
1153 const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory();
1154 const G4AffineTransform transformation = g4navigation->GetTransform(indECAM);
1155 const G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint);
1156 const G4ThreeVector endPointinLocal = transformation.TransformPoint (endPoint);
1157 const G4ThreeVector midinLocal = (startPointinLocal+endPointinLocal)*0.5;
1160 ATH_MSG_VERBOSE(
"Position of the step in the LOCAL frame (x,y,z) --> " << midinLocal.x() <<
" " << midinLocal.y() <<
" " << midinLocal.z());
1161 ATH_MSG_VERBOSE(
"Eta and Phi of the step in LOCAL frame --> " << midinLocal.eta() <<
" " << midinLocal.phi());
1166 const G4double xZpos = midinLocal.x();
1167 const G4double yZpos = midinLocal.y();
1168 const G4double zZpos = midinLocal.z();
1169 const G4double etaZpos = midinLocal.pseudoRapidity();
1170 const G4double phiZpos = (midinLocal.phi()<0.) ? midinLocal.phi() + 2.*
M_PI : midinLocal.phi();
1171 const G4double radius2Zpos = xZpos*xZpos + yZpos*yZpos;
1172 const G4double radiusZpos = sqrt(radius2Zpos);
1176 currentCellData.
zSide = 1;
1179 currentCellData.
zSide = zside;
1196 const bool MapDetail(
false);
1197 this->
findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail );
1201 if( currentCellData.
zSide == -1 )
1203 if( currentCellData.
sampling == 1 && currentCellData.
region ==0 )
1206 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 64;
1208 if( currentCellData.
sampling == 1 && currentCellData.
region ==1 )
1211 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 256;
1213 if( currentCellData.
sampling >= 2 )
1216 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 256;
1224 currentCellData.
etaBin=1;
1229 << currentCellData.
zSide
1231 << currentCellData.
region
1232 << currentCellData.
etaBin
1233 << currentCellData.
phiBin;
1243 ATH_MSG_VERBOSE(
"And also etafirst ----> " << thisStepPoint->GetPosition().pseudoRapidity());
1260 const G4int numDeadPhiBins = 64;
1261 double abs_eta = std::fabs(etaZpos);
1262 const double DM1EtaWidth = 0.1 ;
1263 const double DM1PhiWidth = 2.*
M_PI / numDeadPhiBins ;
1264 currentCellData.
etaBin = (G4int) ( abs_eta * (1./DM1EtaWidth) ) ;
1265 currentCellData.
phiBin = (G4int) (phiZpos/ DM1PhiWidth );
1268 if (currentCellData.
phiBin==numDeadPhiBins) currentCellData.
phiBin=currentCellData.
phiBin-1;
1272 if ( currentCellData.
zSide == -1 ) {
1274 if (currentCellData.
phiBin < 0 ) currentCellData.
phiBin +=64 ;
1281 if (currentCellData.
etaBin > 14) currentCellData.
etaBin=14;
1284 ATH_MSG_VERBOSE(
"This hit is in the ECAM volume in front of the accordion (DEAD MATERIAL) !!!!! ");
1290 if (abs_eta < 1.0 ) {
1293 ATH_MSG_VERBOSE(
"This hit is in the ECAM volume behind accordion (DEAD MATERIAL 0) !!!!! ");
1295 }
else if ( abs_eta >= 1.0 && abs_eta < 1.5) {
1299 ATH_MSG_VERBOSE(
"This hit is in the ECAM volume behind accordion (DEAD MATERIAL 2) !!!!! ");
1302 ATH_MSG_ERROR(
" LArBarrelGeometry: hit behind accordion at eta>1.5 !!! ");
1304 currentCellData.
etaBin = 4;
1310 const G4int phisave=currentCellData.
phiBin;
1311 const G4bool MapDetail(
false);
1312 this->
findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail );
1313 sampling = currentCellData.
sampling;
1314 currentCellData.
etaBin=0;
1315 currentCellData.
phiBin=phisave;
1318 if (abs_eta >1.0 && abs_eta < 1.5) {
1322 }
else if (abs_eta < 1.6) {
1325 currentCellData.
etaBin=0;
1330 currentCellData.
etaBin=0;
1334 const G4double thisStepEnergyDeposit = a_step->GetTotalEnergyDeposit() * a_step->GetTrack()->GetWeight();
1335 std::ostringstream dmLog;
1336 dmLog <<
"LArBarrelGeometry: cannot find region for DM hit..." << std::endl;
1337 dmLog <<
"LArBarrelGeometry: cannot find region for DM hit..." << std::endl;
1338 dmLog <<
"m_zMinBarrel: " <<
m_zMinBarrel << std::endl;
1339 dmLog <<
"m_zMaxBarrel: " <<
m_zMaxBarrel << std::endl;
1342 dmLog <<
"r,z,eta,phi " << radiusZpos <<
" " << zZpos <<
" " << etaZpos <<
" " << phiZpos << std::endl;
1343 dmLog <<
"x,y,z (Atlas) " << p.x() <<
" " << p.y() <<
" " << p.z() << std::endl;
1344 dmLog <<
" inSTAC " << inSTAC << std::endl;
1345 dmLog <<
" eDeposited " << thisStepEnergyDeposit << std::endl;
1346 const G4VPhysicalVolume* vol = thisStepPoint->GetPhysicalVolume();
1347 const G4String volName = vol->GetName();
1348 dmLog <<
" volName " << volName << std::endl;
1349 const G4int ndep = g4navigation->GetDepth();
1350 for (G4int ii=0;ii<=ndep;ii++) {
1351 const G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii);
1352 const G4String vname = v1->GetName();
1353 dmLog <<
"vname " << vname << std::endl;
1355 if (thisStepEnergyDeposit > 1.*CLHEP::MeV) {
1365 G4bool MapDetail=
false;
1366 this->
findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail );
1372 currentCellData.
etaBin=1;
1378 << currentCellData.
zSide
1380 << currentCellData.
region
1381 << currentCellData.
etaBin
1382 << currentCellData.
phiBin;
1388 << currentCellData.
zSide * 4
1392 << currentCellData.
etaBin
1393 << currentCellData.
phiBin;
1396 ATH_MSG_VERBOSE(
"Here the identifier for the barrel DEAD materials ---->");