]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSt345SlatSegmentationV2.cxx
BuildStation6 made consistent with AliMUONFactoryV2
[u/mrichter/AliRoot.git] / MUON / AliMUONSt345SlatSegmentationV2.cxx
CommitLineData
90e8f97c 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16/* $Id$ */
17
18#include "AliMUONSt345SlatSegmentationV2.h"
19
20#include "AliLog.h"
21#include "AliMpArea.h"
22#include "AliMpSlat.h"
23#include "AliMpSlatSegmentation.h"
24#include "AliMpPCB.h"
25// FIXME: we should not need access to PCB at this level
26// if the Dpx, Dpy, Sector interface would not be used.
27// Investigate instead to direct use of AliMpVSegmentation and AliMpPad
28// from the clusterFinder ? // :aphecetc:20050722
29// or, or ... have the AliMpSlat handles the notion of zone, finally
30// (where "zone" in mapping is equivalent to "sector" here), and thus
31// let AliMpSlat offer the interface to get information similar to what
32// Dpx, Dpy, Sector offer now to the clustering. That indeed should be
33// handled directly at the level of AliMpVSegmentation...
34#include "AliMpVPadIterator.h"
35#include "AliMUONSegmentationManager.h"
36#include "AliMUONConstants.h"
37
38#include "Riostream.h"
39
40#include "TClass.h"
41
42ClassImp(AliMUONSt345SlatSegmentationV2)
43
44namespace
45{
46 Double_t fgkLengthUnit = 0.1; // This class expects centimeters, while
47 // AliMpSlat works with milimeters.
48 Int_t fgIntOffset = 1;
49 Float_t FMAX(1E9);
50}
51
52//_____________________________________________________________________________
53AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
54: AliMUONVGeometryDESegmentation(),
55fDetElemId(-1),
56fPlaneType(kBendingPlane),
57fSlat(0),
58fSlatSegmentation(0),
59fPadIterator(0),
60fXhit(FMAX),
61fYhit(FMAX)
62{
63 AliDebug(1,Form("this=%p default (empty) ctor",this));
64}
65
66//_____________________________________________________________________________
67AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(Int_t detElemId, AliMpPlaneType bendingOrNonBending)
68: AliMUONVGeometryDESegmentation(),
69fDetElemId(detElemId),
70fPlaneType(bendingOrNonBending),
71fSlat(0),
72fSlatSegmentation(0),
73fPadIterator(0),
74fXhit(FMAX),
75fYhit(FMAX)
76{
77 // slatType is the description of the PCBs of that slat,
78 // e.g. 122200N, 112200SR2, 112233NR3, etc...
79 // The actual filename used is dealt with by the AliMpSt345Reader class.
80 // Same thing for the path if that file, by the way.
81
82 ReadMappingData();
83
84 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
85 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
86 fSlatSegmentation));
87}
88
89//_____________________________________________________________________________
90AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
91{
92 AliDebug(1,Form("dtor this=%p",this));
93 delete fPadIterator;
94}
95
96//_____________________________________________________________________________
97TF1*
98AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t) const
99{
100 AliFatal("Not Implemented");
101 return 0x0;
102}
103
104//_____________________________________________________________________________
105Float_t
106AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t,Int_t,
107 Float_t,Float_t,Int_t*)
108{
109 AliFatal("Not Implemented");
110 return 0.0;
111}
112
113//_____________________________________________________________________________
114void
115AliMUONSt345SlatSegmentationV2::Draw(Option_t*)
116{
117 AliFatal("Not Implemented");
118}
119
120//_____________________________________________________________________________
121Float_t
122AliMUONSt345SlatSegmentationV2::Dpx() const
123{
124 AliFatal("Not Implemented");
125 return 0.0;
126}
127
128//_____________________________________________________________________________
129Float_t
130AliMUONSt345SlatSegmentationV2::Dpy() const
131{
132 AliFatal("Not Implemented");
133 return 0.0;
134}
135
136//_____________________________________________________________________________
137Float_t
138AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
139{
140 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
141 if (!pcb) AliFatal("pcb is null!");
142 return pcb->PadSizeX();
143}
144
145//_____________________________________________________________________________
146Float_t
147AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
148{
149 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
150 if (!pcb) AliFatal("pcb is null!");
151 return pcb->PadSizeY();
152}
153
154//_____________________________________________________________________________
155void
156AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,
157 Float_t /*zhit*/,
158 Float_t dx, Float_t dy)
159{
160 // OK. We will do it in 2 steps. First get the area over which to
161 // iterate, based on hit coordinates and (dx,dy). This first step
162 // has nothing to do with segmentation in the first place, but with
163 // how we simulate the fact that at some point the charge is shared
164 // amongst several pads.
165 // The second step is the actual pad iteration and is handled by
166 // a specific class (which has to do only with iteration...)
167 //
168 // FIXME: this method should not be here in the first place, IMHO.
169 //
170
171 // Find the wire position (center of charge distribution)
172 Float_t xwire = GetAnod(xhit);
173 fXhit = xwire;
174 fYhit = yhit;
175
176 Double_t x01 = xwire - dx;
177 Double_t x02 = xwire + dx;
178 Double_t y01 = yhit - dy;
179 Double_t y02 = yhit + dy;
180
181 Double_t xext = x02 - x01;
182 Double_t yext = y02 - y01;
183
184 // we do not check area here, as we assume the iterator
185 // will do it, and will possibly truncate it if needed.
186 // Note that we convert the area position to a reference frame
187 // located in the lower-left corner of the slat, instead of its
188 // center.
189 AliMpArea area(TVector2((x01+x02)/2.0/fgkLengthUnit+fSlat->DX(),
190 (y01+y02)/2.0/fgkLengthUnit+fSlat->DY()),
191 TVector2(xext/2.0/fgkLengthUnit,yext/2.0/fgkLengthUnit));
192
193 delete fPadIterator;
194
195 fPadIterator = fSlatSegmentation->CreateIterator(area);
196
197 fPadIterator->First();
198
199 fCurrentPad = fPadIterator->CurrentItem();
200
201 if ( !fCurrentPad.IsValid() )
202 {
203 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
204 }
205
206 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
207 xhit,yhit,dx,dy,
208 fCurrentPad.GetIndices().GetFirst()+1,
209 fCurrentPad.GetIndices().GetSecond()+1,fSlat->GetID()));
210}
211
212//_____________________________________________________________________________
213Float_t
214AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
215{
216 // Gets the x-coordinate of the wire which is the closest to xhit.
217
218 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
219 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
220 return AliMUONConstants::Pitch()*wire;
221}
222
223//_____________________________________________________________________________
224AliMUONGeometryDirection
225AliMUONSt345SlatSegmentationV2::GetDirection()
226{
227 AliFatal("Not Implemented");
228 return kDirUndefined;
229}
230
90e8f97c 231//_____________________________________________________________________________
232void
233AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
234{
235 AliFatal("Not Implemented");
236}
237
238//_____________________________________________________________________________
239void
240AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
241 Float_t& x, Float_t& y, Float_t& z)
242{
243 z = 0;
244 GetPadC(ix,iy,x,y);
245}
246
247//_____________________________________________________________________________
248void
249AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
250 Float_t& x, Float_t& y)
251{
252 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),true);
253 x = pad.Position().X() * fgkLengthUnit;
254 y = pad.Position().Y() * fgkLengthUnit;
255}
256
90e8f97c 257
258//_____________________________________________________________________________
259void
260AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
261Int_t& ix, Int_t& iy)
262{
263 GetPadI(x,y,ix,iy);
264}
265
266//_____________________________________________________________________________
267void
268AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
269 Int_t& ix, Int_t& iy)
270{
271 Double_t slatx = fSlat->DX();
272 Double_t slaty = fSlat->DY();
273 AliMpPad pad =
274 fSlatSegmentation->PadByPosition(TVector2(x/fgkLengthUnit+slatx,
275 y/fgkLengthUnit+slaty), true);
276
277 if ( pad != AliMpPad::Invalid() )
278 {
279 ix = pad.GetIndices().GetFirst() + fgIntOffset;
280 iy = pad.GetIndices().GetSecond() + fgIntOffset;
281 }
282 else
283 {
284 ix = iy = -1;
285 }
286}
287
288//_____________________________________________________________________________
289void
290AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
291{
292 AliFatal("Not Implemented");
293}
294
295//_____________________________________________________________________________
296Bool_t
297AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
298{
299 Int_t ix, iy;
300 GetPadI(x,y,z,ix,iy);
301 return HasPad(ix,iy);
302}
303
304//_____________________________________________________________________________
305Bool_t
306AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
307{
308 return fSlatSegmentation->HasPad(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset));
309}
310
311//_____________________________________________________________________________
312void
313AliMUONSt345SlatSegmentationV2::Init(int)
314{
315 AliWarning("Not Implemented because not needed ;-)");
316}
317
318//_____________________________________________________________________________
319void
320AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
321 Float_t& y1, Float_t& y2)
322{
323 //
324 // Returns integration limits for current pad
325 //
326
327 // x1 = fXhit - fX - Dpx(fSector)/2.;
328 // x2 = x1 + Dpx(fSector);
329 // y1 = fYhit - fY - Dpy(fSector)/2.;
330 // y2 = y1 + Dpy(fSector);
331
332 Float_t x = fCurrentPad.Position().X() * fgkLengthUnit;
333 Float_t y = fCurrentPad.Position().Y() * fgkLengthUnit;
334
335 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0 * fgkLengthUnit;
336 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0 * fgkLengthUnit;
337
338 x1 = fXhit - x - padsizex/2.0;
339 x2 = x1 + padsizex;
340 y1 = fYhit - y - padsizey/2.0;
341 y2 = y1 + padsizey;
342
343 AliDebug(4,Form("xhit,yhit=%e,%e x,y=%e,%e, x1,x2,y1,y2=%e,%e,%e,%e",fXhit,fYhit,x,y,x1,x2,y1,y2));
344}
345
346//_____________________________________________________________________________
347Int_t
348AliMUONSt345SlatSegmentationV2::ISector()
349{
350 // FIXME: remove the usage of ISector from all the code.
351 return -10;
352}
353
354//_____________________________________________________________________________
355Int_t
356AliMUONSt345SlatSegmentationV2::Ix()
357{
358 if ( fPadIterator )
359 {
360 return fPadIterator->CurrentItem().GetIndices().GetFirst() + fgIntOffset;
361 }
362 else
363 {
364 return -1;
365 }
366}
367
368//_____________________________________________________________________________
369Int_t
370AliMUONSt345SlatSegmentationV2::Iy()
371{
372 if ( fPadIterator )
373 {
374 return fPadIterator->CurrentItem().GetIndices().GetSecond() + fgIntOffset;
375 }
376 else
377 {
378 return -1;
379 }
380}
381
382//_____________________________________________________________________________
383Int_t
384AliMUONSt345SlatSegmentationV2::MorePads()
385{
386 return (fPadIterator && !fPadIterator->IsDone());
387}
388
389//_____________________________________________________________________________
390void
391AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
392 Int_t Xlist[10], Int_t Ylist[10])
393{
394 // Find pad at (ix,iy) for which we'll search neighbours.
395 AliMpPad pad =
396 fSlatSegmentation->PadByIndices(AliMpIntPair(iX-fgIntOffset,iY-fgIntOffset),kTRUE);
397
398 // Define the region to look into : a region slightly bigger
399 // than the pad itself (10% bigger), in order to catch first neighbours.
400 AliMpArea area(pad.Position()+fSlat->Dimensions(),pad.Dimensions()*2.1);
401
402 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
403 it->First();
404 Int_t n = 0;
405 while ( !it->IsDone() && n < 10 )
406 {
407 AliMpPad p = it->CurrentItem();
408 if ( p != pad ) // skip self
409 {
410 Xlist[n] = p.GetIndices().GetFirst() + fgIntOffset;
411 Ylist[n] = p.GetIndices().GetSecond() + fgIntOffset;
412 ++n;
413 }
414 it->Next();
415 }
416 delete it;
417 *Nlist = n;
418}
419
420//_____________________________________________________________________________
421void
422AliMUONSt345SlatSegmentationV2::NextPad()
423{
424 if ( fPadIterator )
425 {
426 fPadIterator->Next();
427 fCurrentPad = fPadIterator->CurrentItem();
428 }
429 else
430 {
431 AliError("PadIterator not initialized. Please use First() first ;-)");
432 }
433}
434
435//_____________________________________________________________________________
436Int_t
437AliMUONSt345SlatSegmentationV2::Npx() const
438{
439 return fSlatSegmentation->MaxPadIndexX()+1;
440}
441
442//_____________________________________________________________________________
443Int_t
444AliMUONSt345SlatSegmentationV2::Npy() const
445{
446 return fSlatSegmentation->MaxPadIndexY()+1;
447}
448
449//_____________________________________________________________________________
450void
451AliMUONSt345SlatSegmentationV2::Print(Option_t*) const
452{
453 cout << "DetElemId=" << fDetElemId << " PlaneType="
454 << fPlaneType << " fSlat=" << fSlat
455 << " fSlatSegmentation=" << fSlatSegmentation
456 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
457}
458
459//_____________________________________________________________________________
460void
461AliMUONSt345SlatSegmentationV2::ReadMappingData()
462{
463 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>(AliMUONSegmentationManager::Segmentation(fDetElemId,fPlaneType));
464 if (!fSlatSegmentation)
465 {
466 AliFatal("Wrong segmentation type encountered");
467 }
468 fSlat = fSlatSegmentation->Slat();
469}
470
471//_____________________________________________________________________________
472Int_t
473AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t iy)
474{
475 return fSlat->FindPCBIndex(ix,iy);
476}
477
478//_____________________________________________________________________________
479Int_t
480AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
481{
482 return fSlat->FindPCBIndex(x,y);
483}
484
485//_____________________________________________________________________________
486void
487AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t,TF1*)
488{
489 AliFatal("Not Implemented");
490}
491
492//_____________________________________________________________________________
493void
494AliMUONSt345SlatSegmentationV2::SetDAnod(float)
495{
496 AliFatal("Not Implemented");
497}
498
499//_____________________________________________________________________________
500void
501AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
502{
503 fXhit = x;
504 fYhit = y;
505
506 //
507 // insure we're within the slat limits. If not, issue an error and sets
508 // the current hit to slat center.
509 // FIXME: this should probably a) not happen at all b) be a fatal error
510 //
511 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
512 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
513 {
514 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
515 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
516 fXhit = 0.0;
517 fYhit = 0.0;
518 }
519
520}
521
522//_____________________________________________________________________________
523void
524AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
525{
526 fCurrentPad =
527 fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),kTRUE);
528 if ( !fCurrentPad.IsValid() )
529 {
530 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
531 }
532}
533
534//_____________________________________________________________________________
535void
536AliMUONSt345SlatSegmentationV2::SetPadSize(float,float)
537{
538 AliFatal("Not Implemented");
539}
540
541//_____________________________________________________________________________
542Int_t
543AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
544{
545 AliFatal("Not Implemented");
546 return 0;
547}
548
549//_____________________________________________________________________________
550void
551AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
552{
553 AliFatal("Not Implemented");
554}
555
556//_____________________________________________________________________________
557void
558AliMUONSt345SlatSegmentationV2::Streamer(TBuffer &R__b)
559{
560 if (R__b.IsReading())
561 {
562 AliMUONSt345SlatSegmentationV2::Class()->ReadBuffer(R__b, this);
563 ReadMappingData();
564 }
565 else
566 {
567 AliMUONSt345SlatSegmentationV2::Class()->WriteBuffer(R__b, this);
568 }
569}
570