]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONPainterDataRegistry.cxx
Fixed calculation of fluctuations of energy loss in absrber.
[u/mrichter/AliRoot.git] / MUON / AliMUONPainterDataRegistry.cxx
CommitLineData
0b936dc0 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: AliMUONPainterDataRegistry.cxx 26812 2008-06-20 15:22:59Z laphecet $
17
18#include "AliMUONPainterDataRegistry.h"
19
20#include "AliMpManuIterator.h"
21#include "AliMUON2DMap.h"
22#include "AliMUONCalibParamND.h"
23#include "AliMUONTrackerData.h"
24#include "AliMUONVTrackerDataMaker.h"
25#include "AliLog.h"
26#include <THashList.h>
27#include <TObjArray.h>
28#include <TString.h>
29#include <Riostream.h>
30
31///\class AliMUONPainterDataRegistry
32///
33/// Registry for AliMUONVPainter related stuff : painter data sources
34/// and painter matrices
35///
36///\author Laurent Aphecetche, Subatech
37
b80faac0 38using std::cout;
39using std::endl;
0b936dc0 40///\cond CLASSIMP
41ClassImp(AliMUONPainterDataRegistry)
42///\endcond
43
44AliMUONPainterDataRegistry* AliMUONPainterDataRegistry::fgInstance(0x0);
45
46//_____________________________________________________________________________
47AliMUONPainterDataRegistry::AliMUONPainterDataRegistry() : TObject(), TQObject(),
48fDataMakers(new TObjArray),
49fZombies(new TObjArray),
50fInteractiveReadOutConfig(0x0)
51{
52 /// ctor
53 fDataMakers->SetOwner(kTRUE);
54 fZombies->SetOwner(kTRUE);
55}
56
57//_____________________________________________________________________________
58AliMUONPainterDataRegistry::~AliMUONPainterDataRegistry()
59{
60 /// dtor
61 delete fDataMakers;
62 delete fInteractiveReadOutConfig;
63}
64
65//_____________________________________________________________________________
66void
67AliMUONPainterDataRegistry::CreateInteractiveReadOutConfig() const
68{
69 /// Create a base config
70
71 fInteractiveReadOutConfig = new AliMUONTrackerData("IROC","IROC",1);
72 fInteractiveReadOutConfig->SetDimensionName(0,"Switch");
73 fInteractiveReadOutConfig->DisableChannelLevel();
74 AliMpManuIterator it;
75 Int_t detElemId;
76 Int_t manuId;
77 AliMUON2DMap store(true);
78
79 while ( it.Next(detElemId,manuId) )
80 {
81 AliMUONVCalibParam* param = new AliMUONCalibParamND(1,64,detElemId,manuId,1);
82 store.Add(param);
83 }
84 fInteractiveReadOutConfig->Add(store);
85}
86
87//_____________________________________________________________________________
88AliMUONVTrackerDataMaker*
89AliMUONPainterDataRegistry::DataMaker(Int_t i) const
90{
91 /// Get one data source
92 if ( i >= 0 && i <= fDataMakers->GetLast() )
93 {
94 return static_cast<AliMUONVTrackerDataMaker*>(fDataMakers->At(i));
95 }
96 else
97 {
98 AliError(Form("Index out of bounds : %d / %d",i,fDataMakers->GetLast()+1));
99 return 0x0;
100 }
101}
102
103//_____________________________________________________________________________
104AliMUONVTrackerData*
105AliMUONPainterDataRegistry::DataSource(Int_t i) const
106{
107 /// Get one data source
108
109 AliMUONVTrackerDataMaker* maker = DataMaker(i);
110 if ( maker ) return maker->Data();
111 return 0x0;
112}
113
114//_____________________________________________________________________________
115void
57e2ad1a 116AliMUONPainterDataRegistry::DataMakerWasRegistered(const AliMUONVTrackerDataMaker* data)
0b936dc0 117{
118 /// A new reader source was registered
119 Long_t param[] = { (Long_t)data };
120
121 Emit("DataMakerWasRegistered(AliMUONVTrackerDataMaker*)",param);
122}
123
124//_____________________________________________________________________________
125void
57e2ad1a 126AliMUONPainterDataRegistry::DataMakerWasUnregistered(const AliMUONVTrackerDataMaker* data)
0b936dc0 127{
128 /// A data reader was unregistered
129 Long_t param[] = { (Long_t)data };
130
131 Emit("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)",param);
132
133}
134
135//_____________________________________________________________________________
136void
57e2ad1a 137AliMUONPainterDataRegistry::DataSourceWasRegistered(const AliMUONVTrackerData* data)
0b936dc0 138{
139 /// A new data source was registered
140 Long_t param[] = { (Long_t)data };
141
142 Emit("DataSourceWasRegistered(AliMUONVTrackerData*)",param);
143}
144
145//_____________________________________________________________________________
146void
57e2ad1a 147AliMUONPainterDataRegistry::DataSourceWasUnregistered(const AliMUONVTrackerData* data)
0b936dc0 148{
149 /// A data source was unregistered
150 Long_t param[] = { (Long_t)data };
151
152 Emit("DataSourceWasUnregistered(AliMUONVTrackerData*)",param);
153
154}
155
156//_____________________________________________________________________________
157AliMUONVTrackerData*
158AliMUONPainterDataRegistry::DataSource(const char* name) const
159{
160 /// Find a data source by name
161 for ( Int_t i = 0; i < NumberOfDataMakers(); ++i )
162 {
163 AliMUONVTrackerData* data = DataMaker(i)->Data();
164 if ( data )
165 {
166 TString dname(data->GetName());
167 if ( dname == name ) return data;
168 }
169 }
170 return 0x0;
171}
172
173//_____________________________________________________________________________
174AliMUONPainterDataRegistry*
175AliMUONPainterDataRegistry::Instance()
176{
177 /// Get unique instance of this class
178 if ( !fgInstance ) fgInstance = new AliMUONPainterDataRegistry;
179 return fgInstance;
180}
181
182//_____________________________________________________________________________
183AliMUONVTrackerData*
184AliMUONPainterDataRegistry::InteractiveReadOutConfig() const
185{
186 /// Return an object that contains the parts of the detector selected
187 /// (using the mouse) to be part of the readout.
188
189 if (!fInteractiveReadOutConfig) CreateInteractiveReadOutConfig();
190 return fInteractiveReadOutConfig;
191}
192
193//_____________________________________________________________________________
194void
195AliMUONPainterDataRegistry::Print(Option_t* opt) const
196{
197 /// Printout
198 TString sopt(opt);
199 sopt.ToUpper();
200
201 cout << "Number of data readers = " << NumberOfDataMakers() << endl;
202
203 if ( sopt.Contains("FULL") || sopt.Contains("READER") || sopt.Contains("DATA") )
204 {
205 TIter next(fDataMakers);
206 AliMUONVTrackerDataMaker* reader;
207
208 while ( ( reader = static_cast<AliMUONVTrackerDataMaker*>(next()) ) )
209 {
210 if ( sopt.Contains("DATA") )
211 {
212 AliMUONVTrackerData* data = reader->Data();
213 if ( data ) data->Print();
214 }
215 else
216 {
217 reader->Print();
218 }
219 }
220 }
221}
222
223//_____________________________________________________________________________
224void
225AliMUONPainterDataRegistry::Register(AliMUONVTrackerDataMaker* reader)
226{
227 /// reader is adopted, i.e. the registry becomes the owner of it.
228 fDataMakers->AddLast(reader);
229 DataMakerWasRegistered(reader);
230 if ( reader->Data() ) DataSourceWasRegistered(reader->Data());
231}
232
233//_____________________________________________________________________________
234Int_t
235AliMUONPainterDataRegistry::NumberOfDataMakers() const
236{
237 /// The number of data readers we handle
238 return fDataMakers->GetLast()+1;
239}
240
241//_____________________________________________________________________________
242void
243AliMUONPainterDataRegistry::DeleteZombies()
244{
245 /// Delete zombies
246 fZombies->Delete();
247}
248
249//_____________________________________________________________________________
250Bool_t
251AliMUONPainterDataRegistry::Unregister(AliMUONVTrackerDataMaker* reader)
252{
253 /// Unregister some reader
254
255 if (!reader) return kFALSE;
256
257 if ( reader->Data() )
258 {
259 DataSourceWasUnregistered(reader->Data());
260 reader->Data()->Destroyed(); // we pretend it's deleted now, even
261 // if it will be only later on when zombie are killed, so that
262 // for instance painters depending on it will no longer try to access it
263 }
264
265 DataMakerWasUnregistered(reader);
266
267 TObject* o = fDataMakers->Remove(reader);
268
269 fZombies->Add(o); // for later deletion
270
271// if ( o )
272// {
273// delete o;
274// }
275// else
276// {
277// AliError(Form("Could not unregister data named %s title %s",reader->GetName(),
278// reader->GetTitle()));
279// }
280 return ( o != 0x0 );
281}