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::FillManuList(TObjArray& manuList) const
239 /// Fill (append to) manu list
240 TIter next(Children());
243 while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
245 if ( p->IsA() == AliMUONBusPatchPainter::Class() )
247 // Only consider bus patch painters (and not PCB ones),
248 // in order not to double count some manus
249 p->FillManuList(manuList);
254 //_____________________________________________________________________________
256 AliMUONDEPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
257 Double_t min, Double_t max)
259 /// Paint the area of this detection element
261 if (!data.HasDetectionElement(fDetElemId)) return;
263 Double_t value = data.DetectionElement(fDetElemId,dataIndex);
265 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
267 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
269 Contour()->PaintArea(color);
272 //_____________________________________________________________________________
274 AliMUONDEPainter::Validate(const AliMUONAttPainter& attributes) const
276 /// Normalize attributes
278 AliMUONAttPainter norm(attributes);
280 norm.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
282 if ( norm.IsCathodeDefined() && !norm.IsPlaneDefined() )
284 // only cathode known : derive the plane
286 AliMp::CathodType cathodType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 );
288 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathodType);
290 Bool_t bending = ( planeType == AliMp::kBendingPlane ) ;
292 norm.SetPlane(bending,!bending);
295 else if ( !norm.IsCathodeDefined() && norm.IsPlaneDefined() )
297 // only plane is known : derive the cathode
299 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
301 Bool_t cath0 = ( AliMpDEManager::GetCathod(fDetElemId,planeType) == AliMp::kCath0 );
303 norm.SetCathode(cath0,!cath0);
307 // check that both information are compatible
309 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
311 AliMp::CathodType cathode = AliMpDEManager::GetCathod(fDetElemId,planeType);
313 if ( cathode == AliMp::kCath0 && norm.IsCathode1() ||
314 cathode == AliMp::kCath1 && norm.IsCathode0() )
316 norm.SetValid(kFALSE);