FairShip
Loading...
Searching...
No Matches
CosmicsGenerator.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5// -------------------------------------------------------------------
6// ----- CosmicsGenerator source file for SHiP -----
7// ----- Version as of 15.09.15 by Martin Franke -----
8// ----- mailto: mfranke(at)physik.hu-berlin.de -----
9// -------------------------------------------------------------------
10
11#ifndef SHIPGEN_COSMICSGENERATOR_H_
12#define SHIPGEN_COSMICSGENERATOR_H_
13
14#include "FairLogger.h"
15#include "Generator.h"
16#include "TF1.h"
17#include "TH1.h"
18#include "TMath.h"
19#include "TROOT.h"
20#include "TRandom3.h"
21
22class FairPrimaryGenerator;
23
24class Co3Rng {
25 public:
27 rng = new TRandom3(gRandom->GetSeed());
28 fTheta = new TF1("f2", "cos(x)*cos(x)", 0, TMath::Pi() / 2);
29 fTheta->SetNpx(10);
31 new TF1("f4", "1400*TMath::Power(x,-2.7)*(1/(1+x/115)+0.054/(1+x/850))",
32 100, 1000); // momentum above 100GeV
33 };
34 virtual ~Co3Rng() {
35 delete rng;
36 delete fTheta;
37 delete fSpectrumH;
38 };
39 double Uniform(Float_t min, Float_t max) { return rng->Uniform(min, max); };
41 TF1* fTheta;
42 double fSpectrumL(double theta, double minE,
43 Bool_t generateP); // momentum below 100GeV
44 private:
45 TRandom3* rng;
46};
47
49 public:
51 CosmicsGenerator() = default;
52 ~CosmicsGenerator() override {
53 delete fRandomEngine;
54 std::cout << nInside << " events have been generated." << std::endl;
55 std::cout << "There is a total of " << nInside << "/" << nTest
56 << " muons that passed close enough to the detector."
57 << std::endl;
58 std::cout << "Including the given weight this corresponds to ";
59 std::cout << weighttest / FluxIntegral / xdist / zdist * 10000
60 << " spills (1 spill = " << xdist * zdist * FluxIntegral / 10000;
61 std::cout << " real cosmic muons = " << n_EVENTS << " simulated events)."
62 << std::endl;
63 };
64
67 Bool_t ReadEvent(FairPrimaryGenerator*) override;
68 // virtual Bool_t Init(); //!
69 virtual Bool_t Init(Bool_t largeMom);
70 Bool_t Init(const char* inFile) override { return Init(inFile, 0); };
71
72 Bool_t Init(const char* inFile, int startEvent) override {
73 LOG(warning) << "Init with files not implemented for CosmicsGenerator.";
74 return false;
75 };
76
77 double z0, yBox, xBox, zBox, xdist, zdist, minE;
79
80 private:
81 Co3Rng* fRandomEngine = nullptr;
82
83 protected:
86 Bool_t high;
87
88 void GenerateDynamics();
89 Bool_t DetectorBox();
90};
91
92#endif // SHIPGEN_COSMICSGENERATOR_H_ /* !PNDCoGENERATOR_H */
double fSpectrumL(double theta, double minE, Bool_t generateP)
TF1 * fSpectrumH
TRandom3 * rng
double Uniform(Float_t min, Float_t max)
virtual ~Co3Rng()
Bool_t Init(const char *inFile, int startEvent) override
~CosmicsGenerator() override
Bool_t Init(const char *inFile) override
Bool_t ReadEvent(FairPrimaryGenerator *) override
CosmicsGenerator()=default
virtual Bool_t Init(Bool_t largeMom)
virtual Bool_t Init(const char *, int)=0