Saw Strange Behaviour in TLorentzVecotor

Hello,

When I tried to fill TLorentzVector using

TLorentzVector Iqrk0(Particle_Px[im], Particle_Py[im], Particle_Pz[im], Particle_E[im]);

then from next events for all the line after the above statement in which I cout the px, py, pz, etc shows me 0 or some strange value.

But When I defined it like this then everything was fine.

TLorentzVector Iqrk0;
Iqrk0.SetPxPyPzE(Particle_Px[im], Particle_Py[im], Particle_Pz[im], Particle_E[im]);

Is there some difference between the two ways of filling the TLorentzVector? Or, May be I was doing something wrong? Please let me know.

If you want to see the code then it is given below:
ReadLHE.C (2.81 KB)
ReadLHE.h (9.9 KB)

Thanks & regards,
Ram

one test root file (“unweighted_events.root”) ?

Link of Root file:

drive.google.com/file/d/0B2Yvp8 … sp=sharing

I’m afraid this is some kind of a CINT bug.
Try the attached “ReadLHE.C” file.
When “interpreted”, I get a “segmentation violation” (note that the “Particle_” variable has been modified without any reason):

root [0] .L ReadLHE.C
root [1] ReadLHE t
Warning in <TClass::TClass>: no dictionary for class TRootLHEFEvent is available
Warning in <TClass::TClass>: no dictionary for class TRootWeight is available
Warning in <TClass::TClass>: no dictionary for class TRootLHEFParticle is available
Warning in <TClass::TClass>: no dictionary for class TSortableObject is available
root [2] t.Loop();
nb = 940
0       Particle_Py = 1304.34
0       Particle_PID = -1
quakr_count = 1
px, py, pz, E 0 0       1304.34 1304.34
0       Particle_ BEFORE Iqrk0 = 6
0       Particle_ AFTER Iqrk0 = 6
1       Particle_Py = 490.969
1       Particle_PID = 21
quakr_count = 2
px, py, pz, E 0 0       -490.969        490.969
2       Particle_Py = 280.684
2       Particle_PID = 23
3       Particle_Py = 669.786
3       Particle_PID = 23
4       Particle_Py = 416.124
4       Particle_PID = 21
quakr_count = 3
px, py, pz, E -29.075   5.31222 -415.073        416.124
5       Particle_Py = 428.717
5       Particle_PID = -1
quakr_count = 4
px, py, pz, E 90.4598   -213.77 360.441 428.717
nb = 940
0       Particle_Py = 1083.1
0       Particle_PID = 1
quakr_count = 1
px, py, pz, E 0 0       1083.1  1083.1
0       Particle_ BEFORE Iqrk0 = 6
0       Particle_ AFTER Iqrk0 = 0

 *** Break *** segmentation violation



===========================================================
There was a crash (kSigSegmentationViolation).
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f2e2f03b6dc in __libc_waitpid (pid=5485, stat_loc=stat_loc
entry=0x7fff72833820, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:31
#1  0x00007f2e2efc02e2 in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2  0x00007f2e2fdd6d4a in TUnixSystem::Exec (this=0x1ae0ec0, shellcmd=0x2a188a0 "/.../v5-34-00-patches/etc/gdb-backtrace.sh 5471 1>&2") at /.../v5-34-00-patches/core/unix/src/TUnixSystem.cxx:2172
#3  0x00007f2e2fdd7626 in TUnixSystem::StackTrace (this=0x1ae0ec0) at /.../v5-34-00-patches/core/unix/src/TUnixSystem.cxx:2419
#4  0x00007f2e2fdd4f0f in TUnixSystem::DispatchSignals (this=0x1ae0ec0, sig=kSigSegmentationViolation) at /.../v5-34-00-patches/core/unix/src/TUnixSystem.cxx:1294
#5  0x00007f2e2fdd2e5b in SigHandler (sig=kSigSegmentationViolation) at /.../v5-34-00-patches/core/unix/src/TUnixSystem.cxx:440
#6  0x00007f2e2fddafea in sighandler (sig=11) at /.../v5-34-00-patches/core/unix/src/TUnixSystem.cxx:3748
#7  0x00007f2e2fe0f488 in textinput::TerminalConfigUnix::HandleSignal (this=0x7f2e305aad80 <textinput::TerminalConfigUnix::Get()::s>, signum=11) at /.../v5-34-00-patches/core/textinput/src/textinput/TerminalConfigUnix.cpp:96
#8  0x00007f2e2fe0f1c5 in (anonymous namespace)::TerminalConfigUnix__handleSignal (signum=11) at /.../v5-34-00-patches/core/textinput/src/textinput/TerminalConfigUnix.cpp:36
#9  <signal handler called>
#10 0x00007f2e2e67a352 in G__interpret_func (result7=0x1b0d940, funcname=0x2127f60 "LoadTree", libp=0x7fff72837150, hash=784, p_ifunc=0x2273070, funcmatch=1, memfunc_flag=0) at cint/cint/src/ifunc.cxx:6032
#11 0x00007f2e2e5e2aee in G__exec_asm (start=0, stack=0, presult=0x7fff728420c0, localmem=0) at cint/cint/src/bc_exec_asm.h:1982
#12 0x00007f2e2e6d8fe3 in G__exec_loop (forinit=0x0, condition=0x1b20c40 "jentry<nentries", foraction=...) at cint/cint/src/parse.cxx:3318
#13 0x00007f2e2e6d810e in G__exec_for () at cint/cint/src/parse.cxx:2764
#14 0x00007f2e2e6e4d46 in G__exec_statement (mparen=0x7fff728425c4) at cint/cint/src/parse.cxx:7262
#15 0x00007f2e2e67cbd7 in G__interpret_func (result7=0x7fff728433b0, funcname=0x1afcb00 "Loop", libp=0x7fff728433f0, hash=410, p_ifunc=0x2273370, funcmatch=1, memfunc_flag=1) at cint/cint/src/ifunc.cxx:6710
#16 0x00007f2e2e652053 in G__getfunction (item=0x1afbed2 "Loop()", known3=0x7fff7284ec7c, memfunc_flag=1) at cint/cint/src/func.cxx:2660
#17 0x00007f2e2e79042d in G__getstructmem (store_var_type=112, varname=..., membername=0x1afbed2 "Loop()", memnamesize=1021, tagname=0x1afbed0 "t", known2=0x7fff7284ec7c, varglobal=0x7f2e2ea5c680 <G__global>, objptr=1) at cint/cint/src/var.cxx:6821
#18 0x00007f2e2e77fca3 in G__getvariable (item=0x1af62b0 "t.Loop()", known=0x7fff7284ec7c, varglobal=0x7f2e2ea5c680 <G__global>, varlocal=0x0) at cint/cint/src/var.cxx:5390
#19 0x00007f2e2e641326 in G__getitem (item=0x1af62b0 "t.Loop()") at cint/cint/src/expr.cxx:1906
#20 0x00007f2e2e63e934 in G__getexpr (expression=0x1b1f410 "t.Loop()") at cint/cint/src/expr.cxx:1488
#21 0x00007f2e2e6d3e61 in G__exec_function (statement=..., pc=0x7fff72851480, piout=0x7fff72851484, plargestep=0x7fff7285148c, presult=0x7fff72851570) at cint/cint/src/parse.cxx:645
#22 0x00007f2e2e6e54bc in G__exec_statement (mparen=0x7fff72851750) at cint/cint/src/parse.cxx:7371
#23 0x00007f2e2e610e64 in G__exec_tempfile_core (file=0x0, fp=0x25f98c0) at cint/cint/src/debug.cxx:266
#24 0x00007f2e2e6128d6 in G__exec_tempfile_fp (fp=0x25f98c0) at cint/cint/src/debug.cxx:807
#25 0x00007f2e2e6f48df in G__process_cmd (line=0x7fff72852c59 "t.Loop();", prompt=0x1ae6fe8 "", more=0x1ae6fe0, err=0x7fff72852a2c, rslt=0x7fff72852a60) at cint/cint/src/pause.cxx:3343
#26 0x00007f2e2fd86b7e in TCint::ProcessLine (this=0x1ae6fa0, line=0x7fff72852c59 "t.Loop();", error=0x0) at /.../v5-34-00-patches/core/meta/src/TCint.cxx:548
#27 0x00007f2e2fcc5a71 in TApplication::ProcessLine (this=0x1c33300, line=0x7fff72852c59 "t.Loop();", sync=false, err=0x0) at /.../v5-34-00-patches/core/base/src/TApplication.cxx:974
#28 0x00007f2e2f86f33d in TRint::HandleTermInput (this=0x1c33300) at /.../v5-34-00-patches/core/rint/src/TRint.cxx:584
#29 0x00007f2e2f86d189 in TTermInputHandler::Notify (this=0x212e040) at /.../v5-34-00-patches/core/rint/src/TRint.cxx:125
#30 0x00007f2e2f870841 in TTermInputHandler::ReadNotify (this=0x212e040) at /.../v5-34-00-patches/core/rint/src/TRint.cxx:117
#31 0x00007f2e2fdd5273 in TUnixSystem::CheckDescriptors (this=0x1ae0ec0) at /.../v5-34-00-patches/core/unix/src/TUnixSystem.cxx:1396
#32 0x00007f2e2fdd4441 in TUnixSystem::DispatchOneEvent (this=0x1ae0ec0, pendingOnly=false) at /.../v5-34-00-patches/core/unix/src/TUnixSystem.cxx:1103
#33 0x00007f2e2fd3812b in TSystem::InnerLoop (this=0x1ae0ec0) at /.../v5-34-00-patches/core/base/src/TSystem.cxx:410
#34 0x00007f2e2fd37ec6 in TSystem::Run (this=0x1ae0ec0) at /.../v5-34-00-patches/core/base/src/TSystem.cxx:360
#35 0x00007f2e2fcc6542 in TApplication::Run (this=0x1c33300, retrn=false) at /.../v5-34-00-patches/core/base/src/TApplication.cxx:1122
#36 0x00007f2e2f86eb00 in TRint::Run (this=0x1c33300, retrn=false) at /.../v5-34-00-patches/core/rint/src/TRint.cxx:455
#37 0x000000000040128e in main (argc=1, argv=0x7fff72855098) at /.../v5-34-00-patches/main/src/rmain.cxx:29
===========================================================


Root > Function Loop() busy flag cleared

root [3] .q

but when “precompiled”, I get it right:

root [0] .L ReadLHE.C++
Info in <TUnixSystem::ACLiC>: creating shared library /..././ReadLHE_C.so
root [1] ReadLHE t
Warning in <TClass::TClass>: no dictionary for class TRootLHEFEvent is available
Warning in <TClass::TClass>: no dictionary for class TRootWeight is available
Warning in <TClass::TClass>: no dictionary for class TRootLHEFParticle is available
Warning in <TClass::TClass>: no dictionary for class TSortableObject is available
root [2] t.Loop();
nb = 940
0       Particle_Py = 1304.34
0       Particle_PID = -1
quakr_count = 1
px, py, pz, E 0 0       1304.34 1304.34
0       Particle_ BEFORE Iqrk0 = 6
0       Particle_ AFTER Iqrk0 = 6
1       Particle_Py = 490.969
1       Particle_PID = 21
quakr_count = 2
px, py, pz, E 0 0       -490.969        490.969
2       Particle_Py = 280.684
2       Particle_PID = 23
3       Particle_Py = 669.786
3       Particle_PID = 23
4       Particle_Py = 416.124
4       Particle_PID = 21
quakr_count = 3
px, py, pz, E -29.075   5.31222 -415.073        416.124
5       Particle_Py = 428.717
5       Particle_PID = -1
quakr_count = 4
px, py, pz, E 90.4598   -213.77 360.441 428.717
nb = 940
0       Particle_Py = 1083.1
0       Particle_PID = 1
quakr_count = 1
px, py, pz, E 0 0       1083.1  1083.1
0       Particle_ BEFORE Iqrk0 = 6
0       Particle_ AFTER Iqrk0 = 6
1       Particle_Py = 67.644
1       Particle_PID = 21
quakr_count = 2
px, py, pz, E 0 0       -67.644 67.644
2       Particle_Py = 686.778
2       Particle_PID = 23
3       Particle_Py = 382.898
3       Particle_PID = 23
4       Particle_Py = 35.2051
4       Particle_PID = 21
quakr_count = 3
px, py, pz, E 12.3725   32.8481 -2.7057 35.2051
5       Particle_Py = 45.8611
5       Particle_PID = 1
quakr_count = 4
px, py, pz, E 25.0471   -26.653 -27.6677        45.8611
root [3] .q

ReadLHE.C (3.65 KB)

Hi Wile E.,

Thanks for figuring that out. And: yikes :frowning: At least you got a crash and not just silently wrong numbers like Ram. The problem is that these things are deep, deep inside CINT (parser and evaluation) and that’s really something I’d hate to touch in ROOT 5 these days.

Ram - can you either compile your macro and run that (see the working version of Wile E.'s example) or move to ROOT 6 where this “just works”?

Cheers, Axel.

I’m not 100% sure that it’s solely just a CINT problem.
The “LHEF” tree seems to contain some arrays (maybe even some “TObjArray” or “TClonesArray” objects) of some objects (of classes “TRootLHEFEvent”, “TRootWeight”, “TRootLHEFParticle”, “TSortableObject”, no dictionaries for them are provided) written in “decomposed object mode”.
The TTree::MakeClass has been used to create the “skeleton analysis” (i.e. “ReadLHE.h” and “ReadLHE.C”) and then one tries to read some of these “decomposed” branches.
Well, I’m not really sure that this approach is kosher so maybe an expert in ROOT I/O (Philippe?) should have a look at it.
P.S. Of course, you can use TFile::MakeProject to (re)generate dictionaries, but I think it will not help here.

******************************************************************************
*Tree    :LHEF      : Analysis tree                                          *
*Entries :    50000 : Total =        46909123 bytes  File  Size =   18473811 *
*        :          : Tree compression factor =   2.54                       *
******************************************************************************
*Br    0 :Event     : Int_t Event_                                           *
*Entries :    50000 : Total  Size=     407555 bytes  File Size  =      62520 *
*Baskets :       10 : Basket Size=      64000 bytes  Compression=   6.41     *
*............................................................................*
*Br    1 :Event.fUniqueID : UInt_t fUniqueID[Event_]                         *
*Entries :    50000 : Total  Size=     401514 bytes  File Size  =      62582 *
*Baskets :       10 : Basket Size=      64000 bytes  Compression=   6.41     *
*............................................................................*
*Br    2 :Event.fBits : UInt_t fBits[Event_]                                 *
*Entries :    50000 : Total  Size=     401458 bytes  File Size  =      62684 *
*Baskets :       10 : Basket Size=      64000 bytes  Compression=   6.39     *
*............................................................................*
*Br    3 :Event.Number : Long64_t Number[Event_]                             *
*Entries :    50000 : Total  Size=     601793 bytes  File Size  =     160176 *
*Baskets :       13 : Basket Size=      64000 bytes  Compression=   3.75     *
*............................................................................*
*Br    4 :Event.Nparticles : Int_t Nparticles[Event_]                        *
*Entries :    50000 : Total  Size=     401528 bytes  File Size  =      62718 *
*Baskets :       10 : Basket Size=      64000 bytes  Compression=   6.39     *
*............................................................................*
*Br    5 :Event.ProcessID : Int_t ProcessID[Event_]                          *
*Entries :    50000 : Total  Size=     401514 bytes  File Size  =      62582 *
*Baskets :       10 : Basket Size=      64000 bytes  Compression=   6.41     *
*............................................................................*
*Br    6 :Event.Weight : Double_t Weight[Event_]                             *
*Entries :    50000 : Total  Size=     601793 bytes  File Size  =      61174 *
*Baskets :       13 : Basket Size=      64000 bytes  Compression=   9.83     *
*............................................................................*
*Br    7 :Event.ScalePDF : Double_t ScalePDF[Event_]                         *
*Entries :    50000 : Total  Size=     601827 bytes  File Size  =     311536 *
*Baskets :       13 : Basket Size=      64000 bytes  Compression=   1.93     *
*............................................................................*
*Br    8 :Event.CouplingQED : Double_t CouplingQED[Event_]                   *
*Entries :    50000 : Total  Size=     601878 bytes  File Size  =      61264 *
*Baskets :       13 : Basket Size=      64000 bytes  Compression=   9.81     *
*............................................................................*
*Br    9 :Event.CouplingQCD : Double_t CouplingQCD[Event_]                   *
*Entries :    50000 : Total  Size=     601878 bytes  File Size  =     433690 *
*Baskets :       13 : Basket Size=      64000 bytes  Compression=   1.39     *
*............................................................................*
*Br   10 :Event_size : Event_size/I                                          *
*Entries :    50000 : Total  Size=     201033 bytes  File Size  =       1761 *
*Baskets :        7 : Basket Size=      32000 bytes  Compression= 113.88     *
*............................................................................*
*Br   11 :Rwgt      : Int_t Rwgt_                                            *
*Entries :    50000 : Total  Size=     403488 bytes  File Size  =      62473 *
*Baskets :       10 : Basket Size=      64000 bytes  Compression=   6.42     *
*............................................................................*
*Br   12 :Rwgt.fUniqueID : UInt_t fUniqueID[Rwgt_]                           *
*Entries :    50000 : Total  Size=     201211 bytes  File Size  =       1823 *
*Baskets :        7 : Basket Size=      64000 bytes  Compression= 110.05     *
*............................................................................*
*Br   13 :Rwgt.fBits : UInt_t fBits[Rwgt_]                                   *
*Entries :    50000 : Total  Size=     201167 bytes  File Size  =       1795 *
*Baskets :        7 : Basket Size=      64000 bytes  Compression= 111.75     *
*............................................................................*
*Br   14 :Rwgt.Weight : Double_t Weight[Rwgt_]                               *
*Entries :    50000 : Total  Size=     201178 bytes  File Size  =       1802 *
*Baskets :        7 : Basket Size=      64000 bytes  Compression= 111.32     *
*............................................................................*
*Br   15 :Rwgt_size : Rwgt_size/I                                            *
*Entries :    50000 : Total  Size=     201022 bytes  File Size  =       1633 *
*Baskets :        7 : Basket Size=      32000 bytes  Compression= 122.80     *
*............................................................................*
*Br   16 :Particle  : Int_t Particle_                                        *
*Entries :    50000 : Total  Size=     423494 bytes  File Size  =      62638 *
*Baskets :       10 : Basket Size=      64000 bytes  Compression=   6.40     *
*............................................................................*
*Br   17 :Particle.fUniqueID : UInt_t fUniqueID[Particle_]                   *
*Entries :    50000 : Total  Size=    1403370 bytes  File Size  =      76409 *
*Baskets :       26 : Basket Size=      64000 bytes  Compression=  18.35     *
*............................................................................*
*Br   18 :Particle.fBits : UInt_t fBits[Particle_]                           *
*Entries :    50000 : Total  Size=    1403250 bytes  File Size  =      76885 *
*Baskets :       26 : Basket Size=      64000 bytes  Compression=  18.24     *
*............................................................................*
*Br   19 :Particle.PID : Int_t PID[Particle_]                                *
*Entries :    50000 : Total  Size=    1403190 bytes  File Size  =     282709 *
*Baskets :       26 : Basket Size=      64000 bytes  Compression=   4.96     *
*............................................................................*
*Br   20 :Particle.Status : Int_t Status[Particle_]                          *
*Entries :    50000 : Total  Size=    1403280 bytes  File Size  =      78861 *
*Baskets :       26 : Basket Size=      64000 bytes  Compression=  17.78     *
*............................................................................*
*Br   21 :Particle.Mother1 : Int_t Mother1[Particle_]                        *
*Entries :    50000 : Total  Size=    1403310 bytes  File Size  =      78808 *
*Baskets :       26 : Basket Size=      64000 bytes  Compression=  17.79     *
*............................................................................*
*Br   22 :Particle.Mother2 : Int_t Mother2[Particle_]                        *
*Entries :    50000 : Total  Size=    1403310 bytes  File Size  =      78836 *
*Baskets :       26 : Basket Size=      64000 bytes  Compression=  17.79     *
*............................................................................*
*Br   23 :Particle.ColorLine1 : Int_t ColorLine1[Particle_]                  *
*Entries :    50000 : Total  Size=    1403400 bytes  File Size  =     272812 *
*Baskets :       26 : Basket Size=      64000 bytes  Compression=   5.14     *
*............................................................................*
*Br   24 :Particle.ColorLine2 : Int_t ColorLine2[Particle_]                  *
*Entries :    50000 : Total  Size=    1403400 bytes  File Size  =     263366 *
*Baskets :       26 : Basket Size=      64000 bytes  Compression=   5.33     *
*............................................................................*
*Br   25 :Particle.Px : Double_t Px[Particle_]                               *
*Entries :    50000 : Total  Size=    2605068 bytes  File Size  =    1717104 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   1.52     *
*............................................................................*
*Br   26 :Particle.Py : Double_t Py[Particle_]                               *
*Entries :    50000 : Total  Size=    2605068 bytes  File Size  =    1716928 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   1.52     *
*............................................................................*
*Br   27 :Particle.Pz : Double_t Pz[Particle_]                               *
*Entries :    50000 : Total  Size=    2605068 bytes  File Size  =    2400971 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   1.08     *
*............................................................................*
*Br   28 :Particle.E : Double_t E[Particle_]                                 *
*Entries :    50000 : Total  Size=    2605020 bytes  File Size  =    2366884 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   1.10     *
*............................................................................*
*Br   29 :Particle.M : Double_t M[Particle_]                                 *
*Entries :    50000 : Total  Size=    2605020 bytes  File Size  =     304884 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   8.54     *
*............................................................................*
*Br   30 :Particle.PT : Double_t PT[Particle_]                               *
*Entries :    50000 : Total  Size=    2605068 bytes  File Size  =    1678146 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   1.55     *
*............................................................................*
*Br   31 :Particle.Eta : Double_t Eta[Particle_]                             *
*Entries :    50000 : Total  Size=    2605116 bytes  File Size  =    1737453 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   1.50     *
*............................................................................*
*Br   32 :Particle.Phi : Double_t Phi[Particle_]                             *
*Entries :    50000 : Total  Size=    2605116 bytes  File Size  =    1732990 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   1.50     *
*............................................................................*
*Br   33 :Particle.Rapidity : Double_t Rapidity[Particle_]                   *
*Entries :    50000 : Total  Size=    2605356 bytes  File Size  =    1735773 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   1.50     *
*............................................................................*
*Br   34 :Particle.LifeTime : Double_t LifeTime[Particle_]                   *
*Entries :    50000 : Total  Size=    2605356 bytes  File Size  =      89809 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=  29.00     *
*............................................................................*
*Br   35 :Particle.Spin : Double_t Spin[Particle_]                           *
*Entries :    50000 : Total  Size=    2605164 bytes  File Size  =     298074 *
*Baskets :       44 : Basket Size=      64000 bytes  Compression=   8.74     *
*............................................................................*
*Br   36 :Particle_size : Particle_size/I                                    *
*Entries :    50000 : Total  Size=     201066 bytes  File Size  =       1783 *
*Baskets :        7 : Basket Size=      32000 bytes  Compression= 112.48     *
*............................................................................

Hi,

I see your point - could be simply memory corruption by a mismatch in read versus memory size. I agree, I’ll ask Philippe :slight_smile:

Axel.

Hi,

I can not reproduce the problem (does not crash for me, at least not in the Loop). The file and the source has matching array sizes (but a different file may have longer array and thus could fail).

I noted the slightly issue with the code:

      Long64_t ientry = LoadTree(jentry);
      if (ientry < 0) break;
      nb = fChain->GetEntry(jentry);   nbytes += nb;
     cout<<"nb = "<<nb<<endl; 
     nb = b_Particle_E->GetEntry(jentry);

where the last line ought to use ientry rather than jentry (but this would only be a real issue if this is used with a TChain with more than one file.

Cheers,
Philippe.

Please take the “ReadLHE.C” file that is attached to my post (the original “ReadLHE.h” file is fine).

BTW. Note that, in the piece of code that you show, the “nb = b_Particle_E->GetEntry(ientry);” is not needed at all as there’s the “nb = fChain->GetEntry(jentry);”.

Fair enough :slight_smile:. Yours does indeed crash …

Thanks,
Philippe.

Hi Wile,

As far as I can tell the crash with your version is due to CINT mis-handling of temporary objects (i.e. a known hard to fix problem) and not to TTree or MakeClass. (and this might be the original problem too since the original macro also has a temporary object).

Cheers,
Philippe.

PS. To work around the problem, the typical solution is to allocation the object via the operator new …

I can confirm that I get no problem, neither in “interpreted” nor in “precompiled” code, when I replace:

TLorentzVector Iqrk0(Particle_Px[im], Particle_Py[im], Particle_Pz[im], Particle_E[im]);

with:

TLorentzVector *Iqrk0 = new TLorentzVector(Particle_Px[im], Particle_Py[im], Particle_Pz[im], Particle_E[im]);
// ...
delete Iqrk0;

Sorry for late reply.

I compiled the macro edited by Wile E. and now its not giving me any error.