Some CERN ROOT stuff

Updated: 20 octobre 2014


    When I tried to recompile root-v5-34-00-patches I had this error
Error: cannot open file "AvailabilityMacros.h"  include/RConfig.h:376:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing core/base/src/G__Base1.cxx core/base/src/G__Base1.h !!!
Error: core/utils/src/rootcint_tmp: error loading headers...
make: *** [core/base/src/G__Base1.cxx] Error 1
  • Some root flags compilation
	./configure --enable-reflex --enable-qt --with-qt-incdir=/usr/local/Trolltech/Qt-4.6.0//include --with-qt-libdir=/usr/local/Trolltech/Qt-4.6.0/lib
  • Find the maximum x abscissa of a variable from a tuple:
Sampler0->Draw("E") (event if there is no display)
double *b = Sampler0->GetV1()
  • You have a 3D histo and you are looking at which bins correspond the global bin N :
int x,y,z ; 
  • I was fed up to put the variables of my TNtuple (and specially when there are a lot of variables).

So I (finally) decided to make a small program to avoid that
Here the newntuple.C

int ntuple(TString file)
    int col = ComptCol(file);
	cout<<"In file " << file << " there is " << col <<endl;
    char var[256];
    for(int i=0;i<7;i++){
        if(i==0) sprintf(var,"var%d",i);
        else sprintf(var,"%s:var%d",var,i);
    cout << var << endl;     TNtuple *nt = new TNtuple("nt","nt",var);     nt->ReadFile(file);
    return 0;

int ComptCol(TString file_name)
	ifstream file;
    int columns=0;
	char charac;, ios::binary);

		cout<<" Error while opening "<< file_name << endl;

    while(file.get(charac)){ if(charac==' ')columns++; if(charac=='\n') return columns;}

run root. and then do

.L newntuple.C

and then


The variable are calling var1:var2…:vary (n=nb of columns of your file).
Then you can do :


enjoy !!!
hope it could help.

Ce contenu a été publié dans CHEP, Informatique. Vous pouvez le mettre en favoris avec ce permalien.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *