]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSRecPointContainer.cxx
Possible fix for bug 59991 (F. Prino). Added TObjArray::Delete at the end of the...
[u/mrichter/AliRoot.git] / ITS / AliITSRecPointContainer.cxx
CommitLineData
b21c1af0 1#include <TTree.h>
2#include "AliLog.h"
3#include "AliITSRecoParam.h"
4#include "AliITSReconstructor.h"
5#include "AliITSRecPointContainer.h"
6#include "AliITSRecPoint.h"
7#include "AliRunLoader.h"
8
9ClassImp(AliITSRecPointContainer)
10
11//////////////////////////////////////////////////////////////////////
12// Class to store ITS RecPoints for the duration of //
13// one event processing //
14// The container is cleared at each event and new RP //
15// are loaded from TTree //
16// Origin masera@to.infn.it Nov. 12 2009 //
17//////////////////////////////////////////////////////////////////////
18
19/* $Id$ */
20
21AliITSRecPointContainer* AliITSRecPointContainer::fgInstance = 0x0;
22
23//______________________________________________________________________
24AliITSRecPointContainer::AliITSRecPointContainer(const AliITSRecoParam* krp):TObject(),
25fSPDNModules(0),
26fSDDNModules(0),
27fSSDNModules(0),
28fArray(),
29fCurrentEve(-1000),
30fActualSize(0),
e62fe478 31fDet(""),
32fStatusOK(kTRUE){
b21c1af0 33 // Default constructor
34
35 if(fgkNModules != AliITSgeomTGeo::GetNModules())AliError(Form("The total number of modules is not %d, but %d",fgkNModules,AliITSgeomTGeo::GetNModules()));
36
37 Int_t modperlay[6];
38 for(Int_t i=0;i<6;i++)modperlay[i]=AliITSgeomTGeo::GetNDetectors(1+i)*AliITSgeomTGeo::GetNLadders(1+i);
39 fSPDNModules=modperlay[0]+modperlay[1];
40 fSDDNModules=modperlay[2]+modperlay[3];
41 fSSDNModules=modperlay[4]+modperlay[5];
42 // AliInfo(Form("Total modules: %d \n SPD modules=%d , SDD modules=%d, SSD modules=%d ",fgkNModules,fSPDNModules,fSDDNModules,fSSDNModules));
43
44 // kLimits[0:5] --> low fluw; kLimits[6,11] --> High flux
45 const Int_t kLimits[12]={25,25,20,20,10,10,300,300,200,200,100,100};
46 Int_t offset=0;
47 if(!krp){
48 AliWarning("AliITSRecoPoint is missing. Using defaults");
49 }
50 else {
51 if(krp->GetEventSpecie() == AliRecoParam::kHighMult)offset=6;
52 }
53 Int_t maxval[6];
54 TString values="";
55 for(Int_t i=0;i<6;i++){
56 maxval[i]=kLimits[i+offset];
57 values+=maxval[i];
58 values+=" ";
59 if(i>0)modperlay[i]+=modperlay[i-1];
60 }
61 AliInfo(Form("Container created with sizes/layer: %s",values.Data()));
62 Int_t layer=0;
63 for(Int_t i=0;i<fgkNModules;i++){
64 if(i>=modperlay[layer])++layer;
65 fArray[i]=new TClonesArray("AliITSRecPoint",maxval[layer]);
66 }
67}
68
69
70//______________________________________________________________________
71AliITSRecPointContainer::~AliITSRecPointContainer(){
72 // Destructor
73 for(Int_t i=0;i<fgkNModules;i++){
74 if(fArray[i]){
75 fArray[i]->Delete();
76 delete fArray[i];
77 }
78 }
79}
80
81//______________________________________________________________________
82void AliITSRecPointContainer::CookEntries(){
83 // From the number of entries in TTree R, the number of ITS subdetectors
84 // active for the present run is inferred
85 if(fActualSize == fgkNModules)fDet="ALL SPD SDD SSD ";
86 if(fActualSize == fSPDNModules) fDet = "SPD ";
87 if(fActualSize == fSDDNModules) fDet = "SDD ";
88 if(fActualSize == fSSDNModules)fDet = "SSD ";
89 if(fActualSize == (fSPDNModules+fSDDNModules)) fDet = "SPD SDD ";
90 if(fActualSize == (fSPDNModules+fSSDNModules))fDet = "SPD SSD ";
91 if(fActualSize == (fSDDNModules+fSSDNModules))fDet = "SDD SSD ";
92 if((!fDet.Contains("SPD")) && (!fDet.Contains("SDD")) &&
e62fe478 93 (!fDet.Contains("SSD"))){
94 AliError(Form("The number of active modules %d does not correspond to any standard configuration of the detector",fActualSize));
95 fStatusOK = kFALSE;
96 }
b21c1af0 97}
98//______________________________________________________________________
99TClonesArray* AliITSRecPointContainer::FetchClusters(Int_t mod, TTree* tR){
788ba14f 100 // retrieves Recpoints for module mod (offline mode: the event number is
101 // retrieved via the AliRunLoader object)
b21c1af0 102 Int_t cureve=AliRunLoader::Instance()->GetEventNumber();
788ba14f 103 return FetchClusters(mod,tR,cureve);
104}
105//______________________________________________________________________
106TClonesArray* AliITSRecPointContainer::FetchClusters(Int_t mod, TTree* tR,Int_t cureve){
107 // retrieves Recpoints for module mod
108 // cureve is the current event number. If it is different w.r.t.
109 // the event number stored in fCurrentEve, the recpoints are read from
110 // the TTree. Otherwise, the RP stored in memory are used.
b21c1af0 111 if(cureve != fCurrentEve){
112 fCurrentEve = cureve;
113 Reset();
114 TBranch *branch = NULL;
115 branch = tR->GetBranch("ITSRecPoints");
116 if(!branch){
117 AliError("Branch ITSRecPoints not found on ITS recpoints TTree");
e62fe478 118 fStatusOK = kFALSE;
b21c1af0 119 return NULL;
120 }
121
122 fActualSize = branch->GetEntries();
123 CookEntries();
124 if(fDet.IsNull())return NULL;
125
126 // it is assumed that the filling order of the tree is SPD, SDD, SSD
127 // even if one or two subdetector are missing
128 if(IsSPDActive()){
129 for(Int_t i=0;i<fSPDNModules;i++){
130 branch->SetAddress(&fArray[i]);
131 branch->GetEvent(i);
132 }
133 }
134 if(IsSDDActive()){
135 Int_t start=0;
136 if(IsSPDActive())start+=fSPDNModules;
137 Int_t counter = fSPDNModules;
138 for(Int_t i=start;i<start+fSDDNModules;i++){
139 branch->SetAddress(&fArray[counter]);
140 ++counter;
141 branch->GetEvent(i);
142 }
143 }
144 if(IsSSDActive()){
145 Int_t start=0;
146 if(IsSPDActive())start+=fSPDNModules;
147 if(IsSDDActive())start+=fSDDNModules;
148 Int_t counter = fSPDNModules+fSDDNModules;
149 for(Int_t i=start;i<start+fSSDNModules;i++){
150 branch->SetAddress(&fArray[counter]);
151 ++counter;
152 branch->GetEvent(i);
153 }
154 }
155 }
156
157 if(CheckBoundaries(mod)){
158 return fArray[mod];
159 }
160 else {
161 AliError(Form("Module %d is out of boundaries",mod));
162 return NULL;
163 }
164
165}
166
167//______________________________________________________________________
168AliITSRecPointContainer* AliITSRecPointContainer::Instance(const AliITSRecoParam* kptr){
169 // returns AliITSRecPointContainer instance (singleton)
170 if(!fgInstance){
171 if(!kptr){
172 fgInstance = new AliITSRecPointContainer(AliITSReconstructor::GetRecoParam());
173 }
174 else {
175 fgInstance = new AliITSRecPointContainer(kptr);
176 }
177 }
178 return fgInstance;
179}
180
181//______________________________________________________________________
182void AliITSRecPointContainer::Reset(){
183 // Resets the status of the object
184 for(Int_t i=0;i<fgkNModules;i++){
185 (fArray[i])->Clear();
186 }
187 fDet="";
188}