ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 class TPythia6;
56 TPythia6 *g_pythia = 0;
57 
58 // Implemented in MultiView.C
59 class MultiView;
60 MultiView* gMultiView = 0;
61 
62 TEveTrackList *gTrackList = 0;
63 
64 //==============================================================================
65 // Forward decalarations of CINT functions.
66 //------------------------------------------------------------------------------
67 
68 void pythia_next_event();
69 void pythia_make_gui();
70 
71 //==============================================================================
72 // Main - pythia_display()
73 //------------------------------------------------------------------------------
74 
75 void run_pythia_display()
76 {
77  if (g_pythia != 0)
78  {
79  Warning("pythia_display()", "Already initialized.");
80  return;
81  }
82 
83  //========================================================================
84  //========================================================================
85 
86  // Create an instance of the Pythia event generator ...
87  g_pythia = new TPythia6;
88  TPythia6& P = * g_pythia;
89 
90  P.SetMSEL(0); // full user controll;
91  P.SetMSUB(102, 1); // g + g -> H0
92  //P.SetMSUB(123, 1); // f + f' -> f + f' + H0
93  //P.SetMSUB(124, 1); // f + f' -> f" + f"' + H0
94 
95  P.SetPMAS(6, 1, 175); // mass of TOP
96  P.SetPMAS(25, 1, 180); // mass of Higgs
97 
98 
99  P.SetCKIN(1, 170.0); // range of allowed mass
100  P.SetCKIN(2, 190.0);
101 
102  P.SetMSTP(61, 0); // switch off ISR
103  P.SetMSTP(71, 0); // switch off FSR
104  P.SetMSTP(81, 0); // switch off multiple interactions
105 
106  P.SetMSTP(111, 0); // Switch off fragmentation
107 
108  // Force h0 -> ZZ
109  for (Int_t i = 210; i <= 288; ++i)
110  P.SetMDME(i, 1, 0);
111  P.SetMDME(225, 1, 1);
112 
113  // Force Z -> mumu
114  for (Int_t i = 174; i <= 189; ++i)
115  P.SetMDME(i, 1, 0);
116  P.SetMDME(184, 1, 1);
117 
118 
119  P.Initialize("cms", "p", "p", 14000);
120 
121  //========================================================================
122  // Create views and containers.
123  //========================================================================
124 
126 
127  TEveElementList *fake_geom = new TEveElementList("Geometry");
128 
129  TEveGeoShape *b;
130 
131  b = new TEveGeoShape("Barell 1");
132  b->SetShape(new TGeoTube(kR_min, kR_max, kZ_d));
133  b->SetMainColor(kCyan);
134  b->SetMainTransparency(80);
135  fake_geom->AddElement(b);
136 
137  b = new TEveGeoShape("Barell 2");
138  b->SetShape(new TGeoTube(2*kR_min, 2*kR_max, 2*kZ_d));
139  b->SetMainColor(kPink-3);
140  b->SetMainTransparency(80);
141  fake_geom->AddElement(b);
142 
143  gEve->AddGlobalElement(fake_geom);
144 
145 
146  gMultiView = new MultiView;
147 
148  gMultiView->ImportGeomRPhi(fake_geom);
149  gMultiView->ImportGeomRhoZ(fake_geom);
150 
151  gEve->GetBrowser()->GetTabRight()->SetTab(1);
152 
153  gTrackList = new TEveTrackList("Pythia Tracks");
154  gTrackList->SetMainColor(kYellow);
155  gTrackList->SetMarkerColor(kRed);
156  gTrackList->SetMarkerStyle(4);
157  gTrackList->SetMarkerSize(0.5);
158  gEve->AddElement(gTrackList);
159 
160  TEveTrackPropagator* trkProp = gTrackList->GetPropagator();
161  trkProp->SetMagField(kMagField);
162  trkProp->SetMaxR(2*kR_max);
163  trkProp->SetMaxZ(2*kZ_d);
164 
165  //========================================================================
166  //========================================================================
167 
168  pythia_make_gui();
169  pythia_next_event();
170 
171  gEve->Redraw3D(kTRUE);
172 }
173 
174 
175 //==============================================================================
176 // Next event
177 //------------------------------------------------------------------------------
178 
179 void pythia_next_event()
180 {
181  gTrackList->DestroyElements();
182 
183  TPythia6& P = * g_pythia;
184 
185  P.GenerateEvent();
186 
187  int nh = P.GetMSTU(72);
188 
189  // printf("N = %d, Nhard = %d :: NumSec = %d, separators (%d,%d,%d,%d)\n",
190  // P.GetN(), nh, P.GetMSTU(70), P.GetMSTU(71), P.GetMSTU(72), P.GetMSTU(73), P.GetMSTU(74));
191  // 2->2 hard postfrag final
192 
193  TEveTrackPropagator *trkProp = gTrackList->GetPropagator();
195  for (Int_t i = 0; i < 7; ++i)
196  {
197  TMCParticle& p = (TMCParticle&)*MC[nh+i];
198  TParticle pb(p.GetKF(), p.GetKS(), 0, 0,
199  p.GetFirstChild()-nh-1, p.GetLastChild()-nh-1,
200  p.GetPx(), p.GetPy(), p.GetPz(), p.GetEnergy(),
201  p.GetVx(), p.GetVy(), p.GetVz(), p.GetTime());
202 
203  TEveTrack* track = new TEveTrack(&pb, i, trkProp);
204  track->SetName(Form("%s [%d]", pb.GetName(), i));
205  track->SetStdTitle();
206  track->SetAttLineAttMarker(gTrackList);
207  if (i == 0)
208  track->SetLineColor(kColors[0]);
209  else if (i <= 2)
210  track->SetLineColor(kColors[1]);
211 
212  gTrackList->AddElement(track);
213 
214  /*
215  printf("%d - %d %d %d %d %d %d\n", i,
216  p.GetKF(), p.GetKS(), 0, 0,
217  p.GetFirstChild()-nh-1, p.GetLastChild()-nh-1);
218  printf("%d - %f %f %f %f\n", i,
219  p.GetPx(), p.GetPy(), p.GetPz(), p.GetEnergy(),
220  printf("%d - %f %f %f %f\n", i,
221  p.GetVx(), p.GetVy(), p.GetVz(), p.GetTime());
222  */
223  }
224 
225  gTrackList->MakeTracks();
226 
227 
228  TEveElement* top = gEve->GetCurrentEvent();
229 
230  gMultiView->DestroyEventRPhi();
231  gMultiView->ImportEventRPhi(top);
232 
233  gMultiView->DestroyEventRhoZ();
234  gMultiView->ImportEventRhoZ(top);
235 
236  gEve->Redraw3D();
237 }
238 
239 
240 //==============================================================================
241 // GUI stuff
242 //------------------------------------------------------------------------------
243 class EvNavHandler
244 {
245 public:
246  void Fwd()
247  {
248  pythia_next_event();
249  }
250  void Bck()
251  {}
252 };
253 
254 //______________________________________________________________________________
255 void pythia_make_gui()
256 {
257  // Create minimal GUI for event navigation.
258 
259  TEveBrowser* browser = gEve->GetBrowser();
261 
262  TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
263  frmMain->SetWindowName("XX GUI");
264  frmMain->SetCleanup(kDeepCleanup);
265 
266  TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain);
267  {
268 
269  TString icondir( Form("%s/icons/", gSystem->Getenv("ROOTSYS")) );
270  TGPictureButton* b = 0;
271  EvNavHandler *fh = new EvNavHandler;
272 
273  b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
274  b->SetEnabled(kFALSE);
275  b->SetToolTipText("Go to previous event - not supported.");
276  hf->AddFrame(b);
277  b->Connect("Clicked()", "EvNavHandler", fh, "Bck()");
278 
279  b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
280  b->SetToolTipText("Generate new event.");
281  hf->AddFrame(b);
282  b->Connect("Clicked()", "EvNavHandler", fh, "Fwd()");
283  }
284  frmMain->AddFrame(hf);
285 
286  frmMain->MapSubwindows();
287  frmMain->Resize();
288  frmMain->MapWindow();
289 
290  browser->StopEmbedding();
291  browser->SetTabTitle("Event Control", 0);
292 }
293 
294 #endif
295 
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
virtual void StartEmbedding(Int_t pos=kRight, Int_t subpos=-1)
Start embedding external frame in the tab "pos" and tab element "subpos".
Int_t GetLastChild() const
Definition: TMCParticle.h:84
void SetMSUB(int i, int m)
Definition: TPythia6.h:218
Float_t GetPy() const
Definition: TMCParticle.h:87
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
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
void SetMDME(int i, int j, int m)
Definition: TPythia6.h:190
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:344
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:1766
Basic string class.
Definition: TString.h:137
#define gClient
Definition: TGClient.h:174
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
Float_t GetTime() const
Definition: TMCParticle.h:95
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
Int_t GetKS() const
Definition: TMCParticle.h:80
Definition: Rtypes.h:61
Definition: Rtypes.h:61
TPythia is an interface class to F77 version of Pythia 6.2.
Definition: TPythia6.h:90
TEveEventManager * GetCurrentEvent() const
Definition: TEveManager.h:149
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:1020
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:1575
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
Float_t GetPz() const
Definition: TMCParticle.h:88
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Int_t GetFirstChild() const
Definition: TMCParticle.h:83
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
Float_t GetVy() const
Definition: TMCParticle.h:93
Float_t GetVx() const
Definition: TMCParticle.h:92
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:1135
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
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
Int_t GetKF() const
Definition: TMCParticle.h:81
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,...)
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,...)
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
virtual void SetMarkerSize(Size_t s)
Set marker size for the list and the elements.
Definition: TEveTrack.cxx:963
Float_t GetPx() const
Definition: TMCParticle.h:86
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
Float_t GetEnergy() const
Definition: TMCParticle.h:89
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
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
Definition: TEveGeoShape.h:23
void MakeTracks(Bool_t recurse=kTRUE)
Regenerate the visual representations of tracks.
Definition: TEveTrack.cxx:637
virtual TObjArray * GetListOfParticles() const
Definition: TGenerator.h:178
Float_t GetVz() const
Definition: TMCParticle.h:94
void SetMSEL(int m)
Definition: TPythia6.h:216
int GetMSTU(int i)
Definition: TPythia6.h:158
const Bool_t kTRUE
Definition: Rtypes.h:91
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
TGTab * GetTabRight() const
Definition: TRootBrowser.h:145
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395