Belle II Software  release-05-02-19
B2BIIMCParticlesMonitorModule.cc
1 //+
2 // File : B2BIIMCParticlesMonitorModule.cc
3 // Description : A module to plot MCParticles monitor histograms in basf2
4 //
5 // Contributors: Hulya Atmacan
6 // Date : November 21, 2015
7 //-
8 
9 #include <b2bii/modules/B2BIIMCParticlesMonitor/B2BIIMCParticlesMonitorModule.h>
10 
11 // framework
12 #include <framework/core/HistoModule.h>
13 
14 // framework - DataStore
15 #include <framework/datastore/StoreArray.h>
16 
17 // dataonjects
18 #include <mdst/dataobjects/MCParticle.h>
19 
20 using namespace std;
21 using namespace Belle2;
22 
23 //-----------------------------------------------------------------
24 // Register the Module
25 //-----------------------------------------------------------------
26 REG_MODULE(B2BIIMCParticlesMonitor)
27 
28 //-----------------------------------------------------------------
29 // Implementation
30 //-----------------------------------------------------------------
31 
33 {
34  //Set module properties
35  setDescription("This module creates and fills B2BII MCParticles monitoring histograms.");
36  // setDescription(c_ParallelProcessingCertified); // specify this flag if you need parallel processing
37 }
38 
39 B2BIIMCParticlesMonitorModule::~B2BIIMCParticlesMonitorModule()
40 {
41 }
42 
43 void B2BIIMCParticlesMonitorModule::defineHisto()
44 {
45  mcPDG = new TH1F("mcPDG", "PDG values of MCParticles", 100, -22500, 22500);
46  mcM = new TH1F("mcM", "M", 100, 0, 11.6);
47  mcPx = new TH1F("mcPx", "Px", 100, -5.8, 5.8);
48  mcPy = new TH1F("mcPy", "Py", 100, -5.8, 5.8);
49  mcPz = new TH1F("mcPz", "Pz", 100, -4.2, 8.6);
50  mcE = new TH1F("mcE", "E", 100, 0, 12.6);
51  mcVx = new TH1F("mcVx", "Vx", 100, -4500, 5100);
52  mcVy = new TH1F("mcVy", "Vy", 100, -5000, 4200);
53  mcVz = new TH1F("mcVz", "Vz", 100, -9000, 9800);
54  mcPiPlusMother = new TH1F("mcPiPlusMother", "Pi+ Mother PDG's", 102, -498000, 9498000);
55  mcPiMinusMother = new TH1F("mcPiMinusMother", "Pi- Mother PDG's", 102, -498000, 9498000);
56  mcPi0Mother = new TH1F("mcPi0Mother", "Pi0 Mother PDG's", 102, -498000, 9498000);
57  mcNDau = new TH1F("mcNDau", "Number of Daughters", 56, 0, 56);
58 }
59 
60 void B2BIIMCParticlesMonitorModule::initialize()
61 {
62  REG_HISTOGRAM // required to register histograms to HistoManager
63 }
64 
65 void B2BIIMCParticlesMonitorModule::beginRun()
66 {
67 }
68 
69 void B2BIIMCParticlesMonitorModule::event()
70 {
71  StoreArray<MCParticle> mc_particles;
72  if (!mc_particles) B2ERROR("Cannot find MCParticles array");
73 
74  int nentries = mc_particles.getEntries();
75 
76  for (int i = 0; i < nentries; i++) {
77 
78  const MCParticle* mcparticle = mc_particles[i];
79 
80  mcPDG->Fill(mcparticle->getPDG());
81 
82  mcM->Fill(mcparticle->getMass());
83  mcPx->Fill(mcparticle->getMomentum().X());
84  mcPy->Fill(mcparticle->getMomentum().Y());
85  mcPz->Fill(mcparticle->getMomentum().Z());
86  mcE->Fill(mcparticle->getEnergy());
87 
88  mcVx->Fill(mcparticle->getProductionVertex().X());
89  mcVy->Fill(mcparticle->getProductionVertex().Y());
90  mcVz->Fill(mcparticle->getProductionVertex().Z());
91 
92  int mcparticle_pdg = mcparticle->getPDG();
93 
94  if (mcparticle->getMother()) {
95  if (mcparticle_pdg == 211) mcPiPlusMother->Fill(mcparticle->getMother()->getPDG());
96  if (mcparticle_pdg == -211) mcPiMinusMother->Fill(mcparticle->getMother()->getPDG());
97  if (mcparticle_pdg == 111) mcPi0Mother->Fill(mcparticle->getMother()->getPDG());
98  }
99 
100  mcNDau->Fill(mcparticle->getNDaughters());
101  }
102 }
103 
104 void B2BIIMCParticlesMonitorModule::endRun()
105 {
106 }
107 
108 void B2BIIMCParticlesMonitorModule::terminate()
109 {
110 }
111 
Belle2::MCParticle::getEnergy
float getEnergy() const
Return particle energy in GeV.
Definition: MCParticle.h:158
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MCParticle::getProductionVertex
TVector3 getProductionVertex() const
Return production vertex position.
Definition: MCParticle.h:200
Belle2::MCParticle::getPDG
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:123
Belle2::MCParticle::getMass
float getMass() const
Return the particle mass in GeV.
Definition: MCParticle.h:146
Belle2::MCParticle::getMother
MCParticle * getMother() const
Returns a pointer to the mother particle.
Definition: MCParticle.h:593
Belle2::B2BIIMCParticlesMonitorModule
Declaration of class B2BIIMCParticlesMonitor.
Definition: B2BIIMCParticlesMonitorModule.h:24
Belle2::MCParticle::getMomentum
TVector3 getMomentum() const
Return momentum.
Definition: MCParticle.h:209
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::StoreArray< MCParticle >
Belle2::MCParticle::getNDaughters
int getNDaughters() const
Return number of daughter MCParticles.
Definition: MCParticle.cc:66
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::HistoModule
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29