Using TMVA for the .root files converted from madgraph generated .lhe file

Hi,

I am new here regarding using TMVA and root as well. I have specific background process and a signal, generated using madgraph. I converted the .lhe files as .root files. Also I am able to generate the desired histograms using root. To start with, I am not able to understand how to use the .root files (say, background.root and signal.root) in TMVA platform; I mean how can I import then to make it usable by TMVAClassification.C or TMVARegression.C ?

Thank you in advance.

Hi,

What does your files contain? If they contain a TTree with your variables integrating it should be straightforward. In essence it should be a matter of chaning the path to the loaded files and changing the names of the loaded variables.

You could also have a look at TMVAMinimalClassification for a less overwhelming template.

If you have any specific questions arising from looking at these two files, I’m happy to answer them.

Cheers,
Kim

Hi,

Thank you very much for your reply. Yeah I guess the files contain TTree as I am able to plot the histos by TH1. By I am confused about TMVAMinimalClassification.C or TMVAClassification.C; which statement stands for importing my file.root…!!!

This example should maybe make things a bit more clear. Then you can combine this with MinimalClassification to build a fully working setup for your case.

// Get the input file
TFile * input = TFile::Open("/path/to/your/file.root");
if (not input) {
   std::cout << "ERROR: Could not open input file!" << std::endl;
   exit(1);
}

// Get the trees from the input file
TTree * sigTree = static_cast<TTree *>(input->Get("TreeS"));
TTree * bkgTree = static_cast<TTree *>(input->Get("TreeB"));

// Add the trees to the dataset
auto * dataloader = new TMVA::DataLoader("dataset");
dataloader->AddVariable("YourVariable1");
dataloader->AddVariable("YourVariable2");
dataloader->AddSignalTree(sigTree);
dataloader->AddSignalTree(bkgTree);

Cheers,
Kim

Thank you very much Kim for your time and effort. That solves my problem and makes it easier to understand for me. Thank you once again.

For this particular file I am getting this error…

##########################################################
: Tree does not exist (empty pointer).
***> abort program execution
terminate called after throwing an instance of ‘std::runtime_error’
what(): FATAL error
##########################################################
bg.root (2.5 MB)

Please find the attached file; I’m not sure what is wrong here. It’s a .root file converted from a .lhe file using ExRootLHEFConverter.

Thank you. Regards.

It seems that the tree that you are trying to access does not exist. You can inspect the contents of the root file using rootbrowse /path/to/file or rootls -t /path/to/file.

Cheers,
Kim

Well. Yeah… this command " rootls -t /path/to/file ." is working fine… It shows the following messages…
#############################################################
TTree Feb 24 19:50 2019 LHEF “Analysis tree”
Event “Event_” 80160
Event.fUniqueID “fUniqueID[Event_]” 80180
Event.fBits “fBits[Event_]” 80172
Event.Number “Number[Event_]” 120261
Event.Nparticles “Nparticles[Event_]” 80182
Event.ProcessID “ProcessID[Event_]” 80180
Event.Weight “Weight[Event_]” 120261
Event.ScalePDF “ScalePDF[Event_]” 120267
Event.CouplingQED “CouplingQED[Event_]” 120276
Event.CouplingQCD “CouplingQCD[Event_]” 120276
Event_size “Event_size/I” 40154
Rwgt “Rwgt_” 80158
Rwgt.fUniqueID “fUniqueID[Rwgt_]” 40178
Rwgt.fBits “fBits[Rwgt_]” 40170
Rwgt.Weight “Weight[Rwgt_]” 40172
Rwgt_size “Rwgt_size/I” 40152
Particle “Particle_” 80166
Particle.fUniqueID “fUniqueID[Particle_]” 240861
Particle.fBits “fBits[Particle_]” 240841
Particle.PID “PID[Particle_]” 240831
Particle.Status “Status[Particle_]” 240846
Particle.Mother1 “Mother1[Particle_]” 240851
Particle.Mother2 “Mother2[Particle_]” 240851
Particle.ColorLine1 “ColorLine1[Particle_]” 240866
Particle.ColorLine2 “ColorLine2[Particle_]” 240866
Particle.Px “Px[Particle_]” 441480
Particle.Py “Py[Particle_]” 441480
Particle.Pz “Pz[Particle_]” 441480
Particle.E “E[Particle_]” 441472
Particle.M “M[Particle_]” 441472
Particle.PT “PT[Particle_]” 441480
Particle.Eta “Eta[Particle_]” 441488
Particle.Phi “Phi[Particle_]” 441488
Particle.Rapidity “Rapidity[Particle_]” 441528
Particle.LifeTime “LifeTime[Particle_]” 441528
Particle.Spin “Spin[Particle_]” 441496
Particle_size “Particle_size/I” 40160
#####################################################
How can I identify the name of the tree(s)?

Should be this, no?

EDIT: As @Pepe_Le_Pew was kind enough to highlight, it is not so obvious to see the actual name of the tree. The tree name is “LHEF” and then there is the tree title “Analysis Tree”.

Should you be able to use rootbrowse (e.g. if you are running locally or through an ssh session with X forwarding) this should be better indicated.

Cheers,
Kim

Thanks… The TTree has been loaded now without any error.

Cheers…

Atanu

In my above mentioned file, can I use condition to work on a particular branch like “Particle” and set a condition to take out the events only for Particle.PID == 22 , I mean in general for any particular particle?