1818#include " MathUtils/Cartesian.h"
1919#include " SimulationDataFormat/MCTruthContainer.h"
2020#include " DetectorsRaw/HBFUtils.h"
21+ #include " CommonConstants/MathConstants.h"
2122
2223#include < TRandom.h>
2324#include < climits>
@@ -37,10 +38,13 @@ using namespace o2::its3;
3738
3839void Digitizer::init ()
3940{
41+ mLayerID .clear ();
42+ mSuperSegmentations .clear ();
4043 for (int iLayer{0 }; iLayer < mGeometry ->getNumberOfLayers () - 4 ; ++iLayer) {
4144 for (int iChip{0 }; iChip < mGeometry ->getNumberOfChipsPerLayer (iLayer); ++iChip) {
4245 LOGP (info, " layer: {} chip: {}" , iLayer, iChip);
4346 mSuperSegmentations .push_back (SegmentationSuperAlpide (iLayer));
47+ mLayerID .push_back (iLayer);
4448 }
4549 }
4650
@@ -232,17 +236,22 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, uint32_t& maxFr, int evID
232236 float gap = 0.1 ; // FIXME: get this properly!
233237 auto startPos = hit.GetPosStart ();
234238 // LOGP(info, "StartPos: {} {} {}", startPos.X(), startPos.Y(), startPos.Z());
235- float reShiftedStartY = (startPos.Y () > 0 ) ? startPos.Y () - gap / 2 : startPos.Y () + gap / 2 ; // This is due to the gap between the ITS3 emispheres
236- float startPhi{std::atan2 (reShiftedStartY, startPos.X ())};
237- LOGP (info, " X: {}, Y: {}, startPhi: {}" , startPos.X (), reShiftedStartY, startPhi);
239+ bool isTop = startPos.Y () > 0 ;
240+ float reShiftedStartY = isTop ? startPos.Y () - gap / 2 : startPos.Y () + gap / 2 ; // This is due to the gap between the ITS3 emispheres
241+ float startPhi{std::atan2 (-reShiftedStartY, -startPos.X ()) + (isTop ? constants::math::PI / 2 : -constants::math::PI / 2 )};
242+ if (innerBarrel) {
243+ // LOGP(info, "X: {}, Y: {}, startPhi: {}", startPos.X(), reShiftedStartY, startPhi);
244+ }
238245 auto endPos = hit.GetPos ();
239- float reShiftedEndY = (endPos.Y () > 0 ) ? endPos.Y () - gap / 2 : endPos.Y () + gap / 2 ; // This is due to the gap between the ITS3 emispheres
240- float endPhi{std::atan2 (reShiftedEndY, endPos.X ())};
241- LOGP (info, " X: {}, Y: {}, endPhi: {}" , endPos.X (), reShiftedEndY, endPhi);
246+ float reShiftedEndY = isTop ? endPos.Y () - gap / 2 : endPos.Y () + gap / 2 ; // This is due to the gap between the ITS3 emispheres
247+ float endPhi{std::atan2 (-reShiftedEndY, -endPos.X ()) + (isTop ? constants::math::PI / 2 : -constants::math::PI / 2 )};
248+ if (innerBarrel) {
249+ // LOGP(info, "X: {}, Y: {}, endPhi: {}", endPos.X(), reShiftedEndY, endPhi);
250+ }
242251 math_utils::Vector3D<float > xyzLocS, xyzLocE;
243252 if (innerBarrel) {
244- xyzLocS = {SegmentationSuperAlpide::Radii[detID] * (startPhi), 0 .f , startPos.Z ()};
245- xyzLocE = {SegmentationSuperAlpide::Radii[detID] * (endPhi), 0 .f , endPos.Z ()};
253+ xyzLocS = {SegmentationSuperAlpide::Radii[mLayerID [ detID] ] * (startPhi), 0 .f , startPos.Z ()};
254+ xyzLocE = {SegmentationSuperAlpide::Radii[mLayerID [ detID] ] * (endPhi), 0 .f , endPos.Z ()};
246255 } else {
247256 xyzLocS = matrix ^ (hit.GetPosStart ());
248257 xyzLocE = matrix ^ (hit.GetPos ());
@@ -261,18 +270,20 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, uint32_t& maxFr, int evID
261270 // get entrance pixel row and col
262271 while (!mSuperSegmentations [detID].localToDetector (xyzLocS.X (), xyzLocS.Z (), rowS, colS)) { // guard-ring ?
263272 if (++nSkip >= nSteps) {
273+ LOGP (info, " Start: detId {}" , detID);
264274 return ; // did not enter to sensitive matrix
265275 }
266276 xyzLocS += step;
267277 }
268278 // get exit pixel row and col
269279 while (!mSuperSegmentations [detID].localToDetector (xyzLocE.X (), xyzLocE.Z (), rowE, colE)) { // guard-ring ?
270280 if (++nSkip >= nSteps) {
281+ LOGP (info, " End: detId {}" , detID);
271282 return ; // did not enter to sensitive matrix
272283 }
273284 xyzLocE -= step;
274285 }
275- LOGP (info, " x: {}, z: {}, col: {}, row: {}, detID: {}" , xyzLocS.X (), xyzLocS.Z (), colS, rowS, detID);
286+ // LOGP(info, "x: {}, z: {}, col: {}, row: {}, detID: {}", xyzLocS.X(), xyzLocS.Z(), colS, rowS, detID);
276287 } else {
277288 // get entrance pixel row and col
278289 while (!Segmentation::localToDetector (xyzLocS.X (), xyzLocS.Z (), rowS, colS)) { // guard-ring ?
0 commit comments