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 "AliMUONChamberPainter.h"
19 :
20 : #include "AliMUONDEPainter.h"
21 : #include "AliMUONContour.h"
22 : #include "AliMUONPainterHelper.h"
23 : #include "AliMUONVCalibParam.h"
24 : #include "AliMUONVTrackerData.h"
25 : #include "AliMpConstants.h"
26 : #include "AliMpDEIterator.h"
27 : #include "AliMpDEManager.h"
28 : #include "AliMpPlaneType.h"
29 : #include "AliMpSegmentation.h"
30 : #include "AliMpStationType.h"
31 : #include "AliMpVSegmentation.h"
32 : #include "AliMUONObjectPair.h"
33 : #include "AliLog.h"
34 : #include <Riostream.h>
35 : #include <TObjString.h>
36 : #include <TArrayI.h>
37 : #include <cassert>
38 : #include <float.h>
39 :
40 : /// \class AliMUONChamberPainter
41 : ///
42 : /// Painter for one plane/cathode of one chamber
43 : ///
44 : /// \author Laurent Aphecetche, Subatech
45 :
46 : ///\cond CLASSIMP
47 12 : ClassImp(AliMUONChamberPainter)
48 : ///\endcond
49 :
50 : //_____________________________________________________________________________
51 : AliMUONChamberPainter::AliMUONChamberPainter()
52 0 : : AliMUONVPainter(),
53 0 : fChamberId(-1)
54 0 : {
55 : /// ctor
56 0 : }
57 :
58 : //_____________________________________________________________________________
59 : AliMUONChamberPainter::AliMUONChamberPainter(TRootIOCtor* ioCtor)
60 0 : : AliMUONVPainter(ioCtor),
61 0 : fChamberId(-1)
62 0 : {
63 : /// ctor
64 0 : }
65 :
66 : //_____________________________________________________________________________
67 : AliMUONChamberPainter::AliMUONChamberPainter(const AliMUONAttPainter& att,
68 : Int_t chamberId)
69 0 : : AliMUONVPainter("Chamber"),
70 0 : fChamberId(chamberId)
71 0 : {
72 : /// ctor
73 :
74 0 : AliMUONPainterHelper* h = AliMUONPainterHelper::Instance(); // to be sure mapping is loaded...
75 :
76 0 : AliMUONAttPainter chAtt(att);
77 :
78 0 : chAtt.SetCathodeAndPlaneMutuallyExclusive(kTRUE);
79 :
80 0 : SetAttributes(chAtt);
81 :
82 0 : SetID(chamberId,-1);
83 0 : SetName(h->ChamberName(fChamberId).Data());
84 0 : SetPathName(h->ChamberPathName(fChamberId).Data());
85 :
86 0 : AliMpDEIterator deIt;
87 :
88 0 : deIt.First(fChamberId);
89 :
90 0 : AliMUONContour* contour = h->GetContour(ContourName());
91 0 : TObjArray contourArray;
92 :
93 0 : while (!deIt.IsDone())
94 : {
95 0 : Int_t detElemId = deIt.CurrentDEId();
96 :
97 0 : AliMUONAttPainter deAtt(att);
98 :
99 0 : if ( att.IsCathodeDefined() )
100 : {
101 0 : deAtt.SetCathode(kFALSE,kFALSE);
102 : AliMp::PlaneType planeType;
103 :
104 0 : if ( att.IsCathode0() ) planeType = AliMpDEManager::GetPlaneType(detElemId,AliMp::kCath0);
105 0 : else planeType = AliMpDEManager::GetPlaneType(detElemId,AliMp::kCath1);
106 :
107 0 : Bool_t bending = ( planeType == AliMp::kBendingPlane );
108 :
109 0 : deAtt.SetPlane(bending,!bending);
110 0 : }
111 :
112 0 : assert(deAtt.IsPlaneDefined());
113 :
114 0 : AliMUONVPainter* painter = new AliMUONDEPainter(deAtt,detElemId);
115 :
116 0 : Add(painter);
117 :
118 0 : if (!contour)
119 : {
120 0 : contourArray.Add(painter->Contour());
121 : }
122 :
123 0 : deIt.Next();
124 0 : }
125 :
126 : Double_t xmin(1E9), xmax(-1E9), ymin(1E9), ymax(-1E9);
127 0 : TIter next(Children());
128 : AliMUONVPainter* painter;
129 :
130 0 : while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
131 : {
132 0 : const AliMpArea& area = painter->Area();
133 0 : xmin = TMath::Min(xmin,area.LeftBorder());
134 0 : xmax = TMath::Max(xmax,area.RightBorder());
135 0 : ymin = TMath::Min(ymin,area.DownBorder());
136 0 : ymax = TMath::Max(ymax,area.UpBorder());
137 0 : }
138 :
139 0 : if ( contourArray.GetLast() >= 0 )
140 : {
141 0 : contour = h->MergeContours(contourArray,ContourName());
142 0 : }
143 :
144 0 : SetContour(contour);
145 0 : }
146 :
147 : //_____________________________________________________________________________
148 : AliMUONChamberPainter::AliMUONChamberPainter(const AliMUONChamberPainter& rhs)
149 0 : : AliMUONVPainter(rhs),
150 0 : fChamberId(rhs.fChamberId)
151 0 : {
152 : /// copy ctor
153 0 : rhs.Copy(*this);
154 0 : }
155 :
156 : //_____________________________________________________________________________
157 : AliMUONChamberPainter&
158 : AliMUONChamberPainter::operator=(const AliMUONChamberPainter& rhs)
159 : {
160 : /// assignment operator
161 0 : if ( this != &rhs )
162 : {
163 0 : rhs.Copy(*this);
164 0 : }
165 0 : return *this;
166 : }
167 :
168 : //_____________________________________________________________________________
169 0 : AliMUONChamberPainter::~AliMUONChamberPainter()
170 0 : {
171 : /// dtor
172 0 : }
173 :
174 : //_____________________________________________________________________________
175 : void
176 : AliMUONChamberPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
177 : Double_t& dataMin, Double_t& dataMax) const
178 : {
179 : /// Compute data range spanned by this (plane of that) chamber
180 0 : dataMin = dataMax = data.Chamber(fChamberId, dataIndex);
181 0 : }
182 :
183 :
184 : //_____________________________________________________________________________
185 : void
186 : AliMUONChamberPainter::Copy(TObject& object) const
187 : {
188 : /// Copy this to object
189 0 : AliMUONVPainter::Copy((AliMUONVPainter&)(object));
190 0 : ((AliMUONChamberPainter&)(object)).fChamberId = fChamberId;
191 0 : }
192 :
193 : //_____________________________________________________________________________
194 : TString
195 : AliMUONChamberPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
196 : Double_t, Double_t)
197 : {
198 : /// Describe data at this chamber
199 :
200 0 : if (!data.HasChamber(fChamberId)) return "";
201 :
202 0 : Double_t value = data.Chamber(fChamberId,dataIndex);
203 :
204 0 : return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
205 0 : }
206 :
207 : //_____________________________________________________________________________
208 : Bool_t
209 : AliMUONChamberPainter::IsIncluded() const
210 : {
211 : /// whether this chamber is included in the readout or not
212 0 : return ( InteractiveReadOutConfig()->Chamber(fChamberId) > 0 );
213 : }
214 :
215 : //_____________________________________________________________________________
216 : void
217 : AliMUONChamberPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
218 : Double_t min, Double_t max)
219 : {
220 : /// Paint area of this chamber according to data
221 :
222 0 : if (!data.HasChamber(fChamberId)) return;
223 :
224 0 : Double_t value = data.Chamber(fChamberId,dataIndex);
225 :
226 0 : if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
227 :
228 0 : Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
229 :
230 0 : PaintArea(color);
231 0 : }
232 :
233 : //_____________________________________________________________________________
234 : AliMUONAttPainter
235 : AliMUONChamberPainter::Validate(const AliMUONAttPainter& attributes) const
236 : {
237 : /// Normalize attributes
238 :
239 0 : AliMUONAttPainter norm(attributes);
240 :
241 : // A chamber painter must be either cathode defined or plane defined
242 :
243 0 : if ( norm.IsCathodeDefined() && norm.IsPlaneDefined() )
244 : {
245 0 : norm.SetValid(kFALSE);
246 : }
247 :
248 0 : if ( !norm.IsCathodeDefined() && !norm.IsPlaneDefined() )
249 : {
250 0 : norm.SetValid(kFALSE);
251 : }
252 :
253 : return norm;
254 0 : }
|