REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestResponse.h
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see https://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see https://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
23#ifndef REST_TRestResponse
24#define REST_TRestResponse
25
26#include "TRestMetadata.h"
27
30 private:
32 std::string fFilename = "";
33
35 std::string fVariable = "";
36
38 TVector2 fOrigin = TVector2(0, 0);
39
41 Double_t fBinSize = 0.1; //<
42
44 std::vector<std::vector<Float_t>> fResponseMatrix; //<
45
47 Bool_t fTransposed = false; //<
48
50 Bool_t fInterpolation = false;
51
52 public:
53 void SetBinSize(Double_t bSize) { fBinSize = bSize; }
54 void SetResponseFilename(std::string responseFile) { fFilename = responseFile; }
55 void SetOrigin(const TVector2& v) { fOrigin = v; }
56 void SetVariable(const std::string& var) { fVariable = var; }
57
58 Bool_t ApplyInterpolation() { return fInterpolation; }
59 void Interpolate(Bool_t interpolate = true) { fInterpolation = interpolate; }
60
61 Double_t GetBinSize() const { return fBinSize; }
62 std::string GetResponseFilename() const { return fFilename; }
63 TVector2 GetOrigin() const { return fOrigin; }
64 std::string GetVariable() const { return fVariable; }
65
66 TVector2 GetInputRange() const {
67 return TVector2(fOrigin.X(), fOrigin.X() + fResponseMatrix[0].size() * fBinSize);
68 }
69
70 TVector2 GetOutputRange() const {
71 return TVector2(fOrigin.Y(), fOrigin.Y() + fResponseMatrix.size() * fBinSize);
72 }
73
74 void Initialize() override;
75
76 void LoadResponse(Bool_t transpose = true);
77
78 std::vector<std::pair<Double_t, Double_t>> GetResponse(Double_t input);
79
80 void PrintResponseMatrix(Int_t fromRow, Int_t toRow);
81
82 void PrintMetadata() override;
83
84 std::vector<std::vector<Float_t>> GetMatrix() const { return fResponseMatrix; }
85
86 TRestResponse(const char* cfgFileName, const std::string& name = "");
89
90 ClassDefOverride(TRestResponse, 1);
91};
92#endif
A base class for any REST metadata class.
Definition: TRestMetadata.h:70
A response matrix that might be applied to a given component inside a TRestComponent.
Definition: TRestResponse.h:29
Double_t fBinSize
The resolution of the response matrix (binning)
Definition: TRestResponse.h:41
std::vector< std::vector< Float_t > > fResponseMatrix
The response matrix.
Definition: TRestResponse.h:44
Bool_t fTransposed
Determines if the response matrix has been transposed.
Definition: TRestResponse.h:47
void Initialize() override
It will initialize the data frame with the filelist and column names (or observables) that have been ...
void LoadResponse(Bool_t transpose=true)
It loads into the fResponseMatrix data member the response from a file.
~TRestResponse()
Default destructor.
Bool_t fInterpolation
It allows to decide if the returned response should be interpolated (default:false)
Definition: TRestResponse.h:50
std::string fVariable
It defines the variable name for which the response should be applied to.
Definition: TRestResponse.h:35
std::vector< std::pair< Double_t, Double_t > > GetResponse(Double_t input)
This method will return a vector of std::pair, each pair will contain the output energy together with...
TVector2 fOrigin
First element of the response matrix (input/incident, output/detected)
Definition: TRestResponse.h:38
TRestResponse()
Default constructor.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestAxionSolarFlux.
std::string fFilename
The filename used to import the response matrix.
Definition: TRestResponse.h:32
void PrintResponseMatrix(Int_t fromRow, Int_t toRow)
Prints on screen the information about the metadata members of TRestAxionSolarFlux.