Belle II Software development
B2BIIMCParticlesMonitorModule.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// File : B2BIIMCParticlesMonitorModule.cc
10// Description : A module to plot MCParticles monitor histograms in basf2
11//
12//-
13
14#include <b2bii/modules/B2BIIMCParticlesMonitor/B2BIIMCParticlesMonitorModule.h>
15
16// framework
17#include <framework/core/HistoModule.h>
18
19// framework - DataStore
20#include <framework/datastore/StoreArray.h>
21
22// framework aux
23#include <framework/gearbox/Const.h>
24
25// dataonjects
26#include <mdst/dataobjects/MCParticle.h>
27
28using namespace std;
29using namespace Belle2;
30
31//-----------------------------------------------------------------
32// Register the Module
33//-----------------------------------------------------------------
34REG_MODULE(B2BIIMCParticlesMonitor);
35
36//-----------------------------------------------------------------
37// Implementation
38//-----------------------------------------------------------------
39
41{
42 //Set module properties
43 setDescription("This module creates and fills B2BII MCParticles monitoring histograms.");
44 // setDescription(c_ParallelProcessingCertified); // specify this flag if you need parallel processing
45}
46
48{
49}
50
52{
53 mcPDG = new TH1F("mcPDG", "PDG values of MCParticles", 100, -22500, 22500);
54 mcM = new TH1F("mcM", "M", 100, 0, 11.6);
55 mcPx = new TH1F("mcPx", "Px", 100, -5.8, 5.8);
56 mcPy = new TH1F("mcPy", "Py", 100, -5.8, 5.8);
57 mcPz = new TH1F("mcPz", "Pz", 100, -4.2, 8.6);
58 mcE = new TH1F("mcE", "E", 100, 0, 12.6);
59 mcVx = new TH1F("mcVx", "Vx", 100, -4500, 5100);
60 mcVy = new TH1F("mcVy", "Vy", 100, -5000, 4200);
61 mcVz = new TH1F("mcVz", "Vz", 100, -9000, 9800);
62 mcPiPlusMother = new TH1F("mcPiPlusMother", "Pi+ Mother PDG's", 102, -498000, 9498000);
63 mcPiMinusMother = new TH1F("mcPiMinusMother", "Pi- Mother PDG's", 102, -498000, 9498000);
64 mcPi0Mother = new TH1F("mcPi0Mother", "Pi0 Mother PDG's", 102, -498000, 9498000);
65 mcNDau = new TH1F("mcNDau", "Number of Daughters", 56, 0, 56);
66}
67
69{
70 REG_HISTOGRAM // required to register histograms to HistoManager
71}
72
74{
75}
76
78{
79 StoreArray<MCParticle> mc_particles;
80 if (!mc_particles) B2ERROR("Cannot find MCParticles array");
81
82 int nentries = mc_particles.getEntries();
83
84 for (int i = 0; i < nentries; i++) {
85
86 const MCParticle* mcparticle = mc_particles[i];
87
88 mcPDG->Fill(mcparticle->getPDG());
89
90 mcM->Fill(mcparticle->getMass());
91 mcPx->Fill(mcparticle->getMomentum().X());
92 mcPy->Fill(mcparticle->getMomentum().Y());
93 mcPz->Fill(mcparticle->getMomentum().Z());
94 mcE->Fill(mcparticle->getEnergy());
95
96 mcVx->Fill(mcparticle->getProductionVertex().X());
97 mcVy->Fill(mcparticle->getProductionVertex().Y());
98 mcVz->Fill(mcparticle->getProductionVertex().Z());
99
100 int mcparticle_pdg = mcparticle->getPDG();
101
102 if (mcparticle->getMother()) {
103 if (mcparticle_pdg == Const::pion.getPDGCode()) mcPiPlusMother->Fill(mcparticle->getMother()->getPDG());
104 if (mcparticle_pdg == -Const::pion.getPDGCode()) mcPiMinusMother->Fill(mcparticle->getMother()->getPDG());
105 if (mcparticle_pdg == Const::pi0.getPDGCode()) mcPi0Mother->Fill(mcparticle->getMother()->getPDG());
106 }
107
108 mcNDau->Fill(mcparticle->getNDaughters());
109 }
110}
111
113{
114}
115
117{
118}
119
TH1F * mcPi0Mother
histogram PDG codes of mother particles of pi0's
virtual void initialize() override
Initialize the module.
TH1F * mcPDG
histogram PDG values of MC Particles
virtual void event() override
Called for each event.
virtual void endRun() override
Called when the current run finished.
virtual void terminate() override
Terminates the module.
virtual void beginRun() override
Called when a new run is started.
TH1F * mcPiMinusMother
histogram PDG codes of mother particles of negative pions
TH1F * mcPiPlusMother
histogram PDG codes of mother particles of positive pions
TH1F * mcNDau
histogram number of daughter particles of all particles
virtual void defineHisto() override
function to define histograms
static const ParticleType pi0
neutral pion particle
Definition: Const.h:674
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
float getEnergy() const
Return particle energy in GeV.
Definition: MCParticle.h:147
float getMass() const
Return the particle mass in GeV.
Definition: MCParticle.h:135
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
Definition: MCParticle.h:189
int getNDaughters() const
Return number of daughter MCParticles.
Definition: MCParticle.cc:75
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:112
ROOT::Math::XYZVector getMomentum() const
Return momentum.
Definition: MCParticle.h:198
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
MCParticle * getMother() const
Returns a pointer to the mother particle.
Definition: MCParticle.h:600
Abstract base class for different kinds of events.
STL namespace.