ROOT
master
Reference Guide
Loading...
Searching...
No Matches
evegen_001_MonteCarlo.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_evegen
3
/// Macro to compare masses in ROOT data base to the values from
4
/// [pdg](http://pdg.lbl.gov/2009/mcdata/mass_width_2008.mc).
5
///
6
/// The ROOT values are read in by TDatabasePDG from `$ROOTSYS/etc/pdg_table.txt`
7
///
8
/// \macro_output
9
/// \macro_code
10
///
11
/// \author Christian.Klein-Boesing
12
13
#include "
TDatabasePDG.h
"
14
#include "
TParticlePDG.h
"
15
16
17
void
evegen_001_MonteCarlo
()
18
{
19
TString
massWidthFile
=
gSystem
->
UnixPathName
(
__FILE__
);
20
massWidthFile
.ReplaceAll(
"evegen_001_MonteCarlo.C"
,
"mass_width_2008.mc.txt"
);
21
22
FILE
* file =
fopen
(
massWidthFile
.Data(),
"r"
);
23
24
if
(!file){
25
Printf
(
"Could not open PDG particle file %s"
,
massWidthFile
.Data());
26
return
;
27
}
28
29
char
c
[200];
30
char
cempty
;
31
Int_t
pdg
[4];
32
Float_t
mass,
err1
,
err2
, err;
33
Int_t
ndiff
= 0;
34
35
while
(
fgets
(
c
, 200, file)) {
36
if
(
c
[0] !=
'*'
&&
c
[0] !=
'W'
) {
37
//printf("%s",c);
38
sscanf
(&
c
[1],
"%8d"
, &
pdg
[0]);
39
40
// check emptiness
41
pdg
[1] = 0;
42
for
(
int
i = 0;i<8;i++){
43
sscanf
(&
c
[9+i],
"%c"
,&
cempty
);
44
if
(
cempty
!=
' '
)
sscanf
(&
c
[9],
"%8d"
,&
pdg
[1]);
45
}
46
47
pdg
[2] = 0;
48
for
(
int
i = 0;i<8;i++){
49
sscanf
(&
c
[17+i],
"%c"
,&
cempty
);
50
if
(
cempty
!=
' '
)
sscanf
(&
c
[17],
"%8d"
,&
pdg
[2]);
51
}
52
53
pdg
[3] = 0;
54
for
(
int
i = 0;i<8;i++){
55
sscanf
(&
c
[25+i],
"%c"
,&
cempty
);
56
if
(
cempty
!=
' '
)
sscanf
(&
c
[25],
"%8d"
,&
pdg
[3]);
57
}
58
59
sscanf
(&
c
[35],
"%14f"
,&mass);
60
sscanf
(&
c
[50],
"%8f"
,&
err1
);
61
sscanf
(&
c
[50],
"%8f"
,&
err2
);
62
err =
TMath::Max
((
Double_t
)
err1
,(
Double_t
)-1.*
err2
);
63
for
(
int
ipdg
= 0;
ipdg
< 4;
ipdg
++){
64
if
(
pdg
[
ipdg
]==0)
continue
;
65
TParticlePDG
*
partRoot
=
TDatabasePDG::Instance
()->GetParticle(
pdg
[
ipdg
]);
66
if
(
partRoot
){
67
Float_t
massRoot
=
partRoot
->Mass();
68
Float_t
deltaM
=
TMath::Abs
(
massRoot
- mass);
69
// if(deltaM > err){
70
if
(mass != 0.0 &&
deltaM
/mass>1E-05){
71
ndiff
++;
72
Printf
(
"%10s %8d pdg mass %E pdg err %E root Mass %E >> deltaM %E = %3.3f%%"
,
partRoot
->GetName(),
pdg
[
ipdg
],mass,err,
massRoot
,
deltaM
,100.*
deltaM
/mass);
73
}
74
}
75
}
76
}
77
}
// while
78
fclose
(file);
79
if
(
ndiff
== 0)
Printf
(
"Crongratulations !! All particles in ROOT and PDG have identical masses"
);
80
81
}
c
#define c(i)
Definition
RSha256.hxx:101
Int_t
int Int_t
Definition
RtypesCore.h:45
Float_t
float Float_t
Definition
RtypesCore.h:57
Double_t
double Double_t
Definition
RtypesCore.h:59
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TDatabasePDG.h
TParticlePDG.h
Printf
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition
TString.cxx:2503
gSystem
R__EXTERN TSystem * gSystem
Definition
TSystem.h:561
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TDatabasePDG::Instance
static TDatabasePDG * Instance()
static function
Definition
TDatabasePDG.cxx:106
TParticlePDG
Description of the static properties of a particle.
Definition
TParticlePDG.h:19
TString
Basic string class.
Definition
TString.h:139
TSystem::UnixPathName
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition
TSystem.cxx:1063
TMath::Max
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition
TMathBase.h:250
TMath::Abs
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition
TMathBase.h:123
tutorials
evegen
evegen_001_MonteCarlo.C
ROOT master - Reference Guide Generated on Fri Jan 24 2025 04:37:19 (GVA Time) using Doxygen 1.10.0