|
From: Jan T. <the...@ph...> - 2011-07-22 11:08:02
|
Hi Diego,
the problem is probably, that ROOT is trying to assign the
training/testing trees to the input file, because this is the last
file you opened. Just placing a
outputFile->cd();
just in front of the loop where you're filling the events should do
the job.
The stand-alone class should be generate automatically during training
and can be found in the weights/ directory. It will be named something
like TMVAClassification_MLP.class.C
Cheers
Jan
On Thu, 21 Jul 2011 17:04:58 -0500
Diego Menezes <dom...@gm...> wrote:
> Dear all,
>
> Two questions about the TMVA mlp method. First, I've been using a
>modified
> version of ROOT's /root/tmva/test/MVAnalysis.C to study signal and
> background separation using TMVA mlp with this set up:
>
> TFile *inputsig = new TFile("ttbar_signal.root");
> TFile *inputback = new TFile("ttbar_back.root");
>
>
> TTree *signal = (TTree*)inputsig->Get("TopTauTree");
> TTree *background = (TTree*)inputback->Get("TopTauTree");
>
> factory->AddVariable( "Et", 'F' );
> factory->AddVariable( "cent", 'F' );
> factory->AddVariable( "ht", 'F' );
> factory->AddVariable( "sqrts", 'F' );
>
> and then
>
> std::vector<Double_t> vars( 4 ); // vector has size of number of
>input
> variables
> Float_t treevars[4];
> signal->SetBranchAddress("Et", &(treevars[0]) );
> signal->SetBranchAddress("cent", &(treevars[1]) );
> signal->SetBranchAddress("ht", &(treevars[2]) );
> signal->SetBranchAddress("sqrts", &(treevars[3]) );
> for (Int_t i=0; i<signal->GetEntries(); i++) {
> signal->GetEntry(i);
> for (Int_t ivar=0; ivar<4; ivar++) vars[ivar] = treevars[ivar];
> // add training and test events; here: first half is training,
>second
> is testing
> // note that the weight can also be event-wise
> if (i < signal->GetEntries()/2)
>factory->AddSignalTrainingEvent( vars,
> signalWeight );
> else factory->AddSignalTestEvent
> ( vars,
> signalWeight );
> }
>
> Plus something similar for the background part. The error I see when
>running
> the macro is
>
>
> Error in <TTree::Fill>: Failed filling
>branch:LocalSigTrainTree.weight,
> nbytes=-1
> This error is symptomatic of a Tree created as a memory-resident
>Tree
> Instead of doing:
> TTree *T = new TTree(...)
> TFile *f = new TFile(...)
> you should do:
> TFile *f = new TFile(...)
> TTree *T = new TTree(...)
> Error in <TTree::Fill>: Failed filling
>branch:LocalSigTrainTree.metl,
> nbytes=-1
> Error in <TTree::Fill>: Failed filling
>branch:LocalSigTrainTree.cent,
> nbytes=-1
> Error in <TTree::Fill>: Failed filling
>branch:LocalSigTrainTree.sqrts,
> nbytes=-1
> Error in <TTree::Fill>: Failed filling branch:LocalSigTrainTree.ht,
> nbytes=-1
>
> Any ideas on how to fix it? Second, my old ROOT's
>TMultiLayerPerceptron
> macro generates as one the output a .cxx file that I use in my
>analysis
> later on. Can TMVA mlp do the same when training the NN? If so, how?
>
> Thanks,
>
> Diego.
--------------
Jan Therhaag
Physikalisches Institut, Universität Bonn
Office: CERN bat. 304-1-042 Tel: +41 22 76 78052
eMail: the...@ph...
|