10#include <klm/bklm/modules/bklmSimHistogrammer/BKLMSimHistogrammerModule.h>
13#include <framework/dataobjects/EventMetaData.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/datastore/StoreObjPtr.h>
35 m_hSimHitPerChannelLayer(nullptr),
37 m_hSimHitPhiRPC(nullptr),
38 m_bgSourcePerLayer(nullptr),
39 m_bgSourcePerLayer2D(nullptr),
40 m_bgSourceVsPhi(nullptr),
41 m_bgSourceVsTheta(nullptr),
43 m_bgSource2D(nullptr),
44 m_hSimHitPhiScinti(nullptr),
45 m_hSimHitThetaRPC(nullptr),
46 m_hSimHitThetaScinti(nullptr),
47 m_hSimHit_layer(nullptr),
48 m_hSimHit_layer2D(nullptr),
49 m_hSimHitThetaPhiRPC(nullptr),
50 m_hSimHitThetaPhiScinti(nullptr),
57 addParam(
"filename",
m_filename,
"Output root filename", std::string(
"bg_output.root"));
76 m_hEvt =
new TH1D(
"hEvts",
"hEvts", 10001, -1, 10000);
78 m_hSimHitPhiRPC =
new TH1D(
"simhitPhiRPC",
"simHitPhiRPC", 100, -1 * TMath::Pi(), 1 * TMath::Pi());
79 m_hSimHitPhiScinti =
new TH1D(
"simhitPhiScinti",
"simHitPhiScinti", 100, -1 * TMath::Pi(), 1 * TMath::Pi());
80 m_hSimHitThetaRPC =
new TH1D(
"simhitThetaRPC",
"simHitThetaRPC", 100, 0, 1 * TMath::Pi());
81 m_hSimHitThetaScinti =
new TH1D(
"simhitThetaScinti",
"simHitThetaScinti", 100, 0, 1 * TMath::Pi());
86 m_bgSourcePerLayer =
new TH2D(
"bgSourcPerLayer",
"bgSourcePerLayer", 21, 0, 20, 16, 0, 15);
87 m_bgSourcePerLayer2D =
new TH2D(
"bgSourcPerLayer2D",
"bgSourcePerLayer2D", 21, 0, 20, 16, 0, 15);
88 m_bgSourceVsPhi =
new TH2D(
"bgSourceVsPhi",
"bgSourceVsPhi", 100, -1 * TMath::Pi(), TMath::Pi(), 21, 0, 20);
89 m_bgSourceVsTheta =
new TH2D(
"bgSourceVsTheta",
"bgSourceVsTheta", 100, 0, TMath::Pi(), 21, 0, 20);
91 m_bgSource =
new TH1D(
"bgSource",
"bgSource", 21, 0, 20);
92 m_bgSource2D =
new TH1D(
"bgSource2D",
"bgSource2D", 21, 0, 20);
103 B2INFO(
"BKLMSimHistogrammer: Experiment " << evtMetaData->getExperiment() <<
" run " << evtMetaData->getRun());
112 int nSimHit =
simHits.getEntries();
124 int n2DHits =
hits2D.getEntries();
125 int n1DHits =
hits1D.getEntries();
126 std::cout <<
"we have " << nSimHit <<
" sim hits " << n1DHits <<
" 1D hits " << n2DHits <<
" 2D hits " << std::endl;
131 for (
int i = 0; i <
hits1D.getEntries(); i++) {
132 std::cout <<
"looking at 1DHit " << i << std::endl;
135 for (
const auto& bklmDigit : bklmDigits) {
137 for (
const auto& simHit : relatedSimHits) {
143 std::cout <<
"scaledTag: " << scaledTag << std::endl;
149 int channel =
hits1D[i]->getSection() * 840 +
hits1D[i]->getSector() * 105 +
hits1D[i]->isPhiReadout() * 1680 +
154 std::cout <<
"filling layer with tag: " << scaledTag <<
" and layer " <<
hits1D[i]->getLayer() << std::endl;
157 for (
int i = 0; i <
hits2D.getEntries(); i++) {
161 ROOT::Math::XYZVector gHitPos =
hits2D[i]->getPosition();
163 for (
const auto& hit1d : related1DHits) {
165 for (
const auto& bklmDigit : bklmDigits) {
167 for (
const auto& simHit : relatedSimHits) {
189 for (
int i = 0; i < n2DHits; i++) {
191 ROOT::Math::XYZVector gHitPos = hit2D->
getPosition();
192 if (hit2D->
inRPC()) {
200 for (
int h = 0; h < nSimHit; ++h) {
204 if (bklmMCParticles.
size() > 0) {
205 std::cout <<
"found MC particle!" << std::endl;
207 std::cout <<
"got " << bklmMCParticlesTo.
size() <<
" as relation to " << std::endl;
Store one reconstructed BKLM 1D hit as a ROOT object.
TH1D * m_hSimHitPhiScinti
histogram for sim hit phi
float m_realTime
time this simulation corresponds to
TH1D * m_bgSource
bg source of 1D hits
TH2D * m_bgSourcePerLayer2D
bg source of 2D hits
TH1I * m_hSimHit_layer2D
histogram for the layers of 2D hits
BKLMSimHistogrammerModule()
Constructor.
void initialize() override
Initialize at start of job.
TH1D * m_bgSource2D
bg source of 2D hits
void event() override
Digitize one event and write hits, digis, and relations into DataStore.
TH1D * m_hSimHitThetaRPC
histogram for sim hit theta
void endRun() override
Do any needed actions at the end of a simulation run.
void terminate() override
Terminate at the end of job.
TH2D * m_hSimHitPerChannelLayer
hits per channel
TH1D * m_hSimHitThetaScinti
histogram for sim hit theta scint
StoreArray< KLMSimHit > simHits
KLMSimHit StoreArray.
TH2D * m_bgSourceVsPhi
bg source of 2D hits vs phi
TH1D * m_hEvt
keep track of events
StoreArray< BKLMHit1d > hits1D
hits1D StoreArray
TH1I * m_hSimHit_layer
histogram for the layers of 1D hits
void beginRun() override
Do any needed actions at the start of a simulation run.
TH1D * m_hSimHitPhiRPC
histogram for sim hit phi
StoreArray< KLMHit2d > hits2D
hits2D StoreArray
TFile * m_file
Digitize hit(s) in one scintillator strip with pulse-shape fit.
~BKLMSimHistogrammerModule()
Destructor.
TH2D * m_bgSourceVsTheta
bg source of 2D hits vs theta
float m_weight
weight for each event (inverse of the realTime)
std::string m_filename
filename for the root file
TH2D * m_bgSourcePerLayer
bg source of 1D hits
KLM digit (class representing a digitized hit in RPCs or scintillators).
bool inRPC() const
Determine whether this 2D hit is in RPC or scintillator.
ROOT::Math::XYZVector getPosition() const
Get hit global position.
A Class to store the Monte Carlo particle information.
void setDescription(const std::string &description)
Sets the description of the module.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
virtual unsigned short getBackgroundTag() const
Get background tag.
Type-safe access to single objects in the data store.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.