X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONPainterRegistry.cxx;h=874a6ced25220a44036983651271196771124f28;hb=0742685016164b4badfff3326341f1f29c07d4d8;hp=4b0c02c965ae05ab12ed8a201b5957bce5b79034;hpb=0145e89abcfc92979b59eb1e7514739f1f945d05;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONPainterRegistry.cxx b/MUON/AliMUONPainterRegistry.cxx index 4b0c02c965a..874a6ced252 100644 --- a/MUON/AliMUONPainterRegistry.cxx +++ b/MUON/AliMUONPainterRegistry.cxx @@ -17,8 +17,11 @@ #include "AliMUONPainterRegistry.h" +#include "AliMpManuIterator.h" +#include "AliMUON2DMap.h" +#include "AliMUONCalibParamND.h" #include "AliMUONPainterMatrix.h" -#include "AliMUONVTrackerData.h" +#include "AliMUONTrackerData.h" #include "AliMUONVTrackerDataMaker.h" #include "AliLog.h" #include @@ -42,41 +45,64 @@ ClassImp(AliMUONPainterRegistry) AliMUONPainterRegistry* AliMUONPainterRegistry::fgInstance(0x0); //_____________________________________________________________________________ -AliMUONPainterRegistry::AliMUONPainterRegistry() : TObject(), -fDataSources(new TObjArray), +AliMUONPainterRegistry::AliMUONPainterRegistry() : TObject(), TQObject(), fPainterMatrices(new TObjArray), -fDataReaders(new TObjArray), +fDataMakers(new TObjArray), fHistoryMenu(0x0), fMenuBar(0x0), -fHistoryCounter(0) +fHistoryCounter(0), +fZombies(new TObjArray), +fInteractiveReadOutConfig(0x0) { /// ctor - fDataSources->SetOwner(kTRUE); fPainterMatrices->SetOwner(kTRUE); - fDataReaders->SetOwner(kTRUE); + fDataMakers->SetOwner(kTRUE); + fZombies->SetOwner(kTRUE); } //_____________________________________________________________________________ AliMUONPainterRegistry::~AliMUONPainterRegistry() { /// dtor - delete fDataSources; delete fPainterMatrices; - delete fDataReaders; + delete fDataMakers; + delete fInteractiveReadOutConfig; +} + +//_____________________________________________________________________________ +void +AliMUONPainterRegistry::CreateInteractiveReadOutConfig() const +{ + /// Create configuration of readout + fInteractiveReadOutConfig = new AliMUONTrackerData("IROC","IROC",1); + fInteractiveReadOutConfig->SetDimensionName(0,"Switch"); + /// FIXME: should use a version of TrackerData w/ no storage for channels + /// (i.e. starting at the manu level, or even bus patch level ?) + AliMpManuIterator it; + Int_t detElemId; + Int_t manuId; + AliMUON2DMap store(true); + + while ( it.Next(detElemId,manuId) ) + { + AliMUONVCalibParam* param = new AliMUONCalibParamND(1,64,detElemId,manuId,1); + store.Add(param); + } + fInteractiveReadOutConfig->Add(store); } //_____________________________________________________________________________ AliMUONVTrackerDataMaker* -AliMUONPainterRegistry::DataReader(Int_t i) const +AliMUONPainterRegistry::DataMaker(Int_t i) const { /// Get one data source - if ( i >= 0 && i <= fDataReaders->GetLast() ) + if ( i >= 0 && i <= fDataMakers->GetLast() ) { - return static_cast(fDataReaders->At(i)); + return static_cast(fDataMakers->At(i)); } else { - AliError(Form("Index out of bounds : %d / %d",i,fDataReaders->GetLast()+1)); + AliError(Form("Index out of bounds : %d / %d",i,fDataMakers->GetLast()+1)); return 0x0; } } @@ -86,41 +112,36 @@ AliMUONVTrackerData* AliMUONPainterRegistry::DataSource(Int_t i) const { /// Get one data source - if ( i >= 0 && i <= fDataSources->GetLast() ) - { - return static_cast(fDataSources->At(i)); - } - else - { - AliError(Form("Index out of bounds : %d / %d",i,fDataSources->GetLast()+1)); - return 0x0; - } + + AliMUONVTrackerDataMaker* maker = DataMaker(i); + if ( maker ) return maker->Data(); + return 0x0; } //_____________________________________________________________________________ void -AliMUONPainterRegistry::DataReaderWasRegistered(AliMUONVTrackerDataMaker* data) +AliMUONPainterRegistry::DataMakerWasRegistered(const AliMUONVTrackerDataMaker* data) { /// A new reader source was registered Long_t param[] = { (Long_t)data }; - Emit("DataReaderWasRegistered(AliMUONVTrackerDataMaker*)",param); + Emit("DataMakerWasRegistered(AliMUONVTrackerDataMaker*)",param); } //_____________________________________________________________________________ void -AliMUONPainterRegistry::DataReaderWasUnregistered(AliMUONVTrackerDataMaker* data) +AliMUONPainterRegistry::DataMakerWasUnregistered(const AliMUONVTrackerDataMaker* data) { /// A data reader was unregistered Long_t param[] = { (Long_t)data }; - Emit("DataReaderWasUnregistered(AliMUONVTrackerDataMaker*)",param); + Emit("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)",param); } //_____________________________________________________________________________ void -AliMUONPainterRegistry::DataSourceWasRegistered(AliMUONVTrackerData* data) +AliMUONPainterRegistry::DataSourceWasRegistered(const AliMUONVTrackerData* data) { /// A new data source was registered Long_t param[] = { (Long_t)data }; @@ -130,7 +151,7 @@ AliMUONPainterRegistry::DataSourceWasRegistered(AliMUONVTrackerData* data) //_____________________________________________________________________________ void -AliMUONPainterRegistry::DataSourceWasUnregistered(AliMUONVTrackerData* data) +AliMUONPainterRegistry::DataSourceWasUnregistered(const AliMUONVTrackerData* data) { /// A data source was unregistered Long_t param[] = { (Long_t)data }; @@ -141,10 +162,19 @@ AliMUONPainterRegistry::DataSourceWasUnregistered(AliMUONVTrackerData* data) //_____________________________________________________________________________ AliMUONVTrackerData* -AliMUONPainterRegistry::FindDataSource(const char* name) const +AliMUONPainterRegistry::DataSource(const char* name) const { /// Find a data source by name - return static_cast(fDataSources->FindObject(name)); + for ( Int_t i = 0; i < NumberOfDataMakers(); ++i ) + { + AliMUONVTrackerData* data = DataMaker(i)->Data(); + if ( data ) + { + TString dname(data->GetName()); + if ( dname == name ) return data; + } + } + return 0x0; } //_____________________________________________________________________________ @@ -155,17 +185,9 @@ AliMUONPainterRegistry::FindIndexOf(AliMUONPainterMatrix* group) const return fPainterMatrices->IndexOf(group); } -//_____________________________________________________________________________ -Int_t -AliMUONPainterRegistry::FindIndexOf(AliMUONVTrackerData* data) const -{ - /// Get the index of a given data - return fDataSources->IndexOf(data); -} - //_____________________________________________________________________________ AliMUONPainterMatrix* -AliMUONPainterRegistry::FindPainterMatrix(const char* name) const +AliMUONPainterRegistry::PainterMatrix(const char* name) const { /// Get a painterMatrix by name return static_cast(fPainterMatrices->FindObject(name)); @@ -195,6 +217,17 @@ AliMUONPainterRegistry::Instance() return fgInstance; } +//_____________________________________________________________________________ +AliMUONVTrackerData* +AliMUONPainterRegistry::InteractiveReadOutConfig() const +{ + /// Return an object that contains the parts of the detector selected + /// (using the mouse) to be part of the readout. + + if (!fInteractiveReadOutConfig) CreateInteractiveReadOutConfig(); + return fInteractiveReadOutConfig; +} + //_____________________________________________________________________________ AliMUONPainterMatrix* AliMUONPainterRegistry::PainterMatrix(Int_t i) const @@ -213,7 +246,7 @@ AliMUONPainterRegistry::PainterMatrix(Int_t i) const //_____________________________________________________________________________ void -AliMUONPainterRegistry::PainterMatrixWantToShow(AliMUONPainterMatrix* group) +AliMUONPainterRegistry::PainterMatrixWantToShow(const AliMUONPainterMatrix* group) { /// A given paintermatrix want to appear on screen Long_t param[] = { (Long_t)group }; @@ -267,7 +300,7 @@ AliMUONPainterRegistry::AddToHistory(AliMUONPainterMatrix* group) //_____________________________________________________________________________ void -AliMUONPainterRegistry::PainterMatrixWasRegistered(AliMUONPainterMatrix* group) +AliMUONPainterRegistry::PainterMatrixWasRegistered(const AliMUONPainterMatrix* group) { /// A new painter matrix was registered Long_t param[] = { (Long_t)group }; @@ -277,7 +310,7 @@ AliMUONPainterRegistry::PainterMatrixWasRegistered(AliMUONPainterMatrix* group) //_____________________________________________________________________________ void -AliMUONPainterRegistry::PainterMatrixWasUnregistered(AliMUONPainterMatrix* group) +AliMUONPainterRegistry::PainterMatrixWasUnregistered(const AliMUONPainterMatrix* group) { /// A painter matrix was unregistered Long_t param[] = { (Long_t)group }; @@ -293,13 +326,12 @@ AliMUONPainterRegistry::Print(Option_t* opt) const TString sopt(opt); sopt.ToUpper(); - cout << "Number of data sources = " << NumberOfDataSources() << endl; - cout << "Number of data readers = " << NumberOfDataReaders() << endl; + cout << "Number of data readers = " << NumberOfDataMakers() << endl; cout << "Number of painter matrices = " << NumberOfPainterMatrices() << endl; if ( sopt.Contains("FULL") || sopt.Contains("READER") ) { - TIter next(fDataReaders); + TIter next(fDataMakers); AliMUONVTrackerDataMaker* reader; while ( ( reader = static_cast(next()) ) ) @@ -310,12 +342,13 @@ AliMUONPainterRegistry::Print(Option_t* opt) const if ( sopt.Contains("FULL") || sopt.Contains("DATA") ) { - TIter next(fDataSources); - AliMUONVTrackerData* data; - - while ( ( data = static_cast(next()) ) ) + TIter next(fDataMakers); + AliMUONVTrackerDataMaker* reader; + + while ( ( reader = static_cast(next()) ) ) { - data->Print(); + AliMUONVTrackerData* data = reader->Data(); + if ( data ) data->Print(); } } @@ -344,40 +377,22 @@ AliMUONPainterRegistry::Register(AliMUONPainterMatrix* group) return fPainterMatrices->IndexOf(group); } -//_____________________________________________________________________________ -void -AliMUONPainterRegistry::Register(AliMUONVTrackerData* data) -{ - /// data is adopted, i.e. the registry becomes the owner of it. - fDataSources->AddLast(data); - DataSourceWasRegistered(data); -} - //_____________________________________________________________________________ void AliMUONPainterRegistry::Register(AliMUONVTrackerDataMaker* reader) { /// reader is adopted, i.e. the registry becomes the owner of it. - fDataReaders->AddLast(reader); - DataReaderWasRegistered(reader); - Register(reader->Data()); - reader->SetOwner(kFALSE); // important so data it not deleted twice + fDataMakers->AddLast(reader); + DataMakerWasRegistered(reader); + if ( reader->Data() ) DataSourceWasRegistered(reader->Data()); } //_____________________________________________________________________________ Int_t -AliMUONPainterRegistry::NumberOfDataReaders() const +AliMUONPainterRegistry::NumberOfDataMakers() const { /// The number of data readers we handle - return fDataReaders->GetLast()+1; -} - -//_____________________________________________________________________________ -Int_t -AliMUONPainterRegistry::NumberOfDataSources() const -{ - /// The number of data soures we handle - return fDataSources->GetLast()+1; + return fDataMakers->GetLast()+1; } //_____________________________________________________________________________ @@ -389,26 +404,11 @@ AliMUONPainterRegistry::NumberOfPainterMatrices() const } //_____________________________________________________________________________ -Bool_t -AliMUONPainterRegistry::Unregister(AliMUONVTrackerData* data) +void +AliMUONPainterRegistry::DeleteZombies() { - /// Unregister some data - - if (!data) return kFALSE; - - DataSourceWasUnregistered(data); - - TObject* o = fDataSources->Remove(data); - if ( o ) - { - delete o; - } - else - { - AliError(Form("Could not unregister data named %s title %s",data->GetName(), - data->GetTitle())); - } - return ( o != 0x0 ); + /// Delete zombies + fZombies->Delete(); } //_____________________________________________________________________________ @@ -419,18 +419,29 @@ AliMUONPainterRegistry::Unregister(AliMUONVTrackerDataMaker* reader) if (!reader) return kFALSE; - DataReaderWasUnregistered(reader); - - TObject* o = fDataReaders->Remove(reader); - if ( o ) + if ( reader->Data() ) { - delete o; - } - else - { - AliError(Form("Could not unregister data named %s title %s",reader->GetName(), - reader->GetTitle())); + DataSourceWasUnregistered(reader->Data()); + reader->Data()->Destroyed(); // we pretend it's deleted now, even + // if it will be only later on when zombie are killed, so that + // for instance painters depending on it will no longer try to access it } + + DataMakerWasUnregistered(reader); + + TObject* o = fDataMakers->Remove(reader); + + fZombies->Add(o); // for later deletion + +// if ( o ) +// { +// delete o; +// } +// else +// { +// AliError(Form("Could not unregister data named %s title %s",reader->GetName(), +// reader->GetTitle())); +// } return ( o != 0x0 ); }