AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONPainterDataRegistry.cxx
Go to the documentation of this file.
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 
19 
20 #include "AliMpManuIterator.h"
21 #include "AliMUON2DMap.h"
22 #include "AliMUONCalibParamND.h"
23 #include "AliMUONTrackerData.h"
25 #include "AliLog.h"
26 #include <THashList.h>
27 #include <TObjArray.h>
28 #include <TString.h>
29 #include <Riostream.h>
30 
37 
38 using std::cout;
39 using std::endl;
43 
45 
46 //_____________________________________________________________________________
48 fDataMakers(new TObjArray),
49 fZombies(new TObjArray),
50 fInteractiveReadOutConfig(0x0)
51 {
53  fDataMakers->SetOwner(kTRUE);
54  fZombies->SetOwner(kTRUE);
55 }
56 
57 //_____________________________________________________________________________
59 {
61  delete fDataMakers;
63 }
64 
65 //_____________________________________________________________________________
66 void
68 {
70 
71  fInteractiveReadOutConfig = new AliMUONTrackerData("IROC","IROC",1);
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  }
85 }
86 
87 //_____________________________________________________________________________
90 {
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 //_____________________________________________________________________________
106 {
108 
110  if ( maker ) return maker->Data();
111  return 0x0;
112 }
113 
114 //_____________________________________________________________________________
115 void
117 {
119  Long_t param[] = { (Long_t)data };
120 
121  Emit("DataMakerWasRegistered(AliMUONVTrackerDataMaker*)",param);
122 }
123 
124 //_____________________________________________________________________________
125 void
127 {
129  Long_t param[] = { (Long_t)data };
130 
131  Emit("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)",param);
132 
133 }
134 
135 //_____________________________________________________________________________
136 void
138 {
140  Long_t param[] = { (Long_t)data };
141 
142  Emit("DataSourceWasRegistered(AliMUONVTrackerData*)",param);
143 }
144 
145 //_____________________________________________________________________________
146 void
148 {
150  Long_t param[] = { (Long_t)data };
151 
152  Emit("DataSourceWasUnregistered(AliMUONVTrackerData*)",param);
153 
154 }
155 
156 //_____________________________________________________________________________
159 {
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 //_____________________________________________________________________________
176 {
179  return fgInstance;
180 }
181 
182 //_____________________________________________________________________________
185 {
188 
191 }
192 
193 //_____________________________________________________________________________
194 void
196 {
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 //_____________________________________________________________________________
224 void
226 {
228  fDataMakers->AddLast(reader);
229  DataMakerWasRegistered(reader);
230  if ( reader->Data() ) DataSourceWasRegistered(reader->Data());
231 }
232 
233 //_____________________________________________________________________________
234 Int_t
236 {
238  return fDataMakers->GetLast()+1;
239 }
240 
241 //_____________________________________________________________________________
242 void
244 {
246  fZombies->Delete();
247 }
248 
249 //_____________________________________________________________________________
250 Bool_t
252 {
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 }
AliMUONVTrackerData * DataSource(Int_t i) const
virtual void DisableChannelLevel()=0
Disable recording of information at the channel level.
Implementation of AliMUONVTrackerData.
void DataMakerWasUnregistered(const AliMUONVTrackerDataMaker *reader)
static AliMUONPainterDataRegistry * fgInstance
unique instance
#define TObjArray
virtual void Print(Option_t *wildcard="") const
Print all objects whose name matches wildcard.
Producer of some AliMUONVTrackerData.
TObjArray * fZombies
data readers to be deleted
TObjArray * fDataMakers
data makers
void DataSourceWasUnregistered(const AliMUONVTrackerData *data)
Bool_t Next(Int_t &detElemId, Int_t &manuId)
Class to loop over all manus of MUON Tracker.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
void Register(AliMUONVTrackerDataMaker *reader)
static AliMUONPainterDataRegistry * Instance()
Container of calibration values for a given number of channels.
Bool_t Unregister(AliMUONVTrackerDataMaker *reader)
Registry for painter data sources.
void DataSourceWasRegistered(const AliMUONVTrackerData *data)
Implementation of AliMUONVCalibParam for tuples of double.
virtual void SetDimensionName(Int_t index, const char *value)=0
Set the name of a given dimension.
Basic implementation of AliMUONVStore container using AliMpExMap internally.
Definition: AliMUON2DMap.h:20
AliMUONVTrackerDataMaker * DataMaker(Int_t i) const
virtual Bool_t Add(TObject *object)
Add an object to the store.
virtual Bool_t Add(const AliMUONVStore &store, TArrayI *arrayOfNofEventsPerDDL=0x0)=0
Add values for one event from one full store.
virtual AliMUONVTrackerData * Data() const =0
Our data.
Base class for MUON data that can be presented at different levels in the hierarchy of the MUON syste...
void DataMakerWasRegistered(const AliMUONVTrackerDataMaker *reader)
AliMUONVTrackerData * InteractiveReadOutConfig() const
AliMUONVTrackerData * fInteractiveReadOutConfig
clickable readout configuration