Skip to content

Commit 3850c09

Browse files
author
Andrea
committed
Changing reserve to resize to assure that accessing vector elements with [] is safe.
1 parent e9513c6 commit 3850c09

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Common/Tools/TrackTuner.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -497,24 +497,24 @@ struct TrackTuner : o2::framework::ConfigurableGroup {
497497
if (inputNphiBins == 0)
498498
nPhiBins = 1; // old phi_independent settings
499499

500-
// reserve memory for needed number of graphs
501-
grDcaXYResVsPtPionMC.reserve(nPhiBins);
502-
grDcaXYResVsPtPionData.reserve(nPhiBins);
500+
// reserve memory and initialize vector for needed number of graphs
501+
grDcaXYResVsPtPionMC.resize(nPhiBins);
502+
grDcaXYResVsPtPionData.resize(nPhiBins);
503503

504-
grDcaZResVsPtPionMC.reserve(nPhiBins);
505-
grDcaZResVsPtPionData.reserve(nPhiBins);
504+
grDcaZResVsPtPionMC.resize(nPhiBins);
505+
grDcaZResVsPtPionData.resize(nPhiBins);
506506

507-
grDcaXYMeanVsPtPionMC.reserve(nPhiBins);
508-
grDcaXYMeanVsPtPionData.reserve(nPhiBins);
507+
grDcaXYMeanVsPtPionMC.resize(nPhiBins);
508+
grDcaXYMeanVsPtPionData.resize(nPhiBins);
509509

510-
grDcaZMeanVsPtPionMC.reserve(nPhiBins);
511-
grDcaZMeanVsPtPionData.reserve(nPhiBins);
510+
grDcaZMeanVsPtPionMC.resize(nPhiBins);
511+
grDcaZMeanVsPtPionData.resize(nPhiBins);
512512

513-
grDcaXYPullVsPtPionMC.reserve(nPhiBins);
514-
grDcaXYPullVsPtPionData.reserve(nPhiBins);
513+
grDcaXYPullVsPtPionMC.resize(nPhiBins);
514+
grDcaXYPullVsPtPionData.resize(nPhiBins);
515515

516-
grDcaZPullVsPtPionMC.reserve(nPhiBins);
517-
grDcaZPullVsPtPionData.reserve(nPhiBins);
516+
grDcaZPullVsPtPionMC.resize(nPhiBins);
517+
grDcaZPullVsPtPionData.resize(nPhiBins);
518518

519519
/// Lambda expression to get the TGraphErrors from file
520520
auto loadGraph = [&](int phiBin, const std::string& strBaseName) -> TGraphErrors* {

0 commit comments

Comments
 (0)