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
43
45 {
46 // Print set parameters
48
49 // create/open the file
50 m_ff = new TFile(m_filename.c_str(), "RECREATE");
51
52 // create trees
53 m_tree1 = new TTree("tree1", "ECLHits data");
54 m_tree2 = new TTree("tree2", "ECLSimHits data");
55
56 // create branches
57 m_tree1->Branch("CellId", &m_CellId);
58 m_tree1->Branch("TcId", &m_TcId);
59 m_tree1->Branch("Edep", &m_Edep);
60 m_tree1->Branch("TimeAve", &m_TimeAve);
61
62 m_tree2->Branch("CellId", &m_CellId);
63 m_tree2->Branch("TcId", &m_TcId);
64 m_tree2->Branch("Pdg", &m_Pdg);
65 m_tree2->Branch("FlightTime", &m_FlightTime);
66 m_tree2->Branch("Edep", &m_Edep);
67 m_tree2->Branch("Hadronedep", &m_Hadronedep);
68
69 m_TCMap = new TrgEclMapping();
70 }
71
73 {
74 // Print run number
75 B2INFO("EclBackgroundStudy: Processing. ");
76 }
77
79 {
80 m_CellId.clear();
81 m_TcId.clear();
82 m_Pdg.clear();
83 m_Edep.clear();
84 m_TimeAve.clear();
85 m_FlightTime.clear();
86 m_Hadronedep.clear();
87
88 // loop over ECLHits
89 for (const ECLHit& hit : m_ECLHits) {
90 m_CellId.push_back(hit.getCellId());
91 m_TcId.push_back(m_TCMap->getTCIdFromXtalId(hit.getCellId()));
92 m_Edep.push_back(hit.getEnergyDep());
93 m_TimeAve.push_back(hit.getTimeAve());
94 }
95 // fill the tree
96 m_tree1->Fill();
97
98 m_CellId.clear();
99 m_TcId.clear();
100 m_Pdg.clear();
101 m_Edep.clear();
102 m_TimeAve.clear();
103 m_FlightTime.clear();
104 m_Hadronedep.clear();
105
106 // loop over ECLSimHits
107 for (const ECLSimHit& hit : m_ECLSimHits) {
108 m_CellId.push_back(hit.getCellId());
109 m_TcId.push_back(m_TCMap->getTCIdFromXtalId(hit.getCellId()));
110 m_Pdg.push_back(hit.getPDGCode());
111 m_FlightTime.push_back(hit.getFlightTime());
112 m_Edep.push_back(hit.getEnergyDep());
113 m_Hadronedep.push_back(hit.getHadronEnergyDep());
114 }
115 // fill the tree
116 m_tree2->Fill();
117
118 // increase the entry counter
119 m_iEntry++;
120 }
121
125
127 {
128 // CPU time end
129
130 // Announce
131 B2INFO("EclBackgroundStudy finished.");
132 B2INFO("nEntries = " << m_iEntry);
133
134 // write
135 m_ff->cd();
136 m_tree1->Write();
137 m_tree2->Write();
138 // close the tree
139 m_ff->Close();
140 }
141
143 {
144 B2INFO("EclBackgroundStudy: output file name = " << m_filename);
145 }
146
147} // 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 event()
Event processor.
virtual void initialize()
Initialize the Module.
virtual void beginRun()
Called when entering a new run.
virtual void terminate()
Termination action.
virtual void endRun()
End-of-run action.
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.