Belle II Software  release-08-01-10
Manager.h
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 #pragma once
10 
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <Geant4/G4Transform3D.hh>
15 #include <root/TMatrixD.h>
16 #include <genfit/StateOnPlane.h>
17 #include <root/TGeoMatrix.h>
18 #include <set>
19 
20 #include <framework/logging/Logger.h>
21 
22 #include <mdst/dbobjects/BeamSpot.h>
23 #include <alignment/dbobjects/VXDAlignment.h>
24 #include <alignment/dbobjects/CDCCalibration.h>
25 #include <klm/dbobjects/bklm/BKLMAlignment.h>
26 #include <klm/dbobjects/eklm/EKLMAlignment.h>
27 #include <klm/dbobjects/eklm/EKLMSegmentAlignment.h>
28 
29 #include <cdc/dbobjects/CDCTimeZeros.h>
30 #include <cdc/dbobjects/CDCTimeWalks.h>
31 #include <cdc/dbobjects/CDCAlignment.h>
32 #include <cdc/dbobjects/CDCXtRelations.h>
33 
34 #include <alignment/GlobalParam.h>
35 #include <alignment/GlobalTimeLine.h>
36 #include <alignment/Hierarchy.h>
37 
38 #include <map>
39 #include <string>
40 #include <vector>
41 
42 namespace Belle2 {
47  namespace alignment {
48 
51 
52  public:
53 
54 
55 
57  std::function<bool(const EventMetaData&, const EventMetaData&)> cmpEventMetaData = [](const EventMetaData& lhs,
58  const EventMetaData& rhs) -> bool {
59  if (lhs.getExperiment() < rhs.getExperiment()) return true;
60  if (lhs.getExperiment() > rhs.getExperiment()) return false;
61 
62  if (lhs.getRun() < rhs.getRun()) return true;
63  if (lhs.getRun() > rhs.getRun()) return false;
64 
65  if (lhs.getEvent() < rhs.getEvent()) return true;
66  return false;
67  };
68 
78 
79 
88  static void initGlobalVector(GlobalParamVector& vector);
89 
92  void sortUniqueVector(std::vector<EventMetaData>& vec);
93 
96 
98  void initialize(const std::vector<std::string>& components = {}, const std::vector<EventMetaData>& timeSlices = {});
99 
101  void preCollect(const EventMetaData& emd);
102 
104  public:
110  Constraints& getConstraints() { return m_constraints; }
111 
113  void writeConstraints(std::string txtFilename);
114 
115  private:
122 
126  int updateTimeDepGlobalLabels(const EventMetaData& event);
127 
128 
130  bool m_initialized {false};
131 
133  std::unique_ptr<RigidBodyHierarchy> m_alignment {new RigidBodyHierarchy()};
135  std::unique_ptr<LorentShiftHierarchy> m_lorentzShift {new LorentShiftHierarchy()};
137  std::unique_ptr<GlobalParamVector> m_globalVector {new GlobalParamVector()};
139  std::map<long, Constraint> m_constraints {};
140 
142  std::vector<EventMetaData> m_dbTimeSlicing {};
143 
146  alignment::timeline::TimeTable m_iniTimeTable{};
147  };
148 
149  }
151 }
Store event, run, and experiment numbers.
Definition: EventMetaData.h:33
int getRun() const
Run Getter.
unsigned int getEvent() const
Event Getter.
int getExperiment() const
Experiment Getter.
Class to hold hierarchy of whole Belle2.
Definition: Manager.h:50
std::function< bool(const EventMetaData &, const EventMetaData &)> cmpEventMetaData
Comparison function for EventMetaData.
Definition: Manager.h:57
Constraints & getConstraints()
Get the constraints collected so far.
Definition: Manager.h:110
bool m_initialized
Finished initialization?
Definition: Manager.h:130
LorentShiftHierarchy & getLorentzShiftHierarchy() const
Get the Lorentz shift hierarchy.
Definition: Manager.h:108
std::unique_ptr< RigidBodyHierarchy > m_alignment
The alignment hierarchy.
Definition: Manager.h:133
GlobalCalibrationManager()
Singleton class, hidden constructor.
Definition: Manager.h:117
void writeConstraints(std::string txtFilename)
Write-out complete hierarchy to a text file.
Definition: Manager.cc:169
void initialize(const std::vector< std::string > &components={}, const std::vector< EventMetaData > &timeSlices={})
Initialize the manager with given configuration (from MillepedeCollector)
Definition: Manager.cc:52
std::vector< EventMetaData > m_dbTimeSlicing
Vector of EventMetaData containing the time slicing of the calibration job.
Definition: Manager.h:142
std::unique_ptr< LorentShiftHierarchy > m_lorentzShift
Hierarchy for Lorentz shift corrections.
Definition: Manager.h:135
RigidBodyHierarchy & getAlignmentHierarchy() const
Get the rigid body alignment hierarchy.
Definition: Manager.h:106
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:190
std::unique_ptr< GlobalParamVector > m_globalVector
The global vector for unified access to DB constants.
Definition: Manager.h:137
std::map< long, Constraint > m_constraints
Map of constraints {unique label, labels and coefficients}.
Definition: Manager.h:139
int updateTimeDepGlobalLabels(const EventMetaData &event)
Update the current time ID in the GlobalLabel.
Definition: Manager.cc:196
GlobalCalibrationManager & operator=(const GlobalCalibrationManager &)
Singleton class, hidden assignment operator.
static void initGlobalVector(GlobalParamVector &vector)
Initialize a given GlobalParamVector with all DB objects and interfaces.
Definition: Manager.cc:33
GlobalCalibrationManager(const GlobalCalibrationManager &)
Singleton class, hidden copy constructor.
void preCollect(const EventMetaData &emd)
Notice manager of a comming event (from MillepedeCollector)
Definition: Manager.cc:98
alignment::timeline::TimeTable m_iniTimeTable
The initial time table generated from time intervals in GlobalLabel used to check if payload (labels)...
Definition: Manager.h:146
static GlobalCalibrationManager & getInstance()
Get instance of the Manager auto& gcm = GlobalCalibrationManager::getInstance();.
Definition: Manager.cc:27
The central user class to manipulate any global constant in any DB object Used to retrieve global par...
Definition: GlobalParam.h:327
1D Hierarchy for Lorentz shift correction
Definition: Hierarchy.h:108
6D Hierarchy of rigid bodies
Definition: Hierarchy.h:144
Abstract base class for different kinds of events.