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{
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
65
66// Implemented in MultiView.C
67class MultiView;
69
71
72//==============================================================================
73// Forward decalarations of CINT functions.
74//------------------------------------------------------------------------------
75
77void pythia_make_gui();
78
79//==============================================================================
80// Main - pythia_display()
81//------------------------------------------------------------------------------
82
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
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);
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
178
180}
181
182
183//==============================================================================
184// Next event
185//------------------------------------------------------------------------------
186
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 {
257 }
258 void Bck()
259 {}
260};
261
262//______________________________________________________________________________
263void pythia_make_gui()
264{
265 // Create minimal GUI for event navigation.
266
268 browser->StartEmbedding(TRootBrowser::kLeft);
269
270 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
271 frmMain->SetWindowName("XX GUI");
272 frmMain->SetCleanup(kDeepCleanup);
273
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
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:566
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
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
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
Holding structure for a number of track rendering parameters.
Visual representation of a track.
Definition TEveTrack.h:33
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
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
TGTab * GetTabRight() const
Basic string class.
Definition TString.h:139
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