Skip to content

Instantly share code, notes, and snippets.

@cvson
cvson / createMakeClass.C
Last active May 6, 2019 08:11
[Create root class] work with tree #ROOT #TTree #utils
void createMakeClass(char* filename="",char* treename="", char* classname=""){
TFile *pfile = new TFile(filename);
TTree *ptree = (TTree*)pfile->Get(treename);
ptree->MakeClass(classname);
}
@cvson
cvson / football_score.C
Last active May 6, 2019 08:13
[Football score] illustration football score #tutorials #MC #ROOT
//
// football_score.C
////////////////////////////////////////////////////
//
// Simple Monte Carlo
//
///////////////////////////////////////////////////
// Created by @visionlib.postach.io
{
const Int_t nteam = 4;
//
// trafficModeling.C
////////////////////////////////////////////////////
//
// Simple Monte Carlo for traffic modeling
//
///////////////////////////////////////////////////
// Created by @visionlib.postach.io
void titleStyle(TH2* h1){
h1->GetYaxis()->CenterTitle();
@cvson
cvson / duongbayvang.C
Last active May 6, 2019 08:12
[Duong Bay Vang] to check #root #traffic #lifeapp #tutorials
//http://us.24h.com.vn/tin-tuc-trong-ngay/su-that-ve-duong-bay-vang-qua-khong-phan-campuchia-c46a653855.html
void titleStyle(TH1* h1){
h1->GetYaxis()->CenterTitle();
h1->GetXaxis()->CenterTitle();
h1->GetXaxis()->SetLabelSize(h1->GetXaxis()->GetTitleSize()*1.2);
h1->GetYaxis()->SetLabelSize(h1->GetYaxis()->GetTitleSize()*1.2);
h1->GetXaxis()->SetTitleSize(h1->GetXaxis()->GetLabelSize()*1.2);
h1->GetYaxis()->SetTitleSize(h1->GetYaxis()->GetLabelSize()*1.2);
h1->GetYaxis()->SetTitleOffset(0.9);
h1->GetXaxis()->SetTitleOffset(0.9);
//
// mcintegral.C
////////////////////////////////////////////////////
//
// Simple Monte Carlo for integral
//
///////////////////////////////////////////////////
// Created by @visionlib.postach.io
void mcintegral(){
//this is to produce gif animation
////////////////////////////////////
// //
// @visionlib.postach.io //
// //
////////////////////////////////////
void titleStyle(TH1* h1){
h1->GetYaxis()->CenterTitle();
h1->GetXaxis()->CenterTitle();
h1->GetXaxis()->SetLabelSize(h1->GetXaxis()->GetTitleSize()*1.2);
h1->GetYaxis()->SetLabelSize(h1->GetYaxis()->GetTitleSize()*1.2);
# Seconds Count
133 1
134 7
135 1
136 4
137 3
138 3
141 7
142 24
143 13
@cvson
cvson / AppleScript-chrome-screenshot
Created August 27, 2014 03:47
Automatically screenshot webpage with AppleScript
-- set file name
set fileNames to "webshot-googleAnalytics"
tell application "Google Chrome"
-- open window with secret mode, if with normal mode then use {mode:"normal"}
set aWin to make new window with properties {mode:"normal"}
tell aWin
-- open new tab and set URL
set newTab to make new tab with properties {URL:"https://www.google.com/analytics/web/?et=&authuser=#report/visitors-overview/a38108925w74194420p76615924/"}
tell active tab
@cvson
cvson / gridWalk.C
Created August 25, 2014 01:57
Solve Random walk problem with Monte Carlo Method
{
TH2F *h = new TH2F("h","h",10,0,9,10,0,9);
TCanvas *c = new TCanvas("c","c");
c->Range(-0.3373713,-2.125,3.036341,9.125);
//new TCanvas;
//gPad->Range(-0.3373713,-2.125,3.036341,9.125);
gStyle->SetOptStat(0);
c->cd();
h->SetTitle("");
void titleStyle(TH1* h1){
h1->SetTitle("");
h1->GetYaxis()->CenterTitle();
h1->GetXaxis()->CenterTitle();
h1->GetXaxis()->SetLabelSize(h1->GetXaxis()->GetTitleSize()*1.4);
h1->GetYaxis()->SetLabelSize(h1->GetYaxis()->GetTitleSize()*1.4);
h1->GetXaxis()->SetTitleSize(h1->GetXaxis()->GetLabelSize()*1.2);
h1->GetYaxis()->SetTitleSize(h1->GetYaxis()->GetLabelSize()*1.2);
h1->GetYaxis()->SetTitleOffset(0.9);
}