How to load up a TTree in a RooDataSet inside PyRoot???

From: Antonio Augusto Alves Junior <aalvesju_at_cern.ch>
Date: Fri, 24 Dec 2010 05:50:47 +0100


Dear Colleagues,

I am getting problems to load up a TTree, from a .root file, inside a RooDataSet using the PyRoot environment.

The code is basically this :

   Import ROOT

             dataSource = ROOT.TFile('myRootFile.root', "READ"  )
             tree = dataSource.Get( 'Tree'])
             rooData =  ROOT.RooDataSet('data', 'dataset' , 
ROOT.RooArgSet( variables of interest... ) , tree, 'cut string...' )

when I try run this, I get this errors messages:

    TypeError: none of the 8 overloaded methods succeeded. Full details:

       RooDataSet::RooDataSet() =>
         takes at most 0 arguments (5 given)
       RooDataSet::RooDataSet(const char* name, const char* title, const
    RooArgSet& vars, const char* wgtVarName = 0) =>
         takes at most 4 arguments (5 given)
       RooDataSet::RooDataSet(const char* name, const char* title, const
    RooArgSet& vars, const RooCmdArg& arg1, const RooCmdArg& arg2 =     RooCmdArg(), const RooCmdArg& arg3 = RooCmdArg(), const RooCmdArg&     arg4 = RooCmdArg(), const RooCmdArg& arg5 = RooCmdArg(), const     RooCmdArg& arg6 = RooCmdArg(), const RooCmdArg& arg7 = RooCmdArg(),     const RooCmdArg& arg8 = RooCmdArg()) =>
         could not convert argument 4
       RooDataSet::RooDataSet(const char* name, const char* title,
    RooDataSet* data, const RooArgSet& vars, const char* cuts = 0, const     char* wgtVarName = 0) =>
         could not convert argument 3
       RooDataSet::RooDataSet(const char* name, const char* title,
    RooDataSet* data, const RooArgSet& vars, const RooFormulaVar&     cutVar, const char* wgtVarName = 0) =>
         could not convert argument 3
       RooDataSet::RooDataSet(const char* name, const char* title,
    TTree* ntuple, const RooArgSet& vars, const char* cuts = 0, const     char* wgtVarName = 0) =>
         could not convert argument 3
       RooDataSet::RooDataSet(const char* name, const char* title,
    TTree* t, const RooArgSet& vars, const RooFormulaVar& cutVar, const     char* wgtVarName = 0) =>
         could not convert argument 3
       RooDataSet::RooDataSet(RooDataSet const& other, const char*
    newname = 0) =>
         takes at most 2 arguments (5 given)

    Please, does someone know how to do this operation ?

Augusto.

On 24-12-2010 05:33, Philippe Canal wrote:
> Hi Noel,
>
> In newer version of ROOT you can simply your scripts by using
>
> gInterpreter->GenerateDictionary("vector<vector<float> >", "vector");
>
> which does most of the work of your make_class.
>
> Cheers,
> Philippe.
>
> On 12/22/10 4:29 PM, Noel Dawe wrote:
>> For all the python fans out there I've attached a simple module which
>> may be used to generate classes in PyROOT which are not available by
>> default (like vector<vector<float> > etc.)
>>
>> Example usage:
>>
>> Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
>> [GCC 4.4.5] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> from classfactory import *
>> >>> make_class("vector<vector<float> >", "<vector>")
>> True
>> >>> ROOT.vector("vector<float>")()
>> <ROOT.vector<vector<float> > object at 0x2b1cf10>
>> >>> make_class("vector<TH1D>", "TH1D.h")
>> True
>> >>> ROOT.vector("TH1D")()
>> <ROOT.vector<TH1D> object at 0x2b2c160>
>> >>>
>>
>> Suggestions/improvements are welcome.
>>
>> Cheers,
>> Noel
>

-- 
"O mais corrente neste mundo, nestes tempos em que às cegas vamos tropeçando, é esbarrarmos, ao virar a esquina mais próxima, com homens e mulheres na maturidade da existência e da prosperidade, que, tendo sido aos dezoito anos briosos revolucionários decididos a arrasar o sistema dos pais e pôr no seu lugar o paraíso, enfim, da fraternidade, se encontram agora, com firmeza pelo menos igual, repoltreados em convicções e práticas que, depois de haverem passado por qualquer das muitas versões do conservadorismo moderado, acabaram por desembocar no mais desbocado e reaccionário egoísmo. Em palavras não tão cerimoniosas, estes homens e estas mulheres, diante do espelho da sua vida, cospem todos os dias na cara do que foram o escarro do que são."

José Saramago, em Ensaio sobre a lucidez

=============================================

A. Augusto Alves Jr.

Istituto Nazionale di Fisica Nucleare - Sezione di Roma
c/o Dipartimento di Fisica -
Università degli Studi di Roma "La Sapienza"

P.le Aldo Moro, 2 - 00185 Roma - Italy
tel.: 00 39 06 49914229
Received on Fri Dec 24 2010 - 05:50:54 CET

This archive was generated by hypermail 2.2.0 : Fri Dec 24 2010 - 11:50:01 CET