]>
Commit | Line | Data |
---|---|---|
0b936dc0 | 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 | /// \class AliMUONManuContourMaker | |
19 | /// | |
20 | /// Maker of manu contours. | |
21 | /// | |
22 | /// Make use of the AliMUONContourMaker class, but this one contains | |
23 | /// specific things for MUON (as the mapping, for instance), hence its | |
24 | /// separation from AliMUONContourMaker. | |
25 | /// | |
26 | /// This class requires that the mapping is loaded before anything can be done. | |
27 | /// | |
28 | /// \author Laurent Aphecetche, Subatech | |
29 | ||
30 | #include "AliMUONManuContourMaker.h" | |
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 | ||
57 | ///\cond CLASSIMP | |
58 | ClassImp(AliMUONManuContourMaker) | |
59 | ///\endcond | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliMUONManuContourMaker::AliMUONManuContourMaker(AliMpExMap* deTransformations) | |
63 | : TObject(), fDETransformations(deTransformations), fLocalManuContours(222,1) | |
64 | { | |
cddcc1f3 | 65 | /// Standard constructor |
66 | ||
0b936dc0 | 67 | fLocalManuContours.SetOwnerKeyValue(kTRUE,kTRUE); |
68 | } | |
69 | ||
70 | //_____________________________________________________________________________ | |
71 | AliMUONManuContourMaker::~AliMUONManuContourMaker() | |
72 | { | |
cddcc1f3 | 73 | /// Destructor |
0b936dc0 | 74 | } |
75 | ||
76 | //_____________________________________________________________________________ | |
77 | AliMUONContour* | |
78 | AliMUONManuContourMaker::CreateManuContour(Int_t detElemId, Int_t manuId, const char* name) const | |
79 | { | |
80 | /// Create the contour of a given manu (global coordinates) | |
81 | ||
99c136e1 | 82 | AliCodeTimerAuto("",0); |
0b936dc0 | 83 | |
84 | TString sname(name); | |
85 | ||
86 | if ( sname.Length()==0 ) | |
87 | { | |
88 | sname = ManuPathName(detElemId,manuId); | |
89 | } | |
90 | ||
91 | const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); | |
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 | //_____________________________________________________________________________ | |
120 | AliMUONContour* | |
121 | AliMUONManuContourMaker::CreateMotifContour(const AliMpMotifPosition& motifPosition) const | |
122 | { | |
123 | /// Create the contour of a given MOTIF (i.e. local coordinates only). | |
124 | ||
99c136e1 | 125 | AliCodeTimerAuto("",0); |
0b936dc0 | 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 | { | |
dd0be8a7 | 189 | AliCodeTimerAuto("localmanucontour.add",1); |
0b936dc0 | 190 | fLocalManuContours.Add(new TObjString(mpName),contour); |
191 | } | |
192 | ||
193 | return static_cast<AliMUONContour*>(contour->Clone()); | |
194 | } | |
195 | ||
196 | //_____________________________________________________________________________ | |
197 | TObjArray* | |
198 | AliMUONManuContourMaker::GenerateManuContours(Bool_t stopAtError) | |
199 | { | |
200 | /// Generate the contours for all the manus, taking into account the given transformation | |
201 | /// (to go from local to global). That transformation need not be the real one (i.e. | |
202 | /// it can be an "exploded" one to ease visualization). | |
203 | ||
99c136e1 | 204 | AliCodeTimerAuto("",0); |
0b936dc0 | 205 | |
206 | TObjArray* manuContours = new TObjArray; | |
207 | ||
208 | manuContours->SetOwner(kTRUE); | |
209 | ||
210 | AliMpManuIterator it; | |
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 | ||
3305a01d | 233 | AliDebug(1,Form("%d manus. %d contours successfully created",nmanus,nok)); |
0b936dc0 | 234 | |
235 | return manuContours; | |
236 | } | |
237 | ||
238 | //_____________________________________________________________________________ | |
239 | TString | |
240 | AliMUONManuContourMaker::NameIt(const AliMpMotifPosition& motifPosition) const | |
241 | { | |
242 | /// Get the name of an AliMpMotifPosition | |
243 | ||
244 | AliMpVMotif* motif = motifPosition.GetMotif(); | |
245 | TString name(Form("%s",motif->GetID().Data())); | |
246 | ||
247 | for ( Int_t i = 0; i < motif->GetNofPadDimensions(); ++i ) | |
248 | { | |
249 | name += Form("/%7.3f-%7.3f:",motif->GetPadDimensionX(i),motif->GetPadDimensionY(i)); | |
250 | } | |
251 | ||
252 | return name; | |
253 | } | |
254 | ||
255 | //_____________________________________________________________________________ | |
256 | TString | |
257 | AliMUONManuContourMaker::ManuPathName(Int_t detElemId, Int_t manuId, Bool_t withCathodeName) | |
258 | { | |
259 | /// Get the name of a manu | |
260 | ||
261 | AliMp::PlaneType planeType; | |
262 | if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) | |
263 | { | |
264 | planeType = AliMp::kNonBendingPlane; | |
265 | } | |
266 | else | |
267 | { | |
268 | planeType = AliMp::kBendingPlane; | |
269 | } | |
270 | AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,planeType); | |
271 | ||
272 | Int_t chamberId = AliMpDEManager::GetChamberId(detElemId); | |
273 | Int_t stationId = chamberId/2; | |
274 | ||
275 | Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId, manuId); | |
276 | ||
277 | AliMpUID id(cathodeType,stationId,chamberId,detElemId,busPatchId,manuId); | |
278 | ||
279 | if ( withCathodeName ) return id.PathName(); | |
280 | ||
281 | TString name(id.PathName()); | |
282 | ||
283 | name.ReplaceAll("Cathode0/",""); | |
284 | name.ReplaceAll("Cathode1/",""); | |
285 | ||
286 | return name; | |
287 | } | |
288 | ||
289 | ||
290 | ||
291 |