Belle II Software development
MillepedeTreeConversionAlgorithm.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <alignment/calibration/MillepedeTreeConversionAlgorithm.h>
10
11#include <genfit/GblData.h>
12
13#include <TFile.h>
14
15using namespace Belle2;
16
18 CalibrationAlgorithm("MillepedeCollector"), m_OutputFile("millepede_data.root") {}
19
21{
22}
23
25{
26 m_OutputFile = outputFile;
27}
28
30{
31 const int max_entries = 100;
32 int i, j, n;
33 std::vector<gbl::GblData>* dat = NULL;
34 std::vector<gbl::GblData>::iterator it;
35 double aValue, aErr;
36 std::vector<unsigned int>* indLocal;
37 std::vector<int>* labGlobal;
38 std::vector<double>* derLocal, *derGlobal;
39 float value, error, der[max_entries];
40 int nlab, label[max_entries];
41 auto gblData = getObjectPtr<TTree>("GblDataTree");
42 gblData->SetBranchAddress("GblData", &dat);
43 TFile* f_out = new TFile(m_OutputFile.c_str(), "recreate");
44 TTree* t_out = new TTree("mille", "");
45 t_out->Branch("value", &value, "value/F");
46 t_out->Branch("error", &error, "error/F");
47 t_out->Branch("nlab", &nlab, "nlab/I");
48 t_out->Branch("label", label, "label[nlab]/I");
49 t_out->Branch("der", der, "der[nlab]/F");
50 n = gblData->GetEntries();
51 for (i = 0; i < n; i++) {
52 gblData->GetEntry(i);
53 for (it = dat->begin(); it != dat->end(); ++it) {
54 it->getAllData(aValue, aErr, indLocal, derLocal, labGlobal, derGlobal);
55 if (labGlobal->size() == 0)
56 continue;
57 value = aValue;
58 error = aErr;
59 nlab = std::min((int)labGlobal->size(), max_entries);
60 for (j = 0; j < nlab; j++) {
61 label[j] = (*labGlobal)[j];
62 der[j] = (*derGlobal)[j];
63 }
64 t_out->Fill();
65 }
66 }
67 f_out->cd();
68 t_out->Write();
69 delete t_out;
70 delete f_out;
72}
73
Base class for calibration algorithms.
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
void setOutputFile(const char *outputFile)
Set output file name.
CalibrationAlgorithm::EResult calibrate() override
Calibration.
Abstract base class for different kinds of events.