]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEERBase/AliPoolsSet.cxx
declaring clusters as const prevents the [] operator from allocating memory
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliPoolsSet.cxx
1 #include "AliPoolsSet.h"
2 #include "AliLog.h"
3
4 ClassImp(AliPoolsSet)
5
6 //__________________________________________
7 AliPoolsSet::AliPoolsSet() : fPools(kMaxPools)
8 {
9   // def ctor
10   fPools.SetOwner();
11 }
12
13 //___________________________________________________________
14 void AliPoolsSet::InitPools()
15 {
16   // Create obligatory pools (which always needed). 
17   // The pools for specific detector objects are initialized by respective trackers of AliReconstruction
18   AliInfo("Initializing pools>>");
19   if (!GetPoolN()) SetPool(new AliPoolN(100000), kPoolN);
20   if (!GetPool(kPoolExtTrPar)) {
21     SetPool(new AliClonesPool("AliExternalTrackParam",5000), kPoolExtTrPar);
22     GetPoolC(kPoolExtTrPar)->SetName("ExternalTrackParam");
23   }
24   if (!GetPool(kPoolTrFriend)) {
25     SetPool(new AliClonesPool("AliESDfriendTrack",5000),kPoolTrFriend);
26     GetPoolC(kPoolTrFriend)->SetName("ESDfriendTrack");
27   }
28   if (!GetPool(kPoolTPCdEdx)) {
29     SetPool(new AliClonesPool("AliTPCdEdxInfo",5000), kPoolTPCdEdx);
30     GetPoolC(kPoolTPCdEdx)->SetName("TPCdEdxInfo");
31   }
32   //
33   AliInfo("Initializing pools<<");
34 }
35
36 //___________________________________________________________
37 void AliPoolsSet::DeletePools()
38 {
39   // delete all global pools
40   fPools.Delete();
41 }
42
43 //___________________________________________________________
44 void AliPoolsSet::ResetPools()
45 {
46   // reset all pools
47   for (int i=kMaxPools;i--;) {
48     TObject* pool = GetPool(i);
49     if (!pool) continue;
50     pool->Clear("C");
51   }
52 }
53
54 //___________________________________________________________
55 Bool_t AliPoolsSet::SetPool(TObject* pool, Int_t id)
56 {
57   // attach the pool
58   if (!pool) return kFALSE;
59   if (id<0 || id>=kMaxPools) AliFatal(Form("Defined pool id's are 0:%d, %d requested",kMaxPools,id));
60   if (!pool->InheritsFrom("AliPoolN") && !pool->InheritsFrom("AliClonesPool")) 
61     AliFatal(Form("Supported pool types: %s,%s | supplied %s","AliPoolN","AliClonesPool",pool->ClassName()));
62   //
63   fPools[id] = pool;
64   return kTRUE;
65 }
66
67 //___________________________________________________________
68 void AliPoolsSet::Print(Option_t* opt) const
69 {
70   // print summary
71   for (int i=0;i<kMaxPools;i++) {
72     TObject* pl = GetPool(i);
73     if (!pl) continue;
74     if      ( pl->IsA() == AliClonesPool::Class() ) ((AliClonesPool*)pl)->PrintSummary(opt);
75     else if ( pl->IsA() == AliPoolN::Class() )      ((AliPoolN*)pl)->PrintSummary(opt);
76   }
77 }