Functions
d4sigma_plot.C File Reference
#include <TMath.h>
#include <TH3D.h>
#include <TFile.h>
#include <TCanvas.h>
#include <TPad.h>
#include <TGraph.h>
#include <TString.h>
#include <TStyle.h>
#include <iostream>

Go to the source code of this file.

Functions

void d4sigma_plot ()
 

Function Documentation

void d4sigma_plot ( )

Definition at line 17 of file d4sigma_plot.C.

17  {
18 
19  // Should be the same as when input rootfile was generated
20  const int COMP = 10;
21 
22  // Initialisation of variables
23  const double pi = TMath::Pi();
24  const int nsteps1 = 10*COMP, nsteps2 = 10*COMP, nsteps3 = 10*COMP, nsteps4 = 2*COMP;
25  double varmin1, varmin2, varmin3, varmin4, varmax1, varmax2, varmax3, varmax4;
26  int i,j,k,l;
27 
28  double Enu; // neutrino energy [GeV]
29  printf("Please enter neutrino energy: ");
30  scanf("%lf", &Enu);
31  printf("Trying to find input file for E_nu = %3.1lf GeV...\n", Enu);
32 
33  std::string fname = Form("data/d4sigma_hist_%3.1lfGeV.root", Enu);
34  TFile *file = new TFile(fname.c_str());
35 
36  if (!file) {
37  printf("ERROR: File not found!");
38  return;
39  }
40 
41  TH3D *hist[nsteps4];
42  for (l=0; l<nsteps4; l++) {
43  hist[l] = (TH3D*)file->Get(Form("d4sigma_hist_%d",l));
44  }
45 
46  // Get minimum/maximum of variables
47  varmin1 = hist[0]->GetXaxis()->GetXmin(); varmax1 = hist[0]->GetXaxis()->GetXmax();
48  varmin2 = hist[0]->GetYaxis()->GetXmin(); varmax2 = hist[0]->GetYaxis()->GetXmax();
49  varmin3 = hist[0]->GetZaxis()->GetXmin(); varmax3 = hist[0]->GetZaxis()->GetXmax();
50  varmin4 = -pi; varmax4 = pi;
51 
52  // Get bin edges for each variable
53  double binedge1[nsteps1+1], binedge2[nsteps2+1], binedge3[nsteps3+1];
54  binedge1[0] = varmin1; binedge2[0] = varmin2; binedge3[0] = varmin3;
55  for (i=1; i<nsteps1; i++) binedge1[i] = hist[0]->GetXaxis()->GetBinLowEdge(i+1);
56  for (j=1; j<nsteps2; j++) binedge2[j] = hist[0]->GetYaxis()->GetBinLowEdge(j+1);
57  for (k=1; k<nsteps3; k++) binedge3[k] = hist[0]->GetZaxis()->GetBinLowEdge(k+1);
58  binedge1[nsteps1] = varmax1; binedge2[nsteps2] = varmax2; binedge3[nsteps3] = varmax3;
59 
60  // Get bin widths for each variable
61  double binwidth1[nsteps1], binwidth2[nsteps2], binwidth3[nsteps3], binwidth4[nsteps4];
62  for (i=0; i<nsteps1; i++) binwidth1[i] = hist[0]->GetXaxis()->GetBinWidth(i+1);
63  for (j=0; j<nsteps2; j++) binwidth2[j] = hist[0]->GetYaxis()->GetBinWidth(j+1);
64  for (k=0; k<nsteps3; k++) binwidth3[k] = hist[0]->GetZaxis()->GetBinWidth(k+1);
65  for (l=0; l<nsteps4; l++) binwidth4[l] = (varmax4-varmin4)/nsteps4;
66 
67  // Initialise histograms with supposedly clever bins
68  TH1D* dTk = new TH1D("dTk", "d#sigma/dT_{kaon}", nsteps1, binedge1);
69  TH1D* dTl = new TH1D("dTl", "d#sigma/dT_{lepton}", nsteps2, binedge2);
70  TH1D* dct = new TH1D("dct", "d#sigma/dcos(#theta_{#nul})", nsteps3, binedge3);
71  TH1D* dph = new TH1D("dph", "d#sigma/d#phi_{kq}", nsteps4, varmin4, varmax4);
72 
73  // Get differential cross-section over T_kaon
74  double diff1Tk, diff2Tk, diff3Tk;
75  for (i=0; i<nsteps1; i++) {
76  diff1Tk = 0.;
77  for (j=0; j<nsteps2; j++) {
78  diff2Tk = 0.;
79  for (k=0; k<nsteps3; k++) {
80  diff3Tk = 0.;
81  for (l=0; l<nsteps4; l++) {
82  diff3Tk += hist[l]->GetBinContent(i+1,j+1,k+1)*binwidth4[l];
83  }
84  diff2Tk += diff3Tk*binwidth3[k];
85  }
86  diff1Tk += diff2Tk*binwidth2[j];
87  }
88  dTk->SetBinContent(i+1, diff1Tk*binwidth1[i]);
89  }
90 
91  // Get differential cross-section over T_lepton
92  double diff1Tl, diff2Tl, diff3Tl;
93  for (j=0; j<nsteps2; j++) {
94  diff1Tl = 0.;
95  for (i=0; i<nsteps1; i++) {
96  diff2Tl = 0.;
97  for (k=0; k<nsteps3; k++) {
98  diff3Tl = 0.;
99  for (l=0; l<nsteps4; l++) {
100  diff3Tl += hist[l]->GetBinContent(i+1,j+1,k+1)*binwidth4[l];
101  }
102  diff2Tl += diff3Tl*binwidth3[k];
103  }
104  diff1Tl += diff2Tl*binwidth1[i];
105  }
106  dTl->SetBinContent(j+1, diff1Tl*binwidth2[j]);
107  }
108 
109  // Get differential cross-section over cos(theta)
110  double diff1ct, diff2ct, diff3ct;
111  for (k=0; k<nsteps3; k++) {
112  diff1ct = 0.;
113  for (i=0; i<nsteps1; i++) {
114  diff2ct = 0.;
115  for (j=0; j<nsteps2; j++) {
116  diff3ct = 0.;
117  for (l=0; l<nsteps4; l++) {
118  diff3ct += hist[l]->GetBinContent(i+1,j+1,k+1)*binwidth4[l];
119  }
120  diff2ct += diff3ct*binwidth2[j];
121  }
122  diff1ct += diff2ct*binwidth1[i];
123  }
124  dct->SetBinContent(k+1, diff1ct*binwidth3[k]);
125  }
126 
127  // Get differential cross-section over phi_kq
128  double diff1ph, diff2ph, diff3ph;
129  for (l=0; l<nsteps4; l++) {
130  diff1ph = 0.;
131  for (i=0; i<nsteps1; i++) {
132  diff2ph = 0.;
133  for (j=0; j<nsteps2; j++) {
134  diff3ph = 0.;
135  for (k=0; k<nsteps3; k++) {
136  diff3ph += hist[l]->GetBinContent(i+1,j+1,k+1)*binwidth3[k];
137  }
138  diff2ph += diff3ph*binwidth2[j];
139  }
140  diff1ph += diff2ph*binwidth1[i];
141  }
142  dph->SetBinContent(l+1, diff1ph*binwidth4[l]);
143  }
144 
145  double sum1 = dTk->Integral();
146  double sum2 = dTl->Integral();
147  double sum3 = dct->Integral();
148  double sum4 = dph->Integral();
149 
150  printf("Integrals are:\n %.6e\n %.6e\n %.6e\n %.6e\n",sum1,sum2,sum3,sum4);
151 
152  dTk->SetMinimum(0);
153  dTl->SetMinimum(0);
154  dct->SetMinimum(0);
155  dph->SetMinimum(0);
156 
157  gStyle->SetOptStat(0);
158 
159  std::string outname = Form("d4sigma_plot_%3.1lfGeV", Enu);
160 
161  dTl->SetXTitle("T_{lepton} [GeV]");
162  dTk->SetXTitle("T_{kaon} [GeV]");
163  dct->SetXTitle("cos(#theta_{#nul}) [ ]");
164  dph->SetXTitle("#phi_{Kq} [rad]");
165 
166  TCanvas *c1 = new TCanvas("c1", "Differential cross-sections", 800, 600);
167  c1->Divide(2,2);
168  c1->cd(1); dTl->Draw();
169  c1->cd(2); dTk->Draw();
170  c1->cd(3); dct->Draw();
171  c1->cd(4); dph->Draw();
172  c1->Print(("images/"+outname+".png").c_str()); c1->Close();
173 
174  TFile* outfile = new TFile(("data/"+outname+".root").c_str(), "RECREATE");
175  dTl->Write("dsigma_dTlepton");
176  dTk->Write("dsigma_dTkaon");
177  dct->Write("dsigma_dcostheta");
178  dph->Write("dsigma_dphikq");
179  outfile->Close();
180  std::cout << std::endl << "Output written to file: " << outname << ".root" << std::endl << std::endl;
181 
182 }
size_t i(0)
std::string string
Definition: nybbler.cc:12
const double pi
Definition: LAr.C:31
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
< separator(=)> module_type Type Source location< separator(-)> DummyAnalyzer analyzer< path > DummyAnalyzer_module cc DummyFilter filter< path > DummyFilter_module cc *DummyProducer producer< path > DummyProducer_module cc *DummyProducer producer< path > DummyProducer_module cc< separator(=)> The modules marked *above are degenerate i e specifying the short module_type value leads to an ambiguity In order to use a degenerate in your configuration file
a1 GetXaxis() -> SetTitle("Q2")