]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPCBPainter.cxx
First big commit of the mchview program and its accompanying library,
[u/mrichter/AliRoot.git] / MUON / AliMUONPCBPainter.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
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 **************************************************************************/
15
16 // $Id$
17
18 /// \class AliMUONPCBPainter
19 ///
20 /// Implementation of AliMUONVPainter for slat's PCBs
21 /// 
22 /// \author Laurent Aphecetche, Subatech
23
24 #include "AliMUONPCBPainter.h"
25
26 #include "AliMUONManuPainter.h"
27 #include "AliMUONPainterContour.h"
28 #include "AliMUONPainterHelper.h"
29 #include "AliMUONVCalibParam.h"
30 #include "AliMUONVTrackerData.h"
31 #include "AliMpDEManager.h"
32 #include "AliMpMotifPosition.h"
33 #include "AliMpPCB.h"
34 #include "AliMpPlaneType.h"
35 #include "AliMpSlat.h"
36 #include "AliLog.h"
37
38 /// \cond(CLASSIMP)
39 ClassImp(AliMUONPCBPainter)
40 /// \endcond
41
42 //_____________________________________________________________________________
43 AliMUONPCBPainter::AliMUONPCBPainter()
44 : AliMUONVPainter(),
45 fDetElemId(-1),
46 fPCBIndex(-1)
47 {
48   /// empty ctor
49 }
50
51 //_____________________________________________________________________________
52 AliMUONPCBPainter::AliMUONPCBPainter(const AliMUONAttPainter& att,
53                                      Int_t detElemId,
54                                      Int_t pcbNumber)
55 : AliMUONVPainter("PCB"),
56   fDetElemId(detElemId),
57   fPCBIndex(pcbNumber)
58 {
59     /// Ctor
60
61     SetAttributes(att);
62     
63     AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
64     
65     AliMp::PlaneType planeType = ( att.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
66     
67     const AliMpSlat* slat = AliMUONPainterHelper::Instance()->GetSlat(fDetElemId,planeType);
68     
69     SetID(detElemId,pcbNumber);
70     SetName(h->PCBName(pcbNumber));
71     SetPathName(h->PCBPathName(detElemId,pcbNumber));
72     
73     AliMpPCB* pcb = slat->GetPCB(fPCBIndex);
74     
75     AliMUONPainterContour* contour = h->GetContour(ContourName());
76     TObjArray contourArray;
77     
78     for ( Int_t imp = 0 ; imp < pcb->GetSize(); ++imp ) 
79     {
80       AliMpMotifPosition* mp = pcb->GetMotifPosition(imp);
81       AliDebug(1,Form("Adding manu %d to PCB %d of DE %d",
82                       mp->GetID(),fPCBIndex,fDetElemId));
83       AliMUONVPainter* painter = new AliMUONManuPainter(Attributes(),fDetElemId,mp->GetID());
84       Add(painter);
85       if (!contour)
86       {
87         contourArray.Add(painter->Contour());
88       }
89     }
90     
91     Double_t x,y,z;
92     
93     h->Local2Global(fDetElemId,
94                                                    pcb->X()-slat->Position().X(),
95                                                    pcb->Y()-slat->Position().Y(),
96                                                    0.0,
97                                                    x,y,z);
98     
99     if (!contour)
100     {
101       contour = h->MergeContours(contourArray,ContourName());
102     }
103     
104     SetContour(contour);
105 }
106
107 //_____________________________________________________________________________
108 AliMUONPCBPainter::~AliMUONPCBPainter()
109 {
110   /// dtor
111 }
112
113 //_____________________________________________________________________________
114 AliMUONPCBPainter::AliMUONPCBPainter(const AliMUONPCBPainter& rhs)
115 : AliMUONVPainter(rhs),
116   fDetElemId(-1),
117   fPCBIndex(-1)
118 {
119     /// copy ctor
120     rhs.Copy(*this);
121 }
122
123 //_____________________________________________________________________________
124 AliMUONPCBPainter&
125 AliMUONPCBPainter::operator=(const AliMUONPCBPainter& rhs)
126 {
127   /// assignment operator
128   if ( this != &rhs )
129   {
130     rhs.Copy(*this);
131   }
132   return *this;
133 }
134
135 //_____________________________________________________________________________
136 void 
137 AliMUONPCBPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, 
138                                    Double_t& dataMin, Double_t& dataMax) const
139 {
140   /// Compute the min and max of this PCB data 
141   dataMin = dataMax = data.PCB(fDetElemId, fPCBIndex,dataIndex);
142 }
143
144 //_____________________________________________________________________________
145 void
146 AliMUONPCBPainter::Copy(TObject& object) const
147 {
148   /// Copy this to object
149   AliMUONVPainter::Copy((AliMUONVPainter&)(object));
150   ((AliMUONPCBPainter&)(object)).fDetElemId = fDetElemId;
151   ((AliMUONPCBPainter&)(object)).fPCBIndex = fPCBIndex;
152 }
153
154 //_____________________________________________________________________________
155 void
156 AliMUONPCBPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
157                             Double_t min, Double_t max)
158 {
159   /// Fill the contour of this PCB with a color depending of the value of the data
160   if (!data.HasPCB(fDetElemId,fPCBIndex)) return;
161   
162   Double_t value = data.PCB(fDetElemId,fPCBIndex,dataIndex);
163   
164   if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
165   
166   Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
167   
168   Contour()->PaintArea(color);
169 }
170