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
36 ClassImp(AliMUONPainterPadStore)
39 //_____________________________________________________________________________
40 AliMUONPainterPadStore::AliMUONPainterPadStore(TRootIOCtor* /*dummy*/) : TObject(),
46 //_____________________________________________________________________________
47 AliMUONPainterPadStore::AliMUONPainterPadStore() : TObject(),
48 fPadStore(new AliMUON2DMap(kTRUE))
53 //_____________________________________________________________________________
54 AliMUONPainterPadStore::~AliMUONPainterPadStore()
60 //_____________________________________________________________________________
62 AliMUONPainterPadStore::FindPadID(const TArrayI& pads, Double_t x, Double_t y) const
64 /// Find, in array of pads, the one which contains (x,y). Returns -1 if not
67 for ( Int_t i = 0; i < pads.GetSize(); ++i )
69 Int_t id = pads.At(i);
74 GetPadGeometry(id,position,dimensions);
76 TVector2 bl(position-dimensions);
77 TVector2 ur(position+dimensions);
78 if ( bl.X() <= x && ur.X() >= x && bl.Y() <= y && ur.Y() >= y )
87 //_____________________________________________________________________________
89 AliMUONPainterPadStore::Get(Int_t detElemId, Int_t manuId) const
91 /// Get the pad container for a given manu
93 AliMUONVCalibParam* param =
94 static_cast<AliMUONVCalibParam*>(fPadStore->FindObject(detElemId,manuId));
98 param = new AliMUONCalibParamND(4,64,detElemId,manuId,-1.0);
99 fPadStore->Add(param);
105 //_____________________________________________________________________________
107 AliMUONPainterPadStore::GetBoundaries(const TArrayI& pads,
111 Double_t& ymax) const
113 /// Get the area covered by an array of pads
118 for ( Int_t i = 0; i < pads.GetSize(); ++i )
120 Int_t id = pads.At(i);
125 GetPadGeometry(id,position,dimensions);
127 TVector2 bl(position-dimensions);
128 TVector2 ur(position+dimensions);
129 xmin = TMath::Min(xmin,bl.X());
130 ymin = TMath::Min(ymin,bl.Y());
131 xmax = TMath::Max(xmax,ur.X());
132 ymax = TMath::Max(ymax,ur.Y());
136 //_____________________________________________________________________________
138 AliMUONPainterPadStore::GetPadGeometry(Int_t padId,
140 TVector2& dimensions) const
142 /// Get the geomtry of one pad
146 AliError(Form("padId is < 0 : %d",padId));
147 position.Set(0.0,0.0);
148 dimensions.Set(-1.0,-1.0);
152 Int_t detElemId = AliMUONVDigit::DetElemId(padId);
153 Int_t manuId = AliMUONVDigit::ManuId(padId);
154 Int_t manuChannel = AliMUONVDigit::ManuChannel(padId);
156 AliMUONVCalibParam* param =
157 static_cast<AliMUONVCalibParam*>(fPadStore->FindObject(detElemId,manuId));
161 AliError(Form("Could not find object DE %d manu %d",detElemId,manuId));
162 position.Set(0.0,0.0);
163 dimensions.Set(-1.0,-1.0);
167 position.Set(param->ValueAsDouble(manuChannel,0),
168 param->ValueAsDouble(manuChannel,1));
170 dimensions.Set(param->ValueAsDouble(manuChannel,2),
171 param->ValueAsDouble(manuChannel,3));
173 AliDebug(3,Form("DE %4d Manu %4d Channel %2d Pos %e %e Dim %e %e",
174 detElemId,manuId,manuChannel,
175 position.X(),position.Y(),
176 dimensions.X(),dimensions.Y()));
179 //_____________________________________________________________________________
181 AliMUONPainterPadStore::GetSize() const
183 /// Get the number of pads we handle
185 TIter next(fPadStore->CreateIterator());
186 AliMUONVCalibParam* param;
189 while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
191 for ( Int_t i = 0; i < param->Size(); ++i )
193 if ( param->ValueAsDouble(i,2) >= 0 && param->ValueAsDouble(i,3) >= 0 )
203 //_____________________________________________________________________________
205 AliMUONPainterPadStore::PrintPads(const TArrayI& pads) const
208 cout << "n=" << pads.GetSize() << endl;
210 for ( Int_t i = 0; i < pads.GetSize(); ++i )
212 Int_t id = pads.At(i);
213 TVector2 position, dimensions;
214 GetPadGeometry(id,position,dimensions);
215 cout << Form("i %4d DE %4d ManuID %4d ManuChannel %2d (X,Y)=(%7.3f,%7.3f)"
216 " (DX,DY)=(%7.3f,%7.3f)",
218 AliMUONVDigit::DetElemId(id),
219 AliMUONVDigit::ManuId(id),
220 AliMUONVDigit::ManuChannel(id),
221 position.X(),position.Y(),
222 dimensions.X(),dimensions.Y()) << endl;