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.