Problems with TSelector and TEventList

Ciao!

I have a problem using TSelector and TEventList.

Following the example h1analysis.C I created a class Selector that inherits from TSelector. However, instead of using the MakeSelector method, I tried to implement the class by myself.

This is my selector class:

[code]class Selector : public TSelector{

public:

TTree *fChain;    
TrkLevel2 *event;

Selector(TTree *tree=0);
~Selector();
int     Version() const {return 1;}
void    Begin(TTree *tree);
void    SlaveBegin(TTree *tree);
void    Init(TTree *tree);
Bool_t  Notify();
Bool_t  Process(Long64_t entry);
void    SetOption(const char *option) { fOption = option; }
void    SetObject(TObject *obj) { fObject = obj; }
void    SetInputList(TList *input) {fInput = input;}
TList  *GetOutputList() const { return fOutput; }
void    SlaveTerminate();
void    Terminate();

ClassDef(Selector,0);

};[/code]

TrkLevel2 is the class that I used to create the tree branch I want to read.
(I don’t attach here the class definition, hoping it is not the problem).

Inside the Init() method I set the branch address:

[code]void Selector::Init(TTree *tree)
{
// Set branch addresses
printf(“Selector: Init() \n”);
if (tree == 0) return;
fChain = tree;

tree->SetBranchAddress("TrkLevel2",&event);

}[/code]

In the Process() method I read the event and fill, if required, the TEventList:

[code]Bool_t Selector::Process(Long64_t entry)
{
// entry is the entry number in the current Tree

// get entry
fChain->GetTree()->GetEntry(entry);

// ----- selection -----
if(event->GetNTracks() <1>Enter(fChain->GetChainEntryNumber(entry));

return kTRUE;

}[/code]

I create a chain and apply the method Process(“Selector.C”,“fillList”), with the option “fillList” to fill the event list. All this work (I checked the list and it contains the correct chain entries).

Hence I apply the event list to the chain with SetEventList(elist), and also this works, becouse if I make a scan only the selected events are printed.

Then if I apply again my selector, I would expect it to loop only over pre-selected events.
However, it almost work… but for some entries I got error messages like:

[quote]Warning in : basket:fUniqueID has fNevBuf=7980 but fEntryOffset=0, pos=10835447, len=31999, fNbytes=251, fObjlen=31920, trying to repair
Error in : File: 6.Level2.root at byte:9690, branch:fBits, entry:-1, badread=-1
[/quote]
or:

[quote]R__unzip: error in inflate (zlib)
Error in : fNbytes = 31562, fKeylen = 84, fObjlen = 32016, noutot = 0, nout=0, nin=31478, nbuf=32016
Warning in : basket:estrip has fNevBuf=72 but fEntryOffset=0, pos=16959, len=32100, fNbytes=31562, fObjlen=32016, trying to repair
Error in : File: 130.Level2.root at byte:387143, branch:SingletX.cls, entry:111, badread=0

[/quote]
Is it something related to the procedure I am applying? Did I misunderstood something in the use of TSelector and/or TEventList?

I hope my problem is not too stupid and I don’t make you waste too much time…
Anyway, thank you in advance for the help!!

Elena.

Unfortunatly you do not indicate which version of ROOT you use.
It is likely that you have a version where we had a bug with entrylitsts
and the cache manager. Just try
fChain->SetCacheSize(0) in your Begin function.

Rene

Dear Rene,

the ROOT version I am using is
Version 5.12/00e 6 September 2006

I followed your suggestion but the script simply crashes.
This is the stack trace:

[quote] *** Break *** segmentation violation
Generating stack trace…
0x00146f0a in G__ExceptionWrapper + 0x42 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001e290f in G__call_cppfunc + 0x2a7 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001d1792 in G__interpret_func + 0x7de from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001c0402 in G__getfunction + 0x14e0 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x00242c14 in G__getstructmem + 0xab4 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x0023c41d in G__getvariable + 0x5e3 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001b734b in G__getitem + 0x521 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001b5fe6 in G__getexpr + 0x884c from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001f9be6 in G__exec_function + 0x1d8 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x00200ac0 in G__exec_statement + 0x254a from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001d314e in G__interpret_func + 0x219a from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x0017b121 in G__CallFunc::ExecInterpretedFunc(G__value*) + 0x11b from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x0017afbd in G__CallFunc::Execute(void*) + 0xa3 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x02f842ed in TSelectorCint::Begin(TTree*) + 0x6b from /home/pamela_software_test/installed/ROOT/lib/libTree.so
0x01945252 in TTreePlayer::Process(TSelector*, char const*, long long, long long) + 0x88 from /home/pamela_software_test/installed/ROOT/lib/libTreePlayer.so
0x01945174 in TTreePlayer::Process(char const*, char const*, long long, long long) + 0xca from /home/pamela_software_test/installed/ROOT/lib/libTreePlayer.so
0x02f92af1 in TTree::Process(char const*, char const*, long long, long long) + 0x63 from /home/pamela_software_test/installed/ROOT/lib/libTree.so
0x02f6c15f in TChain::Process(char const*, char const*, long long, long long) + 0xa7 from /home/pamela_software_test/installed/ROOT/lib/libTree.so
0x02fedfc5 in from /home/pamela_software_test/installed/ROOT/lib/libTree.so
0x00146f0a in G__ExceptionWrapper + 0x42 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001e290f in G__call_cppfunc + 0x2a7 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001d1792 in G__interpret_func + 0x7de from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001c0402 in G__getfunction + 0x14e0 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x00242c14 in G__getstructmem + 0xab4 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x0023c41d in G__getvariable + 0x5e3 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001b734b in G__getitem + 0x521 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001b5fe6 in G__getexpr + 0x884c from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x001f9be6 in G__exec_function + 0x1d8 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x00200ac0 in G__exec_statement + 0x254a from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x0019d2d4 in G__exec_tempfile_core + 0x2ee from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x0019d4c6 in G__exec_tempfile_fp + 0x22 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x00209075 in G__process_cmd + 0x4767 from /home/pamela_software_test/installed/ROOT/lib/libCint.so
0x009fb338 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0x138 from /home/pamela_software_test/installed/ROOT/lib/libCore.so
0x00934110 in TApplication::ProcessLine(char const*, bool, int*) + 0x61e from /home/pamela_software_test/installed/ROOT/lib/libCore.so
0x0068de4f in TRint::HandleTermInput() + 0x1dd from /home/pamela_software_test/installed/ROOT/lib/libRint.so
0x0068c988 in TTermInputHandler::Notify() + 0x24 from /home/pamela_software_test/installed/ROOT/lib/libRint.so
0x0068e706 in TTermInputHandler::ReadNotify() + 0x12 from /home/pamela_software_test/installed/ROOT/lib/libRint.so
0x00a849ce in TUnixSystem::CheckDescriptors() + 0x144 from /home/pamela_software_test/installed/ROOT/lib/libCore.so
0x00a838bc in TUnixSystem::DispatchOneEvent(bool) + 0x152 from /home/pamela_software_test/installed/ROOT/lib/libCore.so
0x009b319a in TSystem::InnerLoop() + 0x18 from /home/pamela_software_test/installed/ROOT/lib/libCore.so
0x009b313f in TSystem::Run() + 0x6f from /home/pamela_software_test/installed/ROOT/lib/libCore.so
0x00934bf0 in TApplication::Run(bool) + 0x32 from /home/pamela_software_test/installed/ROOT/lib/libCore.so
0x0068d8e0 in TRint::Run(bool) + 0x3e6 from /home/pamela_software_test/installed/ROOT/lib/libRint.so
0x080488dd in main + 0x71 from /home/pamela_software_test/installed/ROOT/bin/root.exe
0x014df79a in __libc_start_main + 0xda from /lib/tls/libc.so.6
0x080487e1 in _Unwind_Resume + 0x31 from /home/pamela_software_test/installed/ROOT/bin/root.exe
[/quote]

I went on trying, and I noticed that I have problems only with one file, which differs from the other in the chain only for the size: it inlcudes about 70000 entries, for a total of about 100M.
Is it maybe too big?
I will try again with smaller files.

Thank you for the help!

Ciao,
Elena.

[quote]Warning in : basket:fUniqueID has fNevBuf=7980 but fEntryOffset=0, pos=10835447, len=31999, fNbytes=251, fObjlen=31920, trying to repair
Error in : File: 6.Level2.root at byte:9690, branch:fBits, entry:-1, badread=-1
[/quote]This means that in your in one of the case where the new prefetch cache was broken. Use a new version of ROOT or disable the cache:

mychain->SetCacheSize(0);Cheers,
Philippe

Ciao!

Ok, finally it seems to work.
I disabled the cache.
But I have to do it just after creating the chain. If I do it inside the Begin() method of the selector it does not work, it crashes.

Thank you again!
Have a nice weekend!

Elena.