1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONChamberPainter.h"
20 #include "AliMUONDEPainter.h"
21 #include "AliMUONPainterContour.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"
34 #include <Riostream.h>
35 #include <TObjString.h>
40 /// \class AliMUONChamberPainter
42 /// Painter for one plane/cathode of one chamber
44 /// \author Laurent Aphecetche, Subatech
47 ClassImp(AliMUONChamberPainter)
50 //_____________________________________________________________________________
51 AliMUONChamberPainter::AliMUONChamberPainter()
58 //_____________________________________________________________________________
59 AliMUONChamberPainter::AliMUONChamberPainter(const AliMUONAttPainter& att,
61 : AliMUONVPainter("Chamber"),
66 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance(); // to be sure mapping is loaded...
68 AliMUONAttPainter chAtt(att);
70 chAtt.SetCathodeAndPlaneMutuallyExclusive(kTRUE);
75 SetName(h->ChamberName(fChamberId).Data());
76 SetPathName(h->ChamberPathName(fChamberId).Data());
80 deIt.First(fChamberId);
82 AliMUONPainterContour* contour = h->GetContour(ContourName());
83 TObjArray contourArray;
85 while (!deIt.IsDone())
87 Int_t detElemId = deIt.CurrentDEId();
89 AliMUONAttPainter deAtt(att);
91 if ( att.IsCathodeDefined() )
93 deAtt.SetCathode(kFALSE,kFALSE);
94 AliMp::PlaneType planeType;
96 if ( att.IsCathode0() ) planeType = AliMpDEManager::GetPlaneType(detElemId,AliMp::kCath0);
97 else planeType = AliMpDEManager::GetPlaneType(detElemId,AliMp::kCath1);
99 Bool_t bending = ( planeType == AliMp::kBendingPlane );
101 deAtt.SetPlane(bending,!bending);
104 assert(deAtt.IsPlaneDefined());
106 AliMUONVPainter* painter = new AliMUONDEPainter(deAtt,detElemId);
112 contourArray.Add(painter->Contour());
118 Double_t xmin(1E9), xmax(-1E9), ymin(1E9), ymax(-1E9);
119 TIter next(Children());
120 AliMUONVPainter* painter;
122 while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
124 const AliMpArea& area = painter->Area();
125 xmin = TMath::Min(xmin,area.LeftBorder());
126 xmax = TMath::Max(xmax,area.RightBorder());
127 ymin = TMath::Min(ymin,area.DownBorder());
128 ymax = TMath::Max(ymax,area.UpBorder());
131 if ( contourArray.GetLast() >= 0 )
133 contour = h->MergeContours(contourArray,ContourName());
139 //_____________________________________________________________________________
140 AliMUONChamberPainter::AliMUONChamberPainter(const AliMUONChamberPainter& rhs)
141 : AliMUONVPainter(rhs),
142 fChamberId(rhs.fChamberId)
148 //_____________________________________________________________________________
149 AliMUONChamberPainter&
150 AliMUONChamberPainter::operator=(const AliMUONChamberPainter& rhs)
152 /// assignment operator
160 //_____________________________________________________________________________
161 AliMUONChamberPainter::~AliMUONChamberPainter()
166 //_____________________________________________________________________________
168 AliMUONChamberPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
169 Double_t& dataMin, Double_t& dataMax) const
171 /// Compute data range spanned by this (plane of that) chamber
172 dataMin = dataMax = data.Chamber(fChamberId, dataIndex);
176 //_____________________________________________________________________________
178 AliMUONChamberPainter::Copy(TObject& object) const
180 /// Copy this to object
181 AliMUONVPainter::Copy((AliMUONVPainter&)(object));
182 ((AliMUONChamberPainter&)(object)).fChamberId = fChamberId;
185 //_____________________________________________________________________________
187 AliMUONChamberPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
190 /// Describe data at this chamber
192 if (!data.HasChamber(fChamberId)) return "";
194 Double_t value = data.Chamber(fChamberId,dataIndex);
196 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
199 //_____________________________________________________________________________
201 AliMUONChamberPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
202 Double_t min, Double_t max)
204 /// Paint area of this chamber according to data
206 if (!data.HasChamber(fChamberId)) return;
208 Double_t value = data.Chamber(fChamberId,dataIndex);
210 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
212 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
214 Contour()->PaintArea(color);
217 //_____________________________________________________________________________
219 AliMUONChamberPainter::Validate(const AliMUONAttPainter& attributes) const
221 /// Normalize attributes
223 AliMUONAttPainter norm(attributes);
225 // A chamber painter must be either cathode defined or plane defined
227 if ( norm.IsCathodeDefined() && norm.IsPlaneDefined() )
229 norm.SetValid(kFALSE);
232 if ( !norm.IsCathodeDefined() && !norm.IsPlaneDefined() )
234 norm.SetValid(kFALSE);