Belle II Software  release-06-00-14
writeROIparametersToDB.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 <framework/database/DBImportObjPtr.h>
10 #include <framework/database/IntervalOfValidity.h>
11 #include <framework/database/Configuration.h>
12 #include <framework/logging/LogSystem.h>
13 #include <framework/utilities/FileSystem.h>
14 
15 #include <simulation/dbobjects/ROIParameters.h>
16 
17 #include <iostream>
18 
19 //------------------------------------------------------------------------
20 int main(int argc, char** argv)
21 {
22  if (argc < 4 or !(std::stoi(argv[1]) == 0 or std::stoi(argv[1]) == 1)) {
23  std::cout <<
24  "Please specify IOV: 0/1 {=off/on} N {=off for every Nth event; -1 if not used} experiment run [experimentEnd] [runEnd]" <<
25  std::endl;
26  return -1;
27  }
28 
29  bool enableROI = std::stoi(argv[1]) == 1;
30  int disableROIforEveryNth = std::stoi(argv[2]);
31 
32  if (!enableROI) {
33  disableROIforEveryNth = -1;
34  std::cout << "Parameter \"N\" does not have any function if ROI finding turned off. Neglecting." << std::endl;
35  } else if (disableROIforEveryNth == 0 or disableROIforEveryNth == 1) {
36  disableROIforEveryNth = -1;
37  std::cout <<
38  "Parameter \"N\" does not make any sense. Please use positive integer greater than 1 (or negative integer for disabling this feature)."
39  << std::endl;
40  } else if (disableROIforEveryNth < -1) {
41  disableROIforEveryNth = -1;
42  }
43 
44  int experiment = std::stoi(argv[3]);
45  int run = std::stoi(argv[4]);
46  int exp_end = -1;
47  int run_end = -1;
48  if (argc > 5) exp_end = std::stoi(argv[5]);
49  if (argc > 6) run_end = std::stoi(argv[6]);
50 
51  //------------------------------------------------------------------------
52  //..Specify database
54  conf.prependTestingPayloadLocation("localdb/database.txt");
55 
56  //..set debug level
58  logging->setLogLevel(Belle2::LogConfig::c_Debug);
59  logging->setDebugLevel(10);
60 
61  //..create ROI parameters
62  Belle2::ROIParameters roiParameters;
63  roiParameters.setROIfinding(enableROI);
64  roiParameters.setDisableROIforEveryNth(disableROIforEveryNth);
65 
66  //------------------------------------------------------------------------
67  //..Write out to localdb
69  roiParametersDBPtr.construct(roiParameters);
70  roiParametersDBPtr.import(Belle2::IntervalOfValidity(experiment, run, exp_end, run_end));
71  std::cout << "Successfully wrote payload ROIParameters with iov "
72  << experiment << "," << run << "," << exp_end << "," << run_end << std::endl;
73 }
74 
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
bool import(const IntervalOfValidity &iov)
Import the object to database.
Definition: DBImportBase.cc:36
Class for importing a single object to the database.
void construct(Args &&... params)
Construct an object of type T in this DBImportObjPtr using the provided constructor arguments.
A class that describes the interval of experiments/runs for which an object in the database is valid.
The LogConfig class.
Definition: LogConfig.h:22
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
LogConfig * getLogConfig()
Returns global log system configuration.
Definition: LogSystem.h:78
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
The payload containing all PXD ROI parameters.
Definition: ROIParameters.h:22
void setDisableROIforEveryNth(int disableROIforEveryNth)
Set if ROI finding was disabled for every Nth event (-1 if not used)
Definition: ROIParameters.h:42
void setROIfinding(bool useROIfinding)
Set whether ROI finding was used.
Definition: ROIParameters.h:30
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:75