Belle II Software development
EclBackgroundStudyModule.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 <background/modules/EclBackgroundStudy/EclBackgroundStudyModule.h>
10
11using namespace std;
12using namespace boost;
13
14namespace Belle2 {
19 //-----------------------------------------------------------------
21 //-----------------------------------------------------------------
22
23 REG_MODULE(EclBackgroundStudy);
24
25
26 //-----------------------------------------------------------------
27 // Implementation
28 //-----------------------------------------------------------------
29
31 m_TCMap(NULL)
32 {
33 // Set description()
34 setDescription("EclBackgroundStudy module. Used to extract information relevant for the ECL background from background files");
35
36 // Add parameters
37 addParam("FileName", m_filename, "output file name", string("mytree.root"));
38 }
39
41 {
42 // Print set parameters
44
45 // create/open the file
46 m_ff = new TFile(m_filename.c_str(), "RECREATE");
47
48 // create trees
49 m_tree1 = new TTree("tree1", "ECLHits data");
50 m_tree2 = new TTree("tree2", "ECLSimHits data");
51
52 // create branches
53 m_tree1->Branch("CellId", &m_CellId);
54 m_tree1->Branch("TcId", &m_TcId);
55 m_tree1->Branch("Edep", &m_Edep);
56 m_tree1->Branch("TimeAve", &m_TimeAve);
57
58 m_tree2->Branch("CellId", &m_CellId);
59 m_tree2->Branch("TcId", &m_TcId);
60 m_tree2->Branch("Pdg", &m_Pdg);
61 m_tree2->Branch("FlightTime", &m_FlightTime);
62 m_tree2->Branch("Edep", &m_Edep);
63 m_tree2->Branch("Hadronedep", &m_Hadronedep);
64
65 m_TCMap = new TrgEclMapping();
66 }
67
69 {
70 // Print run number
71 B2INFO("EclBackgroundStudy: Processing. ");
72 }
73
75 {
76 m_CellId.clear();
77 m_TcId.clear();
78 m_Pdg.clear();
79 m_Edep.clear();
80 m_TimeAve.clear();
81 m_FlightTime.clear();
82 m_Hadronedep.clear();
83
84 // loop over ECLHits
85 for (const ECLHit& hit : m_ECLHits) {
86 m_CellId.push_back(hit.getCellId());
87 m_TcId.push_back(m_TCMap->getTCIdFromXtalId(hit.getCellId()));
88 m_Edep.push_back(hit.getEnergyDep());
89 m_TimeAve.push_back(hit.getTimeAve());
90 }
91 // fill the tree
92 m_tree1->Fill();
93
94 m_CellId.clear();
95 m_TcId.clear();
96 m_Pdg.clear();
97 m_Edep.clear();
98 m_TimeAve.clear();
99 m_FlightTime.clear();
100 m_Hadronedep.clear();
101
102 // loop over ECLSimHits
103 for (const ECLSimHit& hit : m_ECLSimHits) {
104 m_CellId.push_back(hit.getCellId());
105 m_TcId.push_back(m_TCMap->getTCIdFromXtalId(hit.getCellId()));
106 m_Pdg.push_back(hit.getPDGCode());
107 m_FlightTime.push_back(hit.getFlightTime());
108 m_Edep.push_back(hit.getEnergyDep());
109 m_Hadronedep.push_back(hit.getHadronEnergyDep());
110 }
111 // fill the tree
112 m_tree2->Fill();
113
114 // increase the entry counter
115 m_iEntry++;
116 }
117
119 {
120 // CPU time end
121
122 // Announce
123 B2INFO("EclBackgroundStudy finished.");
124 B2INFO("nEntries = " << m_iEntry);
125
126 // write
127 m_ff->cd();
128 m_tree1->Write();
129 m_tree2->Write();
130 // close the tree
131 m_ff->Close();
132 }
133
135 {
136 B2INFO("EclBackgroundStudy: output file name = " << m_filename);
137 }
138
139} // end Belle2 namespace
Class to store simulated hits which equate to average of ECLSImHit on crystals input for digitization...
Definition ECLHit.h:25
ClassECLSimHit - Geant4 simulated hit for the ECL.
Definition ECLSimHit.h:29
StoreArray< ECLSimHit > m_ECLSimHits
ECL simHits.
std::vector< double > m_FlightTime
Vector of flight times.
std::vector< int > m_CellId
Vector of CellId.
StoreArray< ECLHit > m_ECLHits
ECL hits.
std::vector< int > m_Pdg
Vector of PDG codes.
std::vector< int > m_TcId
Vector of TcId.
std::vector< double > m_Edep
Vector of deposited energies.
std::string m_filename
Output file name.
std::vector< double > m_Hadronedep
Vector of hadronic deposited energies.
TrgEclMapping * m_TCMap
TRGECL mapping.
std::vector< double > m_TimeAve
Vector of average times.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Module()
Constructor.
Definition Module.cc:30
A class of TC Mapping.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void terminate() override
Termination action.
virtual void beginRun() override
Called when entering a new run.
void printModuleParams() const
Prints module parameters.
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.