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 "AliMUONDEPainter.h"
20 #include "AliMUONBusPatchPainter.h"
21 #include "AliMUONGeometryTransformer.h"
22 #include "AliMUONPCBPainter.h"
23 #include "AliMUONPainterContour.h"
24 #include "AliMUONPainterHelper.h"
25 #include "AliMUONVCalibParam.h"
26 #include "AliMUONVTrackerData.h"
27 #include "AliMUONObjectPair.h"
28 #include "AliMpDDLStore.h"
29 #include "AliMpDEManager.h"
30 #include "AliMpDetElement.h"
32 #include "AliMpSector.h"
33 #include "AliMpSlat.h"
35 #include <TObjString.h>
37 /// \class AliMUONDEPainter
39 /// Painter for one detection element
41 /// It draws a given plane (bending or non bending) of a given detection element
43 /// \author Laurent Aphecetche, Subatech
46 ClassImp(AliMUONDEPainter)
49 //_____________________________________________________________________________
50 AliMUONDEPainter::AliMUONDEPainter()
57 //_____________________________________________________________________________
58 AliMUONDEPainter::AliMUONDEPainter(const AliMUONAttPainter& att, Int_t detElemId)
59 : AliMUONVPainter("DE"),
64 AliMUONAttPainter deAtt(att);
66 if ( att.IsCathodeDefined() )
68 AliMp::CathodType cathodType = ( att.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ;
70 Bool_t cath0 = ( cathodType == AliMp::kCath0 ) ;
72 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodType);
74 Bool_t bending = ( planeType == AliMp::kBendingPlane );
76 deAtt.SetCathode(cath0,!cath0);
77 deAtt.SetPlane(bending,!bending);
81 if ( att.IsPlaneDefined() )
83 AliMp::PlaneType planeType = ( att.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
85 Bool_t bending = ( planeType == AliMp::kBendingPlane );
87 Bool_t cath0 = ( AliMpDEManager::GetCathod(detElemId,planeType) == AliMp::kCath0 );
89 deAtt.SetCathode(cath0,!cath0);
90 deAtt.SetPlane(bending,!bending);
94 deAtt.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
98 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
101 SetName(h->DEName(fDetElemId).Data());
102 SetPathName(h->DEPathName(fDetElemId).Data());
104 AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
108 if ( AliMpDEManager::GetStationType(DetElemId()) == AliMp::kStation345 )
110 const AliMpSlat* slat = h->GetSlat(DetElemId(),planeType);
112 for ( Int_t i = 0; i < slat->GetSize(); ++i )
114 Add(new AliMUONPCBPainter(Attributes(),DetElemId(),i));
117 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,x,y,z);
119 else if ( AliMpDEManager::GetStationType(DetElemId()) != AliMp::kStationTrigger )
121 const AliMpSector* sector = h->GetSector(DetElemId(),planeType);
123 Double_t xl(sector->Dimensions().X());
124 Double_t yl(sector->Dimensions().Y());
126 h->Local2Global(fDetElemId,xl,yl,0.0,x,y,z);
130 AliFatal("Not implemented for trigger !!!");
133 AliMUONPainterContour* contour = h->GetContour(ContourName());
135 TObjArray contourArray;
137 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId);
139 AliDebug(1,Form("de %p n %d",de,de->GetNofBusPatches()));
141 for ( Int_t i = 0; i < de->GetNofBusPatches(); ++i )
143 AliMUONBusPatchPainter* painter = new AliMUONBusPatchPainter(Attributes(),de->GetBusPatchId(i));
145 if ( !painter->IsValid() )
147 AliDebug(1,Form("Skipping BP %d which seem to have no manu in plane %s",
148 de->GetBusPatchId(i),
149 Attributes().IsBendingPlane() ? "bending" : "non bending"));
160 contourArray.Add(painter->Contour());
166 contour = h->MergeContours(contourArray,ContourName());
169 AliError(Form("%s : could not merge those contours",Name().Data()));
170 StdoutToAliError(contourArray.Print(););
177 //_____________________________________________________________________________
178 AliMUONDEPainter::AliMUONDEPainter(const AliMUONDEPainter& rhs):
179 AliMUONVPainter(rhs), fDetElemId(-1)
185 //_____________________________________________________________________________
187 AliMUONDEPainter::operator=(const AliMUONDEPainter& rhs)
189 /// assignment operator
197 //_____________________________________________________________________________
198 AliMUONDEPainter::~AliMUONDEPainter()
203 //_____________________________________________________________________________
205 AliMUONDEPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
206 Double_t& dataMin, Double_t& dataMax) const
208 /// Compute the data range spanned by this detection element
209 dataMin = dataMax = data.DetectionElement(fDetElemId, dataIndex);
212 //_____________________________________________________________________________
214 AliMUONDEPainter::Copy(TObject& object) const
216 /// Copy this to object
217 AliMUONVPainter::Copy((AliMUONVPainter&)(object));
218 ((AliMUONDEPainter&)(object)).fDetElemId = fDetElemId;
221 //_____________________________________________________________________________
223 AliMUONDEPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
226 /// Describe data at this detection element
228 if (!data.HasDetectionElement(fDetElemId)) return "";
230 Double_t value = data.DetectionElement(fDetElemId,dataIndex);
232 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
235 //_____________________________________________________________________________
237 AliMUONDEPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
238 Double_t min, Double_t max)
240 /// Paint the area of this detection element
242 if (!data.HasDetectionElement(fDetElemId)) return;
244 Double_t value = data.DetectionElement(fDetElemId,dataIndex);
246 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
248 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
250 Contour()->PaintArea(color);
253 //_____________________________________________________________________________
255 AliMUONDEPainter::Validate(const AliMUONAttPainter& attributes) const
257 /// Normalize attributes
259 AliMUONAttPainter norm(attributes);
261 norm.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
263 if ( norm.IsCathodeDefined() && !norm.IsPlaneDefined() )
265 // only cathode known : derive the plane
267 AliMp::CathodType cathodType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 );
269 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathodType);
271 Bool_t bending = ( planeType == AliMp::kBendingPlane ) ;
273 norm.SetPlane(bending,!bending);
276 else if ( !norm.IsCathodeDefined() && norm.IsPlaneDefined() )
278 // only plane is known : derive the cathode
280 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
282 Bool_t cath0 = ( AliMpDEManager::GetCathod(fDetElemId,planeType) == AliMp::kCath0 );
284 norm.SetCathode(cath0,!cath0);
288 // check that both information are compatible
290 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
292 AliMp::CathodType cathode = AliMpDEManager::GetCathod(fDetElemId,planeType);
294 if ( cathode == AliMp::kCath0 && norm.IsCathode1() ||
295 cathode == AliMp::kCath1 && norm.IsCathode0() )
297 norm.SetValid(kFALSE);