ȥå   ʬ Хåå   ñ측 ǽ   إ   ǽRSS

ROOT

Last-modified: 2014-11-05 () 16:23:09 (1323d)
Top / ROOT

ROOTγн(ROOTͤɤʤꤿ衢¿ʬϤȤ餤δط)

UsersGuideˤꡪ
ʥåե󥹤!


Minuit

MinuitȤ˺Ͽ

Ѽ

ޤminuit

TMinuit minui(9);

9ѿο

˴ؿƤ롣FCNȤ
줫顢

minuit.SetFCN(function);

Ǵؿ򥻥åȡؿϥѥ᡼Фƥեåƥ󥰤δȤʤ(^2,Likelihoodʤ)֤줬Ǿ(˺粽)褦ʥѥ᡼õɤȤǼ«롣«ͤʤɤϡminuit.GetParameter()ǤȤäƤ롣

줫顢ѿΥѥ᡼򥻥åȤ롣Ȥ

minuit.DefineParameter(0, "x", 0.0, 1.0, -200.0, 200.0);

ʤ顢0ܤxȤѿ0.0ͤǡƥåפ1.0ϰϤ-200.0200.ޤǡȤ̣ˤʤ롣
⤷ѿꤷȤˤϡ

minuit.FixParameter(0);

Ȥɤ0ѿֹ档

ºݤ˼¹ԤȤˤ

minuit.Migrad();

OKξMigradȤ르ꥺȤ¾ˤMinosȤ餷

«ʬ

եåƥ󥰤η̤ϡͤ˶ᤤȤ˼«ϤȽǤ뤿ΤҤȤĤδबEDM(Estimated Distance to the Minimum)ȤΡ줬⾮ʤäȤ˼«Ȥߤʤ
դˡ줬ߤƤʤȤˤϡ«ʤäȤ롣

ǥ쥯ȥΥեꥹȤȤƼ

TStyle::OpenDirectory()ʤɡROOTΥե򰷤ؿȤäƤäƤߤ롣

vector<TString> get_file_list( TString dir_name , TString extention ){//{{{

   void *dir = gSystem->OpenDirectory( dir_name );
   if (!dir) {
      cerr << "error opening directory " <<  dir_name << endl;
      return 0;
   }   

   vector<TString> fname; 
   const char *ent;
   while( ( ent = gSystem->GetDirEntry( dir ) ) ){
      if( *ent == '.' ) continue;
      if( *ent == '..' ) continue;

      TString fn = Form("%s", ent );
      if( fn.EndsWith( extention ) ){
         fname.push_back( ent );
      }   
   }   
 
   return fname;
} //}}}

get_file_list( dir_name , extention )dir_name˥ǥ쥯ȥΥѥơextention˳ĥҤ줿顢Υǥ쥯ȥˤ롢ꤷĥҤΥե̾vector<TString>Ȥ֤äƤ롣

Ϸ̤ʤɤTexηˤƽϤƤ

ޤޤ̤ȤɽȤϤƤƤ줬texʤʤɤ礬ΤǡŬ˥饹äfileMakeTex.h
Ȥϰʲ̤ꡣ

MakeTex *mt = new MakeTex();
mt->SetTitle( "test" );
mt->AddText( "\\section{aho no table}" );   //<- documentʬɵ롣\ϰĤǤϤ
mt->SetTableContent( 1 , 0 , "aho" ); //<-ɽꤿȤϤȤ(ԡ󡢥ƥ)ν֤
mt->SetTableContent( 0 , 1 , "baka" );
mt->AddTable(); //<-ɽɵ
mt->MakeTexFile("aho.tex"); //<-եϤ
delete mt;

ץꥢ֥ȤꤿȤϡDefaultPreambleȤȤ򤤤롣äȤꤿä顢ʬŬ˽񤭴롣
̤ϤʴΤǤ롣fileMakeTex_test.ps

եåȤȥ顼ޥȥꥯȤäƸɾ

Ȥ2ѿǥեåȤȤǻȤ

h1->Fit();
double e_mat[2][2];
gMinuit->mnemat( &e_mat[0][0] , 2 );
TGraph *chk_emat = (TGraph*)gMinuit->Contour( 100 , 0 , 1 );

뤳ȤǡեåȤȤΥ顼ޥȥå(Ǥ2x2ι)e_matǤ롣mnemat222롣
ѿؤߤ뤿ʱߤˤϡgMinuit->Contour򤹤ȤȤäƤ롣ϥդ軰ؤߤѿֹ򼨤

ROOTɽ

ɽߤˤƥǡ񤭽ФƤȤΤɽ饹fileTable.h (ROOT˸Τ뤫ɡդ󤫤äΤǺä)
Ȥ

Table *tb = new Table( "table" , 2 , 3 );//23Ԥɽ

tb->Set( 1 , 1 , "# of baka" , 0.07 ); //11ܤʸ,ǸΤϥ
tb->Set( 1 , 2 , "# of aho" , 0.07 );
tb->Set( 2 , 1 , 1. );
tb->Set( 2 , 2 , 2. );

tb->SetTitle("aho baka party");
TCanvas *c1 = new TCanvas();
tb->Draw();

ǡʤ󤬤Ǥ롣test.png

ʣROOTեȤ礹

ޤޤǤ虜虜TChainȤäƤäĤꡢTTreeǤ뤰󤷤ƤäĤƤɼ¤ϡ

hadd baka.root aho1.root aho2.root aho3.root 

aho?.rootbaka.root˥ޡ롣
ntupleҥȥޡ롣ʤƿޥɡ

TStringʸ

ʸ󥳥ޥɤ⡣

ޤ"aho.dat"ȤʸäƤȤˡŬ˿ƤƤĤեꤿȤȤ롣Ȥ

TString str = "aho.dat"
str.Insert( str.First( "." ) , "_1" );

Ȥȡ"."ľ"_1"ơ"aho_1.dat"ߤΤǤ롣
Ķ

ե¸ߤå

ʲΤ褦ˤ롣

FileStat_t info;
std::cout << "chk: " << gSystem->GetPathInfo( "ե/ǥ쥯ȥ̾" , info ) << std::endl;

ե뤬ϡGetPathInfo0֤ơʤ1֤

TTree礹

ʲΤ褦ˤOK

combined(){

TChain chain("h1");
TString fname;

for(Int_t i = 0;i  < 10;i++){
  fname = "root/file";fname += i;fname += ".root";
  chain.Add(fname);
}

chain.Merge("combined.root");

}

file0.rootfile9.rootޤǤ礷combined.rootȤե뤬Ǥ롣

ƥȤ

ƥȤ줿ȤˤϡTTextTLatexȤȤС

TText *t = new TText(0.1,0.1,"ahoaho");

뤬 Τޤ޲⤻DrawФȤCanvasˤƤ(ȤTH1F)ȤκɸξȤơ(0.1,0.1)ξɽ롣
Canvasкɸˤ

t->SetNDC(1);

ȤФ褤(ʤߤ˸᤹ΤSetNDC(0))
ȡ(0.1,0.1)Canvasx,y10%ξɽ롣

ҥȥ򥳥ԡ

ҥȥ򥳥ԡȤˤϡ

TH1F *hnew = (TH1F*)h->Clone();
hnew->SetName();

OK
SetName֤̾Τɤɬס

1٥Ȥĥǡߤ

roottupleΤʤ1٥ȤĤߤƤȤ롣
Ȥntuple.root

nt_aho

Ȥĥ꡼Ȥˡdataͤ򥤥٥ˤȤäƤޥϤʴ äƤΤϡadcȤͤȤäƤơ

TFile *f = new TFile("ntuple.root"); //ntuple.rootɤ߹

Double_t d_adc;    //ntupleǡȤäƤѿ
Int_t hit_adc = 0;

TTree *tr = =(TTree*)f->Get("nt_aho");     //nt_ahotr˴Ϣդ
tr->SetBranchAddress("adc" , &d_adc ); //nt_ahoΥǡ"adc"d_adcȤѿ˴ϢŤ롡

for(Int_t i = 0;i < tr->GetEntries();i++){ //nt_ahoΥȥ꡼(event)ο롼ײ
   tr->GetEntry( i ); //iܤΥ٥Ȥ˰ư
   
   if( d_adc > 200){ //adcͤ200ʾΤȤnhit_adc򥤥󥯥
     nhit_adc++;
   }

}

ǽd_adcΤ褦ŬѿƤơ

TTree *tr = =(TTree*)f->Get("nt_aho");

ǥĥ꡼Υɥ쥹ȤäƤơ

tr->SetBranchAddress("adc" , &d_adc );

ȤΤǡntĥ꡼adcȤΤd_adcȤѿ˴Ϣդ롣¾ΤߤȤϤιԤ䤻Ф
θ

for(Int_t i = 0;i < tr->GetEntries();i++){
   tr->GetEntry( i );
   ------
}

Ƥ뤬GetEntry뤳Ȥd_adcͤi٥ܤadcͤˤʤΤǡ롼פ뤳Ȥǡ1٥ȤĤߤƤ롣

ROOTC++ȤǻȤ

᤯äꤹ롣ڤä⤹롣 ǤȤ;뵻ѤǡȤʤʤʵѤ˿󤵤줿ޤ

GUIƤӽФäΤǤĴ٤

ĤФ

ɤޤȤơ

#include "TApplication.h"
--main--
TApplication theApp("App", &argc, argv);

ȤTApplication.hɤ߹ɤߤǤ&argcȤϲǤʤȤ

TGraphErrorsȤʤ

TGraphErrorsफĤΤǡˤʤ褦˳н񤭡

  • TGraphErrorsǥ󥸤
    Drawץ"A"ȤмưŪ˥󥸤Ƥ뤬ʣŤͤüˡǽΥդ˰ĥƤफĤ¸ߤˤʤ롣
    ȤΤframeȤ
    TH1F *frame = gPad->DrawFrame(Xstrat,Ystart,Xend,Yend);
    ǥ󥸤롣ΤȤ"A"ץס
    canvasʬ䤷ƤǤ⡢եƤcanvasŬ롣
  • TGraphErrorsǼ
    frameȤäƤ
    frame->GetXaxis()->SetTitle("xaxis");
    OK
  • 쥸ɤ
    Ƥʤǥ쥸ɤäƤΤʡĴ٤ƤФƤʤǤ狼->פΤȤߤǤ
    Ȥ
    TLegend *led = new TLegend(size,"");
    leg->AddEntry(graph,name,optoin(ex."apl"));
    ɲäƤ롣

    (2011.5.22)
    TGraphˤ줿ǡľܿꤿȤˤ
    for(int index = 0;index < g->GetN();index++){
      x = g->GetX()[index];
      xerr = g->GetErrorX(index);
      y = g->GetY()[index];
      yerr = g->GetErrorY(index);
    }
    ȤǤ롣

դξܥå򤤤

ȤfitФȤ

gStyle->SetOptFit();

ǽФƤ롦ΤޤޤȱˤʸΤǡ礭ѤˡΥ⡣
⤵Ѥ

gStyle->SetStatH(3);

Ѥ

gStyle->SetStatW(0.15);

եȤΥѤ

gStyle->SetStatFontSize(30);

¾ˤ⤤Ǥߤ


sameץɲäƽ񤭹Ȥˤ"same""sames"ˤ뤳ȤǡܥåϺ褵롣ΤȤˡɽΤ򥪥֥Ȥ˸ǤƤʤץܥå褵ʤ

2011.05.06ɵ:
ȤTH1FȤξܥåäȤˤ

TH1F *h;
h->Draw();
h->SetStats( 0 );

Ǿä롣

2013.5.1ɵ
ñ˾ܥåΰ֤ưȤȤϡ

gStyle->SetStatX( 0.2 );
gStyle->SetStatY( 0.9 );

ȤǤ롣礭SetStatW,HǤ롣

ROOTSharedObject

ޤ饤֥롣ȤŬexample.cc򼡤Τ褦˽񤯡

void aho(void){
  std::cout << "aho!" << std::endl;
}

ΤrootΩ夲ơ

>.x example.cc+

ȤСexample_C.soեƤ롣Ǵñ˥ʥߥå˴ؿʤ󤫤ɤ߹롣
gccǤȤ̤ΤǤܤߤǤ餷ɡͤϺޡ

θsoեϻĤΤǡޥ

gSystem->Load("example_C.so");

ȤƤС֥Ȥɤ߹롣dzڡץߥ󥰡

ROOTȤ

򻲹ͤˤƤ

x = gRandom->Gaus(0,3);

ǥʬۤ˽ȤäƤ롣meansigmaμϤĤäơ줾㤦ϼΤΤ롣

Rndm() or Uniform(min,max), Gaus(mean,sigma), Exp(tau), BreitWigner(mean,sigma),
Landau(mean,sigma), Poisson(mean), Binomial(ntot,prob)

ȤäƤʤߤˡgRandomȤˤ"TRandom.h"ɤ߹ɬפꡣ

ȡ˺줺ˡ

gRandom->SetSeed( time(NULL) )

NTuple˵ͤ

ȤСʴ

TNtuple *ntuple = new TNtuple("h3","castum1","iev:z:Lmu:nphot");
for(...){
  .....
  ntuple->Fill(i,Z[i],peak[i],NOP[i]);
}

TNtuple¤ΤƤȤ˵ͤǤ̾ꤷƤäơȤϵͤ ξh3Ȥ֥"iev","z","Lmu","nphot"Ȥ꡼դĤƤäƤ롣Ĥ1٥i˴ϢŤ줿֤ǵͤޤƤ ꤷꤷۤ褤ȤϤαѤǤ

äntuple¸ˤϼμƧOK

TFile *tmproot = new TFile("tmp.root","recreate");
(ޤˤ f->cd(); ʤȤʤȤ)
TNtuple *hnew = (TNtuple*)f->FindObject("hnew");
hnew->Write();
tmproot->Close();

ĤähnewΥݥ󥿤fȤFileõƤơätmprootȤȤwrite롣


TNtuopleˤϰ쵤14ĤޤǤFillǤʤʤΤǡĶȤˤ˵ͤǤäơϤʤηfloatˤʤȤʤ

ꤹOK

TLine *line = new TLine(88,0,88,-300);

Ǥ롣 ξ(88,0)(88,-300)ؤľƤ롣

gaussʬۤfitȤѤ򻻽

fitparameterΤȤgaussǤʤgaussnСfitparameter0(P0)Ѥˤʤ롣ϤñˡfitݤѿˤƤѥ᡼⤵ѤѤ

ROOTĶ

rootϤSGEꤲ

ޤ֤Ȥ򤵤ȤˡʬüǤäƤư٤ѡʤΤbsub¾Υޥ˻Ż򤵤롣
rootǵĤ뤳ȤDrawȤ˾canvaɽΤǡ

root -l -b -q aho.cc

Τ褦ˤ-b(Хå֥ե饰)θ̤ɽʤʤ롣-qϥޥ¹Ԥ龡˽λǡ줬ʤjobʤ
¹ԥ㡣

#!/bin/csh 

cd WORK_DIRECTORY
root -l -b -q ana4_jobs.cc


顼н

Ǥ顼Ǥ衪

Warning in <TROOT::Append>: Replacing existing TH1: h_aho (Potential memory leak).

TH1F򿨤äȤ˽Ф륨顼ɤⲿŤͤdelete⤻newƤΤߤ
롼פξѤơnewʤ褦ˤ顢ɽʤʤä


źեե: fileMakeTex.h 516 [ܺ] fileMakeTex_test.ps 527 [ܺ] filetest.png 865 [ܺ] fileTable.h 426 [ܺ]