1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // The TRD propagation layer //
23 // Marian Ivanov <M.Ivanov@gsi.de> //
24 // Alex Bercuci <A.Bercuci@gsi.de> //
25 // Markus Fasel <M.Fasel@gsi.de> //
27 ////////////////////////////////////////////////////////////////////////////
33 #include "AliTRDpropagationLayer.h"
34 //#include "AliTRDtracker.h"
35 #include "AliTRDcluster.h"
36 #include "AliTRDgeometry.h"
38 //_____________________________________________________________________________
39 AliTRDpropagationLayer::AliTRDpropagationLayer()
62 // Default constructor
67 //_____________________________________________________________________________
68 AliTRDpropagationLayer::AliTRDpropagationLayer(Double_t x, Double_t dx, Double_t rho
69 , Double_t radLength, Int_t tbIndex, Int_t plane)
79 ,fTimeBinIndex(tbIndex)
92 // AliTRDpropagationLayer constructor
95 for (Int_t i = 0; i < (Int_t)kZones; i++) {
100 if (fTimeBinIndex >= 0) {
101 fClusters = new AliTRDcluster*[kMaxClusterPerTimeBin];
102 fIndex = new UInt_t[kMaxClusterPerTimeBin];
105 for (Int_t i = 0; i < 5; i++) {
111 //_____________________________________________________________________________
112 AliTRDpropagationLayer::AliTRDpropagationLayer(const AliTRDpropagationLayer &p)
113 :TObject((TObject&)p)
122 ,fTimeBinIndex(p.fTimeBinIndex)
125 ,fYmaxSensitive(p.fYmaxSensitive)
128 ,fHoleZmax(p.fHoleZmax)
130 ,fHoleYmax(p.fHoleYmax)
131 ,fHoleRho(p.fHoleRho)
135 // AliTRDpropagationLayer copy constructor
138 for (Int_t i = 0; i < (Int_t)kZones; i++) {
140 fZmax[i] = p.fZmax[i];
141 fIsHole[i] = p.fIsHole[i];
142 fZmaxSensitive[i] = p.fZmaxSensitive[i];
145 // Make a deep copy of the Clusters array and the Index array unless they are needed in class AliTRDstackLayer
146 Int_t arrsize = (Int_t)kMaxClusterPerTimeBin;
147 if (fTimeBinIndex >= 0) {
148 fClusters = new AliTRDcluster*[arrsize];
149 fIndex = new UInt_t[arrsize];
151 memset(fIndex, 0, sizeof(UInt_t)*arrsize);
152 memset(fClusters, 0, sizeof(AliTRDcluster *)*arrsize);
153 for(Int_t i = 0; i < arrsize; i++){
154 fClusters[i] = p.fClusters[i];
155 fIndex[i] = p.fIndex[i];
159 //_____________________________________________________________________________
160 AliTRDpropagationLayer::~AliTRDpropagationLayer()
166 if (fTimeBinIndex >= 0) {
173 //_____________________________________________________________________________
174 void AliTRDpropagationLayer::Copy(TObject &o) const
180 AliTRDpropagationLayer &p = (AliTRDpropagationLayer &)o;
187 p.fTimeBinIndex = fTimeBinIndex;
190 p.fYmaxSensitive = fYmaxSensitive;
193 p.fHoleZmax = fHoleZmax;
195 p.fHoleYmax = fHoleYmax;
196 p.fHoleRho = fHoleRho;
199 for (Int_t i = 0; i < (Int_t)kZones; i++) {
201 p.fZmax[i] = fZmax[i];
202 p.fIsHole[i] = fIsHole[i];
203 p.fZmaxSensitive[i] = fZmaxSensitive[i];
206 // Make a deep copy of the Clusters array and the Index array
207 // unless they are needed in class AliTRDstackLayer
208 if (fTimeBinIndex >= 0) {
210 p.fClusters = new AliTRDcluster*[(Int_t)kMaxClusterPerTimeBin];
212 p.fIndex = new UInt_t[(Int_t)kMaxClusterPerTimeBin];
214 for (Int_t i = 0; i < (Int_t)kMaxClusterPerTimeBin; i++){
216 p.fClusters[i] = fClusters[i];
217 p.fIndex[i] = fIndex[i];
222 //_____________________________________________________________________________
223 void AliTRDpropagationLayer::SetZ(Double_t *center, Double_t *w, Double_t *wsensitive )
226 // Set centers and the width of sectors
229 for (Int_t istack = 0; istack < AliTRDgeometry::kNstack; istack++) {
230 fZc[istack] = center[istack];
231 fZmax[istack] = w[istack];
232 fZmaxSensitive[istack] = wsensitive[istack];
237 //_____________________________________________________________________________
238 void AliTRDpropagationLayer::SetHoles(Bool_t *holes)
241 // Set centers and the width of sectors
246 for (Int_t istack = 0; istack < AliTRDgeometry::kNstack; istack++) {
247 fIsHole[istack] = holes[istack];
255 //_____________________________________________________________________________
256 void AliTRDpropagationLayer::InsertCluster(AliTRDcluster *c, UInt_t index)
259 // Insert cluster in cluster array.
260 // Clusters are sorted according to Y coordinate.
263 if (fTimeBinIndex < 0) {
264 //AliWarning("Attempt to insert cluster into non-sensitive time bin!\n");
268 if (fN == (Int_t) kMaxClusterPerTimeBin) {
269 //AliWarning("Too many clusters !\n");
279 Int_t i = Find(c->GetY());
280 memmove(fClusters+i+1,fClusters+i,(fN-i)*sizeof(AliTRDcluster*));
281 memmove(fIndex +i+1,fIndex +i,(fN-i)*sizeof(UInt_t));
288 //_____________________________________________________________________________
289 Int_t AliTRDpropagationLayer::Find(Float_t y) const
292 // Returns index of the cluster nearest in Y
298 if (y <= fClusters[0]->GetY()) {
301 if (y > fClusters[fN-1]->GetY()) {
307 Int_t m = (b + e) / 2;
309 for ( ; b < e; m = (b + e) / 2) {
310 if (y > fClusters[m]->GetY()) {
322 //_____________________________________________________________________________
323 Int_t AliTRDpropagationLayer::FindNearestCluster(Float_t y, Float_t z
325 , Float_t maxroadz) const
328 // Returns index of the cluster nearest to the given y,z
333 Float_t mindist = maxroad;
335 for (Int_t i = Find(y-maxroad); i < maxn; i++) {
336 AliTRDcluster *c = (AliTRDcluster *) (fClusters[i]);
337 Float_t ycl = c->GetY();
338 if (ycl > (y + maxroad)) {
341 if (TMath::Abs(c->GetZ() - z) > maxroadz) {
344 if (TMath::Abs(ycl - y) < mindist) {
345 mindist = TMath::Abs(ycl - y);