MCTruthDisplay.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
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 
31 using std::ostringstream;
32 
33 using namespace genie;
34 using namespace genie::utils;
35 using namespace genie::masterclass;
36 
37 //______________________________________________________________________________
38 MCTruthDisplay::MCTruthDisplay(TRootEmbeddedCanvas * ec, TGTextEdit * gtx) :
39 fEmbeddedCanvas(ec),
40 fGTxt(gtx)
41 {
42 
43 }
44 //______________________________________________________________________________
46 {
47 
48 }
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 //______________________________________________________________________________
intermediate_table::iterator iterator
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
string delim()
Definition: fcldump.cxx:40
std::string string
Definition: nybbler.cc:12
TRootEmbeddedCanvas * fEmbeddedCanvas
void PrintEventRecord(EventRecord *event)
double Radius(int A, double Ro=constants::kNucRo)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
p
Definition: test.py:223
#define pINFO
Definition: Messenger.h:62
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:37
#define A
Definition: memgrp.cpp:38
int A(void) const
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
void DrawDiagram(EventRecord *event)
Root of GENIE utility namespaces.
Event finding and building.