MakeSelector - TCut problem?

Hello all, what I’m trying to do is firstly chain all my datafile.root’s together, then use MakeSelector to give me an output file of only the data which is present in my TCuts.

root -l chain_files.C++

(chains ok)


After a while the expected TH2F appears on c1, I do a TCut and name it ‘chiopl’, as expected in the code. Then a second TH2F appears on c2. I do another TCut and name it ‘chiodc’. The process loop works up to the point between ‘here4’ and ‘here5’ in the code, where there is a segmentation violation. I include this error in case it is useful.

Any help would be much appreciated, Ben.

"here 4

*** Break *** segmentation violation
Generating stack trace…
0xb4f43490 in benselector::Process(long long) + 0x2cc from /home/bp/useful/nicklad/./
0xb5b6bc34 in TTreePlayer::Process(TSelector*, char const*, long long, long long) + 0x3f4 from /usr/local/root/lib/
0xb5b6b575 in TTreePlayer::Process(char const*, char const*, long long, long long) + 0xaf from /usr/local/root/lib/
0xb6aed000 in TTree::Process(char const*, char const*, long long, long long) + 0x80 from /usr/local/root/lib/
0xb6ac935f in TChain::Process(char const*, char const*, long long, long long) + 0xd3 from /usr/local/root/lib/
0xb6b46377 in from /usr/local/root/lib/
0xb7317b9d in G__ExceptionWrapper + 0x57 from /usr/local/root/lib/
0xb73cb6e0 in G__call_cppfunc + 0x2d8 from /usr/local/root/lib/
0xb73b5637 in G__interpret_func + 0x82b from /usr/local/root/lib/
0xb73aa765 in G__getfunction at v6_func.cxx:0 from /usr/local/root/lib/
0xb743d9a9 in G__getstructmem at v6_var.cxx:0 from /usr/local/root/lib/
0xb74350c7 in G__getvariable at v6_var.cxx:0 from /usr/local/root/lib/
0xb738a895 in G__getitem at v6_expr.cxx:0 from /usr/local/root/lib/
0xb73956e2 in G__getexpr at v6_expr.cxx:0 from /usr/local/root/lib/
0xb73e88b1 in G__exec_function + 0xcd from /usr/local/root/lib/
0xb73ee40f in G__exec_statement at v6_parse.cxx:0 from /usr/local/root/lib/
0xb73774f4 in G__exec_tempfile_core + 0x35c from /usr/local/root/lib/ 0xb73776e0 in G__exec_tempfile_fp + 0x2e from /usr/local/root/lib/
0xb73fa444 in G__process_cmd + 0x552c from /usr/local/root/lib/
0xb7888c13 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0x129 from /usr/local/root/lib/
0xb77b3184 in TApplication::ProcessLine(char const*, bool, int*) + 0x6c2 from /usr/local/root/lib/
0xb68091d9 in TRint::HandleTermInput() + 0x259 from /usr/local/root/lib/
0xb6808873 in TTermInputHandler::Notify() + 0x25 from /usr/local/root/lib/
0xb680a91a in TTermInputHandler::ReadNotify() + 0x14 from /usr/local/root/lib/
0xb7924768 in TUnixSystem::CheckDescriptors() + 0x148 from /usr/local/root/lib/
0xb7924a02 in TUnixSystem::DispatchOneEvent(bool) + 0x14c from /usr/local/root/lib/
0xb7837355 in TSystem::InnerLoop() + 0x21 from /usr/local/root/lib/
0xb78372f3 in TSystem::Run() + 0x71 from /usr/local/root/lib/
0xb77b2450 in TApplication::Run(bool) + 0x34 from /usr/local/root/lib/
0xb6809697 in TRint::Run(bool) + 0x39f from /usr/local/root/lib/
0x08048d17 in main + 0x87 from /usr/local/root/bin/root.exe
0xb65baea2 in __libc_start_main + 0xd2 from /lib/tls/i686/cmov/
0x08048c11 in TApplicationImp::ShowMembers(TMemberInspector&, char*) + 0x31 from /usr/local/root/bin/root.exe
Root >"
boselector.h (38.6 KB)
boselector.C (2.54 KB)
chain_files.C (758 Bytes)

At the time you get the crash, your pointer h1 is unknown.
Could you try the code in attachment (look at line with “//<=========”

boselector.C (2.68 KB)

Hello Rene, thankyou for the very quick reply! Your modifications to the .C file changed h1 (from oldh1.png to newh1.png), unfortunately I cannot use newh1.png to do the TCut. This change does not happen when “h1->SetDirectory(0);” is commented out.
Naturally, that is what I tried next. Unfortunately after the first TCut I received the following error; Error in TTreeFormula::Compile: Bad numerical expression : “title”

After this I removed “title” from h1’s definition, leaving it as “”. On the next compilation I received the errors; Error in TTreeFormula::DefinedVariable: Found a TCutG without leaf information (chiopl)
Error in TTreeFormula::Compile: Bad numerical expression : “chiopl”

Which did not happen previously. Thanks in advance, Ben.

Remove the line
h1->SetDirectory(0); //<==============


Hello Rene, unfortunately doing that caused some errors after the first TCut (see above). Thanks anyway, Ben.

To make progress with your problem, I would need your code (if possible correct C++ code checked with ACLIC) and your data files.


That is very generous Rene, The smallest of my files which I chain can be downloaded at I have tested it and it replicates the same problem.

root [0] TFile f(“Run635_cal.root”);
root [1] TTree t1 = (TTree) f->Get(“Analysed_Data”);
root [2] t1->Process(“boselector.C++”);

on c1 do a TCut, name it chiopl

(I find I have to name it twice for it to work)

On c1_n2 there should appear the gated CHIO_Cal:DcX1 {chiopl}.

Another TCut, named chiodc.

Process loop works, until ‘segment violation’ between cout ‘here4’ and cout ‘here5’.

Best Regards, Ben.

Apologies, the link should read

The file size is 3.8M.

I did not realize that you had already declared the pointer h1 in boselector.h (but with TH1F instead of TH2F). I can run your test with the files modified in attachment.

boselector.h (38.6 KB)
boselector.C (2.61 KB)

I feel I’m making good progress now - thankyou for your help!

Hello all. Using MakeSelector when I apply one TCut ‘if’ condition to the processing loop it works fine. When I apply another on its own - that works fine.

When I apply them both (’&&’) in the output the branches cannot be opened using TBrowser or piped into histograms. There are definitely events in both TCuts together.

Bool_t boselector::Process(Long64_t entry)

      if ( chiopl->IsInside(EPL_R,CHIO_Cal) )   
      // Or this also works;
      // if ( chiodc->IsInside(DcX1,CHIO_Cal))   

return kTRUE;
return kFALSE;

//************* (The above works fine, the below does not)

Bool_t boselector::Process(Long64_t entry)

      if ( chiodc->IsInside(DcX1,CHIO_Cal) && chiopl->IsInside(EPL_R,CHIO_Cal) )   

return kTRUE;
return kFALSE;


I have tried putting one if loop inside the other, changing the condition to (chiopl && chiodc) and putting further brackets around each condition;
if ( (chiodc->IsInside(DcX1,CHIO_Cal)) && (chiopl->IsInside(EPL_R,CHIO_Cal)))

I include my MakeSelector if it helps. Cheers, Ben.
boselector.h (43.5 KB)
boselector.C (3.16 KB)

Not that anyone’s interested, but the problem was that TH2F *h1; was defined first before piping.

So commenting TH2F*h1; in the .h, and commenting // h1 = new TH2F(“h1”,“title”,1000,2900,8000,1000,2200,3800); (in the .C)

and replacing it with a direct pipe

fixed it.