Logo ROOT   6.08/07
Reference Guide
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 
12 void 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 
41 const Double_t kR_min = 240;
42 const Double_t kR_max = 250;
43 const Double_t kZ_d = 300;
44 
45 // Solenoid field along z, in Tesla.
46 const Double_t kMagField = 4;
47 
48 // Color for Higgs, Zs and muons
49 const 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 
59 TPythia6 *g_pythia = 0;
60 
61 // Implemented in MultiView.C
62 class MultiView;
63 MultiView* gMultiView = 0;
64 
65 TEveTrackList *gTrackList = 0;
66 
67 //==============================================================================
68 // Forward decalarations of CINT functions.
69 //------------------------------------------------------------------------------
70 
71 void pythia_next_event();
72 void pythia_make_gui();
73 
74 //==============================================================================
75 // Main - pythia_display()
76 //------------------------------------------------------------------------------
77 
78 void 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 
132  TEveGeoShape *b;
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 
154  gEve->GetBrowser()->GetTabRight()->SetTab(1);
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 
174  gEve->Redraw3D(kTRUE);
175 }
176 
177 
178 //==============================================================================
179 // Next event
180 //------------------------------------------------------------------------------
181 
182 void 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 
231  TEveElement* top = gEve->GetCurrentEvent();
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 //------------------------------------------------------------------------------
246 class EvNavHandler
247 {
248 public:
249  void Fwd()
250  {
251  pythia_next_event();
252  }
253  void Bck()
254  {}
255 };
256 
257 //______________________________________________________________________________
258 void 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 
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
void SetCKIN(int i, double c)
Definition: TPythia6.h:219
Cylindrical tube class.
Definition: TGeoTube.h:19
virtual void StartEmbedding(Int_t pos=kRight, Int_t subpos=-1)
Start embedding external frame in the tab "pos" and tab element "subpos".
void SetMSUB(int i, int m)
Definition: TPythia6.h:218
Definition: Rtypes.h:61
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
void SetMDME(int i, int j, int m)
Definition: TPythia6.h:190
Float_t GetPy() const
Definition: TMCParticle.h:87
Float_t GetVy() const
Definition: TMCParticle.h:93
Description of the dynamic properties of a particle.
Definition: TParticle.h:34
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
#define gROOT
Definition: TROOT.h:364
Specialization of TRootBrowser for Eve.
Definition: TEveBrowser.h:128
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1819
Basic string class.
Definition: TString.h:137
#define gClient
Definition: TGClient.h:174
Int_t GetKF() const
Definition: TMCParticle.h:81
int Int_t
Definition: RtypesCore.h:41
void GenerateEvent()
generate event and copy the information from /HEPEVT/ to fPrimaries
Definition: TPythia6.cxx:297
const Bool_t kFALSE
Definition: Rtypes.h:92
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
virtual void SetMarkerColor(Color_t c)
Set marker color for the list and the elements.
Definition: TEveTrack.cxx:931
Definition: Rtypes.h:61
Definition: Rtypes.h:61
Int_t GetFirstChild() const
Definition: TMCParticle.h:83
TPythia is an interface class to F77 version of Pythia 6.2.
Definition: TPythia6.h:90
A list of TEveElements.
Definition: TEveElement.h:459
virtual const char * UnixPathName(const char *unixpathname)
Convert from a Unix pathname to a local pathname.
Definition: TSystem.cxx:1037
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
void SetMaxR(Double_t x)
Set maximum radius and rebuild tracks.
This class serves as a data storage for description of one particle.
Definition: TMCParticle.h:26
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:436
virtual void SetMarkerStyle(Style_t s)
Set marker style for the list and the elements.
Definition: TEveTrack.cxx:899
Definition: Rtypes.h:62
void SetMSTP(int i, int m)
Definition: TPythia6.h:230
A list of tracks supporting change of common attributes and selection based on track parameters...
Definition: TEveTrack.h:137
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1628
virtual void SetMainColor(Color_t c)
Set main (line) color for the list and the elements.
Definition: TEveTrack.cxx:803
void SetShape(TGeoShape *s)
Set TGeoShape shown by this object.
virtual void SetMainColor(Color_t color)
Set main color.
Definition: TEveShape.cxx:58
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
virtual void DestroyElements()
Destroy all children of this element.
void SetPMAS(int ip, int i, double m)
Definition: TPythia6.h:177
void Error(const char *location, const char *msgfmt,...)
short Color_t
Definition: RtypesCore.h:79
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:1137
Float_t GetVx() const
Definition: TMCParticle.h:92
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
void SetTabTitle(const char *title, Int_t pos=kRight, Int_t subpos=-1)
Set text "title" of Tab "subpos" in TGTab "pos".
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
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:507
char * Form(const char *fmt,...)
static double P[]
Float_t GetPx() const
Definition: TMCParticle.h:86
TEveTrackPropagator * GetPropagator()
Definition: TEveTrack.h:175
virtual void AddElement(TEveElement *el)
Add el to the list of children.
Holding structure for a number of track rendering parameters.
void SetMaxZ(Double_t x)
Set maximum z and rebuild tracks.
Visual representation of a track.
Definition: TEveTrack.h:32
void Warning(const char *location, const char *msgfmt,...)
Int_t GetKS() const
Definition: TMCParticle.h:80
TGTab * GetTabRight() const
Definition: TRootBrowser.h:145
virtual void SetMainTransparency(Char_t t)
Set main-transparency.
double Double_t
Definition: RtypesCore.h:55
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
Int_t GetLastChild() const
Definition: TMCParticle.h:84
virtual void SetMarkerSize(Size_t s)
Set marker size for the list and the elements.
Definition: TEveTrack.cxx:963
virtual void StopEmbedding(const char *name=0)
Definition: TRootBrowser.h:156
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
Definition: Rtypes.h:61
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
void SetMagField(Double_t bX, Double_t bY, Double_t bZ)
Set constant magnetic field and rebuild tracks.
An array of clone (identical) objects.
Definition: TClonesArray.h:32
virtual void MapWindow()
Definition: TGFrame.h:267
TEveEventManager * GetCurrentEvent() const
Definition: TEveManager.h:149
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
Definition: TEveGeoShape.h:23
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
void MakeTracks(Bool_t recurse=kTRUE)
Regenerate the visual representations of tracks.
Definition: TEveTrack.cxx:637
void SetMSEL(int m)
Definition: TPythia6.h:216
Float_t GetVz() const
Definition: TMCParticle.h:94
Float_t GetEnergy() const
Definition: TMCParticle.h:89
int GetMSTU(int i)
Definition: TPythia6.h:158
const Bool_t kTRUE
Definition: Rtypes.h:91
Float_t GetPz() const
Definition: TMCParticle.h:88
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
virtual TObjArray * GetListOfParticles() const
Definition: TGenerator.h:178
Float_t GetTime() const
Definition: TMCParticle.h:95