ProcessHitsMethod.
Process a single energy spot from a frozen shower. The appropriate region of the sensitive detector is calculated and a LArIdentifier is constructed
38 {
39
40
42
45
46 Point3D<double> localPosition = globalPosition.z()<0 ? xfNeg*globalPosition : xfPos*globalPosition;
47 int zIndex = globalPosition.z() <0 ? 0:1;
48 double eta = localPosition.getEta();
49 double phi = localPosition.getPhi();
50 double r = localPosition.perp();
51
52 bool implementWaves=true;
53
56 const EMBDetectorRegion *region = *
e;
59 const CellBinning & etaBinning=regionDescriptor->
getEtaBinning();
60 if (
eta>etaBinning.getStart() &&
eta<etaBinning.getEnd()) {
61 unsigned int etaIndex =
int((
eta - etaBinning.getStart())/etaBinning.getDelta()) + etaBinning.getFirstDivisionNumber();
66 if (
r>rmin &&
r<rmax) {
67 const CellBinning & phiBinning=regionDescriptor->
getPhiBinning();
68 double minPhi=std::min(phiBinning.getStart(), phiBinning.getEnd());
69 double maxPhi=std::max(phiBinning.getStart(), phiBinning.getEnd());
70
75 unsigned int phiIndex =
int((
phi - phiBinning.getStart())/phiBinning.getDelta()) + phiBinning.getFirstDivisionNumber();
76
77
78 if (samplingIndex!=0) {
80
81 double delta=-2.0*
M_PI/1024/2;
82
83 double phiLocalUpper=cellPtr->getPhiLocalUpper()-delta;
84 double phiLocalLower=cellPtr->getPhiLocalLower()-delta;
85
86 while (phiLocalLower<0) phiLocalLower += 2.0*
M_PI;
87 while (phiLocalUpper<0) phiLocalUpper += 2.0*
M_PI;
88 while (phiLocalLower>2*
M_PI) phiLocalLower -= 2.0*
M_PI;
89 while (phiLocalUpper>2*
M_PI) phiLocalUpper -= 2.0*
M_PI;
90
91 int accordionIndexUpper=
int(phiLocalUpper/(2*
M_PI)*1024+0.25);
if (accordionIndexUpper==1024) accordionIndexUpper=0;
92 int accordionIndexLower=
int(phiLocalLower/(2*
M_PI)*1024+0.25);
if (accordionIndexLower==1024) accordionIndexLower=0;
93
94 Point3D<double> A0 =
97
98 Point3D<double> A1=
101
102 Point3D<double> P0=Point3D<double>(localPosition.x(), localPosition.y(),0)-A0;
103 int stackIndex=
int(A1.dot(P0)/A1.mag2()*22.0 + 3.0)/2 ;
104
105 if (stackIndex<0 || stackIndex>13) {
106 G4cout <<
"Warning, bad stack index " << stackIndex <<
' ' << rmin <<
' ' <<
r <<
' ' << A0.perp() <<
' ' << A0 <<
' ' << A1 <<
' ' << P0 << G4endl;
107 if (implementWaves) return;
108 } else {
114
115 Point3D<double>
u(xcent-halfLength*cosU, ycent-halfLength*sinU,0);
116 Point3D<double>
v(xcent+halfLength*cosU, ycent+halfLength*sinU,0);
117 Point3D<double>
x=
v-
u,
y=Hep3Vector(localPosition.x(),localPosition.y(),0)-
u;
118 if ((zIndex==0 &&
x.cross(
y).z()>0) || (zIndex==1&&
x.cross(
y).z()<0)) {
119 if (implementWaves) {
120 if (phiIndex==0)
phiIndex=phiBinning.getNumDivisions()-1;
122 }
123 } else {
129
130 Point3D<double>
u(xcent-halfLength*cosU, ycent-halfLength*sinU,0);
131 Point3D<double>
v(xcent+halfLength*cosU, ycent+halfLength*sinU,0);
132 Point3D<double>
x=
v-
u,
y=Hep3Vector(localPosition.x(),localPosition.y(),0)-
u;
133 if ((zIndex==0 &&
x.cross(
y).z()<0) || (zIndex==1 &&
x.cross(
y).z()>0)) {
134 if (implementWaves) {
135 if (phiIndex==phiBinning.getNumDivisions()-1)
phiIndex=0;
137 }
138 }
139 }
140 }
141 }
142
143
146 << 1
148 << samplingIndex
149 << regionIndex
150 << etaIndex
151 << phiIndex;
152
154
155 return;
156 }
157 }
158 }
159
160}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Eigen::Affine3d Transform3D
GeoIntrusivePtr< const EMBCell > EMBCellConstLink
LArG4Identifier m_larID
My LAr identifier.
const CellBinning & getPhiBinning() const
The Binning in Phi.
const CellBinning & getEtaBinning() const
The Binning in Eta.
std::vector< constEMBDetectorRegion * >::const_iterator DetectorRegionConstIterator
const EMBDetDescr * getDescriptor() const
Returns the Descriptor for this region.
EMBCellConstLink getEMBCell(unsigned int ieta, unsigned int iphi) const
Access to Cells.
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index.
EMBDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
unsigned int getRegionIndex() const
Returns the Region Index.
G4ThreeVector GetPosition() const
G4double GetEnergy() const
G4bool SimpleHit(const LArG4Identifier &lar_id, G4double time, G4double energy)
First method translates to this - also for fast sims.
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
@ u
Enums for curvilinear frames.
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi