]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSURecoDet.cxx
Simulation response function treatment.
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSURecoDet.cxx
1 #include <TGeoVolume.h>
2 #include <TGeoTube.h>
3 #include <TGeoManager.h>
4 #include "AliITSURecoDet.h"
5 #include "AliITSUGeomTGeo.h"
6 #include "AliITSsegmentation.h"
7 #include "AliITSUSegmentationPix.h"
8 #include "AliITSUReconstructor.h"
9
10
11 ClassImp(AliITSURecoDet)
12
13
14 const Char_t* AliITSURecoDet::fgkBeamPipeVolName = "IP_PIPE";
15
16
17 //______________________________________________________
18 AliITSURecoDet::AliITSURecoDet(AliITSUGeomTGeo* geom, const char* name)
19 :  fNLayers(0)
20   ,fNLayersActive(0)
21   ,fRMax(-1)
22   ,fRMin(-1)
23   ,fLayers(0)
24   ,fLayersActive(0)
25   ,fGeom(geom)
26 {
27   // def. c-tor
28   SetNameTitle(name,name);
29   fLayers.SetOwner(kTRUE);        // layers belong to this array
30   fLayersActive.SetOwner(kFALSE); // this one just points on active layers in fLayers
31   Build();
32 }
33
34 //______________________________________________________
35 AliITSURecoDet::~AliITSURecoDet()
36 {
37   // def. d-tor
38   fLayersActive.Clear(); 
39   fLayers.Clear();         // owned!
40 }
41
42 //______________________________________________________
43 void AliITSURecoDet::Print(Option_t* opt) const                       
44 {
45   //print 
46   printf("Detector %s, %d layers, %d active layers\n",GetName(),GetNLayers(),GetNLayersActive());
47   TString opts = opt; opts.ToLower();
48   if (opts.Contains("lr")) for (int i=0;i<GetNLayers();i++) GetLayer(i)->Print(opt);
49 }
50
51 //______________________________________________________
52 void AliITSURecoDet::AddLayer(const AliITSURecoLayer* lr)
53 {
54   //add new layer
55   fLayers.AddLast((TObject*)lr);
56   fNLayers++;
57   if (lr->IsActive()) {
58     fLayersActive.AddLast((TObject*)lr);
59     fNLayersActive++;
60   }
61 }
62
63 //______________________________________________________
64 Bool_t AliITSURecoDet::Build()
65 {
66   // build detector from TGeo
67   //
68   if (!fGeom) AliFatal("Geometry interface is not set");
69   int nlr = fGeom->GetNLayers();
70   if (!nlr) AliFatal("No geometry loaded");
71   //
72   // build active ITS layers
73   for (int ilr=0;ilr<nlr;ilr++) {
74     int lrTyp = fGeom->GetLayerDetTypeID(ilr);
75     // name layer according its active id, detector type and segmentation tyoe
76     AliITSURecoLayer* lra = new AliITSURecoLayer(Form("Lr%d%s%d",ilr,fGeom->GetDetTypeName(lrTyp),
77                                                       lrTyp%AliITSUGeomTGeo::kMaxSegmPerDetType),
78                                                  ilr,fGeom);
79     lra->SetPassive(kFALSE);
80     AddLayer(lra);
81   }
82   //
83   // build passive ITS layers
84   //
85   double rMin,rMax,zMin,zMax;
86   // beam pipe
87   TGeoVolume *v = gGeoManager->GetVolume(fgkBeamPipeVolName);
88   AliITSURecoLayer* lrp = 0;
89   if (!v) AliWarning("No beam pipe found in geometry");
90   {
91     TGeoTube *t=(TGeoTube*)v->GetShape();
92     rMin = t->GetRmin();
93     rMax = t->GetRmax();
94     zMin =-t->GetDz();
95     zMax = t->GetDz();
96     lrp = new AliITSURecoLayer("BeamPipe");
97     lrp->SetRMin(rMin);
98     lrp->SetRMax(rMax);
99     lrp->SetR(0.5*(rMin+rMax));
100     lrp->SetZMin(zMin);
101     lrp->SetZMax(zMax);
102     lrp->SetPassive(kTRUE);
103     AddLayer(lrp);
104     //
105   }
106   //
107   // TPC-ITS wall
108   const AliITSURecoParam* recopar = AliITSUReconstructor::GetRecoParam();
109   if (recopar) {
110     lrp = new AliITSURecoLayer("TPC-ITSwall");
111     lrp->SetRMin(AliITSUReconstructor::GetRecoParam()->GetTPCITSWallRMin());
112     lrp->SetRMax(AliITSUReconstructor::GetRecoParam()->GetTPCITSWallRMax());
113     lrp->SetR(0.5*(lrp->GetRMin()+lrp->GetRMax()));
114     lrp->SetZMin(-AliITSUReconstructor::GetRecoParam()->GetTPCITSWallZSpanH());
115     lrp->SetZMax( AliITSUReconstructor::GetRecoParam()->GetTPCITSWallZSpanH());
116     lrp->SetMaxStep( AliITSUReconstructor::GetRecoParam()->GetTPCITSWallMaxStep());
117     lrp->SetPassive(kTRUE);
118     AddLayer(lrp);
119   }
120   else {
121     AliWarning("RecoParam is not available, TPC-ITS wall is not set");
122   }
123   //
124   IndexLayers();
125   Print("lr");
126   return kTRUE;
127 }
128
129 //______________________________________________________
130 void AliITSURecoDet::IndexLayers()
131 {
132   // sort and index layers
133   const Double_t kRMargin = 1e-2; // 100 micron margin
134   fLayersActive.Sort();
135   for (int i=0;i<fNLayersActive;i++) GetLayerActive(i)->SetActiveID(i);
136   fLayers.Sort();
137   for (int i=0;i<fNLayers;i++) GetLayer(i)->SetID(i);
138   if (fNLayers>0) {
139     SetRMin(GetLayer(0)->GetRMin()-kRMargin);
140     SetRMax(GetLayer(fNLayers-1)->GetRMax()+kRMargin);
141   }
142 }
143
144 //______________________________________________________
145 Int_t AliITSURecoDet::FindLastLayerID(Double_t r, int dir) const
146 {
147   // find the last layer which the particle moving in direction dir (1:outward,-1:inward) 
148   // will traverse on its way to radius r 
149   int ilr;
150   //
151   if (dir>0) {
152     for (ilr=0;ilr<fNLayers;ilr++) {
153       AliITSURecoLayer* lr = GetLayer(ilr);
154       if ( r<lr->GetR(-dir) ) break;  // this layer at least entered
155     }
156     return --ilr;  // -1 will correspond to point below the smalles layer
157   }
158   else {
159     for (ilr=fNLayers;ilr--;) {
160       AliITSURecoLayer* lr = GetLayer(ilr);
161       if ( r>lr->GetR(-dir) ) break; // this layer at least entered
162     }
163     ilr++;
164     return ilr<fNLayers ? ilr:-1; // -1 will correspond to point above outer layer
165   }
166   //
167 }
168
169 //______________________________________________________
170 Int_t AliITSURecoDet::FindFirstLayerID(Double_t r, int dir) const
171 {
172   // find the first layer which the particle moving in direction dir (1:outward,-1:inward) 
173   // will traverse starting from radius r 
174   int ilr;
175   //
176   if (dir>0) {
177     for (ilr=0;ilr<fNLayers;ilr++) {
178       AliITSURecoLayer* lr = GetLayer(ilr);
179       if ( r<lr->GetR(dir) ) break;  // this layer at least entered
180     }
181     return ilr<fNLayers ? ilr:-1;  // -1 will correspond to point above outer leayer
182   }
183   else {
184     for (ilr=fNLayers;ilr--;) {
185       AliITSURecoLayer* lr = GetLayer(ilr);
186       if ( r>lr->GetR(dir) ) break; // this layer at least entered
187     }
188     return ilr; // -1 will correspond to point below inner layer
189   }
190   //
191 }