Belle II Software  release-05-02-19
CalibrationAlgorithm.cc
1 #include <set>
2 #include <utility>
3 #include <boost/algorithm/string.hpp>
4 #include <boost/python.hpp>
5 #include <boost/python/list.hpp>
6 #include <boost/filesystem.hpp>
7 #include <TChain.h>
8 #include <calibration/CalibrationAlgorithm.h>
9 #include <framework/logging/Logger.h>
10 #include <framework/core/PyObjConvUtils.h>
11 #include <framework/io/RootIOUtilities.h>
12 
13 using namespace Belle2;
14 using namespace std;
15 using namespace Calibration;
16 namespace fs = boost::filesystem;
17 
18 const ExpRun CalibrationAlgorithm::m_allExpRun = make_pair(-1, -1);
19 
22 {
23  // Is it a sequence?
24  if (PySequence_Check(pyObj)) {
25  Py_ssize_t nObj = PySequence_Length(pyObj);
26  // Does it have 2 objects in it?
27  if (nObj != 2) {
28  B2DEBUG(29, "ExpRun was a Python sequence which didn't have exactly 2 entries!");
29  return false;
30  }
31  PyObject* item1, *item2;
32  item1 = PySequence_GetItem(pyObj, 0);
33  item2 = PySequence_GetItem(pyObj, 1);
34  // Did the GetItem work?
35  if ((item1 == NULL) || (item2 == NULL)) {
36  B2DEBUG(29, "A PyObject pointer was NULL in the sequence");
37  return false;
38  }
39  // Are they longs?
40  if (PyLong_Check(item1) && PyLong_Check(item2)) {
41  long value1, value2;
42  value1 = PyLong_AsLong(item1);
43  value2 = PyLong_AsLong(item2);
44  if (((value1 == -1) || (value2 == -1)) && PyErr_Occurred()) {
45  B2DEBUG(29, "An error occurred while converting the PyLong to long");
46  return false;
47  }
48  } else {
49  B2DEBUG(29, "One or more of the PyObjects in the ExpRun wasn't a long");
50  return false;
51  }
52  // Make sure to kill off the reference GetItem gave us responsibility for
53  Py_DECREF(item1);
54  Py_DECREF(item2);
55  } else {
56  B2DEBUG(29, "ExpRun was not a Python sequence.");
57  return false;
58  }
59  return true;
60 }
61 
64 {
65  ExpRun expRun;
66  PyObject* itemExp, *itemRun;
67  itemExp = PySequence_GetItem(pyObj, 0);
68  itemRun = PySequence_GetItem(pyObj, 1);
69  expRun.first = PyLong_AsLong(itemExp);
70  Py_DECREF(itemExp);
71  expRun.second = PyLong_AsLong(itemRun);
72  Py_DECREF(itemRun);
73  return expRun;
74 }
75 
77 {
78  B2DEBUG(29, "Running execute() using Python Object as input argument");
79  // Reset the execution specific data in case the algorithm was previously called
80  m_data.reset();
81  m_data.setIteration(iteration);
82  vector<ExpRun> vecRuns;
83  // Is it a list?
84  if (PySequence_Check(runs)) {
85  boost::python::handle<> handle(boost::python::borrowed(runs));
86  boost::python::list listRuns(handle);
87 
88  int nList = boost::python::len(listRuns);
89  for (int iList = 0; iList < nList; ++iList) {
90  boost::python::object pyExpRun(listRuns[iList]);
91  if (!checkPyExpRun(pyExpRun.ptr())) {
92  B2ERROR("Received Python ExpRuns couldn't be converted to C++");
93  m_data.setResult(c_Failure);
94  return c_Failure;
95  } else {
96  vecRuns.push_back(convertPyExpRun(pyExpRun.ptr()));
97  }
98  }
99  } else {
100  B2ERROR("Tried to set the input runs but we didn't receive a Python sequence object (list,tuple).");
101  m_data.setResult(c_Failure);
102  return c_Failure;
103  }
104  return execute(vecRuns, iteration, iov);
105 }
106 
108 {
109  // Check if we are calling this function directly and need to reset, or through Python where it was already done.
110  if (m_data.getResult() != c_Undefined) {
111  m_data.reset();
112  m_data.setIteration(iteration);
113  }
114 
115  if (m_inputFileNames.empty()) {
116  B2ERROR("There aren't any input files set. Please use CalibrationAlgorithm::setInputFiles()");
117  m_data.setResult(c_Failure);
118  return c_Failure;
119  }
120 
121  // Did we receive runs to execute over explicitly?
122  if (!(runs.empty())) {
123  for (auto expRun : runs) {
124  B2DEBUG(29, "ExpRun requested = (" << expRun.first << ", " << expRun.second << ")");
125  }
126  // We've asked explicitly for certain runs, but we should check if the data granularity is 'run'
127  if (strcmp(getGranularity().c_str(), "all") == 0) {
128  B2ERROR(("The data is collected with granularity=all (exp=-1,run=-1), but you seem to request calibration for specific runs."
129  " We'll continue but using ALL the input data given instead of the specific runs requested."));
130  }
131  } else {
132  // If no runs are provided, infer the runs from all collected data
133  runs = getRunListFromAllData();
134  // Let's check that we have some now
135  if (runs.empty()) {
136  B2ERROR("No collected data in input files.");
137  m_data.setResult(c_Failure);
138  return c_Failure;
139  }
140  for (auto expRun : runs) {
141  B2DEBUG(29, "ExpRun requested = (" << expRun.first << ", " << expRun.second << ")");
142  }
143  }
144 
145  m_data.setRequestedRuns(runs);
146  if (iov.empty()) {
147  // If no user specified IoV we use the IoV from the executed run list
148  iov = IntervalOfValidity(runs[0].first, runs[0].second, runs[runs.size() - 1].first, runs[runs.size() - 1].second);
149  }
150  m_data.setRequestedIov(iov);
151  // After here, the getObject<...>(...) helpers start to work
152 
153  CalibrationAlgorithm::EResult result = calibrate();
154  m_data.setResult(result);
155  return result;
156 }
157 
159 void CalibrationAlgorithm::setInputFileNames(PyObject* inputFileNames)
160 {
161  // The reasoning for this very 'manual' approach to extending the Python interface
162  // (instead of using boost::python) is down to my fear of putting off final users with
163  // complexity on their side.
164  //
165  // I didn't want users that inherit from this class to be forced to use boost and
166  // to have to define a new python module just to use the CAF. A derived class from
167  // from a boost exposed class would need to have its own boost python module definition
168  // to allow access from a steering file and to the base class functions (I think).
169  // I also couldn't be bothered to write a full framework to get around the issue in a similar
170  // way to Module()...maybe there's an easy way.
171  //
172  // But this way we can allow people to continue using their ROOT implemented classes and inherit
173  // easily from this one. But add in a few helper functions that work with Python objects
174  // created in their steering file i.e. instead of being forced to use STL objects as input
175  // to the algorithm.
176  if (PyList_Check(inputFileNames)) {
177  boost::python::handle<> handle(boost::python::borrowed(inputFileNames));
178  boost::python::list listInputFileNames(handle);
179  auto vecInputFileNames = PyObjConvUtils::convertPythonObject(listInputFileNames, vector<string>());
180  setInputFileNames(vecInputFileNames);
181  } else {
182  B2ERROR("Tried to set the input files but we didn't receive a Python list.");
183  }
184 }
185 
187 void CalibrationAlgorithm::setInputFileNames(vector<string> inputFileNames)
188 {
189  // A lot of code below is tweaked from RootInputModule::initialize,
190  // since we're basically copying the functionality anyway.
191  if (inputFileNames.empty()) {
192  B2WARNING("You have called setInputFileNames() with an empty list. Did you mean to do that?");
193  return;
194  }
195  auto tmpInputFileNames = RootIOUtilities::expandWordExpansions(inputFileNames);
196 
197  // We'll use a set to enforce sorted unique file paths as we check them
198  set<string> setInputFileNames;
199  // Check that files exist and convert to absolute paths
200  for (auto path : tmpInputFileNames) {
201  string fullPath = fs::absolute(path).string();
202  if (fs::exists(fullPath)) {
203  setInputFileNames.insert(fs::canonical(fullPath).string());
204  } else {
205  B2WARNING("Couldn't find the file " << path);
206  }
207  }
208 
209  if (setInputFileNames.empty()) {
210  B2WARNING("No valid files specified!");
211  return;
212  } else {
213  // Reset the run -> files map as our files are likely different
214  m_runsToInputFiles.clear();
215  }
216 
217  // Open TFile to check they can be accessed by ROOT
218  TDirectory* dir = gDirectory;
219  for (const string& fileName : setInputFileNames) {
220  unique_ptr<TFile> f;
221  try {
222  f.reset(TFile::Open(fileName.c_str(), "READ"));
223  } catch (logic_error&) {
224  //this might happen for ~invaliduser/foo.root
225  //actually undefined behaviour per standard, reported as ROOT-8490 in JIRA
226  }
227  if (!f || !f->IsOpen()) {
228  B2FATAL("Couldn't open input file " + fileName);
229  }
230  }
231  dir->cd();
232 
233  // Copy the entries of the set to a vector
234  m_inputFileNames = vector<string>(setInputFileNames.begin(), setInputFileNames.end());
235  m_granularityOfData = getGranularityFromData();
236 }
237 
239 {
240  PyObject* objInputFileNames = PyList_New(m_inputFileNames.size());
241  for (size_t i = 0; i < m_inputFileNames.size(); ++i) {
242  PyList_SetItem(objInputFileNames, i, Py_BuildValue("s", m_inputFileNames[i].c_str()));
243  }
244  return objInputFileNames;
245 }
246 
248 {
249  string expRunString;
250  expRunString += to_string(expRun.first);
251  expRunString += ".";
252  expRunString += to_string(expRun.second);
253  return expRunString;
254 }
255 
256 string CalibrationAlgorithm::getFullObjectPath(string name, ExpRun expRun) const
257 {
258  string dirName = getPrefix() + "/" + name;
259  string objName = name + "_" + getExpRunString(expRun);
260  return dirName + "/" + objName;
261 }
262 
263 void CalibrationAlgorithm::saveCalibration(TObject* data, const string& name, const IntervalOfValidity& iov)
264 {
265  B2DEBUG(29, "Saving calibration TObject = '" << name << "' to payloads list.");
266  getPayloads().emplace_back(name, data, iov);
267 }
268 
269 void CalibrationAlgorithm::saveCalibration(TClonesArray* data, const string& name, const IntervalOfValidity& iov)
270 {
271  B2DEBUG(29, "Saving calibration TClonesArray '" << name << "' to payloads list.");
272  getPayloads().emplace_back(name, data, iov);
273 }
274 
276 {
277  saveCalibration(data, DataStore::objectName(data->IsA(), ""), iov);
278 }
279 
281 {
282  saveCalibration(data, DataStore::objectName(data->IsA(), ""));
283 }
284 
285 void CalibrationAlgorithm::saveCalibration(TObject* data, const string& name)
286 {
287  saveCalibration(data, name, m_data.getRequestedIov());
288 }
289 
290 void CalibrationAlgorithm::saveCalibration(TClonesArray* data, const string& name)
291 {
292  saveCalibration(data, name, m_data.getRequestedIov());
293 }
294 
296 {
297  if (getPayloads().empty())
298  return false;
299  list<Database::DBImportQuery> payloads = getPayloads();
300  B2INFO("Committing " << payloads.size() << " payloads to database.");
301  return Database::Instance().storeData(payloads);
302 }
303 
304 bool CalibrationAlgorithm::commit(list<Database::DBImportQuery> payloads)
305 {
306  if (payloads.empty())
307  return false;
308  return Database::Instance().storeData(payloads);
309 }
310 
312 {
313  RunRange runRange = getRunRangeFromAllData();
314  set<ExpRun> expRunSet = runRange.getExpRunSet();
315  return vector<ExpRun>(expRunSet.begin(), expRunSet.end());
316 }
317 
319 {
320  return getRunRangeFromAllData().getIntervalOfValidity();
321 }
322 
324 {
325  m_runsToInputFiles.clear();
326  // Save TDirectory to change back at the end
327  TDirectory* dir = gDirectory;
328  RunRange* runRange;
329  // Construct the TDirectory name where we expect our objects to be
330  string runRangeObjName(getPrefix() + "/" + RUN_RANGE_OBJ_NAME);
331  for (const auto& fileName : m_inputFileNames) {
332  //Open TFile to get the objects
333  unique_ptr<TFile> f;
334  f.reset(TFile::Open(fileName.c_str(), "READ"));
335  runRange = dynamic_cast<RunRange*>(f->Get(runRangeObjName.c_str()));
336  if (runRange) {
337  // Insert or extend the run -> file mapping for this ExpRun
338  auto expRuns = runRange->getExpRunSet();
339  for (const auto& expRun : expRuns) {
340  auto runFiles = m_runsToInputFiles.find(expRun);
341  if (runFiles != m_runsToInputFiles.end()) {
342  (runFiles->second).push_back(fileName);
343  } else {
344  m_runsToInputFiles.insert(std::make_pair(expRun, std::vector<std::string> {fileName}));
345  }
346  }
347  } else {
348  B2WARNING("Missing a RunRange object for file: " << fileName);
349  }
350  }
351  dir->cd();
352 }
353 
355 {
356  // Save TDirectory to change back at the end
357  TDirectory* dir = gDirectory;
358  RunRange runRange;
359  RunRange* runRangeOther;
360  // Construct the TDirectory name where we expect our objects to be
361  string runRangeObjName(getPrefix() + "/" + RUN_RANGE_OBJ_NAME);
362  for (const auto& fileName : m_inputFileNames) {
363  //Open TFile to get the objects
364  unique_ptr<TFile> f;
365  f.reset(TFile::Open(fileName.c_str(), "READ"));
366  runRangeOther = dynamic_cast<RunRange*>(f->Get(runRangeObjName.c_str()));
367  if (runRangeOther) {
368  runRange.merge(runRangeOther);
369  } else {
370  B2WARNING("Missing a RunRange object for file: " << fileName);
371  }
372  }
373  dir->cd();
374  return runRange;
375 }
376 
378 {
379  // Save TDirectory to change back at the end
380  TDirectory* dir = gDirectory;
381  RunRange* runRange;
382  string runRangeObjName(getPrefix() + "/" + RUN_RANGE_OBJ_NAME);
383  // We only check the first file
384  string fileName = m_inputFileNames[0];
385  unique_ptr<TFile> f;
386  f.reset(TFile::Open(fileName.c_str(), "READ"));
387  runRange = dynamic_cast<RunRange*>(f->Get(runRangeObjName.c_str()));
388  if (!runRange) {
389  B2FATAL("The input file " << fileName << " does not contain a RunRange object at "
390  << runRangeObjName << ". Please set your input files to exclude it.");
391  return "";
392  }
393  string granularity = runRange->getGranularity();
394  dir->cd();
395  return granularity;
396 }
397 
398 void CalibrationAlgorithm::updateDBObjPtrs(const unsigned int event = 1, const int run = 0, const int experiment = 0)
399 {
400  // Construct an EventMetaData object but NOT in the Datastore
401  EventMetaData emd(event, run, experiment);
402  // Explicitly update while avoiding registering a Datastore object
403  DBStore::Instance().update(emd);
404  // Also update the intra-run objects to the event at the same time (maybe unnessary...)
406 }
407 
408 // Have to put the explicit template specialization in the enclosing namespace
409 namespace Belle2 {
417  template<>
418  shared_ptr<TTree> CalibrationAlgorithm::getObjectPtr<TTree>(const string& name,
419  const vector<ExpRun>& requestedRuns)
420  {
421  // Check if this object already exists
422  RunRange runRangeRequested(requestedRuns);
423  std::shared_ptr<TTree> objOutputPtr = std::dynamic_pointer_cast<TTree>(m_data.getCalibObj(name, runRangeRequested));
424  if (objOutputPtr)
425  return objOutputPtr;
426 
427  // If not we best make a new one
428  shared_ptr<TChain> chain = make_shared<TChain>(name.c_str());
429  chain->SetDirectory(0);
430  // Construct the TDirectory names where we expect our objects to be
431  string runRangeObjName(getPrefix() + "/" + RUN_RANGE_OBJ_NAME);
432 
433  if (strcmp(getGranularity().c_str(), "run") == 0) {
434  // Loop over our runs requested for the right files
435  for (auto expRunRequested : requestedRuns) {
436  // Find the relevant files for this ExpRun
437  auto searchFiles = m_runsToInputFiles.find(expRunRequested);
438  if (searchFiles == m_runsToInputFiles.end()) {
439  B2WARNING("No input file found with data collected from run "
440  "(" << expRunRequested.first << "," << expRunRequested.second << ")");
441  continue;
442  } else {
443  auto files = searchFiles->second;
444  for (auto fileName : files) {
445  RunRange* runRangeData;
446  //Open TFile to get the objects
447  std::unique_ptr<TFile> f;
448  f.reset(TFile::Open(fileName.c_str(), "READ"));
449  runRangeData = dynamic_cast<RunRange*>(f->Get(runRangeObjName.c_str()));
450  // Check that nothing went wrong in the mapping and that this file definitely contains this run's data
451  auto runSet = runRangeData->getExpRunSet();
452  if (runSet.find(expRunRequested) == runSet.end()) {
453  B2WARNING("Something went wrong with the mapping of ExpRun -> Input Files. "
454  "(" << expRunRequested.first << "," << expRunRequested.second << ") not in " << fileName);
455  }
456  // Get the path/directory of the Exp,Run TDirectory that holds the object(s)
457  std::string objDirName = getFullObjectPath(name, expRunRequested);
458  TDirectory* objDir = f->GetDirectory(objDirName.c_str());
459  if (!objDir) {
460  B2ERROR("Directory for requested object " << name << " not found: " << objDirName);
461  return nullptr;
462  }
463  // Find all the objects inside, there may be more than one
464  for (auto key : * (objDir->GetListOfKeys())) {
465  string keyName = key->GetName();
466  string objectPath = fileName + "/" + objDirName + "/" + keyName;
467  B2DEBUG(29, "Adding TTree " << objectPath);
468  chain->Add(objectPath.c_str());
469  }
470  }
471  }
472  }
473  } else {
474  ExpRun allGranExpRun = getAllGranularityExpRun();
475  string objDirName = getFullObjectPath(name, allGranExpRun);
476  for (const auto& fileName : m_inputFileNames) {
477  string objectPath = fileName + "/" + objDirName + "/" + name + "_1"; // Only one index for this granularity
478  B2DEBUG(29, "Adding TTree " << objectPath);
479  chain->Add(objectPath.c_str());
480  }
481  }
482  if (!chain->GetListOfFiles()->GetEntries()) {
483  B2ERROR("No data found for object " << name);
484  return nullptr;
485  }
486  objOutputPtr = static_pointer_cast<TTree>(chain);
487  // make a TNamed version to input to the map of previous calib objects
488  shared_ptr<TNamed> storedObjPtr = static_pointer_cast<TNamed>(objOutputPtr);
489  m_data.setCalibObj(name, runRangeRequested, storedObjPtr);
490  B2DEBUG(29, "Passing back merged data " << name);
491  return objOutputPtr;
492  }
494 }
495 
496 bool CalibrationAlgorithm::loadInputJson(const std::string& jsonString)
497 {
498  try {
499  auto jsonInput = nlohmann::json::parse(jsonString);
500  // Input string has an object (dict) as the top level object?
501  if (jsonInput.is_object()) {
502  m_jsonExecutionInput = jsonInput;
503  return true;
504  } else {
505  B2ERROR("JSON input string isn't an object type i.e. not a '{}' at the top level.");
506  return false;
507  }
508  } catch (nlohmann::json::parse_error&) {
509  B2ERROR("Parsing of JSON input string failed");
510  return false;
511  }
512 }
513 
514 const std::vector<ExpRun> CalibrationAlgorithm::findPayloadBoundaries(std::vector<ExpRun> runs, int iteration)
515 {
516  m_boundaries.clear();
517  if (m_inputFileNames.empty()) {
518  B2ERROR("There aren't any input files set. Please use CalibrationAlgorithm::setInputFiles()");
519  return m_boundaries;
520  }
521  // Reset the internal execution data just in case something is hanging around
522  m_data.reset();
523  if (runs.empty()) {
524  // Want to loop over all runs we could possibly know about
525  runs = getRunListFromAllData();
526  }
527  // Let's check that we have some now
528  if (runs.empty()) {
529  B2ERROR("No collected data in input files.");
530  return m_boundaries;
531  }
532  // In order to find run boundaries we must have collected with data granularity == 'run'
533  if (strcmp(getGranularity().c_str(), "all") == 0) {
534  B2ERROR("The data is collected with granularity='all' (exp=-1,run=-1), and we can't use that to find run boundaries.");
535  return m_boundaries;
536  }
537  m_data.setIteration(iteration);
538  // User defined setup function
539  boundaryFindingSetup(runs, iteration);
540  std::vector<ExpRun> runList;
541  // Loop over run list and call derived class "isBoundaryRequired" member function
542  for (auto currentRun : runs) {
543  runList.push_back(currentRun);
544  m_data.setRequestedRuns(runList);
545  // After here, the getObject<...>(...) helpers start to work
546  if (isBoundaryRequired(currentRun)) {
547  m_boundaries.push_back(currentRun);
548  }
549  // Only want run-by-run
550  runList.clear();
551  // Don't want memory hanging around
552  m_data.clearCalibrationData();
553  }
554  m_data.reset();
555  boundaryFindingTearDown();
556  return m_boundaries;
557 }
Belle2::IntervalOfValidity
A class that describes the interval of experiments/runs for which an object in the database is valid.
Definition: IntervalOfValidity.h:35
Belle2::CalibrationAlgorithm::getRunRangeFromAllData
RunRange getRunRangeFromAllData() const
Get the complete RunRange from inspection of collected data.
Definition: CalibrationAlgorithm.cc:354
Belle2::CalibrationAlgorithm::setInputFileNames
void setInputFileNames(PyObject *inputFileNames)
Set the input file names used for this algorithm from a Python list.
Definition: CalibrationAlgorithm.cc:159
Belle2::CalibrationAlgorithm::getGranularityFromData
std::string getGranularityFromData() const
Get the granularity of collected data.
Definition: CalibrationAlgorithm.cc:377
Belle2::CalibrationAlgorithm::getFullObjectPath
std::string getFullObjectPath(std::string name, Calibration::ExpRun expRun) const
constructs the full TDirectory + Key name of an object in a TFile based on its name and exprun
Definition: CalibrationAlgorithm.cc:256
Belle2::CalibrationAlgorithm::convertPyExpRun
Calibration::ExpRun convertPyExpRun(PyObject *pyObj)
Performs the conversion of PyObject to ExpRun.
Definition: CalibrationAlgorithm.cc:63
Belle2::CalibrationAlgorithm::loadInputJson
bool loadInputJson(const std::string &jsonString)
Load the m_inputJson variable from a string (useful from Python interface). The rturn bool indicates ...
Definition: CalibrationAlgorithm.cc:496
Belle2::CalibrationAlgorithm::saveCalibration
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
Definition: CalibrationAlgorithm.cc:290
Belle2::RunRange::getExpRunSet
const std::set< Calibration::ExpRun > & getExpRunSet()
Get access to the stored set.
Definition: RunRange.h:57
Belle2::Database::storeData
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition: Database.cc:152
Belle2::CalibrationAlgorithm::findPayloadBoundaries
const std::vector< Calibration::ExpRun > findPayloadBoundaries(std::vector< Calibration::ExpRun > runs, int iteration=0)
Used to discover the ExpRun boundaries that you want the Python CAF to execute on....
Definition: CalibrationAlgorithm.cc:514
Belle2::CalibrationAlgorithm::updateDBObjPtrs
void updateDBObjPtrs(const unsigned int event, const int run, const int experiment)
Updates any DBObjPtrs by calling update(event) for DBStore.
Definition: CalibrationAlgorithm.cc:398
Belle2::CalibrationAlgorithm::checkPyExpRun
bool checkPyExpRun(PyObject *pyObj)
Checks that a PyObject can be successfully converted to an ExpRun type.
Definition: CalibrationAlgorithm.cc:21
Belle2::CalibrationAlgorithm::getIovFromAllData
IntervalOfValidity getIovFromAllData() const
Get the complete IoV from inspection of collected data.
Definition: CalibrationAlgorithm.cc:318
Belle2::RootIOUtilities::expandWordExpansions
std::vector< std::string > expandWordExpansions(const std::vector< std::string > &filenames)
Performs wildcard expansion using wordexp(), returns matches.
Definition: RootIOUtilities.cc:107
Belle2::CalibrationAlgorithm::getRunListFromAllData
std::vector< Calibration::ExpRun > getRunListFromAllData() const
Get the complete list of runs from inspection of collected data.
Definition: CalibrationAlgorithm.cc:311
Belle2::CalibrationAlgorithm::execute
EResult execute(std::vector< Calibration::ExpRun > runs={}, int iteration=0, IntervalOfValidity iov=IntervalOfValidity())
Runs calibration over vector of runs for a given iteration.
Belle2::CalibrationAlgorithm::fillRunToInputFilesMap
void fillRunToInputFilesMap()
Fill the mapping of ExpRun -> Files.
Definition: CalibrationAlgorithm.cc:323
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::RunRange::merge
virtual void merge(const RunRange *other)
Implementation of merging - other is added to the set (union)
Definition: RunRange.h:45
Belle2::CalibrationAlgorithm::getInputFileNames
PyObject * getInputFileNames()
Get the input file names used for this algorithm and pass them out as a Python list of unicode string...
Definition: CalibrationAlgorithm.cc:238
Belle2::DBStore::Instance
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:36
Belle2::ExpRun
Struct containing exp number and run number.
Definition: Splitter.h:55
Belle2::CalibrationAlgorithm::getExpRunString
std::string getExpRunString(Calibration::ExpRun &expRun) const
Gets the "exp.run" string repr. of (exp,run)
Definition: CalibrationAlgorithm.cc:247
Belle2::RunRange::getGranularity
std::string getGranularity() const
Gets the m_granularity.
Definition: RunRange.h:103
Belle2::CalibrationAlgorithm::EResult
EResult
The result of calibration.
Definition: CalibrationAlgorithm.h:50
Belle2::DBStore::updateEvent
void updateEvent()
Updates all intra-run dependent objects.
Definition: DBStore.cc:150
Belle2::Database::Instance
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:54
Belle2::EventMetaData
Store event, run, and experiment numbers.
Definition: EventMetaData.h:43
Belle2::CalibrationAlgorithm::commit
bool commit()
Submit constants from last calibration into database.
Definition: CalibrationAlgorithm.cc:295
Belle2::DataStore::objectName
static std::string objectName(const TClass *t, const std::string &name)
Return the storage name for an object of the given TClass and name.
Definition: DataStore.cc:151
Belle2::RunRange
Mergeable object holding (unique) set of (exp,run) pairs.
Definition: RunRange.h:18
Belle2::DBStore::update
void update()
Updates all objects that are outside their interval of validity.
Definition: DBStore.cc:87
Belle2::PyObjConvUtils::convertPythonObject
Scalar convertPythonObject(const boost::python::object &pyObject, Scalar)
Convert from Python to given type.
Definition: PyObjConvUtils.h:510