GENIEGenerator
Loading...
Searching...
No Matches
MCTruthDisplay.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
11#include <sstream>
12#include <string>
13#include <vector>
14
15#include <TRootEmbeddedCanvas.h>
16#include <TGTextEdit.h>
17#include <TLorentzVector.h>
18#include <TLine.h>
19#include <TEllipse.h>
20#include <TLatex.h>
21#include <TCanvas.h>
22#include <TStyle.h>
23#include <TIterator.h>
24
30
31using std::ostringstream;
32
33using namespace genie;
34using namespace genie::utils;
35using namespace genie::masterclass;
36
37//______________________________________________________________________________
38MCTruthDisplay::MCTruthDisplay(TRootEmbeddedCanvas * ec, TGTextEdit * gtx) :
40fGTxt(gtx)
41{
42
43}
44//______________________________________________________________________________
49//______________________________________________________________________________
51{
52 if(!fEmbeddedCanvas) return;
53
54 LOG("MasterClass", pINFO) << "Drawing input event diagram";
55
56 fEmbeddedCanvas->GetCanvas()->cd();
57 fEmbeddedCanvas->GetCanvas()->Clear();
58
59 fEmbeddedCanvas->GetCanvas()->Range(0,0,30,30);
60 fEmbeddedCanvas->GetCanvas()->SetFillColor(0);
61 fEmbeddedCanvas->GetCanvas()->SetBorderMode(0);
62
63 GHepParticle * target = event->TargetNucleus();
64 if(target) {
65 int A = target->A();
66 double R = nuclear::Radius(A);
67 TEllipse grpx_target(0,0,R,R);
68 grpx_target.Draw();
69 fEmbeddedCanvas->GetCanvas()->Update();
70 }
71
72 GHepParticle * p = 0;
73 TIter event_iter(event);
74 while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) ) {
75
76
77 }
78
79 //
80 // ...
81 //
82
83 fEmbeddedCanvas->GetCanvas()->Update();
84}
85//______________________________________________________________________________
87{
88 if(!fGTxt) return;
89
90 ostringstream ghep;
91 ghep << *event;
92 string ghepstr = ghep.str(); // GHEP record as a single string
93
94 // split GHEP string to get 1 line per particle - use '\n' as delimiter
95 vector<string> lines;
96 string delim = string("\n");
97 while(ghepstr.find_first_of(delim) < ghepstr.length()) {
98 lines.push_back(
99 ghepstr.substr(0, ghepstr.find_first_of(delim)) );
100 ghepstr = ghepstr.substr(
101 ghepstr.find_first_of(delim)+1, ghepstr.length());
102 }
103 lines.push_back(ghepstr);
104
105 // print GHEP entries to TGTextView
106 vector<string>::iterator line_iter;
107 for(line_iter = lines.begin(); line_iter != lines.end(); ++line_iter) {
108 fGTxt->AddLine( line_iter->c_str() );
109 }
110}
111//______________________________________________________________________________
#define pINFO
Definition Messenger.h:62
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition EventRecord.h:37
STDHEP-like event record entry that can fit a particle or a nucleus.
int A(void) const
TRootEmbeddedCanvas * fEmbeddedCanvas
void PrintEventRecord(EventRecord *event)
MCTruthDisplay(TRootEmbeddedCanvas *ec=0, TGTextEdit *gtx=0)
void DrawDiagram(EventRecord *event)
GHEP event record utilities.
double Radius(int A, double Ro=constants::kNucRo)
Root of GENIE utility namespaces.
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25