Functions | Variables
common_convert.C File Reference
#include <iostream>
#include <iomanip>
#include <cassert>
#include <map>
#include <cstring>
#include <fstream>
#include <stdlib.h>
#include <float.h>
#include "TFile.h"
#include "TTree.h"
#include "TRandom3.h"
#include "TH1D.h"
#include "TString.h"
#include "tree/dk2nu.h"
#include "tree/dkmeta.h"
#include "tree/readWeightLocations.h"
#include "tree/calcLocationWeights.h"

Go to the source code of this file.

Functions

bool histCompare (double a, double b, string s)
 
void ConvertInit (std::string locfilename="$(DK2NU)/etc/locations.txt")
 
void ConvertBookNtuple (std::string ofname="test_dk2nu.root")
 
void ConvertFinish ()
 
int ConvertGeantToPdg (int geant_code, std::string tag="?")
 
int Convert5xToPdg (int old_ntype)
 
TString ConvertFlukaInteractionCodeToString (int interactionCode)
 
TString ConvertVolumeCodeToString (int volumeCode, string volumeFilePath)
 
size_t find_loc_index (string match)
 
string construct_outfilename (string infilename)
 
double estimate_pots (int highest_potnum)
 
bool isCloseEnough (double a, double b, double &difference, double &fdiff, int &nmsg, int mxmsg, string s)
 

Variables

TRandom3 * rndm = 0
 
bsim::Dk2Nudk2nu = 0
 
bsim::DkMetadkmeta = 0
 
TFile * treeFile = 0
 
TTree * dk2nuTree = 0
 
TTree * dkmetaTree = 0
 
int myjob = 0
 
int pots = 0
 
double frac_diff_tolerance = 5.0e-4
 
double obs_frac_diff_max = 0
 
const int kPdgNuE = 12
 
const int kPdgAntiNuE = -12
 
const int kPdgNuMu = 14
 
const int kPdgAntiNuMu = -14
 
const int kPdgNuTau = 16
 
const int kPdgAntiNuTau = -16
 
const int kPdgElectron = 11
 
const int kPdgPositron = -11
 
const int kPdgMuon = 13
 
const int kPdgAntiMuon = -13
 
const int kPdgTau = 15
 
const int kPdgAntiTau = -15
 
const int kPdgUQuark = 2
 
const int kPdgAntiUQuark = -2
 
const int kPdgDQuark = 1
 
const int kPdgAntiDQuark = -1
 
const int kPdgSQuark = 3
 
const int kPdgAntiSQuark = -3
 
const int kPdgCQuark = 4
 
const int kPdgAntiCQuark = -4
 
const int kPdgBQuark = 5
 
const int kPdgAntiBQuark = -5
 
const int kPdgTQuark = 6
 
const int kPdgAntiTQuark = -6
 
const int kPdgDDDiquarkS1 = 1103
 
const int kPdgUDDiquarkS0 = 2101
 
const int kPdgUDDiquarkS1 = 2103
 
const int kPdgUUDiquarkS1 = 2203
 
const int kPdgSDDiquarkS0 = 3101
 
const int kPdgSDDiquarkS1 = 3103
 
const int kPdgSUDiquarkS0 = 3201
 
const int kPdgSUDiquarkS1 = 3203
 
const int kPdgSSDiquarkS1 = 3303
 
const int kPdgProton = 2212
 
const int kPdgAntiProton = -2212
 
const int kPdgNeutron = 2112
 
const int kPdgAntiNeutron = -2112
 
const int kPdgLambda = 3122
 
const int kPdgAntiLambda = -3122
 
const int kPdgSigmaP = 3222
 
const int kPdgSigma0 = 3212
 
const int kPdgSigmaM = 3112
 
const int kPdgAntiSigmaP = -3222
 
const int kPdgAntiSigma0 = -3212
 
const int kPdgAntiSigmaM = -3112
 
const int kPdgXi0 = 3322
 
const int kPdgXiM = 3312
 
const int kPdgAntiXi0 = -3322
 
const int kPdgAntiXiP = -3312
 
const int kPdgOmegaM = 3334
 
const int kPdgAntiOmegaP = -3334
 
const int kPdgLambdaPc = 4122
 
const int kPdgSigma0c = 4112
 
const int kPdgSigmaPc = 4212
 
const int kPdgSigmaPPc = 4222
 
const int kPdgP33m1232_DeltaM = 1114
 
const int kPdgP33m1232_Delta0 = 2114
 
const int kPdgP33m1232_DeltaP = 2214
 
const int kPdgP33m1232_DeltaPP = 2224
 
const int kPdgS11m1535_N0 = 22112
 
const int kPdgS11m1535_NP = 22212
 
const int kPdgD13m1520_N0 = 1214
 
const int kPdgD13m1520_NP = 2124
 
const int kPdgS11m1650_N0 = 32112
 
const int kPdgS11m1650_NP = 32212
 
const int kPdgD13m1700_N0 = 21214
 
const int kPdgD13m1700_NP = 22124
 
const int kPdgD15m1675_N0 = 2116
 
const int kPdgD15m1675_NP = 2216
 
const int kPdgS31m1620_DeltaM = 1112
 
const int kPdgS31m1620_Delta0 = 1212
 
const int kPdgS31m1620_DeltaP = 2122
 
const int kPdgS31m1620_DeltaPP = 2222
 
const int kPdgD33m1700_DeltaM = 11114
 
const int kPdgD33m1700_Delta0 = 12114
 
const int kPdgD33m1700_DeltaP = 12214
 
const int kPdgD33m1700_DeltaPP = 12224
 
const int kPdgP11m1440_N0 = 12112
 
const int kPdgP11m1440_NP = 12212
 
const int kPdgP13m1720_N0 = 31214
 
const int kPdgP13m1720_NP = 32124
 
const int kPdgF15m1680_N0 = 12116
 
const int kPdgF15m1680_NP = 12216
 
const int kPdgP31m1910_DeltaM = 21112
 
const int kPdgP31m1910_Delta0 = 21212
 
const int kPdgP31m1910_DeltaP = 22122
 
const int kPdgP31m1910_DeltaPP = 22222
 
const int kPdgP33m1920_DeltaM = 21114
 
const int kPdgP33m1920_Delta0 = 22114
 
const int kPdgP33m1920_DeltaP = 22214
 
const int kPdgP33m1920_DeltaPP = 22224
 
const int kPdgF35m1905_DeltaM = 1116
 
const int kPdgF35m1905_Delta0 = 1216
 
const int kPdgF35m1905_DeltaP = 2126
 
const int kPdgF35m1905_DeltaPP = 2226
 
const int kPdgF37m1950_DeltaM = 1118
 
const int kPdgF37m1950_Delta0 = 2118
 
const int kPdgF37m1950_DeltaP = 2218
 
const int kPdgF37m1950_DeltaPP = 2228
 
const int kPdgP11m1710_N0 = 42112
 
const int kPdgP11m1710_NP = 42212
 
const int kPdgPiP = 211
 
const int kPdgPiM = -211
 
const int kPdgPi0 = 111
 
const int kPdgEta = 221
 
const int kPdgEtaPrm = 331
 
const int kPdgEtac = 441
 
const int kPdgEtab = 551
 
const int kPdgRhoP = 213
 
const int kPdgRhoM = -213
 
const int kPdgRho0 = 113
 
const int kPdgomega = 223
 
const int kPdgPhi = 333
 
const int kPdgJpsi = 443
 
const int kPdgY = 553
 
const int kPdgKP = 321
 
const int kPdgKM = -321
 
const int kPdgK0 = 311
 
const int kPdgAntiK0 = -311
 
const int kPdgK0L = 130
 
const int kPdgK0S = 310
 
const int kPdgDP = 411
 
const int kPdgDM = -411
 
const int kPdgD0 = 421
 
const int kPdgAntiD0 = -421
 
const int kPdgDPs = 431
 
const int kPdgDMs = -431
 
const int kPdgGluon = 21
 
const int kPdgGamma = 22
 
const int kPdgZ0 = 23
 
const int kPdgWP = 24
 
const int kPdgWM = -24
 
const int kPdgTgtFreeP = 1000010010
 
const int kPdgTgtFreeN = 1000000010
 
const int kPdgTgtDeuterium = 1000010020
 
const int kPdgTgtC12 = 1000060120
 
const int kPdgTgtO16 = 1000080160
 
const int kPdgTgtFe56 = 1000260560
 
const int kPdgHadronicSyst = 2000000001
 
const int kPdgHadronicBlob = 2000000002
 
const int kPdgBindino = 2000000101
 
const int kPdgCoulobtron = 2000000102
 
const int kPdgClusterNN = 2000000200
 
const int kPdgClusterNP = 2000000201
 
const int kPdgClusterPP = 2000000202
 
const int kPdgCluster = 91
 
const int kPdgString = 92
 
const int kPdgIndep = 93
 

Function Documentation

string construct_outfilename ( string  infilename)

Definition at line 491 of file common_convert.C.

References stan::math::dot().

492 {
493  string ofname = infilename;
494  size_t dot = ofname.find(".root");
495  ofname.insert(dot,".dk2nu");
496  size_t slash = ofname.find_last_of("/");
497  if ( slash != std::string::npos ) {
498  ofname.erase(0,slash+1);
499  }
500  return ofname;
501 }
double dot(const std::vector< double > &x, const std::vector< double > &y)
Definition: dot.hpp:10
int Convert5xToPdg ( int  old_ntype)

Definition at line 363 of file common_convert.C.

References ana::assert(), om::cerr, and allTimeWatchdog::endl.

364 {
365  // NuMI ntuples have an odd neutrino "geant" convention
366  switch ( old_ntype ) {
367  case 56: return 14; break; // kPdgNuMu; break;
368  case 55: return -14; break; // kPdgAntiNuMu; break;
369  case 53: return 12; break; // kPdgNuE; break;
370  case 52: return -12; break; // kPdgAntiNuE; break;
371  default:
372  std::cerr << "Convert5xToPdg saw ntype " << old_ntype
373  << " -- unknown " << std::endl;
374  assert(0);
375  }
376  return 0;
377 }
OStream cerr
Definition: OStream.cxx:7
assert(nhit_max >=nhit_nbins)
void ConvertBookNtuple ( std::string  ofname = "test_dk2nu.root")

equivalent to NumiAnalysis::book() in g4numi


Definition at line 74 of file common_convert.C.

References dk2nuTree, dkmetaTree, and treeFile.

75 {
76  ///-----------------------------------------------------------------------
77  ///
78  /// equivalent to NumiAnalysis::book() in g4numi
79  ///
80  ///-----------------------------------------------------------------------
81 
82  // create file, book tree, set branch address to created object
83  treeFile = new TFile(ofname.c_str(),"RECREATE");
84 
85  dk2nuTree = new TTree("dk2nuTree","neutrino ntuple");
86  dk2nuTree->Branch("dk2nu","bsim::Dk2Nu",&dk2nu,32000,99);
87 
88  dkmetaTree = new TTree("dkmetaTree","neutrino ntuple metadata");
89  dkmetaTree->Branch("dkmeta","bsim::DkMeta",&dkmeta,32000,99);
90 }
TTree * dk2nuTree
TTree * dkmetaTree
bsim::Dk2Nu * dk2nu
TFile * treeFile
bsim::DkMeta * dkmeta
void ConvertFinish ( )

equivalent to NumiAnalysis::finish() in g4numi


fill the rest of the metadata (locations filled above)

Definition at line 92 of file common_convert.C.

References dk2nuTree, dkmetaTree, histCompare(), bsim::DkMeta::job, myjob, pots, bsim::DkMeta::pots, and treeFile.

93 {
94  ///-----------------------------------------------------------------------
95  ///
96  /// equivalent to NumiAnalysis::finish() in g4numi
97  ///
98  ///-----------------------------------------------------------------------
99 
100  /// fill the rest of the metadata (locations filled above)
101  //no! would clear location info // dkmeta->clear();
102  dkmeta->job = myjob; // needs to match the value in each dk2nu entry
103  dkmeta->pots = pots; // ntuple represents this many protons-on-target
104  //leave to user// dkmeta->beamsim = "common_convert.C";
105  //leave to user// dkmeta->physics = "bogus";
106 
107  //dkmeta->vintnames.push_back("mytemp_42");
108  //dkmeta->vintnames.push_back("mytemp_ipot");
109  // push entry out to meta-data tree
110  dkmetaTree->Fill();
111 
112  // finish and clean-up
113  treeFile->cd();
114  dk2nuTree->Write();
115  dkmetaTree->Write();
116 
117  treeFile->cd(); // be here so any booked histograms get created inside output file
118  treeFile->mkdir("zzz_diff_hists");
119  treeFile->cd("zzz_diff_hists");
120  histCompare(0,0,"WriteHist");
121 
122  treeFile->Close();
123 
124  delete treeFile; treeFile=0;
125  dk2nuTree=0;
126  dkmetaTree=0;
127 }
TTree * dk2nuTree
int pots
TTree * dkmetaTree
int myjob
Int_t job
identifying job # (keep files distinct)
Definition: dkmeta.h:86
Double_t pots
protons-on-target
Definition: dkmeta.h:87
TFile * treeFile
bool histCompare(double a, double b, string s)
bsim::DkMeta * dkmeta
TString ConvertFlukaInteractionCodeToString ( int  interactionCode)

Definition at line 381 of file common_convert.C.

382 {
383 
384  TString interactionString = "null";
385 
386  if(interactionCode == 100) interactionString = "elastic";
387  if(interactionCode == 101) interactionString = "inelastic";
388  if(interactionCode == 102) interactionString = "decaySecondaries";
389  if(interactionCode == 103) interactionString = "deltaRay";
390  if(interactionCode == 104) interactionString = "pairProduction";
391  if(interactionCode == 105) interactionString = "bremsstrahlung";
392  if(interactionCode == 110) interactionString = "decayProducts";
393  if(interactionCode == 208) interactionString = "bremsstrahlung";
394  if(interactionCode == 210) interactionString = "moller";
395  if(interactionCode == 212) interactionString = "bhabha";
396  if(interactionCode == 214) interactionString = "inFlightAnnihilation";
397  if(interactionCode == 215) interactionString = "annihilationAtRest";
398  if(interactionCode == 217) interactionString = "pairProduction";
399  if(interactionCode == 219) interactionString = "comptonScattering";
400  if(interactionCode == 221) interactionString = "photoelectric";
401  if(interactionCode == 225) interactionString = "rayleighScattering";
402  if(interactionCode == 300) interactionString = "interactionSecndaries";
403  if(interactionCode == 400) interactionString = "deltaRay";
404 
405  return interactionString;
406 }
int ConvertGeantToPdg ( int  geant_code,
std::string  tag = "?" 
)

Definition at line 295 of file common_convert.C.

References om::cerr, allTimeWatchdog::endl, kPdgAntiD0, kPdgAntiLambda, kPdgAntiMuon, kPdgAntiNeutron, kPdgAntiOmegaP, kPdgAntiProton, kPdgAntiSigma0, kPdgAntiSigmaM, kPdgAntiSigmaP, kPdgAntiTau, kPdgAntiXi0, kPdgAntiXiP, kPdgD0, kPdgDM, kPdgDMs, kPdgDP, kPdgDPs, kPdgElectron, kPdgEta, kPdgGamma, kPdgK0L, kPdgK0S, kPdgKM, kPdgKP, kPdgLambda, kPdgMuon, kPdgNeutron, kPdgOmegaM, kPdgPi0, kPdgPiM, kPdgPiP, kPdgPositron, kPdgProton, kPdgSigma0, kPdgSigmaM, kPdgSigmaP, kPdgTau, kPdgWM, kPdgWP, kPdgXi0, kPdgXiM, kPdgZ0, and getGoodRuns4SAM::tag.

296 {
297  if (geant_code == 3) return kPdgElectron; // 11 / e-
298  if (geant_code == 2) return kPdgPositron; // -11 / e+
299  if (geant_code == 6) return kPdgMuon; // 13 / mu-
300  if (geant_code == 5) return kPdgAntiMuon; // -13 / mu+
301  if (geant_code == 34) return kPdgTau; // 15 / tau-
302  if (geant_code == 33) return kPdgAntiTau; // -15 / tau+
303  if (geant_code == 8) return kPdgPiP; // 211 / pi+
304  if (geant_code == 9) return kPdgPiM; // -211 / pi-
305  if (geant_code == 7) return kPdgPi0; // 111 / pi0
306  if (geant_code == 17) return kPdgEta; // 221 / eta
307  if (geant_code == 11) return kPdgKP; // 321 / K+
308  if (geant_code == 12) return kPdgKM; // -321 / K-
309  if (geant_code == 10) return kPdgK0L; // 130 / K0_{long}
310  if (geant_code == 16) return kPdgK0S; // 310 / K0_{short}
311  if (geant_code == 35) return kPdgDP; // 411 / D+
312  if (geant_code == 36) return kPdgDM; // -411 / D-
313  if (geant_code == 37) return kPdgD0; // 421 / D0
314  if (geant_code == 38) return kPdgAntiD0; // -421 / \bar{D0}
315  if (geant_code == 39) return kPdgDPs; // 431 / D+_{s}
316  if (geant_code == 40) return kPdgDMs; // -431 / D-_{s}
317  if (geant_code == 1) return kPdgGamma; // 22 / photon
318  if (geant_code == 44) return kPdgZ0; // 23 / Z
319  if (geant_code == 42) return kPdgWP; // 24 / W+
320  if (geant_code == 43) return kPdgWM; // -24 / W-
321  if (geant_code == 14) return kPdgProton; // 2212
322  if (geant_code == 15) return kPdgAntiProton; // -2212
323  if (geant_code == 13) return kPdgNeutron; // 2112
324  if (geant_code == 25) return kPdgAntiNeutron; // -2112
325  if (geant_code == 18) return kPdgLambda; // 3122 / Lambda
326  if (geant_code == 26) return kPdgAntiLambda; // -3122 / \bar{Lambda}
327  if (geant_code == 19) return kPdgSigmaP; // 3222 / Sigma+
328  if (geant_code == 20) return kPdgSigma0; // 3212 / Sigma0
329  if (geant_code == 21) return kPdgSigmaM; // 3112 / Sigma-
330  if (geant_code == 29) return kPdgAntiSigmaP; // -3112 / \bar{Sigma+}
331  if (geant_code == 28) return kPdgAntiSigma0; // -3212 / \bar{Sigma0}
332  if (geant_code == 27) return kPdgAntiSigmaM; // -3112 / \bar{Sigma-}
333  if (geant_code == 22) return kPdgXi0; // 3322 / Xi0
334  if (geant_code == 23) return kPdgXiM; // 3312 / Xi-
335  if (geant_code == 30) return kPdgAntiXi0; // -3322 / \bar{Xi0}
336  if (geant_code == 31) return kPdgAntiXiP; // -3312 / \bar{Xi+}
337  if (geant_code == 24) return kPdgOmegaM; // 3334 / Omega-
338  if (geant_code == 32) return kPdgAntiOmegaP; // -3334 / \bar{Omega+}
339 
340  // some rare Geant3 codes that don't really need definitions in PDGCodes.h
341  const int kPdgDeuteron = 1000010020; // pdg::IonPdgCode(2,1);
342  const int kPdgTritium = 1000010030; // pdg::IonPdgCode(3,1);
343  const int kPdgAlpha = 1000020040; // pdg::IonPdgCode(4,2);
344  const int kPdgHe3 = 1000020030; // pdg::IonPdgCode(3,2);
345  if (geant_code == 45) return kPdgDeuteron;
346  if (geant_code == 46) return kPdgTritium;
347  if (geant_code == 47) return kPdgAlpha;
348  if (geant_code == 49) return kPdgHe3;
349 
350  // NuMI ntuples have an odd neutrino "geant" convention
351  if (geant_code == 56) return 14; // nu_mu
352  if (geant_code == 55) return -14; // nu_mu_bar
353  if (geant_code == 53) return 12; // nu_e
354  if (geant_code == 52) return -12; // nu_e_bar
355 
356  if (geant_code != 0 )
357  std::cerr << "## Can not convert geant code: " << geant_code
358  << " to PDG (" << tag << ")" << std::endl;
359  return 0;
360 }
const int kPdgAntiD0
const int kPdgWP
const int kPdgProton
const int kPdgDM
const int kPdgMuon
const int kPdgPi0
const int kPdgAntiLambda
const int kPdgAntiXi0
const int kPdgDMs
const int kPdgDP
const int kPdgOmegaM
const int kPdgK0L
OStream cerr
Definition: OStream.cxx:7
const int kPdgSigmaP
const int kPdgAntiTau
const int kPdgAntiXiP
const int kPdgAntiSigma0
const int kPdgPiM
const int kPdgSigmaM
const int kPdgK0S
const int kPdgZ0
const int kPdgSigma0
const int kPdgPositron
const int kPdgAntiNeutron
const int kPdgAntiSigmaM
const int kPdgTau
const int kPdgEta
const int kPdgAntiMuon
const int kPdgAntiProton
const int kPdgWM
const int kPdgGamma
const int kPdgElectron
const int kPdgKM
const int kPdgXi0
const int kPdgNeutron
const int kPdgDPs
const int kPdgKP
const int kPdgXiM
const int kPdgLambda
const int kPdgAntiSigmaP
const int kPdgPiP
const int kPdgAntiOmegaP
const int kPdgD0
void ConvertInit ( std::string  locfilename = "$(DK2NU)/etc/locations.txt")

equivalent to NumiAnalysis::NumiAnalysis() in g4numi


Definition at line 52 of file common_convert.C.

References bsim::printWeightLocations(), bsim::readWeightLocations(), and rndm.

53 {
54  ///-----------------------------------------------------------------------
55  ///
56  /// equivalent to NumiAnalysis::NumiAnalysis() in g4numi
57  ///
58  ///-----------------------------------------------------------------------
59 
60  // create the objects used for writing entries
61  dk2nu = new bsim::Dk2Nu;
62  dkmeta = new bsim::DkMeta;
63 
64  rndm = new TRandom3();
65 
66  // read the text file for locations, fill the dkmeta object
67  /*bsim::*/readWeightLocations(locfilename,dkmeta);
68 
69  // print out what we have for locations
70  /*bsim::*/printWeightLocations(dkmeta);
71 
72 }
void readWeightLocations(std::string locfilename, std::vector< bsim::Location > &locations)
bsim::Dk2Nu * dk2nu
TRandom3 * rndm
void printWeightLocations(std::vector< bsim::Location > &locations)
print the locations
bsim::DkMeta * dkmeta
TString ConvertVolumeCodeToString ( int  volumeCode,
string  volumeFilePath 
)

Definition at line 410 of file common_convert.C.

References om::cout, allTimeWatchdog::endl, and string.

410  {
411 
412  TString FlukaName;
413  TString GeantName;
414 
415  // Open the Fluka Volumes file
416  ifstream volumeFile;
417  volumeFile.open(volumeFilePath.c_str());
418 
419  if(volumeCode==-2222){
420  FlukaName = "not-defined";
421  return FlukaName;
422  }
423 
424  // Make sure the file opened properly
425  if(!volumeFile.good()) {
426  std::cout << "Error opening Volumes file." << std::endl;
427  FlukaName="ErrorOpeningVolumeFile";
428  return FlukaName;
429  }
430 
431  // Variables for file reading
432  const int maxChar = 1024; // Max number of characters to read from a single line from the input file
433  char volumeLine[maxChar]; // Array to hold a single line from the input file
434  bool volumeFound = false; // Flag whether the requested input volume has been found
435 
436  // Loop over lines from the input file until the volume is found or the end of the file is reached
437  while(!(volumeFound || volumeFile.eof())) {
438  // Get the next line
439  if(volumeFile.getline(volumeLine, maxChar).fail()) {
440  std::cout << "Error accessing the next line. " << std::endl
441  << "It may just be the end of the file, "
442  << "and the EOF bit may not have been set as expected." << std::endl;
443  break;
444  }
445 
446  // Make a std::string from the char array
447  // This must be done BEFORE tokenizing the character array,
448  // as strtok "destroys" the array as it goes
449  std::string stringLine(volumeLine);
450 
451  // Get the first set of contiguous characters that skips leading and contains no spaces
452  // token is the number that labels the volume
453  char* token = strtok(volumeLine, " ");
454  double number = atof(token);
455 
456 
457  if(number==volumeCode) {
458  // If the input volume number is in the current line, set the boolean flag to terminate the while loop
459  volumeFound = true;
460  GeantName = strtok(NULL, " "); // this is Geant volume name
461  FlukaName = strtok(NULL, " "); // this is Fluka volume name
462  }
463  } // end of loop until volume number is found or end of the location file is reached
464 
465  // If the volume was not found, warn the user and exit
466  if(!volumeFound) {
467  std::cout << "Could not find the following volume " <<volumeCode << "." << std::endl;
468  FlukaName="FlukaVolumeNameNotFound";
469  return FlukaName;
470  }
471 
472  //If everything went smoothly, return the FlukaName of the volume
473  return FlukaName;
474 }
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::token< char, normalized_string > token
Definition: Database.h:156
enum BeamMode string
double estimate_pots ( int  highest_potnum)

Definition at line 505 of file common_convert.C.

References nquant.

506 {
507  // looks like low counts are due to "evtno" not including
508  // protons that miss the actual target (hit baffle, etc)
509  // this will vary with beam conditions parameters
510  // so we should round way up, those generating flugg files
511  // aren't going to quantize less than 1000
512  // though 500 would probably be okay, 100 would not.
513  // also can't use _last_ potnum because muons decays don't
514  // have theirs set
515  const Int_t nquant = 1000; // 500; // 100
516  const Double_t rquant = nquant;
517 
518  Int_t estimate = (TMath::FloorNint((highest_potnum-1)/rquant)+1)*nquant;
519  return estimate;
520 }
const int nquant
Definition: getContProf.C:25
size_t find_loc_index ( string  match)

Definition at line 478 of file common_convert.C.

References MECModelEnuComparisons::i, and bsim::DkMeta::location.

479 {
480  // find the index in the array of locations
481  for ( size_t i=0; i < dkmeta->location.size(); ++i ) {
482  //cout << "looking for \"" << match << "\" vs \""
483  // << dkmeta->nameloc[i] << "\"" << endl;
484  if ( dkmeta->location[i].name == match ) return i;
485  }
486  //cout << "failed to find match" << endl;
487  return -1;
488 }
std::vector< bsim::Location > location
locations
Definition: dkmeta.h:119
bsim::DkMeta * dkmeta
bool histCompare ( double  a,
double  b,
string  s 
)

static bool first = true;

Definition at line 561 of file common_convert.C.

References close(), release_diff::diff, util::frac(), isCloseEnough(), and nbins.

562 {
563  // booking histograms should end up in the output file
564 
565  static map<std::string,int> nmsg;
566  double diff, frac;
567  const int mxmsg = 10, nbins = 100;
568  static map<std::string,TH1D*> diffmap;
569  static map<std::string,TH1D*> fracmap;
570  /// static bool first = true;
571  //if ( first ) {
572  // first = false;
573  // TH1::SetDefaultSumw2(true);
574  //}
575  if ( s == "WriteHist" ) {
576  map<std::string,TH1D*>::iterator itr;
577  for ( itr=diffmap.begin(); itr != diffmap.end(); ++itr ) (*itr).second->Write();
578  for ( itr=fracmap.begin(); itr != fracmap.end(); ++itr ) (*itr).second->Write();
579  return true;
580  }
581 
582  bool close = isCloseEnough(a,b,diff,frac,nmsg[s],mxmsg,s);
583  TH1D* diffh = diffmap[s];
584  TH1D* frach = fracmap[s];
585  if ( ! diffh ) {
586  string sdh = "difference " + s;
587  diffh = new TH1D(sdh.c_str(),sdh.c_str(),nbins,1,-1); // autoadjust limits by reversed values
588  diffh->Sumw2();
589  diffmap[s] = diffh;
590  }
591  if ( ! frach ) {
592  string sfh = "frac diff " + s;
593  frach = new TH1D(sfh.c_str(),sfh.c_str(),nbins,1,-1); // autoadjust limits by reversed values
594  frach->Sumw2();
595  fracmap[s] = frach;
596  }
597  diffh->Fill(diff);
598  frach->Fill(frac);
599 
600  return close;
601 }
const XML_Char * s
Definition: expat.h:262
const int nbins
Definition: cellShifts.C:15
const double a
double frac(double x)
Fractional part.
bool isCloseEnough(double a, double b, double &difference, double &fdiff, int &nmsg, int mxmsg, string s)
const hit & b
Definition: hits.cxx:21
procfile close()
bool isCloseEnough ( double  a,
double  b,
double &  difference,
double &  fdiff,
int nmsg,
int  mxmsg,
string  s 
)

Definition at line 523 of file common_convert.C.

References a, b, om::cout, delta, e, allTimeWatchdog::endl, epsilon, stan::math::fabs(), frac_diff_tolerance, stan::math::ldexp(), obs_frac_diff_max, and sum.

525 {
526  // For float or double, need to determine equality while
527  // accounting for some degree of imprecision
528  // The method applied here is adopted from Theodore C. Belding's
529  // fcmp implementation of Donald Knuth's algorithm.
530  double value[2] = {a,b};
531  //double epsilon = 10.*FLT_EPSILON;
532  double epsilon = 10.*FLT_EPSILON;
533  // if ( isDouble[0] || isDouble[1] ) epsilon = DBL_EPSILON;
534  int exponent;
535  frexp(fabs(value[0]) > fabs(value[1]) ? value[0] : value[1], &exponent);
536  double delta = ldexp(epsilon,exponent);
537  //double
538  difference = value[0] - value[1];
539  if ( difference > delta || difference < -delta ) {
540  double sum = a+b;
541  if ( TMath::Abs(sum) < 1.0e-30 ) sum = 1.0e-30; // protect divide-by-0
542  //double
543  fdiff = TMath::Abs(2.0*(a-b)/(a+b));
544  if ( fdiff > obs_frac_diff_max ) obs_frac_diff_max = fdiff;
545  if ( fdiff < frac_diff_tolerance ) return true; // we'll allow it anyway
546  ++nmsg;
547  if ( nmsg <= mxmsg ) {
548  cout << "## \"" << s << "\" " << a << " " << b
549  //<< " delta " << delta
550  << " diff " << difference
551  << " fdiff " << fdiff << endl;
552  //cout << "## ndecay (dkproc) " << dk2nu->decay.ndecay << endl;
553  if ( nmsg == mxmsg )
554  cout << "## last message for tag \"" << s << "\"" << endl;
555  }
556  return false; // nope
557  }
558  return true; // these are close
559 }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
double delta
Definition: runWimpSim.h:98
T ldexp(const T &a, int b)
Definition: ldexp.hpp:19
const XML_Char * s
Definition: expat.h:262
double frac_diff_tolerance
const XML_Char int const XML_Char * value
Definition: expat.h:331
const double a
double obs_frac_diff_max
OStream cout
Definition: OStream.cxx:6
double epsilon
const hit & b
Definition: hits.cxx:21
Double_t sum
Definition: plot.C:31
Float_t e
Definition: plot.C:35

Variable Documentation

bsim::Dk2Nu* dk2nu = 0

Definition at line 37 of file common_convert.C.

TTree* dk2nuTree = 0

Definition at line 40 of file common_convert.C.

bsim::DkMeta* dkmeta = 0

Definition at line 38 of file common_convert.C.

TTree* dkmetaTree = 0

Definition at line 41 of file common_convert.C.

double frac_diff_tolerance = 5.0e-4

Definition at line 45 of file common_convert.C.

const int kPdgAntiBQuark = -5

Definition at line 153 of file common_convert.C.

const int kPdgAntiCQuark = -4

Definition at line 151 of file common_convert.C.

const int kPdgAntiD0 = -421

Definition at line 260 of file common_convert.C.

const int kPdgAntiDQuark = -1

Definition at line 147 of file common_convert.C.

const int kPdgAntiK0 = -311

Definition at line 254 of file common_convert.C.

const int kPdgAntiLambda = -3122

Definition at line 172 of file common_convert.C.

const int kPdgAntiMuon = -13

Definition at line 140 of file common_convert.C.

const int kPdgAntiNeutron = -2112

Definition at line 170 of file common_convert.C.

const int kPdgAntiNuE = -12

Definition at line 131 of file common_convert.C.

const int kPdgAntiNuMu = -14

Definition at line 133 of file common_convert.C.

const int kPdgAntiNuTau = -16

Definition at line 135 of file common_convert.C.

const int kPdgAntiOmegaP = -3334

Definition at line 184 of file common_convert.C.

const int kPdgAntiProton = -2212

Definition at line 168 of file common_convert.C.

const int kPdgAntiSigma0 = -3212

Definition at line 177 of file common_convert.C.

const int kPdgAntiSigmaM = -3112

Definition at line 178 of file common_convert.C.

const int kPdgAntiSigmaP = -3222

Definition at line 176 of file common_convert.C.

const int kPdgAntiSQuark = -3

Definition at line 149 of file common_convert.C.

const int kPdgAntiTau = -15

Definition at line 142 of file common_convert.C.

const int kPdgAntiTQuark = -6

Definition at line 155 of file common_convert.C.

const int kPdgAntiUQuark = -2

Definition at line 145 of file common_convert.C.

const int kPdgAntiXi0 = -3322

Definition at line 181 of file common_convert.C.

const int kPdgAntiXiP = -3312

Definition at line 182 of file common_convert.C.

const int kPdgBindino = 2000000101

Definition at line 283 of file common_convert.C.

const int kPdgBQuark = 5

Definition at line 152 of file common_convert.C.

const int kPdgCluster = 91

Definition at line 290 of file common_convert.C.

const int kPdgClusterNN = 2000000200

Definition at line 285 of file common_convert.C.

const int kPdgClusterNP = 2000000201

Definition at line 286 of file common_convert.C.

const int kPdgClusterPP = 2000000202

Definition at line 287 of file common_convert.C.

const int kPdgCoulobtron = 2000000102

Definition at line 284 of file common_convert.C.

const int kPdgCQuark = 4

Definition at line 150 of file common_convert.C.

const int kPdgD0 = 421

Definition at line 259 of file common_convert.C.

const int kPdgD13m1520_N0 = 1214

Definition at line 196 of file common_convert.C.

const int kPdgD13m1520_NP = 2124

Definition at line 197 of file common_convert.C.

const int kPdgD13m1700_N0 = 21214

Definition at line 200 of file common_convert.C.

const int kPdgD13m1700_NP = 22124

Definition at line 201 of file common_convert.C.

const int kPdgD15m1675_N0 = 2116

Definition at line 202 of file common_convert.C.

const int kPdgD15m1675_NP = 2216

Definition at line 203 of file common_convert.C.

const int kPdgD33m1700_Delta0 = 12114

Definition at line 209 of file common_convert.C.

const int kPdgD33m1700_DeltaM = 11114

Definition at line 208 of file common_convert.C.

const int kPdgD33m1700_DeltaP = 12214

Definition at line 210 of file common_convert.C.

const int kPdgD33m1700_DeltaPP = 12224

Definition at line 211 of file common_convert.C.

const int kPdgDDDiquarkS1 = 1103

Definition at line 157 of file common_convert.C.

const int kPdgDM = -411

Definition at line 258 of file common_convert.C.

const int kPdgDMs = -431

Definition at line 262 of file common_convert.C.

const int kPdgDP = 411

Definition at line 257 of file common_convert.C.

const int kPdgDPs = 431

Definition at line 261 of file common_convert.C.

const int kPdgDQuark = 1

Definition at line 146 of file common_convert.C.

const int kPdgElectron = 11

Definition at line 137 of file common_convert.C.

const int kPdgEta = 221

Definition at line 240 of file common_convert.C.

const int kPdgEtab = 551

Definition at line 243 of file common_convert.C.

const int kPdgEtac = 441

Definition at line 242 of file common_convert.C.

const int kPdgEtaPrm = 331

Definition at line 241 of file common_convert.C.

const int kPdgF15m1680_N0 = 12116

Definition at line 216 of file common_convert.C.

const int kPdgF15m1680_NP = 12216

Definition at line 217 of file common_convert.C.

const int kPdgF35m1905_Delta0 = 1216

Definition at line 227 of file common_convert.C.

const int kPdgF35m1905_DeltaM = 1116

Definition at line 226 of file common_convert.C.

const int kPdgF35m1905_DeltaP = 2126

Definition at line 228 of file common_convert.C.

const int kPdgF35m1905_DeltaPP = 2226

Definition at line 229 of file common_convert.C.

const int kPdgF37m1950_Delta0 = 2118

Definition at line 231 of file common_convert.C.

const int kPdgF37m1950_DeltaM = 1118

Definition at line 230 of file common_convert.C.

const int kPdgF37m1950_DeltaP = 2218

Definition at line 232 of file common_convert.C.

const int kPdgF37m1950_DeltaPP = 2228

Definition at line 233 of file common_convert.C.

const int kPdgGamma = 22

Definition at line 265 of file common_convert.C.

const int kPdgGluon = 21

Definition at line 264 of file common_convert.C.

const int kPdgHadronicBlob = 2000000002

Definition at line 282 of file common_convert.C.

const int kPdgHadronicSyst = 2000000001

Definition at line 281 of file common_convert.C.

const int kPdgIndep = 93

Definition at line 292 of file common_convert.C.

const int kPdgJpsi = 443

Definition at line 249 of file common_convert.C.

const int kPdgK0 = 311

Definition at line 253 of file common_convert.C.

const int kPdgK0L = 130

Definition at line 255 of file common_convert.C.

const int kPdgK0S = 310

Definition at line 256 of file common_convert.C.

const int kPdgKM = -321

Definition at line 252 of file common_convert.C.

const int kPdgKP = 321

Definition at line 251 of file common_convert.C.

const int kPdgLambda = 3122

Definition at line 171 of file common_convert.C.

const int kPdgLambdaPc = 4122

Definition at line 185 of file common_convert.C.

const int kPdgMuon = 13

Definition at line 139 of file common_convert.C.

const int kPdgNeutron = 2112

Definition at line 169 of file common_convert.C.

const int kPdgNuE = 12

Definition at line 130 of file common_convert.C.

const int kPdgNuMu = 14

Definition at line 132 of file common_convert.C.

const int kPdgNuTau = 16

Definition at line 134 of file common_convert.C.

const int kPdgomega = 223

Definition at line 247 of file common_convert.C.

const int kPdgOmegaM = 3334

Definition at line 183 of file common_convert.C.

const int kPdgP11m1440_N0 = 12112

Definition at line 212 of file common_convert.C.

const int kPdgP11m1440_NP = 12212

Definition at line 213 of file common_convert.C.

const int kPdgP11m1710_N0 = 42112

Definition at line 234 of file common_convert.C.

const int kPdgP11m1710_NP = 42212

Definition at line 235 of file common_convert.C.

const int kPdgP13m1720_N0 = 31214

Definition at line 214 of file common_convert.C.

const int kPdgP13m1720_NP = 32124

Definition at line 215 of file common_convert.C.

const int kPdgP31m1910_Delta0 = 21212

Definition at line 219 of file common_convert.C.

const int kPdgP31m1910_DeltaM = 21112

Definition at line 218 of file common_convert.C.

const int kPdgP31m1910_DeltaP = 22122

Definition at line 220 of file common_convert.C.

const int kPdgP31m1910_DeltaPP = 22222

Definition at line 221 of file common_convert.C.

const int kPdgP33m1232_Delta0 = 2114

Definition at line 191 of file common_convert.C.

const int kPdgP33m1232_DeltaM = 1114

Definition at line 190 of file common_convert.C.

const int kPdgP33m1232_DeltaP = 2214

Definition at line 192 of file common_convert.C.

const int kPdgP33m1232_DeltaPP = 2224

Definition at line 193 of file common_convert.C.

const int kPdgP33m1920_Delta0 = 22114

Definition at line 223 of file common_convert.C.

const int kPdgP33m1920_DeltaM = 21114

Definition at line 222 of file common_convert.C.

const int kPdgP33m1920_DeltaP = 22214

Definition at line 224 of file common_convert.C.

const int kPdgP33m1920_DeltaPP = 22224

Definition at line 225 of file common_convert.C.

const int kPdgPhi = 333

Definition at line 248 of file common_convert.C.

const int kPdgPi0 = 111

Definition at line 239 of file common_convert.C.

const int kPdgPiM = -211

Definition at line 238 of file common_convert.C.

const int kPdgPiP = 211

Definition at line 237 of file common_convert.C.

const int kPdgPositron = -11

Definition at line 138 of file common_convert.C.

const int kPdgProton = 2212

Definition at line 167 of file common_convert.C.

const int kPdgRho0 = 113

Definition at line 246 of file common_convert.C.

const int kPdgRhoM = -213

Definition at line 245 of file common_convert.C.

const int kPdgRhoP = 213

Definition at line 244 of file common_convert.C.

const int kPdgS11m1535_N0 = 22112

Definition at line 194 of file common_convert.C.

const int kPdgS11m1535_NP = 22212

Definition at line 195 of file common_convert.C.

const int kPdgS11m1650_N0 = 32112

Definition at line 198 of file common_convert.C.

const int kPdgS11m1650_NP = 32212

Definition at line 199 of file common_convert.C.

const int kPdgS31m1620_Delta0 = 1212

Definition at line 205 of file common_convert.C.

const int kPdgS31m1620_DeltaM = 1112

Definition at line 204 of file common_convert.C.

const int kPdgS31m1620_DeltaP = 2122

Definition at line 206 of file common_convert.C.

const int kPdgS31m1620_DeltaPP = 2222

Definition at line 207 of file common_convert.C.

const int kPdgSDDiquarkS0 = 3101

Definition at line 161 of file common_convert.C.

const int kPdgSDDiquarkS1 = 3103

Definition at line 162 of file common_convert.C.

const int kPdgSigma0 = 3212

Definition at line 174 of file common_convert.C.

const int kPdgSigma0c = 4112

Definition at line 186 of file common_convert.C.

const int kPdgSigmaM = 3112

Definition at line 175 of file common_convert.C.

const int kPdgSigmaP = 3222

Definition at line 173 of file common_convert.C.

const int kPdgSigmaPc = 4212

Definition at line 187 of file common_convert.C.

const int kPdgSigmaPPc = 4222

Definition at line 188 of file common_convert.C.

const int kPdgSQuark = 3

Definition at line 148 of file common_convert.C.

const int kPdgSSDiquarkS1 = 3303

Definition at line 165 of file common_convert.C.

const int kPdgString = 92

Definition at line 291 of file common_convert.C.

const int kPdgSUDiquarkS0 = 3201

Definition at line 163 of file common_convert.C.

const int kPdgSUDiquarkS1 = 3203

Definition at line 164 of file common_convert.C.

const int kPdgTau = 15

Definition at line 141 of file common_convert.C.

const int kPdgTgtC12 = 1000060120

Definition at line 276 of file common_convert.C.

const int kPdgTgtDeuterium = 1000010020

Definition at line 275 of file common_convert.C.

const int kPdgTgtFe56 = 1000260560

Definition at line 278 of file common_convert.C.

const int kPdgTgtFreeN = 1000000010

Definition at line 274 of file common_convert.C.

const int kPdgTgtFreeP = 1000010010

Definition at line 273 of file common_convert.C.

const int kPdgTgtO16 = 1000080160

Definition at line 277 of file common_convert.C.

const int kPdgTQuark = 6

Definition at line 154 of file common_convert.C.

const int kPdgUDDiquarkS0 = 2101

Definition at line 158 of file common_convert.C.

const int kPdgUDDiquarkS1 = 2103

Definition at line 159 of file common_convert.C.

const int kPdgUQuark = 2

Definition at line 144 of file common_convert.C.

const int kPdgUUDiquarkS1 = 2203

Definition at line 160 of file common_convert.C.

const int kPdgWM = -24

Definition at line 268 of file common_convert.C.

const int kPdgWP = 24

Definition at line 267 of file common_convert.C.

const int kPdgXi0 = 3322

Definition at line 179 of file common_convert.C.

const int kPdgXiM = 3312

Definition at line 180 of file common_convert.C.

const int kPdgY = 553

Definition at line 250 of file common_convert.C.

const int kPdgZ0 = 23

Definition at line 266 of file common_convert.C.

int myjob = 0

Definition at line 42 of file common_convert.C.

double obs_frac_diff_max = 0

Definition at line 46 of file common_convert.C.

int pots = 0

Definition at line 43 of file common_convert.C.

TRandom3* rndm = 0

common code for use in the ntuple converter code

Author
Robert Hatcher <rhatcher fnal.gov> Fermi National Accelerator Laboratory

2012-11-07

functions for reading location text file and calculating energy and weight vectors for locations

Definition at line 36 of file common_convert.C.

TFile* treeFile = 0

Definition at line 39 of file common_convert.C.