10#include <ecl/calibration/eclWaveformTemplateCalibrationC4Algorithm.h>
13#include <ecl/dataobjects/ECLElementNumbers.h>
14#include <ecl/dbobjects/ECLDigitWaveformParameters.h>
17#include <framework/database/DBObjPtr.h>
26using namespace Calibration;
33 "Collects results from C3 to produce final payload, which contains new waveform templates"
44 std::vector<float> cellIDs;
45 std::vector<float> photonNorms;
46 std::vector<float> hadronNorms;
47 std::vector<float> diodeNorms;
57 B2INFO(
"eclWaveformTemplateCalibrationC4Algorithm i " << i <<
" " << first <<
" " << last);
58 B2INFO(
"eclWaveformTemplateCalibrationC4Algorithm " << Form(
"PhotonParameters_CellID%d_CellID%d", first, last));
59 B2INFO(
"eclWaveformTemplateCalibrationC4Algorithm " << Form(
"HadronDiodeParameters_CellID%d_CellID%d", first, last));
68 ExpRun chosenRun = runs.front();
69 B2INFO(
"merging using the ExpRun (" << chosenRun.second <<
"," << chosenRun.first <<
")");
73 for (
int j = first; j <= last; j++) {
74 B2INFO(
"Check Norm Params CellID " << j);
75 B2INFO(
"P " << j <<
" " << tempexistingPhotonWaveformParameters->getPhotonParameters(j)[0]);
76 B2INFO(
"H " << j <<
" " << tempexistingHadronDiodeWaveformParameters->getHadronParameters(j)[0]);
77 B2INFO(
"D " << j <<
" " << tempexistingHadronDiodeWaveformParameters->getDiodeParameters(j)[0]);
80 photonNorms.push_back(tempexistingPhotonWaveformParameters->getPhotonParameters(j)[0]);
81 hadronNorms.push_back(tempexistingPhotonWaveformParameters->getHadronParameters(j)[0]);
82 diodeNorms.push_back(tempexistingPhotonWaveformParameters->getDiodeParameters(j)[0]);
84 float tempPhotonWaveformParameters[11];
85 float tempHadronWaveformParameters[11];
86 float tempDiodeWaveformParameters[11];
88 for (
int k = 0; k < 11; k++) {
89 tempPhotonWaveformParameters[k] = tempexistingPhotonWaveformParameters->getPhotonParameters(j)[k];
90 tempHadronWaveformParameters[k] = tempexistingHadronDiodeWaveformParameters->getHadronParameters(j)[k];
91 tempDiodeWaveformParameters[k] = tempexistingHadronDiodeWaveformParameters->getDiodeParameters(j)[k];
93 PhotonHadronDiodeParameters->
setTemplateParameters(j, tempPhotonWaveformParameters, tempHadronWaveformParameters,
94 tempDiodeWaveformParameters);
98 auto gphotonNorms =
new TGraph(cellIDs.size(), cellIDs.data(), photonNorms.data());
99 gphotonNorms->SetName(
"gphotonNorms");
100 auto ghadronNorms =
new TGraph(cellIDs.size(), cellIDs.data(), hadronNorms.data());
101 ghadronNorms->SetName(
"ghadronNorms");
102 auto gdiodeNorms =
new TGraph(cellIDs.size(), cellIDs.data(), diodeNorms.data());
103 gdiodeNorms->SetName(
"gdiodeNorms");
106 TFile* histfile =
new TFile(fName,
"recreate");
108 gphotonNorms->Write();
109 ghadronNorms->Write();
110 gdiodeNorms->Write();
115 B2INFO(
"eclWaveformTemplateCalibrationC4Algorithm: Successful, now writing DB PAyload");
116 saveCalibration(PhotonHadronDiodeParameters,
"ECLDigitWaveformParameters");
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.
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
Class for accessing objects in the database.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.
Struct containing exp number and run number.