From 49419555ad4a62c37cff03b3263946838aee56db Mon Sep 17 00:00:00 2001 From: laphecet Date: Thu, 6 Mar 2008 16:44:11 +0000 Subject: [PATCH] mchview version 0.93 New features - Adding a Lock button under the color slider to lock the range shown when switching between views - Default display now shows bending plane (instead of cathode 0 before) - If pad is responder and there's some histo for that pad, clicking on it will display an histo - Right-click on a painter will now display several histogram options (e.g. raw charge as before, but also simple distributions of mean and sigma - In the Data Sources Tab, each data source can now be removed and saved - There's a new Tool menu which allow to produce a TrackerData from two others in order to compare data - The --use option can now reference alien files Bug fixes - Can now read Capacitances from OCDB --- MUON/AliMUON1DMap.cxx | 11 + MUON/AliMUON1DMap.h | 4 +- MUON/AliMUON2DMap.cxx | 11 + MUON/AliMUON2DMap.h | 2 + MUON/AliMUONCDB.cxx | 48 +--- MUON/AliMUONGainSubprocessor.cxx | 3 +- MUON/AliMUONManuPadPainter.cxx | 35 ++- MUON/AliMUONManuPadPainter.h | 6 +- MUON/AliMUONMchViewApplication.cxx | 164 ++++++++++- MUON/AliMUONMchViewApplication.h | 12 +- MUON/AliMUONPainterColorSlider.cxx | 56 +++- MUON/AliMUONPainterColorSlider.h | 9 +- MUON/AliMUONPainterDataSourceFrame.cxx | 52 +++- MUON/AliMUONPainterDataSourceFrame.h | 4 +- MUON/AliMUONPainterDataSourceItem.cxx | 230 +++++++++++---- MUON/AliMUONPainterDataSourceItem.h | 20 +- MUON/AliMUONPainterHelper.cxx | 7 +- MUON/AliMUONPainterInterfaceHelper.cxx | 54 +++- MUON/AliMUONPainterInterfaceHelper.h | 2 + MUON/AliMUONPainterMasterFrame.cxx | 48 ++-- MUON/AliMUONPainterMatrixFrame.cxx | 11 +- MUON/AliMUONPainterPlotSelector.cxx | 46 +-- MUON/AliMUONPainterRegistry.cxx | 163 +++++------ MUON/AliMUONPainterRegistry.h | 32 +-- MUON/AliMUONTrackerCalibratedDataMaker.cxx | 30 +- MUON/AliMUONTrackerCalibratedDataMaker.h | 14 +- MUON/AliMUONTrackerData.cxx | 84 ++++-- MUON/AliMUONTrackerData.h | 12 +- MUON/AliMUONTrackerDataCompareDialog.cxx | 317 +++++++++++++++++++++ MUON/AliMUONTrackerDataCompareDialog.h | 69 +++++ MUON/AliMUONTrackerDataHistogrammer.cxx | 243 +++++++++------- MUON/AliMUONTrackerDataHistogrammer.h | 31 +- MUON/AliMUONTrackerOCDBDataMaker.cxx | 20 +- MUON/AliMUONTrackerOCDBDataMaker.h | 8 +- MUON/AliMUONTrackerRawDataMaker.cxx | 71 +++-- MUON/AliMUONTrackerRawDataMaker.h | 29 +- MUON/AliMUONVPainter.cxx | 62 +++- MUON/AliMUONVPainter.h | 33 ++- MUON/AliMUONVStore.cxx | 2 +- MUON/AliMUONVTrackerData.h | 11 +- MUON/AliMUONVTrackerDataMaker.h | 13 +- MUON/MUONgraphicsLinkDef.h | 2 + MUON/READMEmchview.txt | 6 +- MUON/TestMUONPreprocessor.C | 29 +- MUON/libMUONgraphics.pkg | 4 +- MUON/mchview.cxx | 13 +- 46 files changed, 1583 insertions(+), 550 deletions(-) create mode 100644 MUON/AliMUONTrackerDataCompareDialog.cxx create mode 100644 MUON/AliMUONTrackerDataCompareDialog.h diff --git a/MUON/AliMUON1DMap.cxx b/MUON/AliMUON1DMap.cxx index 07599e620b2..5178de6d693 100644 --- a/MUON/AliMUON1DMap.cxx +++ b/MUON/AliMUON1DMap.cxx @@ -105,6 +105,17 @@ AliMUON1DMap::FindObject(UInt_t i) const return fMap->GetValue(i); } +//_____________________________________________________________________________ +TObject* +AliMUON1DMap::FindObject(Int_t i, Int_t j) const +{ + /// Get the object located at index (i,j), if it exists, and if i,j is correct. + + UInt_t uid = ( ( ( j & 0xFFFF ) << 16 ) | ( i & 0xFFFF ) ); + + return fMap->GetValue(uid); +} + //_____________________________________________________________________________ TIterator* AliMUON1DMap::CreateIterator() const diff --git a/MUON/AliMUON1DMap.h b/MUON/AliMUON1DMap.h index 39c1f7a420c..23bae6f7130 100644 --- a/MUON/AliMUON1DMap.h +++ b/MUON/AliMUON1DMap.h @@ -37,7 +37,9 @@ public: using AliMUONVStore::FindObject; virtual TObject* FindObject(UInt_t i) const; - + + virtual TObject* FindObject(Int_t i, Int_t j) const; + virtual TIterator* CreateIterator() const; using AliMUONVStore::GetSize; diff --git a/MUON/AliMUON2DMap.cxx b/MUON/AliMUON2DMap.cxx index fc3a4771c9e..77f59e8dcb5 100644 --- a/MUON/AliMUON2DMap.cxx +++ b/MUON/AliMUON2DMap.cxx @@ -112,6 +112,17 @@ AliMUON2DMap::Add(TObject* object) return Set(i,j,object,kFALSE); } +//_____________________________________________________________________________ +TObject* +AliMUON2DMap::FindObject(UInt_t uid) const +{ + /// Return the value at position uid + + Int_t j = ( uid & 0xFFFF0000 ) >> 16; + Int_t i = ( uid & 0xFFFF); + return FindObject(i,j); +} + //_____________________________________________________________________________ TObject* AliMUON2DMap::FindObject(Int_t i, Int_t j) const diff --git a/MUON/AliMUON2DMap.h b/MUON/AliMUON2DMap.h index ddbbc679567..5ae8702c7b8 100644 --- a/MUON/AliMUON2DMap.h +++ b/MUON/AliMUON2DMap.h @@ -45,6 +45,8 @@ public: virtual TObject* FindObject(Int_t i, Int_t j) const; + virtual TObject* FindObject(UInt_t uid) const; + /// Whether our internal storage is optimize to store (detection element id, manu id) Bool_t IsOptimizedForDEManu() const { return fOptimizeForDEManu; } diff --git a/MUON/AliMUONCDB.cxx b/MUON/AliMUONCDB.cxx index 96b75b713e7..9a0af849b9f 100644 --- a/MUON/AliMUONCDB.cxx +++ b/MUON/AliMUONCDB.cxx @@ -37,6 +37,7 @@ #include "AliMUONCalibParamNF.h" #include "AliMUONCalibParamNI.h" #include "AliMUONConstants.h" +#include "AliMUONTrackerIO.h" #include "AliMUONTriggerEfficiencyCells.h" #include "AliMUONTriggerLut.h" #include "AliMUONVStore.h" @@ -453,52 +454,7 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file) { /// Read the capacitance values from file and append them to the capaStore - AliCodeTimerAuto(Form("file=%s",file)); - - ifstream in(gSystem->ExpandPathName(file)); - if (in.bad()) return 0; - - Int_t ngenerated(0); - - char line[1024]; - Int_t serialNumber(-1); - AliMUONVCalibParam* param(0x0); - - while ( in.getline(line,1024,'\n') ) - { - if ( isdigit(line[0]) ) - { - serialNumber = atoi(line); - param = static_cast(capaStore.FindObject(serialNumber)); - if (param) - { - AliError(Form("serialNumber %d appears several times !",serialNumber)); - capaStore.Clear(); - break; - } - param = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0); - Bool_t ok = capaStore.Add(param); - if (!ok) - { - AliError(Form("Could not set serialNumber=%d",serialNumber)); - continue; - } - continue; - } - Int_t channel; - Float_t capaValue; - Float_t injectionGain; - sscanf(line,"%d %f %f",&channel,&capaValue,&injectionGain); - AliDebug(1,Form("SerialNumber %10d Channel %3d Capa %f injectionGain %f", - serialNumber,channel,capaValue,injectionGain)); - param->SetValueAsFloat(channel,0,capaValue); - param->SetValueAsFloat(channel,1,injectionGain); - ++ngenerated; - } - - in.close(); - - return ngenerated; + return AliMUONTrackerIO::ReadCapacitances(file,capaStore); } //_____________________________________________________________________________ diff --git a/MUON/AliMUONGainSubprocessor.cxx b/MUON/AliMUONGainSubprocessor.cxx index fd70f4b69d5..bfdea997636 100644 --- a/MUON/AliMUONGainSubprocessor.cxx +++ b/MUON/AliMUONGainSubprocessor.cxx @@ -178,7 +178,8 @@ AliMUONGainSubprocessor::Process(TMap* /*dcsAliasMap*/) AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("MUON TRK"); - metaData.SetComment("Computed by AliMUONGainSubprocessor $Id$"); + metaData.SetComment(Form("Computed by AliMUONGainSubprocessor " + "$Id$ ; %s",fComment.Data())); Bool_t validToInfinity = kTRUE; Bool_t result = Master()->Store("Calib", "Gains", fGains, &metaData, 0, validToInfinity); diff --git a/MUON/AliMUONManuPadPainter.cxx b/MUON/AliMUONManuPadPainter.cxx index aaaff2024da..11e8a39d1e8 100644 --- a/MUON/AliMUONManuPadPainter.cxx +++ b/MUON/AliMUONManuPadPainter.cxx @@ -17,8 +17,11 @@ #include "AliMUONManuPadPainter.h" +#include "AliLog.h" +#include "AliMUONPainterGroup.h" #include "AliMUONPainterHelper.h" #include "AliMUONPainterPadStore.h" +#include "AliMUONTrackerDataHistogrammer.h" #include "AliMUONVCalibParam.h" #include "AliMUONVDigit.h" #include "AliMUONVTrackerData.h" @@ -29,10 +32,11 @@ #include "AliMpPad.h" #include "AliMpSegmentation.h" #include "AliMpVSegmentation.h" -#include "AliLog.h" -#include +#include +#include #include #include +#include ///\class AliMUONManuPadPainter /// @@ -167,6 +171,33 @@ AliMUONManuPadPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex } } +//_____________________________________________________________________________ +void +AliMUONManuPadPainter::DrawHistogramClone(Double_t* values) const +{ + /// Draw histogram for pad at (values[0],values[1]) + + if ( !values ) return; + + AliMUONPainterGroup* group = Master()->PlotterGroup(); + + if ( !group ) return; // no data to histogram in this painter + + AliMpPad pad = PadByPosition(values[0],values[1]); + + AliMUONVTrackerData* data = group->Data(); + + AliMUONTrackerDataHistogrammer tdh(*data,0,-1); + + fHistogram = tdh.CreateChannelHisto(fDetElemId, fManuId, + pad.GetLocation().GetSecond()); + if (fHistogram) + { + new TCanvas(); + fHistogram->Draw(); + } +} + //_____________________________________________________________________________ void AliMUONManuPadPainter::PaintArea(const AliMUONVTrackerData& data, diff --git a/MUON/AliMUONManuPadPainter.h b/MUON/AliMUONManuPadPainter.h index e2f5e14850f..40f098eb9e4 100644 --- a/MUON/AliMUONManuPadPainter.h +++ b/MUON/AliMUONManuPadPainter.h @@ -51,7 +51,11 @@ public: Double_t max); void PaintOutline(Int_t color=-1, Int_t width=-1, Double_t x=FLT_MAX, Double_t y=FLT_MAX); - + + Bool_t CanBeDetached() const { return kFALSE; } + + virtual void DrawHistogramClone(Double_t* values=0x0) const; + private: void BackupStyle(); diff --git a/MUON/AliMUONMchViewApplication.cxx b/MUON/AliMUONMchViewApplication.cxx index 89bb3ec4e85..b4fccf8855d 100644 --- a/MUON/AliMUONMchViewApplication.cxx +++ b/MUON/AliMUONMchViewApplication.cxx @@ -4,10 +4,14 @@ #include "AliCodeTimer.h" #include "AliLog.h" #include "AliMUONPainterDataSourceFrame.h" +#include "AliMUONPainterEnv.h" #include "AliMUONPainterHelper.h" #include "AliMUONPainterMasterFrame.h" #include "AliMUONPainterRegistry.h" +#include "AliMUONTrackerDataCompareDialog.h" +#include "AliMUONTrackerDataWrapper.h" #include "AliMUONVTrackerData.h" +#include "AliMUONVTrackerDataMaker.h" #include #include #include @@ -16,8 +20,11 @@ #include #include #include +#include +#include #include #include +#include #include #include @@ -35,6 +42,8 @@ const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1); const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2); const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3); const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4); +const Int_t AliMUONMchViewApplication::fgkABOUT(5); +const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6); const char* AliMUONMchViewApplication::fgkFileTypes[] = { "ROOT files", "*.root", @@ -119,6 +128,29 @@ AliMUONMchViewApplication::~AliMUONMchViewApplication() /// dtor } +//______________________________________________________________________________ +void +AliMUONMchViewApplication::CompareData() +{ + /// Launch compare data dialog + TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(), + gClient->GetRoot(), + 400,400); + + t->MapSubwindows(); + t->Resize(); + t->MapWindow(); + t->CenterOnParent(); + + // set names + + t->SetWindowName("mchview compare data tool"); + t->SetIconName("mchview compare data tool"); + + t->MapRaised(); + +} + //______________________________________________________________________________ void AliMUONMchViewApplication::CreateMenuBar(UInt_t w) @@ -132,17 +164,22 @@ AliMUONMchViewApplication::CreateMenuBar(UInt_t w) file->AddEntry("&Print As...",fgkFILEPRINTAS); file->AddEntry("&Exit",fgkFILEEXIT); - file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)"); - TGMenuBar* bar = new TGMenuBar(fMainFrame,w); + TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot()); + tools->AddEntry("&Compare data",fgkCOMPAREDATA); + TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot()); - about->AddLabel(FullVersion()); + about->AddEntry(FullVersion(),fgkABOUT); + file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)"); + about->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)"); + tools->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)"); + bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop)); + bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop)); bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop)); - fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX)); AliMUONPainterRegistry::Instance()->SetMenuBar(bar); @@ -168,6 +205,12 @@ AliMUONMchViewApplication::HandleMenu(Int_t i) case fgkFILEPRINTAS: PrintAs(); break; + case fgkABOUT: + ReleaseNotes(); + break; + case fgkCOMPAREDATA: + CompareData(); + break; default: break; } @@ -183,9 +226,18 @@ AliMUONMchViewApplication::Open() fileInfo.fFileTypes = fgkFileTypes; + delete[] fileInfo.fIniDir; + + AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env(); + + fileInfo.fIniDir = StrDup(env->String("LastOpenDir",".")); + new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(), kFDOpen,&fileInfo); - + + env->Set("LastOpenDir",fileInfo.fIniDir); + env->Save(); + Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename))); } @@ -193,11 +245,22 @@ AliMUONMchViewApplication::Open() void AliMUONMchViewApplication::Open(const char* filename) { - /// Open a given file containing saved VTrackerData objects + /// Open a given file containing saved VTrackerDataMaker objects - TFile f(filename); + TString sfilename(gSystem->ExpandPathName(filename)); - TList* keys = f.GetListOfKeys(); + if ( sfilename.Contains(TRegexp("^alien")) ) + { + // insure we've initialized the grid... + if (!gGrid) + { + TGrid::Connect("alien://"); + } + } + + TFile* f = TFile::Open(filename); + + TList* keys = f->GetListOfKeys(); TIter next(keys); TKey* k; @@ -205,16 +268,31 @@ AliMUONMchViewApplication::Open(const char* filename) while ( ( k = static_cast(next()) ) ) { TObject* object = k->ReadObj(); + + if ( object->InheritsFrom("AliMUONVTrackerDataMaker") ) + { + AliMUONVTrackerDataMaker* maker = dynamic_cast(object); + if ( maker ) + { + AliMUONPainterRegistry::Instance()->Register(maker); + } + } if ( object->InheritsFrom("AliMUONVTrackerData") ) { - AliMUONVTrackerData* data = static_cast(object); + // this is for backward compatibility. Early versions of mchview + // wrote VTrackerData objects, and not VTrackerDataMaker ones. + + AliMUONVTrackerData* data = dynamic_cast(object); if ( data ) { - AliMUONPainterRegistry::Instance()->Register(data); + AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data); + AliMUONPainterRegistry::Instance()->Register(maker); } } } + + delete f; } @@ -232,6 +310,64 @@ AliMUONMchViewApplication::PrintAs() fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename))); } +//______________________________________________________________________________ +void +AliMUONMchViewApplication::ReleaseNotes() +{ + /// Display release notes + + UInt_t width = 600; + UInt_t height = 400; + + TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height); + + TGTextView* rn = new TGTextView(t); + + rn->AddLine("0.93"); + rn->AddLine(""); + rn->AddLine("New features"); + rn->AddLine(""); + rn->AddLine("- Adding a Lock button under the color slider to lock the range shown"); + rn->AddLine(" when switching between views"); + rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)"); + rn->AddLine("- If pad is responder and there's some histo for that pad, "); + rn->AddLine(" clicking on it will display an histo"); + rn->AddLine("- Right-click on a painter will now display several histogram options"); + rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean"); + rn->AddLine(" and sigma"); + rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved"); + rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others"); + rn->AddLine(" in order to compare data."); + rn->AddLine(" - The --use option can now reference alien files"); + rn->AddLine(""); + rn->AddLine("Bug fixes"); + rn->AddLine(""); + rn->AddLine("- Can now read Capacitances from OCDB"); + + rn->Resize(width,height); + + t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); + + t->MapSubwindows(); + t->Resize(); + t->MapWindow(); + t->CenterOnParent(); + + // set names + + t->SetWindowName("mchview release notes"); + t->SetIconName("mchview release notes"); + +// t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize | +// kMWMDecorMinimize | kMWMDecorMenu, +// kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize | +// kMWMFuncMinimize, +// kMWMInputModeless); + + t->MapRaised(); +// gClient->WaitFor(t); +} + //______________________________________________________________________________ void AliMUONMchViewApplication::Save() @@ -250,16 +386,16 @@ AliMUONMchViewApplication::Save() void AliMUONMchViewApplication::Save(const char* filename) { - /// Save VTrackerData objects into file of given name + /// Save VTrackerDataMaker objects into file of given name AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance(); TFile f(filename,"RECREATE"); - for ( Int_t i = 0; i < reg->NumberOfDataSources(); ++i ) + for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i ) { - AliMUONVTrackerData* data = reg->DataSource(i); - data->Write(); + AliMUONVTrackerDataMaker* maker = reg->DataMaker(i); + maker->Write(); } f.Close(); diff --git a/MUON/AliMUONMchViewApplication.h b/MUON/AliMUONMchViewApplication.h index 6f3e5308fbd..944aeccc0b1 100644 --- a/MUON/AliMUONMchViewApplication.h +++ b/MUON/AliMUONMchViewApplication.h @@ -29,7 +29,7 @@ public: void HandleMenu(Int_t i); /// Return the version number of the mchview application - static const char* Version() { return "0.92a"; } + static const char* Version() { return "0.93"; } /// Return the SVN revision and version number of the mchview application static const char* FullVersion() { return Form("mchview Version %s ($Id$)",Version()); } @@ -42,12 +42,14 @@ private: /// Not implemented AliMUONMchViewApplication& operator=(const AliMUONMchViewApplication& rhs); + void CompareData(); void CreateMenuBar(UInt_t w); void Save(); void Save(const char* filename); void Open(); void PrintAs(); - + void ReleaseNotes(); + private: TGMainFrame* fMainFrame; ///< pointer to our mainframe AliMUONPainterMasterFrame* fPainterMasterFrame; ///< pointer to our main object @@ -56,10 +58,12 @@ private: static const Int_t fgkFILEOPEN; ///< File/Open... menu static const Int_t fgkFILEEXIT; ///< File/Exit menu static const Int_t fgkFILEPRINTAS; ///< File/Print As... menu - + static const Int_t fgkABOUT; ///< About menu + static const Int_t fgkCOMPAREDATA; ///< Tools/Compare Data menu + static const char* fgkFileTypes[]; ///< For the open menu - ClassDef(AliMUONMchViewApplication,2) // mchview application + ClassDef(AliMUONMchViewApplication,4) // mchview application }; #endif diff --git a/MUON/AliMUONPainterColorSlider.cxx b/MUON/AliMUONPainterColorSlider.cxx index 21825d4d5a3..58952b8f0ef 100644 --- a/MUON/AliMUONPainterColorSlider.cxx +++ b/MUON/AliMUONPainterColorSlider.cxx @@ -39,7 +39,9 @@ AliMUONPainterColorSlider::AliMUONPainterColorSlider(const TGWindow* p, fEntryMin(0x0), fEntryMax(0x0), fMin(FLT_MAX), - fMax(-FLT_MAX) + fMax(-FLT_MAX), + fAutoButton(new TGTextButton(this,"Auto")), + fLockButton(new TGTextButton(this,"Lock")) { /// ctor Int_t ndivisions(20); @@ -77,11 +79,13 @@ AliMUONPainterColorSlider::AliMUONPainterColorSlider(const TGWindow* p, // fEntryMin->SetFormat(TGNumberFormat::kNESRealOne); // fEntryMax->SetFormat(TGNumberFormat::kNESRealOne); - TGTextButton* button = new TGTextButton(this,"Auto"); + AddFrame(fAutoButton,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0)); - AddFrame(button,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0)); + fAutoButton->Connect("Clicked()","AliMUONPainterColorSlider",this,"DataRangeAutoRequested()"); - button->Connect("Clicked()","AliMUONPainterColorSlider",this,"DataRangeAutoRequested()"); + AddFrame(fLockButton,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0)); + + fLockButton->Connect("Clicked()","AliMUONPainterColorSlider",this,"LockButtonWasClicked()"); fEntryMax->Connect("ValueSet(Long_t)","AliMUONPainterColorSlider",this,"DataRangeWasChanged(Double_t*)"); fEntryMin->Connect("ValueSet(Long_t)","AliMUONPainterColorSlider",this,"DataRangeWasChanged(Double_t*)"); @@ -117,6 +121,39 @@ AliMUONPainterColorSlider::DataRangeWasChanged(Double_t*) Emit("DataRangeWasChanged(Double_t*)",param); } +//_____________________________________________________________________________ +Bool_t +AliMUONPainterColorSlider::IsLocked() const +{ + /// Whether our range is locked or not + + return (fLockButton->GetString() == "Unlock"); // if we can unlock it means we are locked... +} + +//_____________________________________________________________________________ +void +AliMUONPainterColorSlider::LockButtonWasClicked() +{ + /// Lock (toggle button) was clicked + + if ( IsLocked() ) + { + // unlock it + fLockButton->SetText("Lock"); + fEntryMin->SetState(kTRUE); + fEntryMax->SetState(kTRUE); + fAutoButton->SetEnabled(kTRUE); + } + else + { + // lock it + fLockButton->SetText("Unlock"); + fEntryMin->SetState(kFALSE); + fEntryMax->SetState(kFALSE); + fAutoButton->SetEnabled(kFALSE); + } +} + //_____________________________________________________________________________ void AliMUONPainterColorSlider::SetRange(Double_t min, Double_t max, Bool_t emit) @@ -125,11 +162,14 @@ AliMUONPainterColorSlider::SetRange(Double_t min, Double_t max, Bool_t emit) AliDebug(1,Form("min %e max %e emit %d",min,max,emit)); - fMin = min; - fMax = max; + if ( !IsLocked() ) + { + fMin = min; + fMax = max; - fEntryMin->SetNumber(fMin); - fEntryMax->SetNumber(fMax); + fEntryMin->SetNumber(fMin); + fEntryMax->SetNumber(fMax); + } if ( emit ) { diff --git a/MUON/AliMUONPainterColorSlider.h b/MUON/AliMUONPainterColorSlider.h index 4f6670fd669..15132b63a21 100644 --- a/MUON/AliMUONPainterColorSlider.h +++ b/MUON/AliMUONPainterColorSlider.h @@ -17,6 +17,7 @@ #endif class TGNumberEntry; +class TGTextButton; class AliMUONPainterColorSlider : public TGCompositeFrame { @@ -27,9 +28,13 @@ public: void DataRangeAutoRequested(); // *SIGNAL* void DataRangeWasChanged(Double_t* range); // *SIGNAL* + + void LockButtonWasClicked(); void SetRange(Double_t min, Double_t max, Bool_t emit=kTRUE); + Bool_t IsLocked() const; + private: /// Not implemented AliMUONPainterColorSlider(const AliMUONPainterColorSlider& rhs); @@ -41,8 +46,10 @@ private: TGNumberEntry* fEntryMax; ///< textbox for max value to be represented Double_t fMin; ///< min value to be represented Double_t fMax; ///< max value to be represented + TGTextButton* fAutoButton; ///< to toggle data range computation + TGTextButton* fLockButton; ///< to toggle locking of range - ClassDef(AliMUONPainterColorSlider,1) // A painter color palette + ClassDef(AliMUONPainterColorSlider,2) // A painter color palette }; #endif diff --git a/MUON/AliMUONPainterDataSourceFrame.cxx b/MUON/AliMUONPainterDataSourceFrame.cxx index 0fcf99a761a..3e6bd4e44fb 100644 --- a/MUON/AliMUONPainterDataSourceFrame.cxx +++ b/MUON/AliMUONPainterDataSourceFrame.cxx @@ -64,9 +64,9 @@ AliMUONPainterDataSourceFrame::AliMUONPainterDataSourceFrame(const TGWindow* p, fRawSelector21(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)), fRawSelector22(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)), fRawSelector23(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)), - fCalibrateNoGain(new TGCheckButton(fRawSelector22,"Zero suppress")), - fCalibrateGainConstantCapa(new TGCheckButton(fRawSelector22,"Zero suppress + gain (capa cste)")), - fCalibrateGain(new TGCheckButton(fRawSelector22,"Full calib (zero suppress + gain with capa)")), + fCalibrateNoGain(new TGCheckButton(fRawSelector22,"Ped subraction")), + fCalibrateGainConstantCapa(new TGCheckButton(fRawSelector22,"Ped subraction + gain (capa cste)")), + fCalibrateGain(new TGCheckButton(fRawSelector22,"Full calib (Ped subraction + gain with capa)")), fHistogramButton(new TGCheckButton(fRawSelector23,"Histogram")), fHistoMin(new TGNumberEntry(fRawSelector23,0)), fHistoMax(new TGNumberEntry(fRawSelector23,4096)), @@ -84,15 +84,15 @@ AliMUONPainterDataSourceFrame::AliMUONPainterDataSourceFrame(const TGWindow* p, AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance(); - reg->Connect("DataReaderWasRegistered(AliMUONVTrackerDataMaker*)", + reg->Connect("DataMakerWasRegistered(AliMUONVTrackerDataMaker*)", "AliMUONPainterDataSourceFrame", this, - "DataReaderWasRegistered(AliMUONVTrackerDataMaker*)"); + "DataMakerWasRegistered(AliMUONVTrackerDataMaker*)"); - reg->Connect("DataReaderWasUnregistered(AliMUONVTrackerDataMaker*)", + reg->Connect("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)", "AliMUONPainterDataSourceFrame", this, - "DataReaderWasUnregistered(AliMUONVTrackerDataMaker*)"); + "DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)"); fItems->SetOwner(kFALSE); @@ -491,7 +491,7 @@ AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri) //_____________________________________________________________________________ void -AliMUONPainterDataSourceFrame::DataReaderWasRegistered(AliMUONVTrackerDataMaker* reader) +AliMUONPainterDataSourceFrame::DataMakerWasRegistered(AliMUONVTrackerDataMaker* reader) { /// Update ourselves as a new data reader was created @@ -517,12 +517,33 @@ AliMUONPainterDataSourceFrame::DataReaderWasRegistered(AliMUONVTrackerDataMaker* //_____________________________________________________________________________ void -AliMUONPainterDataSourceFrame::DataReaderWasUnregistered(AliMUONVTrackerDataMaker* /*reader*/) +AliMUONPainterDataSourceFrame::DataMakerWasUnregistered(AliMUONVTrackerDataMaker* maker) { - /// Update ourselves as a new data reader was deleted + /// Update ourselves as a data reader was deleted - // here we should find which (if any) datasourceitem has this reader, and remove it + AliMUONPainterDataSourceItem* theItem(0x0); + TIter next(fItems); + AliMUONPainterDataSourceItem* item; + + while ( ( item = static_cast(next()) ) && !theItem ) + { + if ( item->DataMaker() == maker ) + { + theItem = item; + } + } + + if (!theItem) return; + + fDataReaders->RemoveFrame(theItem); + fItems->Remove(theItem); + theItem->DestroyWindow(); + delete theItem; + + fDataReaders->MapSubwindows(); + fDataReaders->Resize(); + } //_____________________________________________________________________________ @@ -540,12 +561,19 @@ AliMUONPainterDataSourceFrame::OpenFileDialog() 0,0 }; fileInfo.fFileTypes = fileTypes; + delete[] fileInfo.fIniDir; + + AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env(); + + fileInfo.fIniDir = StrDup(env->String("LastOpenDir",".")); new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(), kFDOpen,&fileInfo); - fFilePath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename))); + + env->Set("LastOpenDir",fileInfo.fIniDir); + env->Save(); } diff --git a/MUON/AliMUONPainterDataSourceFrame.h b/MUON/AliMUONPainterDataSourceFrame.h index 3c44d9be7d0..0d28edc8c75 100644 --- a/MUON/AliMUONPainterDataSourceFrame.h +++ b/MUON/AliMUONPainterDataSourceFrame.h @@ -37,9 +37,9 @@ public: void CreateRawDataSource(); - void DataReaderWasRegistered(AliMUONVTrackerDataMaker* reader); + void DataMakerWasRegistered(AliMUONVTrackerDataMaker* reader); - void DataReaderWasUnregistered(AliMUONVTrackerDataMaker* reader); + void DataMakerWasUnregistered(AliMUONVTrackerDataMaker* reader); void HistogramButtonClicked(); diff --git a/MUON/AliMUONPainterDataSourceItem.cxx b/MUON/AliMUONPainterDataSourceItem.cxx index 4ea9305e6df..7c7036f0697 100644 --- a/MUON/AliMUONPainterDataSourceItem.cxx +++ b/MUON/AliMUONPainterDataSourceItem.cxx @@ -17,9 +17,14 @@ #include "AliMUONPainterDataSourceItem.h" +#include "AliMUONPainterEnv.h" +#include "AliMUONPainterHelper.h" +#include "AliMUONPainterRegistry.h" #include "AliMUONVTrackerDataMaker.h" #include "AliMUONVTrackerData.h" #include "AliLog.h" +#include +#include #include #include #include @@ -54,6 +59,11 @@ namespace while ( ok ) { ok = reader->NextEvent(); + if ( reader->IsZombie() ) + { + AliMUONPainterRegistry::Instance()->DeleteZombies(); + return 0x0; + } if ( !reader->IsRunning() ) gSystem->Sleep(1000); } @@ -66,58 +76,86 @@ namespace //_____________________________________________________________________________ AliMUONPainterDataSourceItem::AliMUONPainterDataSourceItem(const TGWindow* p, UInt_t w, UInt_t h, - AliMUONVTrackerDataMaker* reader) + AliMUONVTrackerDataMaker* maker) : TGCompositeFrame(p,w,h,kHorizontalFrame), - fDataReader(reader), - fSourceName(new TGLabel(this,reader->Data()->Name())), - fSource(new TGLabel(this,reader->Source().Data())), + fDataMaker(maker), + fSourceName(new TGLabel(this,maker->Data()->Name())), + fSource(new TGLabel(this,maker->Source().Data())), fNumberOfEvents(new TGLabel(this,Form("%10d",0))), - fRun(new TGTextButton(this,"Run")), - fStop(new TGTextButton(this,"Stop")), - fRewind(new TGTextButton(this,"Rewind")), - fRemove(0x0),//new TGTextButton(this,"Remove")), + fRun(0x0), + fStop(0x0), + fRewind(0x0), + fRemove(new TGTextButton(this,"Remove")), + fSave(new TGTextButton(this,"Save")), + fSaveAs(new TGTextButton(this,"Save As...")), fThread(0x0), fShouldReset(kFALSE) { /// ctor + + SetCleanup(kDeepCleanup); Update(); - fRun->SetEnabled(reader->Data()->IsRunnable()); - fRun->Connect("Clicked()", - "AliMUONPainterDataSourceItem", - this, - "Run()"); - - fStop->SetEnabled(kFALSE); - fStop->Connect("Clicked()", - "AliMUONPainterDataSourceItem", - this, - "Stop()"); - - fRewind->SetEnabled(kFALSE); - fRewind->Connect("Clicked()", - "AliMUONPainterDataSourceItem", - this, - "Rewind()"); - -// fRemove->Connect("Clicked()", -// "AliMUONPainterDataSourceItem", -// this, -// "Remove()"); - AddFrame(fSourceName, new TGLayoutHints(kLHintsNormal | kLHintsCenterY,5,5,5,5)); AddFrame(fSource,new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,5,5,5,5)); AddFrame(fNumberOfEvents,new TGLayoutHints(kLHintsNormal | kLHintsCenterY,5,5,5,5)); - AddFrame(fRun,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); - AddFrame(fStop,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); - AddFrame(fRewind,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); -// AddFrame(fRemove,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); - - reader->Data()->Connect("NumberOfEventsChanged()", + + if ( fDataMaker->IsRunnable() ) + { + fRun = new TGTextButton(this,"Run"); + fStop = new TGTextButton(this,"Stop"); + fRewind = new TGTextButton(this,"Rewind"); + + fRun->SetEnabled(!maker->Data()->IsSingleEvent()); + fRun->Connect("Clicked()", + "AliMUONPainterDataSourceItem", + this, + "Run()"); + + fStop->SetEnabled(kFALSE); + fStop->Connect("Clicked()", + "AliMUONPainterDataSourceItem", + this, + "Stop()"); + + fRewind->SetEnabled(kFALSE); + fRewind->Connect("Clicked()", + "AliMUONPainterDataSourceItem", + this, + "Rewind()"); + + AddFrame(fRun,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); + AddFrame(fStop,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); + AddFrame(fRewind,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); + } + + AddFrame(fRemove,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); + + AddFrame(fSave,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); + + AddFrame(fSaveAs,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5)); + + maker->Data()->Connect("NumberOfEventsChanged()", "AliMUONPainterDataSourceItem", this, "Update()"); + + fRemove->Connect("Clicked()", + "AliMUONPainterDataSourceItem", + this, + "Remove()"); + + fSave->Connect("Clicked()", + "AliMUONPainterDataSourceItem", + this, + "Save()"); + + fSaveAs->Connect("Clicked()", + "AliMUONPainterDataSourceItem", + this, + "SaveWithDialog()"); + Resize(); } @@ -135,7 +173,10 @@ void AliMUONPainterDataSourceItem::EnableRun() { /// Enable run button - fRun->SetEnabled(kTRUE); + if ( fRun ) + { + fRun->SetEnabled(kTRUE); + } } //_____________________________________________________________________________ @@ -143,15 +184,28 @@ void AliMUONPainterDataSourceItem::DisableRun() { /// Disable run button - fRun->SetEnabled(kFALSE); + if ( fRun ) + { + fRun->SetEnabled(kFALSE); + } } + +//_____________________________________________________________________________ +void +AliMUONPainterDataSourceItem::Remove() +{ + /// Remove + MakeZombie(); + AliMUONPainterRegistry::Instance()->Unregister(fDataMaker); +} + //_____________________________________________________________________________ void AliMUONPainterDataSourceItem::Reset() { /// Reset the data - fDataReader->Data()->Clear(); + fDataMaker->Data()->Clear(); } //_____________________________________________________________________________ @@ -168,11 +222,14 @@ AliMUONPainterDataSourceItem::Rewind() delete fThread; fThread = 0x0; - fRun->SetEnabled(kTRUE); - fStop->SetEnabled(kFALSE); - fRewind->SetEnabled(kFALSE); + if ( fRun && fStop && fRewind ) + { + fRun->SetEnabled(kTRUE); + fStop->SetEnabled(kFALSE); + fRewind->SetEnabled(kFALSE); + } - fDataReader->Rewind(); + fDataMaker->Rewind(); fShouldReset = kTRUE; } @@ -191,20 +248,80 @@ AliMUONPainterDataSourceItem::Run() fShouldReset = kFALSE; } -// fRemove->SetEnabled(kFALSE); + fRemove->SetEnabled(kFALSE); if (!fThread) { fParams[0] = (Long_t)(this); - fParams[1] = (Long_t)(fDataReader); + fParams[1] = (Long_t)(fDataMaker); fThread = new TThread(RunFunction,(void*)(&fParams[0])); fThread->Run(); } - fDataReader->SetRunning(kTRUE); + fDataMaker->SetRunning(kTRUE); - fRun->SetEnabled(kFALSE); - fStop->SetEnabled(kTRUE); + if ( fRun && fStop ) + { + fRun->SetEnabled(kFALSE); + fStop->SetEnabled(kTRUE); + } +} + +//_____________________________________________________________________________ +void +AliMUONPainterDataSourceItem::Save(const char* filename) +{ + /// Save the data maker + + TFile* f = TFile::Open(filename,"RECREATE"); + + fDataMaker->Write(); + + f->Write(); + f->Close(); + + delete f; +} + +//_____________________________________________________________________________ +void +AliMUONPainterDataSourceItem::Save() +{ + /// Save the data maker (filename is fixed) + + TString dname(fDataMaker->Data()->GetName()); + dname.ToLower(); + + TString outputDir(AliMUONPainterHelper::Instance()->Env()->String("LastSaveDir",".")); + + TString filename(Form("%s/mchview.%s.root",gSystem->ExpandPathName(outputDir.Data()),dname.Data())); + + Save(filename.Data()); +} + +//_____________________________________________________________________________ +void +AliMUONPainterDataSourceItem::SaveWithDialog() +{ + /// Save the data maker (filename given by dialog) + + TGFileInfo fileInfo; + +// fileInfo.fFileTypes = fgkFileTypes; + + delete[] fileInfo.fIniDir; + + AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env(); + + fileInfo.fIniDir = StrDup(env->String("LastSaveDir",".")); + + new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(), + kFDSave,&fileInfo); + + env->Set("LastSaveDir",fileInfo.fIniDir); + env->Save(); + + Save(fileInfo.fFilename); } //_____________________________________________________________________________ @@ -215,12 +332,15 @@ AliMUONPainterDataSourceItem::Stop() StopRunning(); - fDataReader->SetRunning(kFALSE); + fDataMaker->SetRunning(kFALSE); - fStop->SetEnabled(kFALSE); - fRun->SetEnabled(kTRUE); - - // fRemove->SetEnabled(kTRUE); + if ( fStop && fRun ) + { + fStop->SetEnabled(kFALSE); + fRun->SetEnabled(kTRUE); + } + + fRemove->SetEnabled(kTRUE); } //_____________________________________________________________________________ @@ -229,7 +349,7 @@ AliMUONPainterDataSourceItem::Update() { /// Update ourselves - fNumberOfEvents->SetText(Form("%10d",fDataReader->Data()->NumberOfEvents())); + fNumberOfEvents->SetText(Form("%10d",fDataMaker->Data()->NumberOfEvents())); } //_____________________________________________________________________________ diff --git a/MUON/AliMUONPainterDataSourceItem.h b/MUON/AliMUONPainterDataSourceItem.h index 386ebcafeaa..4f6aec55476 100644 --- a/MUON/AliMUONPainterDataSourceItem.h +++ b/MUON/AliMUONPainterDataSourceItem.h @@ -26,7 +26,7 @@ class AliMUONPainterDataSourceItem : public TGCompositeFrame { public: AliMUONPainterDataSourceItem(const TGWindow* p, UInt_t w, UInt_t h, - AliMUONVTrackerDataMaker* reader); + AliMUONVTrackerDataMaker* maker); virtual ~AliMUONPainterDataSourceItem(); void Run(); @@ -35,14 +35,14 @@ public: void Rewind(); -//void Remove(); //*SIGNAL* + void Remove(); void Update(); void Reset(); /// Return data source reader - AliMUONVTrackerDataMaker* DataMaker() const { return fDataReader; } + AliMUONVTrackerDataMaker* DataMaker() const { return fDataMaker; } void EnableRun(); @@ -52,13 +52,20 @@ public: void StopRunning(); //*SIGNAL* + void Save(); + + void SaveWithDialog(); + private: + + void Save(const char* filename); + /// Not implemented AliMUONPainterDataSourceItem(const AliMUONPainterDataSourceItem& rhs); /// Not implemented AliMUONPainterDataSourceItem& operator=(const AliMUONPainterDataSourceItem& rhs); - AliMUONVTrackerDataMaker* fDataReader; ///< data source reader (not owner) + AliMUONVTrackerDataMaker* fDataMaker; ///< data source reader (not owner) TGLabel* fSourceName; ///< the (short) name of the data source TGLabel* fSource; ///< the full uri of the data source TGLabel* fNumberOfEvents; ///< number of evts this source has seen so far @@ -66,13 +73,14 @@ private: TGTextButton* fStop; ///< button to stop running over the source TGTextButton* fRewind; ///< button to rewind events for the source TGTextButton* fRemove; ///< button to remove the source - + TGTextButton* fSave; ///< button to save the source (filename is fixed) + TGTextButton* fSaveAs; ///< button to save as... TThread* fThread; ///< thread used to actually loop over the data Long_t fParams[2]; ///< used in conjunction with fThread Bool_t fShouldReset; ///< whether we should reset or not... - ClassDef(AliMUONPainterDataSourceItem,1) // Data source widget + ClassDef(AliMUONPainterDataSourceItem,3) // Data source widget }; #endif diff --git a/MUON/AliMUONPainterHelper.cxx b/MUON/AliMUONPainterHelper.cxx index 929a07c1ae8..3575009302f 100644 --- a/MUON/AliMUONPainterHelper.cxx +++ b/MUON/AliMUONPainterHelper.cxx @@ -500,7 +500,7 @@ AliMUONPainterHelper::Instance() AliMUONPainterEnv env; - TString fileName(gSystem->ExpandPathName(env.String("PadStoreFileName","padstore.root"))); + TString fileName(gSystem->ExpandPathName(env.String("PadStoreFileName","$HOME/padstore.root"))); if ( gSystem->AccessPathName(fileName.Data(),kFileExists) ) // mind the strange return value of that method... { @@ -523,6 +523,7 @@ AliMUONPainterHelper::Instance() fgInstance->GenerateDefaultMatrices(); fgInstance->Modified(kTRUE); fgInstance->fEnv = new AliMUONPainterEnv; + fgInstance->fEnv->Set("PadStoreFileName",fileName.Data()); fgInstance->Save(); } @@ -734,7 +735,9 @@ AliMUONPainterHelper::Save() fgInstance->Print(); - TString fileName(gSystem->ExpandPathName(fgInstance->Env()->String("PadStoreFileName","padstore.root"))); + fgInstance->Env()->Save(); + + TString fileName(gSystem->ExpandPathName(fgInstance->Env()->String("PadStoreFileName"))); AliInfo(Form("Saving to %s",fileName.Data())); diff --git a/MUON/AliMUONPainterInterfaceHelper.cxx b/MUON/AliMUONPainterInterfaceHelper.cxx index 08336b9e303..0156550cef5 100644 --- a/MUON/AliMUONPainterInterfaceHelper.cxx +++ b/MUON/AliMUONPainterInterfaceHelper.cxx @@ -156,10 +156,17 @@ AliMUONPainterInterfaceHelper::Dump(const TGButtonGroup& bg) for ( Int_t i = ButtonStartingId(); i < bg.GetCount() + ButtonStartingId(); ++i ) { TGTextButton* button = static_cast(bg.GetButton(i)); - cout << Form("i %2d button %s id %d wid %d ON %d", + if ( button ) + { + cout << Form("i %2d button %s id %d wid %d ON %d", i,button->GetTitle(),button->GetId(), button->WidgetId(), button->IsOn()) << endl; + } + else + { + cout << Form("i %2d button = 0x0",i) << endl; + } } } @@ -173,9 +180,17 @@ AliMUONPainterInterfaceHelper::FindButtonByName(const TGButtonGroup& bg, for ( Int_t i = ButtonStartingId(); i < ButtonStartingId() + bg.GetCount(); ++i ) { TGTextButton* button = static_cast(bg.GetButton(i)); - if ( name == button->GetTitle() ) + if (!button) { - return button; + AliErrorClass(Form("(%s) : Something wrong",name.Data())); + Dump(bg); + } + else + { + if ( name == button->GetTitle() ) + { + return button; + } } } return 0x0; @@ -315,3 +330,36 @@ AliMUONPainterInterfaceHelper::Unselect(TGButtonGroup& bg, } } +//_____________________________________________________________________________ +void +AliMUONPainterInterfaceHelper::RemoveButton(TGButtonGroup& bg, + TGButton* button) +{ + /// Remove a button + + // need to redo it from scratch in order not the leave holes in the + // id numbering + + TGButtonGroup bgtmp(bg.GetParent(),bg.GetTitle()); + + Int_t id(ButtonStartingId()); + + for ( Int_t i = ButtonStartingId(); i < ButtonStartingId() + bg.GetCount(); ++i ) + { + TGTextButton* b = static_cast(bg.GetButton(i)); + + if ( b != button ) + { + TGButton* bc = new TGRadioButton(&bgtmp,b->GetTitle(),id); + ++id; + bc->SetUserData(b->GetUserData()); + bc->SetOn(b->IsOn()); + } + } + + ClearButtons(bg); + + Copy(bgtmp,bg); + + bg.Show(); +} diff --git a/MUON/AliMUONPainterInterfaceHelper.h b/MUON/AliMUONPainterInterfaceHelper.h index 8bd27a3f02c..bf35475393e 100644 --- a/MUON/AliMUONPainterInterfaceHelper.h +++ b/MUON/AliMUONPainterInterfaceHelper.h @@ -64,6 +64,8 @@ public: static void Unselect(TGButtonGroup& bg, const TString& buttonName, Bool_t emit=kFALSE); + static void RemoveButton(TGButtonGroup& bg, TGButton* button); + ClassDef(AliMUONPainterInterfaceHelper,1) // Helper class for TGButtonGroup manipulation }; diff --git a/MUON/AliMUONPainterMasterFrame.cxx b/MUON/AliMUONPainterMasterFrame.cxx index c17e941ad22..a47b1ae20ff 100644 --- a/MUON/AliMUONPainterMasterFrame.cxx +++ b/MUON/AliMUONPainterMasterFrame.cxx @@ -284,23 +284,26 @@ void AliMUONPainterMasterFrame::Clicked(AliMUONVPainter* painter, Double_t* values) { /// A given painter was (singly) clicked - - AliDebug(1,Form("%s x %7.3f y %7.3f",painter->GetName(),values[0],values[1])); - AliCodeTimerAuto("") - - fPainterMatrixFrame->MouseLeave(painter); + if ( painter->CanBeDetached() ) + { + fPainterMatrixFrame->MouseLeave(painter); - AliMUONPainterMatrix* matrix = new AliMUONPainterMatrix(painter->Name().Data()); + AliMUONPainterMatrix* matrix = new AliMUONPainterMatrix(painter->Name().Data()); - AliMUONVPainter* p = painter->Detach(); + AliMUONVPainter* p = painter->Detach(); - p->SetResponder(1); + p->SetResponder(1); - matrix->Adopt(p); + matrix->Adopt(p); - AddPainterMatrix(matrix); - ShowPainterMatrix(matrix); + AddPainterMatrix(matrix); + ShowPainterMatrix(matrix); + } + else + { + painter->DrawHistogram(values); + } } //_____________________________________________________________________________ @@ -309,6 +312,8 @@ AliMUONPainterMasterFrame::ShiftClicked(AliMUONVPainter* painter, Double_t*) { /// A given painter was shift-clicked + if ( !painter->CanBeDetached() ) return; + AliMUONPainterMatrix* currentMatrix = fPainterMatrixFrame->Matrix(); AliMUONAttPainter a = painter->Attributes(); @@ -317,8 +322,7 @@ AliMUONPainterMasterFrame::ShiftClicked(AliMUONVPainter* painter, Double_t*) TString newName = AliMUONPainterMatrix::NameIt(basename.Data(),a); - AliMUONPainterMatrix* matrix = - AliMUONPainterRegistry::Instance()->FindPainterMatrix(newName.Data()); + AliMUONPainterMatrix* matrix = AliMUONPainterRegistry::Instance()->PainterMatrix(newName.Data()); if (!matrix) { @@ -342,16 +346,16 @@ AliMUONPainterMasterFrame::ShiftClicked(AliMUONVPainter* painter, Double_t*) a1.SetCathodeAndPlaneDisabled(kTRUE); a2.SetCathodeAndPlaneDisabled(kTRUE); - + AliMUONVPainter* p1 = AliMUONVPainter::CreatePainter(painter->ClassName(), a1, painter->ID0(), painter->ID1()); AliMUONVPainter* p2 = AliMUONVPainter::CreatePainter(painter->ClassName(), - a2, - painter->ID0(), - painter->ID1()); + a2, + painter->ID0(), + painter->ID1()); if (!p1 || !p2) { @@ -375,7 +379,7 @@ AliMUONPainterMasterFrame::ShiftClicked(AliMUONVPainter* painter, Double_t*) Int_t ny(1); AliMpArea area(painter->Area()); - + if ( area.Dimensions().X() > 1.2*area.Dimensions().Y() ) { nx = 1; @@ -436,12 +440,13 @@ AliMUONPainterMasterFrame::MakeTopPainterMatrix(UInt_t w, UInt_t h) AliMUONAttPainter att; - att.SetCathode(kTRUE,kFALSE); + att.SetPlane(kTRUE,kFALSE); +// att.SetCathode(kTRUE,kFALSE); att.SetViewPoint(kTRUE,kFALSE); TString name = AliMUONPainterMatrix::NameIt("Tracker",att); - AliMUONPainterMatrix* painterMatrix = AliMUONPainterRegistry::Instance()->FindPainterMatrix(name); + AliMUONPainterMatrix* painterMatrix = AliMUONPainterRegistry::Instance()->PainterMatrix(name); if (!painterMatrix) { @@ -498,8 +503,7 @@ AliMUONPainterMasterFrame::AttributesChanged(AliMUONAttPainter* newValues) TString newName = AliMUONPainterMatrix::NameIt(currentMatrix->Basename(),a); - AliMUONPainterMatrix* matrix = - AliMUONPainterRegistry::Instance()->FindPainterMatrix(newName.Data()); + AliMUONPainterMatrix* matrix = AliMUONPainterRegistry::Instance()->PainterMatrix(newName.Data()); if (!matrix) { diff --git a/MUON/AliMUONPainterMatrixFrame.cxx b/MUON/AliMUONPainterMatrixFrame.cxx index 61c0d3a8d84..feb6f1c32bd 100644 --- a/MUON/AliMUONPainterMatrixFrame.cxx +++ b/MUON/AliMUONPainterMatrixFrame.cxx @@ -283,7 +283,10 @@ AliMUONPainterMatrixFrame::DataRangeWasChanged(Double_t* range) fPainterMatrix->SetDataRange(range[0],range[1]); - Update(); + if ( !fColorSlider->IsLocked() ) + { + Update(); + } } //_____________________________________________________________________________ @@ -523,6 +526,12 @@ void AliMUONPainterMatrixFrame::UpdateDataRange() { /// Update the data range + + if ( fColorSlider->IsLocked() ) + { + fColorSlider->SetRange(0,0,kTRUE); + return; + } Double_t min, max; diff --git a/MUON/AliMUONPainterPlotSelector.cxx b/MUON/AliMUONPainterPlotSelector.cxx index 832fd4c418c..643d481efa0 100644 --- a/MUON/AliMUONPainterPlotSelector.cxx +++ b/MUON/AliMUONPainterPlotSelector.cxx @@ -142,7 +142,7 @@ AliMUONPainterPlotSelector::CreateDimensionButtons(const char* dataSourceName) AliDebug(1,Form("Creating dimension buttons for dataSource %s",dataSourceName)); - AliMUONVTrackerData* data = AliMUONPainterRegistry::Instance()->FindDataSource(dataSourceName); + AliMUONVTrackerData* data = AliMUONPainterRegistry::Instance()->DataSource(dataSourceName); TGButtonGroup* bg = new TGButtonGroup(this,0,3,5,0,dataSourceName); @@ -246,14 +246,14 @@ AliMUONPainterPlotSelector::NumberOfEventsChanged() // find first the sender of the signal - AliMUONVTrackerData* data = reinterpret_cast(gTQSender); - - TGButton* button = AliMUONPainterInterfaceHelper::FindButtonByUserData(*fDataSourceNames,data); - - if (button) - { - button->SetToolTipText(Form("%d events",data->NumberOfEvents()),250); - } +// AliMUONVTrackerData* data = reinterpret_cast(gTQSender); +// +// TGButton* button = AliMUONPainterInterfaceHelper::FindButtonByUserData(*fDataSourceNames,data); +// +// if (button) +// { +// button->SetToolTipText(Form("%d events",data->NumberOfEvents()),250); +// } } //_____________________________________________________________________________ @@ -262,29 +262,33 @@ AliMUONPainterPlotSelector::DataSourceWasUnregistered(AliMUONVTrackerData* data) { /// A data source has been unregistered : remove it from the interface - AliDebug(1,Form("Unregistering %s",data->GetName())); + TGButton* button = AliMUONPainterInterfaceHelper::FindButtonByUserData(*fDataSourceNames,data); - TGButton* button = AliMUONPainterInterfaceHelper::FindButtonByName(*fDataSourceNames, - data->GetName()); - AliMUONVTrackerData* check = reinterpret_cast(button->GetUserData()); - if ( !button || check != data ) + TGButton* bd = AliMUONPainterInterfaceHelper::FindDownButton(*fDataSourceNames); + + if ( bd == button ) { - AliError("Something is seriously wrong. Please check"); - return; + // selected data source is the one we are removing... + // revert to "none" before actually removing it. + SourceButtonWasClicked(1); } - fDataSourceNames->Remove(button); - delete button; - button->DestroyWindow(); - - fDataSourceNames->Show(); + AliMUONPainterInterfaceHelper::RemoveButton(*fDataSourceNames,button); + + // do not forget to re-connect things + fDataSourceNames->Connect("Clicked(Int_t)","AliMUONPainterPlotSelector", + this, + "SourceButtonWasClicked(Int_t)"); + TObject* o = fDimensionButtonMap->Remove(new TObjString(data->GetName())); if (!o) { AliError("Remove failed. Please check"); } + + fDataSourceNames->Show(); Layout(); } diff --git a/MUON/AliMUONPainterRegistry.cxx b/MUON/AliMUONPainterRegistry.cxx index 70f5c796054..1802420db2d 100644 --- a/MUON/AliMUONPainterRegistry.cxx +++ b/MUON/AliMUONPainterRegistry.cxx @@ -43,40 +43,39 @@ AliMUONPainterRegistry* AliMUONPainterRegistry::fgInstance(0x0); //_____________________________________________________________________________ AliMUONPainterRegistry::AliMUONPainterRegistry() : TObject(), TQObject(), -fDataSources(new TObjArray), fPainterMatrices(new TObjArray), -fDataReaders(new TObjArray), +fDataMakers(new TObjArray), fHistoryMenu(0x0), fMenuBar(0x0), -fHistoryCounter(0) +fHistoryCounter(0), +fZombies(new TObjArray) { /// 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; } //_____________________________________________________________________________ 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,35 +85,30 @@ 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(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(AliMUONVTrackerDataMaker* data) { /// A data reader was unregistered Long_t param[] = { (Long_t)data }; - Emit("DataReaderWasUnregistered(AliMUONVTrackerDataMaker*)",param); + Emit("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)",param); } @@ -141,10 +135,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 +158,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)); @@ -293,13 +288,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 +304,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 +339,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 +366,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 +381,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 ); } diff --git a/MUON/AliMUONPainterRegistry.h b/MUON/AliMUONPainterRegistry.h index 5474230a74a..5e0fb2ab1e6 100644 --- a/MUON/AliMUONPainterRegistry.h +++ b/MUON/AliMUONPainterRegistry.h @@ -31,38 +31,36 @@ class AliMUONPainterRegistry : public TObject, public TQObject public: virtual ~AliMUONPainterRegistry(); - AliMUONVTrackerDataMaker* DataReader(Int_t i) const; + AliMUONVTrackerDataMaker* DataMaker(Int_t i) const; AliMUONVTrackerData* DataSource(Int_t i) const; + AliMUONVTrackerData* DataSource(const char* name) const; + void DataSourceWasRegistered(AliMUONVTrackerData* data); // *SIGNAL* void DataSourceWasUnregistered(AliMUONVTrackerData* data); // *SIGNAL* - void DataReaderWasRegistered(AliMUONVTrackerDataMaker* reader); // *SIGNAL* + void DataMakerWasRegistered(AliMUONVTrackerDataMaker* reader); // *SIGNAL* - void DataReaderWasUnregistered(AliMUONVTrackerDataMaker* reader); // *SIGNAL* + void DataMakerWasUnregistered(AliMUONVTrackerDataMaker* reader); // *SIGNAL* - AliMUONVTrackerData* FindDataSource(const char* name) const; - Int_t FindIndexOf(AliMUONPainterMatrix* group) const; - Int_t FindIndexOf(AliMUONVTrackerData* data) const; - - AliMUONPainterMatrix* FindPainterMatrix(const char* groupName) const; - void HistoryMenuActivated(Int_t i); static AliMUONPainterRegistry* Instance(); - Int_t NumberOfDataReaders() const; + Int_t NumberOfDataMakers() const; - Int_t NumberOfDataSources() const; + Int_t NumberOfDataSources() const { return NumberOfDataMakers(); } Int_t NumberOfPainterMatrices() const; AliMUONPainterMatrix* PainterMatrix(Int_t i) const; + AliMUONPainterMatrix* PainterMatrix(const char* groupName) const; + void AddToHistory(AliMUONPainterMatrix* group); void PainterMatrixWasRegistered(AliMUONPainterMatrix* group); // *SIGNAL* @@ -75,8 +73,6 @@ public: Int_t Register(AliMUONPainterMatrix* group); - void Register(AliMUONVTrackerData* data); - void Register(AliMUONVTrackerDataMaker* reader); /// Set the menu bar where to put the history menu @@ -84,10 +80,10 @@ public: Bool_t Unregister(AliMUONPainterMatrix* group); - Bool_t Unregister(AliMUONVTrackerData* data); - Bool_t Unregister(AliMUONVTrackerDataMaker* reader); + void DeleteZombies(); + private: /// Not implemented AliMUONPainterRegistry(); @@ -98,14 +94,14 @@ private: private: static AliMUONPainterRegistry* fgInstance; ///< unique instance - TObjArray* fDataSources; ///< data sources TObjArray* fPainterMatrices; ///< painter matrices - TObjArray* fDataReaders; ///< data readers + TObjArray* fDataMakers; ///< data makers TGPopupMenu* fHistoryMenu; ///< history menu TGMenuBar* fMenuBar; ///< Menu bar where to put the history menu Int_t fHistoryCounter; ///< index to get back history menu items + TObjArray* fZombies; ///< data readers to be deleted - ClassDef(AliMUONPainterRegistry,1) // Registry for AliMUONVPainter related stuff + ClassDef(AliMUONPainterRegistry,3) // Registry for AliMUONVPainter related stuff }; #endif diff --git a/MUON/AliMUONTrackerCalibratedDataMaker.cxx b/MUON/AliMUONTrackerCalibratedDataMaker.cxx index e35317286fe..e9a55d50791 100644 --- a/MUON/AliMUONTrackerCalibratedDataMaker.cxx +++ b/MUON/AliMUONTrackerCalibratedDataMaker.cxx @@ -58,7 +58,6 @@ AliMUONTrackerCalibratedDataMaker::AliMUONTrackerCalibratedDataMaker(AliRawReade fRawReader(reader), fAccumulatedData(0x0), fOneEventData(new AliMUON2DMap(true)), - fIsOwner(kTRUE), fSource("unspecified"), fIsRunning(kFALSE), fDigitMaker(0x0), @@ -66,12 +65,18 @@ AliMUONTrackerCalibratedDataMaker::AliMUONTrackerCalibratedDataMaker(AliRawReade fCalibrationData(0x0), fDigitStore(0x0), fCDBPath(cdbpath), - fNumberOfEvents(0){ + fNumberOfEvents(0) +{ /// Ctor - reader->NextEvent(); // to be sure to get run number available - - Int_t runNumber = reader->GetRunNumber(); - + + Int_t runNumber(0); + + if ( fRawReader ) + { + reader->NextEvent(); // to be sure to get run number available + runNumber = reader->GetRunNumber(); + } + ++fgkCounter; Bool_t calibrate = ( fCDBPath.Length() > 0 ); @@ -110,7 +115,7 @@ AliMUONTrackerCalibratedDataMaker::AliMUONTrackerCalibratedDataMaker(AliRawReade AliInfo(Form("Will histogram between %e and %e",xmin,xmax)); } - reader->RewindEvents(); + if (fRawReader) fRawReader->RewindEvents(); fDigitMaker = new AliMUONDigitMaker; fDigitMaker->SetMakeTriggerDigits(kFALSE); @@ -154,7 +159,7 @@ AliMUONTrackerCalibratedDataMaker::~AliMUONTrackerCalibratedDataMaker() { /// dtor delete fOneEventData; - if ( fIsOwner ) delete fAccumulatedData; + delete fAccumulatedData; delete fRawReader; delete fDigitStore; delete fCalibrationData; @@ -162,6 +167,15 @@ AliMUONTrackerCalibratedDataMaker::~AliMUONTrackerCalibratedDataMaker() delete fDigitCalibrator; } +//_____________________________________________________________________________ +Long64_t +AliMUONTrackerCalibratedDataMaker::Merge(TCollection*) +{ + /// Merge + AliError("Not implemented yet"); + return 0; +} + //_____________________________________________________________________________ Bool_t AliMUONTrackerCalibratedDataMaker::NextEvent() diff --git a/MUON/AliMUONTrackerCalibratedDataMaker.h b/MUON/AliMUONTrackerCalibratedDataMaker.h index 9aa9a045c88..c6d688140ac 100644 --- a/MUON/AliMUONTrackerCalibratedDataMaker.h +++ b/MUON/AliMUONTrackerCalibratedDataMaker.h @@ -59,9 +59,6 @@ public: void Rewind(); - /// Tell if we are owner of our data or not - void SetOwner(Bool_t flag) { fIsOwner = flag; } - /// Get our source URI virtual TString Source() const { return fSource.Data(); } @@ -74,6 +71,8 @@ public: /// Number of events seen Int_t NumberOfEvents() const { return fNumberOfEvents; } + virtual Long64_t Merge(TCollection* list); + private: /// Not implemented AliMUONTrackerCalibratedDataMaker(const AliMUONTrackerCalibratedDataMaker& rhs); @@ -83,21 +82,20 @@ private: Bool_t ConvertDigits(); private: - AliRawReader* fRawReader; ///< reader of the data (owner) - AliMUONVTrackerData* fAccumulatedData; ///< data (owner if fIsOwner==kTRUE) + AliRawReader* fRawReader; //!< reader of the data (owner) + AliMUONVTrackerData* fAccumulatedData; ///< data (owner) AliMUONVStore* fOneEventData; ///< data for one event (owner) - Bool_t fIsOwner; ///< whether we are owner of our data or not TString fSource; ///< where the data comes from Bool_t fIsRunning; ///< whether we are running or are paused AliMUONDigitMaker* fDigitMaker; ///< digit maker - AliMUONDigitCalibrator* fDigitCalibrator; ///< digit calibrator (if calibrating data) + AliMUONDigitCalibrator* fDigitCalibrator; //!< digit calibrator (if calibrating data) AliMUONCalibrationData* fCalibrationData; ///< calibration data (if calibrating data) AliMUONVDigitStore* fDigitStore; ///< digit store (if calibrating data) TString fCDBPath; ///< OCDB path (if calibrating data) Int_t fNumberOfEvents; ///< number of events seen static Int_t fgkCounter; ///< to count the number of instances - ClassDef(AliMUONTrackerCalibratedDataMaker,1) // Producer of calibrated AliMUONVTrackerData from raw data + ClassDef(AliMUONTrackerCalibratedDataMaker,2) // Producer of calibrated AliMUONVTrackerData from raw data }; #endif diff --git a/MUON/AliMUONTrackerData.cxx b/MUON/AliMUONTrackerData.cxx index f7f094b0a4a..655a28514ea 100644 --- a/MUON/AliMUONTrackerData.cxx +++ b/MUON/AliMUONTrackerData.cxx @@ -57,20 +57,20 @@ const Int_t AliMUONTrackerData::fgkVirtualExtraDimension = 1; //_____________________________________________________________________________ AliMUONTrackerData::AliMUONTrackerData(const char* name, const char* title, Int_t dimension, - Bool_t runnable) + Bool_t issingleevent) : AliMUONVTrackerData(name,title), +fIsSingleEvent(issingleevent), fChannelValues(0x0), fManuValues(0x0), fBusPatchValues(0x0), fDEValues(0x0), fChamberValues(0x0), fPCBValues(0x0), -fDimension(dimension*2+fgkExtraDimension), +fDimension(External2Internal(dimension)+fgkExtraDimension), fNevents(0x0), fDimensionNames(new TObjArray(fDimension+fgkVirtualExtraDimension)), fExternalDimensionNames(new TObjArray(dimension)), fExternalDimension(dimension), -fIsRunnable(runnable), fHistogramming(new Int_t[fExternalDimension]), fChannelHistos(0x0), fXmin(0.0), @@ -104,28 +104,56 @@ AliMUONTrackerData::~AliMUONTrackerData() //_____________________________________________________________________________ Bool_t -AliMUONTrackerData::Add(const AliMUONVStore& store, Int_t numberOfEvents) +AliMUONTrackerData::Add(const AliMUONVStore& store) { /// Add the given external store to our internal store AliCodeTimerAuto(GetName()); - fNevents += numberOfEvents; + if ( IsSingleEvent() && fNevents == 1 ) + { + AliError(Form("%s is supposed to be single event only",GetName())); + return kFALSE; + } + + ++fNevents; + NumberOfEventsChanged(); if (!fChannelValues) { + Int_t numberOfBusPatches(0); + Int_t numberOfDEs(0); + + // get number of bus patches and number of detection element + // to initialize fBusPatchValues and fDEValues below + + TExMapIter it(AliMpDDLStore::Instance()->GetBusPatchesIterator()); + Long_t key,value; + while ( it.Next(key,value) ) ++numberOfBusPatches; + AliMpDEIterator deIt; + deIt.First(); + while (!deIt.IsDone()) + { + ++numberOfDEs; + deIt.Next(); + } + fChannelValues = new AliMUON2DMap(kTRUE); fManuValues = new AliMUON2DMap(kTRUE); fPCBValues = new AliMUON2DMap(kFALSE); - fBusPatchValues = new AliMUON1DMap; - fDEValues = new AliMUON1DMap; + fBusPatchValues = new AliMUON1DMap(numberOfBusPatches); + fDEValues = new AliMUON1DMap(numberOfDEs); fChamberValues = new AliMUON1DArray; } TIter next(store.CreateIterator()); AliMUONVCalibParam* external; + Int_t nk(2); + + if ( IsSingleEvent() ) nk = 1; + while ( ( external = static_cast(next()) ) ) { if ( external->Dimension() != ExternalDimension() ) @@ -180,7 +208,7 @@ AliMUONTrackerData::Add(const AliMUONVStore& store, Int_t numberOfEvents) FillChannel(detElemId,manuId,i,j,vext); } - for ( Int_t k = 0; k < 2; ++k ) + for ( Int_t k = 0; k < nk; ++k ) { channel->SetValueAsDoubleFast(i,ix+k,channel->ValueAsDoubleFast(i,ix+k)+value[k]); @@ -518,6 +546,14 @@ AliMUONTrackerData::DimensionName(Int_t dim) const } } +//_____________________________________________________________________________ +Int_t +AliMUONTrackerData::External2Internal(Int_t index) const +{ + /// From external to internal dimension + return IsSingleEvent() ? index : index*2; +} + //_____________________________________________________________________________ TString AliMUONTrackerData::ExternalDimensionName(Int_t dim) const @@ -835,7 +871,7 @@ AliMUONTrackerData::Print(Option_t* wildcard, Option_t* opt) const TNamed::Print(opt); - if ( fIsRunnable ) + if ( !fIsSingleEvent ) { cout << " Nevents=" << fNevents << endl; } @@ -899,13 +935,20 @@ AliMUONTrackerData::SetDimensionName(Int_t index, const char* name) Int_t ix = External2Internal(index); - const char* prefix[] = { "mean", "sigma" }; - - for ( Int_t i = 0; i < 2; ++i ) + if ( !IsSingleEvent() ) { - Int_t j = ix+i; + const char* prefix[] = { "mean", "sigma" }; + + for ( Int_t i = 0; i < 2; ++i ) + { + Int_t j = ix+i; - SetInternalDimensionName(j,Form("%s of %s",prefix[i],name)); + SetInternalDimensionName(j,Form("%s of %s",prefix[i],name)); + } + } + else + { + SetInternalDimensionName(index,name); } SetExternalDimensionName(index,name); @@ -994,7 +1037,7 @@ AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim) c if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return AliMUONVCalibParam::InvalidFloatValue(); - if ( TMath::Even(dim) ) + if ( TMath::Even(dim) || IsSingleEvent() ) { return value/occ; } @@ -1002,9 +1045,16 @@ AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim) c { Double_t n = occ; - Double_t mean = param.ValueAsDouble(i,dim-1)/n; + if ( n > 1.0 ) + { + Double_t mean = param.ValueAsDouble(i,dim-1)/n; - return TMath::Sqrt(TMath::Abs((value-n*mean*mean)/(n-1.0))); + return TMath::Sqrt(TMath::Abs((value-n*mean*mean)/(n-1.0))); + } + else + { + return 0.0; + } } AliError("Why am I here ?"); diff --git a/MUON/AliMUONTrackerData.h b/MUON/AliMUONTrackerData.h index b5e74478320..1d616d2ee72 100644 --- a/MUON/AliMUONTrackerData.h +++ b/MUON/AliMUONTrackerData.h @@ -26,10 +26,10 @@ class AliMUONTrackerData : public AliMUONVTrackerData public: AliMUONTrackerData(const char* name="", const char* title="", Int_t dimension=0, - Bool_t runnable=kTRUE); + Bool_t issingleevent=kFALSE); virtual ~AliMUONTrackerData(); - virtual Bool_t Add(const AliMUONVStore& channelValues, Int_t numberOfEvents=1); + virtual Bool_t Add(const AliMUONVStore& channelValues); virtual Double_t BusPatch(Int_t busPatchId, Int_t dim=0) const; @@ -59,7 +59,7 @@ public: virtual Bool_t HasPCB(Int_t detElemId, Int_t pcbIndex) const; /// Whether we can be run - virtual Bool_t IsRunnable() const { return fIsRunnable; } + virtual Bool_t IsSingleEvent() const { return fIsSingleEvent; } virtual Double_t Manu(Int_t detElemId, Int_t manuId, Int_t dim=0) const; @@ -154,7 +154,7 @@ private: AliMpDetElement*& mpde); /// Convert from external to internal index - Int_t External2Internal(Int_t index) const { return index*2; } + Int_t External2Internal(Int_t index) const; void SetInternalDimensionName(Int_t index, const char* value); @@ -167,6 +167,7 @@ private: private: + Bool_t fIsSingleEvent; ///< whether we can deal with more than one event AliMUONVStore* fChannelValues; ///< the channel store AliMUONVStore* fManuValues; ///< the manu store AliMUONVStore* fBusPatchValues; ///< the bus patch store @@ -178,7 +179,6 @@ private: TObjArray* fDimensionNames; ///< the names of the (internal) dimensions TObjArray* fExternalDimensionNames; ///< the names of the external (i.e. original) dimensions Int_t fExternalDimension; ///< number of interface values per item - Bool_t fIsRunnable; ///< whether we can deal with more than one event /// whether we should histogram the dimension(s) Int_t* fHistogramming; //[fExternalDimension] whether we should histogram the dimension(s) AliMUONVStore* fChannelHistos; ///< the channel histograms @@ -187,7 +187,7 @@ private: static const Int_t fgkExtraDimension; ///< to hold extra information static const Int_t fgkVirtualExtraDimension; ///< to give access to information not stored, but computed on the fly - ClassDef(AliMUONTrackerData,3) // Implementation of AliMUONVTrackerData + ClassDef(AliMUONTrackerData,4) // Implementation of AliMUONVTrackerData }; #endif diff --git a/MUON/AliMUONTrackerDataCompareDialog.cxx b/MUON/AliMUONTrackerDataCompareDialog.cxx new file mode 100644 index 00000000000..9b54277ec1d --- /dev/null +++ b/MUON/AliMUONTrackerDataCompareDialog.cxx @@ -0,0 +1,317 @@ +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ + +// $Id$ + +#include "AliMUONTrackerDataCompareDialog.h" + +/// \class AliMUONTrackerDataCompareDialog +/// +/// Widget to select 2 VTrackerData objects (D1,D2) to be compared +/// +/// The type of differences that can be used are : +/// +/// - Difference = plain difference D1-D2 +/// - Absolute difference = absolute value of the preceeding = |D1-D2| +/// - Relative difference = relative difference = (D1-D2)/D1 +/// - Absolute relative difference = absolute value of preceeding = |(D1-D2)/D1| +/// +/// \author Laurent Aphecetche, Subatech +/// + +#include "AliLog.h" +#include "AliMpConstants.h" +#include "AliMUON2DMap.h" +#include "AliMUONCalibParamND.h" +#include "AliMUONPainterRegistry.h" +#include "AliMUONTrackerData.h" +#include "AliMUONTrackerDataWrapper.h" +#include "AliMUONVTrackerData.h" +#include "AliMpDDLStore.h" +#include "AliMpDetElement.h" +#include "AliMpManuIterator.h" +#include +#include +#include +#include + +/// \cond CLASSIMP +ClassImp(AliMUONTrackerDataCompareDialog) +/// \endcond + +const Int_t AliMUONTrackerDataCompareDialog::fgkDifference(1); +const Int_t AliMUONTrackerDataCompareDialog::fgkAbsoluteDifference(2); +const Int_t AliMUONTrackerDataCompareDialog::fgkRelativeDifference(3); +const Int_t AliMUONTrackerDataCompareDialog::fgkAbsoluteRelativeDifference(4); +const Int_t AliMUONTrackerDataCompareDialog::fgkAll(5); + +namespace +{ + +#define PRECISION 1E-12 + + Double_t Difference(Double_t v1, Double_t v2) + { + Double_t d = v1-v2; + return TMath::Abs(d) < PRECISION ? 0.0 : d; + } + + Double_t AbsoluteDifference(Double_t v1, Double_t v2) + { + return TMath::Abs(Difference(v1,v2)); + } + + + Double_t RelativeDifference(Double_t v1, Double_t v2) + { + if ( TMath::Abs(v1) < PRECISION ) return 0.0; + return (v1-v2)/v1; + } + + Double_t AbsoluteRelativeDifference(Double_t v1, Double_t v2) + { + return TMath::Abs(RelativeDifference(v1,v2)); + } +} + + +//_____________________________________________________________________________ +AliMUONTrackerDataCompareDialog::AliMUONTrackerDataCompareDialog(const TGWindow* p, const TGWindow* main, UInt_t w, UInt_t h) +: TGTransientFrame(p,main,w,h), +fF1(new TGHorizontalFrame(this)), +fData1(new TGComboBox(fF1)), +fF2(new TGHorizontalFrame(this)), +fData2(new TGComboBox(fF2)), +fF3(new TGHorizontalFrame(this)), +fDiffType(new TGComboBox(fF3)), +fF4(new TGHorizontalFrame(this)), +fBasename(new TGTextEntry(fF4)), +fButtonFrame(new TGHorizontalFrame(this)), +fOK(new TGTextButton(fButtonFrame,"OK")), +fCancel(new TGTextButton(fButtonFrame,"Cancel")) +{ + /// ctor + + SetCleanup(kDeepCleanup); + + AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance(); + + for ( Int_t i = 0; i < reg->NumberOfDataSources(); ++i ) + { + AliMUONVTrackerData* data = reg->DataSource(i); + fData1->AddEntry(data->GetName(),i); + fData2->AddEntry(data->GetName(),i); + } + + fDiffType->AddEntry("Difference",fgkDifference); + fDiffType->AddEntry("Absolute difference",fgkAbsoluteDifference); + fDiffType->AddEntry("Relative difference",fgkRelativeDifference); + fDiffType->AddEntry("Absolute relative difference",fgkAbsoluteRelativeDifference); + fDiffType->AddEntry("All four",fgkAll); + + fData1->Select(0); + fData2->Select(0); + fDiffType->Select(4); + + fF1->AddFrame(new TGLabel(fF1,"First data"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5)); + fF1->AddFrame(fData1,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5)); + + fF2->AddFrame(new TGLabel(fF2,"Second data"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5)); + fF2->AddFrame(fData2,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5)); + + fF3->AddFrame(new TGLabel(fF3,"Difference type"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5)); + fF3->AddFrame(fDiffType,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5)); + + fF4->AddFrame(new TGLabel(fF4,"Output basename"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5)); + fF4->AddFrame(fBasename,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5)); + + AddFrame(fF1,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5)); + AddFrame(fF2,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5)); + AddFrame(fF3,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5)); + AddFrame(fF4,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5)); + + fButtonFrame->AddFrame(fOK,new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5)); + fButtonFrame->AddFrame(fCancel,new TGLayoutHints(kLHintsRight|kLHintsTop,5,5,5,5)); + + AddFrame(fButtonFrame,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5)); + + fData1->Resize(200,20); + fData2->Resize(200,20); + fDiffType->Resize(200,20); + + fOK->Connect("Clicked()", "AliMUONTrackerDataCompareDialog",this,"DoOK()"); + fCancel->Connect("Clicked()","AliMUONTrackerDataCompareDialog",this,"DoCancel()"); +} + +//_____________________________________________________________________________ +AliMUONTrackerDataCompareDialog::~AliMUONTrackerDataCompareDialog() +{ + /// dtor +} + +//______________________________________________________________________________ +void +AliMUONTrackerDataCompareDialog::DoOK() +{ + /// Do the job. + + TGTextLBEntry* t1 = static_cast(fData1->GetSelectedEntry()); + TString s1 = t1->GetText()->GetString(); + TGTextLBEntry* t2 = static_cast(fData2->GetSelectedEntry()); + TString s2 = t2->GetText()->GetString(); + + Int_t nd = fDiffType->GetSelected(); + + if ( nd == fgkAll ) + { + CompareData(s1.Data(),s2.Data(),fgkDifference); + CompareData(s1.Data(),s2.Data(),fgkRelativeDifference); + CompareData(s1.Data(),s2.Data(),fgkAbsoluteDifference); + CompareData(s1.Data(),s2.Data(),fgkAbsoluteRelativeDifference); + } + else + { + CompareData(s1.Data(),s2.Data(),nd); + } + + TTimer::SingleShot(150,"AliMUONTrackerDataCompareDialog",this,"CloseWindow()"); +} + +//______________________________________________________________________________ +void +AliMUONTrackerDataCompareDialog::DoCancel() +{ + /// Kills the dialog + TTimer::SingleShot(150,"AliMUONTrackerDataCompareDialog",this,"CloseWindow()"); +} + +//______________________________________________________________________________ +void +AliMUONTrackerDataCompareDialog::CompareData(const char* d1name, + const char* d2name, + Int_t difftype) const +{ + /// Compare two data sources + + AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance(); + + AliMUONVTrackerData* d1 = reg->DataSource(d1name); + if (!d1) + { + AliError(Form("Cannot find data source %s",d1name)); + } + + AliMUONVTrackerData* d2 = reg->DataSource(d2name); + if (!d2) + { + AliError(Form("Cannot find data source %s",d2name)); + } + + Double_t (*difffunction)(Double_t,Double_t)=0x0; + TString suffix("unknown"); + + if ( difftype == fgkDifference ) + { + difffunction = Difference; + suffix = "D"; + } + if ( difftype == fgkAbsoluteDifference ) + { + difffunction = AbsoluteDifference; + suffix = "AD"; + } + if ( difftype == fgkRelativeDifference ) + { + difffunction = RelativeDifference; + suffix = "RD"; + } + if ( difftype == fgkAbsoluteRelativeDifference ) + { + difffunction = AbsoluteRelativeDifference; + suffix = "ARD"; + } + + TString basename = fBasename->GetText(); + + AliMUONVTrackerData* d = CompareData(*d1,*d2,Form("%s:%s",basename.Data(),suffix.Data()),difffunction); + + AliMUONVTrackerDataMaker* dw = new AliMUONTrackerDataWrapper(d); + + AliMUONPainterRegistry::Instance()->Register(dw); +} + +//______________________________________________________________________________ +AliMUONVTrackerData* +AliMUONTrackerDataCompareDialog::CompareData(const AliMUONVTrackerData& d1, + const AliMUONVTrackerData& d2, + const char* outname, + Double_t(*diff)(Double_t,Double_t)) const +{ + /// Compare two data objects, using the diff method + + if ( d1.NumberOfDimensions() != d2.NumberOfDimensions() ) + { + AliError("Cannot compare data of incompatible dimensions"); + return 0x0; + } + + AliMpManuIterator it; + Int_t detElemId, manuId; + + AliMUONVStore* store = new AliMUON2DMap(kTRUE); + + while ( it.Next(detElemId,manuId) ) + { + if ( d1.HasDetectionElement(detElemId) && d2.HasDetectionElement(detElemId) && + d1.HasManu(detElemId,manuId) && d2.HasManu(detElemId,manuId) ) + { + AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); + + AliMUONVCalibParam* param = static_cast(store->FindObject(detElemId,manuId)); + + if (!param) + { + param = new AliMUONCalibParamND(d1.ExternalDimension(),64,detElemId,manuId, + AliMUONVCalibParam::InvalidFloatValue()); + store->Add(param); + } + + for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) + { + if ( de->IsConnectedChannel(manuId,i) ) + { + for ( Int_t k = 0; k < d1.ExternalDimension(); ++k ) + { + + Double_t d = diff(d1.Channel(detElemId,manuId,i,k), + d2.Channel(detElemId,manuId,i,k)); + + param->SetValueAsDouble(i,k,d); + } + } + } + } + } + + AliMUONVTrackerData* d = new AliMUONTrackerData(outname,outname,d1.ExternalDimension(),kTRUE); + for ( Int_t k = 0; k < d1.ExternalDimension(); ++k ) + { + d->SetDimensionName(k,Form("D:%s",d1.ExternalDimensionName(k).Data())); + } + d->Add(*store); + + return d; +} + diff --git a/MUON/AliMUONTrackerDataCompareDialog.h b/MUON/AliMUONTrackerDataCompareDialog.h new file mode 100644 index 00000000000..e07d43b8555 --- /dev/null +++ b/MUON/AliMUONTrackerDataCompareDialog.h @@ -0,0 +1,69 @@ +#ifndef ALIMUONTRACKERDATACOMPAREDIALOG_H +#define ALIMUONTRACKERDATACOMPAREDIALOG_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* See cxx source for full Copyright notice */ + +// $Id$ + +/// \ingroup graphics +/// \class AliMUONTrackerDataCompareDialog +/// \brief +/// +/// Author Laurent Aphecetche, Subatech + +#ifndef ROOT_TGFrame +# include "TGFrame.h" +#endif + +class AliMUONVTrackerData; +class TGButtonGroup; +class TGComboBox; +class TGCompositeFrame; +class TGTextEntry; + +class AliMUONTrackerDataCompareDialog : public TGTransientFrame +{ +public: + AliMUONTrackerDataCompareDialog(const TGWindow* p = 0, const TGWindow* main = 0, UInt_t w = 1, UInt_t h = 1); + virtual ~AliMUONTrackerDataCompareDialog(); + + void DoOK(); + void DoCancel(); + +private: + + AliMUONTrackerDataCompareDialog(const AliMUONTrackerDataCompareDialog& rhs); + AliMUONTrackerDataCompareDialog& operator=(const AliMUONTrackerDataCompareDialog& rhs); + + void CompareData(const char* d1name, const char* d2name, Int_t difftype) const; + + AliMUONVTrackerData* CompareData(const AliMUONVTrackerData& d1, + const AliMUONVTrackerData& d2, + const char* outname, + Double_t (*difffunction)(Double_t,Double_t)) const; + +private: + + TGCompositeFrame* fF1; ///< frame for data source 1 selection + TGComboBox* fData1; ///< to select first data + TGCompositeFrame* fF2; ///< frame for data source 2 selection + TGComboBox* fData2; ///< to select second data + TGCompositeFrame* fF3; ///< frame for difference type selection + TGComboBox* fDiffType; ///< to select the kind of difference to make + TGCompositeFrame* fF4; ///< frame for output basename selection + TGTextEntry* fBasename; ///< basename of resulting (diff-ed) data + TGCompositeFrame* fButtonFrame; ///< to hold OK and Cancel buttons + TGTextButton* fOK; ///< ok button + TGTextButton* fCancel; ///< cancel button + + static const Int_t fgkDifference; /// D1-D2 + static const Int_t fgkAbsoluteDifference; /// |D1-D2| + static const Int_t fgkRelativeDifference; /// (D1-D2)/D1 + static const Int_t fgkAbsoluteRelativeDifference; /// | (D1-D2) | / | D1 | + static const Int_t fgkAll; /// All four differences at once + + ClassDef(AliMUONTrackerDataCompareDialog,1) // Dialog to select two data sources to compare +}; + +#endif diff --git a/MUON/AliMUONTrackerDataHistogrammer.cxx b/MUON/AliMUONTrackerDataHistogrammer.cxx index 0d74f40d680..d3fb150956c 100644 --- a/MUON/AliMUONTrackerDataHistogrammer.cxx +++ b/MUON/AliMUONTrackerDataHistogrammer.cxx @@ -17,6 +17,7 @@ #include "AliMUONTrackerDataHistogrammer.h" +#include "AliLog.h" #include "AliMUONPainterGroup.h" #include "AliMUONSparseHisto.h" #include "AliMUONVPainter.h" @@ -27,8 +28,10 @@ #include "AliMpDEIterator.h" #include "AliMpDetElement.h" #include "AliMpManuUID.h" +#include #include #include +#include ///\class AliMUONTrackerDataHistogrammer /// @@ -44,10 +47,12 @@ ClassImp(AliMUONTrackerDataHistogrammer) //_____________________________________________________________________________ AliMUONTrackerDataHistogrammer::AliMUONTrackerDataHistogrammer(const AliMUONVTrackerData& data, - Int_t dim) + Int_t externalDim, + Int_t internalDim) : TObject(), fData(data), -fDim(dim) +fExternalDim(externalDim), +fInternalDim(internalDim) { /// ctor } @@ -126,83 +131,46 @@ AliMUONTrackerDataHistogrammer::AddManuHisto(TH1& h, Int_t detElemId, Int_t manu { if ( fData.HasChannel(detElemId,manuId,i) ) { - AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,i); + if ( IsInternalMode() ) + { + h.Fill(fData.Channel(detElemId,manuId,i,fInternalDim)); + } + else + { + AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,i); - if ( sh ) - { - Add(h,*sh); + if ( sh ) + { + Add(h,*sh); + } } } } } } - -//_____________________________________________________________________________ -TH1* -AliMUONTrackerDataHistogrammer::CreateBusPatchHisto(Int_t busPatchId) const -{ - /// Create histogram of a given bus patch. Note that in order - /// to keep memory footprint as low as possible, you should delete - /// the returned pointer as soon as possible... - - TH1* h(0x0); - - if ( fData.HasBusPatch(busPatchId) && fData.IsHistogrammed(fDim)) - { - h = CreateHisto(Form("BP%04d_%d",busPatchId,fDim)); - if ( h ) AddBusPatchHisto(*h,busPatchId); - } - - return h; -} - - -//_____________________________________________________________________________ -TH1* -AliMUONTrackerDataHistogrammer::CreateChamberHisto(Int_t chamberId) const -{ - /// Create histogram of a given chamber. Note that in order - /// to keep memory footprint as low as possible, you should delete - /// the returned pointer as soon as possible... - - TH1* h(0x0); - - if ( fData.HasChamber(chamberId) && fData.IsHistogrammed(fDim)) - { - h = CreateHisto(Form("CHAMBER%02d_%d",chamberId,fDim)); - if ( h ) - { - AliMpDEIterator it; - it.First(chamberId); - while ( !it.IsDone() ) - { - Int_t detElemId = it.CurrentDEId(); - AddDEHisto(*h,detElemId); - it.Next(); - } - } - } - - return h; -} - //_____________________________________________________________________________ TH1* -AliMUONTrackerDataHistogrammer::CreateChannelHisto(Int_t detElemId, Int_t manuId, +AliMUONTrackerDataHistogrammer::CreateChannelHisto(Int_t detElemId, + Int_t manuId, Int_t manuChannel) const { /// Create histogram of a given channel. Note that in order /// to keep memory footprint as low as possible, you should delete /// the returned pointer as soon as possible... - if ( fData.HasChannel(detElemId, manuId, manuChannel) && fData.IsHistogrammed(fDim) ) + if ( fData.HasChannel(detElemId, manuId, manuChannel) && fData.IsHistogrammed(fExternalDim) ) { AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,manuChannel); if ( sh ) { - TH1* h = CreateHisto(Form("DE%04dMANU%04dCH%02d_%d",detElemId,manuId,manuChannel,fDim)); + Int_t nbins((1<Nbits())); + Double_t xmin,xmax; + fData.HistogramRange(xmin,xmax); + + TH1* h = CreateHisto(Form("DE%04dMANU%04dCH%02d",detElemId,manuId,manuChannel), + nbins,xmin,xmax); if (h ) { Add(*h,*sh); @@ -215,26 +183,28 @@ AliMUONTrackerDataHistogrammer::CreateChannelHisto(Int_t detElemId, Int_t manuId //_____________________________________________________________________________ TH1* -AliMUONTrackerDataHistogrammer::CreateDEHisto(Int_t detElemId) const +AliMUONTrackerDataHistogrammer::CreateHisto(const char* name, + Int_t nbins, + Double_t xmin, + Double_t xmax) const { - /// Create histogram of a given detection element. Note that in order - /// to keep memory footprint as low as possible, you should delete - /// the returned pointer as soon as possible... + /// Create a single histogram - TH1* h(0x0); + TH1* h(0); - if ( fData.HasDetectionElement(detElemId) && fData.IsHistogrammed(fDim) ) + if ( xmin < xmax ) { - h = CreateHisto(Form("DE%04d-%d",detElemId,fDim)); - if (h) AddDEHisto(*h,detElemId); + h = new TH1F(name,name,nbins,xmin,xmax); + h->SetDirectory(gROOT); } - return h; } //_____________________________________________________________________________ TH1* -AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter) +AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter, + Int_t externalDim, + Int_t internalDim) { /// Create an histogram, from given dim of given data, /// for all the channels handled by painter @@ -244,27 +214,76 @@ AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter) if ( !group ) return 0x0; // no data to histogram in this painter AliMUONVTrackerData* data = group->Data(); - Int_t dim = data->InternalToExternal(group->DataIndex()); - AliMUONTrackerDataHistogrammer tdh(*data,dim); + if ( externalDim >= data->ExternalDimension() ) + { + AliErrorClass(Form("externalDim %d is out of bounds",externalDim)); + return 0x0; + } + + if ( internalDim >= data->NumberOfDimensions() ) + { + AliErrorClass(Form("internalDim %d is out of bounds",internalDim)); + return 0x0; + } + + if ( internalDim < 0 && externalDim < 0 ) + { + AliErrorClass("Both internal and external dim are < 0 !!!"); + return 0x0; + } + + AliMUONTrackerDataHistogrammer tdh(*data,externalDim,internalDim); TObjArray manuArray; painter.FillManuList(manuArray); - + AliMpManuUID* mid; TIter next(&manuArray); + + TString basename(Form("%s-%s",painter.PathName().Data(),painter.Attributes().GetName())); + TString ext; + Int_t nbins((1<<12)); + Double_t xmin(0.0); + Double_t xmax(0.0); - TH1* histo = tdh.CreateHisto(Form("%s-%s",painter.PathName().Data(),painter.Attributes().GetName())); + if ( !tdh.IsInternalMode() ) + { + data->HistogramRange(xmin,xmax); + + xmin -= 0.5; + xmax -= 0.5; + + ext = data->ExternalDimensionName(externalDim).Data(); + } + else + { + tdh.GetDataRange(manuArray,xmin,xmax); + ext = data->DimensionName(internalDim).Data(); + nbins = 100; + } - while ( ( mid = static_cast(next()) ) ) + TString name(Form("%s-%s",basename.Data(),ext.Data())); + + TH1* histo = tdh.CreateHisto(name.Data(),nbins,xmin,xmax); + + if ( histo ) { - TH1* h = tdh.CreateManuHisto(mid->DetElemId(),mid->ManuId()); - if ( h ) + while ( ( mid = static_cast(next()) ) ) { - histo->Add(h); + TH1* h = tdh.CreateManuHisto(mid->DetElemId(),mid->ManuId(),nbins,xmin,xmax); + if ( h ) + { + histo->Add(h); + } + delete h; } - delete h; + } + else + { + AliErrorClass(Form("Could not create histo for painter %s external dim %d internal dim %d", + painter.PathName().Data(),externalDim,internalDim)); } return histo; @@ -272,46 +291,64 @@ AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter) //_____________________________________________________________________________ TH1* -AliMUONTrackerDataHistogrammer::CreateHisto(const char* name) const +AliMUONTrackerDataHistogrammer::CreateManuHisto(Int_t detElemId, Int_t manuId, + Int_t nbins, + Double_t xmin, + Double_t xmax) const { - /// Create a single histogram - - Double_t xmin, xmax; - - fData.HistogramRange(xmin,xmax); + /// Create histogram of a given manu. Note that in order + /// to keep memory footprint as low as possible, you should delete + /// the returned pointer as soon as possible... TH1* h(0x0); - if ( xmin != xmax ) + if ( !fData.HasManu(detElemId,manuId) ) return 0x0; + + if ( ( fExternalDim >= 0 && fData.IsHistogrammed(fExternalDim) ) || + ( fInternalDim >= 0 && fInternalDim < fData.NumberOfDimensions() ) ) { - h = new TH1I(name,Form("Data=%s Dim=%s", - fData.GetName(), - fData.ExternalDimensionName(fDim).Data()), - (1<<12), - xmin-0.5, - xmax-0.5); - h->SetDirectory(0); + h = CreateHisto(Form("DE%04dMANU%04d",detElemId,manuId), + nbins,xmin,xmax); + if ( h ) AddManuHisto(*h,detElemId,manuId); } + return h; } - //_____________________________________________________________________________ -TH1* -AliMUONTrackerDataHistogrammer::CreateManuHisto(Int_t detElemId, Int_t manuId) const +void +AliMUONTrackerDataHistogrammer::GetDataRange(const TObjArray& manuArray, + Double_t& xmin, Double_t& xmax) const { - /// Create histogram of a given manu. Note that in order - /// to keep memory footprint as low as possible, you should delete - /// the returned pointer as soon as possible... + /// Get data range (in case of InternalMode() only) spanned by the manus in + /// manuArray - TH1* h(0x0); + xmin = FLT_MAX; + xmax = -FLT_MAX; - if ( fData.HasManu(detElemId, manuId) && fData.IsHistogrammed(fDim) ) + if (!IsInternalMode()) { - h = CreateHisto(Form("DE%04dMANU%04d_%d",detElemId,manuId,fDim)); - if ( h ) AddManuHisto(*h,detElemId,manuId); + AliError("Cannot use this method for external mode !"); } + + AliMpManuUID* mid; + TIter next(&manuArray); - return h; + while ( ( mid = static_cast(next()) ) ) + { + Int_t detElemId = mid->DetElemId(); + Int_t manuId = mid->ManuId(); + + for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) + { + if ( fData.HasChannel(detElemId,manuId,i) ) + { + Double_t value = fData.Channel(detElemId,manuId,i,fInternalDim); + xmin = TMath::Min(xmin,value); + xmax = TMath::Max(xmax,value); + } + } + } + } diff --git a/MUON/AliMUONTrackerDataHistogrammer.h b/MUON/AliMUONTrackerDataHistogrammer.h index d80f2b9af86..d7e6a017ec2 100644 --- a/MUON/AliMUONTrackerDataHistogrammer.h +++ b/MUON/AliMUONTrackerDataHistogrammer.h @@ -24,25 +24,27 @@ class TH1; class AliMUONTrackerDataHistogrammer : public TObject { public: - AliMUONTrackerDataHistogrammer(const AliMUONVTrackerData& data, Int_t dim); + AliMUONTrackerDataHistogrammer(const AliMUONVTrackerData& data, + Int_t externalDim, + Int_t internalDim=-1); virtual ~AliMUONTrackerDataHistogrammer(); - static TH1* CreateHisto(const AliMUONVPainter& painter); - - TH1* CreateBusPatchHisto(Int_t busPatchId) const; - - TH1* CreateChamberHisto(Int_t chamberId) const; - + static TH1* CreateHisto(const AliMUONVPainter& painter, + Int_t externalDim, + Int_t internalDim); + TH1* CreateChannelHisto(Int_t detElemId, Int_t manuId, Int_t manuChannel) const; - - TH1* CreateDEHisto(Int_t detElemId) const; - - TH1* CreateManuHisto(Int_t detElemId, Int_t manuId) const; + + Bool_t IsInternalMode() const { return fInternalDim >=0; } private: - TH1* CreateHisto(const char* name) const; + TH1* CreateManuHisto(Int_t detElemId, Int_t manuId, Int_t nbins, Double_t xmin, Double_t xmax) const; + + TH1* CreateHisto(const char* basename, Int_t nbins, Double_t xmin, Double_t xmax) const; + + void GetDataRange(const TObjArray& manuList, Double_t& xmin, Double_t& xmax) const; void Add(TH1& h, const AliMUONSparseHisto& sh) const; @@ -54,9 +56,10 @@ private: private: const AliMUONVTrackerData& fData; ///< data we'll histogram - Int_t fDim; ///< dimension we'll histogram + Int_t fExternalDim; ///< (external) dimension we'll histogram + Int_t fInternalDim; ///< (internal) dimension we'll make histogram for - ClassDef(AliMUONTrackerDataHistogrammer,1) // Make histograms from VTrackerData + ClassDef(AliMUONTrackerDataHistogrammer,2) // Make histograms from VTrackerData }; #endif diff --git a/MUON/AliMUONTrackerOCDBDataMaker.cxx b/MUON/AliMUONTrackerOCDBDataMaker.cxx index d4f64613519..e9399554297 100644 --- a/MUON/AliMUONTrackerOCDBDataMaker.cxx +++ b/MUON/AliMUONTrackerOCDBDataMaker.cxx @@ -41,7 +41,6 @@ AliMUONTrackerOCDBDataMaker::AliMUONTrackerOCDBDataMaker(const char* ocdbPath, const char* type) : AliMUONVTrackerDataMaker(), fIsValid(kTRUE), - fIsOwner(kTRUE), fData(0x0), fSource(Form("%s-%010d-%s",ocdbPath,runNumber,type)) { @@ -54,17 +53,18 @@ AliMUONTrackerOCDBDataMaker::AliMUONTrackerOCDBDataMaker(const char* ocdbPath, TString stype(type); stype.ToUpper(); + Bool_t isSingleEvent(kTRUE); if ( stype == "PEDESTALS" ) { - fData = new AliMUONTrackerData(Form("PED%d",runNumber),"Pedestals",2,kFALSE); + fData = new AliMUONTrackerData(Form("PED%d",runNumber),"Pedestals",2,isSingleEvent); fData->SetDimensionName(0,"Mean"); fData->SetDimensionName(1,"Sigma"); store = AliMUONCalibrationData::CreatePedestals(runNumber); } else if ( stype == "GAINS" ) { - fData = new AliMUONTrackerData(Form("GAIN%d",runNumber),"Gains",5,kFALSE); + fData = new AliMUONTrackerData(Form("GAIN%d",runNumber),"Gains",5,isSingleEvent); fData->SetDimensionName(0,"a1"); fData->SetDimensionName(1,"a2"); fData->SetDimensionName(2,"thres"); @@ -74,7 +74,7 @@ AliMUONTrackerOCDBDataMaker::AliMUONTrackerOCDBDataMaker(const char* ocdbPath, } else if ( stype == "CAPACITANCES" ) { - fData = new AliMUONTrackerData(Form("CAPA%d",runNumber),"Capacitances",2,kFALSE); + fData = new AliMUONTrackerData(Form("CAPA%d",runNumber),"Capacitances",2,isSingleEvent); fData->SetDimensionName(0,"Capa"); fData->SetDimensionName(1,"Injection gain"); store = AliMUONCalibrationData::CreateCapacitances(runNumber); @@ -98,5 +98,15 @@ AliMUONTrackerOCDBDataMaker::AliMUONTrackerOCDBDataMaker(const char* ocdbPath, AliMUONTrackerOCDBDataMaker::~AliMUONTrackerOCDBDataMaker() { /// dtor - if ( fIsOwner) delete fData; + delete fData; } + +//_____________________________________________________________________________ +Long64_t +AliMUONTrackerOCDBDataMaker::Merge(TCollection*) +{ + /// Merge + AliError("Not implemented. Does it have sense ?"); + return 0; +} + diff --git a/MUON/AliMUONTrackerOCDBDataMaker.h b/MUON/AliMUONTrackerOCDBDataMaker.h index 7fa67fade52..9ff6ad802c1 100644 --- a/MUON/AliMUONTrackerOCDBDataMaker.h +++ b/MUON/AliMUONTrackerOCDBDataMaker.h @@ -48,9 +48,6 @@ public: /// N/A virtual void Rewind() { } - /// Whether we're owner of our data - virtual void SetOwner(Bool_t flag) { fIsOwner = flag; } - /// Set our source URI virtual void SetSource(const char* source) { fSource = source; } @@ -60,6 +57,8 @@ public: /// Number of events is always 1 Int_t NumberOfEvents() const { return 1; } + virtual Long64_t Merge(TCollection* li); + private: /// Not implemented AliMUONTrackerOCDBDataMaker(const AliMUONTrackerOCDBDataMaker& rhs); @@ -68,11 +67,10 @@ private: private: Bool_t fIsValid; ///< whether we have valid data - Bool_t fIsOwner; ///< whether or not we're the owner of our data AliMUONVTrackerData* fData; ///< our data TString fSource; ///< our source - ClassDef(AliMUONTrackerOCDBDataMaker,1) // Producer of AliMUONVTrackerData from OCDB + ClassDef(AliMUONTrackerOCDBDataMaker,2) // Producer of AliMUONVTrackerData from OCDB }; #endif diff --git a/MUON/AliMUONTrackerRawDataMaker.cxx b/MUON/AliMUONTrackerRawDataMaker.cxx index c374769c0fe..bdb894cb789 100644 --- a/MUON/AliMUONTrackerRawDataMaker.cxx +++ b/MUON/AliMUONTrackerRawDataMaker.cxx @@ -17,25 +17,26 @@ #include "AliMUONTrackerRawDataMaker.h" +#include "AliCDBManager.h" +#include "AliCDBStorage.h" #include "AliCodeTimer.h" #include "AliLog.h" +#include "AliLog.h" #include "AliMUON2DMap.h" #include "AliMUONCalibParamND.h" #include "AliMUONCalibrationData.h" #include "AliMUONDigitCalibrator.h" #include "AliMUONDigitMaker.h" #include "AliMUONDigitStoreV2R.h" +#include "AliMUONRawStreamTracker.h" +#include "AliMUONRawStreamTrackerHP.h" #include "AliMUONTrackerData.h" #include "AliMUONVDigit.h" #include "AliMUONVDigitStore.h" #include "AliMpDDLStore.h" -#include "AliCDBManager.h" -#include "AliCDBStorage.h" #include "AliRawEventHeaderBase.h" #include "AliRawReader.h" -#include "AliLog.h" #include -#include "AliMUONRawStreamTracker.h" ///\class AliMUONTrackerRawDataMaker /// @@ -50,31 +51,39 @@ ClassImp(AliMUONTrackerRawDataMaker) Int_t AliMUONTrackerRawDataMaker::fgkCounter(0); //_____________________________________________________________________________ -AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader, Bool_t histogram) +AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader, + Bool_t histogram, + Bool_t useHPdecoder) : AliMUONVTrackerDataMaker(), fRawReader(reader), fAccumulatedData(0x0), fOneEventData(new AliMUON2DMap(true)), - fIsOwner(kTRUE), fSource("unspecified"), fIsRunning(kFALSE), - fNumberOfEvents(0) + fNumberOfEvents(0), + fRunNumber(0), + fIsEventByEvent(kFALSE), + fUseHPDecoder(useHPdecoder) { /// Ctor - reader->NextEvent(); // to be sure to get run number available - - Int_t runNumber = reader->GetRunNumber(); - + + if (fRawReader) + { + fRawReader->NextEvent(); // to be sure to get run number available + fRunNumber = fRawReader->GetRunNumber(); + fRawReader->RewindEvents(); + } + TString name; - if (!runNumber) + if (!fRunNumber) { ++fgkCounter; name = Form("%sRAW(%d)",(histogram?"H":""),fgkCounter); } else { - name = Form("%sRAW%d",(histogram?"H":""),runNumber); + name = Form("%sRAW%d",(histogram?"H":""),fRunNumber); } fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1); @@ -83,8 +92,6 @@ AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader, Boo { fAccumulatedData->MakeHistogramForDimension(0,kTRUE); } - - reader->RewindEvents(); } //_____________________________________________________________________________ @@ -92,7 +99,28 @@ AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker() { /// dtor delete fOneEventData; - if ( fIsOwner ) delete fAccumulatedData; + delete fAccumulatedData; + delete fRawReader; +} + +//_____________________________________________________________________________ +Long64_t +AliMUONTrackerRawDataMaker::Merge(TCollection*) +{ + /// Merge objects in collection + +// AliRawReader* fRawReader; //!< reader of the data (owner) +// AliMUONVTrackerData* fAccumulatedData; ///< data (owner) +// AliMUONVStore* fOneEventData; ///< data for one event (owner) +// TString fSource; ///< where the data comes from +// Bool_t fIsRunning; ///< whether we are running or are paused +// Int_t fNumberOfEvents; ///< number of events seen +// Int_t fRunNumber; ///< run number of the data +// Bool_t fIsEventByEvent; ///< we only keep one event's data (no accumulation) +// Bool_t fUseHPDecoder; ///< whether to use high performance decoder or not (false by default) + + AliError("Not implemented yet"); + return 0; } //_____________________________________________________________________________ @@ -128,7 +156,16 @@ AliMUONTrackerRawDataMaker::NextEvent() ++nphysics; - AliMUONVRawStreamTracker* stream = new AliMUONRawStreamTracker(fRawReader); + AliMUONVRawStreamTracker* stream = 0x0; + + if ( fUseHPDecoder ) + { + stream = new AliMUONRawStreamTrackerHP(fRawReader); + } + else + { + stream = new AliMUONRawStreamTracker(fRawReader); + } stream->First(); diff --git a/MUON/AliMUONTrackerRawDataMaker.h b/MUON/AliMUONTrackerRawDataMaker.h index e7aaf197082..16be0a67f23 100644 --- a/MUON/AliMUONTrackerRawDataMaker.h +++ b/MUON/AliMUONTrackerRawDataMaker.h @@ -26,7 +26,9 @@ class AliMUONVTrackerData; class AliMUONTrackerRawDataMaker : public AliMUONVTrackerDataMaker { public: - AliMUONTrackerRawDataMaker(AliRawReader* reader = 0x0, Bool_t histogram=kFALSE); + AliMUONTrackerRawDataMaker(AliRawReader* reader = 0x0, + Bool_t histogram=kFALSE, + Bool_t useHPdecoder=kFALSE); virtual ~AliMUONTrackerRawDataMaker(); /// Whether we have a valid raw reader @@ -35,8 +37,14 @@ public: /// Our data AliMUONVTrackerData* Data() const { return fAccumulatedData; } - /// We can be run - virtual Bool_t IsRunnable() const { return kTRUE; } + /// Whether we're only handling event-by-event data (i.e. no accumulation) + virtual Bool_t IsEventByEvent() const { return fIsEventByEvent; } + + /// Set event-by-event mode + virtual void SetEventByEvent(Bool_t flag) { fIsEventByEvent = flag; } + + /// We can be run if we have a reader + virtual Bool_t IsRunnable() const { return IsValid(); } /// Whether we are running or not virtual Bool_t IsRunning() const { return fIsRunning; } @@ -50,9 +58,6 @@ public: void Rewind(); - /// Tell if we are owner of our data or not - void SetOwner(Bool_t flag) { fIsOwner = flag; } - /// Get our source URI virtual TString Source() const { return fSource.Data(); } @@ -62,6 +67,8 @@ public: /// Number of events seen Int_t NumberOfEvents() const { return fNumberOfEvents; } + Long64_t Merge(TCollection* li); + private: /// Not implemented AliMUONTrackerRawDataMaker(const AliMUONTrackerRawDataMaker& rhs); @@ -69,16 +76,18 @@ private: AliMUONTrackerRawDataMaker& operator=(const AliMUONTrackerRawDataMaker& rhs); private: - AliRawReader* fRawReader; ///< reader of the data (owner) - AliMUONVTrackerData* fAccumulatedData; ///< data (owner if fIsOwner==kTRUE) + AliRawReader* fRawReader; //!< reader of the data (owner) + AliMUONVTrackerData* fAccumulatedData; ///< data (owner) AliMUONVStore* fOneEventData; ///< data for one event (owner) - Bool_t fIsOwner; ///< whether we are owner of our data or not TString fSource; ///< where the data comes from Bool_t fIsRunning; ///< whether we are running or are paused Int_t fNumberOfEvents; ///< number of events seen + Int_t fRunNumber; ///< run number of the data + Bool_t fIsEventByEvent; ///< we only keep one event's data (no accumulation) + Bool_t fUseHPDecoder; ///< whether to use high performance decoder or not (false by default) static Int_t fgkCounter; ///< to count the number of instances - ClassDef(AliMUONTrackerRawDataMaker,2) // Producer of AliMUONVTrackerData from raw data + ClassDef(AliMUONTrackerRawDataMaker,3) // Producer of AliMUONVTrackerData from raw data }; #endif diff --git a/MUON/AliMUONVPainter.cxx b/MUON/AliMUONVPainter.cxx index ee24707cdc0..1554162a893 100644 --- a/MUON/AliMUONVPainter.cxx +++ b/MUON/AliMUONVPainter.cxx @@ -857,6 +857,11 @@ AliMUONVPainter::SetData(const char* pattern, AliMUONVTrackerData* data, CreateGroups(); } + if ( data ) + { + data->Connect("Destroyed()",ClassName(),this,Form("SetData(=\"%s\",0x0,-1)",pattern)); + } + TIter next(fPainterGroups); TObjString* str; @@ -893,7 +898,8 @@ AliMUONVPainter::SetData(const char* pattern, AliMUONVTrackerData* data, { TList* l = p->IsA()->GetMenuList(); - l->Clear(); +// l->Clear(); + l->Delete(); if ( group ) { @@ -904,39 +910,73 @@ AliMUONVPainter::SetData(const char* pattern, AliMUONVTrackerData* data, { // Add histo drawing to the popup menu TClassMenuItem* n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(), - "Draw histogram","DrawHistogram",p,"",-1,kTRUE); - l->AddFirst(n); + "Draw histogram","DrawHistogram0",p,"",-1,kTRUE); + l->Add(n); n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(), - "Draw histogram clone","DrawHistogramClone",p,"",-1,kTRUE); - l->AddFirst(n); - - + "Draw histogram clone","DrawHistogramClone0",p,"",-1,kTRUE); + l->Add(n); } + } + + for ( Int_t i = 0; i < data->ExternalDimension()*2; ++i ) + { + TClassMenuItem* n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(), + Form("Draw %s clone",data->DimensionName(i).Data()), + Form("DrawInternalHistogramClone%d",i),p,"",-1,kTRUE); + l->Add(n); + } } } } //_____________________________________________________________________________ void -AliMUONVPainter::DrawHistogram() const +AliMUONVPainter::DrawInternalHistogram(Int_t dim) const +{ + /// Draw histogram (and delete the previous one) + + delete fHistogram; + fHistogram = 0x0; + + DrawInternalHistogramClone(dim); +} + +//_____________________________________________________________________________ +void +AliMUONVPainter::DrawInternalHistogramClone(Int_t dim) const +{ + /// Draw histogram + + fHistogram = AliMUONTrackerDataHistogrammer::CreateHisto(*this,-1,dim); + + if (fHistogram) + { + new TCanvas(); + fHistogram->Draw(); + } +} + +//_____________________________________________________________________________ +void +AliMUONVPainter::DrawHistogram(Double_t* values) const { /// Draw histogram (and delete the previous one) delete fHistogram; fHistogram = 0x0; - DrawHistogramClone(); + DrawHistogramClone(values); } //_____________________________________________________________________________ void -AliMUONVPainter::DrawHistogramClone() const +AliMUONVPainter::DrawHistogramClone(Double_t*) const { /// Draw histogram - fHistogram = AliMUONTrackerDataHistogrammer::CreateHisto(*this); + fHistogram = AliMUONTrackerDataHistogrammer::CreateHisto(*this,0,-1); if (fHistogram) { diff --git a/MUON/AliMUONVPainter.h b/MUON/AliMUONVPainter.h index 4c40fab87ff..f0804a39032 100644 --- a/MUON/AliMUONVPainter.h +++ b/MUON/AliMUONVPainter.h @@ -71,6 +71,8 @@ public: AliMUONVPainter* Detach() const; + virtual Bool_t CanBeDetached() const { return kTRUE; } + /// Whether we are valid or not virtual Bool_t IsValid() const { return fIsValid; } @@ -211,19 +213,42 @@ public: AliMUONVPainter* Master() const; - virtual void DrawHistogram() const; + virtual void DrawHistogram(Double_t* values=0x0) const; + + /// To avoid getting a popup asking for the parameter in the GUI... + void DrawHistogram0() const { DrawHistogram(0x0); } + void DrawHistogramClone0() const { DrawHistogramClone(0x0); } + + virtual void DrawHistogramClone(Double_t* values=0x0) const; + + virtual void DrawInternalHistogram(Int_t dim) const; - virtual void DrawHistogramClone() const; + virtual void DrawInternalHistogramClone(Int_t dim) const; - /// Append (i.e. don't have the right the clear the array !) our list of manus to manuList + /// Append (i.e. don't have the right to clear the array !) our list of manus to manuList virtual void FillManuList(TObjArray& manuList) const; + /// following kind of stupid lines, because I don't know how to + /// pass parameters to TClassMenuItem for context menu (don't even + /// know if that's possible at all) + + void DrawInternalHistogramClone0() { DrawInternalHistogramClone(0); } + void DrawInternalHistogramClone1() { DrawInternalHistogramClone(1); } + void DrawInternalHistogramClone2() { DrawInternalHistogramClone(2); } + void DrawInternalHistogramClone3() { DrawInternalHistogramClone(3); } + void DrawInternalHistogramClone4() { DrawInternalHistogramClone(4); } + void DrawInternalHistogramClone5() { DrawInternalHistogramClone(5); } + void DrawInternalHistogramClone6() { DrawInternalHistogramClone(6); } + void DrawInternalHistogramClone7() { DrawInternalHistogramClone(7); } + void DrawInternalHistogramClone8() { DrawInternalHistogramClone(8); } + void DrawInternalHistogramClone9() { DrawInternalHistogramClone(9); } + protected: virtual TCollection* Children() const; private: - + void FlatList(TList& list); AliMUONPainterGroup* CreateGroup(const char* type, Int_t depth); diff --git a/MUON/AliMUONVStore.cxx b/MUON/AliMUONVStore.cxx index 6f413cf34ae..7f1161643b0 100644 --- a/MUON/AliMUONVStore.cxx +++ b/MUON/AliMUONVStore.cxx @@ -152,7 +152,7 @@ TObject* AliMUONVStore::FindObject(Int_t, Int_t) const { /// Find an object using 2 identifiers - AliError("Not implemented"); + AliError("(Int_t,Int_t) : Not implemented"); return 0; } diff --git a/MUON/AliMUONVTrackerData.h b/MUON/AliMUONVTrackerData.h index cf91a9a7672..c465d68fdf0 100644 --- a/MUON/AliMUONVTrackerData.h +++ b/MUON/AliMUONVTrackerData.h @@ -31,11 +31,12 @@ class AliMUONVTrackerData : public TNamed, public TQObject { public: - AliMUONVTrackerData(const char* name="",const char* title="", Bool_t runnable=kTRUE); + AliMUONVTrackerData(const char* name="",const char* title="", + Bool_t issingleevent=kFALSE); virtual ~AliMUONVTrackerData(); - /// Add values (accumulated over numberOfEvents events) for one full store - virtual Bool_t Add(const AliMUONVStore& store, Int_t numberOfEvents=1) = 0; + /// Add values for one event from one full store + virtual Bool_t Add(const AliMUONVStore& store) = 0; /// Get the value for a given buspatch and given dimension virtual Double_t BusPatch(Int_t busPatchId, Int_t dim=0) const = 0; @@ -80,8 +81,8 @@ public: /// Whether we have data for a given PCB virtual Bool_t HasPCB(Int_t detElemId, Int_t pcbIndex) const = 0; - /// Whether we are runnable (e.g. can handle several events) - virtual Bool_t IsRunnable() const = 0; + /// Whether we deal with only one event at a time + virtual Bool_t IsSingleEvent() const = 0; /// Get the value for a given manu and given dimension virtual Double_t Manu(Int_t detElemId, Int_t manuId, Int_t dim=0) const = 0; diff --git a/MUON/AliMUONVTrackerDataMaker.h b/MUON/AliMUONVTrackerDataMaker.h index 27a729ae972..741fe22713c 100644 --- a/MUON/AliMUONVTrackerDataMaker.h +++ b/MUON/AliMUONVTrackerDataMaker.h @@ -17,6 +17,7 @@ #endif class AliMUONVTrackerData; +class TCollection; class AliMUONVTrackerDataMaker : public TObject { @@ -36,6 +37,12 @@ public: /// Whether we are running (must be false if IsRunnable is false) virtual Bool_t IsRunning() const = 0; + /// Whether we're only handling event-by-event data (i.e. no accumulation) + virtual Bool_t IsEventByEvent() const { return kFALSE; } + + /// Set event-by-event mode + virtual void SetEventByEvent(Bool_t /*flag*/) { } + /// Set the running state (no effect if not runnable) virtual void SetRunning(Bool_t flag) = 0; @@ -45,9 +52,6 @@ public: /// Rewind events (no effect if not runnable) virtual void Rewind() = 0; - /// Whether we're owner of our data - virtual void SetOwner(Bool_t flag) = 0; - /// Set our source URI virtual void SetSource(const char* source) = 0; @@ -57,6 +61,9 @@ public: /// Get the number of events we have seen (but not necessarily used...) virtual Int_t NumberOfEvents() const = 0; + /// Merge + virtual Long64_t Merge(TCollection* list) = 0; + ClassDef(AliMUONVTrackerDataMaker,1) // Producer of AliMUONVTrackerData }; diff --git a/MUON/MUONgraphicsLinkDef.h b/MUON/MUONgraphicsLinkDef.h index 3af5f4defc9..1619b3c9e2a 100644 --- a/MUON/MUONgraphicsLinkDef.h +++ b/MUON/MUONgraphicsLinkDef.h @@ -43,5 +43,7 @@ #pragma link C++ class AliMUONMchViewApplication+; #pragma link C++ class AliMUONSparseHisto+; #pragma link C++ class AliMUONTrackerDataHistogrammer+; +#pragma link C++ class AliMUONTrackerDataWrapper+; +#pragma link C++ class AliMUONTrackerDataCompareDialog+; #endif diff --git a/MUON/READMEmchview.txt b/MUON/READMEmchview.txt index 73b5472a918..922829052b0 100644 --- a/MUON/READMEmchview.txt +++ b/MUON/READMEmchview.txt @@ -78,9 +78,9 @@ The short name of the data source is as follow : - RAW# : raw data for run # - RAW(#) : raw data for simulated run (where run number is always 0, so # here is the number of such data sources opened at the same time) - HRAW# (or HRAW(#)) : as above, but with histogramming turned on -- (H)CALZ# (or (H)CALZ(#)): as above, but for data where zero-suppression has been done (and no gain correction whatsoever) -- (H)CALG# : for data where zero-suppression and gain correction has been applied (but no channel-per-channel capacitance correction done) -- (H)CALC# : for data where zero-suppression and full gain correction (including channel-dependent capacitance correction) applied +- (H)CALZ# (or (H)CALZ(#)): as above, but for data where pedestal subtraction has been done (and no gain correction whatsoever) +- (H)CALG# : for data where pedestal subtraction and gain correction has been applied (but no channel-per-channel capacitance correction done) +- (H)CALC# : for data where pedestal subtraction and full gain correction (including channel-dependent capacitance correction) applied Note that all the file paths can be local ones or alien ones, if you have a correctly installed alien, and you use a short wrapped to call the \em mchview program. For instance : diff --git a/MUON/TestMUONPreprocessor.C b/MUON/TestMUONPreprocessor.C index 145000e0a6d..53447cee5ec 100644 --- a/MUON/TestMUONPreprocessor.C +++ b/MUON/TestMUONPreprocessor.C @@ -71,12 +71,12 @@ #include "TRandom.h" #endif -void TestMUONPreprocessor(Int_t runNumber=80, const char* runType="PEDESTAL") +void TestMUONPreprocessor(Int_t runNumber=80, const char* runType="CALIBRATION") { // runType can be : // // PEDESTAL -> pedestals - // ELECTRONICS_CALIBRATION -> gains + // CALIBRATION -> gains // PHYSICS -> HV // GMS @@ -119,15 +119,24 @@ void TestMUONPreprocessor(Int_t runNumber=80, const char* runType="PEDESTAL") // AddInputFile(, , , , ) // In this example we add 4 files originating from different LDCs but with the same id (PEDESTALS) - shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC0","$ALICE_ROOT/MUON/data/LDC0.ped"); - shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC1","$ALICE_ROOT/MUON/data/LDC1.ped"); - shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC2","$ALICE_ROOT/MUON/data/LDC2.ped"); - shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC3","$ALICE_ROOT/MUON/data/LDC3.ped"); +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC0","$ALICE_ROOT/MUON/data/LDC0.ped"); +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC1","$ALICE_ROOT/MUON/data/LDC1.ped"); +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC2","$ALICE_ROOT/MUON/data/LDC2.ped"); +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC3","$ALICE_ROOT/MUON/data/LDC3.ped"); + + shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC0","$HOME/Alice/Online/GAINRUN/raw.81.LDC0.ped"); + shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC1","$HOME/Alice/Online/GAINRUN/raw.81.LDC1.ped"); + shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC2","$HOME/Alice/Online/GAINRUN/raw.81.LDC2.ped"); +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC3","$HOME/Alice/Online/GAINRUN/raw.81.LDC3.ped"); - shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC0","$ALICE_ROOT/MUON/data/LDC0.gain"); - shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC1","$ALICE_ROOT/MUON/data/LDC1.gain"); - shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC2","$ALICE_ROOT/MUON/data/LDC2.gain"); - shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC3","$ALICE_ROOT/MUON/data/LDC3.gain"); +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC0","$HOME/Desktop/Jean-Luc Charvet/run000001191_MCH_ldc-MTRK-S1-0_GAINS"); + +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC0","$HOME/Desktop/Jean-Luc Charvet/run000001183_MCH_ldc-MTRK-S1-0_GAINS"); + + shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC0","$HOME/Alice/Online/GAINRUN/LDC0.gain"); +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC1","$ALICE_ROOT/MUON/data/LDC1.gain"); +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC2","$ALICE_ROOT/MUON/data/LDC2.gain"); +// shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC3","$ALICE_ROOT/MUON/data/LDC3.gain"); // and GMS file shuttle->AddInputFile(AliTestShuttle::kDCS,"MCH","GMS","GMS","$ALICE_ROOT/MUON/data/GMS.root"); diff --git a/MUON/libMUONgraphics.pkg b/MUON/libMUONgraphics.pkg index 42a339ffb05..1eb588eeb46 100644 --- a/MUON/libMUONgraphics.pkg +++ b/MUON/libMUONgraphics.pkg @@ -34,7 +34,9 @@ SRCS:= AliMUONVPainter.cxx \ AliMUONTrackerCalibratedDataMaker.cxx \ AliMUONMchViewApplication.cxx \ AliMUONSparseHisto.cxx \ - AliMUONTrackerDataHistogrammer.cxx + AliMUONTrackerDataHistogrammer.cxx \ + AliMUONTrackerDataWrapper.cxx \ + AliMUONTrackerDataCompareDialog.cxx HDRS:= $(SRCS:.cxx=.h) diff --git a/MUON/mchview.cxx b/MUON/mchview.cxx index cb67c28ec21..47b4c3920b2 100644 --- a/MUON/mchview.cxx +++ b/MUON/mchview.cxx @@ -39,7 +39,7 @@ Int_t Usage() /// Printout available options of the program cout << "mchview " << endl; cout << " --version : shows the current version of the program" << endl; - cout << " --use filename.root : reuse a previously saved (from this program) root file" << endl; + cout << " --use filename.root : reuse a previously saved (from this program) root file. Several --use can be used ;-)" << endl; return -1; } @@ -56,7 +56,7 @@ int main(int argc, char** argv) Int_t nok(0); - TString fileToOpen; + TObjArray filesToOpen; for ( Int_t i = 0; i <= args.GetLast(); ++i ) { @@ -69,7 +69,7 @@ int main(int argc, char** argv) } if ( a == "--use" && i < args.GetLast() ) { - fileToOpen = static_cast(args.At(i+1))->String(); + filesToOpen.Add(args.At(i+1)); ++i; nok += 2; } @@ -106,7 +106,12 @@ int main(int argc, char** argv) AliCodeTimer::Instance()->Print(); - if ( fileToOpen.Length() > 0 ) theApp->Open(fileToOpen); + TIter next(&filesToOpen); + TObjString* s; + while ( ( s = static_cast(next()) ) ) + { + theApp->Open(s->String().Data()); + } // --- Start the event loop --- theApp->Run(kTRUE); -- 2.39.3