Hi,
When running my code, I get a warning, which I can’t tell whether or not it is a issue which I should pay attention.
root [0]
Processing run_HLTEffAna.C...
Info in <TUnixSystem::ACLiC>: creating shared library /afs/cern.ch/work/f/ftorresd/private/doubleMuPlusGammaEff/ggNtuples/analyzer/CMSSW_9_2_9/src/ZtoUpsilonPhoton/doubleMuPlusGammaHLTEff/tmpdir/HLTEffAna_ZtoUpsilonPhoton_C.so
N. Entries: 55266
Warning in <TTreeReader::SetEntryBase()>: The current tree in the TChain ggNtuplizer/EventTree has changed (e.g. by TTree::Process) even though TTreeReader::SetEntry() was called, which switched the tree again. Did you mean to call TTreeReader::SetLocalEntry()?
Here is a, not so small, snippet of the code which generate this:
run_HLTEffAna.C
{
gSystem->AddIncludePath("-Iexternal");
gSystem->SetBuildDir("tmpdir", kTRUE);
gROOT->ProcessLine(".L HLTEffAna_ZtoUpsilonPhoton.C++");
gStyle->SetOptStat(0);
vector<string> ggNtuplesFiles = {
"file:rootFilesForTest/DATA_MuonEG_Run2017F_v1_95.root",
"file:rootFilesForTest/DATA_MuonEG_Run2017F_v1_102.root",
"file:rootFilesForTest/DATA_MuonEG_Run2017F_v1_3.root",
"file:rootFilesForTest/DATA_MuonEG_Run2017F_v1_900.root",
};
HLTEffAna_ZtoUpsilonPhoton(ggNtuplesFiles);
}
HLTEffAna_ZtoUpsilonPhoton.C
#include <iostream>
#include "TFile.h"
#include "TLorentzVector.h"
#include "TTree.h"
#include "TTreeReader.h"
#include "TTreeReaderValue.h"
#include "TTreeReaderArray.h"
#include "../plugins/ggNtuplesFilesReader.h"
using namespace std;
void HLTEffAna_ZtoUpsilonPhoton(vector<string> ggNtuplesFiles)
{
TTreeReader * dataReader = ggNtuplesFilesReader( ggNtuplesFiles, nFiles );
TTree * dataTree = dataReader->GetTree();
// define readers
TTreeReaderArray< float > phoE(*dataReader, "phoE");
cout << "N. Entries: " << dataTree->GetEntries() << endl;
// data->Print();
while (dataReader->Next()) { // loop over events
for (unsigned int i = 0; i < phoE.GetSize(); i++){
cout << "phoE: " << phoE[i] << endl;
}
} // end loop over events
} //end ana_ZtoUpsilonPhoton
plugins/ggNtuplesFilesReader.h
#include "TChain.h"
#include "TTreeReader.h"
using namespace std;
TTreeReader * ggNtuplesFilesReader(vector<string> ggNtuplesFiles, int nFiles)
{
TChain * chain = new TChain("ggNtuplizer/EventTree");
for(unsigned int i = 0; i < ggNtuplesFiles.size(); i++) {
chain->AddFile( ggNtuplesFiles[i].c_str() );
}
// chain->Print();
TTreeReader * reader = new TTreeReader(chain);
return reader;
}
Any tip would be very helpfull.
Thanks in advance.
Best,
Felipe