Skip to content
Snippets Groups Projects
Commit 8d5aef83 authored by Sergey Gorbunov's avatar Sergey Gorbunov
Browse files

qa directory for common qa tools

parent cc959f75
No related branches found
No related tags found
1 merge request!92qa directory for common qa tools
...@@ -5,6 +5,7 @@ set(CBMBASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/base) ...@@ -5,6 +5,7 @@ set(CBMBASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/base)
add_subdirectory(data) add_subdirectory(data)
add_subdirectory(field) add_subdirectory(field)
add_subdirectory(base) add_subdirectory(base)
add_subdirectory(qa)
add_subdirectory(detectors/trd) add_subdirectory(detectors/trd)
add_subdirectory(detectors/rich) add_subdirectory(detectors/rich)
......
Set(INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
)
Include_Directories( ${INCLUDE_DIRECTORIES})
Set(SYSTEM_INCLUDE_DIRECTORIES
${BASE_INCLUDE_DIRECTORIES}
)
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
set(LINK_DIRECTORIES
${ROOT_LIBRARY_DIR}
${FAIRROOT_LIBRARY_DIR}
${Boost_LIBRARY_DIRS}
)
link_directories( ${LINK_DIRECTORIES})
set(SRCS
CbmQaCanvas.cxx
)
set(LINKDEF CbmQaBaseLinkDef.h)
Set(LIBRARY_NAME CbmQaBase)
Set(DEPENDENCIES
)
GENERATE_LIBRARY()
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class CbmQaCanvas - ;
#endif
/// \file CbmQaCanvas.cxx
/// \brief Implementation of the CbmQaCanvas class
/// \author Sergey Gorbunov <se.gorbunov@gsi.de>
/// \date 17.09.2020
#include "CbmQaCanvas.h"
#include "TBuffer.h"
#include "TVirtualPad.h"
ClassImp(CbmQaCanvas);
/// The Streamer is declared by ClassDef() macro
/// Stream an object of class CbmQaCanvas
///
void CbmQaCanvas::Streamer(TBuffer& R__b) {
// Save global gPad pointer,
// because it will be modified by TCanvas streamer
auto store = gPad;
if (R__b.IsReading()) {
R__b.ReadClassBuffer(CbmQaCanvas::Class(), this);
} else {
R__b.WriteClassBuffer(CbmQaCanvas::Class(), this);
}
// restore the global pointer
gPad = store;
}
void CbmQaCanvas::Divide2D(int nPads) {
if (nPads < 1) nPads = 1;
int rows = (int) sqrt(nPads);
int cols = nPads / rows;
if (cols * rows < nPads) cols++;
TCanvas::Divide(cols, rows);
}
/// \file CbmQaCanvas.h
/// \brief Definition of the CbmQaCanvas class
/// \author Sergey Gorbunov <se.gorbunov@gsi.de>
/// \date 17.09.2020
#ifndef CbmQaCanvas_H
#define CbmQaCanvas_H
#include "TCanvas.h"
#include "TROOT.h"
/// A modification of TCanvas which is helpful for storing canvases in a root
/// file together with other objects.
///
/// 1. When ROOT reads a file which contains canvases, for no reason it sets
/// global gPad to the last canvas in the file, thus deactivating the browser
/// window. CbmQaCanvas modifies the standard TCanvas::Streamer() to suppress
/// this feature.
///
/// 2. The CbmQaCanvas is created in the batch mode, i.e. it is not
/// automatically displayed.
///
/// 3. Please use DrawCopy() methods instead of Draw(), to draw objects in the
/// canvas. Otherwise the same object can be stored several times in the file;
/// later this will cause crashes in the ROOT Browser for whatever reason.
///
class CbmQaCanvas : public TCanvas {
public:
/// Default constructor needed by the ROOT streamer
CbmQaCanvas() : TCanvas() {}
/// Reimplementation of any existing TCanvas constructor
/// It sets the batch mode ON and then calls the constructor
template<typename... Types>
CbmQaCanvas(Types... args) : CbmQaCanvas(SetBatchModeOn(), args...) {}
/// Destructor
virtual ~CbmQaCanvas() {}
/// Divide canvas into nPads in 2D in a nice way
void Divide2D(int nPads);
private:
/// Use a specific type name in order to avoid ambiguities when unrolling
/// templates
enum MyBoolean : Bool_t;
/// Constructor which calls TCanvas constructor and restores the bach mode
template<typename... Types>
CbmQaCanvas(MyBoolean oldBatchMode, Types... args) : TCanvas(args...) {
gROOT->SetBatch((Bool_t) oldBatchMode);
}
/// Set batch mode ON and return its old value
static MyBoolean SetBatchModeOn() {
MyBoolean oldBatchMode = (MyBoolean) gROOT->IsBatch();
gROOT->SetBatch(kTRUE);
return oldBatchMode;
}
ClassDef(CbmQaCanvas, 1);
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment