]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpDEVisu.cxx
PMD module
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpDEVisu.cxx
index 9939360ef540447322c9618b4d002bad950192b2..724213a2bbfd140bde2754de387553cd3678c606 100644 (file)
 #include "AliMpSegmentation.h"
 #include "AliMpPad.h"
 #include "AliMpDDLStore.h"
+#include "AliMpManuStore.h"
 #include "AliMpVPadIterator.h"
 #include "AliMpCDB.h"
+#include "AliMpDataStreams.h"
 
 #include "AliLog.h"
 
 #include <TMath.h>
 #include <TString.h>
-#include <TVector2.h>
 #include <TCanvas.h>
 #include <TGButton.h>
 #include <TRootEmbeddedCanvas.h>
@@ -54,6 +55,8 @@
 #include <TGTextView.h>
 #include <TGTextEntry.h>
 
+#include <cstdio>
+
 // Category: graphics
 
 //-----------------------------------------------------------------------------
@@ -90,25 +93,24 @@ AliMpDEVisu::AliMpDEVisu(UInt_t w, UInt_t h)
   fCurrentPlane(AliMp::kBendingPlane),
   fCurrentDetElem(100),
   fCurrentDEName(),
-  fSegmentation(),
+  fkSegmentation(),
+  fDDLStore(0x0),
+  fManuStore(0x0),
   fZoomMode(false)
 {
 /// Standard constructor
 
   // Load mapping
-  if ( ! AliMpCDB::LoadMpSegmentation() ) 
-  {
+  if ( ! AliMpCDB::LoadDDLStore() ) {
     AliFatal("Could not access mapping from OCDB !");
   }
-  
-  // Load DDL store
-  if ( ! AliMpCDB::LoadDDLStore() ) 
-  {
-    AliFatal("Could not access DDL Store from OCDB !");
+
+  if ( ! AliMpCDB::LoadManuStore() ) {
+    AliFatal("Could not access run-dependent mapping from OCDB !");
   }
 
   fDDLStore = AliMpDDLStore::Instance();
-
+  fManuStore = AliMpManuStore::Instance();
 
   fTrashList.SetOwner(kFALSE);
   
@@ -145,7 +147,7 @@ AliMpDEVisu::AliMpDEVisu(UInt_t w, UInt_t h)
   fDEComboIdx.Set(26);
   for(i = 0; i < 10; i++)
   {
-    sprintf(text,"%d",i+1);
+    snprintf(text,20,"%d",i+1);
     fChamberCombo->AddEntry(text,i);
   }
   fChamberCombo->Resize(40,20);
@@ -269,7 +271,7 @@ AliMpDEVisu::AliMpDEVisu(UInt_t w, UInt_t h)
   fMain->MapWindow();
   
   // instance segmentation
-  fSegmentation = AliMpSegmentation::Instance()->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane));
+  fkSegmentation = AliMpSegmentation::Instance()->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane));
   fLogMessage->AddLine("Segmentation loaded");
   fLogMessage->ShowBottom();
 }
@@ -348,7 +350,7 @@ void AliMpDEVisu::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TO
       EventToReal(eventX,eventY,x,y);
       
       // get manu
-      AliMpPad pad = fSegmentation->PadByPosition(TVector2(x,y), false);
+      AliMpPad pad = fkSegmentation->PadByPosition(x,y, false);
       
       if (!pad.IsValid()) {
        
@@ -358,7 +360,7 @@ void AliMpDEVisu::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TO
         return;
       }
       
-      Int_t manu = pad.GetLocation().GetFirst();
+      Int_t manu = pad.GetManuId();
       
       fNumberEntry->SetNumber(manu);
       
@@ -415,13 +417,13 @@ void AliMpDEVisu::DrawManuMotif(Bool_t popup)
   
   if (AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 ) {
     
-    sprintf(command, "%s%d", "PMCI:", (Int_t)fNumberEntry->GetIntNumber());
+    snprintf(command, 255, "%s%d", "PMCI:", (Int_t)fNumberEntry->GetIntNumber());
     
     DrawSlat(command, popup);
     
   } else {   
     
-    sprintf(command, "%s%d", "RSMCI:", (Int_t)fNumberEntry->GetIntNumber());
+    snprintf(command, 255, "%s%d", "RSMCI:", (Int_t)fNumberEntry->GetIntNumber());
     
     DrawQuadrant(command, popup);
     
@@ -440,11 +442,14 @@ void AliMpDEVisu::DrawSlat(Option_t* option, Bool_t popup)
   
   AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem);
   TString nameType =  detElem->GetSegType();
-  
+
+  AliMpDataStreams dataStreams;
+
   AliMpSlatMotifMap mm;
-  AliMpSt345Reader reader(mm);  
-  AliMpSlat* slatCurrent = reader.ReadSlat(nameType.Data(), fCurrentPlane);
-  AliMpSlat* slatOther   = reader.ReadSlat(nameType.Data(), AliMp::OtherPlaneType(fCurrentPlane));
+  
+  AliMpSt345Reader reader(&mm);
+  AliMpSlat* slatCurrent = reader.ReadSlat(dataStreams,nameType.Data(), fCurrentPlane);
+  AliMpSlat* slatOther   = reader.ReadSlat(dataStreams,nameType.Data(), AliMp::OtherPlaneType(fCurrentPlane));
   
   AliMpVPainter* painter = AliMpVPainter::CreatePainter(slatCurrent);
   painter->Draw(option);
@@ -472,13 +477,15 @@ void AliMpDEVisu::DrawQuadrant(Option_t* option, Bool_t popup)
   canvas->Clear();
   
   AliMpDetElement* detElem = AliMpDEManager::GetDetElement(fCurrentDetElem);
-  AliMp::StationType  station = detElem->GetStationType();
+  AliMq::Station12Type  station = detElem->GetStation12Type();
 
+  AliMpDataStreams dataStreams;
+  
   AliMpSectorReader readerCurrent(station, fCurrentPlane);
-  AliMpSector* sectorCurrent = readerCurrent.BuildSector();
+  AliMpSector* sectorCurrent = readerCurrent.BuildSector(dataStreams);
     
   AliMpSectorReader readerOther(station, AliMp::OtherPlaneType(fCurrentPlane));
-  AliMpSector* sectorOther = readerOther.BuildSector();
+  AliMpSector* sectorOther = readerOther.BuildSector(dataStreams);
   
   AliMpVPainter *painter = AliMpVPainter::CreatePainter(sectorCurrent);
   painter->Draw(option);
@@ -499,32 +506,35 @@ void AliMpDEVisu::DrawQuadrant(Option_t* option, Bool_t popup)
 
 //______________________________________________________________________________
 void 
-AliMpDEVisu::EventToReal(Int_t eventX, Int_t eventY, Double_t& x, Double_t& y) const
+AliMpDEVisu::EventToReal(Int_t eventX, Int_t eventY, 
+                         Double_t& x, Double_t& y) const
 {
   /// estimate graphic pad sizes
 
-  static TVector2 ul(gPad->XtoPixel(0.01), gPad->YtoPixel(0.99));
-  static TVector2 br(gPad->XtoPixel(0.99), gPad->YtoPixel(0.01));
+  static Double_t ulx(gPad->XtoPixel(0.01)); 
+  static Double_t uly(gPad->YtoPixel(0.99));
+  static Double_t brx(gPad->XtoPixel(0.99));
+  static Double_t bry(gPad->YtoPixel(0.01));
 
-  static TVector2 padDim = br - ul;
+  static Double_t padDimX = brx - ulx;
+  static Double_t padDimY = bry - uly;
   
   // get DE dimension (half size)
-  TVector2 deDim(fSegmentation->Dimensions()*2.0);
-  
-  TVector2 padReal;
+  Double_t deDimX(fkSegmentation->GetDimensionX()*2.0);
+  Double_t deDimY(fkSegmentation->GetDimensionY()*2.0);
   
-  if (AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 )
+  if ( AliMpDEManager::GetStationType(fCurrentDetElem) == AliMp::kStation345 )
   {
     // origin at center
-    x = (eventX - ul.X() - padDim.X()/2.)/(padDim.X())*deDim.X()
-    y = (br.Y() - eventY - padDim.Y()/2.)/(padDim.Y())*deDim.Y()
+    x = (eventX - ulx - padDimX/2.)/(padDimX)*deDimX
+    y = (bry - eventY - padDimY/2.)/(padDimY)*deDimY
     
   } 
   else 
   {
     // origin at bottom left
-    x = (eventX - ul.X())/(padDim.X())*deDim.X()
-    y = (br.Y() - eventY)/(padDim.Y())*deDim.Y()
+    x = (eventX - ulx)/(padDimX)*deDimX
+    y = (bry - eventY)/(padDimY)*deDimY
   }
   
 }
@@ -590,8 +600,7 @@ void AliMpDEVisu::InfoDE()
   Int_t firstBus     = TMath::MinElement(detElem->GetNofBusPatches(), vec);
   Int_t lastBus      = TMath::MaxElement(detElem->GetNofBusPatches(), vec);
   
-  detElem = AliMpDEManager::GetDetElement(fCurrentDetElem);
-  Int_t numberOfSerialManu = detElem->GetNofManus(); // number of manu with an identified serial number
+  Int_t numberOfSerialManu = fManuStore->NofManus(detElem->GetId()); // number of manu with an identified serial number
   
   fLogMessage->AddLine(Form("DrawDE: detection element: %d, name: %s", 
                       fCurrentDetElem, fCurrentDEName.Data()));
@@ -653,7 +662,7 @@ Bool_t AliMpDEVisu::ProcessMessage(Long_t msg, Long_t parm1, Long_t /*parm2*/)
                   fNumberEntry->SetNumber(fNumberEntry->GetIntNumber() - 1024);
               }
               DrawDE();
-              fSegmentation = AliMpSegmentation::Instance()
+              fkSegmentation = AliMpSegmentation::Instance()
                 ->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane));
               break;
 
@@ -707,7 +716,7 @@ void AliMpDEVisu::UpdateComboCH()
 
     fCurrentDetElem = fDEComboIdx[fDECombo->GetSelected()];
 
-    fSegmentation = AliMpSegmentation::Instance()
+    fkSegmentation = AliMpSegmentation::Instance()
        ->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane));
 }
 
@@ -758,7 +767,7 @@ void AliMpDEVisu::UpdateNameView(Bool_t firstTime)
   }
 
   fNameDECombo->Select(fDEOccurrence[fCurrentDetElem]);
-  fSegmentation = AliMpSegmentation::Instance()
+  fkSegmentation = AliMpSegmentation::Instance()
     ->GetMpSegmentation(fCurrentDetElem, detElem->GetCathodType(fCurrentPlane));
 }
 
@@ -795,11 +804,11 @@ void AliMpDEVisu::PopUpManuMotif(AliMpSlat* slat)
   AliMpMotifPosition* motifPos = 0x0;
   Int_t manuId = 0;
 
-  for ( AliMpSlat::Size_t i = 0; i < slat->GetSize(); ++i ) {
+  for ( Int_t i = 0; i < slat->GetSize(); ++i ) {
     
     AliMpPCB* pcb = slat->GetPCB(i);
     
-    for ( AliMpPCB::Size_t j = 0; j < slat->GetPCB(i)->GetSize(); ++j ) {
+    for ( Int_t j = 0; j < slat->GetPCB(i)->GetSize(); ++j ) {
       
       motifPos = pcb->GetMotifPosition(j);
       
@@ -817,13 +826,14 @@ void AliMpDEVisu::PopUpManuMotif(AliMpSlat* slat)
   {
     InfoManuMotif(motifPosFound);
 
-    TVector2 dimension(motifPosFound->Dimensions());
+    Double_t dimensionX(motifPosFound->GetDimensionX()); 
+    Double_t dimensionY(motifPosFound->GetDimensionY());
 
     Int_t h = 500;
-    Int_t w = Int_t(h*dimension.X()/dimension.Y());
+    Int_t w = Int_t(h*dimensionX/dimensionY);
     AliMpVPainter* painter = AliMpVPainter::CreatePainter(motifPosFound);
       
-    CreatePopupWindow(w,h,Form("Manu %d",fNumberEntry->GetIntNumber()),
+    CreatePopupWindow(w,h,Form("Manu %ld",fNumberEntry->GetIntNumber()),
                      painter,"ZT");
   }
 }
@@ -844,8 +854,8 @@ void AliMpDEVisu::PopUpManuMotif(AliMpSector* sector)
     
     for (Int_t iRowSeg = 0; iRowSeg < sector->GetRow(iRow)->GetNofRowSegments(); ++iRowSeg){
       
-      for (Int_t iRowSeg = 0; iRowSeg < row->GetNofRowSegments(); ++iRowSeg) {
-        AliMpVRowSegment *rowSegment = row->GetRowSegment(iRowSeg);
+      for (Int_t iRowSeg2 = 0; iRowSeg2 < row->GetNofRowSegments(); ++iRowSeg2) {
+        AliMpVRowSegment *rowSegment = row->GetRowSegment(iRowSeg2);
         
         for (Int_t iMotif = 0; iMotif < rowSegment->GetNofMotifs(); ++iMotif){
           
@@ -872,15 +882,16 @@ void AliMpDEVisu::PopUpManuMotif(AliMpSector* sector)
 
     InfoManuMotif(motifPosFound);
 
-    TVector2 dimension(motifPosFound->Dimensions());
+    Double_t dimensionX(motifPosFound->GetDimensionX()); 
+    Double_t dimensionY(motifPosFound->GetDimensionY());
 
     // Create transient frame
     Int_t h = 400;
-    Int_t w = Int_t(h*dimension.X()/dimension.Y());
+    Int_t w = Int_t(h*dimensionX/dimensionY);
 
     AliMpVPainter* painter = AliMpVPainter::CreatePainter(motifPosFound);
     
-    CreatePopupWindow(w,h,Form("Manu %d",fNumberEntry->GetIntNumber()),
+    CreatePopupWindow(w,h,Form("Manu %ld",fNumberEntry->GetIntNumber()),
                       painter,"ZT");
     
   }
@@ -893,18 +904,19 @@ void AliMpDEVisu::InfoManuMotif(AliMpMotifPosition* motifPos)
 
    // log message
     Int_t manuId = fNumberEntry->GetIntNumber();
-    TVector2 dimension(motifPos->Dimensions());
+
     fLogMessage->AddLine(Form("PopupManuMotif: motif dimension: %5.2f, %5.2f", 
-                             dimension.X()*2., dimension.Y()*2.));
+                             motifPos->GetDimensionX()*2., 
+                              motifPos->GetDimensionY()*2.));
       
     fLogMessage->AddLine( Form("PopupManuMotif: pad dimension: %4.2f, %4.2f", 
-                              motifPos->GetMotif()->GetPadDimensions(0).X()*2.,  
-                              motifPos->GetMotif()->GetPadDimensions(0).Y()*2. ));
+                              motifPos->GetMotif()->GetPadDimensionX(0)*2.,  
+                              motifPos->GetMotif()->GetPadDimensionY(0)*2. ));
 
     fLogMessage->AddLine( Form("PopupManuMotif: manu: %d, serial number: %d, buspatch: %d",
-                              manuId, 
-                              fDDLStore->GetDetElement(fCurrentDetElem)->GetManuSerialFromId(manuId),
-                              fDDLStore->GetBusPatchId(fCurrentDetElem, manuId)) );
+                             manuId, 
+                             fManuStore->GetManuSerial(fCurrentDetElem, manuId),
+                             fDDLStore->GetBusPatchId(fCurrentDetElem, manuId)) );
 
     fLogMessage->ShowBottom();
 
@@ -928,13 +940,13 @@ void AliMpDEVisu::PopUpZoom(Int_t ix0, Int_t iy0, Int_t ix1, Int_t iy1)
   Int_t h = 500;//TMath::Abs(x1-x0);
   Int_t w = 500;//TMath::Abs(y1-y0);
 
-  AliMpArea area(TVector2((x0+x1)/2.0,(y0+y1)/2.0),
-                  TVector2(TMath::Abs(x1-x0)/2.0,TMath::Abs(y1-y0)/2.0));
+  AliMpArea area((x0+x1)/2.0,(y0+y1)/2.0,
+                 TMath::Abs(x1-x0)/2.0,TMath::Abs(y1-y0)/2.0);
 //  area.Print();
   
   if ( area.IsValid() )
   {
-    AliMpVPadIterator* iterator = fSegmentation->CreateIterator(area);
+    AliMpVPadIterator* iterator = fkSegmentation->CreateIterator(area);
     if (iterator)
     {
       AliMpVPainter* painter = AliMpVPainter::CreatePainter(iterator);