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 **************************************************************************/
17 // Class AliMUONGeometrySegmentation
18 // -------------------------------
19 // New class for the module segmentation
20 // composed of the segmentations of detection elements.
21 // Applies transformations defined in geometry.
23 // Author:Ivana Hrivnacova, IPN Orsay
27 #include <Riostream.h>
28 #include <TObjString.h>
33 #include "AliMUONGeometrySegmentation.h"
34 #include "AliMUONVGeometryDESegmentation.h"
35 #include "AliMUONGeometryModuleTransformer.h"
36 #include "AliMUONGeometryDetElement.h"
37 #include "AliMUONGeometryStore.h"
39 ClassImp(AliMUONGeometrySegmentation)
41 const Float_t AliMUONGeometrySegmentation::fgkMaxDistance = 1.0e11;
43 //______________________________________________________________________________
44 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
45 const AliMUONGeometryModuleTransformer* transformer)
48 fCurrentDetElement(0),
49 fCurrentSegmentation(0),
50 fkModuleTransformer(transformer),
55 /// Standard constructor
57 fDESegmentations = new AliMUONGeometryStore(false);
59 fDENames = new AliMUONGeometryStore(true);
61 AliDebug(1, Form("ctor this = %p", this) );
64 //______________________________________________________________________________
65 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation()
68 fCurrentDetElement(0),
69 fCurrentSegmentation(0),
70 fkModuleTransformer(0),
75 /// Default Constructor
77 AliDebug(1, Form("default (empty) ctor this = %p", this));
80 //______________________________________________________________________________
81 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
82 const AliMUONGeometrySegmentation& rhs)
85 /// Protected copy constructor
87 AliFatal("Copy constructor is not implemented.");
90 #include <Riostream.h>
91 //______________________________________________________________________________
92 AliMUONGeometrySegmentation::~AliMUONGeometrySegmentation()
96 AliDebug(1, Form("dtor this = %p", this));
98 delete fDESegmentations;
106 //______________________________________________________________________________
107 AliMUONGeometrySegmentation&
108 AliMUONGeometrySegmentation::operator=(const AliMUONGeometrySegmentation& rhs)
110 /// Protected assignment operator
112 // check assignement to self
113 if (this == &rhs) return *this;
115 AliFatal("Assignment operator is not implemented.");
124 //______________________________________________________________________________
125 Bool_t AliMUONGeometrySegmentation::OwnNotify(Int_t detElemId) const
127 /// Update current detection element and segmentation,
128 /// and checks if they exist.
129 /// Return true if success.
131 if (detElemId != fCurrentDetElemId) {
133 // Find detection element and its segmentation
134 AliMUONGeometryDetElement* detElement
135 = fkModuleTransformer->GetDetElement(detElemId);
137 AliError(Form("Detection element %d not defined", detElemId));
141 AliMUONVGeometryDESegmentation* segmentation
142 = (AliMUONVGeometryDESegmentation*) fDESegmentations->Get(detElemId);
144 AliError(Form("Segmentation for detection element %d not defined",
149 fCurrentDetElemId = detElemId;
150 fCurrentDetElement = detElement;
151 fCurrentSegmentation = segmentation;
161 //______________________________________________________________________________
162 void AliMUONGeometrySegmentation::Add(Int_t detElemId, const TString& detElemName,
163 AliMUONVGeometryDESegmentation* segmentation)
165 /// Add detection element segmentation
167 fDESegmentations->Add(detElemId, segmentation);
168 fDENames->Add(detElemId, new TObjString(detElemName));
172 //______________________________________________________________________________
173 const AliMUONVGeometryDESegmentation*
174 AliMUONGeometrySegmentation::GetDESegmentation(Int_t detElemId) const
176 /// Return the DE segmentation
178 if (!OwnNotify(detElemId)) return 0;
180 return fCurrentSegmentation;
183 //______________________________________________________________________________
184 AliMUONGeometryDirection
185 AliMUONGeometrySegmentation::GetDirection(Int_t detElemId) const
187 /// Return direction with a constant pad size
188 /// (Direction or coordinate where the resolution is the best)
190 if (!OwnNotify(detElemId)) return kDirUndefined;
192 return fCurrentSegmentation->GetDirection();
195 //______________________________________________________________________________
196 TString AliMUONGeometrySegmentation::GetDEName(Int_t detElemId) const
198 /// Return name of the given detection element
200 TObjString* deName = (TObjString*)fDENames->Get(detElemId, false);
203 return deName->GetString();
206 << "Detection element " << detElemId << " not defined. " << endl;
211 //______________________________________________________________________________
212 void AliMUONGeometrySegmentation::Print(Option_t* opt) const
214 // Print DE segmentations
216 std::cout << "fDESegmentations (class "
217 << fDESegmentations->Class()->GetName() << ") entries="
218 << fDESegmentations->GetNofEntries()
220 fDESegmentations->Print(opt);
223 //______________________________________________________________________________
224 void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
226 /// Set pad size Dx*Dy to all detection element segmentations
228 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
229 AliMUONVGeometryDESegmentation* segmentation
230 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
231 segmentation->SetPadSize(p1, p2);
235 //______________________________________________________________________________
236 void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
238 /// Set anod pitch to all detection element segmentations
240 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
241 AliMUONVGeometryDESegmentation* segmentation
242 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
243 segmentation->SetDAnod(d);
247 //______________________________________________________________________________
248 Float_t AliMUONGeometrySegmentation::GetAnod(Int_t detElemId, Float_t xhit) const
250 /// Anod wire coordinate closest to xhit
251 /// Returns for a hit position xhit the position of the nearest anode wire
252 /// !!! xhit is understand a a distance, not as a position in the space
255 if (!OwnNotify(detElemId)) return 0;
257 return fCurrentSegmentation->GetAnod(xhit);
260 //______________________________________________________________________________
261 Bool_t AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
262 Float_t xg, Float_t yg, Float_t zg,
263 Int_t& ix, Int_t& iy)
265 /// Return pad coordinates (ix,iy) for given real coordinates (x,y)
267 if (!OwnNotify(detElemId)) return false;
270 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
272 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) return false;
274 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
278 //______________________________________________________________________________
280 AliMUONGeometrySegmentation::HasPad(Int_t detElemId, Int_t ix, Int_t iy)
282 // Tells if a given pad exists in a given detector element
284 if (!OwnNotify(detElemId)) return false;
286 return fCurrentSegmentation->HasPad(ix,iy);
289 //______________________________________________________________________________
291 AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
293 Float_t& xg, Float_t& yg, Float_t& zg)
295 /// Transform from pad to real coordinates
297 if (!OwnNotify(detElemId)) return false;
299 if (!fCurrentSegmentation->HasPad(ix, iy)) {
300 xg = yg = zg = fgkMaxDistance;
305 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
307 fkModuleTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
311 //______________________________________________________________________________
312 void AliMUONGeometrySegmentation::Init(Int_t chamber)
314 /// Initialize segmentation.
315 /// Check that all detection elements have segmanetation set
317 // Loop over detection elements
318 AliMUONGeometryStore* detElements = fkModuleTransformer->GetDetElementStore();
320 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
322 // Get detction element Id
323 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
325 // Check segmentation
326 if (! fDESegmentations->Get(detElemId) ) {
327 AliError(Form("Detection element %d has not a segmentation set.",
328 detElements->GetEntry(i)->GetUniqueID()));
331 // Initialize DE Segmentation
332 ((AliSegmentation*)fDESegmentations->Get(detElemId))->Init(chamber);
337 //______________________________________________________________________________
338 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
340 /// Get pad size in x
342 if (!OwnNotify(detElemId)) return 0.;
344 return fCurrentSegmentation->Dpx();
347 //______________________________________________________________________________
348 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
350 /// Get pad size in y
352 if (!OwnNotify(detElemId)) return 0.;
354 return fCurrentSegmentation->Dpy();
357 //______________________________________________________________________________
358 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
360 /// Pad size in x by sector
362 if (!OwnNotify(detElemId)) return 0.;
364 return fCurrentSegmentation->Dpx(isector);
367 //______________________________________________________________________________
368 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
370 /// Pad size in x, y by Sector
372 if (!OwnNotify(detElemId)) return 0.;
374 return fCurrentSegmentation->Dpy(isector);
377 //______________________________________________________________________________
378 Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
380 /// Maximum number of Pads in x
382 if (!OwnNotify(detElemId)) return 0;
384 return fCurrentSegmentation->Npx();
387 //______________________________________________________________________________
388 Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
390 /// Maximum number of Pads in y
392 if (!OwnNotify(detElemId)) return 0;
394 return fCurrentSegmentation->Npy();
397 //______________________________________________________________________________
398 void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
400 /// Set pad position.
401 /// Sets virtual pad coordinates, needed for evaluating pad response
402 /// outside the tracking program.
403 /// From AliMUONGeometrySegmentationV01.
405 if (!OwnNotify(detElemId)) return;
407 fCurrentSegmentation->SetPad(ix, iy);
410 //______________________________________________________________________________
411 void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
412 Float_t xghit, Float_t yghit, Float_t zghit)
415 /// Sets virtual hit position, needed for evaluating pad response
416 /// outside the tracking program
417 /// From AliMUONGeometrySegmentationV01.
419 if (!OwnNotify(detElemId)) return;
422 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
424 fCurrentSegmentation->SetHit(xl, yl, zl);
427 //______________________________________________________________________________
428 void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
429 Float_t xghit, Float_t yghit, Float_t zghit,
430 Float_t dx, Float_t dy)
432 /// Iterate over pads - initialiser
434 if (!OwnNotify(detElemId)) return;
436 AliDebug(1,Form("xghit, yghit, zghit, dx, dy = %e,%e,%e,%e, %e",
437 xghit, yghit, zghit, dx, dy));
440 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
442 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
445 //______________________________________________________________________________
446 void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
448 /// Iterate over pads - stepper
450 if (!OwnNotify(detElemId)) return;
452 fCurrentSegmentation->NextPad();
455 //______________________________________________________________________________
456 Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
458 /// Iterate over pads - condition
460 if (!OwnNotify(detElemId)) return 0;
462 return fCurrentSegmentation->MorePads();
465 //______________________________________________________________________________
466 Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
468 Float_t xg, Float_t yg, Float_t zg,
471 /// Return the square of the distance between 1 pad
472 /// labelled by its channel numbers and a coordinate
474 if (!OwnNotify(detElemId)) return 0.;
477 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
479 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
482 //______________________________________________________________________________
483 void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
485 Int_t* nparallel, Int_t* offset)
487 /// Number of pads read in parallel and offset to add to x
488 /// (specific to LYON, but mandatory for display)
491 if (!OwnNotify(detElemId)) return;
493 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
497 //______________________________________________________________________________
498 void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
501 Int_t xlist[10], Int_t ylist[10])
503 /// Get next neighbours
505 if (!OwnNotify(detElemId)) return;
507 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
510 //______________________________________________________________________________
511 Int_t AliMUONGeometrySegmentation::Ix()
513 /// Current pad cursor during disintegration
516 return fCurrentSegmentation->Ix();
519 //______________________________________________________________________________
520 Int_t AliMUONGeometrySegmentation::Iy()
522 /// Current pad cursor during disintegration
525 return fCurrentSegmentation->Iy();
528 //______________________________________________________________________________
529 Int_t AliMUONGeometrySegmentation::DetElemId()
531 /// Current pad cursor during disintegration
534 return fCurrentDetElemId;
537 //______________________________________________________________________________
538 Int_t AliMUONGeometrySegmentation::ISector()
542 return fCurrentSegmentation->ISector();
545 //______________________________________________________________________________
546 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
548 /// Calculate sector from pad coordinates
550 if (!OwnNotify(detElemId)) return 0;
552 return fCurrentSegmentation->Sector(ix, iy);
555 //______________________________________________________________________________
556 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
557 Float_t xg, Float_t yg, Float_t zg)
559 /// Calculate sector from pad coordinates
561 if (!OwnNotify(detElemId)) return 0;
564 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
566 return fCurrentSegmentation->Sector(xl, yl);
569 //______________________________________________________________________________
570 void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
571 Float_t& x1, Float_t& x2,
572 Float_t& y1, Float_t& y2)
574 /// Current integration limits
576 if (!OwnNotify(detElemId)) return;
578 fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
581 //______________________________________________________________________________
582 Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
583 Float_t xg, Float_t yg, Float_t zg)
585 /// Signal Generation Condition during Stepping
586 /// 0: don't generate signal \n
587 /// 1: generate signal \n
590 /// Crossing of pad boundary and mid plane between neighbouring wires is checked.
591 /// To correctly simulate the dependence of the spatial resolution on the angle
592 /// of incidence signal must be generated for constant steps on
593 /// the projection of the trajectory along the anode wire.
595 /// Signal will be generated if particle crosses pad boundary or
596 /// boundary between two wires.
598 if (!OwnNotify(detElemId)) return 0;
601 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
603 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
606 //______________________________________________________________________________
607 void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
608 Float_t xg, Float_t yg, Float_t zg)
610 /// Initialise signal generation at coord (x,y,z)
611 /// Initialise pad and wire position during stepping.
612 /// From AliMUONGeometrySegmentationV01
614 if (!OwnNotify(detElemId)) return;
617 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
619 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) {
621 << "No pad at " << detElemId
622 << " global position: " << xg << " " << yg << " " << zg
623 << " local position: " << xl << " " << yl << " " << zl << endl;
627 fCurrentSegmentation->SigGenInit(xl, yl, zl);
630 //______________________________________________________________________________
631 void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
633 Float_t* /*xg*/, Float_t* /*yg*/) const
635 /// Test points for auto calibration
636 /// Return test point on the pad plane.
637 /// Used during determination of the segmoid correction of the COG-method
638 /// From AliMUONGeometrySegmentationV01
640 // Requires change of interface
641 // to convert points from local to global we need z coordinate
642 AliError("Not implemented.");
645 //______________________________________________________________________________
646 void AliMUONGeometrySegmentation::Draw(const char* opt)
648 /// Draw the segmentation zones for all detElemId
650 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
651 AliMUONVGeometryDESegmentation* segmentation
652 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
653 segmentation->Draw(opt);
657 //______________________________________________________________________________
658 void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt)
660 /// Draw the segmentation zones for a given detElemId.
662 if (!OwnNotify(detElemId)) return;
664 fCurrentSegmentation->Draw(opt);
667 //______________________________________________________________________________
668 void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
669 Int_t isec, TF1* func)
671 /// Set the correction function.
672 /// From AliMUONGeometrySegmentationV01
674 if (!OwnNotify(detElemId)) return;
676 fCurrentSegmentation->SetCorrFunc(isec, func);
679 //______________________________________________________________________________
680 TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
682 /// Get the correction Function.
683 /// From AliMUONGeometrySegmentationV01
685 if (!OwnNotify(detElemId)) return 0;
687 return fCurrentSegmentation->CorrFunc(isec);