ROOT Version 6.11/01
gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Hi,
I’m working on a machine learning project. I want to store the output of a classifier in a TTree, along with the corresponding eventNumber and runNumber for each given event. I also want to apply a cut based on some other criteria (number of b-jets for example) so I do not have to run the classifier over ALL the events.
In order to retrieve this information during the actual analysis, I load this “classifier tree” cls_tree and build the index:
cls_tree->BuildIndex( "runNumber", "eventNumber" )
During the event loop, I do:
for ientry in range(n_entries):
nominal_tree->GetEntry( ientry )
eventNumber = nominal_tree. eventNumber
runNumber = nominal_tree. runNumber
cls_tree.GetEntryWithIndex( runNumber, eventNumber )
This works fine with some events, but for some others fails. I tracked it down to the following issue: the eventNumber is stored in the nominal tree as a long int, while the GetEntryWithIndex() function accepts both parameters as Int_t . See for example:
root [0] TFile * f = TFile::Open( "derived_trees/classifier.dataAll.2b_incl.root")
(TFile *) 0x113f5720
root [1] TTree * t = (TTree*)f->Get("nominal")
(TTree *) 0x11311e80
root [2] t->BuildIndex( "runNumber", "eventNumber" )
(int) 37542
root [3] t->GetEntryWithIndex( 303638, 4972725192 )
ROOT_prompt_3:1:31: warning: implicit conversion from 'long' to 'Int_t' (aka 'int') changes value from 4972725192 to 677757896 [-Wconstant-conversion]
t->GetEntryWithIndex( 303638, 4972725192 )
~~~~~~~~~~~~~~~~~ ^~~~~~~~~~
(int) -1
I can’t change the definition of long int’s in the nominal tree, which is centrally produced. Is there a way to fix this problem in pyroot?
Cheers,
Riccardo