Visualizer.h 2.78 KB
Newer Older
1
/** @file Visualizer.h
2
 *  @brief Class to have a simple visualization of plots through JZCaPA. If you want to plot something, just define here a child method and use it recursively, w/o filling the code with canvases et al.
3
4
5
6
7
8
9
10
11
 *
 *  @author Riccardo Longo
 *  @bug No known bugs.
 */

#ifndef VISUALIZER_H
#define VISUALIZER_H

#include "TH1.h"
12
#include "TH2.h"
13
#include "TStyle.h"
14
15
#include "TVector.h"
#include "TGraph.h"
clantz's avatar
clantz committed
16
17
#include "TVirtualPad.h"
#include "TMarker.h"
18

19
20
#include "Containers.h"

21
#include "TString.h"
22

23
24
25
26
27
28
#include <iostream>
#include <vector>

class Visualizer {

    public :
Chad Lantz's avatar
Chad Lantz committed
29
    Visualizer();
30
31
    Visualizer( std::string _style );

32
    //Styles (so far only ATLAS)
33
    TStyle* AtlasStyle();
Riccardo Longo's avatar
Riccardo Longo committed
34
    //Methods to set a given style
35
36
    void SetAtlasStyle();

37
    /** @brief Sets the label to be printed on each plot **/
38
    void SetTestBeamLabel(std::string _category, std::string _year, std::string _beam) { m_category = _category; m_year = _year; m_beam = _beam; }
39
    void SetTestBeamLabel( int runNo, Alignment* alignment );
40
    void SetTestBeamLabel( int runNo, Alignment2021* alignment );
41

Riccardo Longo's avatar
Riccardo Longo committed
42
43
    /** @brief allow the user to define the extension of the plots once they're printed. ".pdf" by default */
    void SetPlotExtension( std::string _extension ) { m_extension = _extension; }
44

45
46
    /** @brief Set the output directory of Visualizer */
    void SetOutputDirectory( std::string _oFolder ){ m_oFolder = _oFolder; }
Riccardo Longo's avatar
Riccardo Longo committed
47

48
    /** @brief make the argument true to activate the debug mode. False to deactivate it*/
Riccardo Longo's avatar
Riccardo Longo committed
49
    void   SetDebugMode   ( bool _isDebugon ) { m_debug = _isDebugon; }
50
51

    //Special plot treatments
52
53
    void   OverlayHistos  ( TH1 *h1, TH1 *h2 , TVirtualPad* pad, double _line = 0);
    void   ScatterPlot    ( std::vector< double > _v1, std::vector< double > _v2, TVirtualPad* pad);
54
55

    //Main visualization methods
56
    void   ManyPadsPlot   ( std::vector< TH1* > _first_form, std::vector< TH1* > _second_form, int _ncol, int _nrow, std::string _out_name, TString _treatment );
57
    void   SinglePlot     ( std::vector< double > _v1, std::vector< double > _v2, std::string _out_name, std::string _treatment, double _line = 0);
58

59
    void   DrawPlot (TH1* h2, std::string _xTitle, std::string _yTitle, std::string _saveName, std::string _opt, TMarker* _marker = 0, std::string _oFolder = "" );
60

61
62
63
    private :
    /** String identifying the style to be applied */
    std::string m_style;
64
    /** Strings encoding the year of the test and the beam **/
65
66
67
    std::string m_category = "NO";
    std::string m_year = "NO";
    std::string m_beam = "NO";
68
69
    /** Output folder for plots. Defaults to $JZCaPA/results/ */
    std::string m_oFolder = "${JZCaPA}/results/";
70
71
    /** Debug flag */
    bool m_debug = false;
72

Riccardo Longo's avatar
Riccardo Longo committed
73
74
    /** String defining the extension used to print the plots */
    std::string m_extension = ".pdf";
75
76
77
};

#endif