Limit on cut string length in TTree.Draw()?

Hello,

In a script, I am forming a string to be used as cut
in TTree.Draw() command, and I notice that ROOT crashes
when the string gets too long, the crash output is
appended at the bottom. In some cases, the crash
happened only after running over some large number of events,
while it ran fine on a smaller sample.

Is there a limit on the size of the string that one can use
to define a cut?

I append the offending string as illustration, and I am pretty sure
the length is the problem, because it runs if I just remove parts of it.
Is there a way to go around this and still using tree->Draw()
and a string as a cut. I know I can make a class and a selector
for my tree and then cut directly on the variables without strings,
but I would be glad if I don’t have to convert all my running scripts.

Best,
Vuko

[code]cut=(((((((((((((WlId!=0 && ZId!=0)&&(WlPt>20.))&&(abs(WEl_Eta)<2.5 || abs(Wmu_Eta)<2.5))&&(((ZEl1_Pt>10. &&ZEl2_Pt>10.) || (Zmul_Pt>10. && Zmu2_Pt>10.)) && ((ZEl1_Pt>15. || ZEl2_Pt>15.) || (Zmul_Pt>15. || Zmu2_Pt>15.))))&&((abs(Zmul_Eta)<2.5 && abs(Zmu2_Eta)<2.5)||(abs(ZEl1_Eta)<2.5 && abs(ZEl2_Eta)<2.5)))&&((abs(WlId)==11)||(((Wmu_Et_ecal_dr3 + Wmu_Et_hcal_dr3)<5. && Wmu_Pt_tr_dr25<2.)&&(abs(Wmu_d0/Wmu_d0_error)<3.))))&&((abs(WlId)==13)||((WEl_NbTracksDR015<3 && (WEl_IsoTrackDR020-WEl_ESC2exp(-WEl_SC_Eta)/(1+exp(-2WEl_SC_Eta)))/WEl_ESC2exp(-WEl_SC_Eta)/(1+exp(-2WEl_SC_Eta))<0.34 && WEl_HadOEM <0.08)&&(abs(WEl_d0/WEl_d0_error)<3.))))&&((abs(ZId)==11)||((((Zmul_Et_ecal_dr3 + Zmul_Et_hcal_dr3)<5. && (Zmu2_Et_ecal_dr3 + Zmu2_Et_hcal_dr3)<5.) && (Zmul_Pt_tr_dr25<2. && Zmu2_Pt_tr_dr25<2.))&&(abs(Zmul_d0/Zmul_d0_error) <3. && abs(Zmu2_d0/Zmu2_d0_error) <3.))))&&((abs(ZId)==13)||((ZEl1_NbTracksDR015 <3 && ZEl2_NbTracksDR015 <3 && ((ZEl1_IsoTrackDR020-ZEl1_ESC2exp(-ZEl1_SC_Eta)/(1+exp(-2ZEl1_SC_Eta)))/ZEl1_ESC2exp(-ZEl1_SC_Eta)/(1+exp(-2ZEl1_SC_Eta))<0.34) && ((ZEl2_IsoTrackDR020-ZEl2_ESC2exp(-ZEl2_SC_Eta)/(1+exp(-2ZEl2_SC_Eta)))/ZEl2_ESC2exp(-ZEl2_SC_Eta)/(1+exp(-2ZEl2_SC_Eta))<0.34) && (ZEl1_HadOEM <0.08 && ZEl2_HadOEM <0.08))&&(abs(ZEl1_d0/ZEl1_d0_error) <3. && abs(ZEl2_d0/ZEl2_d0_error) <3.))))&&(Jet1Et<20))&&(((abs(WlId)==13)||(abs(ZId)==11))||((sqrt(pow(Zmul_Eta-WEl_Eta,2) + pow(acos(cos(Zmul_Phi-WEl_Phi)),2))>0.1)&&(sqrt(pow(Zmu2_Eta-WEl_Eta,2) + pow(acos(cos(Zmu2_Phi-WEl_Phi)),2))>0.1))))(abs(WlId)==11 && ZId==11))(339.21048*(alpgenID==1000)+94.6833267*(alpgenID == 1001 && weight < 1.03)+42.2297287*(alpgenID == 1001 && weight > 1.03)+103.98037*(alpgenID == 1002 && weight > 1.)+52.0592308*(alpgenID == 1002 && weight < 1.)+15128.2051*(alpgenID == 1003 && weight > 1.)+84.3881836*(alpgenID == 1003 && weight < 1.)+112.714157*(alpgenID == 1004 && weight > 0.96)+ 5000*(alpgenID == 1004 && weight < 0.96)+80.9523773*(alpgenID == 1005 && weight >1.)+40.1606407*(alpgenID == 1005 && weight < 1.)+189.019669*(alpgenID == 2000)+91.9099579*(alpgenID == 2001 && weight> 0.9)+1111.11108*(alpgenID == 2001 && weight < 0.9)+101.270554*(alpgenID == 2002 && weight > 0.9)+10.6261864*(alpgenID == 2002 && weight < 0.9)+53.7974701*(alpgenID == 2003 && weight > 0.9)+ 1300*(alpgenID == 2003 && weight < 0.9)+628.571472*(alpgenID == 2005 && weight < 0.8)+4.81335974*(alpgenID == 2005 && weight > 0.8)+83.5921707*(alpgenID == 3000)+18.5146217*(alpgenID == 3001)+13.5242643*(alpgenID == 3002)))*(alpgenID>=1000 && alpgenID<1500)

*** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library “/lib/tls/libthread_db.so.1”.
Attaching to program: /proc/18452/exe, process 18452
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
[Thread debugging using libthread_db enabled]
[New Thread -151902528 (LWP 18452)]
0x001917a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x04c88d23 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2 0x04c327a9 in do_system () from /lib/tls/libc.so.6
#3 0x0017698d in system () from /lib/tls/libpthread.so.0
#4 0x0085edf5 in TUnixSystem::Exec () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#5 0x0085f2b9 in TUnixSystem::StackTrace () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#6 0x0085d064 in TUnixSystem::DispatchSignals ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#7 0x0085ae64 in SigHandler () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#8 0x00861c6c in sighandler () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#9
#10 0x0074d5b3 in TString::Index () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#11 0x031a852a in TSelectorDraw::Begin ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libTreePlayer.so
#12 0x031cf10d in TTreePlayer::Process ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libTreePlayer.so
#13 0x031c89b6 in TTreePlayer::DrawSelect ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libTreePlayer.so
#14 0x05931a7d in TTree::Draw () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libTree.so
#15 0x05909bb2 in TChain::Draw () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libTree.so
#16 0x05959ebf in G__G__Tree_131_0_38 () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libTree.so
#17 0x00e90051 in Cint::G__ExceptionWrapper ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#18 0x00f71fb4 in G__call_cppfunc () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#19 0x00f5d87a in G__interpret_func () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#20 0x00f411e2 in G__getfunction () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#21 0x00ff3803 in G__getstructmem () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#22 0x00fe99e1 in G__getvariable () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#23 0x00f332f9 in G__getitem () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#24 0x00f30c49 in G__getexpr () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#25 0x00f1510b in G__define_var () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#26 0x00f974cc in G__exec_statement () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#27 0x00f954f5 in G__exec_loop () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#28 0x00f95eee in G__exec_for () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#29 0x00f9ac0c in G__exec_statement () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#30 0x00f954f5 in G__exec_loop () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#31 0x00f95eee in G__exec_for () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#32 0x00f9ac0c in G__exec_statement () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#33 0x00f5f6ae in G__interpret_func () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#34 0x00f41b7c in G__getfunction () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#35 0x00f3341c in G__getitem () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#36 0x00f30c49 in G__getexpr () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#37 0x00f90326 in G__exec_function () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#38 0x00f9afd5 in G__exec_statement () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#39 0x00f5f6ae in G__interpret_func () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#40 0x00f41b7c in G__getfunction () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#41 0x00f3341c in G__getitem () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#42 0x00f30c49 in G__getexpr () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#43 0x00f21aa1 in G__calc_internal () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#44 0x00fa208f in G__process_cmd () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
#45 0x007b0de3 in TCint::ProcessLine () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#46 0x007b0f7d in TCint::ProcessLineSynch () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#47 0x006d2fff in TApplication::ProcessFile ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#48 0x006d2824 in TApplication::ProcessLine ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#49 0x0011e054 in TRint::HandleTermInput () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libRint.so
#50 0x0011c5bb in TTermInputHandler::Notify ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libRint.so
#51 0x0011e50e in TTermInputHandler::ReadNotify ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libRint.so
#52 0x0085d4f5 in TUnixSystem::CheckDescriptors ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#53 0x0085c22e in TUnixSystem::DispatchOneEvent ()
from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#54 0x0075ec9c in TSystem::InnerLoop () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#55 0x0075ec35 in TSystem::Run () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#56 0x006d3119 in TApplication::Run () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
#57 0x0011d9c0 in TRint::Run () from /users/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libRint.so
#58 0x08048d81 in main ()
Root > Function overlayplots() busy flag cleared
Function makePlots() busy flag cleared[/code]

Hi,

In ROOT 5.14/00 the limitation was 2555 characters for the sum of both the selection and variables string’s size.

This limitation was completely lifted in 5.15/04.

You can work around this limitation by using a TEventList and calling mylist->SetReapplyCut(kTRUE); on it (see the TTree documentation for details)

Cheers,
Philippe

Hi Philippe,

I confirm that using a later version, 5.18/00, solves my problem.
I was using 5.14/00f (the version included in the CMS software
version used for that particular task).

Thank you for your help and best regards,
Vuko