I am running a macro and creating some variables like vetomupx, vetomupy etc. I want to save them in the form of tree i.e I want to create a tree of all variables. I donot understand it and it is giving a segmentation error. Kindly help me to resolve this issue.
can you share a minimal reproducer of the error you are dealing with together with the full information about your platform and the version of ROOT you are using?
Linux version 2.6.32-696.3.1.el6.x86_64 (mockbuild@lxsoft21.cern.ch) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) ) #1 SMP Wed May 31 08:51:37 CEST 2017
May be i am not getting exactly what you want. I am asking about how ton create a tree. I am sending you some lines of my macro in which I have generated some containers like vetomupx, vetomupy etc using lorentz vector and in next step i want to store these containers in a TTree and recreate a root file containing them. By doing this I have done something wrong due to which I am getting this error. Kindly check these lines.
Without a reproducer one can only give general comments. A quick look at your file:
You are including a lot of headers twice. Include them only once!
You are using new TFile(...) to open the input file. Use TFile::Open("...") instead (especially because you are opening a root://... file (which should be a TNetFile)) - and add a check that the file exists, i.e. check that f != nullptr. Also check that the tree exists.
In the following code fragment, the second and fourth if can never be true. ```
if (nSelLeptons != 3) continue;
if (nSelLeptons > 3) continue;
if (nvetoLeptons != 0) continue;
if (nvetoLeptons > 0) continue;
- your program should not compile because you are redefining `VetoMupx, VetoMupy, VetoMupz, VetoMuen, VetoMucharge;` (lines 194+231)
- There is some indentation in your code, yet your indentation doesn't help to find out to which block a line belongs. Use a tool like clang-format to reformat your code!
This also leads to the next point:
- you are opening the output file inside the event loop! Don't do that, your output tree will only have one event! (Also, you are missing the `delete ff; / delete f;`)
- finally a physics related question: is ` bool passVetoIso( Mu_id[m]==13 ? relIso<0.25 : true)` useful? For -13 no isolation? At least I would add a comment here.