Skip to content

Commit

Permalink
Basic script and histogram creation examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hansenjo committed May 22, 2018
1 parent 662c6bc commit ae972f1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions add42.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
int add42(int value) {
return value+42;
}
int add53(int value) {
return value+53;
}
14 changes: 14 additions & 0 deletions make_2D.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "TH2F.h"
#include "TRandom.h"

TH2* h2D;

void make_2D()
{
h2D = new TH2F("h2D","2D Gaussian peak",160,-4.,4.,160,-4.,4.);
for( int i=0; i<100000; ++i ) {
double x = gRandom->Gaus(0,1);
double y = gRandom->Gaus(1,2);
h2D->Fill(x,y);
}
}
16 changes: 16 additions & 0 deletions make_histos.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "TH1I.h"
#include "TRandom.h"

TH1 *h1, *h2;

void make_histos() {
h1 = new TH1I("h1","Gaussian distribution",160,-4.,4.);
h2 = new TH1I("h2","Shifted narrower Gaussian",160,-4.,4.);
for ( int i=0; i<10000; ++i ) {
double x;
x = gRandom->Gaus(0,1);
h1->Fill(x);
x = gRandom->Gaus(0.2,0.8);
h2->Fill(x);
}
}
14 changes: 14 additions & 0 deletions make_prof.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "TProfile.h"
#include "TRandom.h"

TProfile* hp;

void make_prof()
{
hp = new TProfile("hp","Profile of shifted Gaussian",160,-4.,4.);
for( int i=0; i<100000; ++i ) {
double x = gRandom->Gaus(0,1);
double y = gRandom->Gaus(1,2);
hp->Fill(x,y);
}
}

0 comments on commit ae972f1

Please sign in to comment.