11 #include <tracking/modules/ipMonitor/BeamSpotMonitorModule.h>
12 #include <framework/datastore/StoreObjPtr.h>
13 #include <framework/dataobjects/EventMetaData.h>
16 #include <TMatrixDSym.h>
33 setDescription(
"Module for the monitoring of the BeamSpot position and size");
36 addParam(
"outputFileName", m_rootFileName,
"Name of output root file.", std::string(
"BeamSpotMonitor.root"));
42 TDirectory* olddir = gDirectory;
43 m_rootFilePtr =
new TFile(m_rootFileName.c_str(),
"RECREATE");
46 m_tree =
new TTree(
"bspt",
"RECREATE");
47 b_exp = m_tree->Branch(
"exp", &m_exp,
"exp/i");
48 b_run = m_tree->Branch(
"run", &m_run,
"run/i");
49 b_x = m_tree->Branch(
"x", &m_x,
"x/d");
50 b_y = m_tree->Branch(
"y", &m_y,
"y/d");
51 b_z = m_tree->Branch(
"z", &m_z,
"z/d");
52 b_xErr = m_tree->Branch(
"xErr", &m_xErr,
"xErr/d");
53 b_yErr = m_tree->Branch(
"yErr", &m_yErr,
"yErr/d");
54 b_zErr = m_tree->Branch(
"zErr", &m_zErr,
"zErr/d");
55 b_xSize = m_tree->Branch(
"xSize", &m_xSize,
"xSize/d");
56 b_ySize = m_tree->Branch(
"ySize", &m_ySize,
"ySize/d");
57 b_zSize = m_tree->Branch(
"zSize", &m_zSize,
"zSize/d");
65 if (! m_BeamSpotDB.isValid()) {
66 B2WARNING(
"No valid BeamSpot for the requested IoV");
68 m_BeamSpot = *m_BeamSpotDB;
77 m_exp = meta->getExperiment();
78 m_run = meta->getRun();
79 B2DEBUG(25,
"monitoring beam spot for experiment = " << m_exp <<
", run = " << m_run);
81 if (! m_BeamSpotDB.isValid())
85 m_x = m_BeamSpot.getIPPosition().X();
86 m_y = m_BeamSpot.getIPPosition().Y();
87 m_z = m_BeamSpot.getIPPosition().Z();
90 TMatrixDSym posErr = m_BeamSpot.getIPPositionCovMatrix();
91 m_xErr = sqrt(posErr[0][0]);
92 m_yErr = sqrt(posErr[1][1]);
93 m_zErr = sqrt(posErr[2][2]);
96 TMatrixDSym size = m_BeamSpot.getSizeCovMatrix();
97 m_xSize = sqrt(size[0][0]);
98 m_ySize = sqrt(size[1][1]);
99 m_zSize = sqrt(size[2][2]);
107 TDirectory* olddir = gDirectory;
108 if (m_rootFilePtr !=
nullptr) {
115 m_rootFilePtr->Close();