- balewski's home page
- Posts
- 2013
- 2012
- 2011
- 2010
- 2009
- December (4)
- November (1)
- October (5)
- September (6)
- August (1)
- July (1)
- June (1)
- May (2)
- April (5)
- March (5)
- February (4)
- January (6)
- 2008
- December (1)
- November (1)
- September (3)
- July (1)
- June (4)
- April (2)
- March (2)
- February (3)
- January (2)
- 2007
- October (1)
- My blog
- Post new blog entry
- All blogs
root tricks
XXX - copied to Everonte
xxxxx
Change gray box display, put it in to .rootrc script
void rootlogon () { cout << "~/.rootrcdir/rootlogon.C is executing.\n"; gStyle->SetTitleBorderSize(0); gStyle->SetFrameFillColor(kWhite); // needed when using root v5 gStyle->SetCanvasColor(kWhite); // background is no longer mouse-dropping white gStyle->SetPalette(1,0); // blue to red false color palette. Use 9 for b/w gStyle->SetCanvasBorderMode(0); // turn off canvas borders gStyle->SetPadBorderMode(0); gStyle->SetPaintTextFormat("5.2f"); // What precision to put numbers if plotted with "TEXT" // For publishing: gStyle->SetLineWidth(2.); gStyle->SetTextSize(1.1); gStyle->SetLabelSize(0.06,"xy"); gStyle->SetTitleSize(0.06,"xy"); gStyle->SetTitleOffset(1.2,"x"); gStyle->SetTitleOffset(1.0,"y"); gStyle->SetPadTopMargin(0.1); gStyle->SetPadRightMargin(0.1); gStyle->SetPadBottomMargin(0.16); gStyle->SetPadLeftMargin(0.12); }
Moving of stats Box
h->Draw(); // need it here to create stats-box can->Update(); // need it here to get access to stats-box TPaveStats *statsbox =( TPaveStats *st ) h->GetListOfFunctions()->FindObject("stats"); statsbox->SetX1NDC(0.18); statsbox->SetY1NDC(0.70); statsbox->SetX2NDC(0.48); statsbox->SetY2NDC(0.95); h->Draw(); // need it to see new position of stat box
Arbitrary division of Canvas
Use case:
sprintf(padTit,"Selected high PT tracks, %s",core0);
can=new TCanvas("aa","aa",800,600); TPad *c0=makeTitle(can,padTit,page);
TPad *cL,*cR; splitPadX(0.4,&cL,&cR);
cR->cd(); cR->Divide(2,2);
cR->cd(1); h->Draw();
int mxRow=3, kRow=1;
//Use case:
int page=1;
TString padTit=Form("Boiling runs ");
can=new TCanvas("aa","aa",800,600); TPad *c0=makeTitle(can,padTit,page);
splitPadX(0.7,&cL,&cR);
cL->cd(); cL->Divide(1,mxRow);
cR->cd(); cR->Divide(1,mxRow);
for(int i=0;i<runL.size();i++) {
int runNo=runL[i];
processRun(runNo,kRow) ;
kRow++;
if(kRow>mxRow) break;
}
char *core0="boling";
char *oPath="./out/";
int pl=2;
TString canTit=Form("%s_page%03d",core0,page);
can->SetTitle(canTit);
can->SetName(canTit);
if(pl&2) can->Print(oPath+canTit+".ps");
//------------------------
TPad *makeTitle(TCanvas *c,char *core, int page) {
c->Range(0,0,1,1);
TPad *pad0 = new TPad("pad0", "apd0",0.0,0.95,1.,1.);
pad0->Draw();
pad0->cd();
TPaveText *pt = new TPaveText(0,0.,1,1,"br");
pt->Draw();
TDatime dt;
TString txt2=core;
txt2+=", page=";
txt2+=page;
txt2+=", ";
txt2+=dt.AsString();
pt->AddText(txt2);
txt2="--";
pt->AddText(txt2);
c->cd();
pad = new TPad("pad1", "apd1",0.0,0.0,1,.95);
pad->Draw();
return pad;
}
Arbitrary X, Y-split of Canvas
//------------------------ void splitPadX(float x, TPad **cL, TPad **cR) { (*cL) = new TPad("padL", "apdL",0.0,0.,x,0.95); (*cL)->Draw(); (*cR) = new TPad("padL", "apdL",x+0.005,0.,1.0,0.95); (*cR)->Draw(); } //------------------------ void splitPadY(float y, TPad **cU, TPad **cD) { (*cU) = new TPad("padD", "apdD",0,y+0.005,1.0,1.); (*cU)->Draw(); (*cD) = new TPad("padU", "apdU",0.0,0.,1.,y); (*cD)->Draw(); /* use case: TPad *cU,*cD; splitPadY(0.4,&cU,&cD); cU->cd(); h->Draw() */ }
gROOT->Macro("loadMuDst.C");
char* dbDate = "2009-01-01 00:00:00";
StBemcTablesWriter *bemctables = new StBemcTablesWriter();
bemctables->loadTables(dbDate);
qiuh@rcf.rhic.bnl.gov wrote:
Hi Matthew.Do you have an example macro or several command lines to use this StBemcTablesWriter?
Thank you.Hao
use STAR Geometry Browser
- Start Browser
- Select the vesion of geometry you need
You an start browser with your custom dewfautl to avoid the
selection
for example
root4star GeomBrowse.C("upg16");
The other versions will be availabe too (as ususally) however upg16 will be the default one.
- choose the top volume you want to vizualiza and doubel click it.
- Activate 3D views:
-Navigate
I want the top edge of the histo is much closer to the yellow line - marking the begin of the second pad.
canvas->Divide(1, 2, 0.001, 0.001); canvas->cd(2); gPad->SetTopMargin(0.01); Four margins between the histogram and pad borders are: gPad->SetTopMargin(), gPad->SetBottomMargin(), gPad->SetLeftMargin(), gPad->SetRightMargin(). Regards, Oleksandr
recompile root with new library ( I needed gdml to display some graphics)
You can go to $ROOTSYS and run:
./configure `cat ./config.status` --enable-gdml
This will preserve the existing config options and add gdml to them.
Loop over all objects in the hist.root file
void jan(const char* filename = "allpt.root") { TFile* file = TFile::Open(filename); assert(filename); TIter next(file->GetListOfKeys()); TKey* key; while (key = (TKey*)next()) { TH1F* h1 = (TH1F*)key->ReadObj(); h1->Draw(); break; } }
- balewski's blog
- Login or register to post comments