Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files 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 #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 
128  TEveManager::Create();
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();
197  TClonesArray &MC = * (TClonesArray*) P.GetListOfParticles();
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();
263  browser->StartEmbedding(TRootBrowser::kLeft);
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