AliRoot Core  edcc906 (edcc906)
AliMUONManuContourMaker.cxx
Go to the documentation of this file.
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 
29 
31 
32 #include "AliCodeTimer.h"
33 #include "AliLog.h"
34 #include "AliMUONContour.h"
35 #include "AliMUONContourMaker.h"
36 #include "AliMUONPolygon.h"
37 #include "AliMpCathodType.h"
38 #include "AliMpConnection.h"
39 #include "AliMpConstants.h"
40 #include "AliMpDDLStore.h"
41 #include "AliMpDEManager.h"
42 #include "AliMpIntPair.h"
43 #include "AliMpMotifPosition.h"
44 #include "AliMpMotifType.h"
45 #include "AliMpManuIterator.h"
46 #include "AliMpPlaneType.h"
47 #include "AliMpSegmentation.h"
48 #include "AliMpUID.h"
49 #include "AliMpVMotif.h"
50 #include "AliMpVSegmentation.h"
51 #include "TGeoMatrix.h"
52 #include "TObjArray.h"
53 #include "TObjString.h"
54 #include "TString.h"
55 #include "TVector2.h"
56 
60 
61 //_____________________________________________________________________________
63 : TObject(), fDETransformations(deTransformations), fLocalManuContours(222,1)
64 {
66 
67  fLocalManuContours.SetOwnerKeyValue(kTRUE,kTRUE);
68 }
69 
70 //_____________________________________________________________________________
72 {
74 }
75 
76 //_____________________________________________________________________________
78 AliMUONManuContourMaker::CreateManuContour(Int_t detElemId, Int_t manuId, const char* name) const
79 {
81 
82  AliCodeTimerAuto("",0);
83 
84  TString sname(name);
85 
86  if ( sname.Length()==0 )
87  {
88  sname = ManuPathName(detElemId,manuId);
89  }
90 
92  const AliMpMotifPosition* motifPos = seg->MotifPosition(manuId);
93 
94  AliMUONContour* contour = CreateMotifContour(*motifPos);
95 
96  if (!contour)
97  {
98  AliError(Form("Could not build contour %s",sname.Data()));
99  return 0x0;
100  }
101 
102  contour->SetName(sname.Data());
103 
104  contour->Offset(motifPos->GetPositionX()-seg->GetPositionX(),
105  motifPos->GetPositionY()-seg->GetPositionY());
106 
107  TGeoHMatrix* matrix = 0x0;
108 
109  if ( fDETransformations )
110  {
111  matrix = static_cast<TGeoHMatrix*>(fDETransformations->GetValue(detElemId));
112  if ( matrix ) contour->Transform(*matrix);
113  }
114 
115  return contour;
116 }
117 
118 
119 //_____________________________________________________________________________
122 {
124 
125  AliCodeTimerAuto("",0);
126 
127  TString mpName(NameIt(motifPosition));
128 
129  AliMUONContour* contour = static_cast<AliMUONContour*>(fLocalManuContours.GetValue(mpName.Data()));
130 
131  if ( contour )
132  {
133  // if we have already done the job, just have to clone it and we are done
134  return static_cast<AliMUONContour*>(contour->Clone());
135  }
136 
137  TObjArray polygons(AliMpConstants::ManuNofChannels()); // array of AliMUONPolygon objects
138  polygons.SetOwner(kTRUE);
139 
140  AliMpVMotif* motif = motifPosition.GetMotif();
141 
142  AliMpMotifType* motifType = motif->GetMotifType();
143 
144  if ( motifType->IsFull() )
145  {
146  // motif is a simple rectangle. No need to loop over pads, we can
147  // compute the contour right here and now.
148  polygons.Add(new AliMUONPolygon(0.0,0.0,motif->DimensionX(),motif->DimensionY()));
149  }
150  else
151  {
152  for ( Int_t i = 0; i <= AliMpConstants::ManuNofChannels(); ++i )
153  {
154  AliMpConnection* connection = motifType->FindConnectionByGassiNum(i);
155 
156  if ( connection )
157  {
158  Int_t ix = connection->GetLocalIx();
159  Int_t iy = connection->GetLocalIy();
160 
161  Double_t x,y,dx,dy;
162 
163  motif->GetPadDimensionsByIndices(ix,iy,dx,dy);
164  motif->PadPositionLocal(ix,iy,x,y);
165 
166  AliMUONPolygon* pol = new AliMUONPolygon(x,y,dx,dy);
167  polygons.Add(pol);
168  }
169  }
170  }
171 
172  AliMUONContourMaker maker;
173 
174  contour = maker.CreateContour(polygons);
175 
176  if (!contour || !contour->IsValid() )
177  {
178  AliError(Form("Failed to properly create contour %s contour = %p",mpName.Data(),contour));
179  if ( contour )
180  {
181  AliError(Form("nofVertices=%d area.isvalid=%d",contour->NumberOfVertices(),contour->Area().IsValid()));
182  StdoutToAliError(contour->Area().Print(););
183  }
184  delete contour;
185  return 0x0;
186  }
187 
188  {
189  AliCodeTimerAuto("localmanucontour.add",1);
190  fLocalManuContours.Add(new TObjString(mpName),contour);
191  }
192 
193  return static_cast<AliMUONContour*>(contour->Clone());
194 }
195 
196 //_____________________________________________________________________________
197 TObjArray*
199 {
203 
204  AliCodeTimerAuto("",0);
205 
206  TObjArray* manuContours = new TObjArray;
207 
208  manuContours->SetOwner(kTRUE);
209 
211  Int_t detElemId, manuId;
212  Int_t nmanus(0);
213  Int_t nok(0);
214 
215  while ( it.Next(detElemId,manuId) )
216  {
217  ++nmanus;
218  AliMUONContour* contour = CreateManuContour(detElemId,manuId);
219  if (contour)
220  {
221  manuContours->Add(contour);
222  }
223  else
224  {
225  if ( stopAtError )
226  {
227  break;
228  }
229  }
230  ++nok;
231  }
232 
233  return manuContours;
234 }
235 
236 //_____________________________________________________________________________
237 TString
239 {
241 
242  AliMpVMotif* motif = motifPosition.GetMotif();
243  TString name(Form("%s",motif->GetID().Data()));
244 
245  for ( Int_t i = 0; i < motif->GetNofPadDimensions(); ++i )
246  {
247  name += Form("/%7.3f-%7.3f:",motif->GetPadDimensionX(i),motif->GetPadDimensionY(i));
248  }
249 
250  return name;
251 }
252 
253 //_____________________________________________________________________________
254 TString
255 AliMUONManuContourMaker::ManuPathName(Int_t detElemId, Int_t manuId, Bool_t withCathodeName)
256 {
258 
259  AliMp::PlaneType planeType;
261  {
262  planeType = AliMp::kNonBendingPlane;
263  }
264  else
265  {
266  planeType = AliMp::kBendingPlane;
267  }
268  AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,planeType);
269 
270  Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
271  Int_t stationId = chamberId/2;
272 
273  Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId, manuId);
274 
275  AliMpUID id(cathodeType,stationId,chamberId,detElemId,busPatchId,manuId);
276 
277  if ( withCathodeName ) return id.PathName();
278 
279  TString name(id.PathName());
280 
281  name.ReplaceAll("Cathode0/","");
282  name.ReplaceAll("Cathode1/","");
283 
284  return name;
285 }
286 
287 
288 
289 
Double_t GetPositionY() const
Return y position.
AliMpArea Area() const
virtual Double_t GetPadDimensionY(Int_t i) const =0
Return the i-th pad y dimension.
static AliMpSegmentation * Instance(Bool_t warn=true)
A connection properties.
#define TObjArray
static AliMp::CathodType GetCathod(Int_t detElemId, AliMp::PlaneType planeType)
Global (string-eable) ID of a tracker channel.
Definition: AliMpUID.h:25
virtual Double_t DimensionY() const =0
Return y dimensions.
A planar polygon.
AliMpConnection * FindConnectionByGassiNum(Int_t gassiNum) const
Int_t GetLocalIx() const
virtual AliMpMotifPosition * MotifPosition(Int_t manuId) const =0
Return the position of a given manu (aka motifPosition)
const AliMpVSegmentation * GetMpSegmentationByElectronics(Int_t detElemId, Int_t elCardID, Bool_t warn=true) const
Int_t NumberOfVertices() const
Get the number of vertices of this contour.
virtual TObject * Clone(const char *="") const
Get a full copy of this object.
AliMpMotifType * GetMotifType() const
Return the motif type.
Definition: AliMpVMotif.h:87
Bool_t Next(Int_t &detElemId, Int_t &manuId)
Class to loop over all manus of MUON Tracker.
void Offset(Double_t x, Double_t y)
Add an offset to all points.
AliMUONContour * CreateMotifContour(const AliMpMotifPosition &motifPosition) const
static AliMpDDLStore * Instance(Bool_t warn=true)
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
static Int_t ManuNofChannels()
Max number of channels per manu.
virtual Double_t GetPositionY() const =0
Return the y position of the origin of the detection element.
Int_t GetBusPatchId(Int_t detElemId, Int_t manuId) const
TString GetID() const
Return the motif identifier.
Definition: AliMpVMotif.h:90
TString NameIt(const AliMpMotifPosition &motifPosition) const
A placed motif.
void Print(Option_t *opt="") const
Definition: AliMpArea.cxx:252
non-bending plane
#define AliCodeTimerAuto(message, counter)
Definition: AliCodeTimer.h:137
Maker of AliMUONContour objects for all the tracker manus.
TMap fLocalManuContours
map of local manu contours
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
AliMpVMotif * GetMotif() const
Return motif.
Int_t GetLocalIy() const
static TString ManuPathName(Int_t detElemId, Int_t manu, Bool_t withCathodeName=kTRUE)
virtual Double_t DimensionX() const =0
Return x dimensions.
#define StdoutToAliError(whatever)
Definition: AliLog.h:619
TObjArray * GenerateManuContours(Bool_t stopAtError=kFALSE)
virtual void PadPositionLocal(MpPair_t localIndices, Double_t &posx, Double_t &posy) const =0
Fill local position of the pad specified by local indices.
Creator/merger of AliMUONContour objects.
bending plane
Abstract base class for a motif with its unique ID and the motif type.
Definition: AliMpVMotif.h:24
The abstract base class for the segmentation.
2D contour
Bool_t IsValid() const
Return validity.
Definition: AliMpArea.h:83
AliMUONContour * CreateContour(const TObjArray &polygons, const char *name=0x0) const
virtual Int_t GetNofPadDimensions() const =0
Return the number of pad dimensions.
virtual Double_t GetPadDimensionX(Int_t i) const =0
Return the i-th pad x dimension.
Double_t GetPositionX() const
Return x position.
#define AliError(message)
Definition: AliLog.h:591
Bool_t IsFull() const
Return true if the motif conatins all pads.
virtual Double_t GetPositionX() const =0
Return the x position of the origin of the detection element.
void Transform(const TGeoHMatrix &matrix)
Apply a global transformation to all points.
Helper class making Root persistent TExMap.
Definition: AliMpExMap.h:28
static Int_t ManuMask(AliMp::PlaneType planeType)
Class that defines the motif properties.
AliMUONContour * CreateManuContour(Int_t detElemId, Int_t manuId, const char *name="") const
Bool_t IsValid() const
virtual void GetPadDimensionsByIndices(MpPair_t localIndices, Double_t &dx, Double_t &dy) const =0
Return the dimensions of the pad specified by localIndices.
AliMpExMap * fDETransformations
map<int,TGeoHMatrix> of detElemId to matrix