Hi, extreme newbie here. I am not sure if this is a ROOT problem per se or just a c++ problem, since I’m very new to the language. I am writing a function that goes through a Chain of trees from 5 files, and looks for the index of the entry that passes the tight selection criteria for being the leading jet. This function is written inside the Macro generated by the Makeclass() method (which I have called testMC.C). The code compiles fine, but always returns -1, even though it should return the index of the leading jet (and I am certain that at least one jet passes the selection criteria).
Int_t testMC::JetSelection() {
//finds the index of leading jet based on tight selection criteria
Int_t jc = -1;
for (int i=0; i<nJet; i++) {
fChain->GetEntry(i);
if ((*jetEta)[i] <= 2.6) {
if ((*jetNHF)[i] < 0.9 && (*jetNEF)[i] < 0.9 && (*jetNConstituents)[i] > 1 && (*jetMuonEnF)[i] < 0.8 && (*jetCHF)[i] > 0 && (*jetNCharged)[i] > 0 && (*jetCEF)[i] < 0.8) {
jc = i;
}
if (jc != -1) {
break;
}
}
else if ((*jetEta)[i] > 2.6 && (*jetEta)[i] <= 2.7) {
if ((*jetNHF)[i] < 0.9 && (*jetNEF)[i] < 0.99 && (*jetMuonEnF)[i] < 0.8 && (*jetNCharged)[i]>0 && (*jetCEF)[i] < 0.8) {
jc = i;
}
if (jc != -1) {
break;
}
}
else if ((*jetEta)[i] > 2.7 && (*jetEta)[i] <= 3.0) {
if (((*jetNEF)[i] < 0.99 && (*jetNEF)[i] > 0.2) && (*jetNNeutral)[i] >2) {
jc = i;
}
if (jc != -1) {
break;
}
}
else if ((*jetEta)[i] > 3.0 && (*jetEta)[i] <= 5.0) {
if ((*jetNHF)[i] > 0.2 && (*jetNEF)[i] < 0.9 && (*jetNNeutral)[i] > 10) {
jc = i;
}
if (jc!= -1) {
break;
}
}
}
return jc;
}