1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONTrackStoreV1
21 /// Implementation of AliMUONTrackStoreV1, which should be backward
22 /// compatible, i.e. able to read old TreeT files
24 /// \author Laurent Aphecetche, Subatech
25 //-----------------------------------------------------------------------------
27 #include "AliMUONTrackStoreV1.h"
29 #include <TClonesArray.h>
32 #include "AliMUONTrack.h"
33 #include "AliMUONTreeManager.h"
36 ClassImp(AliMUONTrackStoreV1)
39 //_____________________________________________________________________________
40 AliMUONTrackStoreV1::AliMUONTrackStoreV1() : AliMUONVTrackStore(),
47 //_____________________________________________________________________________
48 AliMUONTrackStoreV1::AliMUONTrackStoreV1(TRootIOCtor* /*dummy*/) : AliMUONVTrackStore(),
54 //_____________________________________________________________________________
55 AliMUONTrackStoreV1::~AliMUONTrackStoreV1()
61 //_____________________________________________________________________________
63 AliMUONTrackStoreV1::Add(const AliMUONTrack& track)
67 if (!fTracks) CreateTracks();
69 return new((*fTracks)[fTracks->GetLast()+1]) AliMUONTrack(track);
72 //_____________________________________________________________________________
74 AliMUONTrackStoreV1::Remove(AliMUONTrack& track)
76 /// Remove a track from the store
77 AliMUONTrack* t = static_cast<AliMUONTrack*>(fTracks->Remove(&track));
78 if (t) fTracks->Compress();
82 //_____________________________________________________________________________
84 AliMUONTrackStoreV1::Connect(TTree& tree, Bool_t alone) const
86 /// Connect this store to the tree
87 AliMUONTreeManager tman;
91 if ( tree.GetBranch("MUONTrack") )
93 if ( alone ) tman.UpdateBranchStatuses(tree,"MUONTrack");
94 ok = tman.SetAddress(tree,"MUONTrack",TracksPtr());
98 ok = tman.MakeBranch(tree,ClassName(),"TClonesArray","MUONTrack",
104 //_____________________________________________________________________________
106 AliMUONTrackStoreV1::CreateIterator() const
108 /// Create an iterator to loop over tracks
109 if ( fTracks ) return fTracks->MakeIterator();
113 //_____________________________________________________________________________
115 AliMUONTrackStoreV1::Clear(Option_t*)
118 if (fTracks) fTracks->Clear("C");
121 //_____________________________________________________________________________
123 AliMUONTrackStoreV1::CreateTracks()
125 /// Allocate track container
128 AliError("Cannot allocate again fTracks as it is there already !");
132 fTracks = new TClonesArray("AliMUONTrack",10);
136 //_____________________________________________________________________________
138 AliMUONTrackStoreV1::GetSize() const
140 /// Return the number of tracks we hold
141 if ( fTracks ) return fTracks->GetLast()+1;