]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSURecoDet.cxx
update for the NUA
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSURecoDet.cxx
CommitLineData
173b3073 1#include <TGeoVolume.h>
2#include <TGeoTube.h>
3#include <TGeoManager.h>
ee52e7b5 4#include <TTree.h>
a11ef2e4 5#include "AliITSURecoDet.h"
6#include "AliITSUGeomTGeo.h"
7#include "AliITSsegmentation.h"
8#include "AliITSUSegmentationPix.h"
ee52e7b5 9#include "AliITSUClusterPix.h"
173b3073 10#include "AliITSUReconstructor.h"
11
a11ef2e4 12
ee52e7b5 13
a11ef2e4 14ClassImp(AliITSURecoDet)
15
173b3073 16
17const Char_t* AliITSURecoDet::fgkBeamPipeVolName = "IP_PIPE";
18
19
a11ef2e4 20//______________________________________________________
32d38de2 21AliITSURecoDet::AliITSURecoDet(AliITSUGeomTGeo* geom, const char* name)
a11ef2e4 22: fNLayers(0)
23 ,fNLayersActive(0)
24 ,fRMax(-1)
25 ,fRMin(-1)
70cb7fe4 26 ,fRITSTPCRef(-1)
a11ef2e4 27 ,fLayers(0)
28 ,fLayersActive(0)
32d38de2 29 ,fGeom(geom)
a11ef2e4 30{
31 // def. c-tor
32 SetNameTitle(name,name);
33 fLayers.SetOwner(kTRUE); // layers belong to this array
34 fLayersActive.SetOwner(kFALSE); // this one just points on active layers in fLayers
32d38de2 35 Build();
a11ef2e4 36}
37
38//______________________________________________________
39AliITSURecoDet::~AliITSURecoDet()
40{
41 // def. d-tor
42 fLayersActive.Clear();
43 fLayers.Clear(); // owned!
a11ef2e4 44}
45
46//______________________________________________________
47void AliITSURecoDet::Print(Option_t* opt) const
48{
49 //print
50 printf("Detector %s, %d layers, %d active layers\n",GetName(),GetNLayers(),GetNLayersActive());
51 TString opts = opt; opts.ToLower();
70cb7fe4 52 if (opts.Contains("lr")) {
53 for (int i=0;i<GetNLayers();i++) GetLayer(i)->Print(opt);
54 printf("ITS-TPC matching reference R: %.3f\n",fRITSTPCRef);
55 }
a11ef2e4 56}
57
58//______________________________________________________
59void AliITSURecoDet::AddLayer(const AliITSURecoLayer* lr)
60{
61 //add new layer
62 fLayers.AddLast((TObject*)lr);
63 fNLayers++;
64 if (lr->IsActive()) {
65 fLayersActive.AddLast((TObject*)lr);
66 fNLayersActive++;
67 }
68}
69
70//______________________________________________________
71Bool_t AliITSURecoDet::Build()
72{
73 // build detector from TGeo
74 //
32d38de2 75 if (!fGeom) AliFatal("Geometry interface is not set");
76 int nlr = fGeom->GetNLayers();
a11ef2e4 77 if (!nlr) AliFatal("No geometry loaded");
a11ef2e4 78 //
79 // build active ITS layers
80 for (int ilr=0;ilr<nlr;ilr++) {
852af72e 81 int lrTyp = fGeom->GetLayerChipTypeID(ilr);
a11ef2e4 82 // name layer according its active id, detector type and segmentation tyoe
852af72e 83 AliITSURecoLayer* lra = new AliITSURecoLayer(Form("Lr%d%s%d",ilr,fGeom->GetChipTypeName(lrTyp),
84 lrTyp%AliITSUGeomTGeo::kMaxSegmPerChipType),
32d38de2 85 ilr,fGeom);
173b3073 86 lra->SetPassive(kFALSE);
a11ef2e4 87 AddLayer(lra);
88 }
dde91d5d 89 //
90 // build passive ITS layers
91 //
173b3073 92 double rMin,rMax,zMin,zMax;
93 // beam pipe
94 TGeoVolume *v = gGeoManager->GetVolume(fgkBeamPipeVolName);
95 AliITSURecoLayer* lrp = 0;
96 if (!v) AliWarning("No beam pipe found in geometry");
24e3f48c 97 else {
173b3073 98 TGeoTube *t=(TGeoTube*)v->GetShape();
99 rMin = t->GetRmin();
100 rMax = t->GetRmax();
101 zMin =-t->GetDz();
102 zMax = t->GetDz();
103 lrp = new AliITSURecoLayer("BeamPipe");
104 lrp->SetRMin(rMin);
105 lrp->SetRMax(rMax);
106 lrp->SetR(0.5*(rMin+rMax));
107 lrp->SetZMin(zMin);
108 lrp->SetZMax(zMax);
109 lrp->SetPassive(kTRUE);
110 AddLayer(lrp);
111 //
112 }
113 //
114 // TPC-ITS wall
c92b1537 115 const AliITSURecoParam* recopar = AliITSUReconstructor::GetRecoParam();
116 if (recopar) {
117 lrp = new AliITSURecoLayer("TPC-ITSwall");
118 lrp->SetRMin(AliITSUReconstructor::GetRecoParam()->GetTPCITSWallRMin());
119 lrp->SetRMax(AliITSUReconstructor::GetRecoParam()->GetTPCITSWallRMax());
120 lrp->SetR(0.5*(lrp->GetRMin()+lrp->GetRMax()));
121 lrp->SetZMin(-AliITSUReconstructor::GetRecoParam()->GetTPCITSWallZSpanH());
122 lrp->SetZMax( AliITSUReconstructor::GetRecoParam()->GetTPCITSWallZSpanH());
123 lrp->SetMaxStep( AliITSUReconstructor::GetRecoParam()->GetTPCITSWallMaxStep());
124 lrp->SetPassive(kTRUE);
125 AddLayer(lrp);
126 }
127 else {
128 AliWarning("RecoParam is not available, TPC-ITS wall is not set");
129 }
173b3073 130 //
dde91d5d 131 IndexLayers();
132 Print("lr");
a11ef2e4 133 return kTRUE;
134}
32d38de2 135
dde91d5d 136//______________________________________________________
137void AliITSURecoDet::IndexLayers()
138{
c51c3124 139 // sort and index layers
140 const Double_t kRMargin = 1e-2; // 100 micron margin
dde91d5d 141 fLayersActive.Sort();
142 for (int i=0;i<fNLayersActive;i++) GetLayerActive(i)->SetActiveID(i);
143 fLayers.Sort();
144 for (int i=0;i<fNLayers;i++) GetLayer(i)->SetID(i);
c51c3124 145 if (fNLayers>0) {
146 SetRMin(GetLayer(0)->GetRMin()-kRMargin);
147 SetRMax(GetLayer(fNLayers-1)->GetRMax()+kRMargin);
148 }
70cb7fe4 149 //
150 // define the reference R for ITS/TPC matching: outside of last layer but before TPC materials
151 const double kOffsLastActR = 5.; // offset of reference layer wrt last active R
152 int lastActive = GetLrIDActive(fNLayersActive-1);
153 AliITSURecoLayer* lrA = GetLayer(lastActive); // last active
154 double rref = lrA->GetRMax() + kOffsLastActR;
155 //
156 if (lastActive < fNLayers-1) { // there are material layers outside ...
157 AliITSURecoLayer* lrL = GetLayer(lastActive+1);
158 if (lrL->GetRMin()<=rref) rref = lrL->GetRMin();
159 if (rref - lrA->GetRMax()<kOffsLastActR) {
160 AliError(Form("The ITS-TPC matching reference R=%.2f is too close to last active R=%.3f",rref,lrA->GetRMax()));
161 }
162 }
163 SetRITSTPCRef(rref);
164 //
dde91d5d 165}
8b16dbae 166
167//______________________________________________________
168Int_t AliITSURecoDet::FindLastLayerID(Double_t r, int dir) const
169{
170 // find the last layer which the particle moving in direction dir (1:outward,-1:inward)
171 // will traverse on its way to radius r
172 int ilr;
173 //
174 if (dir>0) {
175 for (ilr=0;ilr<fNLayers;ilr++) {
176 AliITSURecoLayer* lr = GetLayer(ilr);
177 if ( r<lr->GetR(-dir) ) break; // this layer at least entered
178 }
e2d2481c 179 return --ilr; // -1 will correspond to point below the smalles layer
8b16dbae 180 }
181 else {
182 for (ilr=fNLayers;ilr--;) {
183 AliITSURecoLayer* lr = GetLayer(ilr);
184 if ( r>lr->GetR(-dir) ) break; // this layer at least entered
185 }
186 ilr++;
187 return ilr<fNLayers ? ilr:-1; // -1 will correspond to point above outer layer
188 }
189 //
190}
191
192//______________________________________________________
193Int_t AliITSURecoDet::FindFirstLayerID(Double_t r, int dir) const
194{
195 // find the first layer which the particle moving in direction dir (1:outward,-1:inward)
196 // will traverse starting from radius r
197 int ilr;
198 //
199 if (dir>0) {
200 for (ilr=0;ilr<fNLayers;ilr++) {
201 AliITSURecoLayer* lr = GetLayer(ilr);
202 if ( r<lr->GetR(dir) ) break; // this layer at least entered
203 }
204 return ilr<fNLayers ? ilr:-1; // -1 will correspond to point above outer leayer
205 }
206 else {
207 for (ilr=fNLayers;ilr--;) {
208 AliITSURecoLayer* lr = GetLayer(ilr);
209 if ( r>lr->GetR(dir) ) break; // this layer at least entered
8b16dbae 210 }
211 return ilr; // -1 will correspond to point below inner layer
212 }
213 //
214}
ee52e7b5 215
216//______________________________________________________
217void AliITSURecoDet::CreateClusterArrays()
218{
219 // create cluster arrays for active layers
220 for (int ilr=0;ilr<fNLayersActive;ilr++) {
221 AliITSURecoLayer* lr = GetLayerActive(ilr);
222 lr->SetOwnsClusterArray(kTRUE);
852af72e 223 int tpDet = fGeom->GetLayerChipTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerChipType;
ee52e7b5 224 //
852af72e 225 if (tpDet == AliITSUGeomTGeo::kChipTypePix) {
ee52e7b5 226 lr->SetClusters(new TClonesArray(AliITSUClusterPix::Class()));
227 }
228 else {
229 AliFatal(Form("Unknown detector type %d",tpDet));
230 }
231 //
232 }
233 //
234}
235
236//_____________________________________________________________________________
237Int_t AliITSURecoDet::LoadClusters(TTree* treeRP)
238{
239 // read clusters from the tree, if it is provided
240 if (!treeRP) return 0;
241 for (int ilr=fNLayersActive;ilr--;) {
242 TBranch* br = treeRP->GetBranch(Form("ITSRecPoints%d",ilr));
243 if (!br) AliFatal(Form("Provided cluster tree does not contain branch for layer %d",ilr));
244 br->SetAddress( GetLayerActive(ilr)->GetClustersAddress() );
245 }
246 return treeRP->GetEntry(0); // we are still in 1 ev/tree mode...
247}