]>
Commit | Line | Data |
---|---|---|
e546b023 | 1 | #include <TClass.h> |
2 | #include <TString.h> | |
3 | #include "AliLog.h" | |
4 | #include "AliClonesPool.h" | |
5 | ||
6 | ClassImp(AliClonesPool) | |
7 | ||
8 | ||
9 | //_______________________________________________________________________________ | |
10 | AliClonesPool::AliClonesPool(const char* classname, Int_t size) | |
11 | : TClonesArray(classname,size), fFreeID(size>1000 ? size/100:10), fNFree(0), fLastID(-1), fCastToTrack(kFALSE) | |
12 | { | |
13 | // ctor, delegate to TClonesArray | |
14 | TClass* cl = TClass::GetClass(classname); | |
15 | if (cl->InheritsFrom(AliVParticle::Class())) fCastToTrack = kTRUE; | |
16 | else AliInfo(Form("Pool will use TObject::GetUniqueID to accout %s clones",classname)); | |
17 | // | |
18 | } | |
19 | ||
20 | //_______________________________________________________________________________ | |
21 | AliClonesPool::AliClonesPool(const TClass* cl, Int_t size) | |
22 | : TClonesArray(cl,size), fFreeID(size>1000 ? size/100:10), fNFree(0), fLastID(-1), fCastToTrack(kFALSE) | |
23 | { | |
24 | // ctor, delegate to TClonesArray | |
25 | if (cl->InheritsFrom(AliVParticle::Class())) fCastToTrack = kTRUE; | |
26 | else AliInfo(Form("Pool will use TObject::GetUniqueID to accout %s clones",cl->ClassName())); | |
27 | // | |
28 | } | |
29 | ||
30 | //_______________________________________________________________________________ | |
31 | AliClonesPool::AliClonesPool(const AliClonesPool& src) | |
32 | : TClonesArray(src), fFreeID(src.fFreeID), fNFree(src.fNFree), fLastID(src.fLastID), fCastToTrack(src.fCastToTrack) | |
33 | { | |
34 | // ctor, delegate to TClonesArray | |
35 | } | |
36 | ||
37 | //_______________________________________________________________________________ | |
38 | AliClonesPool& AliClonesPool::operator=(const AliClonesPool& src) | |
39 | { | |
40 | if (this!=&src) { | |
41 | TClonesArray::operator=(src); | |
42 | fFreeID = src.fFreeID; | |
43 | fNFree = src.fNFree; | |
44 | fLastID = src.fLastID; | |
45 | fCastToTrack = src.fCastToTrack; | |
46 | } | |
47 | return *this; | |
48 | } | |
49 | ||
50 | //_______________________________________________________________________________ | |
51 | AliClonesPool::~AliClonesPool() | |
52 | { | |
53 | // d-tor | |
54 | Delete(); | |
55 | } | |
56 | ||
57 | //_______________________________________________________________________________ | |
58 | void AliClonesPool::Clear(Option_t* opt) | |
59 | { | |
60 | // reset all | |
61 | TClonesArray::Clear(opt); | |
62 | fNFree = 0; | |
63 | fLastID = -1; | |
64 | } | |
65 | ||
66 | //_______________________________________________________________________________ | |
67 | void AliClonesPool::MarkSlotFree(TObject *sd) | |
68 | { | |
69 | // account that this seed is "deleted" | |
70 | int id; | |
71 | if (!sd || (id=GetCloneID(sd))<0 ) return; | |
72 | if (!IsReset()) { | |
73 | // if (id<0) {AliError(Form("Freeing of seed %p NOT from the pool is requested",sd)); return;} | |
74 | sd->Clear(""); | |
75 | RemoveAt(id); | |
76 | if (fFreeID.GetSize()<=fNFree) fFreeID.Set( 2*fNFree + 100 ); | |
77 | fFreeID.GetArray()[fNFree++] = id; | |
78 | } | |
79 | // if (fCastToTrack) ((AliVParticle*)sd)->SetPoolID(-1); | |
80 | // else sd->SetUniqueID(0); | |
81 | } | |
82 | ||
83 | //_______________________________________________________________________________ | |
84 | void AliClonesPool::PrintSummary(Option_t *opt) const | |
85 | { | |
86 | // print summary | |
87 | printf("Pool:%s, Booked %d, Size: %d, Freed: %d\n",GetName(), GetEntriesFast(),GetSize(),fNFree); | |
88 | TString optS = opt; optS.ToLower(); | |
89 | if (optS.Contains("l")) TClonesArray::Print(); | |
90 | } |