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 "AliMUONContour.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(TRootIOCtor* ioCtor)
57 : AliMUONVPainter(ioCtor),
60 /// default streaming ctor
63 //_____________________________________________________________________________
64 AliMUONBusPatchPainter::AliMUONBusPatchPainter(const AliMUONAttPainter& att,
66 : AliMUONVPainter("BUSPATCH"),
67 fBusPatchId(busPatchId)
70 /// WARNING : the construction of this object can fail.
71 /// You MUST check the IsValid() method afterwards (real world would
72 /// be to use exception, but well, whether we should use exceptions
73 /// in aliroot is still unclear to me.
75 SetAttributes(Validate(att));
77 AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
79 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId);
81 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
84 SetName(h->BusPatchName(busPatchId));
85 SetPathName(h->BusPatchPathName(busPatchId));
87 AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(fBusPatchId);
89 Int_t mask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
91 AliMUONContour* bpContour = h->GetContour(ContourName());
93 AliDebug(1,Form("BusPatchId %04d bending %d DE %4d bpContour(%s)=%p nofManus=%d",
94 fBusPatchId,att.IsBendingPlane(),detElemId,ContourName().Data(),bpContour,busPatch->GetNofManus()));
96 Double_t xmin(FLT_MAX), ymin(FLT_MAX), xmax(-FLT_MAX), ymax(-FLT_MAX);
102 for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i )
104 Int_t manuId = busPatch->GetManuId(i);
106 Bool_t correctPlane(kTRUE);
108 if ( planeType == AliMp::kNonBendingPlane )
110 if ( ( manuId & mask ) == 0 ) correctPlane = kFALSE;
114 if ( ( manuId & mask ) == mask ) correctPlane = kFALSE;
117 AliDebug(1,Form("Adding Manu %04d to BusPatch %04d (DE %04d) "
118 "manu & mask = %d correctPlane %d planeType %s",
119 manuId,fBusPatchId,busPatch->GetDEId(),
120 (manuId & mask),correctPlane,AliMp::PlaneTypeName(planeType).Data()));
122 if (!correctPlane) continue;
126 AliMUONVPainter* painter = new AliMUONManuPainter(Attributes(),
132 const AliMpArea& area = painter->Area();
134 xmin = TMath::Min(xmin,
\varea.LeftBorder());
135 ymin = TMath::Min(ymin,area.DownBorder());
136 xmax = TMath::Max(xmax,area.RightBorder());
137 ymax = TMath::Max(ymax,area.UpBorder());
141 contours.Add(painter->Contour());
153 AliDebug(1,Form("Creating contour %s",ContourName().Data()));
154 bpContour = h->MergeContours(contours,ContourName());
157 AliError("Could not merge those contours");
158 StdoutToAliError(contours.Print(););
162 SetContour(bpContour);
165 //_____________________________________________________________________________
167 AliMUONBusPatchPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
168 Double_t& dataMin, Double_t& dataMax) const
170 /// Compute the data range spanned by this bus patch (on this cathode or plane)
171 dataMin = dataMax = data.BusPatch(fBusPatchId, dataIndex);
174 //_____________________________________________________________________________
175 AliMUONBusPatchPainter::AliMUONBusPatchPainter(const AliMUONBusPatchPainter& rhs)
176 : AliMUONVPainter(rhs), fBusPatchId(-1)
182 //_____________________________________________________________________________
183 AliMUONBusPatchPainter&
184 AliMUONBusPatchPainter::operator=(const AliMUONBusPatchPainter& rhs)
186 /// Assignment operator
194 //_____________________________________________________________________________
195 AliMUONBusPatchPainter::~AliMUONBusPatchPainter()
200 //_____________________________________________________________________________
202 AliMUONBusPatchPainter::Copy(TObject& object) const
204 /// Copy this to object
205 AliMUONVPainter::Copy((AliMUONVPainter&)(object));
206 ((AliMUONBusPatchPainter&)(object)).fBusPatchId = fBusPatchId;
209 //_____________________________________________________________________________
211 AliMUONBusPatchPainter::IsIncluded() const
213 /// whether this bus patch is included in the readout or not
214 return ( InteractiveReadOutConfig()->BusPatch(fBusPatchId) > 0 );
217 //_____________________________________________________________________________
219 AliMUONBusPatchPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
224 if (!data.HasBusPatch(fBusPatchId)) return "";
226 Double_t value = data.BusPatch(fBusPatchId,dataIndex);
228 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
231 //_____________________________________________________________________________
233 AliMUONBusPatchPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
234 Double_t min, Double_t max)
236 /// Paint area of this buspatch according to the data
238 if (!data.HasBusPatch(fBusPatchId)) return;
240 Double_t value = data.BusPatch(fBusPatchId,dataIndex);
242 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
244 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
249 //_____________________________________________________________________________
251 AliMUONBusPatchPainter::Validate(const AliMUONAttPainter& attributes) const
253 /// Normalize attributes
255 // we invalidate the attributes, if we have no manu in the requested plane
256 // and we cross-check that both cathode and plane are up-to-date
258 AliMUONAttPainter norm(attributes);
260 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(fBusPatchId);
262 if (!norm.IsValid()) return norm;
264 if ( !norm.IsCathodeDefined() )
266 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
268 AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,planeType);
270 Bool_t cath0 = ( cathodeType == AliMp::kCath0 );
272 norm.SetCathode(cath0,!cath0);
274 else if ( !norm.IsPlaneDefined() )
276 AliMp::CathodType cathodeType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 );
278 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodeType);
280 Bool_t bending = ( planeType == AliMp::kBendingPlane );
282 norm.SetPlane(bending,!bending);
285 AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(fBusPatchId);
287 Int_t mask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
292 for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i )
294 Int_t manuId = busPatch->GetManuId(i);
296 if ( manuId & mask ) ++nb;
300 if ( norm.IsBendingPlane() && !b ) norm.SetValid(kFALSE);
301 if ( norm.IsNonBendingPlane() && !nb ) norm.SetValid(kFALSE);