Belle II Software development
eclWaveformTemplateCalibrationC3Algorithm.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/* Own header. */
10#include <ecl/calibration/eclWaveformTemplateCalibrationC3Algorithm.h>
11
12/* ECL headers. */
13#include <ecl/dataobjects/ECLElementNumbers.h>
14#include <ecl/dbobjects/ECLDigitWaveformParameters.h>
15
16/* ROOT headers. */
17#include <TFile.h>
18#include <TTree.h>
19
20/* C++ headers. */
21#include <cstdlib>
22
23using namespace std;
24using namespace Belle2;
25using namespace ECL;
26
29 CalibrationAlgorithm("eclWaveformTemplateCalibrationC2Collector")
30{
32 "Perform the hadron and diode template shape calibration using photon template shapes from stage C2"
33 );
34}
35
37{
38
39 B2INFO("RUNNING" << Form("eclComputePulseTemplates_Step2.py %d %d", (m_firstCellID), (m_lastCellID)));
40 system(Form("eclComputePulseTemplates_Step2.py %d %d", (m_firstCellID), (m_lastCellID)));
41
42 B2INFO("RUNNING " << Form("eclComputePulseTemplates_Step3 %d %d", m_firstCellID, m_lastCellID));
43 system(Form("eclComputePulseTemplates_Step3 %d %d", m_firstCellID, m_lastCellID));
44
45 //save to db
46 ECLDigitWaveformParameters* HadronDiodeParameters = new ECLDigitWaveformParameters();
47
48 TFile* TempFile = new TFile(Form("HadronPars_Low%d_High%d.root", m_firstCellID, m_lastCellID), "READ");
49 TTree* TempTree = (TTree*) TempFile->Get("HadronWaveformInfo");
50 double tHadronShapePars_A[11];
51 double tDiodeShapePars_A[11];
52 double tMaxResidualHadron_A;
53 double tMaxResidualDiode_A;
54 double tMaxValDiode_A;
55 double tMaxValHadron_A;
56 TempTree->SetBranchAddress("TempHadronPar11_A", &tHadronShapePars_A);
57 TempTree->SetBranchAddress("TempDiodePar11_A", &tDiodeShapePars_A);
58 TempTree->SetBranchAddress("MaxResHadron_A", &tMaxResidualHadron_A);
59 TempTree->SetBranchAddress("MaxResDiode_A", &tMaxResidualDiode_A);
60 TempTree->SetBranchAddress("MaxValDiode_A", &tMaxValDiode_A);
61 TempTree->SetBranchAddress("MaxValHadron_A", &tMaxValHadron_A);
62
63 int batch = m_lastCellID - m_firstCellID;
64 for (int j = 0; j <= batch; j++) {
65 int tCellID = m_firstCellID + j;
66 if (tCellID > ECLElementNumbers::c_NCrystals)continue;
67 B2INFO("tCellID=" << tCellID << " j=" << j);
68 TempTree->GetEntry(j);
69 float tHadronShapePars_float[11];
70 float tDiodeShapePars_float[11];
71 for (int p = 0; p < 11; p++) {
72
73 if (tHadronShapePars_A[p] > 100 || tHadronShapePars_A[p] < -100) {
74 B2INFO("Warning large parameter for: " << tCellID << " " << tHadronShapePars_A[p]);
75 for (int h = 0; h < 11; h++) B2INFO(tHadronShapePars_A[h]);
76 }
77
78 tHadronShapePars_float[p] = (float)tHadronShapePars_A[p];
79 tDiodeShapePars_float[p] = (float)tDiodeShapePars_A[p];
80
81 }
82
83 B2INFO("tCellID tHadronShapePars_float[0]" << tCellID << " " << tHadronShapePars_float[0]);
84
85 HadronDiodeParameters->setTemplateParameters(tCellID, tHadronShapePars_float, tHadronShapePars_float, tDiodeShapePars_float);
86 }
87 TempFile->Close();
88
89 saveCalibration(HadronDiodeParameters, Form("HadronDiodeParameters_CellID%d_CellID%d", m_firstCellID, m_lastCellID));
90 return c_OK;
91}
92
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
DB object to store photon, hadron and diode shape parameters.
void setTemplateParameters(int cellID, const float photonInput[11], const float hadronInput[11], const float diodeInput[11])
Set photon, hadron and diode template parameters for crystal.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.
STL namespace.