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