9 #include <tracking/modules/ipMonitor/BeamSpotMonitorModule.h>
10 #include <framework/datastore/StoreObjPtr.h>
11 #include <framework/dataobjects/EventMetaData.h>
14 #include <TMatrixDSym.h>
31 setDescription(
"Module for the monitoring of the BeamSpot position and size");
34 addParam(
"outputFileName", m_rootFileName,
"Name of output root file.", std::string(
"BeamSpotMonitor.root"));
40 TDirectory* olddir = gDirectory;
41 m_rootFilePtr =
new TFile(m_rootFileName.c_str(),
"RECREATE");
44 m_tree =
new TTree(
"bspt",
"RECREATE");
45 b_exp = m_tree->Branch(
"exp", &m_exp,
"exp/i");
46 b_run = m_tree->Branch(
"run", &m_run,
"run/i");
47 b_x = m_tree->Branch(
"x", &m_x,
"x/d");
48 b_y = m_tree->Branch(
"y", &m_y,
"y/d");
49 b_z = m_tree->Branch(
"z", &m_z,
"z/d");
50 b_xErr = m_tree->Branch(
"xErr", &m_xErr,
"xErr/d");
51 b_yErr = m_tree->Branch(
"yErr", &m_yErr,
"yErr/d");
52 b_zErr = m_tree->Branch(
"zErr", &m_zErr,
"zErr/d");
53 b_xSize = m_tree->Branch(
"xSize", &m_xSize,
"xSize/d");
54 b_ySize = m_tree->Branch(
"ySize", &m_ySize,
"ySize/d");
55 b_zSize = m_tree->Branch(
"zSize", &m_zSize,
"zSize/d");
63 if (! m_BeamSpotDB.isValid()) {
64 B2WARNING(
"No valid BeamSpot for the requested IoV");
66 m_BeamSpot = *m_BeamSpotDB;
75 m_exp = meta->getExperiment();
76 m_run = meta->getRun();
77 B2DEBUG(25,
"monitoring beam spot for experiment = " << m_exp <<
", run = " << m_run);
79 if (! m_BeamSpotDB.isValid())
83 m_x = m_BeamSpot.getIPPosition().X();
84 m_y = m_BeamSpot.getIPPosition().Y();
85 m_z = m_BeamSpot.getIPPosition().Z();
88 TMatrixDSym posErr = m_BeamSpot.getIPPositionCovMatrix();
89 m_xErr = sqrt(posErr[0][0]);
90 m_yErr = sqrt(posErr[1][1]);
91 m_zErr = sqrt(posErr[2][2]);
94 TMatrixDSym size = m_BeamSpot.getSizeCovMatrix();
95 m_xSize = sqrt(size[0][0]);
96 m_ySize = sqrt(size[1][1]);
97 m_zSize = sqrt(size[2][2]);
105 TDirectory* olddir = gDirectory;
106 if (m_rootFilePtr !=
nullptr) {
113 m_rootFilePtr->Close();
Module for the monitoring of the BeamSpot position and size.
virtual void initialize() override
initialize the TTree
virtual void event() override
fill trees
virtual void terminate() override
print the payloads uniqueID and write tree to the rootfile
virtual void beginRun() override
check BeamSpot payload validity
Type-safe access to single objects in the data store.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.