Skip to content

Commit 1825956

Browse files
mfasDashahor02
authored andcommitted
[FOCAL-10] Fixes in EventReader
- Add missing ClassDefNV to EventReader - Add boundary checks to range access - Fix copy/paste error in PixelChipRecord
1 parent 855304f commit 1825956

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

DataFormats/Detectors/FOCAL/include/DataFormatsFOCAL/PixelChipRecord.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class PixelChipRecord
3737
int getLaneID() const { return mLaneID; }
3838
int getChipID() const { return mChipID; }
3939
int getFirstHit() const { return mHitIndexRange.getFirstEntry(); }
40-
int getNumberOfHits() const { return mHitIndexRange.getFirstEntry(); }
40+
int getNumberOfHits() const { return mHitIndexRange.getEntries(); }
4141

4242
void printStream(std::ostream& stream) const;
4343

DataFormats/Detectors/FOCAL/src/Event.cxx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <algorithm>
1212
#include <DataFormatsFOCAL/ErrorHandling.h>
1313
#include <DataFormatsFOCAL/Event.h>
14+
#include <iostream>
15+
1416
using namespace o2::focal;
1517

1618
PadLayerEvent& Event::getPadLayer(unsigned int index)
@@ -69,7 +71,21 @@ void Event::construct(const o2::InteractionRecord& interaction, gsl::span<const
6971
}
7072

7173
for (auto& chip : eventPixels) {
72-
mPixelLayers[chip.getLayerID()].addChip(chip.getLaneID(), chip.getChipID(), pixelHits.subspan(chip.getFirstHit(), chip.getNumberOfHits()));
74+
if (chip.getLayerID() > 1) {
75+
std::cerr << "Invalid layer ID chip " << chip.getChipID() << ": " << chip.getLayerID() << std::endl;
76+
continue;
77+
}
78+
if (chip.getNumberOfHits()) {
79+
if (chip.getFirstHit() >= pixelHits.size()) {
80+
std::cerr << "First hit index " << chip.getFirstHit() << " exceeding hit contiainer " << pixelHits.size() << std::endl;
81+
continue;
82+
}
83+
if (chip.getFirstHit() + chip.getNumberOfHits() - 1 >= pixelHits.size()) {
84+
std::cerr << "First hit index " << chip.getFirstHit() + chip.getNumberOfHits() - 1 << " exceeding hit contiainer " << pixelHits.size() << std::endl;
85+
continue;
86+
}
87+
mPixelLayers[chip.getLayerID()].addChip(chip.getLaneID(), chip.getChipID(), pixelHits.subspan(chip.getFirstHit(), chip.getNumberOfHits()));
88+
}
7389
}
7490
}
7591

Detectors/FOCAL/base/include/FOCALBase/EventReader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class EventReader
4444
std::unique_ptr<TTreeReaderValue<std::vector<PixelHit>>> mPixelHitBranch;
4545
std::unique_ptr<TTreeReaderValue<std::vector<PixelChipRecord>>> mPixelChipBranch;
4646
std::unique_ptr<TTreeReaderValue<std::vector<TriggerRecord>>> mTriggerBranch;
47+
48+
ClassDefNV(EventReader, 1);
4749
};
4850

4951
} // namespace o2::focal

0 commit comments

Comments
 (0)