Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Potential segfault in AthenaDumpReader #3721

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class RootAthenaDumpReader : public IReader {
std::vector<std::tuple<std::uint32_t, std::size_t, std::size_t>> m_eventMap;
std::shared_ptr<TChain> m_inputchain;
long unsigned int m_events;
bool m_haveStripFeatures = true;

static constexpr unsigned int maxCL = 1500000;
static constexpr unsigned int maxSP = 1500000;
Expand All @@ -189,7 +190,7 @@ class RootAthenaDumpReader : public IReader {
int CLindex[maxCL] = {}; //[nCL]

// Clusters
std::vector<std::string> *CLhardware;
std::vector<std::string> *CLhardware{};
Double_t CLx[maxCL] = {}; //[nCL]
Double_t CLy[maxCL] = {}; //[nCL]
Double_t CLz[maxCL] = {}; //[nCL]
Expand All @@ -199,13 +200,13 @@ class RootAthenaDumpReader : public IReader {
Int_t CLphi_module[maxCL] = {}; //[nCL]
Int_t CLside[maxCL] = {}; //[nCL]
ULong64_t CLmoduleID[maxCL] = {}; //[nCL]
std::vector<std::vector<int>> *CLparticleLink_eventIndex;
std::vector<std::vector<int>> *CLparticleLink_barcode;
std::vector<std::vector<bool>> *CLbarcodesLinked;
std::vector<std::vector<float>> *CLparticle_charge;
std::vector<std::vector<int>> *CLphis;
std::vector<std::vector<int>> *CLetas;
std::vector<std::vector<int>> *CLtots;
std::vector<std::vector<int>> *CLparticleLink_eventIndex{};
std::vector<std::vector<int>> *CLparticleLink_barcode{};
std::vector<std::vector<bool>> *CLbarcodesLinked{};
std::vector<std::vector<float>> *CLparticle_charge{};
std::vector<std::vector<int>> *CLphis{};
std::vector<std::vector<int>> *CLetas{};
std::vector<std::vector<int>> *CLtots{};
Double_t CLloc_direction1[maxCL] = {}; //[nCL]
Double_t CLloc_direction2[maxCL] = {}; //[nCL]
Double_t CLloc_direction3[maxCL] = {}; //[nCL]
Expand All @@ -223,7 +224,7 @@ class RootAthenaDumpReader : public IReader {
Float_t CLnorm_x[maxCL] = {}; //[nCL]
Float_t CLnorm_y[maxCL] = {}; //[nCL]
Float_t CLnorm_z[maxCL] = {}; //[nCL]
std::vector<std::vector<double>> *CLlocal_cov;
std::vector<std::vector<double>> *CLlocal_cov{};

// Particles
Int_t nPartEVT = 0;
Expand All @@ -246,8 +247,8 @@ class RootAthenaDumpReader : public IReader {
Int_t Part_vProdNout[maxPart] = {}; //[nPartEVT]
Int_t Part_vProdStatus[maxPart] = {}; //[nPartEVT]
Int_t Part_vProdBarcode[maxPart] = {}; //[nPartEVT]
std::vector<std::vector<int>> *Part_vParentID;
std::vector<std::vector<int>> *Part_vParentBarcode;
std::vector<std::vector<int>> *Part_vParentID{};
std::vector<std::vector<int>> *Part_vParentBarcode{};

// Spacepoints
Int_t nSP = 0;
Expand All @@ -263,27 +264,27 @@ class RootAthenaDumpReader : public IReader {
double SPcovz[maxSP] = {}; //[nSP]
float SPhl_topstrip[maxSP] = {}; //[nSP]
float SPhl_botstrip[maxSP] = {}; //[nSP]
std::vector<std::vector<float>> *SPtopStripDirection;
std::vector<std::vector<float>> *SPbottomStripDirection;
std::vector<std::vector<float>> *SPstripCenterDistance;
std::vector<std::vector<float>> *SPtopStripCenterPosition;
std::vector<std::vector<float>> *SPtopStripDirection{};
std::vector<std::vector<float>> *SPbottomStripDirection{};
std::vector<std::vector<float>> *SPstripCenterDistance{};
std::vector<std::vector<float>> *SPtopStripCenterPosition{};

// Tracks
Int_t nTRK = 0;
Int_t TRKindex[maxTRK] = {}; //[nTRK]
Int_t TRKtrack_fitter[maxTRK] = {}; //[nTRK]
Int_t TRKparticle_hypothesis[maxTRK] = {}; //[nTRK]
std::vector<std::vector<int>> *TRKproperties;
std::vector<std::vector<int>> *TRKpattern;
std::vector<std::vector<int>> *TRKproperties{};
std::vector<std::vector<int>> *TRKpattern{};
Int_t TRKndof[maxTRK] = {}; //[nTRK]
Int_t TRKmot[maxTRK] = {}; //[nTRK]
Int_t TRKoot[maxTRK] = {}; //[nTRK]
Float_t TRKchiSq[maxTRK] = {}; //[nTRK]
std::vector<std::vector<int>> *TRKmeasurementsOnTrack_pixcl_sctcl_index;
std::vector<std::vector<int>> *TRKoutliersOnTrack_pixcl_sctcl_index;
std::vector<std::vector<int>> *TRKmeasurementsOnTrack_pixcl_sctcl_index{};
std::vector<std::vector<int>> *TRKoutliersOnTrack_pixcl_sctcl_index{};
Int_t TRKcharge[maxTRK] = {}; //[nTRK]
std::vector<std::vector<double>> *TRKperigee_position;
std::vector<std::vector<double>> *TRKperigee_momentum;
std::vector<std::vector<double>> *TRKperigee_position{};
std::vector<std::vector<double>> *TRKperigee_momentum{};
Int_t TTCindex[maxTRK] = {}; //[nTRK]
Int_t TTCevent_index[maxTRK] = {}; //[nTRK]
Int_t TTCparticle_link[maxTRK] = {}; //[nTRK]
Expand All @@ -293,10 +294,10 @@ class RootAthenaDumpReader : public IReader {
Int_t nDTT = 0;
Int_t DTTindex[maxDTT] = {}; //[nDTT]
Int_t DTTsize[maxDTT] = {}; //[nDTT]
std::vector<std::vector<int>> *DTTtrajectory_eventindex;
std::vector<std::vector<int>> *DTTtrajectory_barcode;
std::vector<std::vector<int>> *DTTstTruth_subDetType;
std::vector<std::vector<int>> *DTTstTrack_subDetType;
std::vector<std::vector<int>> *DTTstCommon_subDetType;
std::vector<std::vector<int>> *DTTtrajectory_eventindex{};
std::vector<std::vector<int>> *DTTtrajectory_barcode{};
std::vector<std::vector<int>> *DTTstTruth_subDetType{};
std::vector<std::vector<int>> *DTTstTrack_subDetType{};
std::vector<std::vector<int>> *DTTstCommon_subDetType{};
};
} // namespace ActsExamples
47 changes: 28 additions & 19 deletions Examples/Io/Root/src/RootAthenaDumpReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ RootAthenaDumpReader::RootAthenaDumpReader(
m_outputMeasurements.initialize(m_cfg.outputMeasurements);
}

if (m_inputchain->GetBranch("SPtopStripDirection") == nullptr) {
ACTS_WARNING("Additional SP strip features not available");
m_haveStripFeatures = false;
}

// Set the branches

// Set object pointer
Expand Down Expand Up @@ -192,13 +197,13 @@ RootAthenaDumpReader::RootAthenaDumpReader(
m_inputchain->SetBranchAddress("SPcovz", SPcovz);
m_inputchain->SetBranchAddress("SPhl_topstrip", SPhl_topstrip);
m_inputchain->SetBranchAddress("SPhl_botstrip", SPhl_botstrip);
m_inputchain->SetBranchAddress("SPtopStripDirection", SPtopStripDirection);
m_inputchain->SetBranchAddress("SPtopStripDirection", &SPtopStripDirection);
m_inputchain->SetBranchAddress("SPbottomStripDirection",
SPbottomStripDirection);
&SPbottomStripDirection);
m_inputchain->SetBranchAddress("SPstripCenterDistance",
SPstripCenterDistance);
&SPstripCenterDistance);
m_inputchain->SetBranchAddress("SPtopStripCenterPosition",
SPtopStripCenterPosition);
&SPtopStripCenterPosition);

m_inputchain->SetBranchAddress("nTRK", &nTRK);
m_inputchain->SetBranchAddress("TRKindex", TRKindex);
Expand Down Expand Up @@ -578,21 +583,25 @@ RootAthenaDumpReader::readSpacepoints(
sLinks.emplace_back(second);

using Vector3f = Eigen::Matrix<float, 3, 1>;
const Vector3f topStripDirection{SPtopStripDirection->at(isp).at(0),
SPtopStripDirection->at(isp).at(1),
SPtopStripDirection->at(isp).at(2)};
const Vector3f bottomStripDirection{
SPbottomStripDirection->at(isp).at(0),
SPbottomStripDirection->at(isp).at(1),
SPbottomStripDirection->at(isp).at(2)};
const Vector3f stripCenterDistance{SPstripCenterDistance->at(isp).at(0),
SPstripCenterDistance->at(isp).at(1),
SPstripCenterDistance->at(isp).at(2)};
const Vector3f topStripCenterPosition{
SPtopStripCenterPosition->at(isp).at(0),
SPtopStripCenterPosition->at(isp).at(1),
SPtopStripCenterPosition->at(isp).at(2)};

Vector3f topStripDirection = Vector3f::Zero();
Vector3f bottomStripDirection = Vector3f::Zero();
Vector3f stripCenterDistance = Vector3f::Zero();
Vector3f topStripCenterPosition = Vector3f::Zero();

if (m_haveStripFeatures) {
topStripDirection = {SPtopStripDirection->at(isp).at(0),
SPtopStripDirection->at(isp).at(1),
SPtopStripDirection->at(isp).at(2)};
bottomStripDirection = {SPbottomStripDirection->at(isp).at(0),
SPbottomStripDirection->at(isp).at(1),
SPbottomStripDirection->at(isp).at(2)};
stripCenterDistance = {SPstripCenterDistance->at(isp).at(0),
SPstripCenterDistance->at(isp).at(1),
SPstripCenterDistance->at(isp).at(2)};
topStripCenterPosition = {SPtopStripCenterPosition->at(isp).at(0),
SPtopStripCenterPosition->at(isp).at(1),
SPtopStripCenterPosition->at(isp).at(2)};
}
sp = SimSpacePoint(globalPos, std::nullopt, spCovr, spCovz, std::nullopt,
sLinks, SPhl_topstrip[isp], SPhl_botstrip[isp],
topStripDirection.cast<double>(),
Expand Down
Loading