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 "AliMUONManuPadPainter.h"
21 #include "AliMUONPainterGroup.h"
22 #include "AliMUONPainterHelper.h"
23 #include "AliMUONTrackerDataHistogrammer.h"
24 #include "AliMUONVCalibParam.h"
25 #include "AliMUONVDigit.h"
26 #include "AliMUONVTrackerData.h"
27 #include "AliMpConnection.h"
28 #include "AliMpConstants.h"
29 #include "AliMpDDLStore.h"
31 #include "AliMpSegmentation.h"
32 #include "AliMpVSegmentation.h"
35 #include <TVirtualPad.h>
36 #include <TVirtualX.h>
39 ///\class AliMUONManuPadPainter
41 /// Painter for the pads of one manu
43 ///\author Laurent Aphecetche, Subatech
46 ClassImp(AliMUONManuPadPainter)
49 //_____________________________________________________________________________
50 AliMUONManuPadPainter::AliMUONManuPadPainter()
62 //_____________________________________________________________________________
63 AliMUONManuPadPainter::AliMUONManuPadPainter(TRootIOCtor* ioCtor)
64 : AliMUONVPainter(ioCtor),
75 //_____________________________________________________________________________
76 AliMUONManuPadPainter::AliMUONManuPadPainter(const AliMUONVPainter& mother,
79 : AliMUONVPainter("PAD"),
80 fDetElemId(detElemId),
88 SetID(detElemId,manuId);
89 SetName(Form("%s/PAD",mother.GetName()));
90 SetPathName(Form("%s/PAD",mother.PathName().Data()));
91 SetContour(mother.Contour());
94 //_____________________________________________________________________________
95 AliMUONManuPadPainter::~AliMUONManuPadPainter()
100 //_____________________________________________________________________________
102 AliMUONManuPadPainter::BackupStyle()
104 /// Remember line and fill style values
106 fFillStyleBck = gVirtualX->GetFillStyle();
107 fFillColorBck = gVirtualX->GetFillColor();
108 fLineColorBck = gVirtualX->GetLineColor();
109 fLineWidthBck = gVirtualX->GetLineWidth();
112 //_____________________________________________________________________________
114 AliMUONManuPadPainter::ComputeDataRange(const AliMUONVTrackerData& data,
116 Double_t& dataMin, Double_t& dataMax) const
118 /// Compute data range spanned by this manu pads
119 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fDetElemId,fManuId);
124 for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels();
127 if ( seg->HasPadByLocation(fManuId,manuChannel) )
129 Double_t value = data.Channel(fDetElemId, fManuId, manuChannel, dataIndex);
130 dataMin = TMath::Min(value,dataMin);
131 dataMax = TMath::Max(value,dataMax);
136 //_____________________________________________________________________________
138 AliMUONManuPadPainter::GetObjectInfo(Int_t px, Int_t py) const
141 return const_cast<char*>(Form("%s:%d:%d",GetName(),px,py));
144 //_____________________________________________________________________________
146 AliMUONManuPadPainter::NameAtPosition(Double_t x, Double_t y) const
148 /// Specific name, dependent on the position within this painter
150 TString name("invalid");
152 AliMpPad pad = PadByPosition(x,y);
156 name = Form("%s%d",PathName().Data(),pad.GetManuChannel());
162 //_____________________________________________________________________________
164 AliMUONManuPadPainter::IsIncluded() const
166 /// whether this manu is included in the readout or not
167 return ( InteractiveReadOutConfig()->Manu(fDetElemId,fManuId) > 0 );
170 //_____________________________________________________________________________
172 AliMUONManuPadPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
173 Double_t x, Double_t y)
175 /// Describe data at given location
177 if ( ! data.HasManu(fDetElemId,fManuId) ) return "";
179 AliMpPad pad = PadByPosition(x,y);
183 Double_t value = data.Channel(fDetElemId,fManuId,pad.GetManuChannel(),dataIndex);
185 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
193 //_____________________________________________________________________________
195 AliMUONManuPadPainter::DrawHistogramClone(Double_t* values) const
197 /// Draw histogram for pad at (values[0],values[1])
199 if ( !values ) return;
201 AliMUONPainterGroup* group = Master()->PlotterGroup();
203 if ( !group ) return; // no data to histogram in this painter
205 AliMpPad pad = PadByPosition(values[0],values[1]);
207 AliMUONVTrackerData* data = group->Data();
209 AliMUONTrackerDataHistogrammer tdh(*data,0,-1);
211 fHistogram = tdh.CreateChannelHisto(fDetElemId, fManuId,pad.GetManuChannel());
220 //_____________________________________________________________________________
222 AliMUONManuPadPainter::PaintArea(const AliMUONVTrackerData& data,
227 /// Paint area of this manu pads according to the data
231 if ( ! data.HasManu(fDetElemId,fManuId) ) return;
233 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
237 gVirtualX->SetLineColor(-1);
238 gVirtualX->SetFillStyle(1001);
240 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fDetElemId,fManuId);
242 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
244 AliMpPad pad = seg->PadByLocation(fManuId,i,kFALSE);
248 Double_t value = data.Channel(fDetElemId,fManuId,i,dataIndex);
250 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
252 Int_t color = h->ColorFromValue(value,min,max);
256 AliDebug(1,Form("DE %d manuId %d channel %d value %e min %e max %e color %d",
257 fDetElemId,fManuId,i,value,min,max,
261 gVirtualX->SetFillColor(color);
271 //_____________________________________________________________________________
273 AliMUONManuPadPainter::PaintPad(const AliMpPad& pad) const
275 Double_t blx = pad.GetPositionX()-pad.GetDimensionX();
276 Double_t bly = pad.GetPositionY()-pad.GetDimensionY();
278 Double_t urx = pad.GetPositionX()+pad.GetDimensionX();
279 Double_t ury = pad.GetPositionY()+pad.GetDimensionY();
281 Double_t xe1,ye1,xe2,ye2,z;
283 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,blx,bly,0,xe1,ye1,z);
284 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,urx,ury,0,xe2,ye2,z);
286 gPad->PaintBox(xe1,ye1,xe2,ye2);
289 //_____________________________________________________________________________
291 AliMUONManuPadPainter::PaintOutline(Int_t color, Int_t, Double_t x, Double_t y)
293 /// Paint the outline of our pads
297 Int_t lineColor = color >= 0 ? color : GetLineColor();
303 gVirtualX->SetLineColor(lineColor);
304 gVirtualX->SetFillStyle(0);
306 if ( x < FLT_MAX && y < FLT_MAX )
308 // find pad to be drawn
309 AliMpPad pad = PadByPosition(x,y);
315 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fDetElemId,fManuId);
317 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
319 AliMpPad pad = seg->PadByLocation(fManuId,i,kFALSE);
321 if (pad.IsValid()) PaintPad(pad);
331 //_____________________________________________________________________________
333 AliMUONManuPadPainter::PadByPosition(Double_t x, Double_t y) const
335 /// Find the pad at given exploded-position (x,y)
337 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fDetElemId,fManuId);
342 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,xg,yg,zg); // to get zg
344 AliMUONPainterHelper::Instance()->Global2Local(fDetElemId,x,y,zg,xl,yl,zl);
346 return seg->PadByPosition(xl,yl);
349 //_____________________________________________________________________________
351 AliMUONManuPadPainter::RestoreStyle()
353 /// Restore line and fill style values
355 gVirtualX->SetFillStyle(fFillStyleBck);
356 gVirtualX->SetFillColor(fFillColorBck);
357 gVirtualX->SetLineColor(fLineColorBck);
358 gVirtualX->SetLineWidth(fLineWidthBck);