save number of clusters/tracklet in debug stream
[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){
100 // retrieves Recpoints for module mod
101 Int_t cureve=AliRunLoader::Instance()->GetEventNumber();
102 if(cureve != fCurrentEve){
103 fCurrentEve = cureve;
104 Reset();
105 TBranch *branch = NULL;
106 branch = tR->GetBranch("ITSRecPoints");
107 if(!branch){
108 AliError("Branch ITSRecPoints not found on ITS recpoints TTree");
e62fe478 109 fStatusOK = kFALSE;
b21c1af0 110 return NULL;
111 }
112
113 fActualSize = branch->GetEntries();
114 CookEntries();
115 if(fDet.IsNull())return NULL;
116
117 // it is assumed that the filling order of the tree is SPD, SDD, SSD
118 // even if one or two subdetector are missing
119 if(IsSPDActive()){
120 for(Int_t i=0;i<fSPDNModules;i++){
121 branch->SetAddress(&fArray[i]);
122 branch->GetEvent(i);
123 }
124 }
125 if(IsSDDActive()){
126 Int_t start=0;
127 if(IsSPDActive())start+=fSPDNModules;
128 Int_t counter = fSPDNModules;
129 for(Int_t i=start;i<start+fSDDNModules;i++){
130 branch->SetAddress(&fArray[counter]);
131 ++counter;
132 branch->GetEvent(i);
133 }
134 }
135 if(IsSSDActive()){
136 Int_t start=0;
137 if(IsSPDActive())start+=fSPDNModules;
138 if(IsSDDActive())start+=fSDDNModules;
139 Int_t counter = fSPDNModules+fSDDNModules;
140 for(Int_t i=start;i<start+fSSDNModules;i++){
141 branch->SetAddress(&fArray[counter]);
142 ++counter;
143 branch->GetEvent(i);
144 }
145 }
146 }
147
148 if(CheckBoundaries(mod)){
149 return fArray[mod];
150 }
151 else {
152 AliError(Form("Module %d is out of boundaries",mod));
153 return NULL;
154 }
155
156}
157
158//______________________________________________________________________
159AliITSRecPointContainer* AliITSRecPointContainer::Instance(const AliITSRecoParam* kptr){
160 // returns AliITSRecPointContainer instance (singleton)
161 if(!fgInstance){
162 if(!kptr){
163 fgInstance = new AliITSRecPointContainer(AliITSReconstructor::GetRecoParam());
164 }
165 else {
166 fgInstance = new AliITSRecPointContainer(kptr);
167 }
168 }
169 return fgInstance;
170}
171
172//______________________________________________________________________
173void AliITSRecPointContainer::Reset(){
174 // Resets the status of the object
175 for(Int_t i=0;i<fgkNModules;i++){
176 (fArray[i])->Clear();
177 }
178 fDet="";
179}