nuint09_qel4.C
Go to the documentation of this file.
1 //
2 // NuINT09 Conference, Benchmark Calculations (GENIE contribution)
3 //
4 // QEL.4:
5 // dSigma / dOmega_p dKE_p at E_nu = 0.5 and 1.0 GeV
6 //
7 // Inputs:
8 // - sample id: 0 (nu_mu+C12), 1 (nu_mu+O16), 2 (nu_mu+Fe56)
9 //
10 // Costas Andreopoulos, STFC / Rutherford Appleton Laboratory
11 //
12 #include <iomanip>
13 
14 //
15 // consts
16 //
17 const int kNSamples = 3;
18 const int kNWCur = 1;
19 const int kNEnergies = 2;
20 const int kNRunsPerCase = 5;
21 const int kNEvtPerRun = 100000;
22 
23 const char * kLabel[kNSamples] =
24 {
25  /* 0 */ "nu_mu_C12",
26  /* 1 */ "nu_mu_O16",
27  /* 2 */ "nu_mu_Fe56"
28 };
29 
31 {
32  /* indices : sample ; cc/nc ; energy */
33  {
34  /* 0,0,0 (nu_mu C12, CC, 0.5 GeV) */ { {200100, 200101, 200102, 200103, 200104},
35  /* 0,0,1 (nu_mu C12, CC, 1.0 GeV) */ {200200, 200201, 200202, 200203, 200204} }
36  },
37  {
38  /* 1,0,0 (nu_mu O16, CC, 0.5 GeV) */ { {210100, 210101, 210102, 210103, 210104},
39  /* 1,0,1 (nu_mu O16, CC, 1.0 GeV) */ {210200, 210201, 210202, 210203, 210204} }
40  },
41  {
42  /* 2,0,0 (nu_mu Fe56, CC, 0.5 GeV) */ { {220100, 220101, 220102, 220103, 220104},
43  /* 2,0,1 (nu_mu Fe56, CC, 1.0 GeV) */ {220200, 220201, 220202, 220203, 220204} }
44  }
45 };
46 int kZ[3] =
47 {
48  // Z for nuclear target at each sample
49  /* 0 */ 6,
50  /* 1 */ 8,
51  /* 2 */ 26
52 };
53 int kA[3] =
54 {
55  // A for nuclear target at each sample
56  /* 0 */ 12,
57  /* 1 */ 16,
58  /* 2 */ 56
59 };
60 
61 void nuint09_qel4(int isample)
62 {
63  cout << " ***** running: QEL.4" << endl;
64 
65  if(isample<0 || isample >= kNSamples) return;
66 
67  const char * label = kLabel[isample];
68 
69  int A = kA[isample];
70  int Z = kZ[isample];
71  int N = A-Z;
72 
73  // get cross section graphs
74 
75  TFile fsig("../sig/splines.root","read");
76  TDirectory * sig_dir = (TDirectory *) fsig.Get(label);
77 
78  TGraph * sig_graph_qelcc = (TGraph*) sig_dir->Get("qel_cc_n");
79 
80  // range & spacing
81 
82  const int nKEp = 60;
83  const double KEpmin = 0.01;
84  const double KEpmax = 1.50;
85 
86  const int ncosth = 30;
87  const double costhmin = -1;
88  const double costhmax = +1;
89 
90  // create output stream
91 
92  ostringstream out_filename;
93  out_filename << label << ".qel_4.d2sig_dKEpdOmega.data";
94  ofstream out_stream(out_filename.str().c_str(), ios::out);
95 
96  // write out txt file
97 
98  out_stream << "# [" << label << "]" << endl;
99  out_stream << "# " << endl;
100  out_stream << "# [QEL.4]:" << endl;
101  out_stream << "# dSigma / dOmega_p dKE_p at E_nu = 0.5 and 1.0 GeV" << endl;
102  out_stream << "# " << endl;
103  out_stream << "# Note:" << endl;
104  out_stream << "# - proton energies are _kinetic_ energies " << endl;
105  out_stream << "# - proton kinetic energy KE in GeV, between KEmin = " << KEpmin << " GeV, KEmax = " << KEpmax << " GeV " << endl;
106  out_stream << "# - cross sections in 1E-38 cm^2 /GeV /sterad" << endl;
107  out_stream << "# - quoted cross section is nuclear cross section per nucleon contributing in the scattering (eg only neutrons for nu_mu QELCC)" << endl;
108  out_stream << "# Columns:" << endl;
109  out_stream << "# | KE(p) | cos(theta_p) | sig(QELCC; Ev=0.5GeV) | sig(QELCC; Ev=1.0GeV) | " << endl;
110 
111  out_stream << std::fixed << setprecision(6);
112 
113  //
114  // load event data
115  //
116 
117  TChain * chain = new TChain("gst");
118 
119  // loop over CC/NC cases
120  for(int iwkcur=0; iwkcur<kNWCur; iwkcur++) {
121  // loop over energies
122  for(int ie=0; ie<kNEnergies; ie++) {
123  // loop over runs for current case
124  for(int ir=0; ir<kNRunsPerCase; ir++) {
125  // build filename
126  ostringstream filename;
127  int run_number = kRunNu[isample][iwkcur][ie][ir];
128  filename << "../gst/gntp." << run_number << ".gst.root";
129  // add to chain
130  cout << "Adding " << filename.str() << " to event chain" << endl;
131  chain->Add(filename.str().c_str());
132  }
133  }
134  }
135 
136  //
137  // get QELCC cross sections at given energies for normalization purposes
138  //
139  double sig_qelcc_0500MeV = sig_graph_qelcc->Eval(0.5) / N;
140  double sig_qelcc_1000MeV = sig_graph_qelcc->Eval(1.0) / N;
141 
142  //
143  // book histograms
144  //
145  TH2D * hst_d2sig_dKEpdOmg_qelcc_0500MeV = new TH2D("hst_d2sig_dKEpdOmg_qelcc_0500MeV",
146  "dsig/d2KEpdOmega, nu_mu QEL CC, Enu=0.5 GeV", nKEp, KEpmin, KEpmax, ncosth, costhmin, costhmax);
147  TH2D * hst_d2sig_dKEpdOmg_qelcc_1000MeV = new TH2D("hst_d2sig_dKEpdOmg_qelcc_1000MeV",
148  "dsig/d2KEpdOmega, nu_mu QEL CC, Enu=1.0 GeV", nKEp, KEpmin, KEpmax, ncosth, costhmin, costhmax);
149 
150  //
151  // fill histograms
152  //
153  chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.938272)>>hst_d2sig_dKEpdOmg_qelcc_0500MeV","qel&&cc&&Ev>0.49&&Ev<0.51&&pdgi==2212","GOFF");
154  chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.938272)>>hst_d2sig_dKEpdOmg_qelcc_1000MeV","qel&&cc&&Ev>0.99&&Ev<1.01&&pdgi==2212","GOFF");
155 
156  //
157  // normalize
158  //
159  double norm_qelcc_0500MeV = hst_d2sig_dKEpdOmg_qelcc_0500MeV -> Integral("width") * 2*TMath::Pi() / sig_qelcc_0500MeV;
160  double norm_qelcc_1000MeV = hst_d2sig_dKEpdOmg_qelcc_1000MeV -> Integral("width") * 2*TMath::Pi() / sig_qelcc_1000MeV;
161 
162  if (norm_qelcc_0500MeV > 0) hst_d2sig_dKEpdOmg_qelcc_0500MeV -> Scale(1./norm_qelcc_0500MeV);
163  if (norm_qelcc_1000MeV > 0) hst_d2sig_dKEpdOmg_qelcc_1000MeV -> Scale(1./norm_qelcc_1000MeV);
164 
165  for(int i = 1; i <= hst_d2sig_dKEpdOmg_qelcc_1000MeV->GetNbinsX(); i++) {
166  for(int j = 1; j <= hst_d2sig_dKEpdOmg_qelcc_1000MeV->GetNbinsY(); j++) {
167 
168  double KEp = hst_d2sig_dKEpdOmg_qelcc_1000MeV -> GetXaxis() -> GetBinCenter(i);
169  double costhp = hst_d2sig_dKEpdOmg_qelcc_1000MeV -> GetYaxis() -> GetBinCenter(j);
170 
171  double d2sig_dKEpdOmg_qelcc_0500MeV = hst_d2sig_dKEpdOmg_qelcc_0500MeV -> GetBinContent(i,j);
172  double d2sig_dKEpdOmg_qelcc_1000MeV = hst_d2sig_dKEpdOmg_qelcc_1000MeV -> GetBinContent(i,j);
173 
174  d2sig_dKEpdOmg_qelcc_0500MeV = TMath::Max(0., d2sig_dKEpdOmg_qelcc_0500MeV);
175  d2sig_dKEpdOmg_qelcc_1000MeV = TMath::Max(0., d2sig_dKEpdOmg_qelcc_1000MeV);
176 
177  out_stream << setw(15) << KEp
178  << setw(15) << costhp
179  << setw(15) << d2sig_dKEpdOmg_qelcc_0500MeV
180  << setw(15) << d2sig_dKEpdOmg_qelcc_1000MeV
181  << endl;
182  }//costh
183  }//E
184 
185  out_stream.close();
186 
187  delete chain;
188 }
const char * kLabel[kNSamples]
Definition: nuint09_qel4.C:23
size_t i(0)
const int kNEnergies
Definition: nuint09_qel4.C:19
a1 GetYaxis() -> SetTitle("F2")
the ParameterSet object passed in for the configuration of a destination should be the only source that can affect the behavior of that destination This is to eliminate the dependencies of configuring a destination from multiple mostly from the defaults It suppresses possible glitches about changing the configuration file somewhere outside of a destination segament might still affect the behavior of that destination In the previous configuration for a specific the value of a certain e may come from following and have been suppressed It the configuring ParameterSet object for each destination will be required to carry a parameter list as complete as possible If a parameter still cannot be found in the ParameterSet the configuration code will go look for a hardwired default directly The model is a great simplicity comparing with the previous especially when looking for default values Another great advantage is most of the parameters now have very limited places that allows to appear Usually they can only appear at one certain level in a configuration file For in the old configuring model or in a default ParameterSet object inside of a or in a category or in a severity object This layout of multiple sources for a single parameter brings great confusion in both writing a configuration and in processing the configuration file Under the new the only allowed place for the parameter limit to appear is inside of a category which is inside of a destination object Other improvements simplify the meaning of a destination name In the old a destination name has multiple folds of meanings the e cout and cerr have the special meaning of logging messages to standard output or standard error the name also serves as the output filename if the destination is a file these names are also references to look up for detailed configurations in configuring the MessageFacility The multi purpose of the destination name might cause some unwanted behavior in either writing or parsing the configuration file To amend in the new model the destination name is now merely a name for a which might represent the literal purpose of this or just an id All other meanings of the destinations names now go into the destination ParameterSet as individual such as the type parameter and filename parameter Following is the deatiled rule for the new configuring Everything that is related with MessageFacility configuration must be wrapped in a single ParameterSet object with the name MessageFacility The MessageFacility ParameterSet object contains a series of top level parameters These parameters can be chosen a vector of string listing the name of debug enabled models Or use *to enable debug messages in all modules a vector of string a vector of string a vector of string a ParameterSet object containing the list of all destinations The destinations ParameterSet object is a combination of ParameterSet objects for individual destinations There are two types of destinations that you can insert in the destinations ParameterSet ordinary including cout
const int kNWCur
Definition: nuint09_qel4.C:18
const int kNSamples
Definition: nuint09_qel4.C:17
int kA[3]
Definition: nuint09_qel4.C:53
void nuint09_qel4(int isample)
Definition: nuint09_qel4.C:61
var ie
Definition: slidy.js:14
const int kRunNu[kNSamples][kNWCur][kNEnergies][kNRunsPerCase]
Definition: nuint09_qel4.C:30
const int kNEvtPerRun
Definition: nuint09_qel4.C:21
int kZ[3]
Definition: nuint09_qel4.C:46
a1 GetXaxis() -> SetTitle("Q2")
const int kNRunsPerCase
Definition: nuint09_qel4.C:20