]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONManuPainter.cxx
No effc++ warnings in RALICE
[u/mrichter/AliRoot.git] / MUON / AliMUONManuPainter.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 #include "AliMUONManuPainter.h"
19
20 #include "AliMUONManuPadPainter.h"
21 #include "AliMUONPainterContour.h"
22 #include "AliMUONPainterHelper.h"
23 #include "AliMUONVCalibParam.h"
24 #include "AliMUONVDigit.h"
25 #include "AliMUONVTrackerData.h"
26 #include "AliMpDEManager.h"
27 #include "AliMpManuUID.h"
28 #include "AliMpMotifPosition.h"
29 #include "AliMpMotifType.h"
30 #include "AliMpSlat.h"
31 #include "AliMpStationType.h"
32 #include "AliMpVMotif.h"
33 #include "AliMpVPadIterator.h"
34 #include "AliLog.h"
35 #include <TArrayI.h>
36 #include <float.h>
37
38 ///\class AliMUONManuPainter
39 ///
40 /// Implementation of AliMUONVPainter for one manu (not the pads, only the manu
41 /// itself).
42 ///
43 ///\author Laurent Aphecetche, Subatech
44
45 ///\cond CLASSIMP
46 ClassImp(AliMUONManuPainter)
47 ///\endcond
48
49 //_____________________________________________________________________________
50 AliMUONManuPainter::AliMUONManuPainter()
51 : AliMUONVPainter(),
52 fDetElemId(-1),
53 fManuId(-1)
54 {
55   /// ctor
56 }
57
58 //_____________________________________________________________________________
59 AliMUONManuPainter::AliMUONManuPainter(const AliMUONAttPainter& att,
60                                        Int_t detElemId,
61                                        Int_t manuId)
62 : AliMUONVPainter("MANU"),
63   fDetElemId(detElemId),
64   fManuId(manuId)
65 {
66     /// ctor
67     
68     SetAttributes(att);
69     
70     AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
71     
72     SetID(detElemId,manuId);
73     SetName(h->ManuName(manuId));
74     SetPathName(h->ManuPathName(detElemId,manuId));
75     
76     AliMpMotifPosition* mp = h->GetMotifPosition(detElemId,manuId);
77     
78     if (!mp)
79     {
80       AliFatal(Form("Could not get manuId %04d from DE %04d",manuId,detElemId));
81     }
82     
83     Double_t x,y,z;
84     
85     AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
86     
87     if ( stationType == AliMp::kStation345 ) 
88     {
89       const AliMpSlat* slat = AliMUONPainterHelper::Instance()->GetSlat(detElemId,manuId);
90       
91       h->Local2Global(fDetElemId,
92                       mp->Position().X() -slat->Position().X(),
93                       mp->Position().Y() -slat->Position().Y(),
94                       0,
95                       x,y,z);
96     }
97     else if ( stationType != AliMp::kStationTrigger ) 
98     {
99       h->Local2Global(fDetElemId,
100                       mp->Position().X(),
101                       mp->Position().Y(),
102                       0,
103                       x,y,z);      
104     }
105     else
106     {
107       AliError("Hu ho. Not supposed to be used for trigger !");
108       Invalidate();
109       return;
110     }
111     
112     AliMUONPainterContour* contour = h->GetContour(ContourName());
113     
114     if (!contour)
115     {
116       contour = h->GenerateManuContour(fDetElemId,
117                                        fManuId,
118                                        Attributes(),
119                                        ContourName());
120     }
121     SetContour(contour);
122     
123     Add(new AliMUONManuPadPainter(*this,fDetElemId,fManuId));
124 }
125
126 //_____________________________________________________________________________
127 AliMUONManuPainter::AliMUONManuPainter(const AliMUONManuPainter& rhs)
128 : AliMUONVPainter(rhs), fDetElemId(-1), fManuId(-1)
129 {
130   /// copy ctor
131   rhs.Copy(*this);
132 }
133
134 //_____________________________________________________________________________
135 AliMUONManuPainter&
136 AliMUONManuPainter::operator=(const AliMUONManuPainter& rhs)
137 {
138   /// assignment operator
139   if ( this != &rhs ) 
140   {
141     rhs.Copy(*this);
142   }
143   return *this;
144 }
145
146 //_____________________________________________________________________________
147 AliMUONManuPainter::~AliMUONManuPainter()
148 {
149   /// dtor
150 }
151
152 //_____________________________________________________________________________
153 void 
154 AliMUONManuPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, 
155                                      Double_t& dataMin, Double_t& dataMax) const
156 {
157   /// Compute data range spanned by this manu
158   dataMin = dataMax = data.Manu(fDetElemId, fManuId, dataIndex);
159 }
160
161
162 //_____________________________________________________________________________
163 void
164 AliMUONManuPainter::Copy(TObject& object) const
165 {
166   /// copyy this to object
167   AliMUONVPainter::Copy((AliMUONVPainter&)(object));
168   ((AliMUONManuPainter&)(object)).fDetElemId = fDetElemId;
169   ((AliMUONManuPainter&)(object)).fManuId = fManuId;
170 }
171
172 //_____________________________________________________________________________
173 TString
174 AliMUONManuPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
175                              Double_t, Double_t)
176 {
177   /// Describe data at this manu
178   
179   if (!data.HasManu(fDetElemId,fManuId)) return "";
180   
181   Double_t value = data.Manu(fDetElemId,fManuId,dataIndex);
182   
183   return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
184 }
185
186 //_____________________________________________________________________________
187 void
188 AliMUONManuPainter::FillManuList(TObjArray& manuList) const
189 {
190   /// Append our manu to the list
191   manuList.Add(new AliMpManuUID(fDetElemId,fManuId));
192 }
193
194 //_____________________________________________________________________________
195 void
196 AliMUONManuPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
197                               Double_t min, Double_t max)
198 {
199   /// Paint area of this manu according to data
200   
201   if (!data.HasManu(fDetElemId,fManuId)) return;
202
203   Double_t value = data.Manu(fDetElemId,fManuId,dataIndex);
204   
205   if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
206   
207   Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
208   
209   Contour()->PaintArea(color);
210 }
211
212 //_____________________________________________________________________________
213 AliMUONAttPainter
214 AliMUONManuPainter::Validate(const AliMUONAttPainter& attributes) const
215 {
216   /// Normalize the attributes
217   
218   /// check that cathode and plane are up-to-date, and that they are legal
219   
220   AliMUONAttPainter norm(attributes);
221
222   norm.SetValid(kFALSE);
223   
224   if ( norm.IsCathodeDefined() ) 
225   {
226     if ( norm.IsCathode0() != Attributes().IsCathode0() ) return norm;
227   }
228   
229   if ( norm.IsPlaneDefined() ) 
230   {
231     if ( norm.IsBendingPlane() != Attributes().IsBendingPlane() ) return norm;
232   }
233   
234   norm.SetValid(kTRUE);
235   
236   if ( norm.IsCathodeDefined() && !norm.IsPlaneDefined() ) 
237   {
238     // derive plane from cathode
239     
240     AliMp::CathodType cathode = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ;
241
242     AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathode);
243     
244     Bool_t bending = ( planeType == AliMp::kBendingPlane );
245     
246     norm.SetPlane(bending,!bending);    
247   }
248   else if ( norm.IsPlaneDefined() && !norm.IsCathodeDefined() )
249   {
250     // derive cathode from plane
251
252     AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
253
254     AliMp::CathodType cathode = AliMpDEManager::GetCathod(fDetElemId,planeType);
255           
256     Bool_t cath0 = ( cathode == AliMp::kCath0 );
257     
258     norm.SetCathode(cath0,!cath0);    
259   }
260   else if ( norm.IsPlaneDefined() && norm.IsCathodeDefined() ) 
261   {
262     // check that cathode and plane matches
263     
264     AliMp::CathodType cathode = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ;
265
266     AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathode);
267     
268     Bool_t bending = ( planeType == AliMp::kBendingPlane );
269     
270     if ( bending != norm.IsBendingPlane() ) 
271     {
272       norm.SetValid(kFALSE);
273     }
274   }
275   
276   return norm;
277 }
278
279