Line data Source code
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 : #include "AliMUONHitStoreV1.h"
19 :
20 : //-----------------------------------------------------------------------------
21 : /// \class AliMUONHitStoreV1
22 : ///
23 : /// Implementation of AliMUONVHitStore
24 : ///
25 : /// \author Laurent Aphecetche, Subatech
26 : //-----------------------------------------------------------------------------
27 :
28 : #include <TClonesArray.h>
29 : #include <TTree.h>
30 : #include "AliMUONTreeManager.h"
31 : #include "AliMUONHit.h"
32 :
33 : /// \cond CLASSIMP
34 16 : ClassImp(AliMUONHitStoreV1)
35 : /// \endcond
36 :
37 : //_____________________________________________________________________________
38 4 : AliMUONHitStoreV1::AliMUONHitStoreV1(TRootIOCtor* /*dummy*/) : AliMUONVHitStore(),
39 4 : fHits(0x0)
40 20 : {
41 : /// default ctor from file
42 8 : }
43 :
44 : //_____________________________________________________________________________
45 1 : AliMUONHitStoreV1::AliMUONHitStoreV1() : AliMUONVHitStore(),
46 3 : fHits(new TClonesArray("AliMUONHit",10))
47 5 : {
48 : /// ctor
49 1 : fHits->SetOwner(kTRUE);
50 2 : }
51 :
52 : //_____________________________________________________________________________
53 : AliMUONHitStoreV1::~AliMUONHitStoreV1()
54 30 : {
55 : /// dtor
56 10 : delete fHits;
57 15 : }
58 :
59 : //_____________________________________________________________________________
60 : void
61 : AliMUONHitStoreV1::Add(const AliMUONHit& hit)
62 : {
63 : /// add a hit
64 230 : new((*fHits)[fHits->GetLast()+1]) AliMUONHit(hit);
65 115 : }
66 :
67 : //_____________________________________________________________________________
68 : TCollection*
69 : AliMUONHitStoreV1::Collection()
70 : {
71 2 : return fHits;
72 : }
73 :
74 : //_____________________________________________________________________________
75 : Bool_t
76 : AliMUONHitStoreV1::Connect(TTree& tree, Bool_t /*alone*/) const
77 : {
78 : /// Connect this to tree.
79 16 : AliMUONTreeManager tman;
80 : Bool_t ok;
81 :
82 16 : if ( tree.GetBranch("MUONHits") )
83 : {
84 8 : ok = tman.SetAddress(tree,"MUONHits",HitsPtr());
85 4 : }
86 : else
87 : {
88 12 : ok = tman.MakeBranch(tree,ClassName(),"TClonesArray","MUONHits",
89 4 : HitsPtr());
90 : }
91 8 : return ok;
92 8 : }
93 :
94 : //_____________________________________________________________________________
95 : TIterator*
96 : AliMUONHitStoreV1::CreateIterator() const
97 : {
98 : /// create an iterator on hits
99 224 : return fHits->MakeIterator();
100 : }
101 :
102 : //____________________________________________________________________________
103 : Int_t
104 : AliMUONHitStoreV1::GetSize() const
105 : {
106 0 : return fHits->GetLast()+1;
107 : }
108 :
109 : //____________________________________________________________________________
110 : void
111 : AliMUONHitStoreV1::Clear(Option_t*)
112 : {
113 : /// reset the internal array
114 454 : fHits->Clear("C");
115 227 : }
|