Go from pointer to ifstream to ifstream.
[u/mrichter/AliRoot.git] / MUON / AliMUONPCBPainter.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/// \class AliMUONPCBPainter
19///
20/// Implementation of AliMUONVPainter for slat's PCBs
21///
22/// \author Laurent Aphecetche, Subatech
23
24#include "AliMUONPCBPainter.h"
25
26#include "AliMUONManuPainter.h"
8f0acce4 27#include "AliMUONContour.h"
0145e89a 28#include "AliMUONPainterHelper.h"
29#include "AliMUONVCalibParam.h"
30#include "AliMUONVTrackerData.h"
31#include "AliMpDEManager.h"
32#include "AliMpMotifPosition.h"
33#include "AliMpPCB.h"
34#include "AliMpPlaneType.h"
35#include "AliMpSlat.h"
36#include "AliLog.h"
37
9016a84e 38/// \cond CLASSIMP
0145e89a 39ClassImp(AliMUONPCBPainter)
40/// \endcond
41
42//_____________________________________________________________________________
1ffbeb9d 43AliMUONPCBPainter::AliMUONPCBPainter(TRootIOCtor* ioCtor)
44: AliMUONVPainter(ioCtor),
45fDetElemId(-1),
46fPCBIndex(-1)
47{
48 /// root streaming ctor
49}
50
51//_____________________________________________________________________________
0145e89a 52AliMUONPCBPainter::AliMUONPCBPainter()
53: AliMUONVPainter(),
54fDetElemId(-1),
55fPCBIndex(-1)
56{
57 /// empty ctor
58}
59
60//_____________________________________________________________________________
61AliMUONPCBPainter::AliMUONPCBPainter(const AliMUONAttPainter& att,
62 Int_t detElemId,
63 Int_t pcbNumber)
64: AliMUONVPainter("PCB"),
65 fDetElemId(detElemId),
66 fPCBIndex(pcbNumber)
67{
8f0acce4 68 /// Ctor
69
70 SetAttributes(att);
71
72 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
73
74 AliMp::PlaneType planeType = ( att.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
75
76 const AliMpSlat* slat = AliMUONPainterHelper::Instance()->GetSlat(fDetElemId,planeType);
77
78 SetID(detElemId,pcbNumber);
79 SetName(h->PCBName(pcbNumber));
80 SetPathName(h->PCBPathName(detElemId,pcbNumber));
81
82 AliMpPCB* pcb = slat->GetPCB(fPCBIndex);
83
84 AliMUONContour* contour = h->GetContour(ContourName());
85 TObjArray contourArray;
86
87 for ( Int_t imp = 0 ; imp < pcb->GetSize(); ++imp )
88 {
89 AliMpMotifPosition* mp = pcb->GetMotifPosition(imp);
90 AliDebug(1,Form("Adding manu %d to PCB %d of DE %d",
91 mp->GetID(),fPCBIndex,fDetElemId));
92 AliMUONVPainter* painter = new AliMUONManuPainter(Attributes(),fDetElemId,mp->GetID());
93 Add(painter);
0145e89a 94 if (!contour)
95 {
8f0acce4 96 contourArray.Add(painter->Contour());
0145e89a 97 }
8f0acce4 98 }
99
100 Double_t x,y,z;
101
102 h->Local2Global(fDetElemId,
103 pcb->X()-slat->GetPositionX(),
104 pcb->Y()-slat->GetPositionY(),
105 0.0,
106 x,y,z);
107
108 if (!contour)
109 {
110 contour = h->MergeContours(contourArray,ContourName());
111 }
112
113 SetContour(contour);
0145e89a 114}
115
116//_____________________________________________________________________________
117AliMUONPCBPainter::~AliMUONPCBPainter()
118{
119 /// dtor
120}
121
122//_____________________________________________________________________________
123AliMUONPCBPainter::AliMUONPCBPainter(const AliMUONPCBPainter& rhs)
124: AliMUONVPainter(rhs),
125 fDetElemId(-1),
126 fPCBIndex(-1)
127{
128 /// copy ctor
129 rhs.Copy(*this);
130}
131
132//_____________________________________________________________________________
133AliMUONPCBPainter&
134AliMUONPCBPainter::operator=(const AliMUONPCBPainter& rhs)
135{
136 /// assignment operator
137 if ( this != &rhs )
138 {
139 rhs.Copy(*this);
140 }
141 return *this;
142}
143
144//_____________________________________________________________________________
145void
146AliMUONPCBPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
147 Double_t& dataMin, Double_t& dataMax) const
148{
149 /// Compute the min and max of this PCB data
150 dataMin = dataMax = data.PCB(fDetElemId, fPCBIndex,dataIndex);
151}
152
153//_____________________________________________________________________________
154void
155AliMUONPCBPainter::Copy(TObject& object) const
156{
157 /// Copy this to object
158 AliMUONVPainter::Copy((AliMUONVPainter&)(object));
159 ((AliMUONPCBPainter&)(object)).fDetElemId = fDetElemId;
160 ((AliMUONPCBPainter&)(object)).fPCBIndex = fPCBIndex;
161}
162
163//_____________________________________________________________________________
10eb3d17 164TString
165AliMUONPCBPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
166 Double_t, Double_t)
167{
168 /// Describe data at this PCB
169
170 if (!data.HasPCB(fDetElemId,fPCBIndex)) return "";
171
172 Double_t value = data.PCB(fDetElemId,fPCBIndex,dataIndex);
173
174 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
175}
176
177//_____________________________________________________________________________
1ffbeb9d 178Bool_t
179AliMUONPCBPainter::IsIncluded() const
180{
181 /// Whether this PCB is included in the read out or not
182 return ( InteractiveReadOutConfig()->PCB(fDetElemId,fPCBIndex) > 0 );
183}
184
185//_____________________________________________________________________________
0145e89a 186void
187AliMUONPCBPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
188 Double_t min, Double_t max)
189{
190 /// Fill the contour of this PCB with a color depending of the value of the data
191 if (!data.HasPCB(fDetElemId,fPCBIndex)) return;
192
193 Double_t value = data.PCB(fDetElemId,fPCBIndex,dataIndex);
194
195 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
196
197 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
198
8f0acce4 199 PaintArea(color);
0145e89a 200}
201