Belle II Software release-09-00-00
CDCDedxDatabaseImporter Class Reference

dE/dx database importer. More...

#include <CDCDedxDatabaseImporter.h>

Collaboration diagram for CDCDedxDatabaseImporter:

Public Member Functions

 CDCDedxDatabaseImporter (std::string inputFileName, const std::string &m_name)
 Constructor.
 
virtual ~CDCDedxDatabaseImporter ()
 Destructor.
 
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 32 of file CDCDedxDatabaseImporter.cc.

33{
34 m_inputFileNames.push_back(inputFileName);
35 m_name = name;
36}
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 48 of file CDCDedxDatabaseImporter.cc.

49{
50
51 TClonesArray hadronCorrection("Belle2::CDCDedxHadronCor");
52
53 TH1F* parhist = 0;
54 int nFiles = 0;
55
56 for (const std::string& inputFile : m_inputFileNames) {
57
58 TFile* f = TFile::Open(inputFile.c_str(), "READ");
59
60 TIter next(f->GetListOfKeys());
61 TKey* key;
62 while ((key = (TKey*) next())) {
63
64 std::string histconstants = key->GetName();
65
66 if (histconstants.compare("CDCDedxHadronCor") == 0) {
67 parhist = (TH1F*)f->Get(histconstants.c_str());
68 B2INFO("Key name matches: " << histconstants);
69 }
70
71 else {
72 B2WARNING("Key name does not match: " << histconstants);
73 continue;
74 }
75 }
76
77 nFiles++;
78 }
79
80 if (nFiles != 1) { B2FATAL("Sorry, you must only import one file at a time for now!"); }
81
82 // loop over the histogram to fill the TClonesArray
83 if (!parhist) B2FATAL("None of the input files contains the histogram called 'CDCDedxHadronCor'!");
84 short version = parhist->GetBinContent(1);
85 std::vector<double> hadroncor;
86 for (int bin = 2; bin <= parhist->GetNbinsX(); ++bin) {
87 hadroncor.push_back(parhist->GetBinContent(bin));
88 }
89 new (hadronCorrection[0]) CDCDedxHadronCor(version, hadroncor);
90
91 IntervalOfValidity iov(0, 0, -1, -1); // IOV (0,0,-1,-1) is valid for all runs and experiments
92 Database::Instance().storeData(m_name, hadronCorrection[0], iov);
93}
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 95 of file CDCDedxDatabaseImporter.cc.

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

◆ importScaleFactor()

void importScaleFactor ( double  scale)

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

Definition at line 38 of file CDCDedxDatabaseImporter.cc.

39{
40
41 TClonesArray scaleFactor("Belle2::CDCDedxScaleFactor");
42 new (scaleFactor[0]) CDCDedxScaleFactor(scale);
43
44 IntervalOfValidity iov(0, 0, -1, -1); // IOV (0,0,-1,-1) is valid for all runs and experiments
45 Database::Instance().storeData(m_name, scaleFactor[0], iov);
46}
dE/dx run gain calibration constants

◆ importSigmaParameters()

void importSigmaParameters ( )

Import predicted resolution parameters to the database.

Definition at line 142 of file CDCDedxDatabaseImporter.cc.

143{
144
145 TClonesArray sigmaParameters("Belle2::CDCDedxSigmaPars");
146
147 TH1F* parhist = 0;
148 int nFiles = 0;
149
150 for (const std::string& inputFile : m_inputFileNames) {
151
152 TFile* f = TFile::Open(inputFile.c_str(), "READ");
153
154 TIter next(f->GetListOfKeys());
155 TKey* key;
156 while ((key = (TKey*) next())) {
157
158 std::string histconstants = key->GetName();
159
160 if (histconstants.compare("CDCDedxSigmaPars") == 0) {
161 parhist = (TH1F*)f->Get(histconstants.c_str());
162 B2INFO("Key name matches: " << histconstants);
163 }
164
165 else {
166 B2WARNING("Key name does not match: " << histconstants);
167 continue;
168 }
169 }
170
171 nFiles++;
172 }
173
174 if (nFiles != 1) { B2FATAL("Sorry, you must only import one file at a time for now!"); }
175
176 // loop over the histogram to fill the TClonesArray
177 if (!parhist) B2FATAL("None of the input files contains the histogram called 'CDCDedxSigmaPars'!");
178 short version = parhist->GetBinContent(1);
179 std::vector<double> sigmapars;
180 for (int bin = 2; bin <= parhist->GetNbinsX(); ++bin) {
181 sigmapars.push_back(parhist->GetBinContent(bin));
182 }
183 new (sigmaParameters[0]) CDCDedxSigmaPars(version, sigmapars);
184
185 IntervalOfValidity iov(0, 0, -1, -1); // IOV (0,0,-1,-1) is valid for all runs and experiments
186 Database::Instance().storeData(m_name, sigmaParameters[0], iov);
187}
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 59 of file CDCDedxDatabaseImporter.h.

◆ m_name

std::string m_name
private

Name of database ROOT file.

Definition at line 60 of file CDCDedxDatabaseImporter.h.


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