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 "AliMUONPainterPadStore.h"
20 #include "AliMUONCalibParamND.h"
21 #include "AliMUON2DMap.h"
22 #include "AliMUONVStore.h"
23 #include "AliMUONVDigit.h"
25 #include <Riostream.h>
29 ///\class AliMUONPainterPadStore
31 /// Container for pads
33 ///\author Laurent Aphecetche, Subatech
38 ClassImp(AliMUONPainterPadStore)
41 //_____________________________________________________________________________
42 AliMUONPainterPadStore::AliMUONPainterPadStore(TRootIOCtor* /*dummy*/) : TObject(),
48 //_____________________________________________________________________________
49 AliMUONPainterPadStore::AliMUONPainterPadStore() : TObject(),
50 fPadStore(new AliMUON2DMap(kTRUE))
55 //_____________________________________________________________________________
56 AliMUONPainterPadStore::~AliMUONPainterPadStore()
62 //_____________________________________________________________________________
64 AliMUONPainterPadStore::FindPadID(const TArrayI& pads, Double_t x, Double_t y) const
66 /// Find, in array of pads, the one which contains (x,y). Returns -1 if not
69 for ( Int_t i = 0; i < pads.GetSize(); ++i )
71 Int_t id = pads.At(i);
76 GetPadGeometry(id,position,dimensions);
78 TVector2 bl(position-dimensions);
79 TVector2 ur(position+dimensions);
80 if ( bl.X() <= x && ur.X() >= x && bl.Y() <= y && ur.Y() >= y )
89 //_____________________________________________________________________________
91 AliMUONPainterPadStore::Get(Int_t detElemId, Int_t manuId) const
93 /// Get the pad container for a given manu
95 AliMUONVCalibParam* param =
96 static_cast<AliMUONVCalibParam*>(fPadStore->FindObject(detElemId,manuId));
100 param = new AliMUONCalibParamND(4,64,detElemId,manuId,-1.0);
101 fPadStore->Add(param);
107 //_____________________________________________________________________________
109 AliMUONPainterPadStore::GetBoundaries(const TArrayI& pads,
113 Double_t& ymax) const
115 /// Get the area covered by an array of pads
120 for ( Int_t i = 0; i < pads.GetSize(); ++i )
122 Int_t id = pads.At(i);
127 GetPadGeometry(id,position,dimensions);
129 TVector2 bl(position-dimensions);
130 TVector2 ur(position+dimensions);
131 xmin = TMath::Min(xmin,bl.X());
132 ymin = TMath::Min(ymin,bl.Y());
133 xmax = TMath::Max(xmax,ur.X());
134 ymax = TMath::Max(ymax,ur.Y());
138 //_____________________________________________________________________________
140 AliMUONPainterPadStore::GetPadGeometry(Int_t padId,
142 TVector2& dimensions) const
144 /// Get the geomtry of one pad
148 AliError(Form("padId is < 0 : %d",padId));
149 position.Set(0.0,0.0);
150 dimensions.Set(-1.0,-1.0);
154 Int_t detElemId = AliMUONVDigit::DetElemId(padId);
155 Int_t manuId = AliMUONVDigit::ManuId(padId);
156 Int_t manuChannel = AliMUONVDigit::ManuChannel(padId);
158 AliMUONVCalibParam* param =
159 static_cast<AliMUONVCalibParam*>(fPadStore->FindObject(detElemId,manuId));
163 AliError(Form("Could not find object DE %d manu %d",detElemId,manuId));
164 position.Set(0.0,0.0);
165 dimensions.Set(-1.0,-1.0);
169 position.Set(param->ValueAsDouble(manuChannel,0),
170 param->ValueAsDouble(manuChannel,1));
172 dimensions.Set(param->ValueAsDouble(manuChannel,2),
173 param->ValueAsDouble(manuChannel,3));
175 AliDebug(3,Form("DE %4d Manu %4d Channel %2d Pos %e %e Dim %e %e",
176 detElemId,manuId,manuChannel,
177 position.X(),position.Y(),
178 dimensions.X(),dimensions.Y()));
181 //_____________________________________________________________________________
183 AliMUONPainterPadStore::GetSize() const
185 /// Get the number of pads we handle
187 TIter next(fPadStore->CreateIterator());
188 AliMUONVCalibParam* param;
191 while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
193 for ( Int_t i = 0; i < param->Size(); ++i )
195 if ( param->ValueAsDouble(i,2) >= 0 && param->ValueAsDouble(i,3) >= 0 )
205 //_____________________________________________________________________________
207 AliMUONPainterPadStore::PrintPads(const TArrayI& pads) const
210 cout << "n=" << pads.GetSize() << endl;
212 for ( Int_t i = 0; i < pads.GetSize(); ++i )
214 Int_t id = pads.At(i);
215 TVector2 position, dimensions;
216 GetPadGeometry(id,position,dimensions);
217 cout << Form("i %4d DE %4d ManuID %4d ManuChannel %2d (X,Y)=(%7.3f,%7.3f)"
218 " (DX,DY)=(%7.3f,%7.3f)",
220 AliMUONVDigit::DetElemId(id),
221 AliMUONVDigit::ManuId(id),
222 AliMUONVDigit::ManuChannel(id),
223 position.X(),position.Y(),
224 dimensions.X(),dimensions.Y()) << endl;