TRef reading back entry from file

Hi,

I have a question regarding how TRef access the object from file.

For systematics study, I’m scaling the jet 4-mom by +/-1 and need to propagate that to the missingEt computation.
In order to not have to do this all over the place, I’m trying to do it once at the beginning of the event loop, changing the actual values of the jet TLorentzVector read from the ntuple, since i’m accessing this via pointer:

b_jetA[idxJetBr]->GetEntry(jentry); std::vector<Jet>* _jetA = Nt.jetA[idxJetBr]; for(unsigned int ii=0; ii<jetA->size(); ii++){ Jet* _j = &(*jetA)[ii]; std::cout << "Jet before "; _j->print(); TLorentzVector _corrLv= _j->lv().operator*( scaleJet(_j) ); _j->setLV( _corrLv ); std::cout << "Jet after "; _j->print(); }

This all works find each time I access jets form Nt.jetA[] vector…
However, when I access the same jet via a TRef from another branch/object, the TRef returns the value of the jets from the ntuple and not the one from memory.

for(unsigned int io=0; io< _metJetA.size(); io++){ const UCI::MetObject* _obj = _metJetA[io]; UCI::Jet* _j = (UCI::Jet*) _obj->ref().GetObject(); //Grabbing jet contributing to Met std::cout<< "\tRefJet "; _j->print(); //returns values from file }

From reading the documentation on TRef/TBranchRef, I was under the impression that once the object is loaded into memory it is not read back from file via TRef.

I’m a doing something obviously wrong or is there a way to change this behavior ?

Cheers
-a

[quote]From reading the documentation on TRef/TBranchRef, I was under the impression that once the object is loaded into memory it is not read back from file via TRef.[/quote]This is indeed the expected behavior ; I would suspect that the modified version either got deleted or got re-used (i.e. its unique id changed) in between the two code snippet. If you provide a small running example reproducing the problem I will take a look.

Cheers,
Philippe.

Hi Philippe,

Thanks for the prompt feedback.
TRef behaves as expected, once read in memory, TRef re-access the value in memory.
I found the issue in my code #-o

One more question, is there a way to know via TBranch if a call to GetEntry was already done, ie know if the branch was already loaded to memory for a given event ?

Cheers
-a

Hi,

Yes, check the value of branch->GetReadEntry()

Cheers,
Philippe