Belle II Software  release-06-00-14
IPDQMExpressRecoModule.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 #include <dqm/modules/PhysicsObjectsDQM/IPDQMExpressRecoModule.h>
10 #include <analysis/dataobjects/ParticleList.h>
11 #include <analysis/utility/ReferenceFrame.h>
12 #include <TLorentzVector.h>
13 #include <TDirectory.h>
14 
15 using namespace Belle2;
16 
17 //-----------------------------------------------------------------
18 // Register the Module
19 //-----------------------------------------------------------------
20 REG_MODULE(IPDQMExpressReco)
21 
22 //-----------------------------------------------------------------
23 // Implementation
24 //-----------------------------------------------------------------
25 
27 {
28  //Set module properties
29 
30  setDescription("Monitor the position of the beamspot using mu+mu- events");
31  setPropertyFlags(c_ParallelProcessingCertified);
32 
33  addParam("Y4SPListName", m_Y4SPListName, "Name of the Y4S particle list", std::string("Upsilon(4S):IPDQM"));
34 }
35 
37 {
38  TDirectory* oldDir = gDirectory;
39  oldDir->mkdir("IPMonitoring")->cd();
40 
41  m_h_x = new TH1F("Y4S_Vertex.X", "IP position - coord. X", 1000, -0.5, 0.5);
42  m_h_x->SetXTitle("IP_coord. X [cm]");
43  m_h_y = new TH1F("Y4S_Vertex.Y", "IP position - coord. Y", 1000, -0.5, 0.5);
44  m_h_y->SetXTitle("IP_coord. Y [cm]");
45  m_h_z = new TH1F("Y4S_Vertex.Z", "IP position - coord. Z", 2000, -2, 2);
46  m_h_z->SetXTitle("IP_coord. Z [cm]");
47  m_h_px = new TH1F("Y4S_Vertex.pX", "Total momentum in lab. frame - coord. X", 100, -2, 2);
48  m_h_px->SetXTitle("pX [GeV/c]");
49  m_h_py = new TH1F("Y4S_Vertex.pY", "Total momentum in lab. frame - coord. Y", 100, -2, 2);
50  m_h_py->SetXTitle("pY [GeV/c]");
51  m_h_pz = new TH1F("Y4S_Vertex.pZ", "Total momentum in lab. frame - coord. Z", 100, 1, 5);
52  m_h_pz->SetXTitle("pZ [GeV/c]");
53  m_h_E = new TH1F("Y4S_Vertex.E", "Energy in lab. frame", 100, 8, 13);
54  m_h_E->SetXTitle("E [GeV]");
55  m_h_pull = new TH1F("Y4S_pull.Y", "Pull - coord. Y", 100, -10, 10);
56  m_h_pull->SetXTitle("(y_{reco}- y_{med})/#sigma_{y}^{reco}");
57  m_h_pull->GetXaxis()->SetTitleOffset(1.2);
58  m_h_pull->GetXaxis()->SetTitleSize(.04);
59  m_h_y_risol = new TH1F("Y4S_Res.Y", "Resolution - coord. Y", 1000, -1, 1);
60  m_h_y_risol->GetXaxis()->SetTitleOffset(1.2);
61  m_h_y_risol->SetXTitle("(y_{reco}- y_{med}) [cm]");
62  m_h_temp = new TH1F("Y4S_temp.Y", "temp - coord. Y", 2000, -2, 2);
63  m_h_temp->SetXTitle("IP_coord. Y [cm]");
64  m_h_xx = new TH1F("Y4S_Prod.XX", "IP position - prod. XX", 1000, 0, 0.5);
65  m_h_xx->SetXTitle("IP_prod. XX [cm^{2} ]");
66  m_h_yy = new TH1F("Y4S_Prod.YY", "IP position - prod. YY", 1000, 0, 0.5);
67  m_h_yy->SetXTitle("IP_prod. YY [cm^{2} ]");
68  m_h_zz = new TH1F("Y4S_Prod.ZZ", "IP position - prod. ZZ", 2000, 0, 4);
69  m_h_zz->SetXTitle("IP_prod. ZZ [cm^{2} ]");
70  m_h_xy = new TH1F("Y4S_Prod.XY", "IP position - prod. XY", 1000, -1, 1);
71  m_h_xy->SetXTitle("IP_prod. XY [cm^{2} ]");
72  m_h_yz = new TH1F("Y4S_Prod.YZ", "IP position - prod. YZ", 1000, -1, 1);
73  m_h_yz->SetXTitle("IP_prod. YZ [cm^{2} ]");
74  m_h_xz = new TH1F("Y4S_Prod.XZ", "IP position - prod. XZ", 1000, -1, 1);
75  m_h_xz->SetXTitle("IP_prod. XZ [cm^{2} ]");
76  m_h_cov_x_x = new TH1F("Var.X", "X Variance", 500, 0., 0.005);
77  m_h_cov_x_x->SetXTitle("Var. X [cm^{2} ]");
78  m_h_cov_y_y = new TH1F("Var.Y", "Y Variance", 500, 0., 0.005);
79  m_h_cov_y_y->SetXTitle("Var. Y [cm^{2} ]");
80  m_h_cov_z_z = new TH1F("Var.Z", "Z Variance", 500, 0., 0.005);
81  m_h_cov_z_z->SetXTitle("Var. Z [cm^{2} ]");
82  m_h_cov_x_y = new TH1F("Covar.XY", "XY Covariance", 1000, -0.005, 0.005);
83  m_h_cov_x_y->SetXTitle("Var. XY [cm^{2} ]");
84  m_h_cov_x_z = new TH1F("Covar.XZ", "XZ Covariance", 1000, -0.005, 0.005);
85  m_h_cov_x_z->SetXTitle("Covar. XZ [cm^{2} ]");
86  m_h_cov_y_z = new TH1F("Covar.YZ", "YZ Covariance", 1000, -0.005, 0.005);
87  m_h_cov_y_z->SetXTitle("Covar. YZ [cm^{2} ]");
88 
89  oldDir->cd();
90 }
91 
92 
94 {
95  REG_HISTOGRAM
96 }
97 
98 
100 {
101  m_h_x->Reset();
102  m_h_y->Reset();
103  m_h_z->Reset();
104  m_h_pull->Reset();
105  m_h_temp->Reset();
106  m_h_y_risol->Reset();
107  m_h_cov_x_x->Reset();
108  m_h_cov_y_y->Reset();
109  m_h_cov_z_z->Reset();
110  m_h_cov_x_y->Reset();
111  m_h_cov_x_z->Reset();
112  m_h_cov_y_z->Reset();
113  m_h_xx->Reset();
114  m_h_yy->Reset();
115  m_h_zz->Reset();
116  m_h_xy->Reset();
117  m_h_xz->Reset();
118  m_h_yz->Reset();
119  m_h_px->Reset();
120  m_h_py->Reset();
121  m_h_pz->Reset();
122  m_h_E->Reset();
123  m_v_y.clear();
124  m_err_y.clear();
125  m_r = 0;
126 }
127 
128 
130 {
131  m_h_x->GetXaxis()->SetRangeUser(m_h_x->GetMean(1) - 5 * m_h_x->GetRMS(1), m_h_x->GetMean(1) + 5 * m_h_x->GetRMS(1));
132  m_h_y->GetXaxis()->SetRangeUser(m_h_y->GetMean(1) - 5 * m_h_y->GetRMS(1), m_h_y->GetMean(1) + 5 * m_h_y->GetRMS(1));
133  m_h_z->GetXaxis()->SetRangeUser(m_h_z->GetMean(1) - 5 * m_h_z->GetRMS(1), m_h_z->GetMean(1) + 5 * m_h_z->GetRMS(1));
134  m_h_xy->GetXaxis()->SetRangeUser(m_h_xy->GetMean(1) - 5 * m_h_xy->GetRMS(1), m_h_xy->GetMean(1) + 5 * m_h_xy->GetRMS(1));
135  m_h_xz->GetXaxis()->SetRangeUser(m_h_xz->GetMean(1) - 5 * m_h_xz->GetRMS(1), m_h_xz->GetMean(1) + 5 * m_h_xz->GetRMS(1));
136  m_h_yz->GetXaxis()->SetRangeUser(m_h_yz->GetMean(1) - 5 * m_h_yz->GetRMS(1), m_h_yz->GetMean(1) + 5 * m_h_yz->GetRMS(1));
137  m_h_xx->GetXaxis()->SetRangeUser(m_h_xx->GetMean(1) - 5 * m_h_xx->GetRMS(1), m_h_xx->GetMean(1) + 5 * m_h_xx->GetRMS(1));
138  m_h_yy->GetXaxis()->SetRangeUser(m_h_yy->GetMean(1) - 5 * m_h_yy->GetRMS(1), m_h_yy->GetMean(1) + 5 * m_h_yy->GetRMS(1));
139  m_h_zz->GetXaxis()->SetRangeUser(m_h_zz->GetMean(1) - 5 * m_h_zz->GetRMS(1), m_h_zz->GetMean(1) + 5 * m_h_zz->GetRMS(1));
140  m_h_pull->GetXaxis()->SetRangeUser(m_h_pull->GetMean(1) - 5 * m_h_pull->GetRMS(1), m_h_pull->GetMean(1) + 5 * m_h_pull->GetRMS(1));
141  m_h_y_risol->GetXaxis()->SetRangeUser(m_h_y_risol->GetMean(1) - 5 * m_h_y_risol->GetRMS(1),
142  m_h_y_risol->GetMean(1) + 5 * m_h_y_risol->GetRMS(1));
143  m_h_cov_x_x->GetXaxis()->SetRangeUser(m_h_cov_x_x->GetMean(1) - 5 * m_h_cov_x_x->GetRMS(1),
144  m_h_cov_x_x->GetMean(1) + 5 * m_h_cov_x_x->GetRMS(1));
145  m_h_cov_y_y->GetXaxis()->SetRangeUser(m_h_cov_y_y->GetMean(1) - 5 * m_h_cov_y_y->GetRMS(1),
146  m_h_cov_y_y->GetMean(1) + 5 * m_h_cov_y_y->GetRMS(1));
147  m_h_cov_z_z->GetXaxis()->SetRangeUser(m_h_cov_z_z->GetMean(1) - 5 * m_h_cov_z_z->GetRMS(1),
148  m_h_cov_z_z->GetMean(1) + 5 * m_h_cov_z_z->GetRMS(1));
149  m_h_cov_x_z->GetXaxis()->SetRangeUser(m_h_cov_x_z->GetMean(1) - 5 * m_h_cov_x_z->GetRMS(1),
150  m_h_cov_x_z->GetMean(1) + 5 * m_h_cov_x_z->GetRMS(1));
151  m_h_cov_x_y->GetXaxis()->SetRangeUser(m_h_cov_x_y->GetMean(1) - 5 * m_h_cov_x_y->GetRMS(1),
152  m_h_cov_x_y->GetMean(1) + 5 * m_h_cov_x_y->GetRMS(1));
153  m_h_cov_y_z->GetXaxis()->SetRangeUser(m_h_cov_y_z->GetMean(1) - 5 * m_h_cov_y_z->GetRMS(1),
154  m_h_cov_y_z->GetMean(1) + 5 * m_h_cov_y_z->GetRMS(1));
155 }
156 
158 {
159 }
160 
162 {
163 
165  const auto& frame = ReferenceFrame::GetCurrent();
166 
167 
168  if (Y4SParticles.isValid() && abs(Y4SParticles->getPDGCode()) == 300553) {
169 
170  for (unsigned int i = 0; i < Y4SParticles->getListSize(); i++) {
171 
172  Particle* Y4S = Y4SParticles->getParticle(i);
173  TVector3 IPVertex = frame.getVertex(Y4S);
174  const auto& errMatrix = Y4S->getVertexErrorMatrix();
175  m_h_x->Fill(IPVertex.X());
176  m_h_y->Fill(IPVertex.Y());
177  m_h_z->Fill(IPVertex.Z());
178  m_h_xy->Fill(IPVertex.X()*IPVertex.Y());
179  m_h_xz->Fill(IPVertex.X()*IPVertex.Z());
180  m_h_yz->Fill(IPVertex.Y()*IPVertex.Z());
181  m_h_xx->Fill(IPVertex.X()*IPVertex.X());
182  m_h_yy->Fill(IPVertex.Y()*IPVertex.Y());
183  m_h_zz->Fill(IPVertex.Z()*IPVertex.Z());
184  m_h_temp->Fill(IPVertex.Y());
185  m_h_cov_x_x->Fill(errMatrix(0, 0));
186  m_h_cov_y_y->Fill(errMatrix(1, 1));
187  m_h_cov_z_z->Fill(errMatrix(2, 2));
188  m_h_cov_x_y->Fill(errMatrix(0, 1));
189  m_h_cov_x_z->Fill(errMatrix(0, 2));
190  m_h_cov_y_z->Fill(errMatrix(1, 2));
191  m_h_px->Fill(frame.getMomentum(Y4S).Px());
192  m_h_py->Fill(frame.getMomentum(Y4S).Py());
193  m_h_pz->Fill(frame.getMomentum(Y4S).Pz());
194  m_h_E->Fill(frame.getMomentum(Y4S).E());
195  m_err_y.push_back(std::sqrt(errMatrix(1, 1)));
196  m_v_y.push_back(IPVertex.Y());
197 
198  if (m_r == m_size_per_unit) {
199  m_h_temp->GetQuantiles(1, &m_median, &m_quantile);
200  for (unsigned int u = 0; u < m_v_y.size(); u++) {
201  m_h_y_risol->Fill(m_v_y.at(u) - m_median);
202  m_h_pull->Fill((m_v_y.at(u) - m_median) / m_err_y.at(u));
203  }
204  m_r = 0;
205  m_v_y.clear();
206  m_err_y.clear();
207  }
208  m_r += 1;
209  }
210 
211  }
212 
213 }
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
This Module, made for ExpressReco, monitors the position and the dimension of the beamspot using mu+m...
TH1F * m_h_temp
initial histogram for median calculation
TH1F * m_h_px
x coord momentum in LAB frame
void initialize() override
Initialize the module.
Double_t m_median
The median of y coord.
void event() override
Event processor The main analysis happens here.
std::string m_Y4SPListName
Name of the Y4S particle list.
void endRun() override
End-of-run action.
Int_t m_size_per_unit
Size for sampling per each unit.
TH1F * m_h_E
Energy in LAB frame.
TH1F * m_h_py
y coord momentum in LAB frame
void terminate() override
Termination action.
Int_t m_r
Counter for sampling.
void beginRun() override
Called when entering a new run Reset the histograms and counter m_r and clear the vectors.
TH1F * m_h_pz
z coord momentum in LAB frame
std::vector< float > m_v_y
store the y coordinates for the pull
std::vector< float > m_err_y
store the y errors for the pull
Double_t m_quantile
The 0.5 quantile for the median.
void defineHisto() override
Defining the histograms.
Class to store reconstructed particles.
Definition: Particle.h:74
TMatrixFSym getVertexErrorMatrix() const
Returns the 3x3 position error sub-matrix.
Definition: Particle.cc:457
static const ReferenceFrame & GetCurrent()
Get current rest frame.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:110
#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.