9 #include <calibration/example_caf_lib/modules/CaTest/CaTestModule.h>
17 #include <alignment/dataobjects/MilleData.h>
18 #include <framework/pcore/ProcHandler.h>
35 setDescription(
"Test Module for saving big data in CAF");
37 addParam(
"entriesPerEvent", m_entriesPerEvent,
38 "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.",
40 addParam(
"spread", m_spread,
41 "Spread of gaussian (mean=42) filling of test histogram (range=<0,100>) - probability of algo iterations depend on it",
int(17.));
46 describeProcess(
"CaTest::prepare");
47 std::string objectName =
"MyTree";
49 TTree* tree =
new TTree(objectName.c_str(),
"");
50 tree->Branch<
int>(
"event", &m_evt);
51 tree->Branch<
int>(
"run", &m_run);
52 tree->Branch<
int>(
"exp", &m_exp);
53 tree->Branch<
double>(
"hitX", &m_hitX);
54 tree->Branch<
double>(
"hitY", &m_hitY);
55 tree->Branch<
double>(
"hitZ", &m_hitZ);
56 tree->Branch<
double>(
"trackX", &m_trackX);
57 tree->Branch<
double>(
"trackY", &m_trackY);
58 tree->Branch<
double>(
"trackZ", &m_trackZ);
59 tree->Branch<
double>(
"chisq", &m_chisq);
60 tree->Branch<
double>(
"pvalue", &m_pvalue);
61 tree->Branch<
double>(
"dof", &m_dof);
66 registerObject<TTree>(objectName, tree);
68 auto hist =
new TH1F(
"histo",
"Test histogram, which mean value should be found by test calibration algo", 100, 0., 100.);
69 registerObject<TH1F>(
"MyHisto", hist);
72 registerObject<MilleData>(
"test_mille", mille);
77 describeProcess(
"CaTest::inDefineHisto()");
82 describeProcess(
"CaTest::startRun()");
87 describeProcess(
"CaTest::closeRun()");
91 auto mille = getObjectPtr<MilleData>(
"test_mille");
92 if (mille->isOpen()) {
93 for (
auto& fileName : mille->getFiles()) {
94 B2DEBUG(100,
"Stored Mille binary file: " << fileName);
103 describeProcess(
"CaTest::collect()");
104 m_evt = m_emdata->getEvent();
105 m_run = m_emdata->getRun();
106 m_exp = m_emdata->getExperiment();
108 std::string objectName =
"MyTree";
109 auto tree = getObjectPtr<TTree>(objectName);
110 auto hist = getObjectPtr<TH1F>(
"MyHisto");
112 for (
int i = 0; i < m_entriesPerEvent; ++i) {
113 m_hitX = gRandom->Gaus();
114 m_hitY = gRandom->Gaus();
115 m_hitZ = gRandom->Gaus();
116 m_trackX = gRandom->Gaus();
117 m_trackY = gRandom->Gaus();
118 m_trackZ = gRandom->Gaus();
119 m_chisq = gRandom->Gaus();
120 m_pvalue = gRandom->Gaus();
121 m_dof = gRandom->Gaus();
123 hist->Fill(gRandom->Gaus(42., m_spread));
126 auto mille = getObjectPtr<MilleData>(
"test_mille");
128 if (!mille->isOpen()) {
129 string newFileName = to_string(m_exp) +
"-" + to_string(m_run) +
"-sevt-" + to_string(m_evt) +
"-pid" + std::to_string(
131 B2INFO(
"Opening new binary file " << newFileName);
132 mille->open(newFileName);
138 describeProcess(
"CaTest::finish()");
141 void CaTestModule::describeProcess(
const string& functionName)
146 +
"\nThe gDirectory is " + gDirectory->GetPath());
Testing module for collection of calibration data.
virtual void startRun() override
Replacement for beginRun(). Do anything you would normally do in beginRun here.
virtual void collect() override
Replacement for event(). Fill you calibration data objects here.
virtual void closeRun() override
Replacement for endRun(). Do anything you would normally do in endRun here.
virtual void prepare() override
Replacement for initialize(). Register calibration dataobjects here as well.
virtual void finish() override
Replacement for terminate(). Do anything you would normally do in terminate here.
virtual void inDefineHisto() override
Runs during the defineHisto() function.
Calibration collector module base class.
Mergeable class holding list of so far opened mille binaries and providing the binaries.
static int EvtProcID()
Return ID of the current process.
static bool parallelProcessingUsed()
Returns true if multiple processes have been spawned, false in single-core mode.
static std::string getProcessName()
Get a name for this process.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.