Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
pythia_display.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demo showing H -> ZZ -> 4 mu generated by Pythia.
4/// Requires libPythia6.
5///
6/// \macro_code
7///
8/// \author Matevz Tadel
9
10#ifndef __RUN_PYTHIA_DISPLAY__
11
12void pythia_display()
13{
14 TString dir = gSystem->UnixPathName(__FILE__);
15 dir.ReplaceAll("pythia_display.C","");
16 dir.ReplaceAll("/./","/");
17 gROOT->LoadMacro(dir +"MultiView.C+");
18
19#ifndef R__WIN32 // libPythia6 is a static library on Windoze
20 if (gSystem->Load("libPythia6") < 0)
21 {
22 Error("pythia_display()",
23 "Could not load 'libPythia6', make sure it is available!");
24 return;
25 }
26#endif
27 gSystem->Load("libEGPythia6");
28
29 gROOT->ProcessLine("#define __RUN_PYTHIA_DISPLAY__ 1");
30 gROOT->ProcessLine("#include \"pythia_display.C\"");
31 gROOT->ProcessLine("run_pythia_display()");
32 gROOT->ProcessLine("#undef __RUN_PYTHIA_DISPLAY__");
33}
34
35#else
36
37//==============================================================================
38// Constants.
39//------------------------------------------------------------------------------
40
41const Double_t kR_min = 240;
42const Double_t kR_max = 250;
43const Double_t kZ_d = 300;
44
45// Solenoid field along z, in Tesla.
46const Double_t kMagField = 4;
47
48// Color for Higgs, Zs and muons
49const Color_t kColors[3] = { kRed, kGreen, kYellow };
50
51//==============================================================================
52// Global variables.
53//------------------------------------------------------------------------------
54
55#include "TEveTrack.h"
56#include "TEveTrackPropagator.h"
57#include "TEveElement.h"
58#include "TEveGeoShape.h"
59
60#include "TPythia6.h"
61#include "TGeoTube.h"
62#include "TMCParticle.h"
63
64TPythia6 *g_pythia = 0;
65
66// Implemented in MultiView.C
67class MultiView;
68MultiView* gMultiView = 0;
69
70TEveTrackList *gTrackList = 0;
71
72//==============================================================================
73// Forward decalarations of CINT functions.
74//------------------------------------------------------------------------------
75
76void pythia_next_event();
77void pythia_make_gui();
78
79//==============================================================================
80// Main - pythia_display()
81//------------------------------------------------------------------------------
82
83void run_pythia_display()
84{
85 if (g_pythia != 0)
86 {
87 Warning("pythia_display()", "Already initialized.");
88 return;
89 }
90
91 //========================================================================
92 //========================================================================
93
94 // Create an instance of the Pythia event generator ...
95 g_pythia = new TPythia6;
96 TPythia6& P = * g_pythia;
97
98 P.SetMSEL(0); // full user controll;
99 P.SetMSUB(102, 1); // g + g -> H0
100 //P.SetMSUB(123, 1); // f + f' -> f + f' + H0
101 //P.SetMSUB(124, 1); // f + f' -> f" + f"' + H0
102
103 P.SetPMAS(6, 1, 175); // mass of TOP
104 P.SetPMAS(25, 1, 180); // mass of Higgs
105
106
107 P.SetCKIN(1, 170.0); // range of allowed mass
108 P.SetCKIN(2, 190.0);
109
110 P.SetMSTP(61, 0); // switch off ISR
111 P.SetMSTP(71, 0); // switch off FSR
112 P.SetMSTP(81, 0); // switch off multiple interactions
113
114 P.SetMSTP(111, 0); // Switch off fragmentation
115
116 // Force h0 -> ZZ
117 for (Int_t i = 210; i <= 288; ++i)
118 P.SetMDME(i, 1, 0);
119 P.SetMDME(225, 1, 1);
120
121 // Force Z -> mumu
122 for (Int_t i = 174; i <= 189; ++i)
123 P.SetMDME(i, 1, 0);
124 P.SetMDME(184, 1, 1);
125
126
127 P.Initialize("cms", "p", "p", 14000);
128
129 //========================================================================
130 // Create views and containers.
131 //========================================================================
132
134
135 TEveElementList *fake_geom = new TEveElementList("Geometry");
136
138
139 b = new TEveGeoShape("Barell 1");
140 b->SetShape(new TGeoTube(kR_min, kR_max, kZ_d));
141 b->SetMainColor(kCyan);
142 b->SetMainTransparency(80);
143 fake_geom->AddElement(b);
144
145 b = new TEveGeoShape("Barell 2");
146 b->SetShape(new TGeoTube(2*kR_min, 2*kR_max, 2*kZ_d));
147 b->SetMainColor(kPink-3);
148 b->SetMainTransparency(80);
149 fake_geom->AddElement(b);
150
151 gEve->AddGlobalElement(fake_geom);
152
153
154 gMultiView = new MultiView;
155
156 gMultiView->ImportGeomRPhi(fake_geom);
157 gMultiView->ImportGeomRhoZ(fake_geom);
158
160
161 gTrackList = new TEveTrackList("Pythia Tracks");
162 gTrackList->SetMainColor(kYellow);
163 gTrackList->SetMarkerColor(kRed);
164 gTrackList->SetMarkerStyle(4);
165 gTrackList->SetMarkerSize(0.5);
166 gEve->AddElement(gTrackList);
167
168 TEveTrackPropagator* trkProp = gTrackList->GetPropagator();
169 trkProp->SetMagField(kMagField);
170 trkProp->SetMaxR(2*kR_max);
171 trkProp->SetMaxZ(2*kZ_d);
172
173 //========================================================================
174 //========================================================================
175
176 pythia_make_gui();
177 pythia_next_event();
178
180}
181
182
183//==============================================================================
184// Next event
185//------------------------------------------------------------------------------
186
187void pythia_next_event()
188{
189 gTrackList->DestroyElements();
190
191 TPythia6& P = * g_pythia;
192
193 P.GenerateEvent();
194
195 int nh = P.GetMSTU(72);
196
197 // printf("N = %d, Nhard = %d :: NumSec = %d, separators (%d,%d,%d,%d)\n",
198 // P.GetN(), nh, P.GetMSTU(70), P.GetMSTU(71), P.GetMSTU(72), P.GetMSTU(73), P.GetMSTU(74));
199 // 2->2 hard postfrag final
200
201 TEveTrackPropagator *trkProp = gTrackList->GetPropagator();
202 TClonesArray &MC = * (TClonesArray*) P.GetListOfParticles();
203 for (Int_t i = 0; i < 7; ++i)
204 {
205 TMCParticle& p = (TMCParticle&)*MC[nh+i];
206 TParticle pb(p.GetKF(), p.GetKS(), 0, 0,
207 p.GetFirstChild()-nh-1, p.GetLastChild()-nh-1,
208 p.GetPx(), p.GetPy(), p.GetPz(), p.GetEnergy(),
209 p.GetVx(), p.GetVy(), p.GetVz(), p.GetTime());
210
211 TEveTrack* track = new TEveTrack(&pb, i, trkProp);
212 track->SetName(Form("%s [%d]", pb.GetName(), i));
213 track->SetStdTitle();
214 track->SetAttLineAttMarker(gTrackList);
215 if (i == 0)
216 track->SetLineColor(kColors[0]);
217 else if (i <= 2)
218 track->SetLineColor(kColors[1]);
219
220 gTrackList->AddElement(track);
221
222 /*
223 printf("%d - %d %d %d %d %d %d\n", i,
224 p.GetKF(), p.GetKS(), 0, 0,
225 p.GetFirstChild()-nh-1, p.GetLastChild()-nh-1);
226 printf("%d - %f %f %f %f\n", i,
227 p.GetPx(), p.GetPy(), p.GetPz(), p.GetEnergy(),
228 printf("%d - %f %f %f %f\n", i,
229 p.GetVx(), p.GetVy(), p.GetVz(), p.GetTime());
230 */
231 }
232
233 gTrackList->MakeTracks();
234
235
236 TEveElement* top = static_cast<TEveElement *>(gEve->GetCurrentEvent());
237
238 gMultiView->DestroyEventRPhi();
239 gMultiView->ImportEventRPhi(top);
240
241 gMultiView->DestroyEventRhoZ();
242 gMultiView->ImportEventRhoZ(top);
243
244 gEve->Redraw3D();
245}
246
247
248//==============================================================================
249// GUI stuff
250//------------------------------------------------------------------------------
251class EvNavHandler
252{
253public:
254 void Fwd()
255 {
256 pythia_next_event();
257 }
258 void Bck()
259 {}
260};
261
262//______________________________________________________________________________
263void pythia_make_gui()
264{
265 // Create minimal GUI for event navigation.
266
267 TEveBrowser* browser = gEve->GetBrowser();
269
270 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
271 frmMain->SetWindowName("XX GUI");
272 frmMain->SetCleanup(kDeepCleanup);
273
274 TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain);
275 {
276
277 TString icondir( Form("%s/icons/", gSystem->Getenv("ROOTSYS")) );
278 TGPictureButton* b = 0;
279 EvNavHandler *fh = new EvNavHandler;
280
281 b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
282 b->SetEnabled(kFALSE);
283 b->SetToolTipText("Go to previous event - not supported.");
284 hf->AddFrame(b);
285 b->Connect("Clicked()", "EvNavHandler", fh, "Bck()");
286
287 b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
288 b->SetToolTipText("Generate new event.");
289 hf->AddFrame(b);
290 b->Connect("Clicked()", "EvNavHandler", fh, "Fwd()");
291 }
292 frmMain->AddFrame(hf);
293
294 frmMain->MapSubwindows();
295 frmMain->Resize();
296 frmMain->MapWindow();
297
298 browser->StopEmbedding();
299 browser->SetTabTitle("Event Control", 0);
300}
301
302#endif
#define b(i)
Definition RSha256.hxx:100
int Int_t
Definition RtypesCore.h:45
short Color_t
Definition RtypesCore.h:92
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
@ kPink
Definition Rtypes.h:67
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kCyan
Definition Rtypes.h:66
@ kYellow
Definition Rtypes.h:66
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
R__EXTERN TEveManager * gEve
#define gClient
Definition TGClient.h:156
@ kDeepCleanup
Definition TGFrame.h:42
winID h TVirtualViewer3D TVirtualGLPainter p
#define gROOT
Definition TROOT.h:406
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
R__EXTERN TSystem * gSystem
Definition TSystem.h:555
An array of clone (identical) objects.
Specialization of TRootBrowser for Eve.
A list of TEveElements.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
virtual void AddElement(TEveElement *el)
Add el to the list of children.
virtual void DestroyElements()
Destroy all children of this element.
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
void SetLineColor(Color_t col) override
Set the line color.
Definition TEveLine.h:48
void AddElement(TEveElement *element, TEveElement *parent=nullptr)
Add an element.
void AddGlobalElement(TEveElement *element, TEveElement *parent=nullptr)
Add a global element, i.e.
TEveBrowser * GetBrowser() const
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
TEveEventManager * GetCurrentEvent() const
A list of tracks supporting change of common attributes and selection based on track parameters.
Definition TEveTrack.h:140
void SetMarkerStyle(Style_t s) override
Set marker style for the list and the elements.
void SetMarkerColor(Color_t c) override
Set marker color for the list and the elements.
void SetMainColor(Color_t c) override
Set main (line) color for the list and the elements.
void SetMarkerSize(Size_t s) override
Set marker size for the list and the elements.
void MakeTracks(Bool_t recurse=kTRUE)
Regenerate the visual representations of tracks.
TEveTrackPropagator * GetPropagator()
Definition TEveTrack.h:175
Holding structure for a number of track rendering parameters.
void SetMaxR(Double_t x)
Set maximum radius and rebuild tracks.
void SetMaxZ(Double_t x)
Set maximum z and rebuild tracks.
void SetMagField(Double_t bX, Double_t bY, Double_t bZ)
Set constant magnetic field and rebuild tracks.
Visual representation of a track.
Definition TEveTrack.h:33
void SetAttLineAttMarker(TEveTrackList *tl)
Set line and marker attributes from TEveTrackList.
virtual void SetStdTitle()
Set standard track title based on most data-member values.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1072
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
void MapWindow() override
map window
Definition TGFrame.h:204
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:397
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1788
Yield an action as soon as it is clicked.
Definition TGButton.h:228
virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit=kTRUE)
Brings the composite frame with the index tabIndex to the front and generate the following event if t...
Definition TGTab.cxx:558
Cylindrical tube class.
Definition TGeoTube.h:17
Description of the dynamic properties of a particle.
Definition TParticle.h:26
virtual void SetName(const char *name)
Change (i.e.
void StartEmbedding(Int_t pos=kRight, Int_t subpos=-1) override
Start embedding external frame in the tab "pos" and tab element "subpos".
void SetTabTitle(const char *title, Int_t pos=kRight, Int_t subpos=-1)
Set text "title" of Tab "subpos" in TGTab "pos".
void StopEmbedding(const char *name=nullptr) override
TGTab * GetTabRight() const
Basic string class.
Definition TString.h:139
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1665
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1857
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1063
const Double_t kR_max
const Double_t kZ_d
const Double_t kR_min