Belle II Software development
eclWriteChannelMap.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/dbobjects/ECLChannelMap.h>
11#include <ecl/mapper/ECLChannelMapper.h>
12
13/* Basf2 headers. */
14#include <framework/database/Configuration.h>
15#include <framework/database/DBImportObjPtr.h>
16#include <framework/logging/LogSystem.h>
17#include <framework/utilities/FileSystem.h>
18
19/* C++ headers. */
20#include <iostream>
21
22using namespace Belle2;
23using namespace ECL;
24
25//------------------------------------------------------------------------
26int main(int argc, char** argv)
27{
28 if (argc < 2) {
29 std::cout << "Usage: eclWriteChannelMap experiment run [experimentEnd] [runEnd]" << std::endl;
30 return -1;
31 }
32 int experiment = std::stoi(argv[1]);
33 int run = std::stoi(argv[2]);
34 int exp_end = -1;
35 int run_end = -1;
36 if (argc > 3) exp_end = std::stoi(argv[3]);
37 if (argc > 4) run_end = std::stoi(argv[4]);
38
39 //------------------------------------------------------------------------
40 //..Specify database
42 conf.prependTestingPayloadLocation("localdb/database.txt");
43
44 //..set debug level
47 logging->setDebugLevel(10);
48
49 //------------------------------------------------------------------------
50 //..Calculate the new values for requested payload
51 std::string map_path = FileSystem::findFile("ecl/data/ecl_channels_map.txt");
52 if (!FileSystem::fileExists(map_path)) {
53 B2FATAL("eclChannelMapper initialization file " << map_path << " doesn't exist");
54 }
55 ECLChannelMapper mapper;
56 mapper.initFromFile(map_path.c_str());
57
58 //------------------------------------------------------------------------
59 //..Write out to localdb
60 Belle2::DBImportObjPtr<Belle2::ECLChannelMap> importer("ECLChannelMap");
61 importer.construct(mapper.getDBObject());
62 importer.import(Belle2::IntervalOfValidity(experiment, run, exp_end, run_end));
63 std::cout << "Successfully wrote payload ECLChannelMap with iov "
64 << experiment << "," << run << "," << exp_end << "," << run_end << std::endl;
65}
66
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
Class for importing a single object to the database.
This class provides access to ECL channel map that is either a) Loaded from the database (see ecl/dbo...
ECLChannelMap getDBObject()
Convert internal data to ECLChannelMap database object.
bool initFromFile()
Initialize channel mapper using data stored in default location.
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:151
static bool fileExists(const std::string &filename)
Check if the file with given filename exists.
Definition: FileSystem.cc:32
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
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition: LogConfig.h:98
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:25
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
Abstract base class for different kinds of events.