fix bugs and inefficiencies in jet systematics
NB: the CMSSW patch storeJERFactorIndex942
was also updated.
The jet systematic-related branches are now:
Jets_jecFactor
Jets_jecUnc
Jets_jerFactor
Jets_jerFactorUp
Jets_jerFactorDown
Jets_origIndex
JetsJECdown_origIndex
JetsJECdown_jerFactor
JetsJECup_origIndex
JetsJECup_jerFactor
JetsJERdown_origIndex
JetsJERup_origIndex
plus the usual scalars.
JetsJEC[down,up]_jerFactor
is added because the central JER smearing is applied after the JEC uncertainty is evaluated. Therefore, to recompute the varied 4-vectors offline, we must keep track of the JER smearing factors evaluated using the JEC-varied jet pT.
Jets_origIndex
is added because the other origIndex
branches point to the jet collection that existed before central JER smearing was applied, but we actually store the jet collection after the smearing. Smearing implies reordering, so we must point back to a "common ancestor". I envision the use of this branch as follows:
vector<int> newIndex(Jets_origIndex.size(),-1);
for(unsigned j = 0; j < Jets_origIndex.size(); ++j){
//reverse the index vector
newIndex[Jets_origIndex[j]] = j;
}
vector<TLorentzVector> JetsJECup(Jets.size());
for(unsigned j = 0; j < JetsJECup_origIndex.size(); ++j){
//JetsJECup_origIndex is sorted in the final order after JEC uncertainty variation
//go up to common ancestor, then down to central smeared collection
int i = newIndex[JetsJECup_origIndex[j]];
//undo central smearing, apply JEC unc, redo smearing w/ new smearing factor
JetsJECup[j] = Jets[i]/Jets_jerFactor[i]*(1+Jets_jerUnc[i])*JetsJECup_jerFactor[j];
}
//etc.
I also differentiated the userfloat names for the origIndex
added by the JEC uncertainty producer vs. the JER uncertainty producer. It is important to know which producer created which origIndex, because we need to store the first instance of it. (For the JEC uncertainty variations, the JER producer will store a second "origIndex" when it computes the central smearing, but this will point back to the JEC-varied collection, not the "common ancestor" collection before any variation or smearing.)
The JEC and JER producers were updated to be able to produce the userfloat for the uncertainty factor (keyed to the original collection) alongside the new collection. This avoids the need to run the producers multiple times with the same settings to get all the info. (It's perhaps a bit confusing conceptually, but technically there wasn't a problem to move to this mode.) The JER producer can instead directly add the uncertainty factor as a userfloat to the new collection (needed for JetsJEC[down,up]_jerFactor
). This reduces CPU usage by a few percent. The event size increases by a few percent because of the few new jet-related branches.
The JetDepot
now additionally returns the intermediate tag from the JEC producer, which may be needed to get the JEC uncertainty value. (When it is not needed, it is captured as _
, as recommended by some Python styles.) There are a few minor changes in makeJetVars
to implement the above modifications in the property branches for systematics.