Functions
gtestResonances.cxx File Reference
#include <string>
#include <TCanvas.h>
#include <TFile.h>
#include <TNtuple.h>
#include <TGraph.h>
#include <TLegend.h>
#include <TH1F.h>
#include <TPad.h>
#include <TPaveLabel.h>
#include "Framework/ParticleData/BaryonResonance.h"
#include "Framework/ParticleData/BaryonResUtils.h"
#include "Framework/Conventions/Constants.h"
#include "Framework/Conventions/Units.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Utils/BWFunc.h"

Go to the source code of this file.

Functions

int main (int, char **)
 

Function Documentation

int main ( int  ,
char **   
)

Definition at line 45 of file gtestResonances.cxx.

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 }
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
#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
std::size_t color(std::string const &procname)
const char * AsString(Resonance_t res)
resonance id -> string