Skip to content

Commit c73ffe5

Browse files
committed
Critical bug fix in the ITS hit generation
- Fixing incorrect calculation of the chip ID and incorrect assignment of the detector ID to the hit in its/Detector.cxx - Implement exception thrown by chip in case of the assignment of a hit to a chip with a different chip ID - Create subdirectory test for test task and its for ITS-related test - Implement ITS hit test suite
1 parent 8f15f08 commit c73ffe5

9 files changed

Lines changed: 416 additions & 16 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ add_subdirectory (field)
217217
add_subdirectory (devices)
218218
add_subdirectory (macro)
219219
add_subdirectory (o2cdb)
220+
add_subdirectory (test)
220221

221222

222223
Option(BUILD_DOXYGEN "Build Doxygen" OFF)

its/Chip.cxx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
// ALICEO2
44
//
55
// Created by Markus Fasel on 23.07.15.
6-
// Adapted from AliITSUChip by Massimo Masers
6+
// Adapted from AliITSUChip by Massimo Masera
77
//
88

99
#include <TMath.h>
1010

11-
#include "Chip.h"
12-
#include "Point.h"
13-
#include "UpgradeGeometryTGeo.h"
11+
#include "FairLogger.h"
12+
13+
#include "its/Chip.h"
14+
#include "its/Point.h"
15+
#include "its/UpgradeGeometryTGeo.h"
1416

1517
ClassImp(AliceO2::ITS::Chip)
1618

@@ -73,6 +75,9 @@ Chip::~Chip(){
7375
}
7476

7577
void Chip::InsertPoint(Point *p){
78+
if (p->GetDetectorID() != fChipIndex) {
79+
throw IndexException(fChipIndex, p->GetDetectorID());
80+
}
7681
fPoints.AddLast(p);
7782
}
7883

@@ -99,8 +104,10 @@ Bool_t Chip::LineSegmentLocal(Int_t hitindex, Double_t &xstart, Double_t &xpoint
99104
Double_t posglob[3] = { tmp->GetX(), tmp->GetY(), tmp->GetZ()},
100105
posglobStart[3] = {tmp->GetStartX(), tmp->GetStartY(), tmp->GetStartZ()},
101106
posloc[3], poslocStart[3];
107+
memset(posloc, 0, sizeof(Double_t)*3);
108+
memset(poslocStart, 0, sizeof(Double_t)*3);
102109

103-
// convert to global position
110+
// convert to local position
104111
fGeometry->globalToLocal(fChipIndex, posglob, posloc);
105112
fGeometry->globalToLocal(fChipIndex, posglobStart, poslocStart);
106113

@@ -109,8 +116,8 @@ Bool_t Chip::LineSegmentLocal(Int_t hitindex, Double_t &xstart, Double_t &xpoint
109116
ystart = poslocStart[1];
110117
zstart = poslocStart[2];
111118
xpoint = posloc[0] - poslocStart[0];
112-
ypoint = posloc[0] - poslocStart[0];
113-
zpoint = posloc[0] - poslocStart[0];
119+
ypoint = posloc[1] - poslocStart[1];
120+
zpoint = posloc[2] - poslocStart[2];
114121

115122
timestart = tmp->GetStartTime();
116123
eloss = tmp->GetEnergyLoss();

its/Chip.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#ifndef ALICEO2_ITS_CHIP_
1010
#define ALICEO2_ITS_CHIP_
1111

12+
#include <exception>
13+
#include <sstream>
14+
1215
#include <TObjArray.h>
1316
#include "TObject.h"
1417

@@ -26,6 +29,51 @@ namespace AliceO2 {
2629
/// chip identified by the chip index.
2730
class Chip : public TObject {
2831
public:
32+
33+
/// @class IndexException
34+
/// @brief Handling discrepancies between Chip index stored in the hit
35+
/// and Chip index stored in the chip
36+
class IndexException : public std::exception{
37+
public:
38+
39+
/// Default constructor
40+
/// Initializes indices with -1. Not to be used when throwing the
41+
/// exception. Use other constructor instead
42+
IndexException(): fDetIdChip(-1), fDetIdHit(-1){}
43+
44+
/// Constructor
45+
/// Initializing indices from chip and from hit
46+
/// @param indexChip Chip index stored in chip itself
47+
/// @param indexHit Chip index stored in the hit
48+
IndexException(ULong_t indexChip, ULong_t indexHit) :
49+
fDetIdChip(indexChip), fDetIdHit(indexHit)
50+
{}
51+
52+
/// Destructor
53+
virtual ~IndexException() throw () {}
54+
55+
/// Build error message
56+
/// The error message contains the indices stored in the chip and in the hit
57+
/// @return Error message connected to this exception
58+
const char *what() const throw() {
59+
std::stringstream message;
60+
message << "Chip ID " << fDetIdHit << " from hit different compared to this ID " << fDetIdChip;
61+
return message.str().c_str();
62+
}
63+
64+
/// Get the chip index stored in the chip
65+
/// @return Chip index stored in the chip
66+
ULong_t GetChipIndexChip() const { return fDetIdChip; }
67+
68+
/// Fet the chip index stored in the hit
69+
/// @return Chip index stored in the hit
70+
ULong_t GetChipIndexHit() const { return fDetIdHit; }
71+
72+
private:
73+
ULong_t fDetIdChip; ///< Index of the chip stored in the chip
74+
ULong_t fDetIdHit; ///< Index of the chip stored in the hit
75+
};
76+
2977
/// Default constructor
3078
Chip();
3179

@@ -71,7 +119,7 @@ namespace AliceO2 {
71119

72120
/// Empties the point container
73121
/// @param option unused
74-
void Clear(Option_t *opt = "");
122+
virtual void Clear(Option_t *opt = "");
75123

76124
/// Change the chip index
77125
/// @param index New chip index

its/Detector.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
415415
Int_t copy = vol->getCopyNo();
416416
Int_t id = vol->getMCid();
417417
Int_t lay = 0;
418-
Int_t cpn0, cpn1, mod;
419418

420419
// FIXME: Determine the layer number. Is this information available directly from the FairVolume?
421420
while ((lay < mNumberLayers) && id != mLayerID[lay]) {
@@ -428,12 +427,13 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
428427
// } // if Outer ITS mother Volume
429428

430429
// Retrieve the indices with the volume path
431-
copy = 1;
432-
gMC->CurrentVolOffID(1, cpn1);
433-
gMC->CurrentVolOffID(2, cpn0);
434-
435-
mod = mGeometryTGeo->getChipIndex(lay, cpn0, cpn1);
436-
430+
int stave(0), halfstave(0), chipinmodule(0), module;
431+
gMC->CurrentVolOffID(1, chipinmodule);
432+
gMC->CurrentVolOffID(2, module);
433+
gMC->CurrentVolOffID(3, halfstave);
434+
gMC->CurrentVolOffID(4, stave);
435+
int chipindex = mGeometryTGeo->getChipIndex(lay, stave, halfstave, module, chipinmodule);
436+
437437
// Record information on the points
438438
mEnergyLoss = gMC->Edep();
439439
mTime = gMC->TrackTime();
@@ -463,7 +463,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
463463
}
464464

465465
// Create Point on every step of the active volume
466-
addHit(mTrackNumberID, mVolumeID,
466+
addHit(mTrackNumberID, chipindex, //mVolumeID,
467467
TVector3(mEntrancePosition.X(), mEntrancePosition.Y(), mEntrancePosition.Z()),
468468
TVector3(mPosition.X(), mPosition.Y(), mPosition.Z()),
469469
TVector3(mMomentum.Px(), mMomentum.Py(), mMomentum.Pz()), mEntranceTime, mTime, mLength,

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(its)

test/its/CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
set(INCLUDE_DIRECTORIES
2+
${CMAKE_SOURCE_DIR}
3+
${CMAKE_SOURCE_DIR}/its
4+
${CMAKE_SOURCE_DIR}/header
5+
${CMAKE_SOURCE_DIR}/test/its
6+
${BASE_INCLUDE_DIRECTORIES}
7+
${Boost_INCLUDE_DIRS}
8+
${FAIRROOT_INCLUDE_DIR}
9+
${AlFa_DIR}/include
10+
${ROOT_INCLUDE_DIR}
11+
)
12+
13+
include_directories( ${INCLUDE_DIRECTORIES})
14+
15+
set(LINK_DIRECTORIES
16+
${ROOT_LIBRARY_DIR}
17+
${FAIRROOT_LIBRARY_DIR}
18+
)
19+
20+
link_directories( ${LINK_DIRECTORIES})
21+
22+
set(SRCS
23+
HitAnalysis.cxx
24+
)
25+
26+
Set(LINKDEF testitsLinkDef.h)
27+
Set(LIBRARY_NAME testits)
28+
Set(DEPENDENCIES
29+
AliceO2Base its
30+
)
31+
32+
GENERATE_LIBRARY()
33+

0 commit comments

Comments
 (0)