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 G__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 "TPythia6.h"
56#include "TGeoTube.h"
57#include "TMCParticle.h"
58
59TPythia6 *g_pythia = 0;
60
61// Implemented in MultiView.C
62class MultiView;
63MultiView* gMultiView = 0;
64
65TEveTrackList *gTrackList = 0;
66
67//==============================================================================
68// Forward decalarations of CINT functions.
69//------------------------------------------------------------------------------
70
71void pythia_next_event();
72void pythia_make_gui();
73
74//==============================================================================
75// Main - pythia_display()
76//------------------------------------------------------------------------------
77
78void run_pythia_display()
79{
80 if (g_pythia != 0)
81 {
82 Warning("pythia_display()", "Already initialized.");
83 return;
84 }
85
86 //========================================================================
87 //========================================================================
88
89 // Create an instance of the Pythia event generator ...
90 g_pythia = new TPythia6;
91 TPythia6& P = * g_pythia;
92
93 P.SetMSEL(0); // full user controll;
94 P.SetMSUB(102, 1); // g + g -> H0
95 //P.SetMSUB(123, 1); // f + f' -> f + f' + H0
96 //P.SetMSUB(124, 1); // f + f' -> f" + f"' + H0
97
98 P.SetPMAS(6, 1, 175); // mass of TOP
99 P.SetPMAS(25, 1, 180); // mass of Higgs
100
101
102 P.SetCKIN(1, 170.0); // range of allowed mass
103 P.SetCKIN(2, 190.0);
104
105 P.SetMSTP(61, 0); // switch off ISR
106 P.SetMSTP(71, 0); // switch off FSR
107 P.SetMSTP(81, 0); // switch off multiple interactions
108
109 P.SetMSTP(111, 0); // Switch off fragmentation
110
111 // Force h0 -> ZZ
112 for (Int_t i = 210; i <= 288; ++i)
113 P.SetMDME(i, 1, 0);
114 P.SetMDME(225, 1, 1);
115
116 // Force Z -> mumu
117 for (Int_t i = 174; i <= 189; ++i)
118 P.SetMDME(i, 1, 0);
119 P.SetMDME(184, 1, 1);
120
121
122 P.Initialize("cms", "p", "p", 14000);
123
124 //========================================================================
125 // Create views and containers.
126 //========================================================================
127
129
130 TEveElementList *fake_geom = new TEveElementList("Geometry");
131
133
134 b = new TEveGeoShape("Barell 1");
135 b->SetShape(new TGeoTube(kR_min, kR_max, kZ_d));
136 b->SetMainColor(kCyan);
137 b->SetMainTransparency(80);
138 fake_geom->AddElement(b);
139
140 b = new TEveGeoShape("Barell 2");
141 b->SetShape(new TGeoTube(2*kR_min, 2*kR_max, 2*kZ_d));
142 b->SetMainColor(kPink-3);
143 b->SetMainTransparency(80);
144 fake_geom->AddElement(b);
145
146 gEve->AddGlobalElement(fake_geom);
147
148
149 gMultiView = new MultiView;
150
151 gMultiView->ImportGeomRPhi(fake_geom);
152 gMultiView->ImportGeomRhoZ(fake_geom);
153
155
156 gTrackList = new TEveTrackList("Pythia Tracks");
157 gTrackList->SetMainColor(kYellow);
158 gTrackList->SetMarkerColor(kRed);
159 gTrackList->SetMarkerStyle(4);
160 gTrackList->SetMarkerSize(0.5);
161 gEve->AddElement(gTrackList);
162
163 TEveTrackPropagator* trkProp = gTrackList->GetPropagator();
164 trkProp->SetMagField(kMagField);
165 trkProp->SetMaxR(2*kR_max);
166 trkProp->SetMaxZ(2*kZ_d);
167
168 //========================================================================
169 //========================================================================
170
171 pythia_make_gui();
172 pythia_next_event();
173
175}
176
177
178//==============================================================================
179// Next event
180//------------------------------------------------------------------------------
181
182void pythia_next_event()
183{
184 gTrackList->DestroyElements();
185
186 TPythia6& P = * g_pythia;
187
188 P.GenerateEvent();
189
190 int nh = P.GetMSTU(72);
191
192 // printf("N = %d, Nhard = %d :: NumSec = %d, separators (%d,%d,%d,%d)\n",
193 // P.GetN(), nh, P.GetMSTU(70), P.GetMSTU(71), P.GetMSTU(72), P.GetMSTU(73), P.GetMSTU(74));
194 // 2->2 hard postfrag final
195
196 TEveTrackPropagator *trkProp = gTrackList->GetPropagator();
198 for (Int_t i = 0; i < 7; ++i)
199 {
200 TMCParticle& p = (TMCParticle&)*MC[nh+i];
201 TParticle pb(p.GetKF(), p.GetKS(), 0, 0,
202 p.GetFirstChild()-nh-1, p.GetLastChild()-nh-1,
203 p.GetPx(), p.GetPy(), p.GetPz(), p.GetEnergy(),
204 p.GetVx(), p.GetVy(), p.GetVz(), p.GetTime());
205
206 TEveTrack* track = new TEveTrack(&pb, i, trkProp);
207 track->SetName(Form("%s [%d]", pb.GetName(), i));
208 track->SetStdTitle();
209 track->SetAttLineAttMarker(gTrackList);
210 if (i == 0)
211 track->SetLineColor(kColors[0]);
212 else if (i <= 2)
213 track->SetLineColor(kColors[1]);
214
215 gTrackList->AddElement(track);
216
217 /*
218 printf("%d - %d %d %d %d %d %d\n", i,
219 p.GetKF(), p.GetKS(), 0, 0,
220 p.GetFirstChild()-nh-1, p.GetLastChild()-nh-1);
221 printf("%d - %f %f %f %f\n", i,
222 p.GetPx(), p.GetPy(), p.GetPz(), p.GetEnergy(),
223 printf("%d - %f %f %f %f\n", i,
224 p.GetVx(), p.GetVy(), p.GetVz(), p.GetTime());
225 */
226 }
227
228 gTrackList->MakeTracks();
229
230
232
233 gMultiView->DestroyEventRPhi();
234 gMultiView->ImportEventRPhi(top);
235
236 gMultiView->DestroyEventRhoZ();
237 gMultiView->ImportEventRhoZ(top);
238
239 gEve->Redraw3D();
240}
241
242
243//==============================================================================
244// GUI stuff
245//------------------------------------------------------------------------------
246class EvNavHandler
247{
248public:
249 void Fwd()
250 {
251 pythia_next_event();
252 }
253 void Bck()
254 {}
255};
256
257//______________________________________________________________________________
258void pythia_make_gui()
259{
260 // Create minimal GUI for event navigation.
261
262 TEveBrowser* browser = gEve->GetBrowser();
264
265 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
266 frmMain->SetWindowName("XX GUI");
267 frmMain->SetCleanup(kDeepCleanup);
268
269 TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain);
270 {
271
272 TString icondir( Form("%s/icons/", gSystem->Getenv("ROOTSYS")) );
273 TGPictureButton* b = 0;
274 EvNavHandler *fh = new EvNavHandler;
275
276 b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
277 b->SetEnabled(kFALSE);
278 b->SetToolTipText("Go to previous event - not supported.");
279 hf->AddFrame(b);
280 b->Connect("Clicked()", "EvNavHandler", fh, "Bck()");
281
282 b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
283 b->SetToolTipText("Generate new event.");
284 hf->AddFrame(b);
285 b->Connect("Clicked()", "EvNavHandler", fh, "Fwd()");
286 }
287 frmMain->AddFrame(hf);
288
289 frmMain->MapSubwindows();
290 frmMain->Resize();
291 frmMain->MapWindow();
292
293 browser->StopEmbedding();
294 browser->SetTabTitle("Event Control", 0);
295}
296
297#endif
298
#define b(i)
Definition RSha256.hxx:100
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:92
double Double_t
Definition RtypesCore.h:59
short Color_t
Definition RtypesCore.h:83
const Bool_t kTRUE
Definition RtypesCore.h:91
@ 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:187
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:231
R__EXTERN TEveManager * gEve
#define gClient
Definition TGClient.h:166
@ kDeepCleanup
Definition TGFrame.h:50
#define gROOT
Definition TROOT.h:406
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
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...
virtual void SetLineColor(Color_t col)
Set the line color.
Definition TEveLine.h:48
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
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
virtual void SetMarkerStyle(Style_t s)
Set marker style for the list and the elements.
virtual void SetMarkerColor(Color_t c)
Set marker color for the list and the elements.
void MakeTracks(Bool_t recurse=kTRUE)
Regenerate the visual representations of tracks.
virtual void SetMainColor(Color_t c)
Set main (line) color for the list and the elements.
TEveTrackPropagator * GetPropagator()
Definition TEveTrack.h:175
virtual void SetMarkerSize(Size_t s)
Set marker size for the list and the elements.
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=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1057
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1149
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
virtual void MapWindow()
map window
Definition TGFrame.h:228
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1749
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:509
virtual TObjArray * GetListOfParticles() const
Definition TGenerator.h:176
Cylindrical tube class.
Definition TGeoTube.h:18
This class serves as a data storage for description of one particle.
Definition TMCParticle.h:20
Float_t GetPx() const
Definition TMCParticle.h:80
Int_t GetKS() const
Definition TMCParticle.h:74
Float_t GetVx() const
Definition TMCParticle.h:86
Float_t GetPy() const
Definition TMCParticle.h:81
Int_t GetLastChild() const
Definition TMCParticle.h:78
Float_t GetTime() const
Definition TMCParticle.h:89
Int_t GetKF() const
Definition TMCParticle.h:75
Float_t GetPz() const
Definition TMCParticle.h:82
Float_t GetVz() const
Definition TMCParticle.h:88
Float_t GetEnergy() const
Definition TMCParticle.h:83
Float_t GetVy() const
Definition TMCParticle.h:87
Int_t GetFirstChild() const
Definition TMCParticle.h:77
Description of the dynamic properties of a particle.
Definition TParticle.h:26
virtual void SetName(const char *name)
Change (i.e.
TPythia is an interface class to F77 version of Pythia 6.2
Definition TPythia6.h:84
int GetMSTU(int i)
Definition TPythia6.h:152
void SetMDME(int i, int j, int m)
Definition TPythia6.h:184
void Initialize(const char *frame, const char *beam, const char *target, float win)
Calls PyInit with the same parameters after performing some checking, sets correct title.
Definition TPythia6.cxx:438
void SetMSEL(int m)
Definition TPythia6.h:210
void SetCKIN(int i, double c)
Definition TPythia6.h:213
void SetPMAS(int ip, int i, double m)
Definition TPythia6.h:171
void GenerateEvent()
generate event and copy the information from /HEPEVT/ to fPrimaries
Definition TPythia6.cxx:299
void SetMSUB(int i, int m)
Definition TPythia6.h:212
void SetMSTP(int i, int m)
Definition TPythia6.h:224
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:136
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:692
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1661
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1853
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1061
const Double_t kR_max
const Double_t kZ_d
const Double_t kR_min