@@ -73,11 +73,18 @@ double Geometry::getSamplingPhiMin()
7373 return (superModuleDeltaPhi - samplingDeltaPhi * mNSamplingModulesPhi ) / 2 .;
7474}
7575
76+ double Geometry::getFrontFaceMaxEta (int i)
77+ {
78+ double theta = std::atan (mRMin / getFrontFaceZatMinR (i));
79+ return -std::log (std::tan (theta / 2 .));
80+ }
81+
7682// ==============================================================================
7783void Geometry::fillFrontFaceCenterCoordinates ()
7884{
79- if (mFrontFaceCenterR .size () > 0 )
85+ if (mFrontFaceCenterR .size () > 0 ) {
8086 return ;
87+ }
8188 mFrontFaceCenterTheta .resize (mNCrystalModulesZ + mNSamplingModulesZ );
8289 mFrontFaceZatMinR .resize (mNCrystalModulesZ + mNSamplingModulesZ );
8390 mFrontFaceCenterR .resize (mNCrystalModulesZ + mNSamplingModulesZ );
@@ -153,7 +160,7 @@ int Geometry::getCellID(int moduleId, int sectorId, bool isCrystal)
153160 if (sectorId % 2 == 0 ) { // sampling at positive eta
154161 cellID = sectorId / 2 * mNModulesZ + moduleId + mNSamplingModulesZ + mNCrystalModulesZ * 2 ;
155162 } else { // sampling at negative eta
156- cellID = sectorId / 2 * mNModulesZ - moduleId + mNSamplingModulesZ ;
163+ cellID = sectorId / 2 * mNModulesZ - moduleId + mNSamplingModulesZ - 1 ;
157164 }
158165 }
159166 return cellID;
@@ -206,13 +213,15 @@ void Geometry::detIdToGlobalPosition(int detId, double& x, double& y, double& z)
206213{
207214 int chamber, sector, iphi, iz;
208215 detIdToRelIndex (detId, chamber, sector, iphi, iz);
216+ double r = 0 ;
209217 if (iz < mNSamplingModulesZ + mNCrystalModulesZ ) {
210218 z = -mFrontFaceCenterZ [mNSamplingModulesZ + mNCrystalModulesZ - iz - 1 ];
219+ r = mFrontFaceCenterR [mNSamplingModulesZ + mNCrystalModulesZ - iz - 1 ];
211220 } else {
212- z = +mFrontFaceCenterZ [iz % (mNSamplingModulesZ + mNCrystalModulesZ )];
221+ z = mFrontFaceCenterZ [iz % (mNSamplingModulesZ + mNCrystalModulesZ )];
222+ r = mFrontFaceCenterR [iz % (mNSamplingModulesZ + mNCrystalModulesZ )];
213223 }
214224 double phi = chamber == 1 ? mFrontFaceCenterCrystalPhi [iphi] : mFrontFaceCenterSamplingPhi [iphi];
215- double r = mFrontFaceCenterR [iz % (mNSamplingModulesZ + mNCrystalModulesZ )];
216225 x = r * std::cos (phi);
217226 y = r * std::sin (phi);
218227}
@@ -224,40 +233,45 @@ int Geometry::areNeighboursVertex(int detId1, int detId2) const
224233 int ch2, sector2, iphi2, iz2;
225234 detIdToRelIndex (detId1, ch1, sector1, iphi1, iz1);
226235 detIdToRelIndex (detId2, ch2, sector2, iphi2, iz2);
227- if (sector1 != sector2 || ch1 != ch2)
236+ if (sector1 != sector2 || ch1 != ch2) {
228237 return 0 ;
229- if (std::abs (iphi1 - iphi2) <= 1 && std::abs (iz1 - iz2) <= 1 )
238+ }
239+ if (std::abs (iphi1 - iphi2) <= 1 && std::abs (iz1 - iz2) <= 1 ) {
230240 return 1 ;
241+ }
231242 return 0 ;
232243}
233244
234245// ==============================================================================
235246bool Geometry::isAtTheEdge (int cellId)
236247{
237248 auto [row, col] = globalRowColFromIndex (cellId);
238- if (col == 0 )
249+ if (col == 0 ) {
239250 return 1 ;
240- if (col == mNSamplingModulesZ )
251+ } else if (col == mNSamplingModulesZ ) {
241252 return 1 ;
242- if (col == mNSamplingModulesZ - 1 )
253+ } else if (col == mNSamplingModulesZ - 1 ) {
243254 return 1 ;
244- if (col == mNSamplingModulesZ + 2 * mNCrystalModulesZ )
255+ } else if (col == mNSamplingModulesZ + 2 * mNCrystalModulesZ ) {
245256 return 1 ;
246- if (col == mNSamplingModulesZ + 2 * mNCrystalModulesZ - 1 )
257+ } else if (col == mNSamplingModulesZ + 2 * mNCrystalModulesZ - 1 ) {
247258 return 1 ;
248- if (col == mNModulesZ - 1 )
259+ } else if (col == mNModulesZ - 1 ) {
249260 return 1 ;
261+ }
250262 for (int m = 0 ; m <= mNSuperModules ; m++) {
251263 if (isCrystal (cellId)) {
252- if (row == m * mNCrystalModulesPhi )
264+ if (row == m * mNCrystalModulesPhi ) {
253265 return 1 ;
254- if (row == m * mNCrystalModulesPhi - 1 )
266+ } else if (row == m * mNCrystalModulesPhi - 1 ) {
255267 return 1 ;
268+ }
256269 } else {
257- if (row == m * mNSamplingModulesPhi )
270+ if (row == m * mNSamplingModulesPhi ) {
258271 return 1 ;
259- if (row == m * mNSamplingModulesPhi - 1 )
272+ } else if (row == m * mNSamplingModulesPhi - 1 ) {
260273 return 1 ;
274+ }
261275 }
262276 }
263277 return 0 ;
0 commit comments