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 "AliMUONPainterPadStore.h"
24 #include "AliMUONTrackerDataHistogrammer.h"
25 #include "AliMUONVCalibParam.h"
26 #include "AliMUONVDigit.h"
27 #include "AliMUONVTrackerData.h"
28 #include "AliMpConnection.h"
29 #include "AliMpConstants.h"
30 #include "AliMpDDLStore.h"
31 #include "AliMpDetElement.h"
33 #include "AliMpSegmentation.h"
34 #include "AliMpVSegmentation.h"
37 #include <TVirtualPad.h>
38 #include <TVirtualX.h>
41 ///\class AliMUONManuPadPainter
43 /// Painter for the pads of one manu
45 ///\author Laurent Aphecetche, Subatech
48 ClassImp(AliMUONManuPadPainter)
51 //_____________________________________________________________________________
52 AliMUONManuPadPainter::AliMUONManuPadPainter()
64 //_____________________________________________________________________________
65 AliMUONManuPadPainter::AliMUONManuPadPainter(TRootIOCtor* ioCtor)
66 : AliMUONVPainter(ioCtor),
77 //_____________________________________________________________________________
78 AliMUONManuPadPainter::AliMUONManuPadPainter(const AliMUONVPainter& mother,
81 : AliMUONVPainter("PAD"),
82 fDetElemId(detElemId),
90 SetID(detElemId,manuId);
91 SetName(Form("%s/PAD",mother.GetName()));
92 SetPathName(Form("%s/PAD",mother.PathName().Data()));
93 SetContour(mother.Contour());
96 //_____________________________________________________________________________
97 AliMUONManuPadPainter::~AliMUONManuPadPainter()
102 //_____________________________________________________________________________
104 AliMUONManuPadPainter::BackupStyle()
106 /// Remember line and fill style values
108 fFillStyleBck = gVirtualX->GetFillStyle();
109 fFillColorBck = gVirtualX->GetFillColor();
110 fLineColorBck = gVirtualX->GetLineColor();
111 fLineWidthBck = gVirtualX->GetLineWidth();
114 //_____________________________________________________________________________
116 AliMUONManuPadPainter::ComputeDataRange(const AliMUONVTrackerData& data,
118 Double_t& dataMin, Double_t& dataMax) const
120 /// Compute data range spanned by this manu pads
121 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId);
126 for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels();
129 if ( de->IsConnectedChannel(fManuId,manuChannel) )
131 Double_t value = data.Channel(fDetElemId, fManuId, manuChannel, dataIndex);
132 dataMin = TMath::Min(value,dataMin);
133 dataMax = TMath::Max(value,dataMax);
138 //_____________________________________________________________________________
140 AliMUONManuPadPainter::GetObjectInfo(Int_t px, Int_t py) const
143 return const_cast<char*>(Form("%s:%d:%d",GetName(),px,py));
146 //_____________________________________________________________________________
148 AliMUONManuPadPainter::NameAtPosition(Double_t x, Double_t y) const
150 /// Specific name, dependent on the position within this painter
152 TString name("invalid");
154 AliMpPad pad = PadByPosition(x,y);
158 name = Form("%s%d",PathName().Data(),pad.GetManuChannel());
164 //_____________________________________________________________________________
166 AliMUONManuPadPainter::IsIncluded() const
168 /// whether this manu is included in the readout or not
169 return ( InteractiveReadOutConfig()->Manu(fDetElemId,fManuId) > 0 );
172 //_____________________________________________________________________________
174 AliMUONManuPadPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
175 Double_t x, Double_t y)
177 /// Describe data at given location
179 if ( ! data.HasManu(fDetElemId,fManuId) ) return "";
181 AliMpPad pad = PadByPosition(x,y);
185 Double_t value = data.Channel(fDetElemId,fManuId,pad.GetManuChannel(),dataIndex);
187 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
195 //_____________________________________________________________________________
197 AliMUONManuPadPainter::DrawHistogramClone(Double_t* values) const
199 /// Draw histogram for pad at (values[0],values[1])
201 if ( !values ) return;
203 AliMUONPainterGroup* group = Master()->PlotterGroup();
205 if ( !group ) return; // no data to histogram in this painter
207 AliMpPad pad = PadByPosition(values[0],values[1]);
209 AliMUONVTrackerData* data = group->Data();
211 AliMUONTrackerDataHistogrammer tdh(*data,0,-1);
213 fHistogram = tdh.CreateChannelHisto(fDetElemId, fManuId, pad.GetManuChannel());
221 //_____________________________________________________________________________
223 AliMUONManuPadPainter::PaintArea(const AliMUONVTrackerData& data,
228 /// Paint area of this manu pads according to the data
232 if ( ! data.HasManu(fDetElemId,fManuId) ) return;
234 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
238 Int_t cathode = h->GetCathodeType(fDetElemId,fManuId);
240 gVirtualX->SetLineColor(-1);
241 gVirtualX->SetFillStyle(1);
243 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
245 Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,i,cathode);
250 h->PadStore().GetPadGeometry(id,position,dimensions);
252 if ( dimensions.X() > 0 )
254 Double_t value = data.Channel(fDetElemId,fManuId,i,dataIndex);
256 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
258 Int_t color = h->ColorFromValue(value,min,max);
262 AliDebug(1,Form("DE %d manuId %d channel %d value %e min %e max %e color %d",
263 fDetElemId,fManuId,i,value,min,max,
267 gVirtualX->SetFillColor(color);
269 TVector2 bl(position-dimensions);
270 TVector2 ur(position+dimensions);
272 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
279 //_____________________________________________________________________________
281 AliMUONManuPadPainter::PaintPad(Int_t padId) const
283 /// Paint a single pad
288 AliMUONPainterHelper::Instance()->PadStore().GetPadGeometry(padId,position,dimensions);
290 if ( dimensions.X() > 0 )
292 TVector2 bl(position-dimensions);
293 TVector2 ur(position+dimensions);
295 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
299 //_____________________________________________________________________________
301 AliMUONManuPadPainter::PaintOutline(Int_t color, Int_t, Double_t x, Double_t y)
303 /// Paint the outline of our pads
307 Int_t lineColor = color >= 0 ? color : GetLineColor();
309 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
311 AliDebug(1,Form("color=%d lineColor=%d x=%7.3f y=%7.3f",color,lineColor,x,y));
317 Int_t cathode = h->GetCathodeType(fDetElemId,fManuId);
319 gVirtualX->SetLineColor(lineColor);
320 gVirtualX->SetFillStyle(0);
322 if ( x < FLT_MAX && y < FLT_MAX )
324 // find pad to be drawn
325 AliMpPad pad = PadByPosition(x,y);
327 Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,pad.GetManuChannel(),cathode);
333 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
335 Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,i,cathode);
345 //_____________________________________________________________________________
347 AliMUONManuPadPainter::PadByPosition(Double_t x, Double_t y) const
349 /// Find the pad at given exploded-position (x,y)
351 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fDetElemId,fManuId);
356 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,xg,yg,zg); // to get zg
358 AliMUONPainterHelper::Instance()->Global2Local(fDetElemId,x,y,zg,xl,yl,zl);
360 return seg->PadByPosition(TVector2(xl,yl));
363 //_____________________________________________________________________________
365 AliMUONManuPadPainter::RestoreStyle()
367 /// Restore line and fill style values
369 gVirtualX->SetFillStyle(fFillStyleBck);
370 gVirtualX->SetFillColor(fFillColorBck);
371 gVirtualX->SetLineColor(fLineColorBck);
372 gVirtualX->SetLineWidth(fLineWidthBck);