]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDEPainter.cxx
effc++ warnings
[u/mrichter/AliRoot.git] / MUON / AliMUONDEPainter.cxx
CommitLineData
0145e89a 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 "AliMUONPainterContour.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 <TObjString.h>
36
37/// \class AliMUONDEPainter
38///
39/// Painter for one detection element
40///
41/// It draws a given plane (bending or non bending) of a given detection element
42///
43/// \author Laurent Aphecetche, Subatech
44
45///\cond CLASSIMP
46ClassImp(AliMUONDEPainter)
47///\endcond
48
49//_____________________________________________________________________________
50AliMUONDEPainter::AliMUONDEPainter()
51: AliMUONVPainter(),
52fDetElemId(-1)
53{
54 /// default ctor
55}
56
57//_____________________________________________________________________________
58AliMUONDEPainter::AliMUONDEPainter(const AliMUONAttPainter& att, Int_t detElemId)
59: AliMUONVPainter("DE"),
60fDetElemId(detElemId)
61{
62 /// normal ctor
63
64 AliMUONAttPainter deAtt(att);
65
66 if ( att.IsCathodeDefined() )
67 {
68 AliMp::CathodType cathodType = ( att.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ;
69
70 Bool_t cath0 = ( cathodType == AliMp::kCath0 ) ;
71
72 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodType);
73
74 Bool_t bending = ( planeType == AliMp::kBendingPlane );
75
76 deAtt.SetCathode(cath0,!cath0);
77 deAtt.SetPlane(bending,!bending);
78
79 }
80
81 if ( att.IsPlaneDefined() )
82 {
83 AliMp::PlaneType planeType = ( att.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
84
85 Bool_t bending = ( planeType == AliMp::kBendingPlane );
86
87 Bool_t cath0 = ( AliMpDEManager::GetCathod(detElemId,planeType) == AliMp::kCath0 );
88
89 deAtt.SetCathode(cath0,!cath0);
90 deAtt.SetPlane(bending,!bending);
91
92 }
93
94 deAtt.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
95
96 SetAttributes(deAtt);
97
98 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
99
100 SetID(detElemId,-1);
101 SetName(h->DEName(fDetElemId).Data());
102 SetPathName(h->DEPathName(fDetElemId).Data());
103
104 AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
105
106 Double_t x,y,z;
107
108 if ( AliMpDEManager::GetStationType(DetElemId()) == AliMp::kStation345 )
109 {
110 const AliMpSlat* slat = h->GetSlat(DetElemId(),planeType);
111
112 for ( Int_t i = 0; i < slat->GetSize(); ++i )
113 {
114 Add(new AliMUONPCBPainter(Attributes(),DetElemId(),i));
115 }
116
117 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,x,y,z);
118 }
119 else if ( AliMpDEManager::GetStationType(DetElemId()) != AliMp::kStationTrigger )
120 {
121 const AliMpSector* sector = h->GetSector(DetElemId(),planeType);
122
123 Double_t xl(sector->Dimensions().X());
124 Double_t yl(sector->Dimensions().Y());
125
126 h->Local2Global(fDetElemId,xl,yl,0.0,x,y,z);
127 }
128 else
129 {
130 AliFatal("Not implemented for trigger !!!");
131 }
132
133 AliMUONPainterContour* contour = h->GetContour(ContourName());
134
135 TObjArray contourArray;
136
137 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId);
138
139 AliDebug(1,Form("de %p n %d",de,de->GetNofBusPatches()));
140
141 for ( Int_t i = 0; i < de->GetNofBusPatches(); ++i )
142 {
143 AliMUONBusPatchPainter* painter = new AliMUONBusPatchPainter(Attributes(),de->GetBusPatchId(i));
144
145 if ( !painter->IsValid() )
146 {
147 AliDebug(1,Form("Skipping BP %d which seem to have no manu in plane %s",
148 de->GetBusPatchId(i),
149 Attributes().IsBendingPlane() ? "bending" : "non bending"));
150 delete painter;
151 continue;
152 }
153 else
154 {
155 Add(painter);
156 }
157
158 if ( !contour )
159 {
160 contourArray.Add(painter->Contour());
161 }
162 }
163
164 if (!contour)
165 {
166 contour = h->MergeContours(contourArray,ContourName());
167 if (!contour)
168 {
169 AliError(Form("%s : could not merge those contours",Name().Data()));
170 StdoutToAliError(contourArray.Print(););
171 }
172 }
173
174 SetContour(contour);
175}
176
177//_____________________________________________________________________________
178AliMUONDEPainter::AliMUONDEPainter(const AliMUONDEPainter& rhs):
179AliMUONVPainter(rhs), fDetElemId(-1)
180{
181 /// copy ctor
182 rhs.Copy(*this);
183}
184
185//_____________________________________________________________________________
186AliMUONDEPainter&
187AliMUONDEPainter::operator=(const AliMUONDEPainter& rhs)
188{
189 /// assignment operator
190 if ( this != &rhs )
191 {
192 rhs.Copy(*this);
193 }
194 return *this;
195}
196
197//_____________________________________________________________________________
198AliMUONDEPainter::~AliMUONDEPainter()
199{
200 /// dtor = nop
201}
202
203//_____________________________________________________________________________
204void
205AliMUONDEPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
206 Double_t& dataMin, Double_t& dataMax) const
207{
208 /// Compute the data range spanned by this detection element
209 dataMin = dataMax = data.DetectionElement(fDetElemId, dataIndex);
210}
211
212//_____________________________________________________________________________
213void
214AliMUONDEPainter::Copy(TObject& object) const
215{
216 /// Copy this to object
217 AliMUONVPainter::Copy((AliMUONVPainter&)(object));
218 ((AliMUONDEPainter&)(object)).fDetElemId = fDetElemId;
219}
220
221//_____________________________________________________________________________
222TString
223AliMUONDEPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
224 Double_t, Double_t)
225{
226 /// Describe data at this detection element
227
228 if (!data.HasDetectionElement(fDetElemId)) return "";
229
230 Double_t value = data.DetectionElement(fDetElemId,dataIndex);
231
232 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
233}
234
235//_____________________________________________________________________________
10eb3d17 236void
237AliMUONDEPainter::FillManuList(TObjArray& manuList) const
238{
239 /// Fill (append to) manu list
240 TIter next(Children());
241 AliMUONVPainter* p;
242
243 while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
244 {
245 if ( p->IsA() == AliMUONBusPatchPainter::Class() )
246 {
247 // Only consider bus patch painters (and not PCB ones),
248 // in order not to double count some manus
249 p->FillManuList(manuList);
250 }
251 }
252}
253
254//_____________________________________________________________________________
0145e89a 255void
256AliMUONDEPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
257 Double_t min, Double_t max)
258{
259 /// Paint the area of this detection element
260
261 if (!data.HasDetectionElement(fDetElemId)) return;
262
263 Double_t value = data.DetectionElement(fDetElemId,dataIndex);
264
265 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
266
267 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
268
269 Contour()->PaintArea(color);
270}
271
272//_____________________________________________________________________________
273AliMUONAttPainter
274AliMUONDEPainter::Validate(const AliMUONAttPainter& attributes) const
275{
276 /// Normalize attributes
277
278 AliMUONAttPainter norm(attributes);
279
280 norm.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
281
282 if ( norm.IsCathodeDefined() && !norm.IsPlaneDefined() )
283 {
284 // only cathode known : derive the plane
285
286 AliMp::CathodType cathodType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 );
287
288 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathodType);
289
290 Bool_t bending = ( planeType == AliMp::kBendingPlane ) ;
291
292 norm.SetPlane(bending,!bending);
293 }
294
295 else if ( !norm.IsCathodeDefined() && norm.IsPlaneDefined() )
296 {
297 // only plane is known : derive the cathode
298
299 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
300
301 Bool_t cath0 = ( AliMpDEManager::GetCathod(fDetElemId,planeType) == AliMp::kCath0 );
302
303 norm.SetCathode(cath0,!cath0);
304 }
305 else
306 {
307 // check that both information are compatible
308
309 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
310
311 AliMp::CathodType cathode = AliMpDEManager::GetCathod(fDetElemId,planeType);
312
313 if ( cathode == AliMp::kCath0 && norm.IsCathode1() ||
314 cathode == AliMp::kCath1 && norm.IsCathode0() )
315 {
316 norm.SetValid(kFALSE);
317 }
318 }
319
320 return norm;
321}
322