Draw Feynman Diagrams Using ROOT

It is needless to say that ROOT Data Analysis Framework provides tons of great tools to write a scientific article. But it happened one more time again and i had a great respect for ROOT after i learned that one can also draw Feynman Diagrams as well.

Although there are alternative ways of drawing the diagrams of your scientific article, why not drawing them using the tool by which you made the analysis ? It’s easier!

Here i am presenting a little code to modify or to use directly just changing some variables. Actually i have just drown a simple S-Channel scattering and i’m leaving the rest of the work to you.

USAGE:

  • Copy the code below and paste it on a text file.
  • Click “Save as” and name the file as workDiagram.C (which is a name for ROOT macro)
  • Open your console and run ROOT writing “root” at the directory you saved workDiagram.C file
  • .L workDiagram.C (Load the file)
  • simpleSCh() (Run the function)
  • You will see something like a compton scattering diagram but the labels are wrong. You can change labels right clicking on them.
  • FEATURES:
    After running the script on the canvas that ROOT opened for you;

  • You can change the labels and their positions by right clicking on
  • You can rearrange the size of the picture by dragging the edge of the window
  • You can right click on the line and choose “SetLineAttributes” and at the “shape” tab you can rearrange its direction.
  • By Drag&Dropping you can change any of the elements on the screen
  • Click “File” and choose “Save as”. You will see that you can save your diagram almost any formats: ps, eps, svc, pdf, jpg, gif, xml, tiff, ..etc.
  • TIPS:

  • Drawing Higss Boson: Right Click on the line and choose “SetLineAttributes” and then make the line dashed choosing at combo box options.
  • Drawing Photon, Ws and Zs: Run script using the variables simpleSCh(“zigzag”,”zigzag”,”zigzag”,”zigzag”,”zigzag”). The first and second variables represents the incoming particles. The third one represents middle propagator and the last two one is outgoing particles.
  • Drawing gluons: Run script using the variables simpleSCh(“curly”,”curly”,”curly”,”curly”,”curly”).
  • Drawing fermions: Run script with default variables simpleSCh() or simpleSCH (“”,””,””,””,””)
    void simpleSCh(char *a="",char *b="",char *c="",char *d="",char *e="")
    {
    //Draw Feynman diagrams
    //Open Source ROOT Script Library
    //Author: Sinan Kuday
    
    TCanvas *c1 = new TCanvas("c1", "A canvas", 10,10, 500, 300);
    c1->SetFillColor(0);
    c1->Range(0, 0, 140, 60);
    Int_t linsav = gStyle->GetLineWidth();
    gStyle->SetLineWidth(3);
    TLatex t;
    t.SetTextAlign(20);
    t.SetTextSize(0.1);
    switch(a){
    case "zigzag":
    TCurlyLine *lt = new TCurlyLine(10,50,40,30); lt->SetWavy();
    break;
    case "curly":
    TCurlyLine *lt = new TCurlyLine(10,50,40,30);
    break;
    default:
    lt = new TArrow(10, 50, 40, 30, 0.03,"->|-"); 			break; 	} 	lt->Draw();
    
    switch (b) {
    case "zigzag":
    TCurlyLine *lb = new TCurlyLine(10, 10, 40, 30); lb->SetWavy();
    break;
    case "curly":
    TCurlyLine *lb = new TCurlyLine(10, 10, 40, 30);
    break;
    default:
    TArrow *lb; lb = new TArrow(10, 10, 40, 30, 0.03,"-|>-");
    break;
    }
    lb->Draw();
    
    t.DrawLatex(24,10,"e^{-}");
    t.DrawLatex(24,46,"e^{+}");
    
    switch (c) {
    case "zigzag":
    TCurlyLine *middle = new TCurlyLine(40, 30, 100, 30);
    middle->SetWavy();
    break;
    case "curly":
    TCurlyLine *middle = new TCurlyLine(40, 30, 100, 30);
    break;
    default:
    TArrow *middle; middle = new TArrow(40, 30, 100, 30, 0.03,"-|>-");
    break;
    }
    middle->Draw();
    
    t.DrawLatex(72,36,"#gamma");
    
    switch (d) {
    case "zigzag":
    TCurlyLine *rt = new TCurlyLine(100, 30, 130, 10);
    rt->SetWavy();
    break;
    case "curly":
    TCurlyLine *rt = new TCurlyLine(100, 30, 130, 10);
    break;
    default:
    TArrow *rt; rt = new TArrow(100, 30, 130, 10, 0.03,"-<|-"); 			break; 	} 	rt->Draw();
    
    switch (e) {
    case "zigzag":
    TCurlyLine *rb = new TCurlyLine(100, 30, 130, 50);
    rb->SetWavy();
    break;
    case "curly":
    TCurlyLine *rb = new TCurlyLine(100, 30, 130, 50);
    break;
    default:
    TArrow *rb; rb = new TArrow(100, 30, 130, 50, 0.03,"-<|-"); 			break; 	} 	rb->Draw();
    
    t.DrawLatex(113,10,"#bar{q}");
    t.DrawLatex(113,46,"q");
    
    c1->Update();
    gStyle->SetLineWidth(linsav);
    }
    
  • Tags:

    About Kuday

    Pure Mind

    One response to “Draw Feynman Diagrams Using ROOT”

    1. Eduardo Alves Coelho says :

      Helped me a lot!! Thanks, Kuday.

    Leave a comment