Re: [ROOT] vicious problem with TCut

From: Edmond Offermann (edmondoffermann@yahoo.com)
Date: Fri Feb 06 2004 - 13:52:31 MET


Hi Mathieu,

I guess scoping issues in CINT . Bring the TCut
declarations out of the loop:

void start()
{
  int max=30;
  int iterator=0;
  TCut cut1;
  TCut cut2;
  TCut cut;
  while(iterator!=max)
  {
    if(iterator<10 || iterator>20)  // <--- *********
    {
      cout<<"hello: "<<iterator<<endl;
      TString str_cut1="detCEL==1";
      cut1=str_cut1;
      TString str_cut2="sampCEL==2";
      cut2=str_cut2;
      cut = cut1 && cut2;  // <--- *********
    }
    ++iterator;
  }
}

Eddy
--- Matthieu LECHOWSKI <lechowsk@lal.in2p3.fr> wrote:
> Hello,
> 
> One of my macros crashes, and I can reproduce the
> problem in this little 
> simple example:
> 
> void start()
> {
>   int max=30;
>   int iterator=0;
>   while(iterator!=max)
>   {
>     if(iterator<10 || iterator>20)  // <---
> *********
>     {
>       cout<<"hello: "<<iterator<<endl;
>       TString str_cut1="detCEL==1"; 	
>       TCut cut1=str_cut1;
>       TString str_cut2="sampCEL==2";
>       TCut cut2=str_cut2;
>       TCut cut = cut1 && cut2;  // <--- *********
>     }
>     ++iterator;
>   }
> }
> Try to execute this and you will have the "break
> segmentation violation" 
> below, but:
>  - if you comment the line TCut cut = cut1 && cut2;
> OR
>  - if you do not make the cut (10->20) in the loop
> then it works !!
> Hard to believe it...
> Maybe I don't use correctly the TCuts (not a big
> experience with them) ? In 
> my macro, I retrieve a ntuple and want draw
> variables (as "detCEL" and 
> "sampCEL") with cuts.
> 
> Could you help me ??
> 
> Matthieu.
> 
> PS: I'm working on lxplus with 
>
ROOTSYS=/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root
> 
>  *** Break *** segmentation violation
>  Generating stack trace...
>  0x406dcc84 in G__exec_asm + 0x1714 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x406cdee5 in G__exec_loop + 0x4d9 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x406ce0fa in G__exec_while + 0x82 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x406d0f7e in G__exec_statement + 0x289a from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x406a1eb4 in G__interpret_func + 0x20c0 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x406872ae in G__getfunction + 0x1f86 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x4067bd11 in G__getitem + 0x715 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x4067a3c3 in G__getexpr + 0x8c5f from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x406c9c6b in G__exec_function + 0x17b from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x406d131d in G__exec_statement + 0x2c39 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x406610bc in G__exec_tempfile_core + 0x2b4 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x4066128d in G__exec_tempfile_fp + 0x25 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x406d9edc in G__process_cmd + 0x5094 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCint.so
>  0x40198b1e in TCint::ProcessLine(char const *,
> TInterpreter::EErrorCode *) 
> + 0x9e from
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCore.so
>  0x401162fe in TApplication::ProcessLine(char const
> *, bool, int *) + 0x5b2 
> from
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCore.so
>  0x40f51333 in TRint::HandleTermInput(void) + 0x1bb
> from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libRint.so
>  0x40f503e1 in TTermInputHandler::Notify(void) +
> 0x29 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libRint.so
>  0x40f5173c in TTermInputHandler::ReadNotify(void) +
> 0x24 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libRint.so
>  0x40204d9a in TUnixSystem::CheckDescriptors(void) +
> 0xfe from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCore.so
>  0x402044c4 in TUnixSystem::DispatchOneEvent(bool) +
> 0x110 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCore.so
>  0x401688a9 in TSystem::InnerLoop(void) + 0x31 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCore.so
>  0x40168819 in TSystem::Run(void) + 0x79 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCore.so
>  0x40116cd6 in TApplication::Run(bool) + 0x32 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libCore.so
>  0x40f50d5b in TRint::Run(bool) + 0x2e3 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/lib/libRint.so
>  0x080488ac in main + 0x88 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/bin/root.exe
>  0x42017589 in __libc_start_main + 0x95 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/bin/root.exe
>  0x08048751 in __register_frame_info + 0x35 from 
>
/afs/cern.ch/sw/root/v3.10.02/rh73_gcc2952/root/bin/root.exe
> Root > Function start() busy flag cleared
> 
> NB: with my macro (more heavy than the little
> example above), I have in 
> addition the line below appearing when I leave with
> .q
>  Error: ~TString() header declared but not defined
> FILE: LINE:0
> 
> Problem of TString's destructor when it's used by
> TCut ??
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET