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