X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONPainterHelper.cxx;h=73b08dfcbdc97b04c439f60648216d55f50732b8;hb=6dbd970fbe9a7d3fd10fd779dc075dc82ce40447;hp=d09f93423b6c92cd910b70d2318792d1b7b9c3c9;hpb=b09247a2e1f543e6819d914f93df8996fa82c16e;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONPainterHelper.cxx b/MUON/AliMUONPainterHelper.cxx index d09f93423b6..73b08dfcbdc 100644 --- a/MUON/AliMUONPainterHelper.cxx +++ b/MUON/AliMUONPainterHelper.cxx @@ -18,13 +18,15 @@ #include #include "AliMUONPainterHelper.h" +#include "AliCodeTimer.h" +#include "AliLog.h" +#include "AliMUONContour.h" +#include "AliMUONContourMaker.h" #include "AliMUONGeometryDetElement.h" #include "AliMUONGeometryTransformer.h" -#include "AliMUONPainterContour.h" -#include "AliMUONPainterContourMaker.h" +#include "AliMUONManuContourMaker.h" #include "AliMUONPainterEnv.h" #include "AliMUONPainterMatrix.h" -#include "AliMUONPainterPadStore.h" #include "AliMUONPainterRegistry.h" #include "AliMUONVCalibParam.h" #include "AliMUONVDigit.h" @@ -40,14 +42,10 @@ #include "AliMpPCB.h" #include "AliMpPad.h" #include "AliMpSector.h" -#include "AliMpSectorSegmentation.h" #include "AliMpSegmentation.h" #include "AliMpSlat.h" -#include "AliMpSlatSegmentation.h" #include "AliMpStationType.h" #include "AliMpVPadIterator.h" -#include "AliCodeTimer.h" -#include "AliLog.h" #include #include #include @@ -55,8 +53,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -69,6 +67,8 @@ #include #include +#include "AliMUONChamberPainter.h" + ///\class AliMUONPainterHelper /// /// Helper class for painters @@ -83,16 +83,17 @@ AliMUONPainterHelper* AliMUONPainterHelper::fgInstance(0x0); //_____________________________________________________________________________ AliMUONPainterHelper::AliMUONPainterHelper() : - TObject(), - fPadStore(0x0), - fExplodedGlobalTransformations(0x0), - fRealGlobalTransformations(0x0), - fIsModified(kFALSE), - fContourMaker(0x0), - fPainterMatrices(0x0), - fEnv(0x0) +TObject(), +fExplodedGlobalTransformations(0x0), +fRealGlobalTransformations(0x0), +fPainterMatrices(0x0), +fEnv(0x0), +fAllContours(20000,1) { /// ctor + + fAllContours.SetOwnerKeyValue(kTRUE,kTRUE); + fExplodeFactor[0] = 1.00; fExplodeFactor[1] = 1.50; @@ -112,37 +113,19 @@ AliMUONPainterHelper::AliMUONPainterHelper() : AliMUONPainterHelper::~AliMUONPainterHelper() { /// dtor - if ( fIsModified ) Save(); delete fExplodedGlobalTransformations; delete fRealGlobalTransformations; - delete fPadStore; - delete fContourMaker; delete fPainterMatrices; + fEnv->Save(); fgInstance = 0; } //_____________________________________________________________________________ -AliMUONPainterContour* +AliMUONContour* AliMUONPainterHelper::GetContour(const char* contourName) const { - /// Get a contour by name - - AliCodeTimerAuto("") - - if ( fContourMaker ) - { - return fContourMaker->GetContour(contourName); - } - return 0x0; -} - -//_____________________________________________________________________________ -Int_t -AliMUONPainterHelper::FindPadID(const TArrayI& pads, Double_t x, Double_t y) const -{ - /// Find a pad by position - - return fPadStore->FindPadID(pads,x,y); + /// Get a contour by name + return static_cast(fAllContours.GetValue(contourName)); } //_____________________________________________________________________________ @@ -151,6 +134,8 @@ AliMUONPainterHelper::GenerateDefaultMatrices() { /// Kind of bootstrap method to trigger the generation of all contours + AliCodeTimerAuto(""); + fPainterMatrices = new TObjArray; fPainterMatrices->SetOwner(kFALSE); @@ -161,17 +146,19 @@ AliMUONPainterHelper::GenerateDefaultMatrices() att.SetViewPoint(kTRUE,kFALSE); att.SetPlane(kFALSE,kFALSE); att.SetCathode(kTRUE,kFALSE); - - AliWarningClass("Should generate back views as well here"); - - attributes.Add(new AliMUONAttPainter(att)); - att.SetCathode(kFALSE,kTRUE); - attributes.Add(new AliMUONAttPainter(att)); + att.SetCathode(kFALSE,kFALSE); att.SetPlane(kTRUE,kFALSE); attributes.Add(new AliMUONAttPainter(att)); - att.SetPlane(kFALSE,kTRUE); - attributes.Add(new AliMUONAttPainter(att)); + +// commented the lines below, as it's now fast enough to be created on the fly, +// only when requested by the user +// +// attributes.Add(new AliMUONAttPainter(att)); +// att.SetCathode(kFALSE,kTRUE); +// attributes.Add(new AliMUONAttPainter(att)); +// att.SetPlane(kFALSE,kTRUE); +// attributes.Add(new AliMUONAttPainter(att)); TIter next(&attributes); AliMUONAttPainter* a; @@ -182,7 +169,7 @@ AliMUONPainterHelper::GenerateDefaultMatrices() for ( Int_t i = 0; i < 10; ++i ) { - AliMUONVPainter* painter = AliMUONVPainter::CreatePainter("AliMUONChamberPainter",*a,i,-1); + AliMUONVPainter* painter = new AliMUONChamberPainter(*a,i); painter->SetResponder("Chamber"); @@ -211,13 +198,12 @@ AliMUONPainterHelper::GenerateGeometry() /// having overlapping detection elements as in the reality, which /// would be inconvenient for a display ;-) - AliDebug(1,Form(" with explodeFactor=%e,%e",fExplodeFactor[0],fExplodeFactor[1])); + AliCodeTimerAuto(""); AliMUONGeometryTransformer transformer; transformer.LoadGeometryData("transform.dat"); -// transformer.LoadGeometryData("geometry.root"); //FIXME: add a protection if geometry.root file does not exist - fExplodedGlobalTransformations = new AliMpExMap(true); - fRealGlobalTransformations = new AliMpExMap(true); + fExplodedGlobalTransformations = new AliMpExMap; + fRealGlobalTransformations = new AliMpExMap; AliMpDEIterator deIt; deIt.First(); while ( !deIt.IsDone() ) @@ -255,7 +241,7 @@ AliMUONPainterHelper::GenerateGeometry() } //_____________________________________________________________________________ -AliMUONPainterContour* +AliMUONContour* AliMUONPainterHelper::GenerateManuContour(Int_t detElemId, Int_t manuId, AliMUONAttPainter viewType, @@ -263,87 +249,26 @@ AliMUONPainterHelper::GenerateManuContour(Int_t detElemId, { /// Generate the contour of the list of pads - if (!fContourMaker) fContourMaker = new AliMUONPainterContourMaker(fExplodedGlobalTransformations); + static AliMUONManuContourMaker maker(fExplodedGlobalTransformations); - AliMUONPainterContour* contour = - fContourMaker->GenerateManuContour(contourName,detElemId,manuId,viewType); - - if (contour) + if ( viewType.IsBackView() ) { - RegisterContour(contour); + AliError("Backview not implemented yet (and will probably never be, after all...)"); + return 0x0; } - return contour; -} - -//_____________________________________________________________________________ -void -AliMUONPainterHelper::GeneratePadStore() -{ - /// Generate the pad store + AliMUONContour* contour = maker.CreateManuContour(detElemId,manuId,contourName); - AliCodeTimerAuto("") - AliDebugClass(1,"Generating pad store"); - fPadStore = new AliMUONPainterPadStore(); + if ( !contour ) return 0x0; - AliMpDEIterator deIt; + AliMUONContour* pContour = new AliMUONContour(*contour); - deIt.First(); - while ( !deIt.IsDone() ) + if (pContour) { - Int_t detElemId = deIt.CurrentDEId(); - if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger ) - { - GeneratePadStore(detElemId); - } - deIt.Next(); + RegisterContour(pContour); } -} - -//_____________________________________________________________________________ -void -AliMUONPainterHelper::GeneratePadStore(Int_t detElemId) -{ - /// Generate part of the padstore for one detection element - AliMp::CathodType cathode[] = { AliMp::kCath0, AliMp::kCath1 }; - - for ( Int_t i = 0; i < 2; ++i ) - { - const AliMpVSegmentation* seg = - AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,cathode[i]); - AliMpVPadIterator* it = seg->CreateIterator(); - it->First(); - - while ( !it->IsDone() ) - { - AliMpPad pad = it->CurrentItem(); - - TVector2 localPosition(pad.Position()); - Double_t x,y,z; - Local2Global(detElemId,localPosition.X(),localPosition.Y(),0, - x,y,z); - Int_t manuId = pad.GetLocation().GetFirst(); - Int_t manuChannel = pad.GetLocation().GetSecond(); - AliMUONVCalibParam* param = fPadStore->Get(detElemId,manuId); - param->SetValueAsDouble(manuChannel,0,x); - param->SetValueAsDouble(manuChannel,1,y); - param->SetValueAsDouble(manuChannel,2,pad.Dimensions().X()); - param->SetValueAsDouble(manuChannel,3,pad.Dimensions().Y()); - it->Next(); - } - delete it; - } -} - -//_____________________________________________________________________________ -void -AliMUONPainterHelper::GetBoundaries(const TArrayI& pads, Double_t& xmin, Double_t& ymin, - Double_t& xmax, Double_t& ymax) const -{ - /// Get the area covered by an array of pads - - return fPadStore->GetBoundaries(pads,xmin,ymin,xmax,ymax); + return pContour; } //_____________________________________________________________________________ @@ -360,13 +285,6 @@ AliMUONPainterHelper::GetCathodeType(Int_t detElemId, Int_t manuId) const return AliMpDEManager::GetCathod(detElemId,planeType); } -//_____________________________________________________________________________ -AliMUONPainterContour* -AliMUONPainterHelper::GetLocalManuContour(Int_t detElemId, Int_t manuId) const -{ - /// Retrieve a manu contour (in local coordinates) - return fContourMaker->FindLocalManuContour(detElemId,manuId); -} //_____________________________________________________________________________ AliMpMotifPosition* @@ -452,16 +370,11 @@ AliMUONPainterHelper::GetSector(Int_t detElemId, AliMp::PlaneType planeType) con { /// Get a given sector AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); - if ( stationType != AliMp::kStation1 && stationType != AliMp::kStation2 ) return 0x0; + if ( stationType != AliMp::kStation12 ) return 0x0; AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,planeType); - const AliMpVSegmentation* seg = - AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,cathodeType); - - const AliMpSectorSegmentation* sectorSeg = static_cast(seg); - return sectorSeg->GetSector(); - + return AliMpSegmentation::Instance()->GetSector(detElemId,cathodeType); } //_____________________________________________________________________________ @@ -472,11 +385,7 @@ AliMUONPainterHelper::GetSlat(Int_t detElemId, AliMp::CathodType cathodeType) co AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); if ( stationType != AliMp::kStation345 ) return 0x0; - const AliMpVSegmentation* seg = - AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,cathodeType); - - const AliMpSlatSegmentation* slatSeg = static_cast(seg); - return slatSeg->Slat(); + return AliMpSegmentation::Instance()->GetSlat(detElemId,cathodeType); } //_____________________________________________________________________________ @@ -484,11 +393,10 @@ const AliMpSlat* AliMUONPainterHelper::GetSlat(Int_t detElemId, Int_t manuId) const { /// Get a given slat - const AliMpVSegmentation* seg = - AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); - - const AliMpSlatSegmentation* slatSeg = static_cast(seg); - return slatSeg->Slat(); + AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); + if ( stationType != AliMp::kStation345 ) return 0x0; + + return AliMpSegmentation::Instance()->GetSlatByElectronics(detElemId,manuId); } //_____________________________________________________________________________ @@ -498,51 +406,13 @@ AliMUONPainterHelper::Instance() /// Return the global and unique instance of this class if (fgInstance) return fgInstance; - - AliMUONPainterEnv env; - - TString fileName(gSystem->ExpandPathName(env.String("PadStoreFileName","$HOME/padstore.root"))); - if ( gSystem->AccessPathName(fileName.Data(),kFileExists) ) // mind the strange return value of that method... - { - // file does NOT exist yet. Create it - AliDebugClass(1,"Generating instance"); - - Int_t ret; - - new TGMsgBox(gClient->GetRoot(),gClient->GetRoot(),"", - Form("File %s not found.\nI will generate it, and this will take a while.\n" - "Click OK (and grab a cup of coffee ;-) ) to proceed,\n or Cancel to quit.",fileName.Data()), - kMBIconQuestion, - kMBOk | kMBCancel, - &ret); - if ( ret == kMBCancel ) exit(1); - - fgInstance = new AliMUONPainterHelper; - fgInstance->GenerateGeometry(); - fgInstance->GeneratePadStore(); - fgInstance->GenerateDefaultMatrices(); - fgInstance->Modified(kTRUE); - fgInstance->fEnv = new AliMUONPainterEnv; - fgInstance->fEnv->Set("PadStoreFileName",fileName.Data()); - fgInstance->Save(); - - } - else - { - AliDebugClass(1,"Reading instance"); - TFile f(fileName.Data()); - fgInstance = static_cast(f.Get("AliMUONPainterHelper")); - - TIter next(fgInstance->fPainterMatrices); - AliMUONPainterMatrix* matrix; - while ( ( matrix = static_cast(next()) ) ) - { - AliMUONPainterRegistry::Instance()->Register(matrix); - } - fgInstance->fPainterMatrices->SetOwner(kFALSE); - fgInstance->fEnv = new AliMUONPainterEnv; - } + AliCodeTimerAutoClass(""); + + fgInstance = new AliMUONPainterHelper; + fgInstance->GenerateGeometry(); + fgInstance->GenerateDefaultMatrices(); + fgInstance->fEnv = new AliMUONPainterEnv; return fgInstance; } @@ -635,18 +505,15 @@ AliMUONPainterHelper::ColorFromValue(Double_t value, Double_t min, Double_t max) } //_____________________________________________________________________________ -AliMUONPainterContour* +AliMUONContour* AliMUONPainterHelper::MergeContours(const TObjArray& contours, const char* contourName) { /// Merge a set of contours (delegating to the contour maker) - if (!fContourMaker) - { - fContourMaker = new AliMUONPainterContourMaker(fExplodedGlobalTransformations); - } - AliMUONPainterContour* contour = fContourMaker->MergeContours(contours, - contourName); + AliMUONContourMaker maker; + + AliMUONContour* contour = maker.MergeContour(contours,contourName); if (contour) { @@ -667,36 +534,15 @@ AliMUONPainterHelper::Print(Option_t* opt) const if ( sopt.Length() == 0 ) { cout << Form("ExplodeFactor=%e,%e",fExplodeFactor[0],fExplodeFactor[1]) << endl; - cout << Form("PadStore=%x",fPadStore); - if ( fPadStore ) cout << Form(" with %d pads",fPadStore->GetSize()); cout << endl; cout << Form("GlobalTransformations=%x",fExplodedGlobalTransformations); if ( fExplodedGlobalTransformations ) cout << Form(" with %d transformations",fExplodedGlobalTransformations->GetSize()); cout << endl; - if ( fContourMaker ) - { - cout << Form(" with %d contours",fContourMaker->Size()); - } - else - { - cout << "No contour"; - } + cout << Form("Contour map : collisions = %5.3f size = %d capacity = %d", + fAllContours.AverageCollisions(), + fAllContours.GetSize(), + fAllContours.Capacity()) << endl; cout << endl; - cout << "Modified="; - if ( IsModified() ) - { - cout << "YES"; - } - else - { - cout << "NO"; - } - cout << endl; - } - - if ( sopt.Contains("CONTOUR") || sopt.Contains("FULL") ) - { - fContourMaker->Print(opt); } if ( sopt.Contains("MATRI") || sopt.Contains("FULL") ) @@ -707,46 +553,18 @@ AliMUONPainterHelper::Print(Option_t* opt) const //_____________________________________________________________________________ void -AliMUONPainterHelper::RegisterContour(AliMUONPainterContour* contour) +AliMUONPainterHelper::RegisterContour(AliMUONContour* contour) { /// contour is adopted by contourMaker AliCodeTimerAuto("") AliDebug(1,contour->GetName()); - if ( fContourMaker->HasContour(contour->GetName()) ) + if ( fAllContours.GetValue(contour->GetName()) ) { AliError(Form("Contour with name %s is already there",contour->GetName())); // Print("CONTOUR"); return; } - fContourMaker->Add(contour); - Modified(kTRUE); -} - -//_____________________________________________________________________________ -void -AliMUONPainterHelper::Save() -{ - /// Save to disk - - if (!IsModified()) return; - - Modified(kFALSE); - - AliInfo(""); - - fgInstance->Print(); - - fgInstance->Env()->Save(); - - TString fileName(gSystem->ExpandPathName(fgInstance->Env()->String("PadStoreFileName"))); - - AliInfo(Form("Saving to %s",fileName.Data())); - - TFile f(fileName,"RECREATE"); - - fgInstance->Write(""); - - f.Close(); + fAllContours.Add(new TObjString(contour->GetName()),contour); } //_____________________________________________________________________________ @@ -774,9 +592,9 @@ AliMUONPainterHelper::PadByExplodedPosition(Int_t detElemId, Int_t manuId, const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); - AliDebug(1,Form("dx,dy=%7.3f,%7.3f",seg->Dimensions().X(),seg->Dimensions().Y())); + AliDebug(1,Form("dx,dy=%7.3f,%7.3f",seg->GetDimensionX(),seg->GetDimensionY())); - return seg->PadByPosition(TVector2(xl,yl)); + return seg->PadByPosition(xl,yl); } //_____________________________________________________________________________ @@ -911,3 +729,4 @@ AliMUONPainterHelper::FormatValue(const char* name, Double_t value) const return Form("%s = %e",name,value); } +