61 EffiToolInstance tool(std::string(
"CP::MuonEfficiencyScaleFactors/EffiTool_") + WP);
63 tool.setProperty(
"WorkingPoint", WP).isSuccess();
64 tool.setProperty(
"UncorrelateSystematics", uncorrelate_Syst).isSuccess();
65 tool.setProperty(
"LowPtThreshold", 15.e3).isSuccess();
66 tool.retrieve().isSuccess();
68 if (!CustomInput.empty()) tool.setProperty(
"CustomInputFolder", CustomInput).isSuccess();
72int main(
int argc,
char* argv[]) {
75 StatusCode::enableFailure();
76 StatusCode::enableFailure();
82 std::string prwFilename =
"dev/PileupReweighting/share/DSID361xxx/pileup_mc20a_dsid361107_FS.root";
83 std::string ilumiFilename =
"GoodRunsLists/data16_13TeV/20180129/PHYS_StandardGRL_All_Good_25ns_297730-311481_OflLumi-13TeV-009.root";
84 std::string InFile =
"";
85 long long int nmax = -1;
87 for (
int k = 1; k < argc - 1; ++k) {
88 if (std::string(argv[k]).
find(
"-i") == 0) {
91 if (std::string(argv[k]).
find(
"-n") == 0) {
92 nmax = atoi(argv[k + 1]);
94 if (std::string(argv[k]).
find(
"--ilumi") == 0) {
95 ilumiFilename = argv[k + 1];
97 if (std::string(argv[k]).
find(
"--prw") == 0) {
98 prwFilename = argv[k + 1];
105 Info(
APP_NAME,
"Opening file: %s", InFile.c_str());
106 std::unique_ptr<TFile> ifile(TFile::Open(InFile.c_str(),
"READ"));
108 Error(
APP_NAME,
" Unable to load xAOD input file");
111 std::string DefaultCalibRelease(
"");
113 DefaultCalibRelease = argv[2];
114 std::cout <<
"Found second argument (" << DefaultCalibRelease <<
"), assuming it is the CalibrationRelease..." << std::endl;
120 Info(
APP_NAME,
"Number of events in the file: %i",
static_cast<int>(event.getEntries()));
122 Long64_t
entries =
event.getEntries();
127 double t_init = tsw.CpuTime();
131 asg::StandaloneToolHandle < CP::IPileupReweightingTool > m_prw_tool(
"CP::PileupReweightingTool/myTool");
133 std::vector<std::string> m_ConfigFiles {
136 std::vector<std::string> m_LumiCalcFiles {
148 const std::vector<std::string> WPs {
150 "Loose",
"Medium",
"Tight",
"HighPt",
"LowPt",
156 "Loose_VarRadIso",
"Tight_VarRadIso",
"PflowLoose_VarRadIso",
"PflowTight_VarRadIso"
159 std::vector<EffiToolInstance> EffiTools;
160 for (
auto& WP : WPs) {
161 EffiTools.push_back(
createSFTool(WP, DefaultCalibRelease,
false));
169 std::vector<float> replicas(50);
170 for (Long64_t entry = 0; entry <
entries; ++entry) {
173 event.getEntry(entry);
180 Info(
APP_NAME,
"===>>> start processing event #%i, run #%i %i events processed so far <<<===",
static_cast<int>(ei->
eventNumber()),
static_cast<int>(ei->
runNumber()),
static_cast<int>(entry));
185 Info(
APP_NAME,
"Number of muons: %i",
static_cast<int>(muons->
size()));
187 for (
const auto *mu : *muons) {
189 Info(
APP_NAME,
" Selected muon: eta = %g, phi = %g, pt = %g", mu->eta(), mu->phi(), mu->pt());
190 for (
auto& effi : EffiTools) {
193 float nominalSF = 1.;
196 CHECK_CPCorr(effi->getEfficiencyScaleFactor(*mu, nominalSF));
199 std::string sysName = (syst.name().
empty()) ?
"Nominal" : syst.name();
200 Info(
APP_NAME,
"Applied %s variation. The scale-factor is %.3f, the data-efficiency is %.3f and the mc-efficiency is %.3f", sysName.c_str(), nominalSF, data_Eff, mc_Eff);
202 CHECK_CPCorr(effi->getEfficiencyScaleFactorReplicas(*mu, replicas));
203 for (
size_t t = 0; t < replicas.size(); t++) {
204 Info(
APP_NAME,
" scaleFactor Replica %d = %.8f",
static_cast<int>(t), replicas[t]);
210 Info(
APP_NAME,
"===>>> done processing event #%i, "
211 "run #%i %i events processed so far <<<===",
static_cast<int>(ei->
eventNumber()),
static_cast<int>(ei->
runNumber()),
static_cast<int>(entry + 1));
213 double t_run = tsw.CpuTime() /
entries;
214 Info(
APP_NAME,
" MCP init took %gs", t_init);
215 Info(
APP_NAME,
" time per event: %gs", t_run);