pythia_display.C

Go to the documentation of this file.
00001 //
00002 // Demo showing H -> ZZ -> 4 mu generated by Pythia.
00003 // Requires libPythia6.
00004 
00005 //==============================================================================
00006 // Constants.
00007 //------------------------------------------------------------------------------
00008 
00009 const Double_t kR_min = 240;
00010 const Double_t kR_max = 250;
00011 const Double_t kZ_d   = 300;
00012 
00013 // Solenoid field along z, in Tesla.
00014 const Double_t kMagField = 4;
00015 
00016 // Color for Higgs, Zs and muons
00017 const Color_t  kColors[3] = { kRed, kGreen, kYellow };
00018 
00019 //==============================================================================
00020 // Global variables.
00021 //------------------------------------------------------------------------------
00022 
00023 class TPythia6;
00024 TPythia6   *g_pythia = 0;
00025 
00026 // Implemented in MultiView.C
00027 class MultiView;
00028 MultiView* gMultiView = 0;
00029 
00030 TEveTrackList *gTrackList = 0;
00031 
00032 //==============================================================================
00033 // Forward decalarations of CINT functions.
00034 //------------------------------------------------------------------------------
00035 
00036 void pythia_next_event();
00037 void pythia_make_gui();
00038 
00039 //==============================================================================
00040 // Main - pythia_display()
00041 //------------------------------------------------------------------------------
00042 
00043 void pythia_display()
00044 {
00045    if (g_pythia != 0)
00046    {
00047       Warning("pythia_display()", "Already initialized.");
00048       return;
00049    }
00050 #ifndef G__WIN32 // libPythia6 is a static library on Windoze
00051    if (gSystem->Load("libPythia6") < 0)
00052    {
00053       Error("pythia_display()",
00054             "Could not load 'libPythia6', make sure it is available!");
00055       return;
00056    }
00057 #endif
00058    gSystem->Load("libEGPythia6");
00059 
00060    if (gROOT->LoadMacro("MultiView.C+") != 0)
00061    {
00062       Error("pythia_display()", "Failed loading MultiView.C in compiled mode.");
00063       return;
00064    }
00065 
00066    //========================================================================
00067    //========================================================================
00068 
00069    // Create an instance of the Pythia event generator ... 
00070    g_pythia = new TPythia6; 
00071    TPythia6& P = * g_pythia;
00072 
00073    P.SetMSEL(0);           // full user controll;
00074    P.SetMSUB(102, 1);      // g + g -> H0
00075    //P.SetMSUB(123, 1);    // f + f' -> f + f' + H0
00076    //P.SetMSUB(124, 1);    // f + f' -> f" + f"' + H0
00077 
00078    P.SetPMAS(6,  1, 175);  // mass of TOP
00079    P.SetPMAS(25, 1, 180);  // mass of Higgs
00080 
00081 
00082    P.SetCKIN(1, 170.0);    // range of allowed mass
00083    P.SetCKIN(2, 190.0);
00084 
00085    P.SetMSTP(61, 0);   // switch off ISR
00086    P.SetMSTP(71, 0);   // switch off FSR
00087    P.SetMSTP(81, 0);   // switch off multiple interactions
00088 
00089    P.SetMSTP(111, 0);  // Switch off fragmentation
00090 
00091    // Force h0 -> ZZ
00092    for (Int_t i = 210; i <= 288; ++i)
00093       P.SetMDME(i, 1, 0);
00094    P.SetMDME(225, 1, 1);
00095 
00096    // Force Z -> mumu
00097    for (Int_t i = 174; i <= 189; ++i)
00098       P.SetMDME(i, 1, 0);
00099    P.SetMDME(184, 1, 1);
00100 
00101 
00102    P.Initialize("cms", "p", "p", 14000);
00103 
00104    //========================================================================
00105    // Create views and containers.
00106    //========================================================================
00107 
00108    TEveManager::Create();
00109 
00110    TEveElementList *fake_geom = new TEveElementList("Geometry");
00111 
00112    TEveGeoShape *b;
00113 
00114    b = new TEveGeoShape("Barell 1");
00115    b->SetShape(new TGeoTube(kR_min, kR_max, kZ_d));
00116    b->SetMainColor(kCyan);
00117    b->SetMainTransparency(80);
00118    fake_geom->AddElement(b);
00119 
00120    b = new TEveGeoShape("Barell 2");
00121    b->SetShape(new TGeoTube(2*kR_min, 2*kR_max, 2*kZ_d));
00122    b->SetMainColor(kPink-3);
00123    b->SetMainTransparency(80);
00124    fake_geom->AddElement(b);
00125 
00126    gEve->AddGlobalElement(fake_geom);
00127 
00128 
00129    gMultiView = new MultiView;
00130 
00131    gMultiView->ImportGeomRPhi(fake_geom);
00132    gMultiView->ImportGeomRhoZ(fake_geom);
00133 
00134    gEve->GetBrowser()->GetTabRight()->SetTab(1);
00135 
00136    gTrackList = new TEveTrackList("Pythia Tracks"); 
00137    gTrackList->SetMainColor(kYellow);
00138    gTrackList->SetMarkerColor(kRed);
00139    gTrackList->SetMarkerStyle(4);
00140    gTrackList->SetMarkerSize(0.5);
00141    gEve->AddElement(gTrackList);
00142 
00143    TEveTrackPropagator* trkProp = gTrackList->GetPropagator();
00144    trkProp->SetMagField(kMagField);
00145    trkProp->SetMaxR(2*kR_max);
00146    trkProp->SetMaxZ(2*kZ_d);
00147 
00148    //========================================================================
00149    //========================================================================
00150 
00151    pythia_make_gui();
00152    pythia_next_event();
00153 
00154    gEve->Redraw3D(kTRUE);
00155 }
00156 
00157 
00158 //==============================================================================
00159 // Next event
00160 //------------------------------------------------------------------------------
00161 
00162 void pythia_next_event()
00163 {
00164    gTrackList->DestroyElements();
00165 
00166    TPythia6& P = * g_pythia;
00167 
00168    P.GenerateEvent();
00169 
00170    int nh = P.GetMSTU(72);
00171 
00172    // printf("N = %d, Nhard = %d :: NumSec = %d, separators (%d,%d,%d,%d)\n",
00173    //    P.GetN(), nh, P.GetMSTU(70), P.GetMSTU(71), P.GetMSTU(72), P.GetMSTU(73), P.GetMSTU(74));
00174    //                          2->2                 hard                  postfrag              final
00175 
00176    TEveTrackPropagator *trkProp = gTrackList->GetPropagator();
00177    TClonesArray        &MC      = * (TClonesArray*) P.GetListOfParticles();
00178    for (Int_t i = 0; i < 7; ++i)
00179    {
00180       TMCParticle& p = * MC[nh+i];
00181       TParticle pb(p.GetKF(), p.GetKS(), 0, 0,
00182                    p.GetFirstChild()-nh-1, p.GetLastChild()-nh-1,
00183                    p.GetPx(), p.GetPy(), p.GetPz(), p.GetEnergy(),
00184                    p.GetVx(), p.GetVy(), p.GetVz(), p.GetTime());
00185 
00186       TEveTrack* track = new TEveTrack(&pb, i, trkProp);
00187       track->SetName(Form("%s [%d]", pb.GetName(), i));
00188       track->SetStdTitle();
00189       track->SetAttLineAttMarker(gTrackList);
00190       if (i == 0)
00191          track->SetLineColor(kColors[0]);
00192       else if (i <= 2)
00193          track->SetLineColor(kColors[1]);
00194 
00195       gTrackList->AddElement(track);
00196       
00197       /*
00198         printf("%d - %d %d %d %d %d %d\n", i,
00199         p.GetKF(), p.GetKS(), 0, 0,
00200         p.GetFirstChild()-nh-1, p.GetLastChild()-nh-1);
00201         printf("%d - %f %f %f %f\n", i,
00202         p.GetPx(), p.GetPy(), p.GetPz(), p.GetEnergy(),
00203         printf("%d - %f %f %f %f\n", i,
00204         p.GetVx(), p.GetVy(), p.GetVz(), p.GetTime());
00205       */
00206    }
00207 
00208    gTrackList->MakeTracks();
00209 
00210 
00211    TEveElement* top = gEve->GetCurrentEvent();
00212 
00213    gMultiView->DestroyEventRPhi();
00214    gMultiView->ImportEventRPhi(top);
00215 
00216    gMultiView->DestroyEventRhoZ();
00217    gMultiView->ImportEventRhoZ(top);
00218 
00219    gEve->Redraw3D();
00220 }
00221 
00222 
00223 //==============================================================================
00224 // GUI stuff
00225 //------------------------------------------------------------------------------
00226 class EvNavHandler
00227 {
00228 public:
00229    void Fwd()
00230    {
00231       pythia_next_event();
00232    }
00233    void Bck()
00234    {}
00235 };
00236 
00237 //______________________________________________________________________________
00238 void pythia_make_gui()
00239 {
00240    // Create minimal GUI for event navigation.
00241 
00242    TEveBrowser* browser = gEve->GetBrowser();
00243    browser->StartEmbedding(TRootBrowser::kLeft);
00244 
00245    TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
00246    frmMain->SetWindowName("XX GUI");
00247    frmMain->SetCleanup(kDeepCleanup);
00248 
00249    TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain);
00250    {
00251       
00252       TString icondir( Form("%s/icons/", gSystem->Getenv("ROOTSYS")) );
00253       TGPictureButton* b = 0;
00254       EvNavHandler    *fh = new EvNavHandler;
00255 
00256       b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
00257       b->SetEnabled(kFALSE);
00258       b->SetToolTipText("Go to previous event - not supported.");
00259       hf->AddFrame(b);
00260       b->Connect("Clicked()", "EvNavHandler", fh, "Bck()");
00261 
00262       b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
00263       b->SetToolTipText("Generate new event.");
00264       hf->AddFrame(b);
00265       b->Connect("Clicked()", "EvNavHandler", fh, "Fwd()");
00266    }
00267    frmMain->AddFrame(hf);
00268 
00269    frmMain->MapSubwindows();
00270    frmMain->Resize();
00271    frmMain->MapWindow();
00272 
00273    browser->StopEmbedding();
00274    browser->SetTabTitle("Event Control", 0);
00275 }

Generated on Tue Jul 5 15:43:52 2011 for ROOT_528-00b_version by  doxygen 1.5.1