Plotting distributions of input variables for a specific final state particle

Hello,
I am new to TMVA and facing some problem in dealing with the input variables.
When I am declaring the input variables for example ‘Energy’, and ‘PT’ and running the classification macro, I am getting some distributions of the input variables. I can’t understand the distribution of a variable corresponds to which final state particle. In my case, there are 3 final state particles.
I have converted the .root file from .lhe file generated by MG5 using ExRootAnalysis.

I will be really grateful if this problem gets solved.

Regards,
Saumyen

Hi,

I think it would be helpful if you would post the plots to which you are referring and explain what you expect them to look like.

Additionally, I am curious what the branch/leaf structure of your root file is, and what you expect it to be.

Without this information it is difficult to give an appropriate answer.

Cheers,
Kim

Hi Kim
You can look at the picture below where you can see four histograms of the four input variables, respectively, ‘Energy’, ‘Transverse momenta’, ‘rapidity’ and ‘azimuthal angle’. I defined the variables using the following commands:

dataloader->AddVariable( “myvar1 := E”,“Energy”,"", ‘F’ );
dataloader->AddVariable( “myvar2 := PT”, “Transverse Momenta”, “”, ‘F’ );
dataloader->AddVariable( “Eta”, “rapidity”, “units”, ‘F’ );
dataloader->AddVariable( “Phi”, “azimuthal angle”, “units”, ‘F’ );

Now in my process, there are three particles in the final states. My question is that the variables that are plotted correspond to which particle? Is there a way that I decide (for example) to have an energy distribution of particle-3 only?

I could see that the variables are written as ‘double_t’ variables in arrays. As you can see in the snap below.

Regards,

Saumyen

Hi,

I think I understand a bit better now what it is you want to do, and for these things the TMVA automatic plotting might not be the best approach. This since TMVA uses a fixed plotting pipeline.

A better approach at this stage might be to construct a histogram with the information you want directly.

Directly in the shell:

$ root -l somefile.root
root [0] auto tree = static_cast<TTree *>(_file0->Get("path/to/tree"))
root [1] tree->Draw("E", "particleID==3")

The cut expression "particleID==3" can of course be customised to e.g. incorporate your background selection.

Cheers,
Kim

Hi Kim,
I tried as per your suggestion. But in this case I’m getting error messages. When I entered

$ root -l bg.root

I got the warning message:

root [0]
Attaching file /home/pdas/codes/bg.root as _file0…
Warning in TClass::Init: no dictionary for class TRootLHEFEvent is available
Warning in TClass::Init: no dictionary for class TRootWeight is available
Warning in TClass::Init: no dictionary for class TRootLHEFParticle is available
Warning in TClass::Init: no dictionary for class TSortableObject is available
(TFile *) 0x1d5c520

Next, when I applied

root [1] auto tree = static_cast<TTree *>(_file0->Get(“bg.root”))

I got :

(TTree *) nullptr

And when I wrote

root [2] tree->Draw(“E”, “particleID==22”)

I got:

#0 0x00007f46c21a907a in __GI___waitpid (pid=8626, stat_loc=stat_loc
entry=0x7ffcf9cee730, options=options
entry=0) at …/sysdeps/unix/sysv/linux/waitpid.c:29
#1 0x00007f46c2121fbb in do_system (line=) at …/sysdeps/posix/system.c:148
#2 0x00007f46c2d844a2 in TUnixSystem::Exec (shellcmd=, this=0x12ae570) at /home/pdas/HEP_Packages/root-6.14.04/core/unix/src/TUnixSystem.cxx:2119
#3 TUnixSystem::StackTrace (this=0x12ae570) at /home/pdas/HEP_Packages/root-6.14.04/core/unix/src/TUnixSystem.cxx:2413
#4 0x00007f46bd714dc5 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /usr/local/lib/libCling.so
#5 0x00007f46bd71487b in cling_runtime_internal_throwIfInvalidPointer () from /usr/local/lib/libCling.so
#6 0x00007f46c337d071 in ?? ()
#7 0x00007ffcf9cf0bd0 in ?? ()
#8 0x0000000001327eb0 in ?? ()
#9 0x00000000021f7fd0 in ?? ()
#10 0x00007f46c216153c in __GI___libc_free (mem=) at malloc.c:2968
#11 0x00007f46bd7158dc in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) [clone .part.290] [clone .constprop.445] () from /usr/local/lib/libCling.so
#12 0x00007f46bd71a3b3 in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /usr/local/lib/libCling.so
#13 0x00007f46bd71a65c in cling::Interpreter::process(std::_cxx11::basic_string<char, std::char_traits, std::allocator > const&, cling::Value*, cling::Transaction**, bool) () from /usr/local/lib/libCling.so
#14 0x00007f46bd7a7897 in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /usr/local/lib/libCling.so
#15 0x00007f46bd68a7ba in HandleInterpreterException (metaProcessor=0x1532e10, input_line=0x220e9a0 “#line 1 "ROOT_prompt_3"\ntree->Draw("E", "particleID==22")”, compRes=
0x7ffcf9cf0fac: cling::Interpreter::kSuccess, result=result
entry=0x7ffcf9cf0fc0) at /home/pdas/HEP_Packages/root-6.14.04/core/metacling/src/TCling.cxx:2060
#16 0x00007f46bd69f5a4 in TCling::ProcessLine (this=0x131fb10, line=, error=0x7ffcf9cf14dc) at /home/pdas/HEP_Packages/root-6.14.04/core/metacling/src/TCling.cxx:2218
#17 0x00007f46c2c3447b in TApplication::ProcessLine (this=this
entry=0x12e8670, line=, sync=sync
entry=false, err=err
entry=0x7ffcf9cf14dc) at /home/pdas/HEP_Packages/root-6.14.04/core/base/src/TApplication.cxx:1021
#18 0x00007f46c30c90de in TRint::ProcessLineNr (this=this
entry=0x12e8670, filestem=filestem
entry=0x7f46c30da87f "ROOT_prompt
", line=0x21e8cc0 “tree->Draw("E", "particleID==22")”, error=0x7ffcf9cf14dc, error
entry=0x0) at /home/pdas/HEP_Packages/root-6.14.04/core/rint/src/TRint.cxx:741
#19 0x00007f46c30c9465 in TRint::HandleTermInput (this=0x12e8670) at /home/pdas/HEP_Packages/root-6.14.04/core/rint/src/TRint.cxx:602
#20 0x00007f46c2d8617c in TUnixSystem::CheckDescriptors (this=this
entry=0x12ae570) at /home/pdas/HEP_Packages/root-6.14.04/core/unix/src/TUnixSystem.cxx:1322
#21 0x00007f46c2d876fa in TUnixSystem::DispatchOneEvent (this=0x12ae570, pendingOnly=) at /home/pdas/HEP_Packages/root-6.14.04/core/unix/src/TUnixSystem.cxx:1077
#22 0x00007f46c2ca3161 in TSystem::InnerLoop (this=0x12ae570) at /home/pdas/HEP_Packages/root-6.14.04/core/base/src/TSystem.cxx:411
#23 TSystem::Run (this=0x12ae570) at /home/pdas/HEP_Packages/root-6.14.04/core/base/src/TSystem.cxx:361
#24 0x00007f46c2c317cf in TApplication::Run (this=this
entry=0x12e8670, retrn=retrn
entry=false) at /home/pdas/HEP_Packages/root-6.14.04/core/base/src/TApplication.cxx:1173
#25 0x00007f46c30cac1b in TRint::Run (this=this
entry=0x12e8670, retrn=retrn
entry=false) at /home/pdas/HEP_Packages/root-6.14.04/core/rint/src/TRint.cxx:455
#26 0x000000000040099a in main (argc=1, argv=0x7ffcf9cf3938) at /home/pdas/HEP_Packages/root-6.14.04/main/src/rmain.cxx:30
Error in : Trying to dereference null pointer or trying to call routine taking non-null arguments.
Execution of your code was aborted.
ROOT_prompt_3:1:1: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
tree->Draw(“E”, “particleID==22”)
^~~~

I don’t understand what’s wrong (actually, I’m new to ROOT as well as TMVA).

Regards,
Saumyen

Hi,

You need to pass te path to the TTree, not the path to the rootfile.

Use _file0->ls() to explore your file. (Or rootls bg.root from the command line.)

Cheers,
Kim

Hello, I get the same error as you got. How did you fix it?

Hello, I am new to ROOT. Do you mind explaining more how I can fix the error from this forum

Hi and welcome to the forum!

Please note that in general it is better to post a new question instead of reviving an old one.

TFile::Get expects the path to an object within the file and returns a pointer to it. The error was that the original poster passed the filename instead like so:

// Warning: Incorrect version!
auto file = TFile::Open("path/to/file.root");
auto tree = static_cast<TTree *>(file->Get("path/to/file.root"))

instead of the correct version:

// Correct version!
auto file = TFile::Open("path/to/file.root");
auto tree = static_cast<TTree *>(file->Get("path/to/ttree"))

The structure of a .root file can be explored with rootbrowse path/to/file.root.

Cheers,
Kim

Thank you for the clarification!