10 #include <ecl/calibration/eclWaveformTemplateCalibrationC4Algorithm.h>
13 #include <ecl/dataobjects/ECLElementNumbers.h>
14 #include <ecl/dbobjects/ECLDigitWaveformParameters.h>
27 using namespace Calibration;
30 eclWaveformTemplateCalibrationC4Algorithm::eclWaveformTemplateCalibrationC4Algorithm():
34 "Collects results from C3 to produce final payload, which contains new waveform templates"
45 std::vector<float> cellIDs;
46 std::vector<float> photonNorms;
47 std::vector<float> hadronNorms;
48 std::vector<float> diodeNorms;
58 B2INFO(
"eclWaveformTemplateCalibrationC4Algorithm i " << i <<
" " << first <<
" " << last);
59 B2INFO(
"eclWaveformTemplateCalibrationC4Algorithm " << Form(
"PhotonParameters_CellID%d_CellID%d", first, last));
60 B2INFO(
"eclWaveformTemplateCalibrationC4Algorithm " << Form(
"HadronDiodeParameters_CellID%d_CellID%d", first, last));
69 ExpRun chosenRun = runs.front();
70 B2INFO(
"merging using the ExpRun (" << chosenRun.second <<
"," << chosenRun.first <<
")");
74 for (
int j = first; j <= last; j++) {
75 B2INFO(
"Check Norm Parms CellID " << j);
76 B2INFO(
"P " << j <<
" " << tempexistingPhotonWaveformParameters->getPhotonParameters(j)[0]);
77 B2INFO(
"H " << j <<
" " << tempexistingHadronDiodeWaveformParameters->getHadronParameters(j)[0]);
78 B2INFO(
"D " << j <<
" " << tempexistingHadronDiodeWaveformParameters->getDiodeParameters(j)[0]);
81 photonNorms.push_back(tempexistingPhotonWaveformParameters->getPhotonParameters(j)[0]);
82 hadronNorms.push_back(tempexistingPhotonWaveformParameters->getHadronParameters(j)[0]);
83 diodeNorms.push_back(tempexistingPhotonWaveformParameters->getDiodeParameters(j)[0]);
85 float tempPhotonWaveformParameters[11];
86 float tempHadronWaveformParameters[11];
87 float tempDiodeWaveformParameters[11];
89 for (
int k = 0; k < 11; k++) {
90 tempPhotonWaveformParameters[k] = tempexistingPhotonWaveformParameters->getPhotonParameters(j)[k];
91 tempHadronWaveformParameters[k] = tempexistingHadronDiodeWaveformParameters->getHadronParameters(j)[k];
92 tempDiodeWaveformParameters[k] = tempexistingHadronDiodeWaveformParameters->getDiodeParameters(j)[k];
94 PhotonHadronDiodeParameters->
setTemplateParameters(j, tempPhotonWaveformParameters, tempHadronWaveformParameters,
95 tempDiodeWaveformParameters);
99 auto gphotonNorms =
new TGraph(cellIDs.size(), cellIDs.data(), photonNorms.data());
100 gphotonNorms->SetName(
"gphotonNorms");
101 auto ghadronNorms =
new TGraph(cellIDs.size(), cellIDs.data(), hadronNorms.data());
102 ghadronNorms->SetName(
"ghadronNorms");
103 auto gdiodeNorms =
new TGraph(cellIDs.size(), cellIDs.data(), diodeNorms.data());
104 gdiodeNorms->SetName(
"gdiodeNorms");
107 TFile* histfile =
new TFile(fName,
"recreate");
109 gphotonNorms->Write();
110 ghadronNorms->Write();
111 gdiodeNorms->Write();
116 B2INFO(
"eclWaveformTemplateCalibrationC4Algorithm: Successful, now writing DB PAyload");
117 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)
EResult
The result of calibration.
@ c_OK
Finished successfuly =0 in Python.
const std::vector< Calibration::ExpRun > & getRunList() const
Get the list of runs for which calibration is called.
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.