Belle II Software  release-06-00-14
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 
28 using namespace std;
29 using namespace Belle2;
30 
31 //-----------------------------------------------------------------
32 // Register the Module
33 //-----------------------------------------------------------------
34 REG_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 
47 B2BIIMCParticlesMonitorModule::~B2BIIMCParticlesMonitorModule()
48 {
49 }
50 
51 void B2BIIMCParticlesMonitorModule::defineHisto()
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 
68 void B2BIIMCParticlesMonitorModule::initialize()
69 {
70  REG_HISTOGRAM // required to register histograms to HistoManager
71 }
72 
73 void B2BIIMCParticlesMonitorModule::beginRun()
74 {
75 }
76 
77 void B2BIIMCParticlesMonitorModule::event()
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 
112 void B2BIIMCParticlesMonitorModule::endRun()
113 {
114 }
115 
116 void B2BIIMCParticlesMonitorModule::terminate()
117 {
118 }
119 
Declaration of class B2BIIMCParticlesMonitor.
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
TVector3 getMomentum() const
Return momentum.
Definition: MCParticle.h:198
int getNDaughters() const
Return number of daughter MCParticles.
Definition: MCParticle.cc:65
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:112
TVector3 getProductionVertex() const
Return production vertex position.
Definition: MCParticle.h:189
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:582
Abstract base class for different kinds of events.