9dc338578fa820bf812cade077c1a9208fed3246
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerTrackStoreV1.cxx
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 //-----------------------------------------------------------------------------
19 /// \class AliMUONTriggerTrackStoreV1
20 ///
21 /// Implementation of AliMUONVTriggerTrackStore which should be
22 /// backward compatible, i.e. able to read TreeT produced before
23 /// the introduction of the AliMUONVStore concept
24 ///
25 /// \author Laurent Aphecetche, Subatech
26 //-----------------------------------------------------------------------------
27
28 #include "AliMUONTriggerTrackStoreV1.h"
29
30 #include <TClonesArray.h>
31 #include "AliMUONTreeManager.h"
32 #include "AliMUONTriggerTrack.h"
33 #include <TTree.h>
34
35 /// \cond CLASSIMP
36 ClassImp(AliMUONTriggerTrackStoreV1)
37 /// \endcond
38
39 //_____________________________________________________________________________
40 AliMUONTriggerTrackStoreV1::AliMUONTriggerTrackStoreV1(TRootIOCtor* /*dummy*/) : AliMUONVTriggerTrackStore(),
41 fTracks(0x0)
42 {
43   /// ctor
44   fTracks->SetOwner(kTRUE);
45 }
46
47 //_____________________________________________________________________________
48 AliMUONTriggerTrackStoreV1::AliMUONTriggerTrackStoreV1() : AliMUONVTriggerTrackStore(),
49  fTracks(new TClonesArray("AliMUONTriggerTrack",10))
50 {
51    /// ctor
52    fTracks->SetOwner(kTRUE);
53 }
54
55 //_____________________________________________________________________________
56 AliMUONTriggerTrackStoreV1::~AliMUONTriggerTrackStoreV1()
57 {
58   /// Dtor
59   delete fTracks;
60 }
61
62 //_____________________________________________________________________________
63 void 
64 AliMUONTriggerTrackStoreV1::Add(const AliMUONTriggerTrack& track)
65 {
66   /// Add a new trigger track
67   new((*fTracks)[fTracks->GetLast()+1]) AliMUONTriggerTrack(track);
68 }
69
70 //_____________________________________________________________________________
71 Bool_t
72 AliMUONTriggerTrackStoreV1::Connect(TTree& tree, Bool_t alone) const
73 {
74   /// Connect this to the tree
75   AliMUONTreeManager tman;
76   Bool_t ok;
77   
78   if ( tree.GetBranch("MUONTriggerTrack") ) 
79   {
80     if ( alone ) tman.UpdateBranchStatuses(tree,"MUONTriggerTrack");
81     ok = tman.SetAddress(tree,"MUONTriggerTrack",TracksPtr());
82   }
83   else
84   {
85     ok = tman.MakeBranch(tree,ClassName(),"TClonesArray","MUONTriggerTrack",
86                          TracksPtr());
87   }
88
89   return kTRUE;
90 }
91
92 //_____________________________________________________________________________
93 Int_t
94 AliMUONTriggerTrackStoreV1::GetSize() const
95 {
96   /// Return the number of trigger tracks we hold
97   return fTracks->GetLast()+1;
98 }
99
100 //_____________________________________________________________________________
101 TIterator*
102 AliMUONTriggerTrackStoreV1::CreateIterator() const
103 {
104   /// Return an iterator to loop over trigger tracks
105   return fTracks->MakeIterator();
106 }
107
108 //_____________________________________________________________________________
109 void 
110 AliMUONTriggerTrackStoreV1::Clear(Option_t*)
111 {
112   /// Reset
113   fTracks->Clear("C");
114 }