]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONMchViewApplication.cxx
Go from pointer to ifstream to ifstream.
[u/mrichter/AliRoot.git] / MUON / AliMUONMchViewApplication.cxx
index 3dcac5c04deff73ec6fdc003d907e3413dc39639..5956f858f4c9c56a59fa336f41506af6021dc9a5 100644 (file)
 #include "AliCDBManager.h"
 #include "AliCodeTimer.h"
 #include "AliLog.h"
+#include "AliMUONAlignmentCompareDialog.h"
+#include "AliMUONChamberPainter.h"
+#include "AliMUONDEPainter.h"
 #include "AliMUONPainterDataRegistry.h"
 #include "AliMUONPainterDataSourceFrame.h"
 #include "AliMUONPainterEnv.h"
 #include "AliMUONPainterHelper.h"
+#include "AliMUONPainterGroup.h"
 #include "AliMUONPainterMasterFrame.h"
+#include "AliMUONPainterMatrix.h"
 #include "AliMUONPainterRegistry.h"
 #include "AliMUONTrackerDataCompareDialog.h"
 #include "AliMUONTrackerDataWrapper.h"
@@ -52,6 +57,8 @@
 ///
 ///\author Laurent Aphecetche, Subatech
 
+using std::cout;
+using std::endl;
 /// \cond CLASSIMP
 ClassImp(AliMUONMchViewApplication)
 /// \endcond CLASSIMP
@@ -62,6 +69,7 @@ const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
 const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
 const Int_t AliMUONMchViewApplication::fgkABOUT(5);
 const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
+const Int_t AliMUONMchViewApplication::fgkCOMPAREALIGNMENTS(7);
 
 const char* AliMUONMchViewApplication::fgkFileTypes[] = { 
   "ROOT files",    "*.root", 
@@ -75,71 +83,195 @@ AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
                                                      UInt_t ox, UInt_t oy) 
 : TRint(name,argc,argv),
   fMainFrame(0x0),
-  fPainterMasterFrame(0x0)
+  fPainterMasterFrameList(new TList),
+  fTabs(0x0)
 {
 
   /// ctor
   /// (w,h) is the size in pixel (if 0,0 it will be computed as 70%,90% of display size)
   /// (ox,oy) is the offset from the top-left of the display
 
-  if (!w | !h)
+  if (!w || !h)
   {
     w = (UInt_t)(gClient->GetDisplayWidth()*0.7);
     h = (UInt_t)(gClient->GetDisplayHeight()*0.9); 
   }
 
   fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
-  
+
   CreateMenuBar(w);
 
   const Int_t kbs = 2;
   
 //  h -= 60; // menubar
   
-  TGTab* tabs = new TGTab(fMainFrame,w,h);
+  fTabs = new TGTab(fMainFrame,w,h);
+  
+  TGCompositeFrame* t = fTabs->AddTab("Painter Master Frame");
+
+  fPainterMasterFrameList->SetOwner(kTRUE);
+  
   
-  TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
+  AliMUONPainterMasterFrame* pmf = new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2,
+                                                                 GenerateStartupMatrix());
 
-  fPainterMasterFrame =
-    new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
+  fPainterMasterFrameList->Add(pmf);
   
-  t->AddFrame(fPainterMasterFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
+  t->AddFrame(pmf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
 
-  t = tabs->AddTab("Data Sources");
+  t = fTabs->AddTab("Data Sources");
   
   AliMUONPainterDataSourceFrame* dsf = 
     new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
   
   t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
   
-  fMainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
+  fMainFrame->AddFrame(fTabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
 
   fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
 
   fMainFrame->MapSubwindows();
   fMainFrame->Resize();
   
-  fPainterMasterFrame->Update();
+  pmf->Update();
   
   fMainFrame->MapWindow();
   
   fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
 
-  fMainFrame->MoveResize(ox,oy, w, h); 
+//  fMainFrame->MoveResize(ox,oy, w, h); 
   fMainFrame->SetWMPosition(ox, oy);
-  fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
+//  fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
+//  fMainFrame->SetWMSizeHints(w,h,w,h,10,10);
   
   cout << "***************************************************" << endl;
   cout << "   Welcome to mchview" << endl;
   cout << "   " << FullVersion() << endl;
   cout << "***************************************************" << endl;
+  
+  // Trying to see if we're requested to draw something specific instead
+  // of the global view of all the chambers
+  
+  AliMUONVPainter* painter(0x0);
+  TObjArray args;
+  args.SetOwner(kTRUE);
+  
+  for ( int i = 1; i < argc[0]; ++i ) 
+  {
+    args.Add(new TObjString(argv[i]));
+  }
+  
+  for ( Int_t i = 0; i <= args.GetLast(); ++i ) 
+  {
+    TString a(static_cast<TObjString*>(args.At(i))->String());
+
+    AliMUONAttPainter att;
+    
+    att.SetPlane(kTRUE,kFALSE);
+    att.SetCathode(kFALSE,kFALSE);
+    att.SetViewPoint(kTRUE,kFALSE);
+        
+    if ( a == "--de" )
+    {
+      Int_t detElemId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
+      
+      painter = new AliMUONDEPainter(att,detElemId);
+      
+      painter->SetOutlined("*",kFALSE);      
+      painter->SetOutlined("BUSPATCH",kTRUE);
+
+      painter->SetLine(1,4,3);      
+      ++i;
+    }
 
+    if ( a == "--chamber" )
+    {
+      Int_t chamberId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
+      
+      painter = new AliMUONChamberPainter(att,chamberId-1);
+      
+      painter->SetOutlined("*",kFALSE);      
+      painter->SetOutlined("DE",kTRUE);
+      
+      painter->SetLine(1,4,3);      
+      ++i;
+    }
+    
+  }
+  
+  if ( painter ) 
+  {
+    pmf->ShiftClicked(painter,0x0);
+    
+    pmf->Update();
+  }
+      
 }
 
 //______________________________________________________________________________
 AliMUONMchViewApplication::~AliMUONMchViewApplication()
 {
   /// dtor
+  delete fPainterMasterFrameList;
+}
+
+//_____________________________________________________________________________
+AliMUONPainterMatrix*
+AliMUONMchViewApplication::GenerateStartupMatrix()
+{
+  /// Kind of bootstrap method to trigger the generation of all contours
+  
+  AliCodeTimerAuto("",0);
+  
+  AliMUONAttPainter att;
+  
+  att.SetViewPoint(kTRUE,kFALSE);
+  att.SetCathode(kFALSE,kFALSE);
+  att.SetPlane(kTRUE,kFALSE);
+
+  AliMUONPainterMatrix* matrix = new AliMUONPainterMatrix("Tracker",5,2);
+    
+  for ( Int_t i = 0; i < 10; ++i )
+  {
+    AliMUONVPainter* painter = new AliMUONChamberPainter(att,i);
+    
+    painter->SetResponder("Chamber");
+    
+    painter->SetOutlined("*",kFALSE);
+    
+    painter->SetOutlined("MANU",kTRUE);
+    
+    for ( Int_t j = 0; j < 3; ++j ) 
+    {
+      painter->SetLine(j,1,4-j);
+    }
+    
+    matrix->Adopt(painter);    
+  }
+  AliMUONPainterRegistry::Instance()->Register(matrix);
+  return matrix;
+}
+
+//______________________________________________________________________________
+void
+AliMUONMchViewApplication::CompareAlignments()
+{
+  /// Launch compare data dialog
+  TGTransientFrame* t = new AliMUONAlignmentCompareDialog(gClient->GetRoot(),
+                                                          gClient->GetRoot(),
+                                                          400,400);
+  
+  t->MapSubwindows();
+  t->Resize();
+  t->MapWindow();
+  t->CenterOnParent();
+  
+  // set names
+  
+  t->SetWindowName("mchview compare alignments tool");
+  t->SetIconName("mchview compare alignments tool");
+  
+  t->MapRaised();  
 }
 
 //______________________________________________________________________________
@@ -161,8 +293,7 @@ AliMUONMchViewApplication::CompareData()
   t->SetWindowName("mchview compare data tool");
   t->SetIconName("mchview compare data tool");
   
-  t->MapRaised();
-  
+  t->MapRaised();  
 }
 
 //______________________________________________________________________________
@@ -182,6 +313,7 @@ AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
   
   TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
   tools->AddEntry("&Compare data",fgkCOMPAREDATA);
+  tools->AddEntry("&Compare alignments",fgkCOMPAREALIGNMENTS);
   
   TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());  
   about->AddEntry(FullVersion(),fgkABOUT);
@@ -225,7 +357,10 @@ AliMUONMchViewApplication::HandleMenu(Int_t i)
     case fgkCOMPAREDATA:
       CompareData();
       break;
-    default:
+    case fgkCOMPAREALIGNMENTS:
+      CompareAlignments();
+      break;
+      default:
       break;
     }
 }
@@ -337,7 +472,16 @@ AliMUONMchViewApplication::PrintAs()
   new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
                    kFDSave,&fileInfo);
   
-  fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
+  TIter next(fPainterMasterFrameList);
+  AliMUONPainterMasterFrame* pmf;
+  Bool_t first(kTRUE);
+  
+  while ( ( pmf = static_cast<AliMUONPainterMasterFrame*>(next()) ) )
+  {
+    pmf->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)),
+                first ? "RECREATE" : "UPDATE");
+    first = kFALSE;
+  }
 }
 
 //______________________________________________________________________________
@@ -353,6 +497,96 @@ AliMUONMchViewApplication::ReleaseNotes()
   
   TGTextView* rn = new TGTextView(t);
 
+  rn->AddLine("1.13");
+  rn->AddLine("");
+  rn->AddLine("Make default OCDB = 2013 one");
+  rn->AddLine("");
+
+  rn->AddLine("1.11");
+  rn->AddLine("");
+  rn->AddLine("Adding [Compare alignments] in the Tools menu + make default OCDB be 2012's version");
+  rn->AddLine("");
+  
+  rn->AddLine("1.10");
+  rn->AddLine("");
+  rn->AddLine("Make the raw OCDB more obvious in the data source tab");
+  rn->AddLine("");
+  
+  rn->AddLine("1.08");
+  rn->AddLine("");
+  rn->AddLine("Changed the default OCDB to 2011 version");
+  rn->AddLine("");
+  
+  rn->AddLine("1.07");
+  rn->AddLine("");
+  rn->AddLine("Added the RejectList as a possible OCDB data source");
+  rn->AddLine("");
+  
+  rn->AddLine("1.06");
+  rn->AddLine("");
+  rn->AddLine("Changed a bit the HV display. Now a trip is indicated with a value of -1");
+  rn->AddLine("");
+  
+  rn->AddLine("1.05");
+  rn->AddLine("");
+  rn->AddLine("Added the possibility to select an event range when reading raw data");
+  rn->AddLine("Usefull e.g. to look at a single suspect event...");
+  rn->AddLine("");
+  
+  rn->AddLine("1.04");
+  rn->AddLine("");
+  rn->AddLine("Changed the default OCDB to 2010 version");
+  rn->AddLine("");
+  
+  rn->AddLine("1.03");
+  rn->AddLine("");
+  rn->AddLine("Add Print buttons");
+  rn->AddLine("Add the automatic creation of often used canvases when using pedestal source");
+  // Internal reorganization to allow several independent tabs to be created to 
+  // show different master frames (not used yet). Important for the moment
+  // is the ability to create a PainterMatrix and pass it to the PainterMasterFrame
+  rn->AddLine("");
+  
+  rn->AddLine("1.02");
+  rn->AddLine("");
+  rn->AddLine("Internal change (merging of AliMUONTrackerACFDataMaker and AliMUONTrackerOCDBDataMaker into AliMUONTrackerConditionDataMaker)");
+  rn->AddLine("Added --ocdb option");
+  rn->AddLine("Corrected the display of the configuration");
+  rn->AddLine("Corrected the interpretation of the switches for the HV display");
+  rn->AddLine("");
+  
+  rn->AddLine("1.01");
+  rn->AddLine("");
+  rn->AddLine("Added the configuration as a possible OCDB data source");
+  rn->AddLine("");
+  
+  rn->AddLine("1.00");
+  rn->AddLine("");
+  rn->AddLine("Added the Status and StatusMap as a possible OCDB data source");
+  rn->AddLine("");
+  rn->AddLine("Added one (computed) dimension to the Gains data source = 1/a1/0.2 (mV/fC)");
+  rn->AddLine("");
+    
+  rn->AddLine("0.99a");
+  rn->AddLine("");
+  rn->AddLine("Added the --de and --chamber options");
+  rn->AddLine("");
+  
+  rn->AddLine("0.99");
+  rn->AddLine("");
+  rn->AddLine("The chamberid in the label (top right of panel) is now starting at 1 as in common usage");  
+  rn->AddLine("");
+  
+  rn->AddLine("0.98");
+  rn->AddLine("");
+  rn->AddLine("Added --asciimapping option");
+  rn->AddLine("");
+  
+  rn->AddLine("0.97");
+  rn->AddLine("");
+  rn->AddLine("Adding calibration option with Emelec (aka injection) gain");
+  rn->AddLine("");
+  
   rn->AddLine("0.96a");
   rn->AddLine("");
   rn->AddLine("Internal reorganization of the contour computations, that lead to improved performance. ");