10#include <ecl/modules/eclLocalRunCalibration/ECLLocalRunCalibratorModule.h>
13#include <ecl/dataobjects/ECLElementNumbers.h>
14#include <ecl/dataobjects/ECLTrig.h>
37 m_time(nullptr), m_ampl(nullptr)
53 "Number of standard deviations used to form initial limits.", 5);
56 "select local or central DB.",
true);
58 std::string defaultDBName =
"localdb/database.txt";
61 "to a local DB.", defaultDBName);
64 "If changePrev is set, the upper run in the interval of "
65 "validity for the previous written payload will be changed.",
69 "Low run for validity interval. "
70 "If the low run value is negative, "
72 "is used as a low run.", -1);
75 "High run for validity interval. "
76 "If the high run value is equal to -1, "
77 "the high run of validity interval is not limited.",
81 "Mark run as reference if it is"
82 "needed to do that at start",
86 "Fill time and amplitude histograms"
87 "for a certain cell id.",
false);
90 "Cell id number, used to "
91 "fill amplitude or time histogram.");
94 const std::string defaultHistoFileName =
95 "time_ampl_histo.root";
99 "File name used to save amplitude and time"
100 "histograms for a certain cell id.",
101 defaultHistoFileName);
104 "Fill full tree.",
false);
124 m_histo_time =
new TH1F(
"histo_time",
"", 10000, -1, -1);
125 m_histo_ampl =
new TH1F(
"histo_ampl",
"", 10000, -1, -1);
138 m_tree =
new TTree(
"localrun",
"");
156 B2FATAL(
"ECLDigits not valid");
162 auto cellid = digit.getCellId();
163 auto index = cellid - 1;
165 if (index < 0 || index >=
signed(
c_ncellids)) {
166 B2FATAL(
"ECLLocalRunCalibratorModule::event(): cell id = "
167 << cellid <<
" out of range!");
170 auto time = digit.getTimeFit();
173 auto ampl = digit.getAmp();
268 auto fl = TFile::Open(
"/ghi/fs01/belle2/bdata/group/detector/ECL/local-run-db/data-full/ecl_local_run_fulltree.root",
283 static_cast<uint32_t
>(
298 return time - 2 * (time / 8);
Class to store ECL digitized hits (output of ECLDigi) relation to ECLHit filled in ecl/modules/eclDig...
ECLLocalRunCalibUnit is the class designed for the control of mean value and the standard deviation a...
void calc()
Calculate accumulated values.
void enableNegAmpl()
This function will be called only in the case, if negative amplitudes are observed in the current run...
void writeToDB(bool isLocal, const std::string &dbName, const std::string &payloadName, const IntervalOfValidity &iov, const int &run, const bool &changePrev, const bool &addref)
Write calibration results into a database.
void add(const int &cellid, const float &value)
Add value to accumulate mean value, standard deviation and number of accepted events.
std::string m_dbName
Tag of central database or path to a local database.
float m_tree_ampl
Amplitude variable used to fill tree.
bool m_isFillHisto
If m_isFillHisto is false, than the mode of local run calibration is enabled.
int m_cellid
cell id number.
bool m_isLocal
Enables local database usage.
TTree * m_tree
Full tree of times and amplitudes per each cellid before calculating mean values.
float m_tree_time
Time variable used to fill tree.
~ECLLocalRunCalibratorModule()
Destructor.
static const std::string c_amplPayloadName
Name of the amplitude payload.
void event() override
Event.
static const std::string c_timePayloadName
Name of the time payload.
bool m_addref
If m_addref is true, then the current calibration run will be marked as reference run immediately aft...
void endRun() override
End run.
float m_maxAmpl
Maximum allowed amplitude value.
float m_minTime
Minimum allowed time value.
StoreArray< ECLDigit > m_ECLDigits
ECL digits.
ECLLocalRunCalibratorModule()
Constructor.
int m_tree_event
Event variable used to fill tree.
int m_tree_cellid
Cellid variable used to fill tree.
ECLLocalRunCalibUnit * m_ampl
m_ampl contains amplitude mean value and standard deviation accumulators for all cell ids.
void beginRun() override
Begin run.
TH1F * m_histo_ampl
m_histo_ampl is the name of the histogram, which contains amplitude distribution for a certain cell i...
bool m_fulltree
Write full tree of times and amplitudes per each cellid (before calculating mean values) to file "ecl...
ECLLocalRunCalibUnit * m_time
m_time contains time mean value and standard deviation accumulators for all cell ids.
uint32_t decodeTrigTime(uint32_t time) const
Decode time.
float m_maxTime
Maximum allowed time value.
static const int c_ncellids
Number of cell ids.
std::string m_histoFileName
The path of the .root file with the histograms obtained in the histogram filling mode.
bool m_changePrev
If m_changePrev is true, the validity intervals of the previous payloads stored into the database wil...
int m_highRun
High run of the validity interval.
int m_lowRun
Low run of the validity interval.
void writeHistoToFile()
Write histograms to file in the case, if the histogram filling mode is enabled.
TH1F * m_histo_time
m_histo_time is the name of the histogram, which contains time distribution for a certain cell id.
void writeCalibResultsToDB()
Write calibration results into a database.
StoreObjPtr< EventMetaData > m_EventMetaData
Event metadata.
float m_minAmpl
Minimum allowed amplitude value.
int m_devs
Number of standard deviations used to update value limits.
int16_t getTimeShift(const ECLDigit &digit) const
Calculate time shift.
Class to store ECLTrig, still need to be study relation to ECLHit filled in ecl/modules/eclDigitizer/...
A class that describes the interval of experiments/runs for which an object in the database is valid.
void setDescription(const std::string &description)
Sets the description of the module.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.