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
65 for (Int_t iZones = 0; iZones < (Int_t)kZones; iZones++) {
68 fZmaxSensitive[iZones] = 0.0;
69 fIsHole[iZones] = kFALSE;
71 memset(fZmaxSensitive, 0, kZones*sizeof(Double_t));
74 //_____________________________________________________________________________
75 AliTRDpropagationLayer::AliTRDpropagationLayer(Double_t x, Double_t dx, Double_t rho
76 , Double_t radLength, Int_t tbIndex, Int_t plane)
86 ,fTimeBinIndex(tbIndex)
99 // AliTRDpropagationLayer constructor
102 for (Int_t i = 0; i < (Int_t)kZones; i++) {
107 if (fTimeBinIndex >= 0) {
108 fClusters = new AliTRDcluster*[kMaxClusterPerTimeBin];
109 fIndex = new UInt_t[kMaxClusterPerTimeBin];
112 for (Int_t i = 0; i < 5; i++) {
115 memset(fZmaxSensitive, 0, kZones*sizeof(Double_t));
118 //_____________________________________________________________________________
119 AliTRDpropagationLayer::AliTRDpropagationLayer(const AliTRDpropagationLayer &p)
120 :TObject((TObject&)p)
129 ,fTimeBinIndex(p.fTimeBinIndex)
132 ,fYmaxSensitive(p.fYmaxSensitive)
135 ,fHoleZmax(p.fHoleZmax)
137 ,fHoleYmax(p.fHoleYmax)
138 ,fHoleRho(p.fHoleRho)
142 // AliTRDpropagationLayer copy constructor
145 for (Int_t i = 0; i < (Int_t)kZones; i++) {
147 fZmax[i] = p.fZmax[i];
148 fIsHole[i] = p.fIsHole[i];
149 fZmaxSensitive[i] = p.fZmaxSensitive[i];
152 // Make a deep copy of the Clusters array and the Index array unless they are needed in class AliTRDstackLayer
153 Int_t arrsize = (Int_t)kMaxClusterPerTimeBin;
154 if (fTimeBinIndex >= 0) {
155 fClusters = new AliTRDcluster*[arrsize];
156 fIndex = new UInt_t[arrsize];
157 memset(fIndex, 0, sizeof(UInt_t)*arrsize);
158 memset(fClusters, 0, sizeof(AliTRDcluster *)*arrsize);
159 for(Int_t i = 0; i < arrsize; i++){
160 fClusters[i] = p.fClusters[i];
161 fIndex[i] = p.fIndex[i];
166 //_____________________________________________________________________________
167 AliTRDpropagationLayer::~AliTRDpropagationLayer()
173 if (fTimeBinIndex >= 0) {
180 //_____________________________________________________________________________
181 void AliTRDpropagationLayer::Copy(TObject &o) const
187 AliTRDpropagationLayer &p = (AliTRDpropagationLayer &)o;
194 p.fTimeBinIndex = fTimeBinIndex;
197 p.fYmaxSensitive = fYmaxSensitive;
200 p.fHoleZmax = fHoleZmax;
202 p.fHoleYmax = fHoleYmax;
203 p.fHoleRho = fHoleRho;
206 for (Int_t i = 0; i < (Int_t)kZones; i++) {
208 p.fZmax[i] = fZmax[i];
209 p.fIsHole[i] = fIsHole[i];
210 p.fZmaxSensitive[i] = fZmaxSensitive[i];
213 // Make a deep copy of the Clusters array and the Index array
214 // unless they are needed in class AliTRDstackLayer
215 if (fTimeBinIndex >= 0) {
217 p.fClusters = new AliTRDcluster*[(Int_t)kMaxClusterPerTimeBin];
219 p.fIndex = new UInt_t[(Int_t)kMaxClusterPerTimeBin];
221 for (Int_t i = 0; i < (Int_t)kMaxClusterPerTimeBin; i++){
223 p.fClusters[i] = fClusters[i];
224 p.fIndex[i] = fIndex[i];
229 //_____________________________________________________________________________
230 void AliTRDpropagationLayer::SetZ(Double_t * const center, Double_t * const w, Double_t * const wsensitive )
233 // Set centers and the width of sectors
236 for (Int_t istack = 0; istack < AliTRDgeometry::kNstack; istack++) {
237 fZc[istack] = center[istack];
238 fZmax[istack] = w[istack];
239 fZmaxSensitive[istack] = wsensitive[istack];
244 //_____________________________________________________________________________
245 void AliTRDpropagationLayer::SetHoles(Bool_t * const holes)
248 // Set centers and the width of sectors
253 for (Int_t istack = 0; istack < AliTRDgeometry::kNstack; istack++) {
254 fIsHole[istack] = holes[istack];
262 //_____________________________________________________________________________
263 void AliTRDpropagationLayer::InsertCluster(AliTRDcluster *c, UInt_t index)
266 // Insert cluster in cluster array.
267 // Clusters are sorted according to Y coordinate.
270 if (fTimeBinIndex < 0) {
271 //AliWarning("Attempt to insert cluster into non-sensitive time bin!\n");
275 if (fN == (Int_t) kMaxClusterPerTimeBin) {
276 //AliWarning("Too many clusters !\n");
286 Int_t i = Find(c->GetY());
287 memmove(fClusters+i+1,fClusters+i,(fN-i)*sizeof(AliTRDcluster*));
288 memmove(fIndex +i+1,fIndex +i,(fN-i)*sizeof(UInt_t));
295 //_____________________________________________________________________________
296 Int_t AliTRDpropagationLayer::Find(Float_t y) const
299 // Returns index of the cluster nearest in Y
305 if (y <= fClusters[0]->GetY()) {
308 if (y > fClusters[fN-1]->GetY()) {
314 Int_t m = (b + e) / 2;
316 for ( ; b < e; m = (b + e) / 2) {
317 if (y > fClusters[m]->GetY()) {
329 //_____________________________________________________________________________
330 Int_t AliTRDpropagationLayer::FindNearestCluster(Float_t y, Float_t z
332 , Float_t maxroadz) const
335 // Returns index of the cluster nearest to the given y,z
340 Float_t mindist = maxroad;
342 for (Int_t i = Find(y-maxroad); i < maxn; i++) {
343 AliTRDcluster *c = (AliTRDcluster *) (fClusters[i]);
344 Float_t ycl = c->GetY();
345 if (ycl > (y + maxroad)) {
348 if (TMath::Abs(c->GetZ() - z) > maxroadz) {
351 if (TMath::Abs(ycl - y) < mindist) {
352 mindist = TMath::Abs(ycl - y);