GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gtestResonances.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \program gtestResonances
5 
6 \brief Program used for testing/debugging the Breit-Wigner distributions
7  for Baryon Resonances
8 
9 \author Costas Andreopoulos <c.andreopoulos \at cern.ch>
10  University of Liverpool
11 
12 \created June 20, 2004
13 
14 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
15  For the full text of the license visit http://copyright.genie-mc.org
16 
17 */
18 //____________________________________________________________________________
19 
20 #include <string>
21 
22 #include <TCanvas.h>
23 #include <TFile.h>
24 #include <TNtuple.h>
25 #include <TGraph.h>
26 #include <TLegend.h>
27 #include <TH1F.h>
28 #include <TPad.h>
29 #include <TPaveLabel.h>
30 
36 #include "Framework/Utils/BWFunc.h"
37 
38 using std::string;
39 
40 using namespace genie;
41 using namespace genie::constants;
42 using namespace genie::utils;
43 using namespace genie::units;
44 
45 int main(int /*argc*/, char ** /*argv*/)
46 {
47  const int kNResonances = 18;
48 
49  const Resonance_t kResonances[kNResonances] = {
56  };
57 
58  const int color[kNResonances] = {1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19};
59 
60  //-- Graphs to hold baryon resonances Breit Wigner distributions
61  TGraph * grbw[kNResonances];
62 
63  //-- Define an output ntuple
64  TNtuple resnt("resnt","baryon resonances","res:W:BW");
65 
66  //-- Loop over baryon resonances
67  for(int ires = 0; ires < kNResonances; ires++) {
68 
69  //-- Get the current baryon resonance
70  Resonance_t resonance = kResonances[ires];
71 
72  LOG("test", pINFO) << "@ Resonance = " << utils::res::AsString(resonance);
73 
74  int LR = utils::res::OrbitalAngularMom (resonance);
75  double MR = utils::res::Mass (resonance);
76  double WR = utils::res::Width (resonance);
77  double NR = utils::res::BWNorm (resonance);
78 
79  LOG("test", pINFO) << "- mass = " << MR << " GeV";
80  LOG("test", pINFO) << "- width = " << WR << " GeV";
81  LOG("test", pINFO) << "- BW norm = " << NR;
82  LOG("test", pINFO) << "- L = " << LR;
83 
84  double bw[50], W[50];
85 
86  for(int iW = 0; iW<50; iW++) {
87  W[iW] = 0.01 + iW*(3.5/50.);
88  bw[iW] = utils::bwfunc::BreitWignerL(W[iW],LR,MR,WR,NR);
89  resnt.Fill((float)resonance, W[iW], bw[iW]);
90  LOG("test", pINFO)
91  << " BreitWigner(W = " << W[iW] << " GeV) = " << bw[iW];
92  }
93  grbw[ires] = new TGraph(50, W, bw);
94  }
95 
96  //-- Create & format output canvas
97 
98  TCanvas * c = new TCanvas("c","",20,20,500,500);
99 
100  c->SetBorderMode(0);
101  c->SetFillColor(0);
102  c->Draw();
103 
104  TH1F * hframe = (TH1F*) c->DrawFrame(1.0,0.5,3.5,6.0);
105  hframe->Draw();
106  TLegend * legend = new TLegend(0.6,0.2,0.8,0.8);
107 
108  for(int ires = 0; ires < kNResonances; ires++) {
109  grbw[ires]->SetLineWidth(2);
110  grbw[ires]->SetLineColor( color[ires] );
111  grbw[ires]->Draw("C");
112  legend->AddEntry(grbw[ires],utils::res::AsString(kResonances[ires]),"L");
113  }
114 
115  legend->SetFillColor(0);
116  legend->Draw();
117 
118  hframe->GetXaxis()->SetTitle("W (GeV)");
119  hframe->GetYaxis()->SetTitle("Breit Wigner Amplitude");
120  hframe->GetXaxis()->SetTitleOffset(1.3);
121  hframe->GetYaxis()->SetTitleOffset(1.3);
122 
123  c->Update();
124 
125  TFile f("./genie-resonances.root","recreate");
126  c->Write("plot");
127  resnt.Write();
128  f.Close();
129 
130  for(int ires = 0; ires < kNResonances; ires++) {
131  delete grbw[ires];
132  }
133  delete legend;
134  delete c;
135 }
136 //____________________________________________________________________________
137 
double Mass(Resonance_t res)
resonance mass (GeV)
double Width(Resonance_t res)
resonance width (GeV)
double BreitWignerL(double W, int L, double mass, double width0, double norm)
Definition: BWFunc.cxx:99
double BWNorm(Resonance_t res, double N0ResMaxNWidths=6, double N2ResMaxNWidths=2, double GnResMaxNWidths=4)
breit-wigner normalization factor
enum genie::EResonance Resonance_t
int main(int argc, char **argv)
Definition: gAtmoEvGen.cxx:327
double W(const Interaction *const i)
Definition: KineUtils.cxx:1101
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
int OrbitalAngularMom(Resonance_t res)
orbital angular momentum
#define pINFO
Definition: Messenger.h:62
const char * AsString(Resonance_t res)
resonance id -&gt; string