Belle II Software  release-05-02-19
GlobalTimeLine.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Tadeas Bilka *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <alignment/GlobalLabel.h>
14 #include <alignment/GlobalParam.h>
15 #include <framework/dataobjects/EventMetaData.h>
16 
17 #include <Python.h>
18 
19 #include <memory>
20 
21 namespace Belle2 {
26  namespace alignment {
27  namespace timeline {
28 
30  typedef std::pair<int, int> ExpRun;
32  typedef std::vector<EventMetaData> EventHeader;
34  typedef std::vector<ExpRun> RunHeader;
38  typedef std::unordered_map<int, std::vector<int>> TableData;
40  typedef std::tuple<EventHeader, RunHeader, TableData> TimeTable;
41 
45  typedef std::vector< std::pair<EventMetaData, std::shared_ptr<GlobalParamSetAccess>>> IntraIoVPayloads;
47  typedef std::vector<std::pair<IntervalOfValidity, IntraIoVPayloads>> PayloadIovBlockRow;
49  typedef std::unordered_map<int, PayloadIovBlockRow> PayloadsTable;
50 
59  EventMetaData gotoNextChangeRunWise(TimeTable& timeTable, int uid, int& timeid);
60 
69  EventMetaData gotoNextChangeInRun(TimeTable& timeTable, int uid, int& timeid);
70 
74  PayloadsTable TimeIdsTable2PayloadsTable(TimeTable& timeTable, const GlobalParamVector& vector);
75 
84  TimeTable makeInitialTimeTable(std::vector<EventMetaData> events, GlobalLabel& label);
85 
89  void finalizeTimeTable(TimeTable& table);
90 
95  std::pair<EventMetaData, std::shared_ptr<GlobalParamSetAccess>> getPayloadByContinuousIndex(PayloadsTable& payloadsTable, int uid,
96  long unsigned int index);;
97 
101  int getContinuousIndexByTimeID(const TimeTable& timeTable, int uid, int timeid);
102 
120  std::vector<EventMetaData> setupTimedepGlobalLabels(PyObject* config);
121 
141  std::vector<EventMetaData> setupTimedepGlobalLabels(
142  std::vector< std::tuple< std::vector< int >, std::vector< std::tuple< int, int, int > > > >& config);
143 
148  class GlobalParamTimeLine {
149 
150  private:
152  TimeTable timeTable{};
154  PayloadsTable payloadsTable{};
155 
156  public:
157 
164  GlobalParamTimeLine(const std::vector<EventMetaData>& events, GlobalLabel& label, const GlobalParamVector& vector);
165 
170  void loadFromDB();
171 
181  void updateGlobalParam(GlobalLabel label, double correction, bool resetParam = false);
182 
186  std::vector<std::pair<IntervalOfValidity, TObject*>> releaseObjects();
187 
188  };
189 
190  } // namespace timeline
191  } // namespace alignment
193 } // namespace Belle2
Belle2::alignment::timeline::GlobalParamTimeLine::timeTable
TimeTable timeTable
The final TimeTable with payload indices.
Definition: GlobalTimeLine.h:160
Belle2::alignment::timeline::GlobalParamTimeLine::releaseObjects
std::vector< std::pair< IntervalOfValidity, TObject * > > releaseObjects()
Release all the objects (you become the owner!) for DB storage.
Definition: GlobalTimeLine.cc:289
Belle2::alignment::timeline::GlobalParamTimeLine::GlobalParamTimeLine
GlobalParamTimeLine(const std::vector< EventMetaData > &events, GlobalLabel &label, const GlobalParamVector &vector)
Constructor.
Definition: GlobalTimeLine.cc:230
Belle2::GlobalLabel
Class to convert to/from global labels for Millepede II to/from detector & parameter identificators.
Definition: GlobalLabel.h:51
Belle2::alignment::GlobalParamVector
The central user class to manipulate any global constant in any DB object Used to retrieve global par...
Definition: GlobalParam.h:336
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::alignment::timeline::GlobalParamTimeLine::updateGlobalParam
void updateGlobalParam(GlobalLabel label, double correction, bool resetParam=false)
Add a correction to any payload's parameter in the timeline.
Definition: GlobalTimeLine.cc:262
Belle2::alignment::timeline::GlobalParamTimeLine::loadFromDB
void loadFromDB()
Load every single payload with the content in database at its corresponding event (when it should sta...
Definition: GlobalTimeLine.cc:238
Belle2::alignment::timeline::GlobalParamTimeLine::payloadsTable
PayloadsTable payloadsTable
Table with payloads.
Definition: GlobalTimeLine.h:162