Belle II Software  release-05-01-25
Manager.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 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 <string>
14 #include <vector>
15 #include <map>
16 #include <Geant4/G4Transform3D.hh>
17 #include <root/TMatrixD.h>
18 #include <genfit/StateOnPlane.h>
19 #include <root/TGeoMatrix.h>
20 #include <set>
21 
22 #include <framework/logging/Logger.h>
23 
24 #include <mdst/dbobjects/BeamSpot.h>
25 #include <alignment/dbobjects/VXDAlignment.h>
26 #include <alignment/dbobjects/CDCCalibration.h>
27 #include <klm/dbobjects/bklm/BKLMAlignment.h>
28 #include <klm/dbobjects/eklm/EKLMAlignment.h>
29 #include <klm/dbobjects/eklm/EKLMSegmentAlignment.h>
30 
31 #include <cdc/dbobjects/CDCTimeZeros.h>
32 #include <cdc/dbobjects/CDCTimeWalks.h>
33 #include <cdc/dbobjects/CDCAlignment.h>
34 #include <cdc/dbobjects/CDCXtRelations.h>
35 
36 #include <alignment/GlobalParam.h>
37 #include <alignment/GlobalTimeLine.h>
38 #include <alignment/Hierarchy.h>
39 
40 #include <map>
41 #include <string>
42 #include <vector>
43 
44 namespace Belle2 {
49  namespace alignment {
50 
52  class GlobalCalibrationManager {
53 
54  public:
55 
56 
57 
59  std::function<bool(const EventMetaData&, const EventMetaData&)> cmpEventMetaData = [](const EventMetaData& lhs,
60  const EventMetaData& rhs) -> bool {
61  if (lhs.getExperiment() < rhs.getExperiment()) return true;
62  if (lhs.getExperiment() > rhs.getExperiment()) return false;
63 
64  if (lhs.getRun() < rhs.getRun()) return true;
65  if (lhs.getRun() > rhs.getRun()) return false;
66 
67  if (lhs.getEvent() < rhs.getEvent()) return true;
68  return false;
69  };
70 
80 
81 
90  static void initGlobalVector(GlobalParamVector& vector);
91 
94  void sortUniqueVector(std::vector<EventMetaData>& vec);
95 
98 
100  void initialize(const std::vector<std::string>& components = {}, const std::vector<EventMetaData>& timeSlices = {});
101 
103  void preCollect(const EventMetaData& emd);
104 
106  public:
108  RigidBodyHierarchy& getAlignmentHierarchy() const { return *m_alignment; }
110  LorentShiftHierarchy& getLorentzShiftHierarchy() const { return *m_lorentzShift; }
112  Constraints& getConstraints() { return m_constraints; }
113 
115  void writeConstraints(std::string txtFilename);
116 
117  private:
124 
128  int updateTimeDepGlobalLabels(const EventMetaData& event);
129 
130 
132  bool m_initialized {false};
133 
135  std::unique_ptr<RigidBodyHierarchy> m_alignment {new RigidBodyHierarchy()};
137  std::unique_ptr<LorentShiftHierarchy> m_lorentzShift {new LorentShiftHierarchy()};
139  std::unique_ptr<GlobalParamVector> m_globalVector {new GlobalParamVector()};
141  std::map<long, Constraint> m_constraints {};
142 
144  std::vector<EventMetaData> m_dbTimeSlicing {};
145 
148  alignment::timeline::TimeTable m_iniTimeTable{};
149  };
150 
151  }
153 }
Belle2::alignment::GlobalCalibrationManager::initialize
void initialize(const std::vector< std::string > &components={}, const std::vector< EventMetaData > &timeSlices={})
Initialize the manager with given configuration (from MillepedeCollector)
Definition: Manager.cc:45
Belle2::alignment::GlobalCalibrationManager::updateTimeDepGlobalLabels
int updateTimeDepGlobalLabels(const EventMetaData &event)
Update the current time ID in the GlobalLabel.
Definition: Manager.cc:189
Belle2::alignment::GlobalCalibrationManager::sortUniqueVector
void sortUniqueVector(std::vector< EventMetaData > &vec)
Sort vector of EventMetaData and make it unique to process user defined time splittings of the consta...
Definition: Manager.cc:183
Belle2::alignment::GlobalCalibrationManager::preCollect
void preCollect(const EventMetaData &emd)
Notice manager of a comming event (from MillepedeCollector)
Definition: Manager.cc:91
Belle2::alignment::GlobalCalibrationManager::getConstraints
Constraints & getConstraints()
Get the constraints collected so far.
Definition: Manager.h:120
Belle2::alignment::GlobalCalibrationManager::m_initialized
bool m_initialized
Finished initialization?
Definition: Manager.h:140
Belle2::alignment::GlobalCalibrationManager::getAlignmentHierarchy
RigidBodyHierarchy & getAlignmentHierarchy() const
Get the rigid body alignment hierarchy.
Definition: Manager.h:116
Belle2::alignment::GlobalCalibrationManager::GlobalCalibrationManager
GlobalCalibrationManager()
Singleton class, hidden constructor.
Definition: Manager.h:127
Belle2::alignment::GlobalCalibrationManager::m_dbTimeSlicing
std::vector< EventMetaData > m_dbTimeSlicing
Vector of EventMetaData containing the time slicing of the calibration job.
Definition: Manager.h:152
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::alignment::GlobalCalibrationManager::~GlobalCalibrationManager
~GlobalCalibrationManager()
Destructor.
Definition: Manager.h:80
Belle2::alignment::GlobalCalibrationManager::cmpEventMetaData
std::function< bool(const EventMetaData &, const EventMetaData &)> cmpEventMetaData
Comparison function for EventMetaData.
Definition: Manager.h:67
Belle2::alignment::GlobalCalibrationManager::m_lorentzShift
std::unique_ptr< LorentShiftHierarchy > m_lorentzShift
Hierarchy for Lorentz shift corrections.
Definition: Manager.h:145
Belle2::alignment::GlobalCalibrationManager::m_alignment
std::unique_ptr< RigidBodyHierarchy > m_alignment
The alignment hierarchy.
Definition: Manager.h:143
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::alignment::GlobalCalibrationManager::m_constraints
std::map< long, Constraint > m_constraints
Map of constraints {unique label, labels and coefficients}.
Definition: Manager.h:149
Belle2::alignment::GlobalCalibrationManager
Class to hold hierarchy of whole Belle2.
Definition: Manager.h:60
Belle2::alignment::GlobalCalibrationManager::operator=
GlobalCalibrationManager & operator=(const GlobalCalibrationManager &)
Singleton class, hidden assignment operator.
Belle2::alignment::GlobalCalibrationManager::writeConstraints
void writeConstraints(std::string txtFilename)
Write-out complete hierarchy to a text file.
Definition: Manager.cc:162
Belle2::alignment::GlobalCalibrationManager::getInstance
static GlobalCalibrationManager & getInstance()
Get instance of the Manager auto& gcm = GlobalCalibrationManager::getInstance();.
Definition: Manager.cc:20
Belle2::alignment::GlobalCalibrationManager::getLorentzShiftHierarchy
LorentShiftHierarchy & getLorentzShiftHierarchy() const
Get the Lorentz shift hierarchy.
Definition: Manager.h:118
Belle2::alignment::GlobalCalibrationManager::m_globalVector
std::unique_ptr< GlobalParamVector > m_globalVector
The global vector for unified access to DB constants.
Definition: Manager.h:147
Belle2::EventMetaData
Store event, run, and experiment numbers.
Definition: EventMetaData.h:43
Belle2::alignment::GlobalCalibrationManager::m_iniTimeTable
alignment::timeline::TimeTable m_iniTimeTable
The initial time table generated from time intervals in GlobalLabel used to check if payload (labels)...
Definition: Manager.h:156
Belle2::alignment::GlobalCalibrationManager::initGlobalVector
static void initGlobalVector(GlobalParamVector &vector)
Initialize a given GlobalParamVector with all DB objects and interfaces.
Definition: Manager.cc:26