StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuFwdTrackCollection.cxx
1 /***************************************************************************
2  *
3  * $Id: StMuFwdTrackCollection.cxx
4  *
5  * Author: jdb, 2021
6  ***************************************************************************
7  *
8  * Description: Fwd Tracks
9  *
10  ***************************************************************************/
11 
12 #include "StMuDSTMaker/COMMON/StMuFwdTrackCollection.h"
13 #include "StMuDSTMaker/COMMON/StMuFwdTrack.h"
14 
15 #include "St_base/StMessMgr.h"
16 
17 
18 StMuFwdTrackCollection::StMuFwdTrackCollection() { mFwdTracks = 0; }
19 
20 StMuFwdTrackCollection::~StMuFwdTrackCollection() {
21  delete mFwdTracks;
22  mFwdTracks = nullptr;
23 }
24 
25 void StMuFwdTrackCollection::init() {
26  mFwdTracks = new TClonesArray("StMuFwdTracks", 0);
27 }
28 
29 StMuFwdTrack* StMuFwdTrackCollection::addFwdTrack(){
30  if(!mFwdTracks) init();
31  int counter = mFwdTracks->GetEntriesFast();
32  StMuFwdTrack* newFwdTrack = new ((*mFwdTracks)[counter]) StMuFwdTrack();
33  return newFwdTrack;
34 }
35 
36 unsigned int StMuFwdTrackCollection::numberOfFwdTracks() const{
37  if(!mFwdTracks) return 0;
38  return mFwdTracks->GetEntriesFast();
39 }
40 
41 StMuFwdTrack* StMuFwdTrackCollection::getFwdTrack(int index){
42  if (!mFwdTracks) return nullptr;
43  return (StMuFwdTrack*) mFwdTracks->At(index);
44 }