10#include <top/modules/TOPBackground/TOPBackgroundModule.h>
13#include <top/dataobjects/TOPBarHit.h>
14#include <top/dataobjects/TOPDigit.h>
15#include <top/dataobjects/TOPSimHit.h>
16#include <top/geometry/TOPGeometryPar.h>
18#include <mdst/dataobjects/MCParticle.h>
19#include <simulation/dataobjects/BeamBackHit.h>
22#include <framework/datastore/DataStore.h>
23#include <framework/datastore/StoreArray.h>
26#include <framework/logging/Logger.h>
27#include <framework/gearbox/Const.h>
35#include <Math/VectorUtil.h>
38#include <geometry/Materials.h>
39#include <G4Material.hh>
101 setDescription(
"A module to analyze beam background simulations regarding TOP");
106 string(
"Backgound.root"));
108 "Real time in micro seconds that corresponds to simulated data", 5.);
124 originpe =
new TTree(
"originpe",
"tree2");
133 peflux =
new TH1F(
"Photoelectron flux",
"Photoelectron flux", 33, -11.25, 360);
134 nflux =
new TH1F(
"Neutron flux",
"Neutron flux", 33, -11.25, 360);
135 rdose =
new TH1F(
"Radiation dose",
"Radiation dose", 33, -11.25, 360);
136 zdist =
new TH1F(
"Photoelectron origin",
"Photoelectron origin", 200, -400, 400);
137 genergy =
new TH1F(
"Energy distribution of photons",
"Energy distribution of photons", 150, 0, 5);
138 genergy2 =
new TH1F(
"Energy distribution of gammas",
"Energy distribution of gammas", 500, 0, 5);
140 zdistg =
new TH1F(
"Photoelectron flux z",
"Photoelectron flux Z projection", 800, -400, 400);
141 originpt =
new TH1F(
"P_t of origin electron",
"P_t of origin electron", 300, 0.06, 0.14);
143 nflux_bar =
new TH2F(
"Neutron flux on bar",
"Neutron flux on bar", 32, -114.8, 211.5, 16, -0, 360);
144 gflux_bar =
new TH2F(
"Gamma flux on bar",
"Gamma flux on bar MHz/cm^{2}", 32, -114.8, 211.5, 16, -0, 360);
145 cflux_bar =
new TH2F(
"Charged flux on bar",
"Charged flux on bar MHz/cm^{2}", 32, -114.8, 211.5, 16, -0, 360);
147 norigin =
new TH1F(
"neutron(BAR) origin",
"neutron(BAR) origin", 200, -400, 400);
148 gorigin =
new TH1F(
"gamma(BAR) origin",
"gamma(BAR) origin", 200, -400, 400);
149 corigin =
new TH1F(
"charged(BAR) origin",
"charged(BAR) origin", 200, -400, 400);
151 nprim =
new TH1F(
"neutron(BAR) primary",
"neutron(BAR) primary", 200, -400, 400);
152 gprim =
new TH1F(
"gamma(BAR) primary",
"gamma(BAR) primary", 200, -400, 400);
153 cprim =
new TH1F(
"charged(BAR) primary",
"charged(BAR) primary", 200, -400, 400);
168 double S2 = geo.getHVBoardWidth() * geo.getHVBoardLength();
169 double V1 = S1 * geo.getFrontBoardThickness();
170 double V2 = S2 * geo.getHVBoardThickness();
172 if (!material1) B2FATAL(
"Material '" << geo.getFrontBoardMaterial() <<
"' not found");
174 if (!material2) B2FATAL(
"Material '" << geo.getHVBoardMaterial() <<
"' not found");
175 double density1 = material1->GetDensity() / CLHEP::kg * CLHEP::cm * CLHEP::cm * CLHEP::cm;
176 double density2 = material2->GetDensity() / CLHEP::kg * CLHEP::cm * CLHEP::cm * CLHEP::cm;
179 PCBmass = V1 * density1 + V2 * density2;
182 evtoJ = 1.60217653 * 1e-10;
183 mtoc = 1.97530864197531;
198 B2INFO(
"TOPBackground: Processing:");
210 for (
int i = 0; i < nHits; i++) {
216 const TOPSimHit* simHit = DataStore::getRelated<TOPSimHit>(aDigit);
217 if (!simHit)
continue;
225 const MCParticle* particle = DataStore::getRelated<MCParticle>(simHit);
242 ROOT::Math::XYZVector momentum = mother->
getMomentum();
243 if (
m_BkgType.at(
m_BkgType.size() - 3) ==
'L') ROOT::Math::VectorUtil::RotateY(momentum, 0.0415);
244 else if (
m_BkgType.at(
m_BkgType.size() - 3) ==
'H') ROOT::Math::VectorUtil::RotateY(momentum, -0.0415);
245 double px = momentum.X();
246 double py = momentum.Y();
247 double pt =
sqrt(px * px + py * py);
259 for (
int iHit = 0; iHit < nHits; ++iHit) {
262 if (subdet != 5)
continue;
265 double phi = ROOT::Math::VectorUtil::Phi_0_2pi(pos.Phi()) * TMath::RadToDeg();
266 int barID = int (phi / 22.5 + 0.5);
286 for (
int iHit = 0; iHit < nHits; ++iHit) {
289 int PDG = toptrk->
getPDG();
327 gStyle->SetOptStat(
"");
328 gStyle->SetOptFit(1111);
330 gStyle->SetCanvasColor(-1);
331 gStyle->SetPadColor(-1);
332 gStyle->SetFrameFillColor(-1);
333 gStyle->SetHistFillColor(-1);
334 gStyle->SetTitleFillColor(-1);
335 gStyle->SetFillColor(-1);
336 gStyle->SetFillStyle(4000);
337 gStyle->SetStatStyle(0);
338 gStyle->SetTitleStyle(0);
339 gStyle->SetCanvasBorderSize(0);
340 gStyle->SetCanvasBorderMode(0);
341 gStyle->SetPadBorderMode(0);
343 gStyle->SetFrameBorderSize(0);
344 gStyle->SetLegendBorderSize(0);
345 gStyle->SetStatBorderSize(0);
346 gStyle->SetTitleBorderSize(0);
351 TCanvas* c1 =
new TCanvas(
"c1",
"", 1920, 1200);
353 double x1 = histo->GetBinLowEdge(1);
354 double nb = histo->GetNbinsX();
355 double bin = histo->GetBinWidth(1);
356 double x2 = x1 + bin * nb;
358 double max = histo->GetBinContent(histo->GetMaximumBin());
361 histo->GetYaxis()->SetRangeUser(0, tresh * 1.1);
364 TLine* line =
new TLine(x1, tresh, x2, tresh);
365 line->SetLineColor(1);
366 line->SetLineWidth(3);
367 line->SetLineStyle(2);
370 histo->SetFillColor(2);
371 histo->SetLineColor(1);
373 gPad->SetTopMargin(0.08);
374 gPad->SetBottomMargin(0.15);
377 histo->GetXaxis()->SetLabelSize(0.06);
378 histo->GetYaxis()->SetLabelSize(0.06);
379 histo->GetXaxis()->SetTitleSize(0.06);
380 histo->GetYaxis()->SetTitleSize(0.06);
381 histo->GetXaxis()->SetTitle(xtit);
382 histo->GetYaxis()->SetTitle(ytit);
383 histo->GetXaxis()->SetTitleOffset(0.9);
384 histo->GetYaxis()->SetTitleOffset(0.7);
388 TLegend* leg =
new TLegend(0.75, 0.95, 0.90, 1.00);
389 leg->AddEntry(histo,
m_BkgType.c_str(),
"pf");
402 B2INFO(
"TOPBackground: Finished:");
435 B2INFO(
"TOPBackground finished");
Class BeamBackHit - Stores hits from beam backgound simulation.
double getNeutronWeight() const
get the effective neutron weigth
double getEnergyDeposit() const
Get particle energy deposit in sensitive volume.
int getPDG() const
Get the lund code of the particle that hit the sensitive area.
double getTrackLength() const
the length of the track in the volume
ROOT::Math::XYZVector getPosition() const
Get global position of the particle hit.
int getSubDet() const
Det the index of subdetector in which hit occured.
int getPDGCode() const
PDG code.
static const ParticleType neutron
neutron particle
static const ParticleType photon
photon particle
A Class to store the Monte Carlo particle information.
ROOT::Math::XYZVector getVertex() const
Return production vertex position, shorthand for getProductionVertex().
ROOT::Math::XYZVector getMomentum() const
Return momentum.
void setDescription(const std::string &description)
Sets the description of the module.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
TH1F * gprim
gamma primery
TH1F * rdose
radiation dose
double origingamma_z
points from origin_zx and _zy graphs: z
TTree * originpe
tree for saving originpe points
TH1F * norigin
nutron origin
TGraph * prim_zx
grapch zx
TH1F * originpt
pt of electrons
TFile * m_rootFile
root file for saving histograms
TH2F * cflux_bar
charged flux on bar
TH1F * corigin
charged origin
double origingamma_y
points from origin_zx and _zy graphs: y
double originpe_x
points for origin of mother of photoelectrons: x
TH1F * zdistg
z distribution of the photoelectron flux
TGraph * module_occupancy
graph zy
TH1F * gorigin
gamma origin
TGraph * origin_zx
grapch zx
TH1F * cprim
charged primary
TH1F * nprim
neutron primery
TH2F * gflux_bar
gamma flux on bar
TH1F * genergy2
energy of gamma that hits the bar
TH2F * nflux_bar
neutron flux on bar
double origingamma_x
points from origin_zx and _zy graphs: x
double originpe_z
points for origin of mother of photoelectrons: z (=zdist)
std::string m_BkgType
Type of background.
TGraph * origin_zy
graph zy
std::string m_OutputFileName
Output filename.
double originpe_y
points for origin of mother of photoelectrons: y
TTree * origingamma
tree for saving origingamma points
double m_TimeOfSimulation
Time of the simulation of the input file.
TH1F * zdist
z distribution of primaries
TH1F * genergy
energy of gamma that hits the bar
Class to store track parameters of incoming MC particles relation to MCParticle filled in top/simulat...
ROOT::Math::XYZPoint getPosition() const
Returns impact point.
int getModuleID() const
Returns module ID.
ROOT::Math::XYZPoint getProductionPoint() const
Returns production point.
int getPDG() const
Returns PDG code of particle.
ROOT::Math::XYZVector getMomentum() const
Returns impact momentum.
Class to store TOP digitized hits (output of TOPDigitizer or raw data unpacker) relations to TOPSimHi...
int getModuleID() const
Returns module ID.
double getFrontBoardWidth() const
Returns front board width.
const TOPGeoFrontEnd & getFrontEnd() const
Returns front-end.
Class to store simulated hits of Cherenkov photons on PMT's input for digitization module (TOPDigitiz...
double getEnergy() const
Returns photon energy.
int getPmtID() const
Returns PMT ID.
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
static G4Material * get(const std::string &name)
Find given material.
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.
double sqrt(double a)
sqrt for double
MCParticle * getMother() const
Returns a pointer to the mother particle.
TOPBackgroundModule()
Constructor.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
void myprint(TH1F *histo, const char *path, const char *xtit, const char *ytit, double tresh)
Print histogram 1D, helper function.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
virtual ~TOPBackgroundModule()
Destructor.
virtual void beginRun() override
Called when entering a new run.
void printModuleParams() const
Prints module parameters.
Abstract base class for different kinds of events.