Belle II Software development
CDCDedxDatabaseImporter Class Reference

dE/dx database importer. More...

#include <CDCDedxDatabaseImporter.h>

Public Member Functions

 CDCDedxDatabaseImporter (std::string inputFileName, const std::string &m_name)
 Constructor.
 
virtual ~CDCDedxDatabaseImporter ()
 Destructor.
 
void importPDFs ()
 Import a set of dedx:momentum pdfs.
 
void importScaleFactor (double scale)
 Import a scale factor to make electron dE/dx ~ 1.
 
void importHadronCorrection ()
 Import parameters for the hadron correction.
 
void importMeanParameters ()
 Import predicted mean parameters to the database.
 
void importSigmaParameters ()
 Import predicted resolution parameters to the database.
 

Private Attributes

std::vector< std::string > m_inputFileNames
 Name of input ROOT files.
 
std::string m_name
 Name of database ROOT file.
 

Detailed Description

dE/dx database importer.

This module writes data from e.g. a ROOT histogram to database.

Definition at line 23 of file CDCDedxDatabaseImporter.h.

Constructor & Destructor Documentation

◆ CDCDedxDatabaseImporter()

CDCDedxDatabaseImporter ( std::string  inputFileName,
const std::string &  m_name 
)

Constructor.

Definition at line 33 of file CDCDedxDatabaseImporter.cc.

34{
35 m_inputFileNames.push_back(inputFileName);
36 m_name = name;
37}
std::vector< std::string > m_inputFileNames
Name of input ROOT files.
std::string m_name
Name of database ROOT file.

◆ ~CDCDedxDatabaseImporter()

virtual ~CDCDedxDatabaseImporter ( )
inlinevirtual

Destructor.

Definition at line 35 of file CDCDedxDatabaseImporter.h.

35{};

Member Function Documentation

◆ importHadronCorrection()

void importHadronCorrection ( )

Import parameters for the hadron correction.

Definition at line 59 of file CDCDedxDatabaseImporter.cc.

60{
61
62 TClonesArray hadronCorrection("Belle2::CDCDedxHadronCor");
63
64 TH1F* parhist = 0;
65 int nFiles = 0;
66
67 for (const std::string& inputFile : m_inputFileNames) {
68
69 TFile* f = TFile::Open(inputFile.c_str(), "READ");
70
71 TIter next(f->GetListOfKeys());
72 TKey* key;
73 while ((key = (TKey*) next())) {
74
75 std::string histconstants = key->GetName();
76
77 if (histconstants.compare("CDCDedxHadronCor") == 0) {
78 parhist = (TH1F*)f->Get(histconstants.c_str());
79 B2INFO("Key name matches: " << histconstants);
80 }
81
82 else {
83 B2WARNING("Key name does not match: " << histconstants);
84 continue;
85 }
86 }
87
88 nFiles++;
89 }
90
91 if (nFiles != 1) { B2FATAL("Sorry, you must only import one file at a time for now!"); }
92
93 // loop over the histogram to fill the TClonesArray
94 if (!parhist) B2FATAL("None of the input files contains the histogram called 'CDCDedxHadronCor'!");
95 short version = parhist->GetBinContent(1);
96 std::vector<double> hadroncor;
97 for (int bin = 2; bin <= parhist->GetNbinsX(); ++bin) {
98 hadroncor.push_back(parhist->GetBinContent(bin));
99 }
100 new (hadronCorrection[0]) CDCDedxHadronCor(version, hadroncor);
101
102 IntervalOfValidity iov(0, 0, -1, -1); // IOV (0,0,-1,-1) is valid for all runs and experiments
103 Database::Instance().storeData(m_name, hadronCorrection[0], iov);
104}
dE/dx hadron saturation parameterization constants
A class that describes the interval of experiments/runs for which an object in the database is valid.
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition: Database.cc:141

◆ importMeanParameters()

void importMeanParameters ( )

Import predicted mean parameters to the database.

Definition at line 106 of file CDCDedxDatabaseImporter.cc.

107{
108
109 TClonesArray meanParameters("Belle2::CDCDedxMeanPars");
110
111 TH1F* parhist = 0;
112 int nFiles = 0;
113
114 for (const std::string& inputFile : m_inputFileNames) {
115
116 TFile* f = TFile::Open(inputFile.c_str(), "READ");
117
118 TIter next(f->GetListOfKeys());
119 TKey* key;
120 while ((key = (TKey*) next())) {
121
122 std::string histconstants = key->GetName();
123
124 if (histconstants.compare("CDCDedxMeanPars") == 0) {
125 parhist = (TH1F*)f->Get(histconstants.c_str());
126 B2INFO("Key name matches: " << histconstants);
127 }
128
129 else {
130 B2WARNING("Key name does not match: " << histconstants);
131 continue;
132 }
133 }
134
135 nFiles++;
136 }
137
138 if (nFiles != 1) { B2FATAL("Sorry, you must only import one file at a time for now!"); }
139
140 // loop over the histogram to fill the TClonesArray
141 if (!parhist) B2FATAL("None of the input files contains the histogram called 'CDCDedxMeanPars'!");
142 short version = parhist->GetBinContent(1);
143 std::vector<double> meanpars;
144 for (int bin = 2; bin <= parhist->GetNbinsX(); ++bin) {
145 meanpars.push_back(parhist->GetBinContent(bin));
146 }
147 new (meanParameters[0]) CDCDedxMeanPars(version, meanpars);
148
149 IntervalOfValidity iov(0, 0, -1, -1); // IOV (0,0,-1,-1) is valid for all runs and experiments
150 Database::Instance().storeData(m_name, meanParameters[0], iov);
151}
dE/dx mean (curve versus beta-gamma) parameterization constants

◆ importPDFs()

void importPDFs ( )

Import a set of dedx:momentum pdfs.

Definition at line 39 of file CDCDedxDatabaseImporter.cc.

40{
41 TClonesArray dedxPDFs("Belle2::DedxPDFs");
42 TFile* infile = TFile::Open(m_inputFileNames[0].c_str(), "READ");
43 new (dedxPDFs[0]) DedxPDFs(infile);
44
45 IntervalOfValidity iov(0, 0, -1, -1); // IOV (0,0,-1,-1) is valid for all runs and experiments
46 Database::Instance().storeData(m_name, dedxPDFs[0], iov);
47}
dE/dx wire gain calibration constants
Definition: DedxPDFs.h:27

◆ importScaleFactor()

void importScaleFactor ( double  scale)

Import a scale factor to make electron dE/dx ~ 1.

Definition at line 49 of file CDCDedxDatabaseImporter.cc.

50{
51
52 TClonesArray scaleFactor("Belle2::CDCDedxScaleFactor");
53 new (scaleFactor[0]) CDCDedxScaleFactor(scale);
54
55 IntervalOfValidity iov(0, 0, -1, -1); // IOV (0,0,-1,-1) is valid for all runs and experiments
56 Database::Instance().storeData(m_name, scaleFactor[0], iov);
57}
dE/dx run gain calibration constants

◆ importSigmaParameters()

void importSigmaParameters ( )

Import predicted resolution parameters to the database.

Definition at line 153 of file CDCDedxDatabaseImporter.cc.

154{
155
156 TClonesArray sigmaParameters("Belle2::CDCDedxSigmaPars");
157
158 TH1F* parhist = 0;
159 int nFiles = 0;
160
161 for (const std::string& inputFile : m_inputFileNames) {
162
163 TFile* f = TFile::Open(inputFile.c_str(), "READ");
164
165 TIter next(f->GetListOfKeys());
166 TKey* key;
167 while ((key = (TKey*) next())) {
168
169 std::string histconstants = key->GetName();
170
171 if (histconstants.compare("CDCDedxSigmaPars") == 0) {
172 parhist = (TH1F*)f->Get(histconstants.c_str());
173 B2INFO("Key name matches: " << histconstants);
174 }
175
176 else {
177 B2WARNING("Key name does not match: " << histconstants);
178 continue;
179 }
180 }
181
182 nFiles++;
183 }
184
185 if (nFiles != 1) { B2FATAL("Sorry, you must only import one file at a time for now!"); }
186
187 // loop over the histogram to fill the TClonesArray
188 if (!parhist) B2FATAL("None of the input files contains the histogram called 'CDCDedxSigmaPars'!");
189 short version = parhist->GetBinContent(1);
190 std::vector<double> sigmapars;
191 for (int bin = 2; bin <= parhist->GetNbinsX(); ++bin) {
192 sigmapars.push_back(parhist->GetBinContent(bin));
193 }
194 new (sigmaParameters[0]) CDCDedxSigmaPars(version, sigmapars);
195
196 IntervalOfValidity iov(0, 0, -1, -1); // IOV (0,0,-1,-1) is valid for all runs and experiments
197 Database::Instance().storeData(m_name, sigmaParameters[0], iov);
198}
dE/dx sigma (versus beta-gamma) parameterization constants

Member Data Documentation

◆ m_inputFileNames

std::vector<std::string> m_inputFileNames
private

Name of input ROOT files.

Definition at line 64 of file CDCDedxDatabaseImporter.h.

◆ m_name

std::string m_name
private

Name of database ROOT file.

Definition at line 65 of file CDCDedxDatabaseImporter.h.


The documentation for this class was generated from the following files: