]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONManuPainter.cxx
Fix for savannah bug report 87728 (Laurent) + fix invalid read found with valgrind...
[u/mrichter/AliRoot.git] / MUON / AliMUONManuPainter.cxx
1
2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 *                                                                        *
5 * Author: The ALICE Off-line Project.                                    *
6 * Contributors are mentioned in the code where appropriate.              *
7 *                                                                        *
8 * Permission to use, copy, modify and distribute this software and its   *
9 * documentation strictly for non-commercial purposes is hereby granted   *
10 * without fee, provided that the above copyright notice appears in all   *
11 * copies and that both the copyright notice and this permission notice   *
12 * appear in the supporting documentation. The authors make no claims     *
13 * about the suitability of this software for any purpose. It is          *
14 * provided "as is" without express or implied warranty.                  *
15 **************************************************************************/
16
17 // $Id$
18
19 #include "AliMUONManuPainter.h"
20
21 #include "AliMpDCSNamer.h"
22 #include "AliLog.h"
23 #include "AliMUONContour.h"
24 #include "AliMUONManuContourMaker.h"
25 #include "AliMUONManuPadPainter.h"
26 #include "AliMUONPainterHelper.h"
27 #include "AliMUONVCalibParam.h"
28 #include "AliMUONVDigit.h"
29 #include "AliMUONVTrackerData.h"
30 #include "AliMpDEManager.h"
31 #include "AliMpManuUID.h"
32 #include "AliMpMotifPosition.h"
33 #include "AliMpMotifType.h"
34 #include "AliMpSlat.h"
35 #include "AliMpStationType.h"
36 #include "AliMpVMotif.h"
37 #include "AliMpVPadIterator.h"
38 #include <TArrayI.h>
39 #include <float.h>
40
41 ///\class AliMUONManuPainter
42 ///
43 /// Implementation of AliMUONVPainter for one manu (not the pads, only the manu
44 /// itself).
45 ///
46 ///\author Laurent Aphecetche, Subatech
47
48 ///\cond CLASSIMP
49 ClassImp(AliMUONManuPainter)
50 ///\endcond
51
52 //_____________________________________________________________________________
53 AliMUONManuPainter::AliMUONManuPainter(TRootIOCtor* ioCtor)
54 : AliMUONVPainter(ioCtor),
55 fDetElemId(-1),
56 fManuId(-1)
57 {
58   /// ctor
59 }
60
61 //_____________________________________________________________________________
62 AliMUONManuPainter::AliMUONManuPainter()
63 : AliMUONVPainter(),
64 fDetElemId(-1),
65 fManuId(-1)
66 {
67   /// ctor
68 }
69
70 //_____________________________________________________________________________
71 AliMUONManuPainter::AliMUONManuPainter(const AliMUONAttPainter& att,
72                                        Int_t detElemId,
73                                        Int_t manuId)
74 : AliMUONVPainter("MANU"),
75   fDetElemId(detElemId),
76   fManuId(manuId)
77 {
78     /// ctor
79     
80   SetAttributes(att);
81     
82   AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
83     
84   SetID(detElemId,manuId);
85   SetName(h->ManuName(manuId));
86   SetPathName(h->ManuPathName(detElemId,manuId));
87   
88   
89   AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
90   
91   if ( stationType == AliMp::kStationTrigger ) 
92   {
93     AliError("Hu ho. Not supposed to be used for trigger !");
94     Invalidate();
95     return;    
96   }
97     
98   TString name = AliMUONManuContourMaker::ManuPathName(detElemId, manuId);
99
100   AliMUONContour* contour = h->GetContour(name.Data());
101   
102   if (!contour)
103   {
104     AliError(Form("Could not get manuId %04d from DE %04d (name=%s)",manuId,detElemId,name.Data()));
105   }
106   
107   SetContour(contour);
108   
109   Add(new AliMUONManuPadPainter(*this,fDetElemId,fManuId));
110 }
111
112 //_____________________________________________________________________________
113 AliMUONManuPainter::AliMUONManuPainter(const AliMUONManuPainter& rhs)
114 : AliMUONVPainter(rhs), fDetElemId(-1), fManuId(-1)
115 {
116   /// copy ctor
117   rhs.Copy(*this);
118 }
119
120 //_____________________________________________________________________________
121 AliMUONManuPainter&
122 AliMUONManuPainter::operator=(const AliMUONManuPainter& rhs)
123 {
124   /// assignment operator
125   if ( this != &rhs ) 
126   {
127     rhs.Copy(*this);
128   }
129   return *this;
130 }
131
132 //_____________________________________________________________________________
133 AliMUONManuPainter::~AliMUONManuPainter()
134 {
135   /// dtor
136 }
137
138 //_____________________________________________________________________________
139 void 
140 AliMUONManuPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, 
141                                      Double_t& dataMin, Double_t& dataMax) const
142 {
143   /// Compute data range spanned by this manu
144   dataMin = dataMax = data.Manu(fDetElemId, fManuId, dataIndex);
145 }
146
147
148 //_____________________________________________________________________________
149 void
150 AliMUONManuPainter::Copy(TObject& object) const
151 {
152   /// copyy this to object
153   AliMUONVPainter::Copy((AliMUONVPainter&)(object));
154   ((AliMUONManuPainter&)(object)).fDetElemId = fDetElemId;
155   ((AliMUONManuPainter&)(object)).fManuId = fManuId;
156 }
157
158 //_____________________________________________________________________________
159 TString
160 AliMUONManuPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
161                              Double_t, Double_t)
162 {
163   /// Describe data at this manu
164   
165   if (!data.HasManu(fDetElemId,fManuId)) return "";
166   
167   Double_t value = data.Manu(fDetElemId,fManuId,dataIndex);
168   
169   TString rv = AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
170   
171   if ( TString(data.GetName()).Contains("HV") )
172   {
173     rv += "\n";
174     
175     AliMpDCSNamer hvNamer("TRACKER");
176     
177     if ( AliMpDEManager::GetStationType(fDetElemId) == AliMp::kStation12 )
178     {
179       Int_t sector = hvNamer.ManuId2Sector(fDetElemId,fManuId);
180
181       rv += hvNamer.DCSChannelName(fDetElemId,sector);
182     }
183     else
184     {
185       rv += hvNamer.DCSChannelName(fDetElemId);
186     }
187   }
188   
189   return rv;
190 }
191
192 //_____________________________________________________________________________
193 void
194 AliMUONManuPainter::FillManuList(TObjArray& manuList) const
195 {
196   /// Append our manu to the list
197   manuList.Add(new AliMpManuUID(fDetElemId,fManuId));
198 }
199
200 //_____________________________________________________________________________
201 Bool_t
202 AliMUONManuPainter::IsIncluded() const
203 {
204   /// whether this manu is included in the readout or not
205   return ( InteractiveReadOutConfig()->Manu(fDetElemId,fManuId) > 0 );
206 }
207
208 //_____________________________________________________________________________
209 void
210 AliMUONManuPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
211                               Double_t min, Double_t max)
212 {
213   /// Paint area of this manu according to data
214   
215   if (!data.HasManu(fDetElemId,fManuId)) return;
216
217   Double_t value = data.Manu(fDetElemId,fManuId,dataIndex);
218   
219   if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
220   
221   Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
222   
223   PaintArea(color);
224 }
225
226 //_____________________________________________________________________________
227 AliMUONAttPainter
228 AliMUONManuPainter::Validate(const AliMUONAttPainter& attributes) const
229 {
230   /// Normalize the attributes
231   
232   /// check that cathode and plane are up-to-date, and that they are legal
233   
234   AliMUONAttPainter norm(attributes);
235
236   norm.SetValid(kFALSE);
237   
238   if ( norm.IsCathodeDefined() ) 
239   {
240     if ( norm.IsCathode0() != Attributes().IsCathode0() ) return norm;
241   }
242   
243   if ( norm.IsPlaneDefined() ) 
244   {
245     if ( norm.IsBendingPlane() != Attributes().IsBendingPlane() ) return norm;
246   }
247   
248   norm.SetValid(kTRUE);
249   
250   if ( norm.IsCathodeDefined() && !norm.IsPlaneDefined() ) 
251   {
252     // derive plane from cathode
253     
254     AliMp::CathodType cathode = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ;
255
256     AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathode);
257     
258     Bool_t bending = ( planeType == AliMp::kBendingPlane );
259     
260     norm.SetPlane(bending,!bending);    
261   }
262   else if ( norm.IsPlaneDefined() && !norm.IsCathodeDefined() )
263   {
264     // derive cathode from plane
265
266     AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
267
268     AliMp::CathodType cathode = AliMpDEManager::GetCathod(fDetElemId,planeType);
269           
270     Bool_t cath0 = ( cathode == AliMp::kCath0 );
271     
272     norm.SetCathode(cath0,!cath0);    
273   }
274   else if ( norm.IsPlaneDefined() && norm.IsCathodeDefined() ) 
275   {
276     // check that cathode and plane matches
277     
278     AliMp::CathodType cathode = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ;
279
280     AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathode);
281     
282     Bool_t bending = ( planeType == AliMp::kBendingPlane );
283     
284     if ( bending != norm.IsBendingPlane() ) 
285     {
286       norm.SetValid(kFALSE);
287     }
288   }
289   
290   return norm;
291 }
292
293