AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONTrackStoreV1.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15 
16 // $Id$
17 
18 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
26 
27 #include "AliMUONTrackStoreV1.h"
28 
29 #include <TClonesArray.h>
30 #include <TTree.h>
31 #include "AliLog.h"
32 #include "AliMUONTrack.h"
33 #include "AliMUONTreeManager.h"
34 
38 
39 //_____________________________________________________________________________
41  fTracks(0x0)
42 {
44  CreateTracks();
45 }
46 
47 //_____________________________________________________________________________
49 fTracks(0x0)
50 {
52 }
53 
54 //_____________________________________________________________________________
56 {
58  delete fTracks;
59 }
60 
61 //_____________________________________________________________________________
64 {
66 
67  if (!fTracks) CreateTracks();
68 
69  return new((*fTracks)[fTracks->GetLast()+1]) AliMUONTrack(track);
70 }
71 
72 //_____________________________________________________________________________
75 {
77  AliMUONTrack* t = static_cast<AliMUONTrack*>(fTracks->Remove(&track));
78  if (t) fTracks->Compress();
79  return t;
80 }
81 
82 //_____________________________________________________________________________
83 Bool_t
84 AliMUONTrackStoreV1::Connect(TTree& tree, Bool_t alone) const
85 {
87  AliMUONTreeManager tman;
88 
89  Bool_t ok;
90 
91  if ( tree.GetBranch("MUONTrack") )
92  {
93  if ( alone ) tman.UpdateBranchStatuses(tree,"MUONTrack");
94  ok = tman.SetAddress(tree,"MUONTrack",TracksPtr());
95  }
96  else
97  {
98  ok = tman.MakeBranch(tree,ClassName(),"TClonesArray","MUONTrack",
99  TracksPtr());
100  }
101  return ok;
102 }
103 
104 //_____________________________________________________________________________
105 TIterator*
107 {
109  if ( fTracks ) return fTracks->MakeIterator();
110  return 0x0;
111 }
112 
113 //_____________________________________________________________________________
114 void
116 {
118  if (fTracks) fTracks->Clear("C");
119 }
120 
121 //_____________________________________________________________________________
122 void
124 {
126  if (fTracks)
127  {
128  AliError("Cannot allocate again fTracks as it is there already !");
129  }
130  else
131  {
132  fTracks = new TClonesArray("AliMUONTrack",10);
133  }
134 }
135 
136 //_____________________________________________________________________________
137 Int_t
139 {
141  if ( fTracks ) return fTracks->GetLast()+1;
142  return 0;
143 }
Base class of a track container.
Bool_t SetAddress(TTree &tree, const char *branchName, void *address) const
virtual AliMUONTrack * Remove(AliMUONTrack &track)
Remove a track from the store.
AliTPCfastTrack * track
TTree * tree
Helper class to ease TTree (MUON) branches manipulations.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
TClonesArray ** TracksPtr() const
Return the address of the tracks array.
virtual void Clear(Option_t *opt="")
Clear ourselves (i.e. Reset)
Implementation of AliMUONVTrackStore.
void UpdateBranchStatuses(TTree &tree, const char *pattern) const
virtual AliMUONTrack * Add(const AliMUONTrack &track)
Add a track.
Bool_t MakeBranch(TTree &tree, const char *storeClassName, const char *branchClassName, const char *branchName, void *address, Int_t bufferSize=4000, Int_t splitLevel=99) const
TClonesArray * fTracks
Internal array.
Reconstructed track in ALICE dimuon spectrometer.
Definition: AliMUONTrack.h:24
virtual Bool_t Connect(TTree &tree, Bool_t alone=kTRUE) const
Connect us to a TTree (only valid if CanConnect()==kTRUE)
virtual TIterator * CreateIterator() const
Create an iterator to loop over tracks.
virtual Int_t GetSize() const
The number of objects stored.