R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandVisualizer.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
15#include "TF1.h"
16#include "TList.h"
17#include "TPaletteAxis.h"
18#include "TROOT.h"
19#include "TStyle.h"
20#include <iostream>
21
22/* This function is required to suppress boxes for empty bins - make them transparent.*/
23static Double_t gEmptyBinSupressor(const Double_t* x, const Double_t*)
24{
25 if (x)
26 {
27 return *x > 0 ? 1. : 0.;
28 }
29 return 0.;
30}
31
32R3BNeulandVisualizer::R3BNeulandVisualizer(const TString& inputFileName, const TString& what)
33 : fFile(std::make_shared<TFile>(inputFileName, "read"))
34 , fTree(dynamic_cast<TTree*>(fFile->Get("evt")))
35 , fh3(nullptr)
36 , fCanvas(nullptr)
37 , fIndex(0)
38{
39 fTree->SetBranchAddress(what, &fh3);
40
41 gStyle->SetCanvasPreferGL(kTRUE);
42 gStyle->SetPalette(kViridis);
43 gStyle->SetOptStat(0);
44
45 // Needs to be after setting gStyle
46 fCanvas = std::make_shared<TCanvas>("canvas", "NeuLAND 3D Event Visualization", 0, 0, 800, 800);
47
48 Visualize();
49}
50
52{
53 if (fIndex >= fTree->GetEntries())
54 {
55 std::cout << "Index larger than number of Events" << std::endl;
56 return;
57 }
58
59 fTree->GetEntry(fIndex);
60
61 TList* const lof = fh3->GetListOfFunctions();
62 lof->Add(new TF1("TransferFunction", gEmptyBinSupressor, 0., 1000., 0));
63
64 fh3->Draw("glcolz");
65
66 fCanvas->Flush();
67}
68
ClassImp(R3B::Neuland::Cal2HitPar)
static Double_t gEmptyBinSupressor(const Double_t *x, const Double_t *)
static Double_t gEmptyBinSupressor(const Double_t *x, const Double_t *)
R3BNeulandVisualizer(const TString &input_file, const TString &what)