TCut and operator

Is the and operator supposed to work with TCut?

>>> cut1 = ROOT.TCut("cut1")
>>> cut2 = ROOT.TCut("cut2")
>>> (cut1 and cut2).GetTitle()
'cut2'

in C++ it doesn’t work better:

root [0] TCut cut1("cut1")
root [1] TCut cut2("cut2")
root [2] cut1 && cut2

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00000038da6bcd3c in waitpid () from /lib64/libc.so.6
#1  0x00000038da642142 in do_system () from /lib64/libc.so.6
#2  0x0000003c2385d7c3 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.5.34
#3  0x0000003c2385f4bc in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.5.34
#4  <signal handler called>
#5  0x0000003c265cc3db in TCut::operator char const*() const () from /usr/lib64/root/libTree.so
#6  0x0000003c2653a7d3 in G__G__Tree_206_0_19(G__value*, char const*, G__param*, int) () from /usr/lib64/root/libTree.so
#7  0x00000038dc710b5d in Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) () from /usr/lib64/root/libCint.so.5.34
#8  0x00000038dc712f27 in G__execute_call () from /usr/lib64/root/libCint.so.5.34
#9  0x00000038dc7132e5 in G__call_cppfunc () from /usr/lib64/root/libCint.so.5.34
#10 0x00000038dc6ccdaf in G__interpret_func () from /usr/lib64/root/libCint.so.5.34
#11 0x00000038dc752b39 in G__getfunction () from /usr/lib64/root/libCint.so.5.34
#12 0x00000038dc6c4771 in G__convert_param () from /usr/lib64/root/libCint.so.5.34
#13 0x00000038dc6c6627 in G__overload_match () from /usr/lib64/root/libCint.so.5.34
#14 0x00000038dc6cb7a1 in G__interpret_func () from /usr/lib64/root/libCint.so.5.34
#15 0x00000038dc752b97 in G__getfunction () from /usr/lib64/root/libCint.so.5.34
#16 0x00000038dc76f310 in G__atevaluate () from /usr/lib64/root/libCint.so.5.34
#17 0x00000038dc772a5c in G__process_cmd () from /usr/lib64/root/libCint.so.5.34
#18 0x0000003c23829800 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /usr/lib64/root/libCore.so.5.34
#19 0x0000003c237b79e6 in TApplication::ProcessLine(char const*, bool, int*) () from /usr/lib64/root/libCore.so.5.34
#20 0x0000003c2321ee59 in TRint::HandleTermInput() () from /usr/lib64/root/libRint.so.5.34
#21 0x0000003c2385ec85 in TUnixSystem::CheckDescriptors() () from /usr/lib64/root/libCore.so.5.34
#22 0x0000003c2385f7aa in TUnixSystem::DispatchOneEvent(bool) () from /usr/lib64/root/libCore.so.5.34
#23 0x0000003c237f3796 in TSystem::InnerLoop() () from /usr/lib64/root/libCore.so.5.34
#24 0x0000003c237f43a0 in TSystem::Run() () from /usr/lib64/root/libCore.so.5.34
#25 0x0000003c237b60df in TApplication::Run(bool) () from /usr/lib64/root/libCore.so.5.34
#26 0x0000003c2322000e in TRint::Run(bool) () from /usr/lib64/root/libRint.so.5.34
#27 0x0000000000400fdc in main ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x0000003c265cc3db in TCut::operator char const*() const () from /usr/lib64/root/libTree.so
===========================================================

using ROOT 5.34/20

ROOT 6 handle that correctly:

root [0] TCut cut1("cut1")
(TCut &) @0x102ad6a78
root [1] TCut cut2("cut2")
(TCut &) @0x102ad6b38
root [2] cut1 && cut2
(TCut) @0x7fc62d625c80
root [3] (cut1 && cut2).GetTitle()
(const char *) "(cut1)&&(cut2)"

In ROOT 5 you will need something like:
TCut cut3 = cut1 && cut2;
cut3.GetTitle()
or:
TCut(cut1 && cut2).GetTitle()

ROOT 5 output:

root [0] TCut cut1("cut1")
root [1] TCut cut2("cut2")
root [2] TCut cut3 = cut1 && cut2;
root [3] cut3.GetTitle()
(const char* 0x7fee261e43d1)"(cut1)&&(cut2)"
root [4] TCut(cut1 && cut2).GetTitle()
(const char* 0x7fee2622f8c1)"(cut1)&&(cut2)"
root [5] 

Of course this works also in ROOT 6 :slight_smile:

[quote=“Wile E. Coyote”]In ROOT 5 you will need something like:
TCut cut3 = cut1 && cut2;
cut3.GetTitle()
or:
TCut(cut1 && cut2).GetTitle()[/quote]

is it a problem from cint (and so python)? because from the C++ point of view I don’t see the problem with temporaries.

I guess it is a CINT issue …

Hi,

Yes, sorry - that’s indeed a CINT issue, with parsing and operator evaluation, and there’s no way we will fix this :frowning: Can you move to ROOT 6?

Cheers, Axel.

[quote=“Axel”]Hi,

Yes, sorry - that’s indeed a CINT issue, with parsing and operator evaluation, and there’s no way we will fix this :frowning: Can you move to ROOT 6?

Cheers, Axel.[/quote]

Actually not, but it is not difficult to concatenate manually two strings with &&.

Axel,

lots of stuff broken with global operators in ROOT6, though. See this report: https://sft.its.cern.ch/jira/browse/ROOT-6552 that has been left neglected since forever.

Cheers,
Wim