31 #include "G4AffineTransform.hh"
32 #include "G4NavigationHistory.hh"
34 #include "G4ThreeVector.hh"
35 #include "G4StepPoint.hh"
47 namespace BarrelPresampler {
50 : base_class(
name, pSvcLocator)
57 Geometry::~Geometry() {;}
67 m_end_module[0]=(
m_mod[0][0]*
m_cmm+2*eps)+m_zminPS+eps;
68 for (
int i=1;
i<8;
i++) m_end_module[
i]=m_end_module[
i-1]+(
m_mod[
i][0]*
m_cmm+2*eps)+eps;
70 for (
int i=0;
i<8;
i++) {
77 m_first_cathod[0]=m_zminPS+
m_mod[0][5]*
m_cmm+m_cat_th/2.+2*eps;
78 for (
int i=1;
i<8;
i++) m_first_cathod[
i]=m_end_module[
i-1]+
m_mod[
i][5]*
m_cmm+m_cat_th/2.+2*eps;
85 for (
int i=0;
i<7;
i++) m_ncell_module[
i]=8;
92 for (
int i=0;
i<7;
i++) m_ngap_cell[
i]=(
int)((
m_mod[
i][1]+0.1)/m_ncell_module[
i]);
101 return StatusCode::SUCCESS;
116 LArG4Identifier Geometry::CalculateIdentifier(
const G4Step* a_step)
const
118 const static G4String fullPSName = (m_detectorName.empty()) ?
"LAr::Barrel::Presampler" : G4String(m_detectorName+
"::LAr::Barrel::Presampler");
119 const static G4String fullCryoName = (m_detectorName.empty()) ?
"LAr::TBBarrel::Cryostat::LAr" : G4String(m_detectorName+
"::LAr::TBBarrel::Cryostat::LAr");
120 const static G4String fullModuleName = (m_detectorName.empty()) ?
"LAr::Barrel::Presampler::Module" : G4String(m_detectorName+
"::LAr::Barrel::Presampler::Module");
123 const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory();
124 const G4int ndep = g4navigation->GetDepth();
129 for (G4int ii=0;ii<=ndep;ii++) {
131 const G4String& vname = g4navigation->GetVolume(ii)->GetName();
132 if (idep<0 && vname==fullPSName) idep=ii;
133 else if (!iactive && vname==fullModuleName) iactive=
true;
136 if (idep < 0) std::abort();
139 return this->CalculatePSActiveIdentifier( a_step , idep );
141 return this->CalculatePS_DMIdentifier( a_step , idep );
150 LArG4Identifier Geometry::CalculatePSActiveIdentifier(
const G4Step* a_step,
const G4int
ind)
const
154 const G4ThreeVector
p = (a_step->GetPostStepPoint()->GetPosition() + a_step->GetPreStepPoint()->GetPosition()) * 0.5;
157 ATH_MSG_VERBOSE(
"Position of the step in the ATLAS frame (x,y,z) --> " <<
p.x() <<
" " <<
p.y() <<
" " <<
p.z());
158 ATH_MSG_VERBOSE(
"Eta and Phi in the atlas frame --> " <<
p.eta() <<
" " <<
p.phi());
163 const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory();
164 const G4ThreeVector ploc = g4navigation->GetTransform(
ind).TransformPoint(
p);
166 const G4int zSide(this->determineZSide(
p.z()));
169 (void)this->findCell(currentCellData,ploc.x(),ploc.y(),ploc.z());
175 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 64;
185 << currentCellData.
phiBin;
188 ATH_MSG_VERBOSE(
"Here the identifier for the presampler ACTIVE ----> ");
201 LArG4Identifier Geometry::CalculatePS_DMIdentifier(
const G4Step* a_step,
const G4int
ind)
const
225 const G4ThreeVector
p = (a_step->GetPostStepPoint()->GetPosition() + a_step->GetPreStepPoint()->GetPosition()) * 0.5;
228 ATH_MSG_VERBOSE(
"Position of the step in the ATLAS frame (x,y,z) --> " <<
p.x() <<
" " <<
p.y() <<
" " <<
p.z());
229 ATH_MSG_VERBOSE(
"Eta and Phi in the atlas frame --> " <<
p.eta() <<
" " <<
p.phi());
235 const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory();
236 const G4ThreeVector ploc = g4navigation->GetTransform(
ind).TransformPoint(
p);
237 const G4double
radius=sqrt(ploc.x()*ploc.x() + ploc.y()*ploc.y());
240 const G4ThreeVector ploc2(ploc.x(),ploc.y(),ploc.z()+m_zpres+m_zminPS);
243 ATH_MSG_VERBOSE(
"Position of the step after traslation (x,y,z) --> " << ploc2.x() <<
" " << ploc2.y() <<
" " << ploc2.z());
244 ATH_MSG_VERBOSE(
"Eta and Phi after translation --> " << ploc2.eta() <<
" " << ploc2.phi());
248 const G4int zSide(this->determineZSide(
p.z()));
251 const G4double
phi = (ploc2.phi() < 0.) ? ploc2.phi()+2.*
M_PI : ploc2.phi();
252 const G4double
eta = ploc2.eta();
263 const G4int numberPhiMod = 32;
264 const G4double dphi = ( 2.*
M_PI ) / numberPhiMod;
265 const G4double inv_dphi = 1. / dphi;
266 const G4double PSModuleRmean = 1420 ;
268 const G4double Rcheck = PSModuleRmean /
cos(
phicheck);
271 currentCellData.
region = 3;
273 currentCellData.
region = 2;
276 const G4double detaDM = 0.1 ;
277 const G4double dphiDM = ( 2 *
M_PI ) / 64. ;
279 currentCellData.
phiBin = G4int(
phi * (1. / dphiDM) );
280 currentCellData.
etaBin = G4int(
eta * (1. / detaDM) );
285 if(currentCellData.
phiBin < 0 ) currentCellData.
phiBin += 64;
289 if ( currentCellData.
phiBin == 64 ) currentCellData.
phiBin = 0;
299 << currentCellData.
phiBin;
302 ATH_MSG_VERBOSE(
"Here the identifier for the presampler DEAD materials ---->");
338 bool Geometry::findCell(CalcData & currentCellData, G4double xloc,G4double yloc,G4double zloc)
const
341 currentCellData.sampling = 0;
342 currentCellData.region = 0;
345 G4double
phi = atan2(yloc,xloc);
347 const G4double z2=fabs(zloc+m_zpres+m_zminPS);
350 const G4int numberPhiBins = 64;
351 const G4double dphi = ( 2.*
M_PI ) / numberPhiBins;
352 const G4double inv_dphi = 1. / dphi;
354 currentCellData.phiBin = G4int(
phi * inv_dphi );
355 if (currentCellData.phiBin >63) currentCellData.phiBin=63;
356 if (currentCellData.phiBin <0) currentCellData.phiBin=0;
361 if (z2 < m_zminPS ) {
362 currentCellData.etaBin=0;
365 if (z2 > m_end_module[7]) {
366 currentCellData.etaBin=60;
371 currentCellData.module=0;
372 for (
int i=1;
i<8;
i++) {
373 if (m_first_cathod[
i]>=z2)
break;
374 currentCellData.module++;
376 if (currentCellData.module <0 || currentCellData.module > 7)
378 G4cerr <<
"LArBarrelPresampler: invalid module/hit " << currentCellData.module <<
" " << z2 << G4endl;
379 if (currentCellData.module<0) currentCellData.etaBin=0;
380 if (currentCellData.module>7) currentCellData.etaBin=60;
391 ATH_MSG_VERBOSE(
"sector number, dist along height " << isect <<
" " << currentCellData.dist);
392 ATH_MSG_VERBOSE(
"z2,module number,m_first_cathod " << z2 <<
" " << currentCellData.module <<
" "
393 << m_first_cathod[currentCellData.module]);
398 G4double deltaz=z2-(m_first_cathod[currentCellData.module]+currentCellData.dist*
tan(m_tilt[currentCellData.module]));
400 if (currentCellData.module>0) {
401 currentCellData.module=currentCellData.module-1;
402 deltaz=z2-(m_first_cathod[currentCellData.module]+currentCellData.dist*
tan(m_tilt[currentCellData.module]));
408 currentCellData.gap = ((
int)(deltaz/m_pitch[currentCellData.module]));
411 ATH_MSG_VERBOSE(
"deltaz from first cathode,gap number " << deltaz <<
" " << currentCellData.gap);
415 currentCellData.etaBin= currentCellData.gap/m_ngap_cell[currentCellData.module];
419 if (currentCellData.etaBin >= m_ncell_module[currentCellData.module]) currentCellData.etaBin=m_ncell_module[currentCellData.module]-1;
421 for (
int i=0;
i<currentCellData.module;
i++) currentCellData.etaBin=currentCellData.etaBin+m_ncell_module[
i];
426 if (currentCellData.etaBin < 0 || currentCellData.etaBin > 60) {
427 ATH_MSG_WARNING(
"LArBarrelPresamplerGeometry::findCell etaBin outside range " << currentCellData.etaBin);
431 const G4double zmiddle=m_first_cathod[currentCellData.module]+((
double)(currentCellData.gap+0.5))*m_pitch[currentCellData.module];
436 currentCellData.xElec=currentCellData.dist*
cos(m_tilt[currentCellData.module])+(z2-zmiddle)*
sin(m_tilt[currentCellData.module]);
437 currentCellData.distElec=(z2-zmiddle)*
cos(m_tilt[currentCellData.module]) - currentCellData.dist*
sin(m_tilt[currentCellData.module]);
439 ATH_MSG_VERBOSE(
"zmiddle,xloc,yloc " << zmiddle <<
" " << currentCellData.distElec <<
" " << currentCellData.xElec);
443 if (fabs(currentCellData.dist)>m_halfThickLAr) {