]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
AliMUONTrackerCalibratedDataMaker
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 16 Feb 2008 18:05:48 +0000 (18:05 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 16 Feb 2008 18:05:48 +0000 (18:05 +0000)
    Adding possibility to STEER the calibration mode, and to histogram
    the results.

AliMUONPainterMasterFrame
AliMUONPainterMatrixFrame
    Adding basic (to be improved) Print facility for canvases we display

AliMUONMchViewApplication
    Adding basic (to be improved) Print facility for canvases we display
    Increasing version number to 0.91

AliMUONTrackerOCDBDataMaker
    Changing names of a0,a1 to a1,a2

AliMUONVPainter
    Adding context menu (right click) to draw histogram, when available

AliMUONSparseHisto
    Adding possibility to specify a range (different from 0..4095). Still
    the precision is only 12 bits and will stay there ;-)

AliMUONManuPainter
AliMUONDEPainter
    Adding FillManuList method

AliMUONPCBPainter
    Implementing the Describe method which was missing

AliMUONVTrackerData.h
AliMUONTrackerData.h
AliMUONTrackerData.cxx
    Reorganized interface. Histogramming (in terms of TH1) is now entirely
    handled by an external class, AliMUONTrackerDataHistogrammer. This class
    only hold the SparseHistos for the individual channels.

AliMUONPainterDataSourceItem
    Disconnecting buttons that are not working so far...

AliMUONPainterDataSourceFrame
    Can now histogram more than just the ADC values.

AliMUONTrackerRawDataMaker
    Small change in one call name.

READMEshuttle.txt
READMEmchview.txt
    Updating doc

mchview.cxx
    Adding the --use option to load back a previously saved .root file

libMUONgraphics.pkg
MUONgraphicsLinkDef.h
    Adding AliMUONTrackerDataHistogrammer class

(Laurent)

36 files changed:
MUON/AliMUONDEPainter.cxx
MUON/AliMUONDEPainter.h
MUON/AliMUONManuPainter.cxx
MUON/AliMUONManuPainter.h
MUON/AliMUONMchViewApplication.cxx
MUON/AliMUONMchViewApplication.h
MUON/AliMUONPCBPainter.cxx
MUON/AliMUONPCBPainter.h
MUON/AliMUONPainterDataSourceFrame.cxx
MUON/AliMUONPainterDataSourceFrame.h
MUON/AliMUONPainterDataSourceItem.cxx
MUON/AliMUONPainterDataSourceItem.h
MUON/AliMUONPainterMasterFrame.cxx
MUON/AliMUONPainterMasterFrame.h
MUON/AliMUONPainterMatrixFrame.cxx
MUON/AliMUONPainterMatrixFrame.h
MUON/AliMUONSparseHisto.cxx
MUON/AliMUONSparseHisto.h
MUON/AliMUONTrackerCalibratedDataMaker.cxx
MUON/AliMUONTrackerCalibratedDataMaker.h
MUON/AliMUONTrackerData.cxx
MUON/AliMUONTrackerData.h
MUON/AliMUONTrackerDataHistogrammer.cxx [new file with mode: 0644]
MUON/AliMUONTrackerDataHistogrammer.h [new file with mode: 0644]
MUON/AliMUONTrackerOCDBDataMaker.cxx
MUON/AliMUONTrackerRawDataMaker.cxx
MUON/AliMUONVPainter.cxx
MUON/AliMUONVPainter.h
MUON/AliMUONVTrackerData.h
MUON/Doxyfile
MUON/MUONOfflineShift.C [new file with mode: 0644]
MUON/MUONgraphicsLinkDef.h
MUON/READMEmchview.txt
MUON/READMEshuttle.txt
MUON/libMUONgraphics.pkg
MUON/mchview.cxx

index 6c9f68ddcfba869ab3c391f605de6a924b8ca515..d298e9e38aabc701aad58bd66e2090ad4d61fd99 100644 (file)
@@ -232,6 +232,25 @@ AliMUONDEPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
   return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
 }
 
+//_____________________________________________________________________________
+void
+AliMUONDEPainter::FillManuList(TObjArray& manuList) const
+{
+  /// Fill (append to) manu list
+  TIter next(Children());
+  AliMUONVPainter* p;
+  
+  while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
+  {
+    if ( p->IsA() == AliMUONBusPatchPainter::Class() )
+    {
+      // Only consider bus patch painters (and not PCB ones),
+      // in order not to double count some manus
+      p->FillManuList(manuList);
+    }
+  }
+}
+                            
 //_____________________________________________________________________________
 void
 AliMUONDEPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
index 9e8aad400675844ee48542835cd6b223d920b979..13f9ce1bed32ca9253e713f85656712bc3ce13b7 100644 (file)
@@ -44,6 +44,8 @@ public:
     
   virtual AliMUONAttPainter Validate(const AliMUONAttPainter& attributes) const;
 
+  virtual void FillManuList(TObjArray& manuList) const;
+  
 private:
   Int_t fDetElemId; ///< our id
 
index 29a417ee2d3b3bf44f5fc6be785865a678dc3822..9976c539f829c5f5440502bf5ab91ba1ceed12a0 100644 (file)
@@ -24,6 +24,7 @@
 #include "AliMUONVDigit.h"
 #include "AliMUONVTrackerData.h"
 #include "AliMpDEManager.h"
+#include "AliMpManuUID.h"
 #include "AliMpMotifPosition.h"
 #include "AliMpMotifType.h"
 #include "AliMpSlat.h"
@@ -82,24 +83,24 @@ AliMUONManuPainter::AliMUONManuPainter(const AliMUONAttPainter& att,
     Double_t x,y,z;
     
     AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
-
+    
     if ( stationType == AliMp::kStation345 ) 
     {
       const AliMpSlat* slat = AliMUONPainterHelper::Instance()->GetSlat(detElemId,manuId);
-
+      
       h->Local2Global(fDetElemId,
-                                                   mp->Position().X() -slat->Position().X(),
-                                                   mp->Position().Y() -slat->Position().Y(),
-                                                   0,
-                                                   x,y,z);
+                      mp->Position().X() -slat->Position().X(),
+                      mp->Position().Y() -slat->Position().Y(),
+                      0,
+                      x,y,z);
     }
     else if ( stationType != AliMp::kStationTrigger ) 
     {
       h->Local2Global(fDetElemId,
-                                                     mp->Position().X(),
-                                                     mp->Position().Y(),
-                                                     0,
-                                                     x,y,z);      
+                      mp->Position().X(),
+                      mp->Position().Y(),
+                      0,
+                      x,y,z);      
     }
     else
     {
@@ -109,13 +110,13 @@ AliMUONManuPainter::AliMUONManuPainter(const AliMUONAttPainter& att,
     }
     
     AliMUONPainterContour* contour = h->GetContour(ContourName());
-
+    
     if (!contour)
     {
       contour = h->GenerateManuContour(fDetElemId,
-                                                                      fManuId,
-                                                                      Attributes(),
-                                                                      ContourName());
+                                       fManuId,
+                                       Attributes(),
+                                       ContourName());
     }
     SetContour(contour);
     
@@ -182,6 +183,14 @@ AliMUONManuPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
   return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
 }
 
+//_____________________________________________________________________________
+void
+AliMUONManuPainter::FillManuList(TObjArray& manuList) const
+{
+  /// Append our manu to the list
+  manuList.Add(new AliMpManuUID(fDetElemId,fManuId));
+}
+
 //_____________________________________________________________________________
 void
 AliMUONManuPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
index 4463347e9fc5767414ad0f84e1049e3444ee4d3b..82144f2efcf9c0f56706b7f05b3adc4b3dee2db7 100644 (file)
@@ -45,6 +45,8 @@ public:
   
     virtual AliMUONAttPainter Validate(const AliMUONAttPainter& attributes) const;
 
+    virtual void FillManuList(TObjArray& manuList) const;
+    
 private:
   Int_t fDetElemId; ///< our detection element id
   Int_t fManuId; ///< our manu id
index 65596bdb7d3cbe79f285b3145593b771e86f974d..89bb3ec4e855f7f23d4fc7e85a3df5b2004b1cf2 100644 (file)
@@ -34,6 +34,12 @@ ClassImp(AliMUONMchViewApplication)
 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 char* AliMUONMchViewApplication::fgkFileTypes[] = { 
+  "ROOT files",    "*.root", 
+  "All files",     "*", 
+  0,               0 }; 
 
 //______________________________________________________________________________
 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
@@ -41,7 +47,8 @@ AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
                                                      Float_t wfraction,
                                                      Float_t hfraction) 
 : TRint(name,argc,argv),
-  fMainFrame(0x0)
+  fMainFrame(0x0),
+  fPainterMasterFrame(0x0)
 {
 
   /// ctor
@@ -66,10 +73,10 @@ AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
   
   TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
 
-  AliMUONPainterMasterFrame* pf = 
+  fPainterMasterFrame =
     new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
   
-  t->AddFrame(pf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
+  t->AddFrame(fPainterMasterFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
 
   t = tabs->AddTab("Data Sources");
   
@@ -84,6 +91,9 @@ AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
 
   fMainFrame->MapSubwindows();
   fMainFrame->Resize();
+  
+  fPainterMasterFrame->Update();
+  
   fMainFrame->MapWindow();
   
   fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
@@ -95,6 +105,12 @@ AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
   fMainFrame->SetWMPosition(x, y);
   
   fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
+  
+  cout << "***************************************************" << endl;
+  cout << "   Welcome to mchview" << endl;
+  cout << "   " << FullVersion() << endl;
+  cout << "***************************************************" << endl;
+
 }
 
 //______________________________________________________________________________
@@ -113,14 +129,20 @@ AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
   
   file->AddEntry("&Open...",fgkFILEOPEN);
   file->AddEntry("&Save As...",fgkFILESAVEAS);
+  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* about = new TGPopupMenu(gClient->GetRoot());  
+  about->AddLabel(FullVersion());
+
   bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
+  bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
   
+
   fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
   
   AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
@@ -143,6 +165,9 @@ AliMUONMchViewApplication::HandleMenu(Int_t i)
     case fgkFILESAVEAS:
       Save();
       break;
+    case fgkFILEPRINTAS:
+      PrintAs();
+      break;
     default:
       break;
     }
@@ -156,6 +181,8 @@ AliMUONMchViewApplication::Open()
   
   TGFileInfo fileInfo;
   
+  fileInfo.fFileTypes = fgkFileTypes;
+  
   new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
                    kFDOpen,&fileInfo);
   
@@ -191,6 +218,20 @@ AliMUONMchViewApplication::Open(const char* filename)
 } 
 
 
+//______________________________________________________________________________
+void
+AliMUONMchViewApplication::PrintAs()
+{
+  /// Print as...
+  
+  TGFileInfo fileInfo;
+  
+  new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
+                   kFDSave,&fileInfo);
+  
+  fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
+}
+
 //______________________________________________________________________________
 void
 AliMUONMchViewApplication::Save()
index 24ceac17347160fc5b9069bb595589a136661372..abef192e45e4ff28be08f710ed87ba2bfe733332 100644 (file)
@@ -19,6 +19,7 @@
 #   include <RQ_OBJECT.h>
 #endif
 
+class AliMUONPainterMasterFrame;
 class TGMainFrame;
 
 class AliMUONMchViewApplication : public TRint
@@ -33,8 +34,13 @@ public:
   void HandleMenu(Int_t i);
 
   /// Return the version number of the mchview application
-  static const char* Version() { return "0.9"; }
+  static const char* Version() { return "0.91"; }
   
+  /// Return the SVN revision  and version number of the mchview application
+  static const char* FullVersion() { return Form("mchview Version %s ($Revision$)",Version()); }
+  
+  void Open(const char* filename);
+
 private:
   /// Not implemented
   AliMUONMchViewApplication(const AliMUONMchViewApplication& rhs);
@@ -45,16 +51,20 @@ private:
   void Save();
   void Save(const char* filename);
   void Open();
-  void Open(const char* filename);
-  
+  void PrintAs();
+    
 private:
   TGMainFrame* fMainFrame; ///< pointer to our mainframe
-
+  AliMUONPainterMasterFrame* fPainterMasterFrame; ///< pointer to our main object
+  
   static const Int_t fgkFILESAVEAS; ///< File/Save As... menu
   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
 
-  ClassDef(AliMUONMchViewApplication,1) // mchview application
+  static const char* fgkFileTypes[]; ///< For the open menu
+  
+  ClassDef(AliMUONMchViewApplication,2) // mchview application
 };
 
 #endif
index c07aa4a8a46b026153b5cb3fb26a81c56c5a97c7..0cd8ffd718c6badad3daa2e427ba96da7df06d5e 100644 (file)
@@ -151,6 +151,20 @@ AliMUONPCBPainter::Copy(TObject& object) const
   ((AliMUONPCBPainter&)(object)).fPCBIndex = fPCBIndex;
 }
 
+//_____________________________________________________________________________
+TString
+AliMUONPCBPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
+                                Double_t, Double_t)
+{
+  /// Describe data at this PCB
+  
+  if (!data.HasPCB(fDetElemId,fPCBIndex)) return "";
+  
+  Double_t value = data.PCB(fDetElemId,fPCBIndex,dataIndex);
+  
+  return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
+}
+
 //_____________________________________________________________________________
 void
 AliMUONPCBPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
index 603494f7db523dbe4ab5943fdc3dc06f2aa241db..1b9d26790b41372b6ab0c89035b93cbd8e081a94 100644 (file)
@@ -36,6 +36,9 @@ public:
   void ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, 
                         Double_t& dataMin, Double_t& dataMax) const;
   
+  TString Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
+                   Double_t, Double_t);
+    
   void PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
                  Double_t min, Double_t max);
   
index 2cc0428a6497bcb7649d9e6b0a977e9df64f5d8a..0fcf99a761a257c3db42d9f9d71301b85368b565 100644 (file)
@@ -58,17 +58,21 @@ ClassImp(AliMUONPainterDataSourceFrame)
 //_____________________________________________________________________________
 AliMUONPainterDataSourceFrame::AliMUONPainterDataSourceFrame(const TGWindow* p, UInt_t w, UInt_t h)
 : TGCompositeFrame(p,w,h,kVerticalFrame),
-  fRecentSourceSelector(new TGGroupFrame(p,"Recent sources",kHorizontalFrame)),
-  fRawSelector(new TGGroupFrame(p,"Raw file URI",kHorizontalFrame)),
+  fRecentSourceSelector(new TGGroupFrame(this,"Recent sources",kHorizontalFrame)),
+  fRawSelector(new TGGroupFrame(this,"Raw file URI",kHorizontalFrame)),
   fRawSelector2(new TGCompositeFrame(fRawSelector,w,h,kVerticalFrame)),
   fRawSelector21(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
   fRawSelector22(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
   fRawSelector23(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
-  fCalibrateButton(new TGCheckButton(fRawSelector22,"Calibrate")),
+  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)")),
   fHistogramButton(new TGCheckButton(fRawSelector23,"Histogram")),
+  fHistoMin(new TGNumberEntry(fRawSelector23,0)),
+  fHistoMax(new TGNumberEntry(fRawSelector23,4096)),
   fRawOCDBPath(new TGTextEntry(fRawSelector22,"")),
-  fOCDBSelector(new TGGroupFrame(p,"OCDB Path",kHorizontalFrame)),
-  fDataReaders(new TGGroupFrame(p,"Data sources")),
+  fOCDBSelector(new TGGroupFrame(this,"OCDB Path",kHorizontalFrame)),
+  fDataReaders(new TGGroupFrame(this,"Data sources")),
   fFilePath(new TGTextEntry(fRawSelector21,"")),
   fOCDBPath(new TGTextEntry(fOCDBSelector,"")),
   fRunSelector(new TGNumberEntry(fOCDBSelector,0)),
@@ -127,21 +131,30 @@ AliMUONPainterDataSourceFrame::AliMUONPainterDataSourceFrame(const TGWindow* p,
     fRawSelector21->AddFrame(openButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
     fRawSelector21->AddFrame(fFilePath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
 
-    fRawSelector22->AddFrame(fCalibrateButton, new TGLayoutHints(kLHintsTop,5,5,5,5));
+    fRawSelector22->AddFrame(fCalibrateNoGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
+    fRawSelector22->AddFrame(fCalibrateGainConstantCapa, new TGLayoutHints(kLHintsTop,5,5,5,5));
+    fRawSelector22->AddFrame(fCalibrateGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
     fRawSelector22->AddFrame(fRawOCDBPath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
     fRawOCDBPath->SetEnabled(kFALSE);
     
     fRawSelector23->AddFrame(fHistogramButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
-
+    
+    fHistogramButton->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"HistogramButtonClicked()");
+    
+    fHistoMin->SetState(kFALSE);
+    fHistoMax->SetState(kFALSE);
+    
+    fRawSelector23->AddFrame(fHistoMin,new TGLayoutHints(kLHintsTop,5,5,5,5));
+    fRawSelector23->AddFrame(fHistoMax,new TGLayoutHints(kLHintsTop,5,5,5,5));
+    
     TGButton* createRawButton = new TGTextButton(fRawSelector,"Create data source");
     
     fRawSelector->AddFrame(fRawSelector2, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
     fRawSelector->AddFrame(createRawButton, new TGLayoutHints(kLHintsCenterY,5,5,5,5));
         
-    fCalibrateButton->Connect("Clicked()",
-                              "AliMUONPainterDataSourceFrame",
-                              this,
-                              "CalibrateButtonClicked()");
+    fCalibrateNoGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
+    fCalibrateGainConstantCapa->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
+    fCalibrateGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
 
     openButton->Connect("Clicked()",
                         "AliMUONPainterDataSourceFrame",
@@ -220,16 +233,34 @@ AliMUONPainterDataSourceFrame::CalibrateButtonClicked()
 {
   /// Calibrate button was clicked.
   
-  if ( fCalibrateButton->IsOn() ) 
+  if ( fCalibrateNoGain->IsOn() ||
+       fCalibrateGainConstantCapa->IsOn() ||
+       fCalibrateGain->IsOn() ) 
   {
     fRawOCDBPath->SetEnabled(kTRUE);
     fRawOCDBPath->SetFocus();
-    fHistogramButton->SetEnabled(kFALSE);
   }
   else
   {
     fRawOCDBPath->SetEnabled(kFALSE);
-    fHistogramButton->SetEnabled(kTRUE);
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONPainterDataSourceFrame::HistogramButtonClicked()
+{
+  /// Histogram button was clicked.
+  
+  if ( fHistogramButton->IsOn() )
+  {
+    fHistoMin->SetState(kTRUE);
+    fHistoMax->SetState(kTRUE);
+  }
+  else
+  {
+    fHistoMin->SetState(kFALSE);
+    fHistoMax->SetState(kFALSE);
   }
 }
 
@@ -313,7 +344,34 @@ AliMUONPainterDataSourceFrame::CreateRawDataSource()
     return;
   }
 
-  uri = Form("%sRAW;%s;%s",( fHistogramButton->IsOn() ? "H":""),uri.Data(),fRawOCDBPath->GetText());
+  TString calibMode("");
+  TString name("RAW");
+  
+  if ( fCalibrateGain->IsOn() ) 
+  {
+    calibMode = "GAIN";
+    name = "CALC";
+  }
+  
+  if ( fCalibrateGainConstantCapa->IsOn() ) 
+  {
+    calibMode = "GAINCONSTANTCAPA";
+    name = "CALG";
+  }
+  
+  if ( fCalibrateNoGain->IsOn() ) 
+  {
+    calibMode = "NOGAIN";
+    name = "CALZ";
+  }
+  
+  uri = Form("%s%s;%s;%s;%s;%s;%s",
+             ( fHistogramButton->IsOn() ? "H":""),
+             name.Data(),uri.Data(),
+             ( strlen(fRawOCDBPath->GetText()) > 0 ? fRawOCDBPath->GetText() : " "),
+             ( calibMode.Length() > 0 ? calibMode.Data() : " "),
+             Form("%e",fHistoMin->GetNumber()),
+             Form("%e",fHistoMax->GetNumber()));
   
   if ( CreateRawDataSource(uri) )
   {
@@ -330,6 +388,9 @@ AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
   
   TString filename;
   TString ocdbPath;
+  TString calibMode;
+  TString sxmin("0.0");
+  TString sxmax("4096.0");
   
   TObjArray* a = uri.Tokenize(";");
   
@@ -338,6 +399,23 @@ AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
   if ( a->GetLast() > 1 ) 
   {
     ocdbPath = static_cast<TObjString*>(a->At(2))->String();
+    if ( ocdbPath == " " ) ocdbPath = "";
+  }
+
+  if ( a->GetLast() > 2 ) 
+  {
+    calibMode = static_cast<TObjString*>(a->At(3))->String();
+    if ( calibMode == " " ) calibMode = "";
+  }
+
+  if ( a->GetLast() > 3 ) 
+  {
+    sxmin = static_cast<TObjString*>(a->At(4))->String();
+  }
+
+  if ( a->GetLast() > 4 ) 
+  {
+    sxmax = static_cast<TObjString*>(a->At(5))->String();
   }
   
   AliRawReader* rawReader = 0x0;
@@ -356,27 +434,39 @@ AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
          
     rawReader = new AliRawReaderRoot(filename.Data());
   }
-  else if ( uri.Contains(TRegexp(".raw")) )
+  else 
   {
+    /// Anything not .root is supposed to be DATE file
     AliDebug(1,"Using RawReaderDate");
     rawReader = new AliRawReaderDate(filename.Data());
   }
-  else
+
+  /// Basic test to see if the file is correct
+  Bool_t ok = rawReader->NextEvent();
+  if (!ok)
   {
-    AliError(Form("Don't know how to open that file : %s\nURI=%s",filename.Data(),uri.Data()));
+    AliError(Form("File %s does not seem to be a raw data file",filename.Data()));
+    fFilePath->SetText("");
     return kFALSE;
   }
   
+  rawReader->RewindEvents();
+  
   AliMUONVTrackerDataMaker* reader(0x0);
   Bool_t histogram(kFALSE);
   
+  if ( uri.Contains(TRegexp("^H")) ) histogram = kTRUE;
+
   if ( ocdbPath.Length() > 0 ) 
   {
-    reader = new AliMUONTrackerCalibratedDataMaker(rawReader,ocdbPath.Data());
+    reader = new AliMUONTrackerCalibratedDataMaker(rawReader,ocdbPath.Data(),
+                                                   calibMode.Data(),
+                                                   histogram,
+                                                   sxmin.Atof(),
+                                                   sxmax.Atof());
   }
   else
   {
-    if ( uri.Contains(TRegexp("^H")) ) histogram = kTRUE;
     reader = new AliMUONTrackerRawDataMaker(rawReader,histogram);
   }
   
@@ -390,11 +480,9 @@ AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
   
   env->Set(fgkNumberOfDataSourcesKey,n+1);
   
-  TString ds(Form("%sRAW;%s;%s",(histogram ? "H":""),filename.Data(),ocdbPath.Data()));
-  
-  env->Set(Form(fgkDataSourceURIKey,n),ds.Data());
+  env->Set(Form(fgkDataSourceURIKey,n),uri.Data());
   
-  AddRecentSource(ds.Data());
+  AddRecentSource(uri.Data());
   
   env->Save();
 
@@ -409,6 +497,16 @@ AliMUONPainterDataSourceFrame::DataReaderWasRegistered(AliMUONVTrackerDataMaker*
   
   AliMUONPainterDataSourceItem* item = new AliMUONPainterDataSourceItem(fDataReaders,100,20,reader);
       
+  item->Connect("StartRunning()",
+                "AliMUONPainterDataSourceFrame",
+                this,
+                Form("StartRunning(=(AliMUONPainterDataSourceItem*)(0x%x))",item));
+
+  item->Connect("StopRunning()",
+                "AliMUONPainterDataSourceFrame",
+                this,
+                Form("StopRunning(=(AliMUONPainterDataSourceItem*)(0x%x))",item));
+  
   fDataReaders->AddFrame(item);
   
   fItems->Add(item);
@@ -419,12 +517,12 @@ AliMUONPainterDataSourceFrame::DataReaderWasRegistered(AliMUONVTrackerDataMaker*
 
 //_____________________________________________________________________________
 void 
-AliMUONPainterDataSourceFrame::DataReaderWasUnregistered(AliMUONVTrackerDataMaker* reader)
+AliMUONPainterDataSourceFrame::DataReaderWasUnregistered(AliMUONVTrackerDataMaker* /*reader*/)
 {
   /// Update ourselves as a new data reader was deleted
   
-//  AliInfo(Form("%s",reader->GetName()));
-          
+  // here we should find which (if any) datasourceitem has this reader, and remove it
+  
 }
 
 //_____________________________________________________________________________
@@ -435,6 +533,14 @@ AliMUONPainterDataSourceFrame::OpenFileDialog()
   
   TGFileInfo fileInfo;
   
+  const char* fileTypes[] = { 
+    "ROOT files","*.root",
+    "DATE files","*.raw",
+    "All files","*",
+    0,0 };
+  
+  fileInfo.fFileTypes = fileTypes;
+  
   new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
                    kFDOpen,&fileInfo);
   
@@ -453,7 +559,8 @@ AliMUONPainterDataSourceFrame::OpenRecentSource()
 
   TString uri(t->GetText()->GetString());
   
-  if ( uri.Contains(TRegexp("^RAW")) || uri.Contains(TRegexp("^HRAW")) )
+  if ( uri.Contains(TRegexp("^RAW")) || uri.Contains(TRegexp("^HRAW")) || 
+       uri.Contains(TRegexp("^CAL")) || uri.Contains(TRegexp("^HCAL")) )
   {
     CreateRawDataSource(uri);
   }
@@ -465,3 +572,32 @@ AliMUONPainterDataSourceFrame::OpenRecentSource()
   fRecentSources->Select(-1);
 }
 
+//_____________________________________________________________________________
+void
+AliMUONPainterDataSourceFrame::StartRunning(AliMUONPainterDataSourceItem* item)
+{
+  /// One data source starts running. Disable the Run button of the other ones
+  TIter next(fItems);
+  AliMUONPainterDataSourceItem* o;
+  while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
+  {
+    if ( o != item ) 
+    {
+      o->DisableRun();
+    }
+  }
+}  
+
+//_____________________________________________________________________________
+void
+AliMUONPainterDataSourceFrame::StopRunning(AliMUONPainterDataSourceItem* /*item*/)
+{
+  /// One data source stops running. Enable the Run button of all items
+  TIter next(fItems);
+  AliMUONPainterDataSourceItem* o;
+  while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
+  {
+    o->EnableRun();
+  }
+}
+  
index e51b20cea7960df4f92353c81cf47b240e22d495..3c44d9be7d03938a450dc82e2c17501c002dd4a5 100644 (file)
@@ -16,6 +16,7 @@
 #  include <TGFrame.h>
 #endif
 
+class AliMUONPainterDataSourceItem;
 class AliMUONVTrackerDataMaker;
 class TGCheckButton;
 class TGComboBox;
@@ -40,10 +41,16 @@ public:
   
   void DataReaderWasUnregistered(AliMUONVTrackerDataMaker* reader);
 
+  void HistogramButtonClicked();
+  
   void OpenFileDialog();
   
   void OpenRecentSource();
-  
+
+  void StartRunning(AliMUONPainterDataSourceItem* item);
+
+  void StopRunning(AliMUONPainterDataSourceItem* item);
+
 private:
   /// Not implemented
   AliMUONPainterDataSourceFrame(const AliMUONPainterDataSourceFrame& rhs);
@@ -67,8 +74,12 @@ private:
   TGCompositeFrame* fRawSelector21; ///< idem
   TGCompositeFrame* fRawSelector22; ///< idem
   TGCompositeFrame* fRawSelector23; ///< idem
-  TGCheckButton* fCalibrateButton; ///< to trig calibration of raw data
+  TGCheckButton* fCalibrateNoGain; ///< to trig calibration of raw data (only 0 suppression)
+  TGCheckButton* fCalibrateGainConstantCapa; ///< to trig calibration of raw data (0-supp and gain w/ constant capacitance)
+  TGCheckButton* fCalibrateGain; ///< to trig calibration of raw data (full blown calibration)
   TGCheckButton* fHistogramButton; ///< to trig histogramming of raw data
+  TGNumberEntry* fHistoMin; ///< xmin of histo to make
+  TGNumberEntry* fHistoMax; ///< xmax of histo to make
   TGTextEntry* fRawOCDBPath; ///< OCDB path for raw data calibration
   
   TGGroupFrame* fOCDBSelector; ///< to select a new OCDB data source
index bfeb2c14dc41e510c06021a854e66248ad0ca8ee..b47b1da0e34b3343147ba25d8c71b8d689ccf9f5 100644 (file)
@@ -69,11 +69,11 @@ AliMUONPainterDataSourceItem::AliMUONPainterDataSourceItem(const TGWindow* p,
   fDataReader(reader),
   fSourceName(new TGLabel(this,reader->Data()->Name())),
   fSource(new TGLabel(this,reader->Source().Data())),
-  fNumberOfEvents(new TGLabel(this,"0")),
+  fNumberOfEvents(new TGLabel(this,Form("%10d",0))),
   fRun(new TGTextButton(this,"Run")),
   fStop(new TGTextButton(this,"Stop")),
   fRewind(new TGTextButton(this,"Rewind")),
-  fRemove(new TGTextButton(this,"Remove")),
+  fRemove(0x0),//new TGTextButton(this,"Remove")),
   fThread(0x0),
   fShouldReset(kFALSE)
 {
@@ -99,10 +99,10 @@ AliMUONPainterDataSourceItem::AliMUONPainterDataSourceItem(const TGWindow* p,
                      this,
                      "Rewind()");
     
-    fRemove->Connect("Clicked()",
-                     "AliMUONPainterDataSourceItem",
-                     this,
-                     "Remove()");
+//    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));
@@ -110,7 +110,7 @@ AliMUONPainterDataSourceItem::AliMUONPainterDataSourceItem(const TGWindow* p,
     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(fRemove,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5));    
     
     reader->Data()->Connect("NumberOfEventsChanged()",
                             "AliMUONPainterDataSourceItem",
@@ -127,13 +127,23 @@ AliMUONPainterDataSourceItem::~AliMUONPainterDataSourceItem()
   delete fThread;
 }
 
+
 //_____________________________________________________________________________
-void
-AliMUONPainterDataSourceItem::Remove()
-{
-  /// Remove button was clicked
+void 
+AliMUONPainterDataSourceItem::EnableRun() 
+{ 
+  /// Enable run button
+  fRun->SetEnabled(kTRUE); 
 }
-
+  
+//_____________________________________________________________________________
+void 
+AliMUONPainterDataSourceItem::DisableRun() 
+{ 
+  /// Disable run button
+  fRun->SetEnabled(kFALSE); 
+}
+  
 //_____________________________________________________________________________
 void
 AliMUONPainterDataSourceItem::Reset()
@@ -171,13 +181,15 @@ AliMUONPainterDataSourceItem::Run()
 {
   /// Run button was clicked
   
+  StartRunning();
+  
   if ( fShouldReset ) 
   {
     Reset();
     fShouldReset = kFALSE;
   }
   
-  fRemove->SetEnabled(kFALSE);
+//  fRemove->SetEnabled(kFALSE);
   
   if (!fThread)
   {
@@ -199,11 +211,14 @@ AliMUONPainterDataSourceItem::Stop()
 {
   /// Stop button was clicked
   
+  StopRunning();
+  
   fDataReader->SetRunning(kFALSE);
   
   fStop->SetEnabled(kFALSE);
   fRun->SetEnabled(kTRUE);
-  fRemove->SetEnabled(kTRUE);
+
+  //  fRemove->SetEnabled(kTRUE);
 }
 
 //_____________________________________________________________________________
@@ -214,3 +229,19 @@ AliMUONPainterDataSourceItem::Update()
   
   fNumberOfEvents->SetText(Form("%10d",fDataReader->Data()->NumberOfEvents()));
 }
+
+//_____________________________________________________________________________
+void
+AliMUONPainterDataSourceItem::StartRunning()
+{
+  /// Signal we start to run
+  Emit("StartRunning()");
+}  
+
+//_____________________________________________________________________________
+void
+AliMUONPainterDataSourceItem::StopRunning()
+{
+  /// Signal we stop to run
+  Emit("StopRunning()");
+}
index dd193484a758167eb852a10a2ec40ad9b104a0ce..386ebcafeaa14676c7412e52b9bad11c25957fda 100644 (file)
@@ -35,12 +35,23 @@ public:
   
   void Rewind();
   
-  void Remove();
+//void Remove(); //*SIGNAL*
   
   void Update();
   
   void Reset();
   
+  /// Return data source reader
+  AliMUONVTrackerDataMaker* DataMaker() const { return fDataReader; }
+  
+  void EnableRun();
+  
+  void DisableRun();
+  
+  void StartRunning(); //*SIGNAL*
+
+  void StopRunning(); //*SIGNAL*
+
 private:
   /// Not implemented
   AliMUONPainterDataSourceItem(const AliMUONPainterDataSourceItem& rhs);
index 76ffe77e8563ca41131f5ab46236f3eec4723c80..c17e941ad2243ac6d2714a9c3a3665326f2f2a33 100644 (file)
@@ -399,6 +399,14 @@ AliMUONPainterMasterFrame::ShiftClicked(AliMUONVPainter* painter, Double_t*)
   PainterMatrixWantToShow(matrix);
 }
 
+//_____________________________________________________________________________
+void 
+AliMUONPainterMasterFrame::SaveAs(const char* filename, Option_t* option) const
+{
+  /// Save painter matrix (in the sense of "print") in filename
+  fPainterMatrixFrame->SaveAs(filename,option);
+}
+
 //_____________________________________________________________________________
 void
 AliMUONPainterMasterFrame::Update()
index 21e3074ab6d6b3d2d321805085ad477cf43131df..7bc4856c41bb297873d2825a3b1ceec48e2abb72 100644 (file)
@@ -52,6 +52,8 @@ public:
 
   void AttributesChanged(AliMUONAttPainter* newValues);
   
+  void SaveAs(const char* filename = "", Option_t* option = "") const;
+  
 private:
   /// not implemented
   AliMUONPainterMasterFrame(const AliMUONPainterMasterFrame& rhs);
index efea6cc28f74604a8d76f20d8535de9f64510ba6..61c0d3a8d84642d48a1c276ab82e0142dc1794dc 100644 (file)
@@ -325,8 +325,7 @@ AliMUONPainterMatrixFrame::EventInfo(Int_t event, Int_t px ,Int_t py, TObject* o
   
 //  cout << "EventInfo : event " << event << " px " << px << " py " << py
 //    << " object " << object << " " << object->GetName() << endl;
-//  
-//  
+// 
   if ( event == 7 ) 
   {
     if ( object->InheritsFrom("AliMUONVPainter") )
@@ -469,6 +468,14 @@ AliMUONPainterMatrixFrame::OutlineButtonWasClicked(Int_t id)
   UpdateInterface(kFALSE);
 }
 
+//_____________________________________________________________________________
+void 
+AliMUONPainterMatrixFrame::SaveAs(const char* filename, Option_t* option) const
+{
+  /// Save painter matrix (in the sense of "print") in filename
+  fView->GetCanvas()->SaveAs(filename,option);
+}
+
 //_____________________________________________________________________________
 void
 AliMUONPainterMatrixFrame::TitleHasChanged(const char* title)
index d50f76cdc3592aef20261139fb5cca4436c23fc6..bb932ea7c028e76da08c3dd4c639c9540d01371e 100644 (file)
@@ -69,6 +69,8 @@ public:
   /// Get the matrix pointer
   AliMUONPainterMatrix* Matrix() const { return fPainterMatrix; }
   
+  void SaveAs(const char* filename="", Option_t* option="") const;
+
 private:
   /// not implemented
   AliMUONPainterMatrixFrame(const AliMUONPainterMatrixFrame& rhs);
index 68afbfb632ace896df50f32f17a987432b4bf848..9a81a0ac15ab6f2569afbc51a8f2ca572e38d67c 100644 (file)
 // $Id$
 
 #include "AliMUONSparseHisto.h"
-#include <TString.h>
+
 #include <Riostream.h>
 #include <TH1.h>
+#include <TMath.h>
+#include <TString.h>
 
 /// \class AliMUONSparseHisto
 ///
-/// Tiny histogram-like class to hold adc distributions of tracker data.
+/// Tiny histogram-like class to hold some distributions of tracker data.
 /// Only intent of this class is to minimize memory consumption, in
 /// order to fit a maximum number of channel histograms into memory.
 /// The rest is not supported ;-)
@@ -34,19 +36,27 @@ ClassImp(AliMUONSparseHisto)
 /// \endcond
 
 //______________________________________________________________________________
-AliMUONSparseHisto::AliMUONSparseHisto()
+AliMUONSparseHisto::AliMUONSparseHisto(Double_t xmin, Double_t xmax)
 : TObject(),
 fNbins(0),
-fArray(0x0)
+fArray(0x0),
+fXmin(xmin),
+fXmax(xmax),
+fFactor((1<<Nbits())/(xmax-xmin))
 {
   /// ctor
+  SetBit(kOverflow,0);
+  SetBit(kUnderflow,0);
 }
 
 //______________________________________________________________________________
 AliMUONSparseHisto::AliMUONSparseHisto(const AliMUONSparseHisto& rhs)
 : TObject(rhs),
 fNbins(0),
-fArray(0x0)
+fArray(0x0),
+fXmin(0.0),
+fXmax(0.0),
+fFactor(0.0)
 {
   /// copy ctor
   rhs.Copy(*this);
@@ -91,32 +101,61 @@ AliMUONSparseHisto::Copy(TObject& object) const
   delete[] h.fArray;
   h.fArray = 0x0;
   h.fNbins = GetNbins();
+  h.fXmin = Xmin();
+  h.fXmax = Xmax();
+  h.fFactor = Factor();
+  
   if ( GetNbins() > 0 )
   {
-    h.fArray = new Int_t[GetNbins()];
+    h.fArray = new UInt_t[GetNbins()];
     for ( Int_t i = 0; i < GetNbins(); ++i ) 
     {
-      h.fArray[i] = GetBinContent(i);
+      h.fArray[i] = GetBin(i);
     }
   }
 }
 
 //______________________________________________________________________________
-void 
-AliMUONSparseHisto::Decode(Int_t value, Int_t& adc, Int_t& count) const
+Double_t 
+AliMUONSparseHisto::DecodeValue(Int_t value) const
 {
-  /// Convert value into (adc,count) pair
-  
-  adc   = ( value & 0xFFF00000 ) >> 20;
-  count = ( value & 0x000FFFFF );
+  /// From internal integer to "original" double
+  return value/Factor() + Xmin();
 }
 
 //______________________________________________________________________________
 Int_t 
-AliMUONSparseHisto::Encode(Int_t adc, Int_t count) const
+AliMUONSparseHisto::EncodeValue(Double_t value) const
+{
+  /// From original double value to internal integer
+  return TMath::Nint(Factor()*(value-Xmin()));
+}
+
+//______________________________________________________________________________
+Int_t
+AliMUONSparseHisto::BinCenter(UInt_t x) const
+{
+  /// Extract binCenter part from x
+  
+  return ( x & 0xFFF00000 ) >> 20;
+}
+
+//______________________________________________________________________________
+Int_t
+AliMUONSparseHisto::BinContent(UInt_t x) const
 {
-  /// Convert (adc,count) into a single value
-  return ( ( adc & 0xFFF ) ) << 20 | ( count & 0xFFFFF );
+  /// Extract binContent part from x
+  
+  return (x & 0xFFFFF);
+}
+
+//______________________________________________________________________________
+UInt_t 
+AliMUONSparseHisto::Encode(Int_t binCenter, Int_t binContent) const
+{
+  /// Convert (binCenter,binContent) into a single value
+  
+  return ( ( binCenter & 0xFFF ) ) << 20 | ( ( binContent & 0xFFFFF ) );
 }
 
 //______________________________________________________________________________
@@ -127,12 +166,12 @@ AliMUONSparseHisto::Expand()
   if (!fArray || !fNbins) 
   {
     delete[] fArray;
-    fArray = new Int_t[1];
+    fArray = new UInt_t[1];
     fNbins = 1;
   }
   else
   {
-    Int_t* tmp = new Int_t[fNbins+1];
+    UInt_t* tmp = new UInt_t[fNbins+1];
     for ( Int_t i = 0; i < fNbins; ++i ) 
     {
       tmp[i] = fArray[i];
@@ -145,26 +184,40 @@ AliMUONSparseHisto::Expand()
 
 //______________________________________________________________________________
 Int_t 
-AliMUONSparseHisto::Fill(Int_t adc)
+AliMUONSparseHisto::Fill(Double_t value)
 {
   /// Fill
   
-  if ( adc < 0 || adc > 4095 ) return -1;
+  if ( value < Xmin() ) 
+  {
+    SetBit(kUnderflow,1);
+    return -1;
+  }
+  
+  if ( value > Xmax() ) 
+  {
+    SetBit(kOverflow,1);
+    return -1;
+  }
+  
+  Int_t ivalue = EncodeValue(value);
   
-  Int_t i = Find(adc);
+  Int_t i = Find(ivalue);
   
   if ( i < 0 ) 
   {
     Int_t n = fNbins;
     Expand();
-    fArray[n] = Encode(adc,1);
+    fArray[n] = Encode(ivalue,1);
     i = n;
   }
   else
   {
-    Int_t iadc,icontent;
-    Decode(fArray[i],iadc,icontent);
-    fArray[i] = Encode(adc,icontent+1);
+    Int_t bc = GetBinContent(i);
+    if ( bc < 0xFFFFF ) 
+    {
+      fArray[i] = Encode(ivalue,bc+1);
+    }
   }
     
   return i;
@@ -172,27 +225,50 @@ AliMUONSparseHisto::Fill(Int_t adc)
 
 //______________________________________________________________________________
 Int_t 
-AliMUONSparseHisto::Find(Int_t adc) const
+AliMUONSparseHisto::Find(Int_t binCenter) const
 {
-  /// Return the index in fArray of adc, or -1 if not found
+  /// Return the index in fArray of value, or -1 if not found
+  
   for ( Int_t i = 0; i < GetNbins(); ++i ) 
   {
-    Int_t content = GetBinContent(i);
-    Int_t iadc,value;
-    Decode(content,iadc,value);
-    if ( iadc == adc ) return i;
+    if ( binCenter == GetBinCenter(i) ) return i;
   }
   return -1;
 }
 
+//______________________________________________________________________________
+UInt_t 
+AliMUONSparseHisto::GetBin(Int_t bin) const
+{
+  /// Get bin, which is a compacted form of two integers : (binCenter,binContent)
+  /// where binCenter itself might be an integer-fied double value.
+  return fArray[bin];
+}
+
+//______________________________________________________________________________
+Double_t 
+AliMUONSparseHisto::GetBinCenter(Int_t bin) const
+{
+  /// Get bin center
+  if ( bin < 0 ) return -FLT_MAX;
+  if ( bin >= GetNbins() ) return FLT_MAX;
+  
+  UInt_t i = GetBin(bin);
+  
+  return DecodeValue(BinCenter(i));
+}
+
 //______________________________________________________________________________
 Int_t 
 AliMUONSparseHisto::GetBinContent(Int_t bin) const
 {
-  /// Get bin content. Note that the content is compacted, so you must
-  /// use Decode() method to get (adc,count) values.
-  if ( bin >= 0 && bin < GetNbins() ) return fArray[bin];
-  return 0;
+  /// Get bin content
+  
+  if ( bin < 0 || bin >= GetNbins() ) return 0xFFFFFFFF;
+
+  UInt_t i = GetBin(bin);
+
+  return BinContent(i);
 }
 
 //______________________________________________________________________________
@@ -203,7 +279,10 @@ AliMUONSparseHisto::Print(Option_t* opt) const
   Int_t id1 = ( GetUniqueID() & 0xFFFF0000 ) >> 16;
   Int_t id2 = GetUniqueID() & 0xFFFF;
   
-  cout << "(" << id1 << "," << id2 << ") n bins = " << GetNbins() << endl;
+  cout << "ID=(" << id1 << "," << id2 << ") n bins = " << GetNbins();
+  if ( HasUnderflow() ) cout << " has underflow(s)";
+  if ( HasOverflow() ) cout << " has overflow(s)";
+  cout << endl;
   
   TString sopt(opt);
   sopt.ToUpper();
@@ -212,11 +291,7 @@ AliMUONSparseHisto::Print(Option_t* opt) const
   {
     for ( Int_t i = 0; i < GetNbins(); ++i ) 
     {
-      Int_t content = GetBinContent(i);
-      Int_t adc,value;
-      Decode(content,adc,value);
-      cout << Form("i %4d content %10x adc %4d value %6d",i,content,adc,value)
-        << endl;
+      cout << Form("Bin (%10u) %e = %6d",GetBin(i),GetBinCenter(i),GetBinContent(i)) << endl;
     }
   }
 }
index af70755c0308e970da6041a3841a93bf6b876eab..61191cd4331abd3dba4fa1868cba7dae9a8b13ad 100644 (file)
@@ -8,7 +8,7 @@
 
 /// \ingroup graphics
 /// \class AliMUONSparseHisto
-/// \brief A very memory compact histogram to hold tracker ADC distributions
+/// \brief A very memory compact histogram to hold some tracker distributions
 /// 
 // Author Laurent Aphecetche, Subatech
 
 class AliMUONSparseHisto : public TObject
 {
 public:
-  AliMUONSparseHisto();
+  
+  enum 
+  {
+    kUnderflow = BIT(20),
+    kOverflow = BIT(21)
+  };
+  
+  AliMUONSparseHisto(Double_t xmin=0.0, Double_t xmax=4096.0); 
   AliMUONSparseHisto(const AliMUONSparseHisto& rhs);
   AliMUONSparseHisto& operator=(const AliMUONSparseHisto& rhs);
   
   virtual ~AliMUONSparseHisto();
   
-  Int_t Fill(Int_t adc);
+  Bool_t HasUnderflow() const { return TestBit(kUnderflow); }
+  
+  Bool_t HasOverflow() const { return TestBit(kOverflow); }
+  
+  Int_t Fill(Double_t value);
   
   /// Return number of bins we hold
   Int_t GetNbins() const { return fNbins; }
+
+  Double_t GetBinCenter(Int_t bin) const;
   
   Int_t GetBinContent(Int_t bin) const;
   
   virtual void Print(Option_t* opt="") const;
   
   virtual void Clear(Option_t* opt="");
+    
+  Int_t Find(Int_t binCenter) const;
   
-  void Decode(Int_t value, Int_t& adc, Int_t& count) const;
+  virtual void Copy(TObject& object) const;
+
+  /// Return max value of bincenter
+  Double_t Xmax() const { return fXmax; }
   
-  Int_t Encode(Int_t adc, Int_t count) const;
+  /// Return min value of bincenter
+  Double_t Xmin() const { return fXmin; }
   
-  Int_t Find(Int_t adc) const;
+  Int_t Nbits() const { return 12; }
   
-  virtual void Copy(TObject& object) const;
-
 private:
-      
-    void Expand();
+  
+  UInt_t Encode(Int_t binCenter, Int_t binContent) const;
+  
+  Double_t DecodeValue(Int_t value) const;
+  
+  Int_t EncodeValue(Double_t value) const;
+  
+  UInt_t GetBin(Int_t i) const;
+  
+  Int_t BinCenter(UInt_t x) const;
+  
+  Int_t BinContent(UInt_t x) const;
+  
+  void Expand();
+  
+  Double_t Factor() const { return fFactor; } 
   
 private:
 
   Int_t fNbins;  ///< number of bins we hold
 
   /// compacted content = (bin,value)
-  Int_t* fArray; //[fNbins] compacted content = (bin,value)
+  UInt_t* fArray; //[fNbins] compacted content = (bin,value)
+
+  Double_t fXmin; ///< min value of bincenter
+  Double_t fXmax; ///< max value of bincenter
+  
+  Double_t fFactor; ///< to go from double to int
   
-  ClassDef(AliMUONSparseHisto,1) // Sparse histogram-like class for ADC distributions
+  ClassDef(AliMUONSparseHisto,2) // Sparse histogram-like class for ADC distributions
 };
 
 #endif
index b72ca8ee6a9ab69be7bdb2de3bc64af0f05e4adc..e35317286fe972324d00a0b99d0ec57ec85de4e2 100644 (file)
@@ -49,7 +49,11 @@ Int_t AliMUONTrackerCalibratedDataMaker::fgkCounter(0);
 
 //_____________________________________________________________________________
 AliMUONTrackerCalibratedDataMaker::AliMUONTrackerCalibratedDataMaker(AliRawReader* reader,
-                                                       const char* cdbpath)
+                                                                     const char* cdbpath,
+                                                                     const char* calibMode,
+                                                                     Bool_t histogram,
+                                                                     Double_t xmin,
+                                                                     Double_t xmax)
 : AliMUONVTrackerDataMaker(),
   fRawReader(reader),
   fAccumulatedData(0x0),
@@ -62,8 +66,7 @@ AliMUONTrackerCalibratedDataMaker::AliMUONTrackerCalibratedDataMaker(AliRawReade
   fCalibrationData(0x0),
   fDigitStore(0x0), 
   fCDBPath(cdbpath),
-  fNumberOfEvents(0)
-{
+  fNumberOfEvents(0){
   /// Ctor
   reader->NextEvent(); // to be sure to get run number available
   
@@ -72,20 +75,40 @@ AliMUONTrackerCalibratedDataMaker::AliMUONTrackerCalibratedDataMaker(AliRawReade
   ++fgkCounter;
   
   Bool_t calibrate = ( fCDBPath.Length() > 0 );
-  
   TString name;
+  TString basename("RAW");
+  
+  if ( calibrate ) 
+  {
+    TString scalib(calibMode);
+    scalib.ToUpper();
+    if ( scalib == "GAIN" ) basename = "CALC";
+    if ( scalib == "NOGAIN" ) basename = "CALZ";
+    if ( scalib == "GAINCONSTANTCAPA" ) basename = "CALG";
+  }
   
   if (!runNumber)
   {
-    name = Form("%s(%d)",(calibrate ? "CAL" : "RAW"),fgkCounter);
+    name = Form("%s%s(%d)",
+                (histogram ? "H" : ""),
+                basename.Data(),
+                fgkCounter);
   }
   else
   {
-    name = Form("%s%d",(calibrate ? "CAL" : "RAW"),runNumber);
+    name = Form("%s%s%d",
+                (histogram ? "H" : ""),
+                basename.Data(),
+                runNumber);
   }
   
   fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1);
   fAccumulatedData->SetDimensionName(0,(calibrate ? "Calibrated charge" : "Raw charge"));
+  if ( histogram ) 
+  {
+    fAccumulatedData->MakeHistogramForDimension(0,kTRUE,xmin,xmax);
+    AliInfo(Form("Will histogram between %e and %e",xmin,xmax));
+  }
   
   reader->RewindEvents();
 
@@ -122,7 +145,7 @@ AliMUONTrackerCalibratedDataMaker::AliMUONTrackerCalibratedDataMaker(AliRawReade
       AliCDBManager::Instance()->SetDefaultStorage(storage);
     }
     
-    fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData);
+    fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,calibMode);
   }
 }
 
index ab054bcf26f5805170a7bc40cdaccdc6cd3f6242..9aa9a045c88e8a55879a831cdf86e716d7258745 100644 (file)
@@ -30,7 +30,12 @@ class AliMUONVDigitStore;
 class AliMUONTrackerCalibratedDataMaker : public AliMUONVTrackerDataMaker
 {
 public:
-  AliMUONTrackerCalibratedDataMaker(AliRawReader* reader = 0x0, const char* cdbpath=0x0);
+  AliMUONTrackerCalibratedDataMaker(AliRawReader* reader = 0x0, 
+                                    const char* cdbpath=0x0,
+                                    const char* calibMode=0x0,
+                                    Bool_t histogram=kFALSE,
+                                    Double_t xmin=0.0,
+                                    Double_t xmax=4096.0);
   virtual ~AliMUONTrackerCalibratedDataMaker();
   
   /// Whether we have a valid raw reader
index dbf97858fde738e0269080c248d419f64a4b0be0..b640b50296f0fcafe197841290ba5765754312b3 100644 (file)
@@ -34,7 +34,6 @@
 #include "AliMpHVNamer.h"
 #include "AliMpManuIterator.h"
 #include <Riostream.h>
-#include <TH1.h>
 #include <TMath.h>
 #include <TObjArray.h>
 #include <TObjString.h>
@@ -73,10 +72,12 @@ fExternalDimensionNames(new TObjArray(dimension)),
 fExternalDimension(dimension),
 fIsRunnable(runnable),
 fHistogramming(new Int_t[fExternalDimension]),
-fChannelHistos(0x0)
+fChannelHistos(0x0),
+fXmin(0.0),
+fXmax(0.0)
 {  
   /// ctor
-  memset(fHistogramming,0,sizeof(Int_t)); // histogramming is off by default. Use SetHistogramDimension to turn it on.
+  memset(fHistogramming,0,sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
   fExternalDimensionNames->SetOwner(kTRUE);
   fDimensionNames->SetOwner(kTRUE);  
   fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
@@ -532,285 +533,58 @@ AliMUONTrackerData::FillChannel(Int_t detElemId, Int_t manuId, Int_t manuChannel
 {
   /// Fill histogram of a given channel
   
-  AliMUONSparseHisto* h = GetChannelHisto(detElemId, manuId, manuChannel,dim);
+  AliMUONSparseHisto* h = GetChannelSparseHisto(detElemId, manuId, manuChannel,dim);
  
   h->Fill(static_cast<Int_t>(TMath::Nint(value)));
 }
 
 //_____________________________________________________________________________
-TH1*
-AliMUONTrackerData::CreateChannelHisto(Int_t detElemId, Int_t manuId, 
-                                       Int_t manuChannel, Int_t dim)
-{
-  /// 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 ( HasChannel(detElemId, manuId, manuChannel) && IsHistogrammed(dim) )
-  {
-    AliMUONSparseHisto* sh = GetChannelHisto(detElemId,manuId,manuChannel,dim);
-  
-    if ( sh ) 
-    {
-      TH1* h = new TH1I(Form("DE%04dMANU%04dCH%02d_%d",detElemId,manuId,manuChannel,dim),
-                        Form("Data=%s Dim=%s",GetName(),ExternalDimensionName(dim).Data()),
-                        4096,-0.5,4095.5);
-      
-      Add(*h,*sh);
-      return h;
-    }
-  }
-  return 0x0;
-}
-
-//_____________________________________________________________________________
-void
-AliMUONTrackerData::Add(TH1& h, const AliMUONSparseHisto& sh)
-{
-  /// Add sparse histo content to histogram.
-  
-  Double_t entries(h.GetEntries());
-  
-  for ( Int_t i = 0; i < sh.GetNbins(); ++i ) 
-  {
-    Int_t x = sh.GetBinContent(i);
-    Int_t adc, count;
-    sh.Decode(x,adc,count);
-    h.Fill(adc,count);
-    entries += count;
-  }
-  
-  h.SetEntries(entries);
-}
-
-//_____________________________________________________________________________
-TH1*
-AliMUONTrackerData::CreateHisto(const char* name, Int_t dim) const
-{
-  /// Create a single histogram
-  return new TH1I(name,Form("Data=%s Dim=%s",GetName(),ExternalDimensionName(dim).Data()),
-                  4096,-0.5,4095.5);
-}
-
-//_____________________________________________________________________________
-TH1*
-AliMUONTrackerData::CreateBusPatchHisto(Int_t busPatchId, Int_t dim)
-{
-  /// 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 ( HasBusPatch(busPatchId) && IsHistogrammed(dim)) 
-  {
-    h = CreateHisto(Form("BP%04d_%d",busPatchId,dim),dim);
-    AddBusPatchHisto(*h,busPatchId,dim);
-  }
-  
-  return h;
-}  
-//_____________________________________________________________________________
-void
-AliMUONTrackerData::AddBusPatchHisto(TH1& h, Int_t busPatchId, Int_t dim)
-{
-  /// Add data from one bus patch to the histogram
-      
-  if ( HasBusPatch(busPatchId ) )
-  {
-    AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
-    for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i ) 
-    {
-      Int_t manuId = busPatch->GetManuId(i);
-      AddManuHisto(h,busPatch->GetDEId(),manuId,dim);
-    }
-  }
-}
-
-
-//_____________________________________________________________________________
-TH1*
-AliMUONTrackerData::CreateDEHisto(Int_t detElemId, Int_t dim)
-{
-  /// 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...
-  
-  TH1* h(0x0);
-  
-  if ( HasDetectionElement(detElemId) && IsHistogrammed(dim) ) 
-  {
-    h = CreateHisto(Form("DE%04d-%d",detElemId,dim),dim);
-    AddDEHisto(*h,detElemId,dim);
-  }
-  
-  return h;
-}
-
-//_____________________________________________________________________________
-void
-AliMUONTrackerData::AddDEHisto(TH1& h, Int_t detElemId, Int_t dim)
+AliMUONSparseHisto*
+AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId, 
+                                          Int_t manuChannel, Int_t dim) const
 {
-  /// Add data from one detection element to the histogram
+  /// Get histogram of a given channel
   
-  if ( HasDetectionElement(detElemId) )
-  {
-    AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
-    for ( Int_t i = 0; i < de->GetNofBusPatches(); ++ i ) 
-    {
-      Int_t busPatchId = de->GetBusPatchId(i);
-      AddBusPatchHisto(h,busPatchId,dim);
-    }
-  }
-}
-
-//_____________________________________________________________________________
-TH1*
-AliMUONTrackerData::CreateManuHisto(Int_t detElemId, Int_t manuId, Int_t dim)
-{
-  /// 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...
+  if (!fChannelHistos) return 0x0;
   
-  TH1* h(0x0);
+  AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fChannelHistos->FindObject(detElemId,manuId));
+  if (!m) return 0x0;
   
-  if ( HasManu(detElemId, manuId) && IsHistogrammed(dim) ) 
-  {
-    h = CreateHisto(Form("DE%04dMANU%04d_%d",detElemId,manuId,dim),dim);
-    AddManuHisto(*h,detElemId,manuId,dim);
-  }
+  UInt_t uid = ( manuChannel << 16 ) | dim;
   
-  return h;
-}
-
-//_____________________________________________________________________________
-void
-AliMUONTrackerData::AddManuHisto(TH1& h, Int_t detElemId, Int_t manuId, Int_t dim)
-{
-  /// Add data from a given manu to histogram
-  
-  if ( HasManu(detElemId,manuId) )
-  {
-    for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) 
-    {
-      if ( HasChannel(detElemId,manuId,i) )
-      {
-        AliMUONSparseHisto* sh = GetChannelHisto(detElemId,manuId,i,dim);
-      
-        if ( sh ) 
-        {      
-          Add(h,*sh);
-        }
-      }
-    }
-  }
-}
-
-//_____________________________________________________________________________
-TH1*
-AliMUONTrackerData::CreatePCBHisto(Int_t /*detElemId*/, Int_t /*pcbIndex*/, Int_t /*dim*/)
-{
-  /// Create histogram of a given PCB. 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 ( HasPCB(detElemId, pcbIndex) && IsHistogrammed(dim)) 
-//  {
-//    h = CreateHisto(Form("DE%04dPCB1d_%d",detElemId,pcbIndex,dim),dim);
-//  }
-//  
-//  return h;
-
-  AliWarning("Not implemented (is it needed ?)");
-  return 0x0;
-}
-
-//_____________________________________________________________________________
-TH1*
-AliMUONTrackerData::CreateChamberHisto(Int_t chamberId, Int_t dim)
-{
-  /// 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 ( HasChamber(chamberId) && IsHistogrammed(dim))
-  {
-    h = CreateHisto(Form("CHAMBER%02d_%d",chamberId,dim),dim);
-    AliMpDEIterator it;
-    it.First(chamberId);
-    while ( !it.IsDone() )
-    {
-      Int_t detElemId = it.CurrentDEId();
-      AddDEHisto(*h,detElemId,dim);
-      it.Next();
-    }
-  }
+  AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
   
   return h;
 }
 
 //_____________________________________________________________________________
 AliMUONSparseHisto*
-AliMUONTrackerData::GetChannelHisto(Int_t detElemId, Int_t manuId, 
-                                    Int_t manuChannel, Int_t dim)
+AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId, 
+                                          Int_t manuChannel, Int_t dim)
 {
-  /// Get histogram of a given channel
+  /// Get histogram of a given channel. Create it if necessary
   
   if (!fChannelHistos) fChannelHistos = new AliMUON2DMap(kTRUE);
   
-  TObjArray* dimArray = static_cast<TObjArray*>(fChannelHistos->FindObject(detElemId,manuId));
-  if (!dimArray)
+  AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fChannelHistos->FindObject(detElemId,manuId));
+  if (!m)
   {
-    dimArray = new TObjArray(fExternalDimension);
-    dimArray->SetUniqueID( ( manuId << 16 ) | detElemId );
-    fChannelHistos->Add(dimArray);
+    m = new AliMUON1DMap(AliMpConstants::ManuNofChannels()); // start with only 1 dim
+    m->SetUniqueID( ( manuId << 16 ) | detElemId );
+    fChannelHistos->Add(m);
   }
   
-  TObjArray* channels = static_cast<TObjArray*>(dimArray->UncheckedAt(dim));
-  if (!channels)
-  {
-    channels = new TObjArray(AliMpConstants::ManuNofChannels());
-    dimArray->AddAt(channels,dim);
-  }
+  UInt_t uid = ( manuChannel << 16 ) | dim;
   
-  AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(channels->UncheckedAt(manuChannel));
+  AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
   if (!h)
   {
-    h = new AliMUONSparseHisto;
-    h->SetUniqueID(( manuChannel << 16 ) | dim);
-    channels->AddAt(h,manuChannel);
+    h = new AliMUONSparseHisto(fXmin,fXmax);
+    
+    h->SetUniqueID(uid);
+    
+    m->Add(h);
   }
-  
-  return h;
-// below is an alternate implementation, using a 1DMap, which *seems* to be
-// slightly SLOWER.
-//
-//  AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fChannelHistos->FindObject(detElemId,manuId));
-//  if (!m)
-//  {
-//    m = new AliMUON1DMap(kFALSE);
-//    m->SetUniqueID( ( manuId << 16 ) | detElemId );
-//    fChannelHistos->Add(m);
-//  }
-//  
-//  UInt_t uid = ( manuChannel << 16 ) | dim;
-//  
-//  AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
-//  if (!h)
-//  {
-//    h = new AliMUONSparseHisto;
-//    
-//    h->SetUniqueID(uid);
-//    
-//    m->Add(h);
-//  }
 
   return h;
 }
@@ -1099,7 +873,7 @@ AliMUONTrackerData::SetDimensionName(Int_t index, const char* name)
 
 //_____________________________________________________________________________
 void 
-AliMUONTrackerData::SetHistogramDimension(Int_t index, Bool_t value)
+AliMUONTrackerData::MakeHistogramForDimension(Int_t index, Bool_t value, Double_t xmin, Double_t xmax)
 {
   /// decide to make histos for a given dimension
   if ( index >= ExternalDimension() ) 
@@ -1109,6 +883,8 @@ AliMUONTrackerData::SetHistogramDimension(Int_t index, Bool_t value)
   }
   
   fHistogramming[index] = value;
+  fXmin = xmin;
+  fXmax = xmax;
 }
 
 //_____________________________________________________________________________
index d34f41c44ca591bfedba77fd78971ca9b30019c5..fd4168b251899b4c3fb68005fa4ca611b73493cd 100644 (file)
@@ -20,7 +20,6 @@ class AliMUONSparseHisto;
 class AliMUONVCalibParam;
 class AliMUONVStore;
 class AliMpDetElement;
-class TH1;
 
 class AliMUONTrackerData : public AliMUONVTrackerData
 {
@@ -67,6 +66,12 @@ public:
   /// Returns the number of dimensions (i.e. the number of values) each element has
   virtual Int_t NumberOfDimensions() const;
   
+  /// The number of values we are inputting
+  virtual Int_t ExternalDimension() const { return fExternalDimension; }
+
+  /// Convert from internal to external dimension
+  virtual Int_t InternalToExternal(Int_t dim) const { return dim/2; }
+
   /// Returns the number of events we have seen so far
   virtual Int_t NumberOfEvents() const { return fNevents; }
   
@@ -81,29 +86,21 @@ public:
 
   Bool_t CanHistogram() const { return kTRUE; }
   
-  void SetHistogramDimension(Int_t index, Bool_t value);
+  void MakeHistogramForDimension(Int_t index, Bool_t value, Double_t xmin=0.0, Double_t xmax=4096.0);
   
-  TH1* CreateChannelHisto(Int_t detElemId, Int_t manuId, 
-                          Int_t manuChannel, Int_t dim=0);
+  virtual void HistogramRange(Double_t& xmin, Double_t& xmax) const { xmin = fXmin; xmax = fXmax; }
 
-  TH1* CreateBusPatchHisto(Int_t busPatchId, Int_t dim=0);
+  AliMUONSparseHisto* GetChannelSparseHisto(Int_t detElemId, Int_t manuId, 
+                                            Int_t manuChannel, Int_t dim=0);
   
-  TH1* CreateDEHisto(Int_t detElemId, Int_t dim=0);
+  virtual AliMUONSparseHisto* GetChannelSparseHisto(Int_t detElemId, Int_t manuId, 
+                                                    Int_t manuChannel, Int_t dim=0) const;
 
-  TH1* CreateManuHisto(Int_t detElemId, Int_t manuId, Int_t dim=0);
-
-  TH1* CreatePCBHisto(Int_t detElemId, Int_t pcbIndex, Int_t dim=0);
-  
-  TH1* CreateChamberHisto(Int_t chamberId, Int_t dim=0);
-  
 private:
     
   void FillChannel(Int_t detElemId, Int_t manuId, Int_t manuChannel,
                    Int_t dim, Double_t value);
 
-  AliMUONSparseHisto* GetChannelHisto(Int_t detElemId, Int_t manuId, 
-                                      Int_t manuChannel, Int_t dim=0);
-  
   AliMUONVCalibParam* BusPatchParam(Int_t busPatch, Bool_t create=kFALSE) const;
 
   AliMUONVCalibParam* CreateBusPatchParam(Int_t busPatch) const;
@@ -133,22 +130,15 @@ private:
   /// Index of the dimension containing the occupancy number
   virtual Int_t IndexOfOccupancyDimension() const { return fDimension - 2; }
 
+  /// Whether we have histograms for a given dimension, or not
+  virtual Bool_t IsHistogrammed(Int_t dim) const { return ( fHistogramming[dim] > 0 ); }
+
 private:
   /// Not implemented
   AliMUONTrackerData(const AliMUONTrackerData& rhs);
   /// Not implemented
   AliMUONTrackerData& operator=(const AliMUONTrackerData& rhs);
   
-  void Add(TH1& h, const AliMUONSparseHisto& sh);
-  
-  void AddManuHisto(TH1& h, Int_t detElemId, Int_t manuId, Int_t dim);
-
-  void AddBusPatchHisto(TH1& h, Int_t busPatchId, Int_t dim);
-
-  void AddDEHisto(TH1& h, Int_t detElemId, Int_t dim);
-  
-  TH1* CreateHisto(const char* name, Int_t dim) const;
-
   AliMUONVCalibParam* CreateDouble(const AliMUONVCalibParam& param) const;
 
   Int_t GetParts(AliMUONVCalibParam* external,
@@ -171,13 +161,7 @@ private:
   
   /// The number of values we actually *store* for each item
   Int_t Dimension() const { return fDimension; }
-
-  /// The number of values we are inputting
-  Int_t ExternalDimension() const { return fExternalDimension; }
-  
-  /// Whether we have histograms for a given dimension, or not
-  Bool_t IsHistogrammed(Int_t dim) const { return ( fHistogramming[dim] > 0 ); }
-  
+    
 private:
     
   AliMUONVStore* fChannelValues; ///< the channel store
@@ -195,11 +179,12 @@ private:
   /// whether we should histogram the dimension(s)
   Int_t* fHistogramming; //[fExternalDimension] whether we should histogram the dimension(s)
   AliMUONVStore* fChannelHistos; ///< the channel histograms
-  
+  Double_t fXmin; ///< min x value for histograms
+  Double_t fXmax; ///< max x value for histograms
   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,2) // Implementation of AliMUONVTrackerData
+  ClassDef(AliMUONTrackerData,3) // Implementation of AliMUONVTrackerData
 };
 
 #endif
diff --git a/MUON/AliMUONTrackerDataHistogrammer.cxx b/MUON/AliMUONTrackerDataHistogrammer.cxx
new file mode 100644 (file)
index 0000000..0d74f40
--- /dev/null
@@ -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 "AliMUONTrackerDataHistogrammer.h"
+
+#include "AliMUONPainterGroup.h"
+#include "AliMUONSparseHisto.h"
+#include "AliMUONVPainter.h"
+#include "AliMUONVTrackerData.h"
+#include "AliMpBusPatch.h"
+#include "AliMpConstants.h"
+#include "AliMpDDLStore.h"
+#include "AliMpDEIterator.h"
+#include "AliMpDetElement.h"
+#include "AliMpManuUID.h"
+#include <TH1.h>
+#include <TObjArray.h>
+
+///\class AliMUONTrackerDataHistogrammer
+///
+/// Class to generate histograms from AliMUONVTrackerData 
+/// (and AliMUONVPainter) objects
+///
+/// \author Laurent Aphecetche, Subatech
+///
+
+///\cond CLASSIMP
+ClassImp(AliMUONTrackerDataHistogrammer)
+///\endcond CLASSIMP
+
+//_____________________________________________________________________________
+AliMUONTrackerDataHistogrammer::AliMUONTrackerDataHistogrammer(const AliMUONVTrackerData& data,
+                                                               Int_t dim)
+: TObject(),
+fData(data),
+fDim(dim)
+{
+  /// ctor
+}
+
+//_____________________________________________________________________________
+AliMUONTrackerDataHistogrammer::~AliMUONTrackerDataHistogrammer()
+{
+  /// dtor
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTrackerDataHistogrammer::Add(TH1& h, const AliMUONSparseHisto& sh) const
+{
+  /// Add sparse histo content to histogram.
+  
+  Double_t entries(h.GetEntries());
+  
+  for ( Int_t i = 0; i < sh.GetNbins(); ++i ) 
+  {
+    Int_t count = sh.GetBinContent(i);
+    
+    h.Fill(sh.GetBinCenter(i),count);
+    
+    entries += count;
+  }
+  
+  h.SetEntries(entries);
+  
+  if (sh.HasUnderflow()) h.SetBinContent(0,1);
+  if (sh.HasOverflow()) h.SetBinContent(h.GetNbinsX()+1,1);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTrackerDataHistogrammer::AddBusPatchHisto(TH1& h, Int_t busPatchId) const
+{
+  /// Add data from one bus patch to the histogram
+  
+  if ( fData.HasBusPatch(busPatchId ) )
+  {
+    AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
+    for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i ) 
+    {
+      Int_t manuId = busPatch->GetManuId(i);
+      AddManuHisto(h,busPatch->GetDEId(),manuId);
+    }
+  }
+}
+//_____________________________________________________________________________
+void
+AliMUONTrackerDataHistogrammer::AddDEHisto(TH1& h, Int_t detElemId) const
+{
+  /// Add data from one detection element to the histogram
+  
+  if ( fData.HasDetectionElement(detElemId) )
+  {
+    AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
+    for ( Int_t i = 0; i < de->GetNofBusPatches(); ++ i ) 
+    {
+      Int_t busPatchId = de->GetBusPatchId(i);
+      AddBusPatchHisto(h,busPatchId);
+    }
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTrackerDataHistogrammer::AddManuHisto(TH1& h, Int_t detElemId, Int_t manuId) const
+{
+  /// Add data from a given manu to histogram
+  
+  if ( fData.HasManu(detElemId,manuId) )
+  {
+    for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) 
+    {
+      if ( fData.HasChannel(detElemId,manuId,i) )
+      {
+        AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,i);
+        
+        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, 
+                                                   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) )
+  {
+    AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,manuChannel);
+    
+    if ( sh ) 
+    {
+      TH1* h = CreateHisto(Form("DE%04dMANU%04dCH%02d_%d",detElemId,manuId,manuChannel,fDim));
+      if (h ) 
+      {
+        Add(*h,*sh);
+      }
+      return h;
+    }
+  }
+  return 0x0;
+}
+
+//_____________________________________________________________________________
+TH1*
+AliMUONTrackerDataHistogrammer::CreateDEHisto(Int_t detElemId) 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...
+  
+  TH1* h(0x0);
+  
+  if ( fData.HasDetectionElement(detElemId) && fData.IsHistogrammed(fDim) ) 
+  {
+    h = CreateHisto(Form("DE%04d-%d",detElemId,fDim));
+    if (h) AddDEHisto(*h,detElemId);
+  }
+  
+  return h;
+}
+
+//_____________________________________________________________________________
+TH1* 
+AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter)
+{
+  /// Create an histogram, from given dim of given data, 
+  /// for all the channels handled by painter
+
+  AliMUONPainterGroup* group = painter.Master()->PlotterGroup();
+  
+  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);
+
+  TObjArray manuArray;
+  
+  painter.FillManuList(manuArray);
+  
+  AliMpManuUID* mid;
+  TIter next(&manuArray);
+  
+  TH1* histo = tdh.CreateHisto(Form("%s-%s",painter.PathName().Data(),painter.Attributes().GetName()));
+  
+  while ( ( mid = static_cast<AliMpManuUID*>(next()) ) )
+  {
+    TH1* h = tdh.CreateManuHisto(mid->DetElemId(),mid->ManuId());
+    if ( h ) 
+    {
+      histo->Add(h);
+    }
+    delete h;
+  }
+  
+  return histo;
+}
+
+//_____________________________________________________________________________
+TH1*
+AliMUONTrackerDataHistogrammer::CreateHisto(const char* name) const
+{
+  /// Create a single histogram
+
+  Double_t xmin, xmax;
+  
+  fData.HistogramRange(xmin,xmax);
+  
+  TH1* h(0x0);
+  
+  if ( xmin != xmax ) 
+  {
+    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);
+  }
+  return h;
+}
+
+
+//_____________________________________________________________________________
+TH1*
+AliMUONTrackerDataHistogrammer::CreateManuHisto(Int_t detElemId, Int_t manuId) 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...
+  
+  TH1* h(0x0);
+  
+  if ( fData.HasManu(detElemId, manuId) && fData.IsHistogrammed(fDim) ) 
+  {
+    h = CreateHisto(Form("DE%04dMANU%04d_%d",detElemId,manuId,fDim));
+    if ( h ) AddManuHisto(*h,detElemId,manuId);
+  }
+  
+  return h;
+}
+
diff --git a/MUON/AliMUONTrackerDataHistogrammer.h b/MUON/AliMUONTrackerDataHistogrammer.h
new file mode 100644 (file)
index 0000000..d80f2b9
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef ALIMUONTRACKERDATAHISTOGRAMMER_H
+#define ALIMUONTRACKERDATAHISTOGRAMMER_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+/// \ingroup graphics
+/// \class AliMUONTrackerDataHistogrammer
+/// \brief Make histograms from VTrackerData and VPainter objects.
+/// 
+// author Laurent Aphecetche, Subatech
+
+#ifndef ROOT_TObject
+#  include "TObject.h"
+#endif
+
+class AliMUONVPainter;
+class AliMUONVTrackerData;
+class AliMUONSparseHisto;
+class TH1;
+
+class AliMUONTrackerDataHistogrammer : public TObject
+{
+public:
+  AliMUONTrackerDataHistogrammer(const AliMUONVTrackerData& data, Int_t dim);
+  virtual ~AliMUONTrackerDataHistogrammer();
+  
+  static TH1* CreateHisto(const AliMUONVPainter& painter);
+  
+  TH1* CreateBusPatchHisto(Int_t busPatchId) const;
+  
+  TH1* CreateChamberHisto(Int_t chamberId) const;
+  
+  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;
+  
+private:
+
+  TH1* CreateHisto(const char* name) const;
+  
+  void Add(TH1& h, const AliMUONSparseHisto& sh) const;
+  
+  void AddBusPatchHisto(TH1& h, Int_t busPatchId) const;
+  
+  void AddDEHisto(TH1& h, Int_t detElemId) const;
+  
+  void AddManuHisto(TH1& h, Int_t detElemId, Int_t manuId) const;
+  
+private:
+  const AliMUONVTrackerData& fData; ///< data we'll histogram 
+  Int_t fDim; ///< dimension we'll histogram
+  
+  ClassDef(AliMUONTrackerDataHistogrammer,1) // Make histograms from VTrackerData
+};
+
+#endif
index bf58c2816fb0d53df5f15a45dd6ee3a7eae57826..d4f64613519ed09a76986bf741e3552fc79bd562 100644 (file)
@@ -65,8 +65,8 @@ AliMUONTrackerOCDBDataMaker::AliMUONTrackerOCDBDataMaker(const char* ocdbPath,
     else if ( stype == "GAINS" ) 
     {
       fData = new AliMUONTrackerData(Form("GAIN%d",runNumber),"Gains",5,kFALSE);
-      fData->SetDimensionName(0,"a0");
-      fData->SetDimensionName(1,"a1");
+      fData->SetDimensionName(0,"a1");
+      fData->SetDimensionName(1,"a2");
       fData->SetDimensionName(2,"thres");
       fData->SetDimensionName(3,"qual");
       fData->SetDimensionName(4,"sat");
index 348e8b321a6be75879d9ef707ec8c9b4da6bcab3..c374769c0fe9c328a49f6c1f8471f9653c27c6d6 100644 (file)
@@ -81,7 +81,7 @@ AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader, Boo
   fAccumulatedData->SetDimensionName(0,"Raw charge");
   if ( histogram ) 
   {
-    fAccumulatedData->SetHistogramDimension(0,kTRUE);
+    fAccumulatedData->MakeHistogramForDimension(0,kTRUE);
   }
   
   reader->RewindEvents();
index 1754d572585e0097ef0dd73f0e06a8481131cbc2..2a1d34096bc6c5c759b1d10eba6584c656440231 100644 (file)
 
 #include "AliMUONVPainter.h"
 
+#include "AliCodeTimer.h"
+#include "AliLog.h"
 #include "AliMUONObjectPair.h"
 #include "AliMUONPainterContour.h"
 #include "AliMUONPainterGroup.h"
 #include "AliMUONPainterHelper.h"
+#include "AliMUONTrackerDataHistogrammer.h"
 #include "AliMUONVTrackerData.h"
-#include "AliCodeTimer.h"
-#include "AliLog.h"
 #include <Riostream.h>
 #include <TCanvas.h>
 #include <TClass.h>
-#include <TClass.h>
+#include <TClassMenuItem.h>
+#include <TH1.h>
 #include <TList.h>
 #include <TMap.h>
 #include <TMath.h>
@@ -39,7 +41,6 @@
 #include <cassert>
 #include <float.h>
 
-
 /// \class AliMUONVPainter
 ///
 /// Base class for a graphical object representing some part of the
@@ -109,7 +110,8 @@ AliMUONVPainter::AliMUONVPainter(const char* type)
   fAttributes(),
   fLineColor(1),
   fLineWidth(1),
-  fIsValid(kTRUE)
+  fIsValid(kTRUE),
+  fHistogram(0x0)
 {
     /// ctor
     SetID(-1,-1);
@@ -133,7 +135,8 @@ fPad(0x0),
 fAttributes(),
 fLineColor(-1),
 fLineWidth(-1),
-fIsValid(kTRUE)
+fIsValid(kTRUE),
+fHistogram(0x0)
 {
   /// copy ctor
   rhs.Copy(*this);
@@ -156,6 +159,7 @@ AliMUONVPainter::~AliMUONVPainter()
 {
   /// dtor
   delete fChildren;
+  delete fHistogram;
 }
 
 //_____________________________________________________________________________
@@ -294,6 +298,9 @@ AliMUONVPainter::Copy(TObject& object) const
   painter.fID[0] = fID[0];
   painter.fID[1] = fID[1];
   
+  delete painter.fHistogram;
+  painter.fHistogram = 0x0;
+  
   TIter next(fChildren);
   AliMUONVPainter* p;
   
@@ -511,7 +518,7 @@ AliMUONVPainter::ExecuteEvent(Int_t event, Int_t px, Int_t py)
 void
 AliMUONVPainter::FlatList(TList& list)
 {
-  /// Make a flat list of our children
+  /// Make a flat list of our children (and ourselves)
   
   TIter next(fChildren);
   AliMUONVPainter* painter;
@@ -856,6 +863,7 @@ AliMUONVPainter::SetData(const char* pattern, AliMUONVTrackerData* data,
   while ( ( str = static_cast<TObjString*>(next()) ) )
   {
     AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(str));
+        
     if ( group->Matches(pattern) )
     {
       group->SetData(data,dataIndex);
@@ -869,6 +877,90 @@ AliMUONVPainter::SetData(const char* pattern, AliMUONVTrackerData* data,
       group->SetData(0x0,-1);
     }
   }
+  
+  // Update context menus
+  TList list;
+  FlatList(list);
+  
+  TIter pnext(&list);
+  AliMUONVPainter* p;
+  
+  AliMUONPainterGroup* group = Master()->PlotterGroup();
+  
+  while ( ( p = static_cast<AliMUONVPainter*>(pnext()) ) )
+  {
+    TList* l = p->IsA()->GetMenuList();
+  
+    l->Clear();
+  
+    if ( group ) 
+    {
+      Int_t dim = group->Data()->InternalToExternal(group->DataIndex());
+      if ( dim < group->Data()->ExternalDimension() )
+      {      
+        if ( data && data->IsHistogrammed(dim) ) 
+        {
+          // Add histo drawing to the popup menu
+          TClassMenuItem* n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
+                                                 "Draw histogram","DrawHistogram",p,"",-1,kTRUE);
+          l->AddFirst(n);
+          
+          n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
+                                 "Draw histogram clone","DrawHistogramClone",p,"",-1,kTRUE);
+          l->AddFirst(n);
+          
+          
+        }
+      }
+    }
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::DrawHistogram() const
+{
+  /// Draw histogram (and delete the previous one)
+
+  delete fHistogram;
+  fHistogram = 0x0;
+  
+  DrawHistogramClone();
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::DrawHistogramClone() const
+{
+  /// Draw histogram 
+  
+  fHistogram = AliMUONTrackerDataHistogrammer::CreateHisto(*this);
+  
+  if (fHistogram) 
+  {
+    new TCanvas();
+    fHistogram->Draw();
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::FillManuList(TObjArray& manuList) const
+{
+  /// Append to manulist
+  /// This is the default implementation, which just calls the FillManuList
+  /// of all our children.
+  /// Some derived class might need to override this in order to exclude
+  /// some children from the fill.
+  
+  TIter next(Children());
+  
+  AliMUONVPainter* p;
+  
+  while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
+  {
+    p->FillManuList(manuList);
+  }
 }
 
 //_____________________________________________________________________________
index 2fa94c7c0191c53b3b3059e50f1a3d4df487036f..86bdd197e2b8c26ff2f4363613e34b69f1983dbb 100644 (file)
@@ -35,6 +35,7 @@ class AliMUONPainterGroup;
 class AliMUONVTrackerData;
 class AliMpArea;
 class TCollection;
+class TH1;
 class TList;
 class TMap;
 class TObjArray;
@@ -212,10 +213,17 @@ public:
 
   AliMUONVPainter* Master() const;
   
+  virtual void DrawHistogram() const;
+
+  virtual void DrawHistogramClone() const;
+
+  /// Append (i.e. don't have the right the clear the array !) our list of manus to manuList
+  virtual void FillManuList(TObjArray& manuList) const;
+  
 protected:
     
   virtual TCollection* Children() const;
-  
+
 private:
 
     void FlatList(TList& list);
@@ -249,7 +257,10 @@ private:
   Int_t fID[2]; ///< our ids
   Bool_t fIsValid; ///< whether we were properly initialized
   
-  ClassDef(AliMUONVPainter,1) // Base class of a graphical object for MUON spectrometer
+protected:
+  mutable TH1* fHistogram; ///< histogram
+  
+  ClassDef(AliMUONVPainter,2) // Base class of a graphical object for MUON spectrometer
 };
 
 #endif
index 131dddb7d9c748250569f2ba2c5eb5151103702e..9a911de2b30b72dd54faf27ee1176c188173a850 100644 (file)
@@ -23,8 +23,8 @@
 #   include <RQ_OBJECT.h>
 #endif
 
+class AliMUONSparseHisto;
 class AliMUONVStore;
-class TH1;
 
 class AliMUONVTrackerData : public TNamed
 {
@@ -57,9 +57,12 @@ public:
   /// Get the value for a given DE and given dimension
   virtual Double_t DetectionElement(Int_t detElemId, Int_t dim=0) const = 0;
   
-  /// Get the name of a given dimension
+  /// Get the name of a given (internal) dimension
   virtual TString DimensionName(Int_t dim) const = 0;
 
+  /// Get the name of a given (external) dimension
+  virtual TString ExternalDimensionName(Int_t dim) const = 0;
+
   /// Whether we have data for a given buspath
   virtual Bool_t HasBusPatch(Int_t busPatchId) const = 0;
 
@@ -87,6 +90,12 @@ public:
   /// The number of dimensions we are handling
   virtual Int_t NumberOfDimensions() const = 0;
 
+  /// Convert from internal to external dimension
+  virtual Int_t InternalToExternal(Int_t dim) const = 0;
+  
+  /// The number of dimensions we are inputting
+  virtual Int_t ExternalDimension() const = 0;
+
   /// The number of events we've seen so far
   virtual Int_t NumberOfEvents() const = 0;
 
@@ -112,27 +121,19 @@ public:
   virtual Bool_t CanHistogram() const { return kFALSE; }
   
   /// Select a dimension to be histogrammed (if CanHistogram==kTRUE) only
-  virtual void SetHistogramDimension(Int_t /* index */, Bool_t /* value */) { }
+  virtual void MakeHistogramForDimension(Int_t /* index */, Bool_t /* value */,
+    Double_t /*xmin*/=0.0, Double_t /*xmax*/=4096.0) { }
+
+  /// Get histogram range
+  virtual void HistogramRange(Double_t& xmin, Double_t& xmax) const { xmin=xmax=0.0; }
+
+  /// Whether we have histograms for a given dimension, or not
+  virtual Bool_t IsHistogrammed(Int_t /*dim*/) const { return kFALSE; }
+
+  /// Get sparse histogram for a given channel
+  virtual AliMUONSparseHisto* GetChannelSparseHisto(Int_t detElemId, Int_t manuId, 
+                                                    Int_t manuChannel, Int_t dim=0) const = 0;
 
-  /// Create (if CanHistogram) an histo for a given channel
-  virtual TH1* CreateChannelHisto(Int_t /*detElemId*/, Int_t /*manuId*/, 
-                                  Int_t /*manuChannel*/, Int_t /*dim*/=0) { return 0x0; }
-  
-  /// Create (if CanHistogram) an histo for a given bus patch
-  virtual TH1* CreateBusPatchHisto(Int_t /*busPatchId*/, Int_t /*dim*/=0)  { return 0x0; }
-  
-  /// Create (if CanHistogram) an histo for a given detection element
-  virtual TH1* CreateDEHisto(Int_t /*detElemId*/, Int_t /*dim*/=0)  { return 0x0; }
-  
-  /// Create (if CanHistogram) an histo for a given manu
-  virtual TH1* CreateManuHisto(Int_t /*detElemId*/, Int_t /*manuId*/, Int_t /*dim*/=0)  { return 0x0; }
-  
-  /// Create (if CanHistogram) an histo for a given pcb
-  virtual TH1* CreatePCBHisto(Int_t /*detElemId*/, Int_t /*pcbIndex*/, Int_t /*dim*/=0)  { return 0x0; }
-  
-  /// Create (if CanHistogram) an histo for a given chamber
-  virtual TH1* CreateChamberHisto(Int_t /*chamberId*/, Int_t /*dim*/=0)  { return 0x0; }
-  
 private:
   /// not implemented
   AliMUONVTrackerData(const AliMUONVTrackerData& rhs);
index c0c1fc37c5fb32a69c052574922b13a325f5d5a2..690ea6312c0cd75f030e5033faecee8818a80744 100644 (file)
@@ -533,7 +533,7 @@ REFERENCED_BY_RELATION = YES
 # then for each documented function all documented entities 
 # called/used by that function will be listed.
 
-REFERENCES_RELATION    = YES
+REFERENCES_RELATION    = NO
 
 # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
 # will generate a verbatim copy of the header file for each class for 
diff --git a/MUON/MUONOfflineShift.C b/MUON/MUONOfflineShift.C
new file mode 100644 (file)
index 0000000..7a4029a
--- /dev/null
@@ -0,0 +1,260 @@
+/**************************************************************************
+* 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$ */
+
+/// \ingroup macros
+/// \file MUONOfflineShift.C
+/// \brief Macro to be used to check raw data during MUON offline shifts.
+///  
+/// Basic usage is : 
+///
+/// MUONOfflineShift("path_to_raw_file","basename of output file")
+///
+/// This will read the raw data and process it several times, varying what's done :
+/// only decoding, decoding + zero-suppression, etc... (TBE)
+///
+/// Two outputs files will be created : 
+///
+/// - basename.root, containing AliMUONVTrackerData objects that can then 
+///   be displayed using the mchview program (using mchview --use basename.root)
+///
+/// - basename.log, containing (for the moment) the occupancy numbers of the various detection elements
+///
+/// \author Laurent Aphecetche
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include "AliCDBManager.h"
+#include "AliCodeTimer.h"
+#include "AliMUONPainterRegistry.h"
+#include "AliMUONTrackerCalibratedDataMaker.h"
+#include "AliMUONTrackerRawDataMaker.h"
+#include "AliMUONVTrackerData.h"
+#include "AliMpCDB.h"
+#include "AliMpConstants.h"
+#include "AliMpDEIterator.h"
+#include "AliRawReader.h"
+#include "AliRawReaderDate.h"
+#include "AliRawReaderRoot.h"
+#include <Riostream.h>
+#include <TFile.h>
+#include <TGrid.h>
+#include <TStopwatch.h>
+#include <TString.h>
+#include <TSystem.h>
+
+#endif
+
+//______________________________________________________________________________
+Int_t DataMakerReading(AliRawReader* rawReader, 
+                       TStopwatch& timer,
+                       const char* cdbPath="",
+                       const char* calibMode="",
+                       Bool_t histogram=kFALSE,
+                       Double_t xmin = 0.0,
+                       Double_t xmax = 4096.0)
+{
+  /// Run over the data and calibrate it if so required (if cdbPath != "")
+  /// calibMode can be :
+  /// - NOGAIN           : only zero-suppression will be done
+  /// - GAINCONSTANTCAPA : zero-suppression + gain, but with a single capa value for all channels
+  /// - GAIN             : zero-suppression + gain w/ individual capacitance per channel.
+  
+  rawReader->RewindEvents();
+  
+  AliMUONVTrackerDataMaker* dm(0x0);
+  
+  if ( strlen(cdbPath) > 0 ) 
+  {
+    dm = new AliMUONTrackerCalibratedDataMaker(rawReader,cdbPath,calibMode,histogram,xmin,xmax);
+  }
+  else  
+  {
+    dm = new AliMUONTrackerRawDataMaker(rawReader,kTRUE);
+  }
+  
+  AliMUONPainterRegistry::Instance()->Register(dm);
+
+  timer.Start(kTRUE);
+  Int_t n(0);
+  
+  dm->SetRunning(kTRUE);
+  
+  while (dm->NextEvent())
+  {
+    ++n;
+  }
+  
+  timer.Stop();
+  
+  delete dm;
+  
+  return n;
+}
+
+//______________________________________________________________________________
+void Print(const char* method, TStopwatch& timer, Int_t n)
+{
+  /// Get the timing for a given method
+  
+  cout << Form("%20s %10d events. Total CPU time %7.2f seconds.",
+               method,n,timer.CpuTime());
+  
+  Double_t cpu = timer.CpuTime()/n;
+  Double_t real = timer.RealTime()/n;
+  
+  cout << Form(" ms real/event = %7.2f ms CPU/event = %7.2f",real*1E3,cpu*1E3)
+    << endl;
+}
+
+//______________________________________________________________________________
+void Occupancy(ostream& outfile)
+{
+  /// Write occupancy numbers to output text file
+  
+  outfile << "-----------------------------------------------------" << endl;
+  outfile << "Occupancy numbers" << endl;
+  outfile << "-----------------------------------------------------" << endl;
+  
+  const Int_t occIndex = 2;
+  
+  AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
+
+  Int_t nofDataSources = reg->NumberOfDataSources();
+
+  outfile << Form("%11s|"," ");
+  
+  for ( Int_t ids = 0; ids < nofDataSources; ++ ids ) 
+  {
+    AliMUONVTrackerData* data = reg->DataSource(ids);
+    outfile << Form(" %13s |",data->GetName());
+  }
+
+  outfile << endl;
+
+  for ( Int_t chamberId = 0; chamberId < AliMpConstants::NofTrackingChambers(); ++chamberId ) 
+  {
+    Bool_t nonZero(kFALSE);
+    for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids ) 
+    {
+      if ( reg->DataSource(ids)->Chamber(chamberId,occIndex) ) nonZero = kTRUE;
+    }
+    
+    if ( !nonZero ) continue;
+    
+    outfile << Form("Chamber %2d |",chamberId);
+    for ( Int_t ids = 0; ids < nofDataSources; ++ ids ) 
+    {
+      AliMUONVTrackerData* data = reg->DataSource(ids);
+      outfile << Form("   %7.2f %%   |",100.0*data->Chamber(chamberId,occIndex));
+    }
+    outfile << endl;
+    
+    AliMpDEIterator it;
+    it.First(chamberId);
+    while (!it.IsDone())
+    {
+      Int_t detElemId = it.CurrentDEId();
+      Bool_t nonZero(kFALSE);
+      for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids ) 
+      {
+        AliMUONVTrackerData* data = reg->DataSource(ids);
+        if ( data->DetectionElement(detElemId,occIndex) > 0 ) 
+        {
+          nonZero = kTRUE;
+        }
+      }
+      
+      if ( nonZero ) 
+      {
+        outfile << Form("   DE %04d |",detElemId);
+        for ( Int_t ids = 0; ids < nofDataSources; ++ ids ) 
+        {
+          AliMUONVTrackerData* data = reg->DataSource(ids);
+          outfile << Form("   %7.2f %%   |",100.0*data->DetectionElement(detElemId,occIndex));
+        }
+        outfile << endl;
+      }
+      it.Next();
+    }
+  }
+}
+
+//______________________________________________________________________________
+void MUONOfflineShift(const char* input, const char* outputBase,
+                      const char* ocdbPath="alien://folder=/alice/data/2008/LHC08a/OCDB")
+{
+  /// Entry point of the macro. 
+  /// Example of syntax for an input file (from alien)
+  ///
+  /// alien::///alice/data/2007/LHC07w/000014493/raw/07000014493001.10.root
+  /// 
+  /// and for an OCDB path : 
+  ///
+  /// alien://folder=/alice/data/2007/LHC07w/OCDB
+  ///
+
+  TGrid::Connect("alien://");
+  
+  AliCodeTimer::Instance()->Reset();
+  
+  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+  AliCDBManager::Instance()->SetRun(0);
+  AliMpCDB::LoadDDLStore();
+  
+  TString fileName(gSystem->ExpandPathName(input));
+  
+  AliRawReader* rawReader(0x0);
+  
+  // check extention to choose the rawdata file format
+  if (fileName.EndsWith(".root")) 
+  {
+    rawReader = new AliRawReaderRoot(fileName);
+  }
+  else if (!fileName.IsNull()) 
+  {
+    rawReader = new AliRawReaderDate(fileName); // DATE file
+  }
+  
+  if (!rawReader) return;
+  
+  TStopwatch timer2;
+  TStopwatch timer3;
+  
+  Int_t n2 = DataMakerReading(rawReader,timer2);
+  
+  Int_t n3 = DataMakerReading(rawReader,timer3,ocdbPath);
+  
+  Print("DataMakerReading(RAW)",timer2,n2);
+  
+  Print("DataMakerReading(CAL)",timer3,n3);
+  
+  AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
+  
+  TFile f(gSystem->ExpandPathName(Form("%s.root",outputBase)),"RECREATE");
+  ofstream out(gSystem->ExpandPathName(Form("%s.log",outputBase)));
+
+  Occupancy(out);
+
+  for ( Int_t i = 0; i < reg->NumberOfDataSources(); ++i )
+  {
+    AliMUONVTrackerData* data = reg->DataSource(i);
+    data->Write();
+  }
+  
+  f.Close();
+  
+}
index ec171dea699be7f08e5064e7c516116c6499d15e..3af5f4defc994c618f8a6179a699e456aa3b80ef 100644 (file)
@@ -42,5 +42,6 @@
 #pragma link C++ class AliMUONTrackerCalibratedDataMaker+;
 #pragma link C++ class AliMUONMchViewApplication+;
 #pragma link C++ class AliMUONSparseHisto+;
+#pragma link C++ class AliMUONTrackerDataHistogrammer+;
 
 #endif
index f3ed2215482aaf6fe0dc01be7594155988aa0cd1..73b5472a91878fbf89045c9cef25f3db7f2bdac0 100644 (file)
@@ -62,7 +62,7 @@ From top to bottom, you'll see group of frames used to :
 - select from a list of recently used source
 
 - select a raw data source (either by typing in its full pathname, or opening a file dialog). 
-The second line in this group is to specify that you want to calibrate the data. Check the calibrate button, and specify the
+The second line in this group is to specify that you want to calibrate the data. Check one of the calibrate buttons, and specify the
 location of the OCDB to be used. If that field is not empty (and the corresponding entry is correct, of course), 
 the raw data will be calibrated.
 The last line in that group is a single check button, to instruct the program to produce histograms of the data (see \ref mchview_histogramming)
@@ -78,7 +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
-- CAL# (or CAL(#)): as above, but for calibrated data.
+- (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
 
 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 :
@@ -115,7 +117,8 @@ a bit the data reading.
 Histograms produced by the program are as compact as possible in order to fit in memory (so they are *not* plain TH1 objects).
 Plain TH1 objects are produced later on (on request only), and should be deleted as soon as possible (you have to realize that
 1 million TH1 of 4096 channels has no chance to fit in memory...)
-For the moment, access to the histograms cannot be done through the GUI. So you have to use the root prompt (of the \em mchview program itself).
+Access to the histograms can be done through the GUI, using the right click on any painter.
+For extra flexibily, you can also use the root prompt (of the \em mchview program itself).
 First get the data object, and then ask the data object to create the histogram(s) you want. Remember to delete those histograms as soon
 as you no longer need them :
 
@@ -132,11 +135,16 @@ etc...
 
 You can get histograms for all levels (except PCB) : channel, manu, bus patch, detection element, chamber. See AliMUONVTrackerData doc. for the methods.
 
----------
+\section mchview_savingprinting Saving and printing
 
-IMPORTANT WARNINGS
+From the File menu of the \em mchview application, you can use SaveAs and PrintAs popups to respectively save the current data sources (meaning you can quit
+the program and start again with the same filled data sources, without having to rerun on the source) and print the current display.
+Printing needs a little bit of polishing (e.g. getting a nice and descriptive title would help a lot), but it's better than nothing.
+Note that the \em mchview application now has a \em --use option to reload a previously saved .root file (same effect as using the File/Open menu).
+
+\section mchview_warnings Important warnings. Please read.
 
-The remove button is currently not working...
+IMPORTANT WARNINGS
 
 In principle, you could have several raw data sources running at the same time. This is NOT currently working. You can have several data sources opened
  at the same time, but not running at the same time. (this has to do with AliRawReader not being thread-safe for the moment).
index e519dd09e70acbb6d8f9e87ed6bf6d0f599494af..a3be2bde43f423ce1e097343bc77caa7ba208785 100644 (file)
@@ -59,9 +59,14 @@ We've written an AliMUONPedestalEventGenerator which creates fake pedestal event
 are taken from the Offline Condition DataBase (OCDB) (which is itself fakely filled
 using the WritePedestals() method of AliMUONCDB class
 
-So first generate a valid pedestal CDB entry by using the AliMUONCDB class
+So first generate a valid pedestal CDB entry by using the AliMUONCDB class. There's one
+ little trick : you should first point to the "default" OCDB (local://$ALICE_ROOT) in
+ order to get the mapping loaded. Then only you can play with another OCDB.
 
 <pre>
+root[] AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+root[] AliCDBManager::Instance()->SetRun(0);
+root[] AliMpCDB::LoadDDLStore();
 root[] const char* cdbpath="local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"; // where to put the CDB
 root[] AliMUONCDB cdb(cdbpath)
 root[] Bool_t defaultValues = kFALSE; // to generate random values instead of plain zeros...
index 51ec8c1c98598a98c643549c6ccb45c47e32766a..cc408b3ca87e66dcd0490a201f055c860e32d23b 100644 (file)
@@ -32,7 +32,8 @@ SRCS:=  AliMUONVPainter.cxx \
   AliMUONTrackerRawDataMaker.cxx \
   AliMUONTrackerCalibratedDataMaker.cxx \
   AliMUONMchViewApplication.cxx \
-  AliMUONSparseHisto.cxx
+  AliMUONSparseHisto.cxx \
+  AliMUONTrackerDataHistogrammer.cxx
     
 HDRS:= $(SRCS:.cxx=.h) 
 
index 528790d2403c18d1a793d3707c431b0bcf5b87b9..cb67c28ec212b5140a18569d72d98c29d855fae0 100644 (file)
@@ -39,6 +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;
   return -1;
 }
 
@@ -55,6 +56,8 @@ int main(int argc, char** argv)
   
   Int_t nok(0);
   
+  TString fileToOpen;
+  
   for ( Int_t i = 0; i <= args.GetLast(); ++i ) 
   {
     TString a(static_cast<TObjString*>(args.At(i))->String());
@@ -64,6 +67,16 @@ int main(int argc, char** argv)
       ++nok;
       return 0;
     }
+    if ( a == "--use" && i < args.GetLast() )
+    {
+      fileToOpen = static_cast<TObjString*>(args.At(i+1))->String();
+      ++i;
+      nok += 2;
+    }
+    else
+    {
+      return Usage();
+    }
   }
   
   if ( nok < args.GetLast() )
@@ -89,10 +102,12 @@ int main(int argc, char** argv)
   gStyle->SetPalette(n+2,colors);
   delete[] colors;
   
-  TRint* theApp = new AliMUONMchViewApplication("mchview", &argc, argv, 0.7, 0.9);
+  AliMUONMchViewApplication* theApp = new AliMUONMchViewApplication("mchview", &argc, argv, 0.7, 0.9);
    
   AliCodeTimer::Instance()->Print();
 
+  if ( fileToOpen.Length() > 0 ) theApp->Open(fileToOpen);
+  
   // --- Start the event loop ---
   theApp->Run(kTRUE);