Difference between revisions of "GEMC at UNH"

From Nuclear Physics Group Documentation Pages
Jump to navigationJump to search
m
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page is going to start out nearly useless, but if I don't start it it will never be started, will it?
+
===Overview===
 +
Hall B at JLAB is upgrading their detector to 12GeV.  One part of the new detector array is the SVT,
 +
or Silicon Vertex Tracker.  UNH is helping to design the SVT, and develop the software which will
 +
interpret the output from the electronics. 
 +
For software, GEMC is the main program we will be working on.  It is built on GEANT4, which is basically
 +
a repository of the last 100 years of particle physics knowledge in easily-wrapped libraries.
  
Now then.
+
===Software Locations===
 
+
We have set-up a suite of software which will be necessary/useful to running GEMC in a shared directoryThe top directory is
We have set-up a suite of software which will be necessary/useful.  Generally it exists in
+
<pre>
 
/net/data/pumpkin2/CLAS12
 
/net/data/pumpkin2/CLAS12
 +
</pre>
 
Under this we have directories with binaries for a handful of platforms.
 
Under this we have directories with binaries for a handful of platforms.
The one of most interest currently is RHEL5_x64, which contains binaries compiled for Red Hat Enterprise Linux 5, AMD64.  It is the most interesting because it is the most complete, and it is suitable for use whilst SSHed to Pumpkin, the NPG's hardcore Opteron monster.
+
The most interesting one currently is RHEL5_x64, which contains binaries compiled for Red Hat Enterprise Linux 5, AMD64.  It is the most interesting because it is the most complete, and it is suitable for use whilst SSHed to Pumpkin, the NPG's hardcore Opteron monster.  Note that einstein and mariecurie are also RHEL5_64.
  
 +
===Using GEMC===
 
Speaking of which, do the following:
 
Speaking of which, do the following:
  
 
ssh to Pumpkin, forwarding the X protocol:
 
ssh to Pumpkin, forwarding the X protocol:
 +
<pre>
 
ssh -X you@pumkpin.unh.edu
 
ssh -X you@pumkpin.unh.edu
 +
</pre>
  
 
Now you will want to set-up your environment.  We have an example skeleton script at  
 
Now you will want to set-up your environment.  We have an example skeleton script at  
 
/net/data/pumpkin2/CLAS12/RHEL5_x64/env.sh
 
/net/data/pumpkin2/CLAS12/RHEL5_x64/env.sh
 
As Maurik pointed out, it does not do a lot of things it should.  For example, it does not scrub your environment of things which could cause trouble, as the stock GEANT4 environment scrupulously does.  In fact, you probably should copy it to your home directory and customize it.  One thing you will almost certainly want to do is export a value for the GEMC environment variable before using it.  Let's imagine that you don't need to customize it for the moment:
 
As Maurik pointed out, it does not do a lot of things it should.  For example, it does not scrub your environment of things which could cause trouble, as the stock GEANT4 environment scrupulously does.  In fact, you probably should copy it to your home directory and customize it.  One thing you will almost certainly want to do is export a value for the GEMC environment variable before using it.  Let's imagine that you don't need to customize it for the moment:
 +
<pre>
 
export GEMC=/net/data/pumpkin2/CLAS12/RHEL5_x64/GEMC
 
export GEMC=/net/data/pumpkin2/CLAS12/RHEL5_x64/GEMC
 
source /net/data/pumpkin2/CLAS12/RHEL5_x64/env.sh
 
source /net/data/pumpkin2/CLAS12/RHEL5_x64/env.sh
 +
</pre>
  
 
Great!  Things should basically just work now, at least somewhat.
 
Great!  Things should basically just work now, at least somewhat.
 
Let's try running GEMC:
 
Let's try running GEMC:
 +
<pre>
 
gemc
 
gemc
 +
</pre>
  
 
Now click in the File menu of the resulting G4UI Session and choose Quitter.  This should bring up the main GUI of GEMC.  Using what settings?  Who knows!  In a minute we will try specifying a few.  First explore the interface.  Note that you have some geometry in a viewer, plus a window with controls.  Try zooming and panning around, blah blah blah.
 
Now click in the File menu of the resulting G4UI Session and choose Quitter.  This should bring up the main GUI of GEMC.  Using what settings?  Who knows!  In a minute we will try specifying a few.  First explore the interface.  Note that you have some geometry in a viewer, plus a window with controls.  Try zooming and panning around, blah blah blah.
  
 
Now the useful stuff.  Try this:
 
Now the useful stuff.  Try this:
$GEMC/gemc -USE_QT=0 -GT=BST -N=1000 -PRINT_EVENT=100 -OUTPUT="evio, 1000protons.ev" -BEAM_P="proton, 2.0*GeV, 0*deg, 0*deg" -SPREAD_P="1.8*GeV, 180*deg, 360*deg" -SPREAD_V="(0.1, 0.1, 2.5)cm" -LUMI_P="e-, 11*GeV, 0, 0" -LUMI_V="(0, 0, -5)cm" -LUMI_EVENT="100, 124*ns, 2*ns" -USE_PHYSICSL=QGSP -HALL_MATERIAL=Vacuum
+
<pre>
 +
$GEMC/gemc -USE_QT=0 -GT=BST -N=1000 -PRINT_EVENT=100 -OUTPUT="evio, 1000protons.ev" \
 +
-BEAM_P="proton, 2.0*GeV, 0*deg, 0*deg" -SPREAD_P="1.8*GeV, 180*deg, 360*deg" \
 +
-SPREAD_V="(0.1, 0.1, 2.5)cm" -LUMI_P="e-, 11*GeV, 0, 0" -LUMI_V="(0, 0, -5)cm" \
 +
-LUMI_EVENT="100, 124*ns, 2*ns" -USE_PHYSICSL=QGSP -HALL_MATERIAL=Vacuum
 +
</pre>
 +
 
 +
This will run GEMC with no GUI (-USE_QT=0), using the geometry table BST (-GT=BST), simulating 1000 events (-N=1000), printing the progress every 100 events (-PRINT_EVENT=100), storing the output in EVIO format in the file 1000protons.ev (-OUTPUT="evio, 1000protons.ev"),  with a beam of protons of energy 2.0 GeV (-BEAM_P="proton, 2.0*GeV, 0*deg, 0*deg"), then there's something about the vertex I don't understand.  Also, some other stuff.
  
This will run GEMC with no GUI (-USE_QT=0), using the geometry table BST (-GT=BST), simulating 1000 events (-N=1000), printing the progress every 100 events (-PRINT_EVENT=100), storing the output in EVIO format in the file 1000protons.ev (-OUTPUT="evio, 1000protons.ev"),  with a beam of protons of energy 2.0 GeV (-BEAM_P="proton, 2.0*GeV, 0*deg, 0*deg"), then there's something about the vertex I don't understand.  Also, some other crap.
 
  
 +
===Analysis with ROOT===
 
Right.  So we've got this file with data now.  What do we do with it?  Let's analyze it with ROOT!
 
Right.  So we've got this file with data now.  What do we do with it?  Let's analyze it with ROOT!
 
But first we need to convert it from the EVIO format to that used by ROOT:
 
But first we need to convert it from the EVIO format to that used by ROOT:
 +
<pre>
 
$CLAS12ROOT/EVIO2ROOT/evio2root  
 
$CLAS12ROOT/EVIO2ROOT/evio2root  
 +
</pre>
  
 
Assuming you're still on pumpkin, and have your environment set-up reasonably, you should be able to just run ROOT by typing:
 
Assuming you're still on pumpkin, and have your environment set-up reasonably, you should be able to just run ROOT by typing:
 +
<pre>
 
root
 
root
 +
</pre>
  
 
This should start ROOT's interactive interpreter.  Start by running
 
This should start ROOT's interactive interpreter.  Start by running
 +
<pre>
 
TBrowser B;
 
TBrowser B;
 +
</pre>
 +
 
Now navigate the directory structure to find your ROOT file, and open it.
 
Now navigate the directory structure to find your ROOT file, and open it.
 +
Try double-clicking on a few trees to display the data in them.
 +
To quit ROOT, type
 +
<pre>
 +
.q
 +
</pre>
 +
 +
Skipping to ROOT examples:
 +
Looking at the relationship between different sets of data is far more useful than just the raw data.
 +
Try running this script:
 +
<pre>
 +
 +
//
 +
// Daniel Mannarino                        July 14, 2008
 +
//
 +
// This script reads in rootfiles and makes a plot of phi
 +
// vs. z for protons
 +
// --------------------------------------------------------
 +
//
 +
 +
 +
// All my standard ROOT includes...
 +
#include <TString.h>
 +
#include <string>
 +
#include <fstream>
 +
#include <iostream>
 +
#include <TCanvas.h>
 +
#include <TH1.h>
 +
#include <TH2.h>
 +
#include <TF1.h>
 +
#include <TH3F.h>
 +
#include <TFile.h>
 +
#include <TTree.h>
 +
#include <TROOT.h>
 +
#include <TStyle.h>
 +
#include <TApplication.h>
 +
#include <TPaveText.h>
 +
#include <TPaveStats.h>
 +
#include <TPaveLabel.h>
 +
#include <vector>
 +
#include <TProfile.h>
 +
#include <TF1.h>
 +
#include <TGraphErrors.h>
 +
#include <TMultiGraph.h>
 +
#include <TGraph.h>
 +
#include <TDatime.h>
 +
#include <TLegend.h>
 +
#include <TAxis.h>
 +
#include <TGaxis.h>
 +
#include <TPad.h>
 +
#include <TLatex.h>
 +
#include <TRandom.h>
 +
#include <stdio.h>
 +
#include <stdlib.h>
 +
#include <math.h>
 +
#include <TMath.h>
 +
#include <TMinuit.h>
 +
#include <TStopwatch.h>
 +
#include <TSpectrum.h>
 +
#include "TMath.h"
 +
 +
 +
// Interactive includes
 +
#include <TRint.h>
 +
#include <TApplication.h>
 +
#include <TGX11.h>
 +
#include <TVirtualX.h>
 +
#include <TFriendElement.h>
 +
 +
using namespace std ;
 +
 +
// Make tree a global variable so that we can access it outside this function.
 +
// You can then also access it from the command line.
 +
TTree *tree;
 +
 +
// ************  The main program starts here. ****************//
 +
 +
int main(int argc, char** argv)
 +
{
 +
 +
  ///////////////////////////////////////////
 +
  //  Initialize root, get our files and  //
 +
  // make them friends, create our canvas. //
 +
  ///////////////////////////////////////////
 +
  TApplication theApp("App", &argc, argv);
 +
  // gStyle->SetOptFit(0111);
 +
  gROOT->SetStyle("Plain");
 +
  gStyle->SetFillColor(10);
 +
 +
  ///////////////////////////////////////////
 +
  //  Proton files
 +
 +
  TFile *pro1 = new TFile("$DATA/proton_500000.root");
 +
  //Get bst tree
 +
  TTree *bst = (TTree*)pro1->Get("bstT");
 +
  bst->AddFriend("genT", "$DATA/proton_500000.root");
 +
 +
  ///////////////////////////////////////////
 +
  //  Pion files
 +
 +
/*
 +
  TFile *pi1 = new TFile("$DATA/pion_500000.root");
 +
  TTree *bst_pi = (TTree*)pi1->Get("bstT");
 +
  bst_pi->AddFriend("genT", "$DATA/pion_500000.root");
 +
*/
 +
 
 +
  ///////////////////////////////////////////
 +
  // Make your canvas
 +
 +
  TCanvas* MyCanvas1 = new TCanvas("MyCanvas1", "Some Graphs", 1);
 +
  MyCanvas1->SetFillColor(10);
 +
  TPaveLabel *title1 = NULL;
 +
  title1 = new TPaveLabel(0.1,0.96,0.9,0.99,"A Plot!  Yay!");
 +
  title1->SetFillColor(10);
 +
  //title1->Draw();
 +
  TDatime *now1;
 +
  now1 = new TDatime();
 +
  TPaveLabel *date1 = new TPaveLabel(0.7,0.01,0.9,0.03,now1->AsString());
 +
  date1->SetFillColor(10);
 +
  //date1->Draw();
 +
 +
  TPad* graphPad1 = new TPad("Graphs","Graphs",0.0,0.0,1.0,1.0);
 +
  graphPad1->SetFillColor(10);
 +
  graphPad1->Draw();
 +
  graphPad1->cd();
 +
 
 +
  ///////////////////////////////////////////
 +
  //  Create and fill our histos          //
 +
  ///////////////////////////////////////////
 +
 +
  TH2F *Edep_strip = new TH2F("Edep_strip","Edep vs. strip (Protons)",100,0,275,100,0,0.54);
 +
  Edep_strip->SetMarkerColor(40); 
 +
  bst->Draw("Edep:strip>>Edep_strip");
 +
 +
  ///////////////////////////////////////////
 +
  //  Draw our graphs                    //
 +
  ///////////////////////////////////////////
 +
  graphPad1->Clear();
 +
  gStyle->SetPalette(1,0);
 +
  Edep_strip->Draw("box");
 +
 +
// Draw a legend
 +
/*
 +
  TLegend *leg = new TLegend(0.4,0.6,0.89,0.89);
 +
  leg->SetTextSize(.03);
 +
  leg->AddEntry(Edep_strip,"Proton","p");
 +
  leg->SetFillColor(0);
 +
  leg->Draw();
 +
*/
 +
 +
// ------------------------------------------------
 +
 +
  // Main application eventloop. Calls system dependent eventloop
 +
  // -> runs an interactive interface
 +
  theApp.Run();
 +
 +
  return(0);
 +
 +
} /**********  End of main *************/
 +
 +
</pre>
 +
 +
Now look through the code and modify it to display and compare other values from the tree.
 +
 +
For more examples, check out the graphs and code at [[SVT_Results_at_UNH]]

Latest revision as of 19:34, 13 August 2008

Overview

Hall B at JLAB is upgrading their detector to 12GeV. One part of the new detector array is the SVT, or Silicon Vertex Tracker. UNH is helping to design the SVT, and develop the software which will interpret the output from the electronics. For software, GEMC is the main program we will be working on. It is built on GEANT4, which is basically a repository of the last 100 years of particle physics knowledge in easily-wrapped libraries.

Software Locations

We have set-up a suite of software which will be necessary/useful to running GEMC in a shared directory. The top directory is

/net/data/pumpkin2/CLAS12

Under this we have directories with binaries for a handful of platforms. The most interesting one currently is RHEL5_x64, which contains binaries compiled for Red Hat Enterprise Linux 5, AMD64. It is the most interesting because it is the most complete, and it is suitable for use whilst SSHed to Pumpkin, the NPG's hardcore Opteron monster. Note that einstein and mariecurie are also RHEL5_64.

Using GEMC

Speaking of which, do the following:

ssh to Pumpkin, forwarding the X protocol:

ssh -X you@pumkpin.unh.edu

Now you will want to set-up your environment. We have an example skeleton script at /net/data/pumpkin2/CLAS12/RHEL5_x64/env.sh As Maurik pointed out, it does not do a lot of things it should. For example, it does not scrub your environment of things which could cause trouble, as the stock GEANT4 environment scrupulously does. In fact, you probably should copy it to your home directory and customize it. One thing you will almost certainly want to do is export a value for the GEMC environment variable before using it. Let's imagine that you don't need to customize it for the moment:

export GEMC=/net/data/pumpkin2/CLAS12/RHEL5_x64/GEMC
source /net/data/pumpkin2/CLAS12/RHEL5_x64/env.sh

Great! Things should basically just work now, at least somewhat. Let's try running GEMC:

gemc

Now click in the File menu of the resulting G4UI Session and choose Quitter. This should bring up the main GUI of GEMC. Using what settings? Who knows! In a minute we will try specifying a few. First explore the interface. Note that you have some geometry in a viewer, plus a window with controls. Try zooming and panning around, blah blah blah.

Now the useful stuff. Try this:

$GEMC/gemc -USE_QT=0 -GT=BST -N=1000 -PRINT_EVENT=100 -OUTPUT="evio, 1000protons.ev" \
-BEAM_P="proton, 2.0*GeV, 0*deg, 0*deg" -SPREAD_P="1.8*GeV, 180*deg, 360*deg" \
-SPREAD_V="(0.1, 0.1, 2.5)cm" -LUMI_P="e-, 11*GeV, 0, 0" -LUMI_V="(0, 0, -5)cm" \
-LUMI_EVENT="100, 124*ns, 2*ns" -USE_PHYSICSL=QGSP -HALL_MATERIAL=Vacuum

This will run GEMC with no GUI (-USE_QT=0), using the geometry table BST (-GT=BST), simulating 1000 events (-N=1000), printing the progress every 100 events (-PRINT_EVENT=100), storing the output in EVIO format in the file 1000protons.ev (-OUTPUT="evio, 1000protons.ev"), with a beam of protons of energy 2.0 GeV (-BEAM_P="proton, 2.0*GeV, 0*deg, 0*deg"), then there's something about the vertex I don't understand. Also, some other stuff.


Analysis with ROOT

Right. So we've got this file with data now. What do we do with it? Let's analyze it with ROOT! But first we need to convert it from the EVIO format to that used by ROOT:

$CLAS12ROOT/EVIO2ROOT/evio2root 

Assuming you're still on pumpkin, and have your environment set-up reasonably, you should be able to just run ROOT by typing:

root

This should start ROOT's interactive interpreter. Start by running

TBrowser B;

Now navigate the directory structure to find your ROOT file, and open it. Try double-clicking on a few trees to display the data in them. To quit ROOT, type

.q

Skipping to ROOT examples: Looking at the relationship between different sets of data is far more useful than just the raw data. Try running this script:


//
// Daniel Mannarino                         July 14, 2008
//
// This script reads in rootfiles and makes a plot of phi
// vs. z for protons
// --------------------------------------------------------
//


// All my standard ROOT includes...
#include <TString.h>
#include <string> 
#include <fstream>
#include <iostream> 
#include <TCanvas.h> 
#include <TH1.h>
#include <TH2.h>
#include <TF1.h>
#include <TH3F.h>
#include <TFile.h>
#include <TTree.h> 
#include <TROOT.h>
#include <TStyle.h>
#include <TApplication.h>
#include <TPaveText.h>
#include <TPaveStats.h>
#include <TPaveLabel.h>
#include <vector>
#include <TProfile.h>
#include <TF1.h>
#include <TGraphErrors.h>
#include <TMultiGraph.h>
#include <TGraph.h>
#include <TDatime.h>
#include <TLegend.h>
#include <TAxis.h>
#include <TGaxis.h>
#include <TPad.h>
#include <TLatex.h>
#include <TRandom.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <TMath.h>
#include <TMinuit.h>
#include <TStopwatch.h>
#include <TSpectrum.h>
#include "TMath.h"


// Interactive includes
#include <TRint.h>
#include <TApplication.h>
#include <TGX11.h>
#include <TVirtualX.h>
#include <TFriendElement.h>

using namespace std ;

// Make tree a global variable so that we can access it outside this function.
// You can then also access it from the command line. 
TTree *tree;

// ************  The main program starts here. ****************//

int main(int argc, char** argv)
{

  ///////////////////////////////////////////
  //   Initialize root, get our files and  //
  // make them friends, create our canvas. //
  ///////////////////////////////////////////
  TApplication theApp("App", &argc, argv);
  // gStyle->SetOptFit(0111);
  gROOT->SetStyle("Plain");
  gStyle->SetFillColor(10); 

  ///////////////////////////////////////////
  //   Proton files

  TFile *pro1 = new TFile("$DATA/proton_500000.root");
  //Get bst tree
  TTree *bst = (TTree*)pro1->Get("bstT");
  bst->AddFriend("genT", "$DATA/proton_500000.root");

  ///////////////////////////////////////////
  //   Pion files

/*
  TFile *pi1 = new TFile("$DATA/pion_500000.root");
  TTree *bst_pi = (TTree*)pi1->Get("bstT");
  bst_pi->AddFriend("genT", "$DATA/pion_500000.root");
*/
  
  ///////////////////////////////////////////
  // Make your canvas

  TCanvas* MyCanvas1 = new TCanvas("MyCanvas1", "Some Graphs", 1);
  MyCanvas1->SetFillColor(10);
  TPaveLabel *title1 = NULL;
  title1 = new TPaveLabel(0.1,0.96,0.9,0.99,"A Plot!  Yay!");
  title1->SetFillColor(10);
  //title1->Draw();
  TDatime *now1;
  now1 = new TDatime();
  TPaveLabel *date1 = new TPaveLabel(0.7,0.01,0.9,0.03,now1->AsString());
  date1->SetFillColor(10);
  //date1->Draw();

   TPad* graphPad1 = new TPad("Graphs","Graphs",0.0,0.0,1.0,1.0);
  graphPad1->SetFillColor(10);
  graphPad1->Draw();
  graphPad1->cd();
  
  /////////////////////////////////////////// 
  //   Create and fill our histos          //
  ///////////////////////////////////////////

  TH2F *Edep_strip = new TH2F("Edep_strip","Edep vs. strip (Protons)",100,0,275,100,0,0.54);
  Edep_strip->SetMarkerColor(40);  
  bst->Draw("Edep:strip>>Edep_strip");

  ///////////////////////////////////////////
  //   Draw our graphs                     //
  ///////////////////////////////////////////
  graphPad1->Clear();
  gStyle->SetPalette(1,0);
  Edep_strip->Draw("box");
 
 // Draw a legend
/*
  TLegend *leg = new TLegend(0.4,0.6,0.89,0.89);
  leg->SetTextSize(.03);	
  leg->AddEntry(Edep_strip,"Proton","p");
  leg->SetFillColor(0);
  leg->Draw();
*/

 // ------------------------------------------------

  // Main application eventloop. Calls system dependent eventloop
  // -> runs an interactive interface 
  theApp.Run();

  return(0); 

} /**********  End of main *************/

Now look through the code and modify it to display and compare other values from the tree.

For more examples, check out the graphs and code at SVT_Results_at_UNH