FairShip
Loading...
Searching...
No Matches
test_fixedtarget_cascade_weight.cxx
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
// The weight of cascade (charm/beauty) events must reproduce the p.o.t. of the
6
// cascade file: every event reads the two heavy-flavour hadrons of a pair.
7
8
#include <TFile.h>
9
#include <TH1F.h>
10
#include <TNtuple.h>
11
12
#include <cmath>
13
#include <cstdio>
14
#include <iostream>
15
16
#include "
FixedTargetGenerator.h
"
17
18
int
main
() {
19
const
char
* fname =
"test_cascade_weight.root"
;
20
const
int
nPairs = 100;
// all primary, i.e. depth 1
21
const
double
chicc = 2.0e-3;
// pairs per p.o.t.
22
{
23
TFile f(fname,
"RECREATE"
);
24
TNtuple nt(
"pythia6"
,
"synthetic cascade"
,
25
"id:px:py:pz:E:M:mid:mpx:mpy:mpz:mE:mM:k"
);
26
TH1F h(
"2"
,
"nr signal per cascade depth"
, 50, 0.5, 50.5);
27
for
(
int
i = 0; i < nPairs; ++i) {
28
for
(
int
sign : {1, -1}) {
29
nt.Fill(421 * sign, 0., 0., 50., 50.035, 1.865, 2212, 0., 0., 400.,
30
400.0011, 0.938272, 1);
31
h.Fill(1);
32
}
33
}
34
f.Write();
35
}
36
FixedTargetGenerator
gen;
37
gen.
SetChicc
(chicc);
38
// process the whole file: nPairs events of one pair each
39
if
(!gen.
InitForCharmOrBeauty
(fname, nPairs, 5e13, 0)) {
40
std::cerr <<
"InitForCharmOrBeauty failed"
<< std::endl;
41
return
1;
42
}
43
const
double
expected = nPairs / chicc;
// p.o.t. of the whole file
44
const
double
pot = gen.
GetPotForCharm
();
45
std::remove(fname);
46
if
(std::abs(pot / expected - 1.) > 1e-9) {
47
std::cerr <<
"p.o.t. equivalent "
<< pot <<
", expected "
<< expected
48
<< std::endl;
49
return
1;
50
}
51
return
0;
52
}
FixedTargetGenerator.h
FixedTargetGenerator
Definition
FixedTargetGenerator.h:23
FixedTargetGenerator::InitForCharmOrBeauty
Bool_t InitForCharmOrBeauty(const TString &fInName, Int_t nev, Double_t npots=5E13, Int_t nStart=0)
Definition
FixedTargetGenerator.cxx:101
FixedTargetGenerator::GetPotForCharm
Double_t GetPotForCharm()
Definition
FixedTargetGenerator.h:108
FixedTargetGenerator::SetChicc
void SetChicc(Double_t x)
Definition
FixedTargetGenerator.h:90
main
int main()
Definition
test_fixedtarget_cascade_weight.cxx:18
tests
test_fixedtarget_cascade_weight.cxx
Generated by
Doxygen
1.15.0