Logo ROOT  
Reference Guide
CompareMasses.C File Reference

Detailed Description

Macro to compare masses in ROOT data base to the values from pdg pdg.

The ROOT values are read in by TDatabasePDG from $ROOTSYS/etc/pdg_table.txt

a_00 10111 pdg mass 1.474000E+00 pdg err 1.900000E-02 root Mass 9.835000E-01 >> deltaM 4.905000E-01 = 33.277%
a_0+ 10211 pdg mass 1.474000E+00 pdg err 1.900000E-02 root Mass 9.835000E-01 >> deltaM 4.905000E-01 = 33.277%
#include "TDatabasePDG.h"
#include "TParticlePDG.h"
void CompareMasses()
{
TString massWidthFile = gSystem->UnixPathName(__FILE__);
massWidthFile.ReplaceAll("CompareMasses.C","mass_width_2008.mc.txt");
FILE* file = fopen(massWidthFile.Data(),"r");
if (!file){
Printf("Could not open PDG particle file %s", massWidthFile.Data());
return;
}
char c[200];
char cempty;
Int_t pdg[4];
Float_t mass, err1, err2, err;
Int_t ndiff = 0;
while (fgets(c, 200, file)) {
if (c[0] != '*' && c[0] !='W') {
//printf("%s",c);
sscanf(&c[1], "%8d", &pdg[0]);
// check emptiness
pdg[1] = 0;
for(int i = 0;i<8;i++){
sscanf(&c[9+i],"%c",&cempty);
if(cempty != ' ')sscanf(&c[9],"%8d",&pdg[1]);
}
pdg[2] = 0;
for(int i = 0;i<8;i++){
sscanf(&c[17+i],"%c",&cempty);
if(cempty != ' ')sscanf(&c[17],"%8d",&pdg[2]);
}
pdg[3] = 0;
for(int i = 0;i<8;i++){
sscanf(&c[25+i],"%c",&cempty);
if(cempty != ' ')sscanf(&c[25],"%8d",&pdg[3]);
}
sscanf(&c[35],"%14f",&mass);
sscanf(&c[50],"%8f",&err1);
sscanf(&c[50],"%8f",&err2);
err = TMath::Max((Double_t)err1,(Double_t)-1.*err2);
for(int ipdg = 0;ipdg < 4;ipdg++){
if(pdg[ipdg]==0)continue;
TParticlePDG *partRoot = TDatabasePDG::Instance()->GetParticle(pdg[ipdg]);
if(partRoot){
Float_t massRoot = partRoot->Mass();
Float_t deltaM = TMath::Abs(massRoot - mass);
// if(deltaM > err){
if (mass != 0.0 && deltaM/mass>1E-05){
ndiff++;
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);
}
}
}
}
}// while
fclose(file);
if (ndiff == 0) Printf("Crongratulations !! All particles in ROOT and PDG have identical masses");
}
Author
Christian.Klein-Boesing

Definition in file CompareMasses.C.

c
#define c(i)
Definition: RSha256.hxx:119
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TString::Data
const char * Data() const
Definition: TString.h:369
TDatabasePDG::Instance
static TDatabasePDG * Instance()
static function
Definition: TDatabasePDG.cxx:106
TParticlePDG
Definition: TParticlePDG.h:19
Float_t
float Float_t
Definition: RtypesCore.h:57
Int_t
int Int_t
Definition: RtypesCore.h:45
TParticlePDG.h
TDatabasePDG::GetParticle
TParticlePDG * GetParticle(Int_t pdgCode) const
Get a pointer to the particle object according to the MC code number.
Definition: TDatabasePDG.cxx:232
TMath::Abs
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
TParticlePDG::Mass
Double_t Mass() const
Definition: TParticlePDG.h:67
TString
Definition: TString.h:136
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
TDatabasePDG.h
Printf
void Printf(const char *fmt,...)
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
Double_t
double Double_t
Definition: RtypesCore.h:59
TSystem::UnixPathName
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition: TSystem.cxx:1061
file
Definition: file.py:1
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
TMath::E
constexpr Double_t E()
Base of natural log:
Definition: TMath.h:102