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"
36 #include <TObjString.h>
37 #include "AliMUONPainterGroup.h"
39 /// \class AliMUONDEPainter
41 /// Painter for one detection element
43 /// It draws a given plane (bending or non bending) of a given detection element
45 /// \author Laurent Aphecetche, Subatech
48 ClassImp(AliMUONDEPainter)
51 //_____________________________________________________________________________
52 AliMUONDEPainter::AliMUONDEPainter()
59 //_____________________________________________________________________________
60 AliMUONDEPainter::AliMUONDEPainter(TRootIOCtor* ioCtor)
61 : AliMUONVPainter(ioCtor),
64 /// default streaming ctor
67 //_____________________________________________________________________________
68 AliMUONDEPainter::AliMUONDEPainter(const AliMUONAttPainter& att, Int_t detElemId)
69 : AliMUONVPainter("DE"),
74 AliMUONAttPainter deAtt(att);
76 if ( att.IsCathodeDefined() )
78 AliMp::CathodType cathodType = ( att.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ;
80 Bool_t cath0 = ( cathodType == AliMp::kCath0 ) ;
82 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodType);
84 Bool_t bending = ( planeType == AliMp::kBendingPlane );
86 deAtt.SetCathode(cath0,!cath0);
87 deAtt.SetPlane(bending,!bending);
91 if ( att.IsPlaneDefined() )
93 AliMp::PlaneType planeType = ( att.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
95 Bool_t bending = ( planeType == AliMp::kBendingPlane );
97 Bool_t cath0 = ( AliMpDEManager::GetCathod(detElemId,planeType) == AliMp::kCath0 );
99 deAtt.SetCathode(cath0,!cath0);
100 deAtt.SetPlane(bending,!bending);
104 deAtt.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
106 SetAttributes(deAtt);
108 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
111 SetName(h->DEName(fDetElemId).Data());
112 SetPathName(h->DEPathName(fDetElemId).Data());
114 AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
118 if ( AliMpDEManager::GetStationType(DetElemId()) == AliMp::kStation345 )
120 const AliMpSlat* slat = h->GetSlat(DetElemId(),planeType);
122 for ( Int_t i = 0; i < slat->GetSize(); ++i )
124 Add(new AliMUONPCBPainter(Attributes(),DetElemId(),i));
127 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,x,y,z);
129 else if ( AliMpDEManager::GetStationType(DetElemId()) != AliMp::kStationTrigger )
131 const AliMpSector* sector = h->GetSector(DetElemId(),planeType);
133 Double_t xl(sector->GetDimensionX());
134 Double_t yl(sector->GetDimensionY());
136 h->Local2Global(fDetElemId,xl,yl,0.0,x,y,z);
140 AliFatal("Not implemented for trigger !!!");
143 AliMUONContour* contour = h->GetContour(ContourName());
145 TObjArray contourArray;
147 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId);
149 AliDebug(1,Form("de %p n %d",de,de->GetNofBusPatches()));
151 for ( Int_t i = 0; i < de->GetNofBusPatches(); ++i )
153 AliMUONBusPatchPainter* painter = new AliMUONBusPatchPainter(Attributes(),de->GetBusPatchId(i));
155 if ( !painter->IsValid() )
157 AliDebug(1,Form("Skipping BP %d which seem to have no manu in plane %s",
158 de->GetBusPatchId(i),
159 Attributes().IsBendingPlane() ? "bending" : "non bending"));
170 contourArray.Add(painter->Contour());
176 contour = h->MergeContours(contourArray,ContourName());
179 AliError(Form("%s : could not merge those contours",Name().Data()));
180 StdoutToAliError(contourArray.Print(););
187 //_____________________________________________________________________________
188 AliMUONDEPainter::AliMUONDEPainter(const AliMUONDEPainter& rhs):
189 AliMUONVPainter(rhs), fDetElemId(-1)
195 //_____________________________________________________________________________
197 AliMUONDEPainter::operator=(const AliMUONDEPainter& rhs)
199 /// assignment operator
207 //_____________________________________________________________________________
208 AliMUONDEPainter::~AliMUONDEPainter()
213 //_____________________________________________________________________________
215 AliMUONDEPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
216 Double_t& dataMin, Double_t& dataMax) const
218 /// Compute the data range spanned by this detection element
219 dataMin = dataMax = data.DetectionElement(fDetElemId, dataIndex);
222 //_____________________________________________________________________________
224 AliMUONDEPainter::Copy(TObject& object) const
226 /// Copy this to object
227 AliMUONVPainter::Copy((AliMUONVPainter&)(object));
228 ((AliMUONDEPainter&)(object)).fDetElemId = fDetElemId;
231 //_____________________________________________________________________________
233 AliMUONDEPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
236 /// Describe data at this detection element
238 if (!data.HasDetectionElement(fDetElemId)) return "";
240 Double_t value = data.DetectionElement(fDetElemId,dataIndex);
242 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
245 //_____________________________________________________________________________
247 AliMUONDEPainter::FillManuList(TObjArray& manuList) const
249 /// Fill (append to) manu list
250 TIter next(Children());
253 while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
255 if ( p->IsA() == AliMUONBusPatchPainter::Class() )
257 // Only consider bus patch painters (and not PCB ones),
258 // in order not to double count some manus
259 p->FillManuList(manuList);
264 //_____________________________________________________________________________
266 AliMUONDEPainter::IsIncluded() const
268 /// whether this detection element is included in the readout or not
269 return ( InteractiveReadOutConfig()->DetectionElement(fDetElemId) > 0 );
272 //_____________________________________________________________________________
274 AliMUONDEPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
275 Double_t min, Double_t max)
277 /// Paint the area of this detection element
279 if (!data.HasDetectionElement(fDetElemId)) return;
281 Double_t value = data.DetectionElement(fDetElemId,dataIndex);
283 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
285 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
290 //_____________________________________________________________________________
292 AliMUONDEPainter::Validate(const AliMUONAttPainter& attributes) const
294 /// Normalize attributes
296 AliMUONAttPainter norm(attributes);
298 norm.SetCathodeAndPlaneMutuallyExclusive(kFALSE);
300 if ( norm.IsCathodeDefined() && !norm.IsPlaneDefined() )
302 // only cathode known : derive the plane
304 AliMp::CathodType cathodType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 );
306 AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathodType);
308 Bool_t bending = ( planeType == AliMp::kBendingPlane ) ;
310 norm.SetPlane(bending,!bending);
313 else if ( !norm.IsCathodeDefined() && norm.IsPlaneDefined() )
315 // only plane is known : derive the cathode
317 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
319 Bool_t cath0 = ( AliMpDEManager::GetCathod(fDetElemId,planeType) == AliMp::kCath0 );
321 norm.SetCathode(cath0,!cath0);
325 // check that both information are compatible
327 AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
329 AliMp::CathodType cathode = AliMpDEManager::GetCathod(fDetElemId,planeType);
331 if ( (cathode == AliMp::kCath0 && norm.IsCathode1()) ||
332 (cathode == AliMp::kCath1 && norm.IsCathode0()) )
334 norm.SetValid(kFALSE);
341 //_____________________________________________________________________________
343 AliMUONDEPainter::SetResponder(Int_t depth)
345 /// Select as responder the *first* group that has a given depth
347 AliDebug(1,Form("depth=%d",depth));
354 TIter next(fPainterGroups);
357 fResponderGroup = 0x0;
359 while ( ( str = static_cast<TObjString*>(next()) ) )
361 AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(str));
362 if ( str->String() == "BUSPATCH" )
364 AliDebug(1,Form("group %s is indeed buspatch, using as responder %d",
365 group->Type(),depth));
366 group->SetResponder(kTRUE);
367 fResponderGroup = group;
372 group->SetResponder(kFALSE);