Skip to content

Commit 15411bb

Browse files
committed
Move TClonesArray -> std::vector<Hit> for TOF
1 parent 30ea1ac commit 15411bb

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

Detectors/TOF/simulation/include/TOFSimulation/Detector.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#ifndef ALICEO2_TOF_DETECTOR_H_
1212
#define ALICEO2_TOF_DETECTOR_H_
1313

14-
#include "TClonesArray.h"
15-
1614
#include "DetectorsBase/Detector.h"
1715
#include "TOFBase/Geo.h"
1816

@@ -98,7 +96,7 @@ class Detector : public o2::Base::Detector
9896
Bool_t mTOFHoles; // flag to allow for holes in front of the PHOS
9997

10098
/// container for data points
101-
TClonesArray* mHitCollection;
99+
std::vector<HitType>* mHits; //!
102100
int mMCTrackBranchId; //! cache for the MCTrackBranchID (to avoid string based query)
103101

104102
ClassDefOverride(Detector, 1);

Detectors/TOF/simulation/src/Detector.cxx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
1010

11-
#include "TClonesArray.h"
1211
#include "TGeoManager.h" // for TGeoManager
1312
#include "TLorentzVector.h"
1413
#include "TMath.h"
@@ -32,7 +31,7 @@ Detector::Detector(Bool_t active)
3231
: o2::Base::Detector("TOF", active),
3332
mEventNr(0),
3433
mTOFHoles(kTRUE),
35-
mHitCollection(new TClonesArray(o2::Base::getTClArrTrueTypeName<HitType>().c_str())),
34+
mHits(new std::vector<HitType>),
3635
mMCTrackBranchId(-1)
3736
{
3837
for (Int_t i = 0; i < Geo::NSECTORS; i++)
@@ -76,34 +75,25 @@ Bool_t Detector::ProcessHits(FairVolume* v)
7675

7776
HitType* Detector::addHit(Float_t x, Float_t y, Float_t z, Float_t time, Float_t energy, Int_t trackId, Int_t detId)
7877
{
79-
TClonesArray& clref = *mHitCollection;
80-
81-
Int_t size = clref.GetEntriesFast();
82-
83-
HitType* hit = new (clref[size]) HitType(x, y, z, time, energy, trackId, detId);
84-
85-
if (mMCTrackBranchId > -1)
86-
hit->SetLink(FairLink(-1, mEventNr, mMCTrackBranchId, trackId));
87-
88-
return hit;
78+
mHits->emplace_back(x, y, z, time, energy, trackId, detId);
79+
return &mHits->back();
8980
}
9081

9182
void Detector::Register()
9283
{
9384
auto* mgr = FairRootManager::Instance();
94-
mgr->Register(addNameTo("Hit").data(), GetName(), mHitCollection, kTRUE);
85+
mgr->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE);
9586

9687
mMCTrackBranchId = mgr->GetBranchId("MCTrack");
9788
}
9889

9990
TClonesArray* Detector::GetCollection(Int_t iColl) const
10091
{
101-
if (iColl > 0)
102-
return nullptr;
103-
return mHitCollection;
92+
LOG(WARNING) << "GetCollection interface no longer supported" << FairLogger::endl;
93+
return nullptr;
10494
}
10595

106-
void Detector::Reset() { mHitCollection->Clear(); }
96+
void Detector::Reset() { mHits->clear(); }
10797
void Detector::CreateMaterials()
10898
{
10999
Int_t isxfld = 2;

0 commit comments

Comments
 (0)