Belle II Software development
IPDQMModule.cc
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/* Own header. */
10#include <dqm/modules/PhysicsObjectsDQM/IPDQMModule.h>
11
12/* Basf2 headers. */
13#include <analysis/dataobjects/ParticleList.h>
14#include <analysis/utility/ReferenceFrame.h>
15#include <framework/logging/Logger.h>
16
17/* ROOT headers. */
18#include <TDirectory.h>
19
20/* C++ headers. */
21#include <cmath>
22
23using namespace Belle2;
24
25REG_MODULE(IPDQM);
26
28{
29 setDescription("Monitor the position and the size of the interaction point using mu+mu- events");
31 addParam("Y4SPListName", m_Y4SPListName, "Name of the Y4S particle list", std::string("Upsilon(4S):IPDQM"));
32 addParam("onlineMode", m_onlineMode, "Mode of the online processing ('hlt' or 'expressreco')", std::string("expressreco"));
33}
34
36{
37 TDirectory* newDirectory{gDirectory->mkdir("IPMonitoring")};
38 TDirectory::TContext context{gDirectory, newDirectory};
39 // Common set of plots for HLT and ExpressReco
40 // Let's add a suffix to the plots when we run on HLT: necessary for the analysis module
41 std::string suffix = (m_onlineMode == "hlt") ? "_hlt" : "";
42 m_h_x = new TH1F(std::string{"Y4S_Vertex.X" + suffix}.c_str(), "IP position - coord. X", 1000, -0.5, 0.5);
43 m_h_x->SetXTitle("IP_coord. X [cm]");
44 m_h_y = new TH1F(std::string{"Y4S_Vertex.Y" + suffix}.c_str(), "IP position - coord. Y", 1000, -0.5, 0.5);
45 m_h_y->SetXTitle("IP_coord. Y [cm]");
46 m_h_z = new TH1F(std::string{"Y4S_Vertex.Z" + suffix}.c_str(), "IP position - coord. Z", 2000, -2.0, 2.0);
47 m_h_z->SetXTitle("IP_coord. Z [cm]");
48 if (m_onlineMode == "expressreco") {
49 m_h_px = new TH1F("Y4S_Vertex.pX", "Total momentum in lab. frame - coord. X", 100, -2, 2);
50 m_h_px->SetXTitle("pX [GeV/c]");
51 m_h_py = new TH1F("Y4S_Vertex.pY", "Total momentum in lab. frame - coord. Y", 100, -2, 2);
52 m_h_py->SetXTitle("pY [GeV/c]");
53 m_h_pz = new TH1F("Y4S_Vertex.pZ", "Total momentum in lab. frame - coord. Z", 100, 1, 5);
54 m_h_pz->SetXTitle("pZ [GeV/c]");
55 m_h_E = new TH1F("Y4S_Vertex.E", "Energy in lab. frame", 100, 8, 13);
56 m_h_E->SetXTitle("E [GeV]");
57 m_h_cov_x_x = new TH1F("Var.X", "X Variance", 500, 0., 0.005);
58 m_h_cov_x_x->SetXTitle("Var. X [cm^{2} ]");
59 m_h_cov_y_y = new TH1F("Var.Y", "Y Variance", 500, 0., 0.005);
60 m_h_cov_y_y->SetXTitle("Var. Y [cm^{2} ]");
61 m_h_cov_z_z = new TH1F("Var.Z", "Z Variance", 500, 0., 0.005);
62 m_h_cov_z_z->SetXTitle("Var. Z [cm^{2} ]");
63 m_h_cov_x_y = new TH1F("Covar.XY", "XY Covariance", 1000, -0.005, 0.005);
64 m_h_cov_x_y->SetXTitle("Var. XY [cm^{2} ]");
65 m_h_cov_x_z = new TH1F("Covar.XZ", "XZ Covariance", 1000, -0.005, 0.005);
66 m_h_cov_x_z->SetXTitle("Covar. XZ [cm^{2} ]");
67 m_h_cov_y_z = new TH1F("Covar.YZ", "YZ Covariance", 1000, -0.005, 0.005);
68 m_h_cov_y_z->SetXTitle("Covar. YZ [cm^{2} ]");
69 }
70 // We currently don't have specific plots for HLT: in case, they can be added here.
71}
72
74{
75 if (not(m_onlineMode == "hlt" or m_onlineMode == "expressreco")) {
76 B2FATAL("Unknown online processing mode" << LogVar("Set mode", m_onlineMode));
77 }
78 REG_HISTOGRAM
79}
80
82{
83 m_h_x->Reset();
84 m_h_y->Reset();
85 m_h_z->Reset();
86 if (m_onlineMode == "expressreco") {
87 m_h_cov_x_x->Reset();
88 m_h_cov_y_y->Reset();
89 m_h_cov_z_z->Reset();
90 m_h_cov_x_y->Reset();
91 m_h_cov_x_z->Reset();
92 m_h_cov_y_z->Reset();
93 m_h_px->Reset();
94 m_h_py->Reset();
95 m_h_pz->Reset();
96 m_h_E->Reset();
97 }
98}
99
101{
103 if (Y4SParticles.isValid() && abs(Y4SParticles->getPDGCode()) == 300553) {
104 const auto& frame = ReferenceFrame::GetCurrent();
105 for (unsigned int i = 0; i < Y4SParticles->getListSize(); i++) {
106 Particle* Y4S = Y4SParticles->getParticle(i);
107 B2Vector3D IPVertex = frame.getVertex(Y4S);
108 double IPX{IPVertex.X()};
109 double IPY{IPVertex.Y()};
110 double IPZ{IPVertex.Z()};
111 if (std::abs(IPX) < 0.5 and std::abs(IPY) < 0.5 and std::abs(IPZ) < 2.0) { // in cm
112 m_h_x->Fill(IPVertex.X());
113 m_h_y->Fill(IPVertex.Y());
114 m_h_z->Fill(IPVertex.Z());
115 if (m_onlineMode == "expressreco") {
116 const auto& errMatrix = Y4S->getVertexErrorMatrix();
117 m_h_cov_x_x->Fill(errMatrix(0, 0));
118 m_h_cov_y_y->Fill(errMatrix(1, 1));
119 m_h_cov_z_z->Fill(errMatrix(2, 2));
120 m_h_cov_x_y->Fill(errMatrix(0, 1));
121 m_h_cov_x_z->Fill(errMatrix(0, 2));
122 m_h_cov_y_z->Fill(errMatrix(1, 2));
123 m_h_px->Fill(frame.getMomentum(Y4S).Px());
124 m_h_py->Fill(frame.getMomentum(Y4S).Py());
125 m_h_pz->Fill(frame.getMomentum(Y4S).Pz());
126 m_h_E->Fill(frame.getMomentum(Y4S).E());
127 }
128 }
129 }
130 }
131}
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
TH1F * m_h_x
x coord
Definition: IPDQMModule.h:63
TH1F * m_h_cov_x_y
Cov xy.
Definition: IPDQMModule.h:87
TH1F * m_h_cov_y_z
Cov yz.
Definition: IPDQMModule.h:85
IPDQMModule()
Constructor.
Definition: IPDQMModule.cc:27
TH1F * m_h_px
x coord momentum in LAB frame
Definition: IPDQMModule.h:69
void initialize() override
Initialize the module.
Definition: IPDQMModule.cc:73
void event() override
Event processor The main analysis happens here.
Definition: IPDQMModule.cc:100
std::string m_Y4SPListName
Name of the Y4S particle list.
Definition: IPDQMModule.h:89
TH1F * m_h_cov_z_z
Var z.
Definition: IPDQMModule.h:81
TH1F * m_h_E
Energy in LAB frame.
Definition: IPDQMModule.h:75
TH1F * m_h_py
y coord momentum in LAB frame
Definition: IPDQMModule.h:71
std::string m_onlineMode
Mode of online processing ("HLT" or "ExpressReco")
Definition: IPDQMModule.h:91
TH1F * m_h_cov_y_y
Var y.
Definition: IPDQMModule.h:79
void beginRun() override
Called when entering a new run Reset the histograms.
Definition: IPDQMModule.cc:81
TH1F * m_h_pz
z coord momentum in LAB frame
Definition: IPDQMModule.h:73
TH1F * m_h_y
y coord
Definition: IPDQMModule.h:65
TH1F * m_h_z
z coord
Definition: IPDQMModule.h:67
TH1F * m_h_cov_x_z
Cov xz.
Definition: IPDQMModule.h:83
TH1F * m_h_cov_x_x
Var x.
Definition: IPDQMModule.h:77
void defineHisto() override
Defining the histograms.
Definition: IPDQMModule.cc:35
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
Class to store reconstructed particles.
Definition: Particle.h:75
TMatrixFSym getVertexErrorMatrix() const
Returns the 3x3 position error sub-matrix.
Definition: Particle.cc:447
static const ReferenceFrame & GetCurrent()
Get current rest frame.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:111
Class to store variables with their name which were sent to the logging service.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.