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 "AliMUONContour.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(TRootIOCtor* ioCtor)
59 : AliMUONVPainter(ioCtor),
62 /// default streaming ctor
65 //_____________________________________________________________________________
66 AliMUONDEPainter::AliMUONDEPainter(const AliMUONAttPainter& att, Int_t detElemId)
67 : AliMUONVPainter("DE"),
72 AliMUONAttPainter deAtt(att);
74 if ( att.IsCathodeDefined() )
76 AliMp::CathodType cathodType = ( att.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ;
78 Bool_t cath0 = ( cathodType == AliMp::kCath0 ) ;
80 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodType);
82 Bool_t bending = ( planeType == AliMp::kBendingPlane );
84 deAtt.SetCathode(cath0,!cath0);
85 deAtt.SetPlane(bending,!bending);
89 if ( att.IsPlaneDefined() )
91 AliMp::PlaneType planeType = ( att.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
93 Bool_t bending = ( planeType == AliMp::kBendingPlane );
95 Bool_t cath0 = ( AliMpDEManager::GetCathod(detElemId,planeType) == AliMp::kCath0 );
97 deAtt.SetCathode(cath0,!cath0);
98 deAtt.SetPlane(bending,!bending);
102 deAtt.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
104 SetAttributes(deAtt);
106 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
109 SetName(h->DEName(fDetElemId).Data());
110 SetPathName(h->DEPathName(fDetElemId).Data());
112 AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
116 if ( AliMpDEManager::GetStationType(DetElemId()) == AliMp::kStation345 )
118 const AliMpSlat* slat = h->GetSlat(DetElemId(),planeType);
120 for ( Int_t i = 0; i < slat->GetSize(); ++i )
122 Add(new AliMUONPCBPainter(Attributes(),DetElemId(),i));
125 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,x,y,z);
127 else if ( AliMpDEManager::GetStationType(DetElemId()) != AliMp::kStationTrigger )
129 const AliMpSector* sector = h->GetSector(DetElemId(),planeType);
131 Double_t xl(sector->GetDimensionX());
132 Double_t yl(sector->GetDimensionY());
134 h->Local2Global(fDetElemId,xl,yl,0.0,x,y,z);
138 AliFatal("Not implemented for trigger !!!");
141 AliMUONContour* contour = h->GetContour(ContourName());
143 TObjArray contourArray;
145 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId);
147 AliDebug(1,Form("de %p n %d",de,de->GetNofBusPatches()));
149 for ( Int_t i = 0; i < de->GetNofBusPatches(); ++i )
151 AliMUONBusPatchPainter* painter = new AliMUONBusPatchPainter(Attributes(),de->GetBusPatchId(i));
153 if ( !painter->IsValid() )
155 AliDebug(1,Form("Skipping BP %d which seem to have no manu in plane %s",
156 de->GetBusPatchId(i),
157 Attributes().IsBendingPlane() ? "bending" : "non bending"));
168 contourArray.Add(painter->Contour());
174 contour = h->MergeContours(contourArray,ContourName());
177 AliError(Form("%s : could not merge those contours",Name().Data()));
178 StdoutToAliError(contourArray.Print(););
185 //_____________________________________________________________________________
186 AliMUONDEPainter::AliMUONDEPainter(const AliMUONDEPainter& rhs):
187 AliMUONVPainter(rhs), fDetElemId(-1)
193 //_____________________________________________________________________________
195 AliMUONDEPainter::operator=(const AliMUONDEPainter& rhs)
197 /// assignment operator
205 //_____________________________________________________________________________
206 AliMUONDEPainter::~AliMUONDEPainter()
211 //_____________________________________________________________________________
213 AliMUONDEPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
214 Double_t& dataMin, Double_t& dataMax) const
216 /// Compute the data range spanned by this detection element
217 dataMin = dataMax = data.DetectionElement(fDetElemId, dataIndex);
220 //_____________________________________________________________________________
222 AliMUONDEPainter::Copy(TObject& object) const
224 /// Copy this to object
225 AliMUONVPainter::Copy((AliMUONVPainter&)(object));
226 ((AliMUONDEPainter&)(object)).fDetElemId = fDetElemId;
229 //_____________________________________________________________________________
231 AliMUONDEPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
234 /// Describe data at this detection element
236 if (!data.HasDetectionElement(fDetElemId)) return "";
238 Double_t value = data.DetectionElement(fDetElemId,dataIndex);
240 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
243 //_____________________________________________________________________________
245 AliMUONDEPainter::FillManuList(TObjArray& manuList) const
247 /// Fill (append to) manu list
248 TIter next(Children());
251 while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
253 if ( p->IsA() == AliMUONBusPatchPainter::Class() )
255 // Only consider bus patch painters (and not PCB ones),
256 // in order not to double count some manus
257 p->FillManuList(manuList);
262 //_____________________________________________________________________________
264 AliMUONDEPainter::IsIncluded() const
266 /// whether this detection element is included in the readout or not
267 return ( InteractiveReadOutConfig()->DetectionElement(fDetElemId) > 0 );
270 //_____________________________________________________________________________
272 AliMUONDEPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
273 Double_t min, Double_t max)
275 /// Paint the area of this detection element
277 if (!data.HasDetectionElement(fDetElemId)) return;
279 Double_t value = data.DetectionElement(fDetElemId,dataIndex);
281 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
283 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
288 //_____________________________________________________________________________
290 AliMUONDEPainter::Validate(const AliMUONAttPainter& attributes) const
292 /// Normalize attributes
294 AliMUONAttPainter norm(attributes);
296 norm.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
298 if ( norm.IsCathodeDefined() && !norm.IsPlaneDefined() )
300 // only cathode known : derive the plane
302 AliMp::CathodType cathodType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 );
304 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathodType);
306 Bool_t bending = ( planeType == AliMp::kBendingPlane ) ;
308 norm.SetPlane(bending,!bending);
311 else if ( !norm.IsCathodeDefined() && norm.IsPlaneDefined() )
313 // only plane is known : derive the cathode
315 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
317 Bool_t cath0 = ( AliMpDEManager::GetCathod(fDetElemId,planeType) == AliMp::kCath0 );
319 norm.SetCathode(cath0,!cath0);
323 // check that both information are compatible
325 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
327 AliMp::CathodType cathode = AliMpDEManager::GetCathod(fDetElemId,planeType);
329 if ( (cathode == AliMp::kCath0 && norm.IsCathode1()) ||
330 (cathode == AliMp::kCath1 && norm.IsCathode0()) )
332 norm.SetValid(kFALSE);