Skip to content

Instantly share code, notes, and snippets.

@pn11
pn11 / print_tree.cc
Last active August 29, 2015 14:06
指定したROOTファイルに含まれるTTreeの中身を表示するだけのプログラム。
#include<iostream>
#include<TList.h>
#include<TFile.h>
int main(int argc, char* argv[]){
using namespace std;
TFile *f1 = new TFile(argv[1]);
TList *l1 = f1->GetListOfKeys();
@pn11
pn11 / chi2_test_normalize_check.cc
Created September 10, 2014 03:06
ROOTのTH1:Chi2Test() (http://root.cern.ch/root/html/TH1.html#TH1:Chi2Test) がnormalizeしてるか確認した。
{
TH1D *h1 = new TH1D("h1", "h1", 3, 0, 3);
h1->Fill(1);
h1->Fill(1);
h1->Fill(2);
h1->Fill(2);
h1->Fill(2);
h1->Fill(2);
h1->Fill(3);
h1->Fill(3);
@pn11
pn11 / check_rms.cc
Created September 11, 2014 18:55
ROOTのTMath::RMS() (http://root.cern.ch/root/html/TMath.html#TMath:RMS) はRMSじゃなくて標準偏差を計算してるけど、それが標本標準偏差(?)なのか不偏標準偏差(?)なのか(標本数nで割ってるのかn-1で割ってるのか)調べた。結果、n-1で割ってた。
{
const int ndata = 10000;
double data[ndata];
TRandom *gaus = new TRandom();
for (int idata = 0; idata < ndata; idata++){
data[idata] = gaus->Gaus(0., 1.);
}
@pn11
pn11 / draw_Kolmogorov.cc
Created September 16, 2014 15:06
TMath::KolmogorovProb() (http://root.cern.ch/root/html/src/TMath.cxx.html#RDBIQ) のソースが良くわからない(c1, c2, c3という謎の係数が出てくる)のでちゃんと正しい値なのか描いてみた件。
{
Int_t npoint = 10000;
Double_t x, xstart = 0., xend = 2.0;
TGraph *g1 = new TGraph();
for (Int_t ipoint=0; ipoint<npoint; ipoint++){
x = xstart + (xend - xstart) / double(npoint) * double(ipoint);
g1->SetPoint(ipoint, x, TMath::KolmogorovProb(x));
}
g1->SetTitle("Kolmogorov distribution");
@pn11
pn11 / central_limit_theorem.cc
Last active August 29, 2015 14:06
中心極限定理を確かめて遊んでみた。(script for ROOT)
// 中心極限定理を確かめて遊んでみた。(script for ROOT)
{
int n = 10000;
int m = 2;
int nbin = 100;
double limit = 8.0;
double binwidth = 2.0*limit/double(nbin);
TH1D *h = new TH1D("h", "hist", nbin, - limit, limit);
@pn11
pn11 / hadd_and_rename.sh
Created September 30, 2014 06:03
haddしてから足しあわせた数をファイル名に追加するだけのスクリプト。while read 以下のloopの中でexprを使ってnadd+1をやろうとしたのになぜかできなかった。しかたないのでリダイレクトしてごにょごにょ。
#!/bin/bash
#hadd_and_rename.sh target.root sources.root
if [ $# -lt 2 ]
then
echo "Number of argument is wrong. Exit hadd_and_rename.sh..."
exit
fi
@pn11
pn11 / plot_Lindhard.cc
Created November 3, 2014 13:20
ROOT script for just calculating quenching factor of Si-28 by Lindhard eq. Lindhardの式でシリコンのQFを計算するだけのスクリプト。
{
double z = 14.; // atomic number
double a = 28.; // mass number
int npoint = 1000;
// double range[2] = {0., 1000.}; // 0 - 1 MeV
// double range[2] = {0., 100.}; // 0 - 100 keV
double range[2] = {0., 10.}; // 0 - 10 keV
@pn11
pn11 / ConvertMollweide.cc
Last active August 29, 2015 14:08
緯度、経度からモルワイデ図法での座標を出すプログラムをクラスの勉強をしながらつくった。定義はWikipediaに従う。テータはニュートン法で求める。 http://ja.wikipedia.org/wiki/%E3%83%A2%E3%83%AB%E3%83%AF%E3%82%A4%E3%83%87%E5%9B%B3%E6%B3%95
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
using namespace std;
class ConvertMollweide
@pn11
pn11 / myAm.mac
Last active August 29, 2015 14:14
Am-241 source defined with GPS.
#/tracking/verbose 0
/tracking/verbose 1
#/control/verbose 1
# /vis/viewer/set/targetPoint 0. 0. 0. cm
# /vis/viewer/set/targetPoint 12.5 0. 0. cm
#/vis/viewer/set/viewpointVector 1 1 1
/vis/viewer/set/viewpointVector 0 0 1
# Those method are from
@pn11
pn11 / backup_android.md
Created February 24, 2015 10:59
Mac (Homebrew) でAndroidをバックアップする

#Mac (Homebrew) でAndroidをバックアップする

##adbを入れる brew install android-platform-tools

##接続確認 AndroidのUSBデバッグモードをONにしてつないで

adb devices