Pileup reweighting - elliot-hughes/fatjet_analysis GitHub Wiki

Table of Contents

Prescription

This prescription follows instructions detailed on the PileupMCReweightingUtilities Twiki page.

Step 1: preparation

In order to calculate pile-up re-weighting factors (the next step), you need to first instantiate a edm::LumiReWeighting object from two, independent, inputs: the pile-up distribution measured in the data, and the pile-up distribution used in MC generation.

Step 1.1: getting the data distribution

The 2016 data distribution is calculated on LXPLUS, in a CMSSW environment, by running

pileupCalc.py -i luminosity_mask.json --inputLumiJSON /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions16/13TeV/PileUp/pileup_latest.txt  --calcMode true --minBiasXsec 69200 --maxPileupBin 75 --numPileupBins 75  pileup_distribution_data16.root
where luminosity_mask.json is the luminosity mask you used for processing the data. The luminosity masks I use are listed on Data. The final result of this script is a histogram that contains the pile-up distribution. More documentation related to this calculation is available on the PileupJSONFileforData Twiki page.


The distribution I use is located at /Analyzers/FatjetAnalyzer/test/pileup_data/pileup_distribution_data16.root.

Step 1.2: getting the MC distribution

The pile-up distribution used in a particular MC sample depends on the sample's generation. For example, the moriond17 distribution exists as a list in /SimGeneral/MixingModule/python/mix_2016_25ns_Moriond17MC_PoissonOOTPU_cfi.py.

The distributions for the MC generations I use are saved in /Analyzers/FatjetAnalyzer/test/pileup_data. These histograms are created using the get_pileup_distributions_mc.cc macro, located in the same directory, which reads in the official data I copied into decortication/macros/pileup.cc.

Step 2: calculation

In an EDAnalyzer, you can calculate the pile-up re-weight factors for each event (after following the previous step) but including the following:

#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
#include "PhysicsTools/Utilities/interface/LumiReWeighting.h"
[...]
edm::LumiReWeighting lumi_weights;
[...]
lumi_weights = edm::LumiReWeighting("pileup_data/pileup_distribution_moriond17.root", "pileup_data/pileup_distribution_data16.root", "pileup", "pileup");
[...]
# Inside the event loop:
float tnpv = -1;       # True number of primary vertices
float wpu = 1;         # Pile-up re-weight factor
if (!is_data_) {
	Handle<vector<PileupSummaryInfo>> info;
	iEvent.getByToken(pileupInfo, info);
	for (std::vector<PileupSummaryInfo>::const_iterator pvi = info->begin(); pvi != info->end(); ++pvi) {
		int bx = pvi->getBunchCrossing();
		if (bx == 0) {
			tnpv = pvi->getTrueNumInteractions();
			continue;
		}
	}
	wpu = lumi_weights.weight(tnpv);
}
This is implemented in /Analyzers/FatjetAnalyzer/plugins/JetTuplizer.cc.
⚠️ **GitHub.com Fallback** ⚠️