8#include <calibration/example_caf_lib/TestDBAccessAlgorithm.h>
22 " -------------------------- Test Calibration Algorithm -------------------------\n"
24 " Testing algorithm which accesses DBObjPtr to show how it could be done. \n"
25 " ------------------------------------------------------------------------------\n"
33 auto ttree = getObjectPtr<TTree>(
"MyTree");
35 B2INFO(
"Number of Entries in MyTree was " << ttree->GetEntries());
37 if (ttree->GetEntries() < 100)
68 B2INFO(
"Mean from DB found for (Exp, Run) : ("
69 << expRun.first <<
"," << expRun.second <<
") = "
73 mean = ((42.0 - mean) / 3.) + mean;
74 float meanError =
m_dbMean->getMeanError();
76 B2INFO(
"New Mean from DB found for (Exp, Run) : ("
77 << expRun.first <<
"," << expRun.second <<
") = "
92 B2INFO(
"Mean from DB found for (Exp, Run) : ("
93 << expRun.first <<
"," << expRun.second <<
") = "
97 float meanError =
m_dbMean->getMeanError();
107 std::vector<float> vecDist;
112 B2INFO(
"Mean from DB found for (Exp, Run) : ("
113 << expRun.first <<
"," << expRun.second <<
") = "
116 vecDist.push_back(42.0 -
m_dbMean->getMean());
118 return std::accumulate(std::begin(vecDist), std::end(vecDist), 0.0) / vecDist.size();
124 float mean = gRandom->Gaus(42.0, 5.0);
125 float meanError = gRandom->Gaus(5.0, 0.2);
127 B2INFO(
"Saving new Mean for (Exp, Run) : ("
128 << expRun.first <<
"," << expRun.second <<
") = "
130 B2INFO(
"Saving new MeanError for (Exp, Run) : ("
131 << expRun.first <<
"," << expRun.second <<
") = "
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
void updateDBObjPtrs(const unsigned int event, const int run, const int experiment)
Updates any DBObjPtrs by calling update(event) for DBStore.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
const std::vector< Calibration::ExpRun > & getRunList() const
Get the list of runs for which calibration is called.
int getIteration() const
Get current iteration.
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
@ c_Iterate
Needs iteration =1 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
@ c_Failure
Failed =3 in Python.
A class that describes the interval of experiments/runs for which an object in the database is valid.
bool getGeneratePayloads() const
Getter for m_generatePayloads.
void setGeneratePayloads(const bool &value)
Setter for m_generatePayloads.
TestDBAccessAlgorithm()
Constructor set the prefix to TestCalibration.
void saveSameMeans()
Saves the same DB values for each run into a new localdb, otherwise we aren't creating a DB this iter...
float getAverageDistanceFromAnswer()
Grabs DBObjects from the Database and finds out the average distance from 42.
void generateNewPayloads()
Generates new payloads.
virtual EResult calibrate() override
Run algo on data.
DBObjPtr< TestCalibMean > m_dbMean
dbMean
void reduceDistancesAndSave()
Saves new DB values for each run where they are a little closer to 42.
Abstract base class for different kinds of events.