43 : base_class(
name, pSvcLocator)
44 , m_detectorName(
"LArMgr")
49 , m_zMaxBarrelDMMargin(0)
63 , m_coudeelec(nullptr)
65 , m_electrode(nullptr)
75 declareProperty(
"DetectorName",m_detectorName);
76 declareProperty(
"TestBeam", m_testbeam);
104 for (G4int idat = 0; idat <
m_Nbrt1 ; idat++) {
139 return StatusCode::SUCCESS;
163 return StatusCode::SUCCESS;
185 const double &yhit,
const int &PhiCell,
int &Num_Straight,
186 const int &Num_Coude,
double &xl)
const
199 const G4double radfold = sqrt(Xc[0]*Xc[0]+Xc[1]*Xc[1]);
200 const G4double radhit = sqrt(xhit*xhit+yhit*yhit);
204 if (Num_Coude == Num_Straight && radhit <radfold) {
205 if (Num_Straight>0) { Num_Straight = Num_Straight-1; }
208 if (Num_Coude == (Num_Straight+1) && radhit > radfold) {
209 if (Num_Straight<12) { Num_Straight = Num_Straight+1; }
218 double dx = xhit - Xm[0];
219 double dy = yhit - Xm[1];
223 const double hit =
dx*
u[0] +
dy*
u[1];
230 if(std::fabs(hit) < Half_Elec) {
241 if (Num_Coude==Num_Straight) { xl=-1.; }
259 const double &yhit,
const int &PhiCell,
const int &Num_Straight,
260 const int &Num_Coude)
const
276 double dx = xhit - Xm[0];
double dy = yhit - Xm[1];
280 const double hit =
dx*
u[0] +
dy*
u[1];
326 G4int& iregion, G4int& isampling, G4int& ieta,
327 G4int& isamp2, G4int& ieta2)
const
331 G4double Eta_max,R_max_acc,Z_max_acc,R_min_acc,Z_max_lowr,dzdr;
332 G4double zmax1,zmax2,zmax3,zmax4,zmax5,zmax6,zmax7,rmax1,rmax2,rmax3,rmax4;
336 static const Geo
g = []() {
341 g.Eta_max =
parameters->GetValue(
"LArEMBMaxEtaAcceptance");
343 g.R_min_acc=
parameters->GetValue(
"LArEMBRadiusInnerAccordion");
345 g.R_max_acc =
parameters->GetValue(
"LArEMBFiducialRmax");
348 g.Z_max_acc =
parameters->GetValue(
"LArEMBfiducialMothZmax");
350 const G4double R_min_highz=1548.;
353 const G4double deltaz=7.;
354 g.zmax1=
g.Z_max_acc-deltaz;
355 g.zmax2=
g.Z_max_acc-2.*deltaz;
356 g.zmax3=
g.Z_max_acc-3.*deltaz;
357 g.zmax4=
g.Z_max_acc-4.*deltaz;
358 g.zmax5=
g.Z_max_acc-5.*deltaz;
359 g.zmax6=
g.Z_max_acc-6.*deltaz;
360 g.zmax7=
g.Z_max_acc-7.*deltaz;
361 g.rmax1=
g.R_max_acc-deltaz;
362 g.rmax2=
g.R_max_acc-2.*deltaz;
363 g.rmax3=
g.R_max_acc-3.*deltaz;
364 g.rmax4=
g.R_max_acc-4.*deltaz;
367 g.Z_max_lowr = sinh(
g.Eta_max)*
g.R_min_acc;
369 g.dzdr = (
g.Z_max_acc-
g.Z_max_lowr)/(R_min_highz-
g.R_min_acc);
380 const G4double Dr_s12=1.1;
381 const G4double Eta_max_s1=1.4;
382 const G4double Eta_max_s3=1.325;
383 const G4double deta=0.025;
389 const G4double aeta=std::fabs(eta);
400 if (aeta<Eta_max_s1) {
403 istrip=(
int) (aeta/deta*8.);
404 if (istrip<0 || istrip >=448) {
405 ATH_MSG_ERROR(
" Problem aeta,istrip " << aeta <<
" " << istrip);
411 imid = (
int) (aeta/deta);
412 if (imid <0 || imid >=56) {
424 if (ieta==0) iactive=0;
430 else if (
radius < (r12+Dr_s12)) {
441 if (aeta<Eta_max_s3) {
456 else if (
z>
g.zmax2) {
460 else if (
z>
g.zmax3) {
464 else if (
z>
g.zmax4) {
468 else if (aeta<1.3 && z>
g.zmax5) {
472 else if (aeta<1.3 && z>
g.zmax6) {
476 else if (
radius>
g.rmax4 && z<g.zmax5 && aeta>1.2) {
517 if (isampling==3 &&
z<
g.zmax4 && (
radius<
g.rmax4 || aeta<1.2) ) {
518 const double etastr = (imid%2==0) ? 0.025*imid : 0.025*(imid+1);
519 const double delta=
radius*(sinh(etastr)-sinh(aeta))/cosh(etastr);
521 if (aeta<0.475) { deltastr=1.5;}
522 else if (aeta<0.80) { deltastr=2.75;}
523 else if (aeta<0.85) { deltastr=1.5;}
524 else if (aeta<1.1) { deltastr=2.75;}
525 else { deltastr=3.25;}
527 if (std::fabs(delta)<deltastr) {
539 else if (
z>
g.zmax2 && aeta<1.375) {
550 if (aeta>=Eta_max_s1 && aeta<
g.Eta_max) {
552 r23=
g.Z_max_acc/sinh(aeta);
554 const double zmax =
g.Z_max_lowr +
g.dzdr*(
radius-
g.R_min_acc);
559 ieta=
int((aeta-Eta_max_s1)/deta);
560 if (
z>
zmax) { iactive=0; }
562 else if (
radius < (r12+Dr_s12)) {
564 ieta=
int((aeta-Eta_max_s1)/deta);
570 if (
z>
zmax) { iactive=0; }
582 if (aeta>
g.Eta_max) {
599 if (
z>
g.Z_max_acc ||
radius>
g.R_max_acc || radius<g.R_min_acc || aeta >
g.Eta_max) iactive=0;
612 const double &xPosition,
613 const double &yPosition,
614 const double &zPosition,
615 const double &aRadius,
618 const bool MapDetail)
const
621 currentCellData.cellID = 0;
631 currentCellData.nstraight=0;
633 if (
m_rc[
i] > aRadius) {
break; }
634 currentCellData.nstraight++;
636 if (currentCellData.nstraight <0 || currentCellData.nstraight >=
m_Nbrt) {
637 ATH_MSG_ERROR(
"Invalid straight number " << currentCellData.nstraight <<
" " << aRadius);
642 currentCellData.nfold=currentCellData.nstraight;
643 if (std::fabs(aRadius-
m_rc[currentCellData.nfold]) > std::fabs(aRadius-
m_rc[currentCellData.nfold+1]) ) {
644 currentCellData.nfold +=1;
646 if (currentCellData.nfold <0 || currentCellData.nfold >=
m_Nbrt1) {
647 ATH_MSG_ERROR(
"Invalid fold number " << currentCellData.nfold);
653 ATH_MSG_VERBOSE(
" BarrelGeometry: radius,eta,phi " << aRadius <<
" " << anEta <<
" ");
654 ATH_MSG_VERBOSE(
" Straight/Fold numbers " << currentCellData.nstraight <<
" " << currentCellData.nfold);
658 G4int ireg,isamp,ieta,isamp2,ieta2;
659 currentCellData.cellID = this->
SampSeg(anEta,aRadius,zPosition,ireg,isamp,ieta,isamp2,ieta2);
661 currentCellData.etaBin = ieta;
662 currentCellData.sampling = isamp;
663 currentCellData.region = ireg;
664 currentCellData.etaMap = ieta2;
665 currentCellData.sampMap = isamp2;
668 int phicell = this->
PhiGap(aRadius,xPosition,yPosition);
669 if (phicell<0) phicell=0;
675 currentCellData.cellID=0;
684 int sampling_phi_nGaps=4;
685 if (currentCellData.region==0 && currentCellData.sampling==1) { sampling_phi_nGaps=16; }
687 if (currentCellData.cellID==0) {
688 currentCellData.phiBin = (G4int) ( phicell/sampling_phi_nGaps );
689 currentCellData.distElec=9999.;
695 G4int nstr = currentCellData.nstraight;
696 const G4double distElec = this->
Distance_Ele(xPosition,yPosition,phicell,nstr,currentCellData.nfold,xl);
703 if (std::fabs(distElec) > 2.5) {
705 double dElecMin=distElec;
707 int phicellmin=phicell;
708 for (
int ii=-2;ii<3;ii++) {
709 if (ii==0) {
continue; }
710 int phicellnew = phicell+ii;
713 if (phicellnew < 0) { phicellnew +=
m_NCellTot; }
716 int nstr2=currentCellData.nstraight;
717 double dElec =
Distance_Ele(xPosition,yPosition,phicellnew,nstr2,currentCellData.nfold,xln);
718 if (std::fabs(dElec)<std::fabs(dElecMin)) {
719 phicellmin=phicellnew;
725 currentCellData.phiGap = phicellmin;
726 currentCellData.distElec = dElecMin;
727 currentCellData.xl = xlmin;
728 currentCellData.nstraight = nstr;
731 currentCellData.phiGap=phicell;
732 currentCellData.distElec=distElec;
733 currentCellData.xl=xl;
734 currentCellData.nstraight=nstr;
738 ATH_MSG_VERBOSE(
" final phiGap,distElec,xl " << currentCellData.phiGap <<
" " << currentCellData.distElec <<
" "
739 << currentCellData.xl);
745 if (currentCellData.distElec<0) nabs=currentCellData.phiGap;
746 else nabs=currentCellData.phiGap+1;
748 currentCellData.distAbs =
Distance_Abs(xPosition,yPosition,nabs,currentCellData.nstraight,currentCellData.nfold);
750 ATH_MSG_VERBOSE(
" nabs,distAbs " << nabs <<
" " << currentCellData.distAbs);
755 if ((currentCellData.distAbs>0. && currentCellData.distElec>0) ||
756 (currentCellData.distAbs<0. && currentCellData.distElec<0) ) {
759 if (std::fabs(currentCellData.distElec)>std::fabs(currentCellData.distAbs)) {
760 if (currentCellData.distAbs>0) { currentCellData.phiGap += 1; }
761 if (currentCellData.distAbs<0) { currentCellData.phiGap -= 1; }
763 if (currentCellData.phiGap <0) { currentCellData.phiGap=0; }
767 if (currentCellData.phiGap < 0) { currentCellData.phiGap +=
m_NCellTot; }
770 currentCellData.distElec =
Distance_Ele(xPosition,yPosition,currentCellData.phiGap,currentCellData.nstraight,currentCellData.nfold,currentCellData.xl);
775 currentCellData.phiBin = (G4int) ( currentCellData.phiGap/sampling_phi_nGaps );
780 const G4double alpha =
m_coudeelec->
PhiRot(currentCellData.nfold,currentCellData.phiGap);
783 const G4double dx1=
dx*
cos(alpha)-
dy*
sin(alpha);
784 const G4double dy1=
dx*
sin(alpha)+
dy*
cos(alpha);
785 currentCellData.x0 = dx1 +
m_xc[currentCellData.nfold];
786 currentCellData.y0 = dy1 +
m_yc[currentCellData.nfold];
787 if (
m_parity==1) { currentCellData.y0 = -1*currentCellData.y0; }
797 const G4double
dl=0.001;
798 const G4double inv_dl = 1. /
dl;
799 G4double cenx[15],ceny[15];
801 G4double sum1[5000],sumx[5000];
810 const G4double inv_rint = 1. / rint;
811 const G4double
dt=
dl * inv_rint;
812 const G4double inv_dt = 1. /
dt;
818 for (G4int
i=0;
i<15;
i++) {
823 for (G4int
i=0;
i<15;
i++) {
860 const G4int nstep=
int((phi1-
phi0)*inv_dt)+1;
861 for (
int ii=0;ii<nstep;ii++) {
863 const G4double
phi=
phi0+
dt*((G4double)ii);
864 const G4double
x=cenx[
i]+rint*
cos(phi);
865 const G4double
y=ceny[
i]+rint*
sin(phi);
868 const G4double phid=
atan(
y/
x);
878 const G4double
dx=cenx[
i+1]-cenx[
i];
879 const G4double
dy=ceny[
i+1]-ceny[
i];
880 const G4double along=std::sqrt(
dx*
dx+
dy*
dy-4.*rint*rint);
881 const G4double
x0=0.5*(cenx[
i+1]+cenx[
i]);
882 const G4double
y0=0.5*(ceny[
i+1]+ceny[
i]);
884 const G4double
x1=
x0-0.5*along*
cos(phi);
885 const G4double
y1=
y0-0.5*along*
sin(phi);
887 const int nstep=
int(along*inv_dl)+1;
888 for (
int ii=0;ii<nstep;ii++) {
890 const G4double
x=
x1+
dl*((G4double)ii)*
cos(phi);
891 const G4double
y=
y1+
dl*((G4double)ii)*
sin(phi);
894 const G4double phid=
atan(
y/
x);
937 const G4double phi_hit=atan2(yhit,xhit);
938 G4double dphi=phi_hit-
phi0;
940 if (dphi<0) dphi=dphi+2*
M_PI;
942 dphi=dphi/(2*
M_PI)*1024;
943 const G4int ngap=((
int) dphi);
960 const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory();
961 const G4int ndep = g4navigation->GetDepth();
964 G4int indECAM = -999;
967 for (G4int ii=0;ii<=ndep;ii++) {
968 const G4String& vname = g4navigation->GetVolume(ii)->GetName();
970 if ( indECAM<0 && vname ==
m_ecamName ) indECAM=ii;
971 if ( !inSTAC && vname.find(
"STAC") !=std::string::npos) inSTAC=
true;
972 if ( vname.find(
"NegPhysical") != std::string::npos) zside=-1;
977 ATH_MSG_ERROR(
"LArBarrel::Geometry::CalculateIdentifier ECAM volume not found in hierarchy");
1040 const G4StepPoint *thisStepPoint = a_step->GetPreStepPoint();
1041 const G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint();
1042 const G4ThreeVector startPoint = thisStepPoint->GetPosition();
1043 const G4ThreeVector endPoint = thisStepBackPoint->GetPosition();
1044 const G4ThreeVector
p = (thisStepPoint->GetPosition() + thisStepBackPoint->GetPosition()) * 0.5;
1047 ATH_MSG_VERBOSE(
"Position of the step in the ATLAS frame (x,y,z) --> " <<
p.x() <<
" " <<
p.y() <<
" " <<
p.z());
1048 ATH_MSG_VERBOSE(
"Eta and Phi in the ATLAS frame --> " <<
p.eta() <<
" " <<
p.phi());
1053 const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory();
1054 const G4AffineTransform transformation = g4navigation->GetTransform(indECAM);
1055 const G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint);
1056 const G4ThreeVector endPointinLocal = transformation.TransformPoint (endPoint);
1057 const G4ThreeVector midinLocal = (startPointinLocal+endPointinLocal)*0.5;
1060 ATH_MSG_VERBOSE(
"Position of the step in the LOCAL frame (x,y,z) --> " << midinLocal.x() <<
" " << midinLocal.y() <<
" " << midinLocal.z());
1061 ATH_MSG_VERBOSE(
"Eta and Phi of the step in LOCAL frame --> " << midinLocal.eta() <<
" " << midinLocal.phi());
1066 const G4double xZpos = midinLocal.x();
1067 const G4double yZpos = midinLocal.y();
1068 const G4double zZpos = midinLocal.z();
1069 const G4double etaZpos = midinLocal.pseudoRapidity();
1070 const G4double phiZpos = (midinLocal.phi()<0.) ? midinLocal.phi() + 2.*
M_PI : midinLocal.phi();
1071 const G4double radius2Zpos = xZpos*xZpos + yZpos*yZpos;
1072 const G4double radiusZpos = sqrt(radius2Zpos);
1076 currentCellData.
zSide = 1;
1079 currentCellData.
zSide = zside;
1096 const bool MapDetail(
false);
1097 this->
findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail );
1101 if( currentCellData.
zSide == -1 )
1103 if( currentCellData.
sampling == 1 && currentCellData.
region ==0 )
1106 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 64;
1108 if( currentCellData.
sampling == 1 && currentCellData.
region ==1 )
1111 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 256;
1113 if( currentCellData.
sampling >= 2 )
1116 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 256;
1124 currentCellData.
etaBin=1;
1129 << currentCellData.
zSide
1131 << currentCellData.
region
1132 << currentCellData.
etaBin
1133 << currentCellData.
phiBin;
1143 ATH_MSG_VERBOSE(
"And also etafirst ----> " << thisStepPoint->GetPosition().pseudoRapidity());
1160 const G4int numDeadPhiBins = 64;
1161 double abs_eta = std::fabs(etaZpos);
1162 const double DM1EtaWidth = 0.1 ;
1163 const double DM1PhiWidth = 2.*
M_PI / numDeadPhiBins ;
1164 currentCellData.
etaBin = (G4int) ( abs_eta * (1./DM1EtaWidth) ) ;
1165 currentCellData.
phiBin = (G4int) (phiZpos/ DM1PhiWidth );
1168 if (currentCellData.
phiBin==numDeadPhiBins) currentCellData.
phiBin=currentCellData.
phiBin-1;
1172 if ( currentCellData.
zSide == -1 ) {
1174 if (currentCellData.
phiBin < 0 ) currentCellData.
phiBin +=64 ;
1181 if (currentCellData.
etaBin > 14) currentCellData.
etaBin=14;
1184 ATH_MSG_VERBOSE(
"This hit is in the ECAM volume in front of the accordion (DEAD MATERIAL) !!!!! ");
1190 if (abs_eta < 1.0 ) {
1193 ATH_MSG_VERBOSE(
"This hit is in the ECAM volume behind accordion (DEAD MATERIAL 0) !!!!! ");
1195 }
else if ( abs_eta >= 1.0 && abs_eta < 1.5) {
1199 ATH_MSG_VERBOSE(
"This hit is in the ECAM volume behind accordion (DEAD MATERIAL 2) !!!!! ");
1202 ATH_MSG_ERROR(
" LArBarrelGeometry: hit behind accordion at eta>1.5 !!! ");
1204 currentCellData.
etaBin = 4;
1210 const G4int phisave=currentCellData.
phiBin;
1211 const G4bool MapDetail(
false);
1212 this->
findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail );
1213 sampling = currentCellData.
sampling;
1214 currentCellData.
etaBin=0;
1215 currentCellData.
phiBin=phisave;
1218 if (abs_eta >1.0 && abs_eta < 1.5) {
1222 }
else if (abs_eta < 1.6) {
1225 currentCellData.
etaBin=0;
1230 currentCellData.
etaBin=0;
1234 const G4double thisStepEnergyDeposit = a_step->GetTotalEnergyDeposit() * a_step->GetTrack()->GetWeight();
1235 std::ostringstream dmLog;
1236 dmLog <<
"LArBarrelGeometry: cannot find region for DM hit..." << std::endl;
1237 dmLog <<
"LArBarrelGeometry: cannot find region for DM hit..." << std::endl;
1238 dmLog <<
"m_zMinBarrel: " <<
m_zMinBarrel << std::endl;
1239 dmLog <<
"m_zMaxBarrel: " <<
m_zMaxBarrel << std::endl;
1242 dmLog <<
"r,z,eta,phi " << radiusZpos <<
" " << zZpos <<
" " << etaZpos <<
" " << phiZpos << std::endl;
1243 dmLog <<
"x,y,z (Atlas) " <<
p.x() <<
" " <<
p.y() <<
" " <<
p.z() << std::endl;
1244 dmLog <<
" inSTAC " << inSTAC << std::endl;
1245 dmLog <<
" eDeposited " << thisStepEnergyDeposit << std::endl;
1246 const G4VPhysicalVolume* vol = thisStepPoint->GetPhysicalVolume();
1247 const G4String volName = vol->GetName();
1248 dmLog <<
" volName " << volName << std::endl;
1249 const G4int ndep = g4navigation->GetDepth();
1250 for (G4int ii=0;ii<=ndep;ii++) {
1251 const G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii);
1252 const G4String vname = v1->GetName();
1253 dmLog <<
"vname " << vname << std::endl;
1265 G4bool MapDetail=
false;
1266 this->
findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail );
1272 currentCellData.
etaBin=1;
1278 << currentCellData.
zSide
1280 << currentCellData.
region
1281 << currentCellData.
etaBin
1282 << currentCellData.
phiBin;
1288 << currentCellData.
zSide * 4
1292 << currentCellData.
etaBin
1293 << currentCellData.
phiBin;
1296 ATH_MSG_VERBOSE(
"Here the identifier for the barrel DEAD materials ---->");
1321 if (type <1 || type > 2)
return false;
1323 if (sampling<1 || sampling>2)
return false;
1325 if (region!=3 && region !=4)
return false;
1326 if (phi<0 || phi>63)
return false;
1328 if (eta<0 || eta>14)
return false;
1331 if (eta !=0)
return false;
1335 if (region !=0 && region !=2)
return false;
1336 if (phi<0 || phi>63)
return false;
1338 if (eta<0 || eta>9)
return false;
1341 if (eta<0 || eta>4)
return false;
1346 if (sampling<1 || sampling >3)
return false;
1347 if (region !=0)
return false;
1348 if (eta!=0)
return false;
1349 if (phi<0 || phi>63)
return false;
1357 if (sampling<0 || sampling >3)
return false;
1359 if (region!=0)
return false;
1360 if (eta<0 || eta>60)
return false;
1361 if (phi<0 || phi>63)
return false;
1364 if (region<0 || region >1)
return false;
1366 if (eta<1 || eta>447)
return false;
1367 if (phi<0 || phi>63)
return false;
1370 if (eta<0 || eta>2)
return false;
1371 if (phi<0 || phi>255)
return false;
1375 if (region<0 || region >1)
return false;
1377 if (eta<0 || eta>55)
return false;
1378 if (phi<0 || phi>255)
return false;
1381 if (eta!=0)
return false;
1382 if (phi<0 || phi>255)
return false;
1386 if (region !=0)
return false;
1387 if (eta<0 || eta>26)
return false;
1388 if (phi<0 || phi>255)
return false;