Belle II Software  release-08-01-10
eclWriteWaveformParametersLocalDB.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 /* ECL headers. */
10 #include <ecl/dataobjects/ECLElementNumbers.h>
11 #include <ecl/dbobjects/ECLDigitWaveformParameters.h>
12 
13 /* Basf2 headers. */
14 #include <framework/database/DBImportObjPtr.h>
15 #include <framework/logging/Logger.h>
16 
17 /* ROOT headers. */
18 #include <TFile.h>
19 #include <TTree.h>
20 
21 /* C++ headers. */
22 #include <iostream>
23 
24 using namespace Belle2;
25 
26 //
27 //See eclComputePulseTemplates_Step0.cc for README instructions.
29 int main()
30 {
31  //
32  TString FileName = "DigitWaveformParameters.root";
33  //
34  TFile* WaveformParameterFileInput = new TFile(FileName, "READ");
35  if (!WaveformParameterFileInput or WaveformParameterFileInput->IsZombie()) {
36  B2FATAL("Could not open file " << FileName);
37  }
38  WaveformParameterFileInput->cd();
39  TTree* WaveformParametersTree = (TTree*) WaveformParameterFileInput->Get("ParTree");
40  //
41  double treePhotonPar11[11];
42  double treeHadronPar11[11];
43  double treeDiodePar11[11];
44  //
45  WaveformParametersTree->SetBranchAddress("PhotonPar", &treePhotonPar11);
46  WaveformParametersTree->SetBranchAddress("HadronPar", &treeHadronPar11);
47  WaveformParametersTree->SetBranchAddress("DiodePar", &treeDiodePar11);
48  //
49 
50  //
51  Belle2::DBImportObjPtr<Belle2::ECLDigitWaveformParameters> importer("ECLDigitWaveformParameters");
52  importer.construct();
53  for (int ID = 0; ID < ECLElementNumbers::c_NCrystals; ID++) {
54  WaveformParametersTree->GetEntry(ID);
55  float tempPhotonPar11[11];
56  float tempHadronPar11[11];
57  float tempDiodePar11[11];
58  for (unsigned int k = 0; k < 11; k++) {
59  tempPhotonPar11[k] = (float)treePhotonPar11[k];
60  tempHadronPar11[k] = (float)treeHadronPar11[k];
61  tempDiodePar11[k] = (float)treeDiodePar11[k];
62  }
63  std::cout << "cellID: " << ID + 1 << " " << tempPhotonPar11[0] << " " << tempHadronPar11[0] << " " << tempDiodePar11[0] <<
64  std::endl;
65  //
66  if (tempPhotonPar11[0] == 0 || tempHadronPar11[0] == 0
67  || tempDiodePar11[0] == 0) std::cout << "WARNING CELLID MISSING: " << ID + 1 << std::endl;
68  //
69  importer->setTemplateParameters(ID + 1, tempPhotonPar11, tempHadronPar11, tempDiodePar11);
70  }
71  importer.import(Belle2::IntervalOfValidity::always());
72  std::cout << "Successfully wrote payload ECLDigitWaveformParameters" << std::endl;
73  //
74 }
Class for importing a single object to the database.
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91