Line data Source code
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 "AliMUONDEPainter.h"
19 :
20 : #include "AliMUONBusPatchPainter.h"
21 : #include "AliMUONGeometryTransformer.h"
22 : #include "AliMUONPCBPainter.h"
23 : #include "AliMUONContour.h"
24 : #include "AliMUONPainterHelper.h"
25 : #include "AliMUONVCalibParam.h"
26 : #include "AliMUONVTrackerData.h"
27 : #include "AliMUONObjectPair.h"
28 : #include "AliMpDDLStore.h"
29 : #include "AliMpDEManager.h"
30 : #include "AliMpDetElement.h"
31 : #include "AliMpPCB.h"
32 : #include "AliMpSector.h"
33 : #include "AliMpSlat.h"
34 : #include "AliLog.h"
35 : #include <TMap.h>
36 : #include <TObjString.h>
37 : #include "AliMUONPainterGroup.h"
38 :
39 : /// \class AliMUONDEPainter
40 : ///
41 : /// Painter for one detection element
42 : ///
43 : /// It draws a given plane (bending or non bending) of a given detection element
44 : ///
45 : /// \author Laurent Aphecetche, Subatech
46 :
47 : ///\cond CLASSIMP
48 12 : ClassImp(AliMUONDEPainter)
49 : ///\endcond
50 :
51 : //_____________________________________________________________________________
52 : AliMUONDEPainter::AliMUONDEPainter()
53 0 : : AliMUONVPainter(),
54 0 : fDetElemId(-1)
55 0 : {
56 : /// default ctor
57 0 : }
58 :
59 : //_____________________________________________________________________________
60 : AliMUONDEPainter::AliMUONDEPainter(TRootIOCtor* ioCtor)
61 0 : : AliMUONVPainter(ioCtor),
62 0 : fDetElemId(-1)
63 0 : {
64 : /// default streaming ctor
65 0 : }
66 :
67 : //_____________________________________________________________________________
68 : AliMUONDEPainter::AliMUONDEPainter(const AliMUONAttPainter& att, Int_t detElemId)
69 0 : : AliMUONVPainter("DE"),
70 0 : fDetElemId(detElemId)
71 0 : {
72 : /// normal ctor
73 :
74 0 : AliMUONAttPainter deAtt(att);
75 :
76 0 : if ( att.IsCathodeDefined() )
77 : {
78 0 : AliMp::CathodType cathodType = ( att.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ;
79 :
80 0 : Bool_t cath0 = ( cathodType == AliMp::kCath0 ) ;
81 :
82 0 : AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodType);
83 :
84 0 : Bool_t bending = ( planeType == AliMp::kBendingPlane );
85 :
86 0 : deAtt.SetCathode(cath0,!cath0);
87 0 : deAtt.SetPlane(bending,!bending);
88 :
89 0 : }
90 :
91 0 : if ( att.IsPlaneDefined() )
92 : {
93 0 : AliMp::PlaneType planeType = ( att.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
94 :
95 0 : Bool_t bending = ( planeType == AliMp::kBendingPlane );
96 :
97 0 : Bool_t cath0 = ( AliMpDEManager::GetCathod(detElemId,planeType) == AliMp::kCath0 );
98 :
99 0 : deAtt.SetCathode(cath0,!cath0);
100 0 : deAtt.SetPlane(bending,!bending);
101 :
102 0 : }
103 :
104 0 : deAtt.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
105 :
106 0 : SetAttributes(deAtt);
107 :
108 0 : AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
109 :
110 0 : SetID(detElemId,-1);
111 0 : SetName(h->DEName(fDetElemId).Data());
112 0 : SetPathName(h->DEPathName(fDetElemId).Data());
113 :
114 0 : AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
115 :
116 0 : Double_t x,y,z;
117 :
118 0 : if ( AliMpDEManager::GetStationType(DetElemId()) == AliMp::kStation345 )
119 : {
120 0 : const AliMpSlat* slat = h->GetSlat(DetElemId(),planeType);
121 :
122 0 : for ( Int_t i = 0; i < slat->GetSize(); ++i )
123 : {
124 0 : Add(new AliMUONPCBPainter(Attributes(),DetElemId(),i));
125 : }
126 :
127 0 : AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,x,y,z);
128 0 : }
129 0 : else if ( AliMpDEManager::GetStationType(DetElemId()) != AliMp::kStationTrigger )
130 : {
131 0 : const AliMpSector* sector = h->GetSector(DetElemId(),planeType);
132 :
133 0 : Double_t xl(sector->GetDimensionX());
134 0 : Double_t yl(sector->GetDimensionY());
135 :
136 0 : h->Local2Global(fDetElemId,xl,yl,0.0,x,y,z);
137 0 : }
138 : else
139 : {
140 0 : AliFatal("Not implemented for trigger !!!");
141 : }
142 :
143 0 : AliMUONContour* contour = h->GetContour(ContourName());
144 :
145 0 : TObjArray contourArray;
146 :
147 0 : AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId);
148 :
149 0 : for ( Int_t i = 0; i < de->GetNofBusPatches(); ++i )
150 : {
151 0 : AliMUONBusPatchPainter* painter = new AliMUONBusPatchPainter(Attributes(),de->GetBusPatchId(i));
152 :
153 0 : if ( !painter->IsValid() )
154 : {
155 0 : delete painter;
156 0 : continue;
157 : }
158 : else
159 : {
160 0 : Add(painter);
161 : }
162 :
163 0 : if ( !contour )
164 : {
165 0 : contourArray.Add(painter->Contour());
166 : }
167 0 : }
168 :
169 0 : if (!contour)
170 : {
171 0 : contour = h->MergeContours(contourArray,ContourName());
172 0 : if (!contour)
173 : {
174 0 : AliError(Form("%s : could not merge those contours",Name().Data()));
175 0 : StdoutToAliError(contourArray.Print(););
176 0 : }
177 : }
178 :
179 0 : SetContour(contour);
180 0 : }
181 :
182 : //_____________________________________________________________________________
183 : AliMUONDEPainter::AliMUONDEPainter(const AliMUONDEPainter& rhs):
184 0 : AliMUONVPainter(rhs), fDetElemId(-1)
185 0 : {
186 : /// copy ctor
187 0 : rhs.Copy(*this);
188 0 : }
189 :
190 : //_____________________________________________________________________________
191 : AliMUONDEPainter&
192 : AliMUONDEPainter::operator=(const AliMUONDEPainter& rhs)
193 : {
194 : /// assignment operator
195 0 : if ( this != &rhs )
196 : {
197 0 : rhs.Copy(*this);
198 0 : }
199 0 : return *this;
200 : }
201 :
202 : //_____________________________________________________________________________
203 0 : AliMUONDEPainter::~AliMUONDEPainter()
204 0 : {
205 : /// dtor = nop
206 0 : }
207 :
208 : //_____________________________________________________________________________
209 : void
210 : AliMUONDEPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
211 : Double_t& dataMin, Double_t& dataMax) const
212 : {
213 : /// Compute the data range spanned by this detection element
214 0 : dataMin = dataMax = data.DetectionElement(fDetElemId, dataIndex);
215 0 : }
216 :
217 : //_____________________________________________________________________________
218 : void
219 : AliMUONDEPainter::Copy(TObject& object) const
220 : {
221 : /// Copy this to object
222 0 : AliMUONVPainter::Copy((AliMUONVPainter&)(object));
223 0 : ((AliMUONDEPainter&)(object)).fDetElemId = fDetElemId;
224 0 : }
225 :
226 : //_____________________________________________________________________________
227 : TString
228 : AliMUONDEPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
229 : Double_t, Double_t)
230 : {
231 : /// Describe data at this detection element
232 :
233 0 : if (!data.HasDetectionElement(fDetElemId)) return "";
234 :
235 0 : Double_t value = data.DetectionElement(fDetElemId,dataIndex);
236 :
237 0 : return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
238 0 : }
239 :
240 : //_____________________________________________________________________________
241 : void
242 : AliMUONDEPainter::FillManuList(TObjArray& manuList) const
243 : {
244 : /// Fill (append to) manu list
245 0 : TIter next(Children());
246 : AliMUONVPainter* p;
247 :
248 0 : while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
249 : {
250 0 : if ( p->IsA() == AliMUONBusPatchPainter::Class() )
251 : {
252 : // Only consider bus patch painters (and not PCB ones),
253 : // in order not to double count some manus
254 0 : p->FillManuList(manuList);
255 : }
256 : }
257 0 : }
258 :
259 : //_____________________________________________________________________________
260 : Bool_t
261 : AliMUONDEPainter::IsIncluded() const
262 : {
263 : /// whether this detection element is included in the readout or not
264 0 : return ( InteractiveReadOutConfig()->DetectionElement(fDetElemId) > 0 );
265 : }
266 :
267 : //_____________________________________________________________________________
268 : void
269 : AliMUONDEPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
270 : Double_t min, Double_t max)
271 : {
272 : /// Paint the area of this detection element
273 :
274 0 : if (!data.HasDetectionElement(fDetElemId)) return;
275 :
276 0 : Double_t value = data.DetectionElement(fDetElemId,dataIndex);
277 :
278 0 : if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
279 :
280 0 : Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
281 :
282 0 : PaintArea(color);
283 0 : }
284 :
285 : //_____________________________________________________________________________
286 : AliMUONAttPainter
287 : AliMUONDEPainter::Validate(const AliMUONAttPainter& attributes) const
288 : {
289 : /// Normalize attributes
290 :
291 0 : AliMUONAttPainter norm(attributes);
292 :
293 0 : norm.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
294 :
295 0 : if ( norm.IsCathodeDefined() && !norm.IsPlaneDefined() )
296 : {
297 : // only cathode known : derive the plane
298 :
299 0 : AliMp::CathodType cathodType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 );
300 :
301 0 : AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathodType);
302 :
303 0 : Bool_t bending = ( planeType == AliMp::kBendingPlane ) ;
304 :
305 0 : norm.SetPlane(bending,!bending);
306 0 : }
307 :
308 0 : else if ( !norm.IsCathodeDefined() && norm.IsPlaneDefined() )
309 : {
310 : // only plane is known : derive the cathode
311 :
312 0 : AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
313 :
314 0 : Bool_t cath0 = ( AliMpDEManager::GetCathod(fDetElemId,planeType) == AliMp::kCath0 );
315 :
316 0 : norm.SetCathode(cath0,!cath0);
317 0 : }
318 : else
319 : {
320 : // check that both information are compatible
321 :
322 0 : AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
323 :
324 0 : AliMp::CathodType cathode = AliMpDEManager::GetCathod(fDetElemId,planeType);
325 :
326 0 : if ( (cathode == AliMp::kCath0 && norm.IsCathode1()) ||
327 0 : (cathode == AliMp::kCath1 && norm.IsCathode0()) )
328 : {
329 0 : norm.SetValid(kFALSE);
330 : }
331 : }
332 :
333 : return norm;
334 0 : }
335 :
336 : //_____________________________________________________________________________
337 : void
338 : AliMUONDEPainter::SetResponder(Int_t depth)
339 : {
340 : /// Select as responder the *first* group that has a given depth
341 :
342 0 : if (!fPainterGroups)
343 : {
344 0 : CreateGroups();
345 0 : }
346 :
347 0 : TIter next(fPainterGroups);
348 : TObjString* str;
349 :
350 0 : fResponderGroup = 0x0;
351 :
352 0 : while ( ( str = static_cast<TObjString*>(next()) ) )
353 : {
354 0 : AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(str));
355 0 : if ( str->String() == "BUSPATCH" )
356 : {
357 0 : group->SetResponder(kTRUE);
358 0 : fResponderGroup = group;
359 0 : break;
360 : }
361 : else
362 : {
363 0 : group->SetResponder(kFALSE);
364 : }
365 0 : }
366 0 : }
367 :
|