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 "AliMUONBusPatchPainter.h"
20 #include "AliMUONManuPainter.h"
21 #include "AliMUONPainterContour.h"
22 #include "AliMUONPainterHelper.h"
23 #include "AliMUONVCalibParam.h"
24 #include "AliMUONVTrackerData.h"
25 #include "AliMpBusPatch.h"
26 #include "AliMpConstants.h"
27 #include "AliMpDDLStore.h"
28 #include "AliMpDEManager.h"
29 #include "AliMpPlaneType.h"
31 #include <TObjArray.h>
35 /// \class AliMUONBusPatchPainter
37 /// Painter for one bus patch. Actually possibly for only part of one
38 /// buspatch (the part that is on the plane/cathode requested when
39 /// creating the painter)
41 /// \author Laurent Aphecetche, Subatech
44 ClassImp(AliMUONBusPatchPainter)
47 //_____________________________________________________________________________
48 AliMUONBusPatchPainter::AliMUONBusPatchPainter()
55 //_____________________________________________________________________________
56 AliMUONBusPatchPainter::AliMUONBusPatchPainter(const AliMUONAttPainter& att,
58 : AliMUONVPainter("BUSPATCH"),
59 fBusPatchId(busPatchId)
62 /// WARNING : the construction of this object can fail.
63 /// You MUST check the IsValid() method afterwards (real world would
64 /// be to use exception, but well, whether we should use exceptions
65 /// in aliroot is still unclear to me.
67 SetAttributes(Validate(att));
69 AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
71 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId);
73 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
76 SetName(h->BusPatchName(busPatchId));
77 SetPathName(h->BusPatchPathName(busPatchId));
79 AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(fBusPatchId);
81 Int_t mask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
83 AliMUONPainterContour* bpContour = h->GetContour(ContourName());
85 AliDebug(1,Form("BusPatchId %04d bending %d DE %4d bpContour(%s)=%p nofManus=%d",
86 fBusPatchId,att.IsBendingPlane(),detElemId,ContourName().Data(),bpContour,busPatch->GetNofManus()));
88 Double_t xmin(FLT_MAX), ymin(FLT_MAX), xmax(-FLT_MAX), ymax(-FLT_MAX);
94 for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i )
96 Int_t manuId = busPatch->GetManuId(i);
98 Bool_t correctPlane(kTRUE);
100 if ( planeType == AliMp::kNonBendingPlane )
102 if ( ( manuId & mask ) == 0 ) correctPlane = kFALSE;
106 if ( ( manuId & mask ) == mask ) correctPlane = kFALSE;
109 AliDebug(1,Form("Adding Manu %04d to BusPatch %04d (DE %04d) "
110 "manu & mask = %d correctPlane %d planeType %s",
111 manuId,fBusPatchId,busPatch->GetDEId(),
112 (manuId & mask),correctPlane,AliMp::PlaneTypeName(planeType).Data()));
114 if (!correctPlane) continue;
118 AliMUONVPainter* painter = new AliMUONManuPainter(Attributes(),
124 const AliMpArea& area = painter->Area();
126 xmin = TMath::Min(xmin,
\varea.LeftBorder());
127 ymin = TMath::Min(ymin,area.DownBorder());
128 xmax = TMath::Max(xmax,area.RightBorder());
129 ymax = TMath::Max(ymax,area.UpBorder());
133 contours.Add(painter->Contour());
145 AliDebug(1,Form("Creating contour %s",ContourName().Data()));
146 bpContour = h->MergeContours(contours,ContourName());
149 AliError("Could not merge those contours");
150 StdoutToAliError(contours.Print(););
154 SetContour(bpContour);
157 //_____________________________________________________________________________
159 AliMUONBusPatchPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
160 Double_t& dataMin, Double_t& dataMax) const
162 /// Compute the data range spanned by this bus patch (on this cathode or plane)
163 dataMin = dataMax = data.BusPatch(fBusPatchId, dataIndex);
166 //_____________________________________________________________________________
167 AliMUONBusPatchPainter::AliMUONBusPatchPainter(const AliMUONBusPatchPainter& rhs)
168 : AliMUONVPainter(rhs), fBusPatchId(-1)
174 //_____________________________________________________________________________
175 AliMUONBusPatchPainter&
176 AliMUONBusPatchPainter::operator=(const AliMUONBusPatchPainter& rhs)
178 /// Assignment operator
186 //_____________________________________________________________________________
187 AliMUONBusPatchPainter::~AliMUONBusPatchPainter()
192 //_____________________________________________________________________________
194 AliMUONBusPatchPainter::Copy(TObject& object) const
196 /// Copy this to object
197 AliMUONVPainter::Copy((AliMUONVPainter&)(object));
198 ((AliMUONBusPatchPainter&)(object)).fBusPatchId = fBusPatchId;
201 //_____________________________________________________________________________
203 AliMUONBusPatchPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
208 if (!data.HasBusPatch(fBusPatchId)) return "";
210 Double_t value = data.BusPatch(fBusPatchId,dataIndex);
212 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
215 //_____________________________________________________________________________
217 AliMUONBusPatchPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
218 Double_t min, Double_t max)
220 /// Paint area of this buspatch according to the data
222 if (!data.HasBusPatch(fBusPatchId)) return;
224 Double_t value = data.BusPatch(fBusPatchId,dataIndex);
226 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
228 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
230 Contour()->PaintArea(color);
233 //_____________________________________________________________________________
235 AliMUONBusPatchPainter::Validate(const AliMUONAttPainter& attributes) const
237 /// Normalize attributes
239 // we invalidate the attributes, if we have no manu in the requested plane
240 // and we cross-check that both cathode and plane are up-to-date
242 AliMUONAttPainter norm(attributes);
244 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(fBusPatchId);
246 if (!norm.IsValid()) return norm;
248 if ( !norm.IsCathodeDefined() )
250 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
252 AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,planeType);
254 Bool_t cath0 = ( cathodeType == AliMp::kCath0 );
256 norm.SetCathode(cath0,!cath0);
258 else if ( !norm.IsPlaneDefined() )
260 AliMp::CathodType cathodeType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 );
262 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodeType);
264 Bool_t bending = ( planeType == AliMp::kBendingPlane );
266 norm.SetPlane(bending,!bending);
269 AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(fBusPatchId);
271 Int_t mask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
276 for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i )
278 Int_t manuId = busPatch->GetManuId(i);
280 if ( manuId & mask ) ++nb;
284 if ( norm.IsBendingPlane() && !b ) norm.SetValid(kFALSE);
285 if ( norm.IsNonBendingPlane() && !nb ) norm.SetValid(kFALSE);