44 : base_class(
name, pSvcLocator)
73 for (G4int idat = 0; idat <
m_Nbrt1 ; idat++) {
108 return StatusCode::SUCCESS;
132 return StatusCode::SUCCESS;
154 const double &yhit,
const int &PhiCell,
int &Num_Straight,
155 const int &Num_Coude,
double &xl)
const
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; }
187 double dx = xhit - Xm[0];
188 double dy = yhit - Xm[1];
192 const double hit =
dx*
u[0] +
dy*
u[1];
199 if(std::fabs(hit) < Half_Elec) {
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
245 double dx = xhit - Xm[0];
double dy = yhit - Xm[1];
249 const double hit =
dx*
u[0] +
dy*
u[1];
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) {
445 else if (
radius>
g.rmax4 && z<g.zmax5 && aeta>1.2) {
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);
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;
600 currentCellData.nstraight=0;
602 if (
m_rc[
i] > aRadius) {
break; }
603 currentCellData.nstraight++;
605 if (currentCellData.nstraight <0 || currentCellData.nstraight >=
m_Nbrt) {
606 ATH_MSG_ERROR(
"Invalid straight number " << currentCellData.nstraight <<
" " << aRadius);
611 currentCellData.nfold=currentCellData.nstraight;
612 if (std::fabs(aRadius-
m_rc[currentCellData.nfold]) > std::fabs(aRadius-
m_rc[currentCellData.nfold+1]) ) {
613 currentCellData.nfold +=1;
615 if (currentCellData.nfold <0 || currentCellData.nfold >=
m_Nbrt1) {
616 ATH_MSG_ERROR(
"Invalid fold number " << currentCellData.nfold);
622 ATH_MSG_VERBOSE(
" BarrelGeometry: radius,eta,phi " << aRadius <<
" " << anEta <<
" ");
623 ATH_MSG_VERBOSE(
" Straight/Fold numbers " << currentCellData.nstraight <<
" " << currentCellData.nfold);
627 G4int ireg,isamp,ieta,isamp2,ieta2;
628 currentCellData.cellID = this->
SampSeg(anEta,aRadius,zPosition,ireg,isamp,ieta,isamp2,ieta2);
630 currentCellData.etaBin = ieta;
631 currentCellData.sampling = isamp;
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;
644 currentCellData.cellID=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 );
658 currentCellData.distElec=9999.;
664 G4int nstr = currentCellData.nstraight;
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; }
685 int nstr2=currentCellData.nstraight;
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;
697 currentCellData.nstraight = nstr;
700 currentCellData.phiGap=phicell;
701 currentCellData.distElec=distElec;
702 currentCellData.xl=xl;
703 currentCellData.nstraight=nstr;
707 ATH_MSG_VERBOSE(
" final phiGap,distElec,xl " << currentCellData.phiGap <<
" " << currentCellData.distElec <<
" "
708 << currentCellData.xl);
714 if (currentCellData.distElec<0) nabs=currentCellData.phiGap;
715 else nabs=currentCellData.phiGap+1;
717 currentCellData.distAbs =
Distance_Abs(xPosition,yPosition,nabs,currentCellData.nstraight,currentCellData.nfold);
719 ATH_MSG_VERBOSE(
" nabs,distAbs " << nabs <<
" " << currentCellData.distAbs);
724 if ((currentCellData.distAbs>0. && currentCellData.distElec>0) ||
725 (currentCellData.distAbs<0. && currentCellData.distElec<0) ) {
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; }
736 if (currentCellData.phiGap < 0) { currentCellData.phiGap +=
m_NCellTot; }
739 currentCellData.distElec =
Distance_Ele(xPosition,yPosition,currentCellData.phiGap,currentCellData.nstraight,currentCellData.nfold,currentCellData.xl);
744 currentCellData.phiBin = (G4int) ( currentCellData.phiGap/sampling_phi_nGaps );
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;
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);
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++) {
864 const G4double phid=
atan(
y/
x);
907 const G4double phi_hit=atan2(yhit,xhit);
908 G4double dphi=phi_hit-
phi0;
910 if (dphi<0) dphi=dphi+2*
M_PI;
912 dphi=dphi/(2*
M_PI)*1024;
913 const G4int ngap=((
int) dphi);
930 const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory();
931 const G4int ndep = g4navigation->GetDepth();
934 G4int indECAM = -999;
937 for (G4int ii=0;ii<=ndep;ii++) {
938 const G4String& vname = g4navigation->GetVolume(ii)->GetName();
940 if ( indECAM<0 && vname ==
m_ecamName ) indECAM=ii;
941 if ( !inSTAC && vname.find(
"STAC") !=std::string::npos) inSTAC=
true;
942 if ( vname.find(
"NegPhysical") != std::string::npos) zside=-1;
947 ATH_MSG_ERROR(
"LArBarrel::Geometry::CalculateIdentifier ECAM volume not found in hierarchy");
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;
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 ---->");
1291 if (type <1 || type > 2)
return false;
1293 if (sampling<1 || sampling>2)
return false;
1295 if (region!=3 && region !=4)
return false;
1296 if (phi<0 || phi>63)
return false;
1298 if (eta<0 || eta>14)
return false;
1301 if (
eta !=0)
return false;
1305 if (region !=0 && region !=2)
return false;
1306 if (phi<0 || phi>63)
return false;
1308 if (eta<0 || eta>9)
return false;
1311 if (eta<0 || eta>4)
return false;
1316 if (sampling<1 || sampling >3)
return false;
1317 if (region !=0)
return false;
1318 if (
eta!=0)
return false;
1319 if (phi<0 || phi>63)
return false;
1327 if (sampling<0 || sampling >3)
return false;
1329 if (region!=0)
return false;
1330 if (eta<0 || eta>60)
return false;
1331 if (phi<0 || phi>63)
return false;
1334 if (region<0 || region >1)
return false;
1336 if (eta<1 || eta>447)
return false;
1337 if (phi<0 || phi>63)
return false;
1340 if (eta<0 || eta>2)
return false;
1341 if (phi<0 || phi>255)
return false;
1345 if (region<0 || region >1)
return false;
1347 if (eta<0 || eta>55)
return false;
1348 if (phi<0 || phi>255)
return false;
1351 if (
eta!=0)
return false;
1352 if (phi<0 || phi>255)
return false;
1356 if (region !=0)
return false;
1357 if (eta<0 || eta>26)
return false;
1358 if (phi<0 || phi>255)
return false;