11 #include <calibration/example_caf_lib/modules/CaTest/CaTestModule.h>
19 #include <alignment/dataobjects/MilleData.h>
20 #include <framework/pcore/ProcHandler.h>
37 setDescription(
"Test Module for saving big data in CAF");
39 addParam(
"entriesPerEvent", m_entriesPerEvent,
40 "Number of entries that we fill into the saved tree per event. As we increase this we start storing larger amonuts of data in a smaller number of events to test the limits.",
42 addParam(
"spread", m_spread,
43 "Spread of gaussian (mean=42) filling of test histogram (range=<0,100>) - probability of algo iterations depend on it",
int(17.));
48 describeProcess(
"CaTest::prepare");
49 std::string objectName =
"MyTree";
51 TTree* tree =
new TTree(objectName.c_str(),
"");
52 tree->Branch<
int>(
"event", &m_evt);
53 tree->Branch<
int>(
"run", &m_run);
54 tree->Branch<
int>(
"exp", &m_exp);
55 tree->Branch<
double>(
"hitX", &m_hitX);
56 tree->Branch<
double>(
"hitY", &m_hitY);
57 tree->Branch<
double>(
"hitZ", &m_hitZ);
58 tree->Branch<
double>(
"trackX", &m_trackX);
59 tree->Branch<
double>(
"trackY", &m_trackY);
60 tree->Branch<
double>(
"trackZ", &m_trackZ);
61 tree->Branch<
double>(
"chisq", &m_chisq);
62 tree->Branch<
double>(
"pvalue", &m_pvalue);
63 tree->Branch<
double>(
"dof", &m_dof);
68 registerObject<TTree>(objectName, tree);
70 auto hist =
new TH1F(
"histo",
"Test histogram, which mean value should be found by test calibration algo", 100, 0., 100.);
71 registerObject<TH1F>(
"MyHisto", hist);
74 registerObject<MilleData>(
"test_mille", mille);
79 describeProcess(
"CaTest::inDefineHisto()");
84 describeProcess(
"CaTest::startRun()");
89 describeProcess(
"CaTest::closeRun()");
93 auto mille = getObjectPtr<MilleData>(
"test_mille");
94 if (mille->isOpen()) {
95 for (
auto& fileName : mille->getFiles()) {
96 B2DEBUG(100,
"Stored Mille binary file: " << fileName);
105 describeProcess(
"CaTest::collect()");
106 m_evt = m_emdata->getEvent();
107 m_run = m_emdata->getRun();
108 m_exp = m_emdata->getExperiment();
110 std::string objectName =
"MyTree";
111 auto tree = getObjectPtr<TTree>(objectName);
112 auto hist = getObjectPtr<TH1F>(
"MyHisto");
114 for (
int i = 0; i < m_entriesPerEvent; ++i) {
115 m_hitX = gRandom->Gaus();
116 m_hitY = gRandom->Gaus();
117 m_hitZ = gRandom->Gaus();
118 m_trackX = gRandom->Gaus();
119 m_trackY = gRandom->Gaus();
120 m_trackZ = gRandom->Gaus();
121 m_chisq = gRandom->Gaus();
122 m_pvalue = gRandom->Gaus();
123 m_dof = gRandom->Gaus();
125 hist->Fill(gRandom->Gaus(42., m_spread));
128 auto mille = getObjectPtr<MilleData>(
"test_mille");
130 if (!mille->isOpen()) {
131 string newFileName = to_string(m_exp) +
"-" + to_string(m_run) +
"-sevt-" + to_string(m_evt) +
"-pid" + std::to_string(
133 B2INFO(
"Opening new binary file " << newFileName);
134 mille->open(newFileName);
140 describeProcess(
"CaTest::finish()");
143 void CaTestModule::describeProcess(
const string& functionName)
148 +
"\nThe gDirectory is " + gDirectory->GetPath());