From fef32488bb28772e360773c9d300c84b9cb87d5c Mon Sep 17 00:00:00 2001 From: laphecet Date: Thu, 8 Oct 2009 15:12:26 +0000 Subject: [PATCH] Upgrading mchview with new features : - adding Status and StatusMap as possible sources (from OCDB) - adding one convenience computed dimension for the Gains (=1/a1/0.2 in mV/fC) - adding --de and --chamber options to start the display on a given part of the detector, instead of the global view of all the chambers - chamberId in the text label is now starting at 1, to avoid confusing (as anywhere else we're used to start at 1 when naming those chambers) Also fix a bug for the contour computation (AliMUONContourMaker), and reorganized it a bit (AliMUONContourHandler, AliMUONPainterHelper) --- MUON/AliMUONContourHandler.cxx | 340 +++++++++++++++++++++++++ MUON/AliMUONContourHandler.h | 61 +++++ MUON/AliMUONContourMaker.cxx | 9 +- MUON/AliMUONContourMakerTest.cxx | 276 +------------------- MUON/AliMUONContourMakerTest.h | 6 +- MUON/AliMUONDEPainter.cxx | 38 +++ MUON/AliMUONDEPainter.h | 4 + MUON/AliMUONManuPainter.cxx | 19 +- MUON/AliMUONMchViewApplication.cxx | 76 +++++- MUON/AliMUONMchViewApplication.h | 2 +- MUON/AliMUONPainterDataSourceFrame.cxx | 2 + MUON/AliMUONPainterHelper.cxx | 331 +++++++----------------- MUON/AliMUONPainterHelper.h | 43 +--- MUON/AliMUONTrackerACFDataMaker.cxx | 2 +- MUON/AliMUONTrackerOCDBDataMaker.cxx | 180 +++++++++---- MUON/AliMUONTrackerOCDBDataMaker.h | 6 +- MUON/AliMUONVPainter.h | 11 +- MUON/MUONgraphicsLinkDef.h | 1 + MUON/libMUONgraphics.pkg | 3 +- MUON/mchview.cxx | 28 +- 20 files changed, 816 insertions(+), 622 deletions(-) create mode 100644 MUON/AliMUONContourHandler.cxx create mode 100644 MUON/AliMUONContourHandler.h diff --git a/MUON/AliMUONContourHandler.cxx b/MUON/AliMUONContourHandler.cxx new file mode 100644 index 00000000000..16c14efa165 --- /dev/null +++ b/MUON/AliMUONContourHandler.cxx @@ -0,0 +1,340 @@ +/************************************************************************** +* 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$ + +/// +/// \class AliMUONContourHandler +/// +/// Class used to create contours of the muon tracker parts : +/// manu, bus patches, detection elements, chambers. +/// +/// \author Laurent Aphecetche, Subatech +/// + +#include "AliMUONContourHandler.h" + +#include "AliCodeTimer.h" +#include "AliLog.h" +#include "AliMUONContour.h" +#include "AliMUONContourMaker.h" +#include "AliMUONGeometryDetElement.h" +#include "AliMUONGeometryTransformer.h" +#include "AliMUONManuContourMaker.h" +#include "AliMUONPolygon.h" +#include "AliMUONSegment.h" +#include "AliMpArea.h" +#include "AliMpCDB.h" +#include "AliMpDDLStore.h" +#include "AliMpDEManager.h" +#include "AliMpExMap.h" +#include +#include "Riostream.h" +#include "TArrow.h" +#include "TCanvas.h" +#include "TFile.h" +#include "TGeoMatrix.h" +#include "TLine.h" +#include "TObjArray.h" +#include "TPolyLine.h" +#include "TSystem.h" + +///\cond CLASSIMP +ClassImp(AliMUONContourHandler) +///\endcond + +//_____________________________________________________________________________ +AliMUONContourHandler::AliMUONContourHandler(Bool_t explodedView) +: TObject(), +fTransformations(0x0), +fAllContourMap(0x0), +fAllContourArray(0x0) +{ + /// ctor. If explodedView=kTRUE, we generate views that will look + /// fine in 2D (i.e. won't show overlaps of DE as in reality) + /// Use kFALSE if you want realistic geometry, though. + /// + /// IMPORTANT : as we many MUON classes, this one cannot work + /// before you've loaded the mapping in memory (see e.g. AliMpCDB::LoadDDLStore) + /// + + fTransformations = GenerateTransformations(explodedView); + AliMUONManuContourMaker manuMaker(fTransformations); + TObjArray* manus = manuMaker.GenerateManuContours(kTRUE); + if (manus) + { + manus->SetOwner(kFALSE); + GenerateAllContours(*manus); + } + delete manus; +} + +//_____________________________________________________________________________ +AliMUONContourHandler::~AliMUONContourHandler() +{ + /// Dtor + delete fAllContourMap; + delete fAllContourArray; +} + +//______________________________________________________________________________ +Bool_t +AliMUONContourHandler::Adopt(AliMUONContour* contour) +{ + /// Adopt the given contour + if ( GetContour(contour->GetName()) ) + { + // contour already exists + return kFALSE; + } + fAllContourMap->Add(new TObjString(contour->GetName()),contour); + return kTRUE; +} + +//______________________________________________________________________________ +TObjArray* +AliMUONContourHandler::CreateContourList(const TObjArray& manuContours) +{ + /// Create an array of maps of contour names + /// + /// Assyming that key is something like station#/chamber#/de#/buspatch#/manu# + /// the idea here is to put one TMap for each level in mapArray : + /// + /// mapArray[0].key = station0 + /// mapArray[0].value = map of strings { station0/chamber0, station0/chamber1 } + /// + /// Then each entry in mapArray will be converted into a contour by + /// merging its children (e.g. station0 contour will be made from the merging + /// of station0/chamber0 and station0/chamber1 in the example above). + /// + + AliCodeTimerAuto(""); + + TIter next(&manuContours); + AliMUONContour* contour; + TObjArray* mapArray = new TObjArray; + + while ( ( contour = static_cast(next()) ) ) + { + // Key is something like station#/chamber#/de#/buspatch#/manu# + + TString key(contour->GetName()); + TObjArray* s = key.Tokenize("/"); + for ( Int_t i = 0; i < s->GetLast(); ++i ) + { + TMap* m = static_cast(mapArray->At(i)); + if (!m) + { + m = new TMap; + if ( i > mapArray->GetSize() ) mapArray->Expand(i); + mapArray->AddAt(m,i); + } + TString parent; + for ( Int_t k = 0; k <= i; ++k ) + { + TObjString* str = static_cast(s->At(k)); + parent += str->String(); + if ( k < i ) parent += "/"; + } + TString child(parent); + child += "/"; + child += static_cast(s->At(i+1))->String(); + + TObjArray* ma = static_cast(m->GetValue(parent.Data())); + if (!ma) + { + ma = new TObjArray; + m->Add(new TObjString(parent.Data()),ma); + } + TPair* p = static_cast(ma->FindObject(child.Data())); + if ( !p ) + { + ma->Add(new TObjString(child.Data())); + } + } + delete s; + } + + return mapArray; +} + +//______________________________________________________________________________ +void +AliMUONContourHandler::GenerateAllContours(const TObjArray& manuContours) +{ + /// From a map of manu contours, generate the compound contours (bp, de, etc...) + /// by merging them. + /// Note that manuContours should NOT be the owner of its contours, + /// as they are adopted by the array returned by this method. + + AliCodeTimerAuto(""); + + // Get the list of contours to create + TObjArray* mapArray = CreateContourList(manuContours); + + // Now loop over the mapArray to actually create the contours + TIter next2(mapArray,kIterBackward); + + fAllContourMap = new TMap(20000,1); + fAllContourMap->SetOwnerKeyValue(kTRUE,kTRUE); + + fAllContourArray = new TObjArray; + fAllContourArray->SetOwner(kFALSE); // the map is the real owner of the contours + + TIter nextContour(&manuContours); + AliMUONContour* contour(0x0); + + // start by adding the manu contours we begin with + while ( ( contour = static_cast(nextContour()) ) ) + { + fAllContourMap->Add(new TObjString(contour->GetName()),contour); + } + + AliMUONContourMaker maker; + + for ( Int_t i = mapArray->GetLast(); i >= 1; --i ) + // end at 1 to avoid merging different cathodes together, which + // would not work... + { + TMap* a = static_cast(mapArray->At(i)); + TIter next3(a); + TObjString* str; + while ( ( str = static_cast(next3()) ) ) + { + TObjArray* m = static_cast(a->GetValue(str->String().Data())); + TIter next4(m); + TObjString* k; + TObjArray subcontours; + subcontours.SetOwner(kFALSE); + while ( ( k = static_cast(next4()) ) ) + { + contour = static_cast(fAllContourMap->GetValue(k->String().Data())); + if ( contour ) + { + subcontours.Add(contour); + } + else + { + AliError(Form("Did not find contour %s",k->String().Data())) + continue; + } + } + + contour = maker.MergeContour(subcontours,str->String().Data()); + + bool error(kFALSE); + + if (!contour) + { + error=kTRUE; + AliError(Form("ERROR : could not merge into %s",str->String().Data())); + } + else + { + if ( contour->Area().IsValid() == kFALSE ) + { + error=kTRUE; + AliError(Form("ERROR : area of contour %s is invalid",str->String().Data())); + } + } + + if (!error) + { + fAllContourMap->Add(new TObjString(str->String().Data()),contour); + fAllContourArray->Add(contour); + } + } + } +} + +//_____________________________________________________________________________ +AliMpExMap* +AliMUONContourHandler::GenerateTransformations(Bool_t exploded) +{ + /// Generate geometric transformations to be used to compute the contours + /// If exploded=kFALSE then we generate real transformations, otherwise + /// we generate tweaked ones that look fine on screen. + + AliCodeTimerAuto(""); + + AliMUONGeometryTransformer transformer; + Bool_t ok = transformer.LoadGeometryData("transform.dat"); + // transformer.LoadGeometryData("geometry.root"); //FIXME: add a protection if geometry.root file does not exist + if (!ok) + { + cout << "ERROR : cannot get geometry !" << endl; + return 0x0; + } + AliMpExMap* transformations = new AliMpExMap; + AliMpDEIterator deIt; + deIt.First(); + while ( !deIt.IsDone() ) + { + Int_t detElemId = deIt.CurrentDEId(); + const AliMUONGeometryDetElement* de = transformer.GetDetElement(detElemId); + + TGeoHMatrix* matrix = static_cast(de->GetGlobalTransformation()->Clone()); + + if (exploded) + { + Double_t* translation = matrix->GetTranslation(); + Double_t xscale = 1.0; + Double_t yscale = 1.5; + Double_t shift = 5.0; // cm + + if ( AliMpDEManager::GetStationType(detElemId) == AliMp::kStation345 ) + { + translation[0] *= xscale; + translation[1] *= yscale; + } + else + { + Double_t xshift[] = { shift, -shift, -shift, shift }; + Double_t yshift[] = { shift, shift, -shift, -shift }; + Int_t ishift = detElemId % 100; + + translation[0] += xshift[ishift]; + translation[1] += yshift[ishift]; + } + matrix->SetTranslation(translation); + } + transformations->Add(detElemId,matrix); + deIt.Next(); + } + return transformations; +} + +//_____________________________________________________________________________ +AliMUONContour* +AliMUONContourHandler::GetContour(const char* contourname) const +{ + /// Get a given contour + return static_cast(fAllContourMap->GetValue(contourname)); +} + +//_____________________________________________________________________________ +void +AliMUONContourHandler::Print(Option_t* opt) const +{ + /// printout + + if ( fAllContourMap ) + { + cout << Form("Contour map : collisions = %5.3f size = %d capacity = %d", + fAllContourMap->AverageCollisions(), + fAllContourMap->GetSize(), + fAllContourMap->Capacity()) << endl; + } +} diff --git a/MUON/AliMUONContourHandler.h b/MUON/AliMUONContourHandler.h new file mode 100644 index 00000000000..d34dc76cd3f --- /dev/null +++ b/MUON/AliMUONContourHandler.h @@ -0,0 +1,61 @@ +#ifndef ALIMUONCONTOURHANDLER_H +#define ALIMUONCONTOURHANDLER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* See cxx source for full Copyright notice */ + +// $Id$ + +/// \ingroup graphics +/// \class AliMUONContourHandler +/// \brief Holder for MUON tracker contours +/// +/// \author Laurent Aphecetche + +#ifndef ROOT_TObject +# include "TObject.h" +#endif + +class TObjArray; +class AliMpExMap; +class TMap; +class AliMUONContour; + +class AliMUONContourHandler : public TObject +{ +public: + AliMUONContourHandler(Bool_t explodedView=kTRUE); + virtual ~AliMUONContourHandler(); + + Bool_t Adopt(AliMUONContour* contour); + + TMap* AllContourMap() const { return fAllContourMap; } + + TObjArray* AllContourArray() const { return fAllContourArray; } + + AliMUONContour* GetContour(const char* contourname) const; + + AliMpExMap* GetTransformations() const { return fTransformations; } + + void Print(Option_t* opt="") const; + +private: + + AliMUONContourHandler(const AliMUONContourHandler& rhs); + AliMUONContourHandler& operator=(const AliMUONContourHandler& rhs); + + AliMpExMap* GenerateTransformations(Bool_t exploded); + + TObjArray* CreateContourList(const TObjArray& manuContours); + + void GenerateAllContours(const TObjArray& manuContours); + +private: + AliMpExMap* fTransformations; //< transformations used to go from local to global coordinates + TMap* fAllContourMap; //< all (i.e. manus, buspatches, detection elements, etc..) contours + TObjArray* fAllContourArray; //< all contours, ordered by hierarchy level + + ClassDef(AliMUONContourHandler,1) // MUON tracker contour holder +}; + +#endif diff --git a/MUON/AliMUONContourMaker.cxx b/MUON/AliMUONContourMaker.cxx index f992d9b8431..30b5d5f1c33 100644 --- a/MUON/AliMUONContourMaker.cxx +++ b/MUON/AliMUONContourMaker.cxx @@ -42,6 +42,7 @@ #include "TArrayD.h" #include "TMath.h" #include +#include "TArrayI.h" /// \cond CLASSIMP ClassImp(AliMUONContourMaker) @@ -167,6 +168,9 @@ AliMUONContourMaker::FinalizeContour(const TObjArray& verticals, all.Add(verticals.UncheckedAt(i)); all.Add(horizontals.UncheckedAt(i)); } + + TArrayI alreadyAdded(all.GetLast()+1); + alreadyAdded.Reset(); Int_t i(0); @@ -186,6 +190,7 @@ AliMUONContourMaker::FinalizeContour(const TObjArray& verticals, AliMUONSegment* si = static_cast(all.UncheckedAt(i)); inorder.Add(si); + alreadyAdded[i] = 1; const AliMUONSegment* all0 = static_cast(all.First()); if ( i != 0 && AliMUONSegment::AreEqual(si->EndX(),all0->StartX()) && AliMUONSegment::AreEqual(si->EndY(),all0->StartY()) ) { @@ -211,13 +216,15 @@ AliMUONContourMaker::FinalizeContour(const TObjArray& verticals, { i = 0; inorder.Clear(); + alreadyAdded.Set(all.GetLast()+1); + alreadyAdded.Reset(); } continue; } for ( Int_t j = 0; j <= all.GetLast(); ++j) { - if ( j != i ) + if ( j != i && alreadyAdded[j] == 0 ) { const AliMUONSegment* sj = static_cast(all.UncheckedAt(j)); if ( AliMUONSegment::AreEqual(si->EndX(),sj->StartX()) && AliMUONSegment::AreEqual(si->EndY(),sj->StartY())) diff --git a/MUON/AliMUONContourMakerTest.cxx b/MUON/AliMUONContourMakerTest.cxx index 298e7b76fc3..d85d8864476 100644 --- a/MUON/AliMUONContourMakerTest.cxx +++ b/MUON/AliMUONContourMakerTest.cxx @@ -29,16 +29,11 @@ #include "AliCodeTimer.h" #include "AliLog.h" #include "AliMUONContour.h" -#include "AliMUONContourMaker.h" -#include "AliMUONGeometryDetElement.h" -#include "AliMUONGeometryTransformer.h" -#include "AliMUONManuContourMaker.h" #include "AliMUONPolygon.h" #include "AliMUONSegment.h" -#include "AliMpArea.h" +#include "AliMUONContourHandler.h" #include "AliMpCDB.h" #include "AliMpDDLStore.h" -#include "AliMpDEManager.h" #include "AliMpExMap.h" #include #include "Riostream.h" @@ -47,6 +42,7 @@ #include "TFile.h" #include "TGeoMatrix.h" #include "TLine.h" +#include "TMap.h" #include "TObjArray.h" #include "TPolyLine.h" #include "TSystem.h" @@ -102,73 +98,6 @@ AliMUONContourMakerTest::~AliMUONContourMakerTest() } -//______________________________________________________________________________ -TObjArray* -AliMUONContourMakerTest::CreateContourList(const TObjArray& manuContours) -{ - /// Create an array of maps of contour names - /// - /// Assyming that key is something like station#/chamber#/de#/buspatch#/manu# - /// the idea here is to put one TMap for each level in mapArray : - /// - /// mapArray[0].key = station0 - /// mapArray[0].value = map of strings { station0/chamber0, station0/chamber1 } - /// - /// Then each entry in mapArray will be converted into a contour by - /// merging its children (e.g. station0 contour will be made from the merging - /// of station0/chamber0 and station0/chamber1 in the example above). - /// - - AliCodeTimerAuto(""); - - TIter next(&manuContours); - AliMUONContour* contour; - TObjArray* mapArray = new TObjArray; - - while ( ( contour = static_cast(next()) ) ) - { - // Key is something like station#/chamber#/de#/buspatch#/manu# - - TString key(contour->GetName()); - TObjArray* s = key.Tokenize("/"); - for ( Int_t i = 0; i < s->GetLast(); ++i ) - { - TMap* m = static_cast(mapArray->At(i)); - if (!m) - { - m = new TMap; - if ( i > mapArray->GetSize() ) mapArray->Expand(i); - mapArray->AddAt(m,i); - } - TString parent; - for ( Int_t k = 0; k <= i; ++k ) - { - TObjString* str = static_cast(s->At(k)); - parent += str->String(); - if ( k < i ) parent += "/"; - } - TString child(parent); - child += "/"; - child += static_cast(s->At(i+1))->String(); - - TObjArray* ma = static_cast(m->GetValue(parent.Data())); - if (!ma) - { - ma = new TObjArray; - m->Add(new TObjString(parent.Data()),ma); - } - TPair* p = static_cast(ma->FindObject(child.Data())); - if ( !p ) - { - ma->Add(new TObjString(child.Data())); - } - } - delete s; - } - - return mapArray; -} - //_____________________________________________________________________________ void AliMUONContourMakerTest::Exec(const Option_t* opt) @@ -191,208 +120,25 @@ AliMUONContourMakerTest::Exec(const Option_t* opt) AliCodeTimer::Instance()->Reset(); AliCodeTimerAuto(""); - - AliMpExMap* real(0x0); - AliMpExMap* exploded(0x0); - - GenerateTransformations(real,exploded); - - TObjArray* manus(0x0); - TObjArray* all(0x0); - - TString sopt(opt); - - if ( sopt.Contains("MANU") || sopt.Contains("ALL") ) - { - AliMUONManuContourMaker manuMaker(exploded); - manus = manuMaker.GenerateManuContours(kTRUE); - } - - if ( sopt.Contains("ALL") && manus ) - { - manus->SetOwner(kFALSE); - all = GenerateAllContours(*manus); - if ( sopt.Contains("SAVE") && all ) - { - TFile f("AliMUONContourMakerTest.all.root","RECREATE"); - all->Write("ALL",TObject::kSingleKey); - f.Close(); - } - - } - - AliCodeTimer::Instance()->Print(); - - delete manus; - delete all; -} -//______________________________________________________________________________ -TObjArray* -AliMUONContourMakerTest::GenerateAllContours(const TObjArray& manuContours) -{ - /// From a map of manu contours, generate the compound contours (bp, de, etc...) - /// by merging them. - /// Note that manuContours should NOT be the owner of its contours, - /// as they are adopted by the array returned by this method. + TString sopt(opt); - AliCodeTimerAuto(""); + Bool_t explodedView(kTRUE); - // Get the list of contours to create - TObjArray* mapArray = CreateContourList(manuContours); + if (sopt.Contains("REAL")) explodedView = kFALSE; - // Now loop over the mapArray to actually create the contours - TIter next2(mapArray,kIterBackward); - - TMap allContourMap; - allContourMap.SetOwnerKeyValue(kTRUE,kFALSE); // not owner of contours, as the returned array will be the owner - TObjArray* allContourArray = new TObjArray; - allContourArray->SetOwner(kTRUE); - - TIter nextContour(&manuContours); - AliMUONContour* contour(0x0); + AliMUONContourHandler ch(explodedView); - while ( ( contour = static_cast(nextContour()) ) ) + if ( sopt.Contains("SAVE") ) { - allContourMap.Add(new TObjString(contour->GetName()),contour); - allContourArray->Add(contour); + TFile f2("AliMUONContourMakerTest.manuContours.root","RECREATE"); + ch.AllContourMap()->Write("ALL",TObject::kSingleKey); + f2.Close(); } - - AliMUONContourMaker maker; - - for ( Int_t i = mapArray->GetLast(); i >= 1; --i ) - // end at 1 to avoid merging different cathodes together, which - // would not work... - { - TMap* a = static_cast(mapArray->At(i)); - TIter next3(a); - TObjString* str; - while ( ( str = static_cast(next3()) ) ) - { - TObjArray* m = static_cast(a->GetValue(str->String().Data())); - TIter next4(m); - TObjString* k; - TObjArray subcontours; - subcontours.SetOwner(kFALSE); - while ( ( k = static_cast(next4()) ) ) - { - contour = static_cast(allContourMap.GetValue(k->String().Data())); - if ( contour ) - { - subcontours.Add(contour); - } - else - { - AliError(Form("Did not find contour %s",k->String().Data())) - return allContourArray; - } - } - contour = maker.MergeContour(subcontours,str->String().Data()); - - bool error(kFALSE); - - if (!contour) - { - error=kTRUE; - AliError(Form("ERROR : could not merge into %s",str->String().Data())); - } - else - { - if ( contour->Area().IsValid() == kFALSE ) - { - error=kTRUE; - AliError(Form("ERROR : area of contour %s is invalid",str->String().Data())); - } - } - - if ( error ) - { - // do it again, but get intermediate results to plot them - PrintAsPNG(str->String().Data(),subcontours); - if (contour ) - { - StdoutToAliError(contour->Area().Print("B");); - } - AliError(Form("%d subcontours",subcontours.GetLast()+1)); - StdoutToAliError(subcontours.Print();); - // check whether one of the subcontour itself is already invalid ? - TIter next(&subcontours); - AliMUONContour* cont; - while ( ( cont = static_cast(next()) ) ) - { - if (!cont->IsValid()) - { - AliError(Form("subcontour %s is invalid",cont->GetName())); - } - } - TFile f("subcontour.root","recreate"); - subcontours.Write("fault",TObject::kSingleKey); - f.Close(); - - return allContourArray; - } - - allContourArray->Add(contour); - allContourMap.Add(new TObjString(str->String().Data()),contour); - } - } - - return allContourArray; + AliCodeTimer::Instance()->Print(); } -//_____________________________________________________________________________ -void -AliMUONContourMakerTest::GenerateTransformations(AliMpExMap*& real, AliMpExMap*& exploded) -{ - /// Generate geometric transformations to be used to compute the contours - /// (real are, as the name implies, real ones, while the other ones are - /// a bit tweaked to look fine on screen). - - AliCodeTimerAuto(""); - - AliMUONGeometryTransformer transformer; - Bool_t ok = transformer.LoadGeometryData("transform.dat"); - // transformer.LoadGeometryData("geometry.root"); //FIXME: add a protection if geometry.root file does not exist - if (!ok) - { - cout << "ERROR : cannot get geometry !" << endl; - return; - } - real = new AliMpExMap; - exploded = new AliMpExMap; - AliMpDEIterator deIt; - deIt.First(); - while ( !deIt.IsDone() ) - { - Int_t detElemId = deIt.CurrentDEId(); - const AliMUONGeometryDetElement* de = transformer.GetDetElement(detElemId); - - real->Add(detElemId,de->GetGlobalTransformation()->Clone()); - - TGeoHMatrix* matrix = static_cast(de->GetGlobalTransformation()->Clone()); - Double_t* translation = matrix->GetTranslation(); - - if ( AliMpDEManager::GetStationType(detElemId) == AliMp::kStation345 ) - { - translation[0] *= 1.0; - translation[1] *= 1.5; - } - else - { - Double_t shift = 5; // cm - Double_t xshift[] = { shift, -shift, -shift, shift }; - Double_t yshift[] = { shift, shift, -shift, -shift }; - Int_t ishift = detElemId % 100; - - translation[0] += xshift[ishift]; - translation[1] += yshift[ishift]; - } - matrix->SetTranslation(translation); - exploded->Add(detElemId,matrix); - deIt.Next(); - } -} //_____________________________________________________________________________ void diff --git a/MUON/AliMUONContourMakerTest.h b/MUON/AliMUONContourMakerTest.h index f11e875d99f..f02a7b514d4 100644 --- a/MUON/AliMUONContourMakerTest.h +++ b/MUON/AliMUONContourMakerTest.h @@ -50,11 +50,7 @@ public: private: - TObjArray* CreateContourList(const TObjArray& manuContours); - - TObjArray* GenerateAllContours(const TObjArray& manuContours); - - void GenerateTransformations(AliMpExMap*& real, AliMpExMap*& exploded); + TString NameIt(const AliMpMotifPosition& motifPosition) const; ClassDef(AliMUONContourMakerTest,1) // Test of AliMUONContourMaker }; diff --git a/MUON/AliMUONDEPainter.cxx b/MUON/AliMUONDEPainter.cxx index b2e69be8a56..c79b7d6bb15 100644 --- a/MUON/AliMUONDEPainter.cxx +++ b/MUON/AliMUONDEPainter.cxx @@ -32,7 +32,9 @@ #include "AliMpSector.h" #include "AliMpSlat.h" #include "AliLog.h" +#include #include +#include "AliMUONPainterGroup.h" /// \class AliMUONDEPainter /// @@ -336,3 +338,39 @@ AliMUONDEPainter::Validate(const AliMUONAttPainter& attributes) const return norm; } +//_____________________________________________________________________________ +void +AliMUONDEPainter::SetResponder(Int_t depth) +{ + /// Select as responder the *first* group that has a given depth + + AliDebug(1,Form("depth=%d",depth)); + + if (!fPainterGroups) + { + CreateGroups(); + } + + TIter next(fPainterGroups); + TObjString* str; + + fResponderGroup = 0x0; + + while ( ( str = static_cast(next()) ) ) + { + AliMUONPainterGroup* group = static_cast(fPainterGroups->GetValue(str)); + if ( str->String() == "BUSPATCH" ) + { + AliDebug(1,Form("group %s is indeed buspatch, using as responder", + group->Type(),depth)); + group->SetResponder(kTRUE); + fResponderGroup = group; + break; + } + else + { + group->SetResponder(kFALSE); + } + } +} + diff --git a/MUON/AliMUONDEPainter.h b/MUON/AliMUONDEPainter.h index 68391a7bd88..c911956c75c 100644 --- a/MUON/AliMUONDEPainter.h +++ b/MUON/AliMUONDEPainter.h @@ -51,6 +51,10 @@ public: virtual Bool_t IsIncluded() const; + using AliMUONVPainter::SetResponder; + + virtual void SetResponder(Int_t depth); + private: Int_t fDetElemId; ///< our id diff --git a/MUON/AliMUONManuPainter.cxx b/MUON/AliMUONManuPainter.cxx index c98aece1e0b..503d5262991 100644 --- a/MUON/AliMUONManuPainter.cxx +++ b/MUON/AliMUONManuPainter.cxx @@ -18,8 +18,10 @@ #include "AliMUONManuPainter.h" -#include "AliMUONManuPadPainter.h" +#include "AliLog.h" #include "AliMUONContour.h" +#include "AliMUONManuContourMaker.h" +#include "AliMUONManuPadPainter.h" #include "AliMUONPainterHelper.h" #include "AliMUONVCalibParam.h" #include "AliMUONVDigit.h" @@ -32,7 +34,6 @@ #include "AliMpStationType.h" #include "AliMpVMotif.h" #include "AliMpVPadIterator.h" -#include "AliLog.h" #include #include @@ -93,19 +94,13 @@ AliMUONManuPainter::AliMUONManuPainter(const AliMUONAttPainter& att, return; } - AliMUONContour* contour = h->GetContour(ContourName()); - - if (!contour) - { - contour = h->GenerateManuContour(fDetElemId, - fManuId, - Attributes(), - ContourName()); - } + TString name = AliMUONManuContourMaker::ManuPathName(detElemId, manuId); + AliMUONContour* contour = h->GetContour(name.Data()); + if (!contour) { - AliFatal(Form("Could not get manuId %04d from DE %04d",manuId,detElemId)); + AliError(Form("Could not get manuId %04d from DE %04d (name=%s)",manuId,detElemId,name.Data())); } SetContour(contour); diff --git a/MUON/AliMUONMchViewApplication.cxx b/MUON/AliMUONMchViewApplication.cxx index 08f5be3e4d3..e7678a091f4 100644 --- a/MUON/AliMUONMchViewApplication.cxx +++ b/MUON/AliMUONMchViewApplication.cxx @@ -20,6 +20,8 @@ #include "AliCDBManager.h" #include "AliCodeTimer.h" #include "AliLog.h" +#include "AliMUONChamberPainter.h" +#include "AliMUONDEPainter.h" #include "AliMUONPainterDataRegistry.h" #include "AliMUONPainterDataSourceFrame.h" #include "AliMUONPainterEnv.h" @@ -89,7 +91,9 @@ AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name, } fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h); - + + AliMUONPainterHelper::Instance()->GenerateDefaultMatrices(); + CreateMenuBar(w); const Int_t kbs = 2; @@ -133,7 +137,64 @@ AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name, cout << " Welcome to mchview" << endl; cout << " " << FullVersion() << endl; cout << "***************************************************" << endl; + + // Trying to see if we're requested to draw something specific instead + // of the global view of all the chambers + + AliMUONVPainter* painter(0x0); + TObjArray args; + args.SetOwner(kTRUE); + + for ( int i = 1; i < argc[0]; ++i ) + { + args.Add(new TObjString(argv[i])); + } + + for ( Int_t i = 0; i <= args.GetLast(); ++i ) + { + TString a(static_cast(args.At(i))->String()); + AliMUONAttPainter att; + + att.SetPlane(kTRUE,kFALSE); + att.SetCathode(kFALSE,kFALSE); + att.SetViewPoint(kTRUE,kFALSE); + + if ( a == "--de" ) + { + Int_t detElemId = static_cast(args.At(i+1))->String().Atoi(); + + painter = new AliMUONDEPainter(att,detElemId); + + painter->SetOutlined("*",kFALSE); + painter->SetOutlined("BUSPATCH",kTRUE); + + painter->SetLine(1,4,3); + ++i; + } + + if ( a == "--chamber" ) + { + Int_t chamberId = static_cast(args.At(i+1))->String().Atoi(); + + painter = new AliMUONChamberPainter(att,chamberId-1); + + painter->SetOutlined("*",kFALSE); + painter->SetOutlined("DE",kTRUE); + + painter->SetLine(1,4,3); + ++i; + } + + } + + if ( painter ) + { + fPainterMasterFrame->ShiftClicked(painter,0x0); + + fPainterMasterFrame->Update(); + } + } //______________________________________________________________________________ @@ -353,6 +414,19 @@ AliMUONMchViewApplication::ReleaseNotes() TGTextView* rn = new TGTextView(t); + rn->AddLine("1.00"); + rn->AddLine(""); + rn->AddLine("Added the Status and StatusMap as a possible OCDB data source"); + rn->AddLine(""); + rn->AddLine("Added one (computed) dimension to the Gains data source = 1/a1/0.2 (mV/fC)"); + rn->AddLine(""); + + + rn->AddLine("0.99a"); + rn->AddLine(""); + rn->AddLine("Added the --de and --chamber options"); + rn->AddLine(""); + rn->AddLine("0.99"); rn->AddLine(""); rn->AddLine("The chamberid in the label (top right of panel) is now starting at 1 as in common usage"); diff --git a/MUON/AliMUONMchViewApplication.h b/MUON/AliMUONMchViewApplication.h index 5892cfc9ca6..937653971f1 100644 --- a/MUON/AliMUONMchViewApplication.h +++ b/MUON/AliMUONMchViewApplication.h @@ -30,7 +30,7 @@ public: void HandleMenu(Int_t i); /// Return the version number of the mchview application - static const char* Version() { return "0.98"; } + static const char* Version() { return "1.00"; } /// Return the SVN revision and version number of the mchview application static const char* FullVersion() { return Form("mchview Version %s ($Id$)",Version()); } diff --git a/MUON/AliMUONPainterDataSourceFrame.cxx b/MUON/AliMUONPainterDataSourceFrame.cxx index d8864d7b52f..e5e306d7dc4 100644 --- a/MUON/AliMUONPainterDataSourceFrame.cxx +++ b/MUON/AliMUONPainterDataSourceFrame.cxx @@ -179,6 +179,8 @@ AliMUONPainterDataSourceFrame::AliMUONPainterDataSourceFrame(const TGWindow* p, fOCDBTypes->AddEntry("Capacitances",2); fOCDBTypes->AddEntry("HV",3); fOCDBTypes->AddEntry("Occupancy",4); + fOCDBTypes->AddEntry("StatusMap",5); + fOCDBTypes->AddEntry("Status",6); fOCDBTypes->Select(0); fOCDBTypes->Resize(100,20); diff --git a/MUON/AliMUONPainterHelper.cxx b/MUON/AliMUONPainterHelper.cxx index 3b9e6d43255..eeb6131987f 100644 --- a/MUON/AliMUONPainterHelper.cxx +++ b/MUON/AliMUONPainterHelper.cxx @@ -21,6 +21,7 @@ #include "AliCodeTimer.h" #include "AliLog.h" #include "AliMUONContour.h" +#include "AliMUONContourHandler.h" #include "AliMUONContourMaker.h" #include "AliMUONGeometryDetElement.h" #include "AliMUONGeometryTransformer.h" @@ -28,6 +29,7 @@ #include "AliMUONPainterEnv.h" #include "AliMUONPainterMatrix.h" #include "AliMUONPainterRegistry.h" +#include "AliMUONPadStatusMaker.h" #include "AliMUONVCalibParam.h" #include "AliMUONVDigit.h" #include "AliMUONVTrackerData.h" @@ -84,48 +86,55 @@ AliMUONPainterHelper* AliMUONPainterHelper::fgInstance(0x0); //_____________________________________________________________________________ AliMUONPainterHelper::AliMUONPainterHelper() : TObject(), -fExplodedGlobalTransformations(0x0), -fRealGlobalTransformations(0x0), fPainterMatrices(0x0), fEnv(0x0), -fAllContours(20000,1) +fReal(0x0), +fExploded(0x0) { - /// ctor + /// ctor - fAllContours.SetOwnerKeyValue(kTRUE,kTRUE); + if ( ! AliMpCDB::LoadMpSegmentation() ) + { + AliFatal("Could not access mapping from OCDB !"); + } - fExplodeFactor[0] = 1.00; - fExplodeFactor[1] = 1.50; - - if ( ! AliMpCDB::LoadMpSegmentation() ) - { - AliFatal("Could not access mapping from OCDB !"); - } - - // Load DDL store - if ( ! AliMpCDB::LoadDDLStore() ) - { - AliFatal("Could not access DDL Store from OCDB !"); - } + // Load DDL store + if ( ! AliMpCDB::LoadDDLStore() ) + { + AliFatal("Could not access DDL Store from OCDB !"); + } + + fExploded = new AliMUONContourHandler(kTRUE); } //_____________________________________________________________________________ AliMUONPainterHelper::~AliMUONPainterHelper() { /// dtor - delete fExplodedGlobalTransformations; - delete fRealGlobalTransformations; delete fPainterMatrices; + delete fReal; + delete fExploded; fEnv->Save(); fgInstance = 0; } //_____________________________________________________________________________ AliMUONContour* -AliMUONPainterHelper::GetContour(const char* contourName) const +AliMUONPainterHelper::GetContour(const char* contourName, Bool_t explodedView) const { /// Get a contour by name - return static_cast(fAllContours.GetValue(contourName)); + if (explodedView) + { + return fExploded->GetContour(contourName); + } + else + { + if ( fReal ) + { + return fReal->GetContour(contourName); + } + } + return 0x0; } //_____________________________________________________________________________ @@ -144,22 +153,10 @@ AliMUONPainterHelper::GenerateDefaultMatrices() AliMUONAttPainter att; att.SetViewPoint(kTRUE,kFALSE); - att.SetPlane(kFALSE,kFALSE); - att.SetCathode(kTRUE,kFALSE); - att.SetCathode(kFALSE,kFALSE); att.SetPlane(kTRUE,kFALSE); 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; @@ -189,88 +186,6 @@ AliMUONPainterHelper::GenerateDefaultMatrices() } } -//_____________________________________________________________________________ -void -AliMUONPainterHelper::GenerateGeometry() -{ - /// Generate the geometry (FIXME: using transform.dat for the moment) - /// The geometry is not the "normal" one as we "explode" it to avoid - /// having overlapping detection elements as in the reality, which - /// would be inconvenient for a display ;-) - - AliCodeTimerAuto(""); - - AliMUONGeometryTransformer transformer; - transformer.LoadGeometryData("transform.dat"); - fExplodedGlobalTransformations = new AliMpExMap; - fRealGlobalTransformations = new AliMpExMap; - AliMpDEIterator deIt; - deIt.First(); - while ( !deIt.IsDone() ) - { - Int_t detElemId = deIt.CurrentDEId(); - const AliMUONGeometryDetElement* de = transformer.GetDetElement(detElemId); - - fRealGlobalTransformations->Add(detElemId,de->GetGlobalTransformation()->Clone()); - - TGeoHMatrix* matrix = static_cast(de->GetGlobalTransformation()->Clone()); - Double_t* translation = matrix->GetTranslation(); - - AliDebug(1,Form("Initial translation for DE %04d is %7.3f, %7.3f", - detElemId,translation[0],translation[1])); - - if ( AliMpDEManager::GetStationType(detElemId) == AliMp::kStation345 ) - { - translation[0] *= fExplodeFactor[0]; - translation[1] *= fExplodeFactor[1]; - } - else - { - Double_t shift = 5; // cm - Double_t xshift[] = { shift, -shift, -shift, shift }; - Double_t yshift[] = { shift, shift, -shift, -shift }; - Int_t ishift = detElemId % 100; - - translation[0] += xshift[ishift]; - translation[1] += yshift[ishift]; - } - matrix->SetTranslation(translation); - fExplodedGlobalTransformations->Add(detElemId,matrix); - deIt.Next(); - } -} - -//_____________________________________________________________________________ -AliMUONContour* -AliMUONPainterHelper::GenerateManuContour(Int_t detElemId, - Int_t manuId, - AliMUONAttPainter viewType, - const char* contourName) -{ - /// Generate the contour of the list of pads - - static AliMUONManuContourMaker maker(fExplodedGlobalTransformations); - - if ( viewType.IsBackView() ) - { - AliError("Backview not implemented yet (and will probably never be, after all...)"); - return 0x0; - } - - AliMUONContour* contour = maker.CreateManuContour(detElemId,manuId,contourName); - - if ( !contour ) return 0x0; - - AliMUONContour* pContour = new AliMUONContour(*contour); - - if (pContour) - { - RegisterContour(pContour); - } - - return pContour; -} - //_____________________________________________________________________________ AliMp::CathodType AliMUONPainterHelper::GetCathodeType(Int_t detElemId, Int_t manuId) const @@ -291,32 +206,14 @@ AliMpMotifPosition* AliMUONPainterHelper::GetMotifPosition(Int_t detElemId, Int_t manuId) const { /// Get a given motif position - AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); - if ( stationType == AliMp::kStation345 ) - { - AliMp::PlaneType planeType(AliMp::kBendingPlane); - if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) - { - planeType = AliMp::kNonBendingPlane; - } - const AliMpSlat* slat = GetSlat(detElemId,planeType); - return slat->FindMotifPosition(manuId); - } - else if ( stationType != AliMp::kStationTrigger ) + const AliMpVSegmentation* vseg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); + if (vseg) { - AliMp::PlaneType planeType(AliMp::kBendingPlane); - if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) - { - planeType = AliMp::kNonBendingPlane; - } - const AliMpSector* sector = GetSector(detElemId,planeType); - return sector->GetMotifMap()->FindMotifPosition(manuId); + return vseg->MotifPosition(manuId); } - AliFatalClass("Not supposed to work with trigger"); return 0x0; } - //_____________________________________________________________________________ AliMpPCB* AliMUONPainterHelper::GetPCB(Int_t detElemId, AliMp::CathodType cathodeType, @@ -410,8 +307,6 @@ AliMUONPainterHelper::Instance() AliCodeTimerAutoClass(""); fgInstance = new AliMUONPainterHelper; - fgInstance->GenerateGeometry(); - fgInstance->GenerateDefaultMatrices(); fgInstance->fEnv = new AliMUONPainterEnv; return fgInstance; } @@ -424,24 +319,7 @@ AliMUONPainterHelper::Global2Local(Int_t detElemId, { /// Local to global transformation of coordinates - TGeoHMatrix* matrix = static_cast(fExplodedGlobalTransformations->GetValue(detElemId)); - Double_t pg[3] = { xg, yg, zg }; - Double_t pl[3] = { 0., 0., 0. }; - matrix->MasterToLocal(pg, pl); - xl = pl[0]; - yl = pl[1]; - zl = pl[2]; -} - -//_____________________________________________________________________________ -void -AliMUONPainterHelper::Global2LocalReal(Int_t detElemId, - Double_t xg, Double_t yg, Double_t zg, - Double_t& xl, Double_t& yl, Double_t& zl) const -{ - /// Local to global transformation of coordinates - - TGeoHMatrix* matrix = static_cast(fRealGlobalTransformations->GetValue(detElemId)); + TGeoHMatrix* matrix = static_cast(fExploded->GetTransformations()->GetValue(detElemId)); Double_t pg[3] = { xg, yg, zg }; Double_t pl[3] = { 0., 0., 0. }; matrix->MasterToLocal(pg, pl); @@ -458,24 +336,7 @@ AliMUONPainterHelper::Local2Global(Int_t detElemId, { /// Local to (exploded) global transformation of coordinates - TGeoHMatrix* matrix = static_cast(fExplodedGlobalTransformations->GetValue(detElemId)); - Double_t pl[3] = { xl, yl, zl }; - Double_t pg[3] = { 0., 0., 0. }; - matrix->LocalToMaster(pl, pg); - xg = pg[0]; - yg = pg[1]; - zg = pg[2]; -} - -//_____________________________________________________________________________ -void -AliMUONPainterHelper::Local2GlobalReal(Int_t detElemId, - Double_t xl, Double_t yl, Double_t zl, - Double_t& xg, Double_t& yg, Double_t& zg) const -{ - /// Local to (real) global transformation of coordinates - - TGeoHMatrix* matrix = static_cast(fRealGlobalTransformations->GetValue(detElemId)); + TGeoHMatrix* matrix = static_cast(fExploded->GetTransformations()->GetValue(detElemId)); Double_t pl[3] = { xl, yl, zl }; Double_t pg[3] = { 0., 0., 0. }; matrix->LocalToMaster(pl, pg); @@ -506,8 +367,7 @@ AliMUONPainterHelper::ColorFromValue(Double_t value, Double_t min, Double_t max) //_____________________________________________________________________________ AliMUONContour* -AliMUONPainterHelper::MergeContours(const TObjArray& contours, - const char* contourName) +AliMUONPainterHelper::MergeContours(const TObjArray& contours, const char* contourName, Bool_t explodedGeometry) { /// Merge a set of contours (delegating to the contour maker) @@ -517,7 +377,7 @@ AliMUONPainterHelper::MergeContours(const TObjArray& contours, if (contour) { - RegisterContour(contour); + RegisterContour(contour,explodedGeometry); } return contour; } @@ -533,19 +393,11 @@ AliMUONPainterHelper::Print(Option_t* opt) const if ( sopt.Length() == 0 ) { - cout << Form("ExplodeFactor=%e,%e",fExplodeFactor[0],fExplodeFactor[1]) << endl; - cout << endl; - cout << Form("GlobalTransformations=%x",fExplodedGlobalTransformations); - if ( fExplodedGlobalTransformations ) cout << Form(" with %d transformations",fExplodedGlobalTransformations->GetSize()); - cout << endl; - cout << Form("Contour map : collisions = %5.3f size = %d capacity = %d", - fAllContours.AverageCollisions(), - fAllContours.GetSize(), - fAllContours.Capacity()) << endl; - cout << endl; + if ( fExploded ) fExploded->Print(); + if ( fReal ) fReal->Print(); } - if ( sopt.Contains("MATRI") || sopt.Contains("FULL") ) + if ( fPainterMatrices && ( sopt.Contains("MATRI") || sopt.Contains("FULL") ) ) { fPainterMatrices->Print(opt); } @@ -553,67 +405,29 @@ AliMUONPainterHelper::Print(Option_t* opt) const //_____________________________________________________________________________ void -AliMUONPainterHelper::RegisterContour(AliMUONContour* contour) +AliMUONPainterHelper::RegisterContour(AliMUONContour* contour, Bool_t explodedView) { /// contour is adopted by contourMaker AliCodeTimerAuto("") AliDebug(1,contour->GetName()); - if ( fAllContours.GetValue(contour->GetName()) ) + AliMUONContourHandler* ch = fReal; + if ( explodedView ) { - AliError(Form("Contour with name %s is already there",contour->GetName())); -// Print("CONTOUR"); - return; + ch = fExploded; + } + if (!ch) + { + AliError(Form("ContourHandler for %s view is not created yet !",explodedView ? "EXPLODED" : "REAL")); + } + else + { + if ( ch->GetContour(contour->GetName()) ) + { + AliError(Form("Contour with name %s is already there",contour->GetName())); + return; + } + ch->Adopt(contour); } - fAllContours.Add(new TObjString(contour->GetName()),contour); -} - -//_____________________________________________________________________________ -AliMpPad -AliMUONPainterHelper::PadByExplodedPosition(Int_t detElemId, Int_t manuId, - Double_t x, Double_t y) const -{ - /// Find a pad by exploded position. FIXME: not really used nor tested ! - - Double_t xr, yr, zr; - -// Local2Global(detElemId,0.0,0.0,0.0,dummy,dummy,z); // to find z - - AliDebug(1,Form("DE %04d ManuID %04d x %7.3f y %7.3f",detElemId,manuId,x,y)); - - Exploded2Real(detElemId,x,y,0,xr,yr,zr); - - AliDebug(1,Form("xr %7.3f yr %7.3f zr %7.3f",xr,yr,zr)); - - Double_t xl,yl,zl; - - Global2LocalReal(detElemId,xr,yr,zr,xl,yl,zl); - - AliDebug(1,Form("xl %7.3f yl %7.3f zl %7.3f",xl,yl,zl)); - - const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); - - AliDebug(1,Form("dx,dy=%7.3f,%7.3f",seg->GetDimensionX(),seg->GetDimensionY())); - - return seg->PadByPosition(xl,yl); -} - -//_____________________________________________________________________________ -void -AliMUONPainterHelper::Exploded2Real(Int_t detElemId, - Double_t xe, Double_t ye, Double_t ze, - Double_t& xr, Double_t& yr, Double_t& zr) const -{ - /// Convert exploded coordinates into real ones. FIXME: not really used nor tested ! - - // first go back to local - - Double_t xl,yl,zl; - - Global2Local(detElemId,xe,ye,ze,xl,yl,zl); - - // and then back to global but not exploded - - Local2GlobalReal(detElemId,xl,yl,zl,xr,yr,zr); } //_____________________________________________________________________________ @@ -727,6 +541,33 @@ AliMUONPainterHelper::FormatValue(const char* name, Double_t value) const /// Format a double value to be displayed /// FIXME: should insure we have the right number of significant digits here... - return Form("%s = %e",name,value); + TString sname(name); + + sname.ToUpper(); + if (sname.Contains("BIT")) + { + Int_t i = (Int_t)(value); + TString rv = Form("%s = 0x%x",name,i); + cout << rv << ":" << AliMUONPadStatusMaker::AsString(i) << endl; + return rv; + } + else + { + return Form("%s = %e",name,value); + } +} + +//_____________________________________________________________________________ +TObjArray* +AliMUONPainterHelper::GetAllContoursAsArray(Bool_t explodedView) const +{ + /// Get the contours in a specially arranged array (orderer by hierarchy level) + + if ( explodedView ) return fExploded->AllContourArray(); // fExploded should always be created + + if (!fReal) fReal = new AliMUONContourHandler(kFALSE); // fReal might be first asked here. + + return fReal->AllContourArray(); } + diff --git a/MUON/AliMUONPainterHelper.h b/MUON/AliMUONPainterHelper.h index 4b1d0173b0d..ad1b637d77b 100644 --- a/MUON/AliMUONPainterHelper.h +++ b/MUON/AliMUONPainterHelper.h @@ -40,12 +40,9 @@ # include "AliMpPad.h" #endif -#ifndef ROOT_TMap -# include "TMap.h" -#endif - class AliMUONAttPainter; class AliMUONContour; +class AliMUONContourHandler; class AliMUONPainterEnv; class AliMUONVCalibParam; class AliMUONVTrackerData; @@ -56,7 +53,6 @@ class AliMpSector; class AliMpSlat; class TArrayI; class TList; -class TMap; class TObjArray; class AliMUONPainterHelper : public TObject @@ -83,11 +79,7 @@ public: AliMp::CathodType GetCathodeType(Int_t detElemId, Int_t manuId) const; - AliMUONContour* GenerateManuContour(Int_t detElemId, Int_t manuId, - AliMUONAttPainter viewType, - const char* contourName); - - AliMUONContour* GetContour(const char* contourName) const; + AliMUONContour* GetContour(const char* contourName, Bool_t explodedGeometry=kTRUE) const; /// Return a contour by name AliMUONContour* GetContour(const TString& contourName) const { return GetContour(contourName.Data()); } @@ -112,35 +104,27 @@ public: static AliMUONPainterHelper* Instance(); - AliMpPad PadByExplodedPosition(Int_t detElemId, Int_t manuId, Double_t x, Double_t y) const; - - void Exploded2Real(Int_t detElemId, Double_t xe, Double_t ye, Double_t ze, - Double_t& xr, Double_t& yr, Double_t& zr) const; - void Local2Global(Int_t detElemId, Double_t xl, Double_t yl, Double_t zl, Double_t& xg, Double_t& yg, Double_t& zg) const; - void Local2GlobalReal(Int_t detElemId, Double_t xl, Double_t yl, Double_t zl, - Double_t& xg, Double_t& yg, Double_t& zg) const; - void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, Double_t& xl, Double_t& yl, Double_t& zl) const; - void Global2LocalReal(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, - Double_t& xl, Double_t& yl, Double_t& zl) const; - - AliMUONContour* MergeContours(const TObjArray& contours, - const char* contourName); + AliMUONContour* MergeContours(const TObjArray& contours, const char* contourName, Bool_t explodedGeometry=kTRUE); virtual void Print(Option_t* opt="") const; - void RegisterContour(AliMUONContour* contour); + void RegisterContour(AliMUONContour* contour, Bool_t explodedView=kTRUE); TString FormatValue(const char* name, Double_t value) const; /// Return the environment AliMUONPainterEnv* Env() { return fEnv; } + TObjArray* GetAllContoursAsArray(Bool_t explodedView=kTRUE) const; + + void GenerateDefaultMatrices(); + private: /// Not implemented @@ -148,20 +132,15 @@ private: /// Not implemented AliMUONPainterHelper& operator=(const AliMUONPainterHelper&); - void GenerateDefaultMatrices(); - void GenerateGeometry(); - private: static AliMUONPainterHelper* fgInstance; ///< global instance - Double_t fExplodeFactor[2]; ///< explosing factors for representation - AliMpExMap* fExplodedGlobalTransformations; ///< global geometric transformations (exploded) - AliMpExMap* fRealGlobalTransformations; ///< global geometric transformations (real) TObjArray* fPainterMatrices; ///< default matrices AliMUONPainterEnv* fEnv; ///< resources - TMap fAllContours; ///< all contours + mutable AliMUONContourHandler* fReal; ///< contours in real coordinates + AliMUONContourHandler* fExploded; ///< contours in exploded coordinates - ClassDef(AliMUONPainterHelper,2) // Helper class for painters + ClassDef(AliMUONPainterHelper,3) // Helper class for painters }; #endif diff --git a/MUON/AliMUONTrackerACFDataMaker.cxx b/MUON/AliMUONTrackerACFDataMaker.cxx index f94e07bee1b..cf349fd27b9 100644 --- a/MUON/AliMUONTrackerACFDataMaker.cxx +++ b/MUON/AliMUONTrackerACFDataMaker.cxx @@ -68,7 +68,7 @@ AliMUONTrackerACFDataMaker::AliMUONTrackerACFDataMaker(const char* acfPath, AliMUONVStore* gains = new AliMUON2DMap(kTRUE); TString comment; AliMUONTrackerIO::ReadGains(filename.Data(),*gains,comment); - store = AliMUONTrackerOCDBDataMaker::SplitQuality(*gains); + store = AliMUONTrackerOCDBDataMaker::PatchGainStore(*gains); delete gains; } else if ( stype == "CAPACITANCES" ) diff --git a/MUON/AliMUONTrackerOCDBDataMaker.cxx b/MUON/AliMUONTrackerOCDBDataMaker.cxx index ae4dab6a207..a93e4cfd4ac 100644 --- a/MUON/AliMUONTrackerOCDBDataMaker.cxx +++ b/MUON/AliMUONTrackerOCDBDataMaker.cxx @@ -23,7 +23,10 @@ #include "AliLog.h" #include "AliMUON2DMap.h" #include "AliMUONCalibParamND.h" +#include "AliMUONCalibParamNI.h" #include "AliMUONCalibrationData.h" +#include "AliMUONDigitCalibrator.h" +#include "AliMUONPadStatusMapMaker.h" #include "AliMUONTrackerData.h" #include "AliMUONVStore.h" #include "AliMpConstants.h" @@ -31,6 +34,8 @@ #include "AliMpDetElement.h" #include "AliMpDEManager.h" #include "AliMpDCSNamer.h" +#include "AliMpManuIterator.h" +#include "Riostream.h" #include #include #include @@ -86,10 +91,10 @@ AliMUONTrackerOCDBDataMaker::AliMUONTrackerOCDBDataMaker(const char* ocdbPath, } else if ( stype == "GAINS" ) { - AliMUONVStore* gains = AliMUONCalibrationData::CreateGains(runNumber,&startOfValidity); + AliMUONVStore* gains = AliMUONCalibrationData::CreateGains(runNumber,&startOfValidity); + store = PatchGainStore(*gains); + delete gains; fData = CreateDataGains(startOfValidity); - store = SplitQuality(*gains); - delete gains; } else if ( stype == "CAPACITANCES" ) { @@ -104,7 +109,20 @@ AliMUONTrackerOCDBDataMaker::AliMUONTrackerOCDBDataMaker(const char* ocdbPath, store = CreateHVStore(*m); delete m; } - + else if ( stype == "STATUSMAP" ) + { + fData = new AliMUONTrackerData(Form("STATUSMAP%d",runNumber),"Status map",2,kTRUE); + fData->SetDimensionName(0,"Bits"); + fData->SetDimensionName(1,"Dead"); + store = CreateStatusMapStore(runNumber); + } + else if ( stype == "STATUS" ) + { + fData = new AliMUONTrackerData(Form("STATUS%d",runNumber),"Status",1,kTRUE); + fData->SetDimensionName(0,"Bits"); + store = CreateStatusStore(runNumber); + } + AliCDBManager::Instance()->SetDefaultStorage(storage); if (!store) @@ -149,16 +167,61 @@ AliMUONTrackerOCDBDataMaker::CreateDataGains(Int_t runNumber) { /// Create data to hold gains values - AliMUONVTrackerData* data = new AliMUONTrackerData(Form("GAIN%d",runNumber),"Gains",6,kTRUE); - data->SetDimensionName(0,"a1"); - data->SetDimensionName(1,"a2"); - data->SetDimensionName(2,"thres"); - data->SetDimensionName(3,"qual1"); - data->SetDimensionName(4,"qual2"); - data->SetDimensionName(5,"sat"); + AliMUONVTrackerData* data = new AliMUONTrackerData(Form("GAIN%d",runNumber),"Gains",7,kTRUE); + data->SetDimensionName(0,"gain"); + data->SetDimensionName(1,"a1"); + data->SetDimensionName(2,"a2"); + data->SetDimensionName(3,"thres"); + data->SetDimensionName(4,"qual1"); + data->SetDimensionName(5,"qual2"); + data->SetDimensionName(6,"sat"); return data; } +//_____________________________________________________________________________ +AliMUONVStore* +AliMUONTrackerOCDBDataMaker::PatchGainStore(AliMUONVStore& gains) +{ + /// Polish the gain store : + /// a) adding a dimension, computed from a1, and called gain = 1/a1/0.2 + /// where 0.2 is internal capa in pF, and gain is then in mV/fC + /// b) splitting the quality in two + + AliMUONVStore* store = gains.Create(); + + TIter next(gains.CreateIterator()); + AliMUONVCalibParam* param; + + while ( ( param = static_cast(next()) ) ) + { + AliMUONVCalibParam* nd = new AliMUONCalibParamND(param->Dimension()+2, + param->Size(), + param->ID0(), + param->ID1()); + for ( Int_t i = 0; i < param->Size(); ++i ) + { + + Int_t qual = param->ValueAsInt(i,3); + Int_t q1 = (qual & 0xF0) >> 4; // linear fit quality + Int_t q2 = qual & 0xF; // parabolic fit quality + Double_t gain = 0.0; + + if ( param->ValueAsFloat(i,0) > 1E-9 ) gain = 1.0/param->ValueAsFloat(i,0)/0.2; + + nd->SetValueAsDouble(i,0,gain); // gain + nd->SetValueAsDouble(i,1,param->ValueAsFloat(i,0)); // a1 + nd->SetValueAsDouble(i,2,param->ValueAsFloat(i,1)); // a2 + nd->SetValueAsInt(i,3,param->ValueAsInt(i,2)); // thres + nd->SetValueAsInt(i,4,q1); // qual1 + nd->SetValueAsInt(i,5,q2); // qual2 + nd->SetValueAsInt(i,6,param->ValueAsInt(i,4)); // sat + } + store->Add(nd); + } + + return store; +} + //_____________________________________________________________________________ AliMUONVTrackerData* AliMUONTrackerOCDBDataMaker::CreateDataPedestals(Int_t runNumber) @@ -171,6 +234,62 @@ AliMUONTrackerOCDBDataMaker::CreateDataPedestals(Int_t runNumber) return data; } +//_____________________________________________________________________________ +AliMUONVStore* +AliMUONTrackerOCDBDataMaker::CreateStatusStore(Int_t runNumber) +{ + /// Get the status store + + AliMUONDigitCalibrator calibrator(runNumber); + + AliMUONVStore* sm = new AliMUON2DMap(kTRUE); + + AliMpManuIterator it; + Int_t detElemId, manuId; + + while (it.Next(detElemId,manuId)) + { + AliMUONVCalibParam* np = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId); + for ( Int_t i = 0; i < np->Size(); ++i ) + { + Int_t value = calibrator.PadStatus(detElemId,manuId,i); + np->SetValueAsInt(i,0,value); // "raw" value of the status + } + sm->Add(np); + } + + return sm; +} + +//_____________________________________________________________________________ +AliMUONVStore* +AliMUONTrackerOCDBDataMaker::CreateStatusMapStore(Int_t runNumber) +{ + /// Get the status map, and polish it a bit for representation purposes + + AliMUONDigitCalibrator calibrator(runNumber); + + AliMUONVStore* sm = new AliMUON2DMap(kTRUE); + + AliMpManuIterator it; + Int_t detElemId, manuId; + + while (it.Next(detElemId,manuId)) + { + AliMUONVCalibParam* np = new AliMUONCalibParamNI(2,AliMpConstants::ManuNofChannels(),detElemId,manuId); + for ( Int_t i = 0; i < np->Size(); ++i ) + { + Int_t value = calibrator.StatusMap(detElemId,manuId,i); + Int_t channelIsDead = ( value & AliMUONPadStatusMapMaker::SelfDeadMask() ); + np->SetValueAsInt(i,0,value); // "raw" value of the status map + np->SetValueAsInt(i,1,channelIsDead); // simple 0 or 1 for this channel + } + sm->Add(np); + } + + return sm; +} + //_____________________________________________________________________________ AliMUONVStore* AliMUONTrackerOCDBDataMaker::CreateHVStore(TMap& m) @@ -262,42 +381,3 @@ AliMUONTrackerOCDBDataMaker::Merge(TCollection*) AliError("Not implemented. Does it have sense ?"); return 0; } - -//_____________________________________________________________________________ -AliMUONVStore* -AliMUONTrackerOCDBDataMaker::SplitQuality(const AliMUONVStore& gains) -{ - /// Create a new store, identical to source gain store, except that qual - /// dimension is "decompacted" in two separated values - - AliMUONVStore* store = gains.Create(); - - TIter next(gains.CreateIterator()); - AliMUONVCalibParam* param; - - while ( ( param = static_cast(next()) ) ) - { - AliMUONVCalibParam* nd = new AliMUONCalibParamND(param->Dimension()+1, - param->Size(), - param->ID0(), - param->ID1()); - for ( Int_t i = 0; i < param->Size(); ++i ) - { - for ( Int_t k = 0; k < param->Dimension(); ++k ) - { - if ( k == 3 ) continue; - Int_t m = ( k < 3 ? k : k+1 ) ; - nd->SetValueAsDouble(i,m,param->ValueAsFloat(i,k)); - } - Int_t qual = param->ValueAsInt(i,3); - - Int_t q1 = (qual & 0xF0) >> 4; // linear fit quality - Int_t q2 = qual & 0xF; // parabolic fit quality - - nd->SetValueAsInt(i,3,q1); - nd->SetValueAsInt(i,4,q2); - } - store->Add(nd); - } - return store; -} diff --git a/MUON/AliMUONTrackerOCDBDataMaker.h b/MUON/AliMUONTrackerOCDBDataMaker.h index 18b6354427a..615c5e8d30c 100644 --- a/MUON/AliMUONTrackerOCDBDataMaker.h +++ b/MUON/AliMUONTrackerOCDBDataMaker.h @@ -63,12 +63,16 @@ public: virtual Long64_t Merge(TCollection* li); static AliMUONVStore* CreateHVStore(TMap& hvMap); - static AliMUONVStore* SplitQuality(const AliMUONVStore& gains); static AliMUONVTrackerData* CreateDataPedestals(Int_t runNumber); static AliMUONVTrackerData* CreateDataGains(Int_t runNumber); static AliMUONVTrackerData* CreateDataCapacitances(Int_t runNumber); + static AliMUONVStore* CreateStatusMapStore(Int_t runNumber); + static AliMUONVStore* CreateStatusStore(Int_t runNumber); + + static AliMUONVStore* PatchGainStore(AliMUONVStore& gains); + private: /// Not implemented AliMUONTrackerOCDBDataMaker(const AliMUONTrackerOCDBDataMaker& rhs); diff --git a/MUON/AliMUONVPainter.h b/MUON/AliMUONVPainter.h index 6124444d8fd..bfb67cba61a 100644 --- a/MUON/AliMUONVPainter.h +++ b/MUON/AliMUONVPainter.h @@ -151,9 +151,9 @@ public: void SetOutlined(const char* pattern, Bool_t flag); - void SetResponder(const char* pattern); + virtual void SetResponder(const char* pattern); - void SetResponder(Int_t depth); + virtual void SetResponder(Int_t depth); void SetVisible(const char* pattern, Bool_t flag); @@ -281,7 +281,10 @@ private: AliMUONPainterGroup* CreateGroup(const char* type, Int_t depth); +protected: void CreateGroups(); + +private: void GetBoundingBox(Double_t& x1, Double_t& y1, Double_t& x2, Double_t& y2) const; @@ -300,9 +303,13 @@ private: AliMUONVPainter* fMother; ///< our mother AliMUONPainterGroup* fGroup; ///< our group AliMUONContour* fContour; ///< our contour +protected: TMap* fPainterGroups; ///< map of groups +private: TObjArray* fChildren; ///< our children +protected: AliMUONPainterGroup* fResponderGroup; ///< the responder group +private: AliMUONPainterGroup* fPlotterGroup; ///< the plotter group Double_t fBorderFactor; ///< border factor for visu TVirtualPad* fPad; ///< the pad we're drawn in diff --git a/MUON/MUONgraphicsLinkDef.h b/MUON/MUONgraphicsLinkDef.h index afa5ac3c594..9d9e4e52b30 100644 --- a/MUON/MUONgraphicsLinkDef.h +++ b/MUON/MUONgraphicsLinkDef.h @@ -48,6 +48,7 @@ #pragma link C++ class AliMUONNode+; #pragma link C++ class AliMUONPointWithRef+; #pragma link C++ class AliMUONContourMakerTest+; +#pragma link C++ class AliMUONContourHandler+; #endif diff --git a/MUON/libMUONgraphics.pkg b/MUON/libMUONgraphics.pkg index b49b089a3b2..ca1d4bc9f2c 100644 --- a/MUON/libMUONgraphics.pkg +++ b/MUON/libMUONgraphics.pkg @@ -40,7 +40,8 @@ SRCS:= AliMUONVPainter.cxx \ AliMUONSegmentTree.cxx \ AliMUONNode.cxx \ AliMUONPointWithRef.cxx \ - AliMUONContourMakerTest.cxx + AliMUONContourMakerTest.cxx \ + AliMUONContourHandler.cxx HDRS:= $(SRCS:.cxx=.h) diff --git a/MUON/mchview.cxx b/MUON/mchview.cxx index f39a511870c..b0debd5b038 100644 --- a/MUON/mchview.cxx +++ b/MUON/mchview.cxx @@ -38,7 +38,7 @@ #include "AliMpDataMap.h" #include "AliMpDataStreams.h" #include "AliMpDDLStore.h" - +#include "AliMpManuStore.h" //______________________________________________________________________________ Int_t Usage() @@ -50,6 +50,8 @@ Int_t Usage() cout << " --geometry #x#+#+# : manually specify the geometry of the window, ala X11..., e.g. --geometry 1280x900+1600+0 will" << endl; cout << " get a window of size 1280x900, located at (1600,0) from the top-left of the (multihead) display " << endl; cout << " --asciimapping : load mapping from ASCII files instead of OCDB (for debug and experts only...)" << endl; + cout << " --de detElemId : start by displaying the given detection element instead of the default view (which is all the chambers)" << endl; + cout << " --chamber chamberId (from 1 to 10) : start by displaying the given chamber instead of the default view (which is all the chambers)" << endl; return -1; } @@ -97,9 +99,15 @@ int main(int argc, char** argv) } else if ( a == "--asciimapping" ) { + ++nok; ASCIImapping = kTRUE; } - + else if ( a == "--de" || a == "--chamber" ) + { + // do nothing. Let AliMUONMchViewApplication handle that one. (and the next one as well). + nok += 2; + ++i; + } else { return Usage(); @@ -119,9 +127,19 @@ int main(int argc, char** argv) if ( ASCIImapping ) { AliMpDataProcessor mp; - AliMpDataMap* map = mp.CreateDataMap("data"); - AliMpDataStreams dataStreams(map); - AliMpDDLStore::ReadData(dataStreams); + { + AliMpDataMap* datamap = mp.CreateDataMap("data"); + AliMpDataStreams dataStreams(datamap); + AliMpDDLStore::ReadData(dataStreams); + } + { + AliMpDataMap* datamap = mp.CreateDataMap("data_run"); + AliMpDataStreams dataStreams(datamap); + AliMpManuStore::ReadData(dataStreams); + } + + AliCDBManager::Instance()->SetSpecificStorage("MUON/Calib/Neighbours","local://$ALICE_ROOT/OCDB"); + } gROOT->SetStyle("Plain"); -- 2.43.0