Saturday, July 30, 2011

Updating Firefox on Ubuntu

I can't find a solid reason to update my browser (unless some site or software that I use asks me to). Today I got tempted by a message on my gmail account asking me to do that. So here is how to do it:

sudo add-apt-repository ppa:mozillateam/firefox-stable
sudo apt-get update
sudo apt-get upgrade
 

This was method 2 among 3 ways to do it that I found under this post.

One new feature Firefox5 has is the Sync feature. So now you can have all your tabs and browsing needs saved (safely as I hope) and you can access then from any machine.

Tuesday, July 12, 2011

Editing PDF files on linux, Two solutions

Since most our meetings and seminars are presented as PDF files. I finally realised that I need some way to edit them on Linux. Something as simple as adding comments and such would do. couple of research attempts lead me to the following link:
http://www.cyberciti.biz/tips/open-source-linux-pdf-writer.html


I tried PDFedit instantly and it did deliver what it promised. the only problem is the limited selection of arrow shapes (hard to use for Feynman diagrams).


To install and run:
$ sudo apt-get install pdfedit
$ pdfedit /path/to/pdf.file & 

The code runs smoothly but has it's limits; If the document had symbols unrecognised by it (Say Japanese characters or Math symbols). It will open but with many of it's functions missing. 

Another option is Open office! They new release (3.0 and after) has a package that is able to open PDF files on a drawing pad. you will even get to stick comments and such. This approach also suffers when opening some unrecognised set of fonts or objects. It will still be fully functional but the locations will be misset up as well as missing some symbols. 

We conclude this note with Images. Where your best bed is with GIMP. Which is a standard release in UBUNTU. Once you do the changes make sure to save as xcf. then using the command:
$  convert file.xcf file.pdf

You will get he new file in the required form.

Sunday, July 3, 2011

ROOT after a little bit of C++

I made a recent revision for Malik's excellent book about C++. This time I made it up to chapter 14 where I learned a lot about pointers. It turns out that this concept is heavily used in ROOT. For example here is a snippet of a code I am using to create plots of publication quality:

#include
#include "TInterpreter.h"
#include "TCanvas.h"
#include "TLatex.h"
#include "TROOT.h"
#include "TH2F.h"
#include "TGraphErrors.h"
#include "TLegend.h"
#include "TPad.h"


These are preprocessor statements to include libraries and header files. the <> symbol is doe standard libraries. and the ones between quotes "" is for libraries made.
void readRFPAS2RHWZ2() {



This starts the function of the type void called readRFPAS2RHWZ2()




float x = 0.446127; //The coordinate of 900GeV labe (t1d, t2d, etc)
float y = 0.190389;
float x1 = 0.2000; //The coordinates for the legends.
float y1 = 0.326465;
float x2 = 0.50275;
float y2 = 0.551054;

Simple variable declaration.

 TInterpreter::Instance() -> LoadMacro("tdrstyle.C");
This is a bit odd as an expression. I am not sure how to interpret it but here is a try. There is a space TInterpreter with an class Instance that has an object LoadMacro. it is called as a pointer:

(*TInterpreter::Instance).LodMacro = tdrstyle.C

What this does is to ask our code to use that macro.
 gROOT -> Reset();

Basically calling another pointer.
(*gROOT).Reset();
 TInterpreter::Instance() -> Execute ("setTDRStyle","");

Same as above.

 TCanvas *c1 = new TCanvas("c1","different scales hists",600,600);

new means we are creating a dynamic variable. in this case of the type TCanvas. it is assigned to the pointer c1.

 c1->Range(-100,-100,10,10);

now c1 points to another object in TCanvas.
(*c1).Range = (-100,-100,10,10);

 TH1F *Dist_Nch_pT20_ = new TH1F("Dist_Nch_pT20_","title",100,-0.5,30);

also TH1F is a data type. with the pointer Dist_Nch_pT20_ is set with the address of the class named Dist_Nch_pT20_  with the parameters needed. next we assign the objects:
 Dist_Nch_pT20_->SetXTitle("N_{ch}");

etc.

So we conclude it is nothing but a bunch of dynamic classes assigned by pointers.