From ebe703f910a3f8535a01d73b8736be745e1183e9 Mon Sep 17 00:00:00 2001 From: Matej Roguljic Date: Fri, 29 Apr 2022 10:20:17 +0200 Subject: [PATCH 1/4] allow instantiating corrections with different constructors --- TIMBER/Analyzer.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/TIMBER/Analyzer.py b/TIMBER/Analyzer.py index 2a79ccf..f01051e 100755 --- a/TIMBER/Analyzer.py +++ b/TIMBER/Analyzer.py @@ -1909,7 +1909,7 @@ class ModuleWorker(object): Writing the C++ modules requires the desired branch/column names must be specified or be used as the argument variable names to allow the framework to automatically determine what branch/column to use in GetCall(). ''' - def __init__(self,name,script,constructor=[],mainFunc='eval',columnList=None,isClone=False,cloneFuncInfo=None): + def __init__(self,name,script,constructor=[],mainFunc='eval',columnList=None,isClone=False,cloneFuncInfo=None,isNewConstr=False): '''Constructor @param name (str): Unique name to identify the instantiated worker object. @@ -1949,6 +1949,9 @@ def __init__(self,name,script,constructor=[],mainFunc='eval',columnList=None,isC self._instantiate(constructor) + if isNewConstr: + self._instantiate(constructor) + def Clone(self,name,newMainFunc=None): '''Makes a clone of current instance. @@ -2204,7 +2207,7 @@ class Correction(ModuleWorker): (2) the return must be a vector ordered as {nominal, up, down} for "weight" type and {up, down} for "uncert" type. ''' - def __init__(self,name,script='',constructor=[],mainFunc='eval',corrtype=None,columnList=None,isClone=False,cloneFuncInfo=None): + def __init__(self,name,script='',constructor=[],mainFunc='eval',corrtype=None,columnList=None,isClone=False,cloneFuncInfo=None,isNewConstr=False): '''Constructor @param name (str): Correction name. @@ -2231,7 +2234,7 @@ def __init__(self,name,script='',constructor=[],mainFunc='eval',corrtype=None,co # str # Name of correction if script != '': - super(Correction,self).__init__(name,script,constructor,mainFunc,columnList,isClone,cloneFuncInfo) + super(Correction,self).__init__(name,script,constructor,mainFunc,columnList,isClone,cloneFuncInfo,isNewConstr) self.existing = False else: self.existing = True From f8b6c78d73a671c5822dca3b5abbb5a006c311a0 Mon Sep 17 00:00:00 2001 From: Matej Roguljic Date: Fri, 29 Apr 2022 10:24:09 +0200 Subject: [PATCH 2/4] Zbb modules --- TIMBER/Framework/Zbb_modules/AK4Btag_SF.cc | 130 ++++++++++ .../Framework/Zbb_modules/BranchCorrection.cc | 22 ++ TIMBER/Framework/Zbb_modules/TTstitching.cc | 101 ++++++++ TIMBER/Framework/Zbb_modules/TrigEff.cc | 87 +++++++ TIMBER/Framework/Zbb_modules/UncLoader.cc | 117 +++++++++ TIMBER/Framework/Zbb_modules/Zbb_Functions.cc | 235 ++++++++++++++++++ .../Framework/Zbb_modules/helperFunctions.cc | 46 ++++ 7 files changed, 738 insertions(+) create mode 100644 TIMBER/Framework/Zbb_modules/AK4Btag_SF.cc create mode 100644 TIMBER/Framework/Zbb_modules/BranchCorrection.cc create mode 100644 TIMBER/Framework/Zbb_modules/TTstitching.cc create mode 100644 TIMBER/Framework/Zbb_modules/TrigEff.cc create mode 100644 TIMBER/Framework/Zbb_modules/UncLoader.cc create mode 100644 TIMBER/Framework/Zbb_modules/Zbb_Functions.cc create mode 100644 TIMBER/Framework/Zbb_modules/helperFunctions.cc diff --git a/TIMBER/Framework/Zbb_modules/AK4Btag_SF.cc b/TIMBER/Framework/Zbb_modules/AK4Btag_SF.cc new file mode 100644 index 0000000..3343d27 --- /dev/null +++ b/TIMBER/Framework/Zbb_modules/AK4Btag_SF.cc @@ -0,0 +1,130 @@ +// without CMSSW / standalone: +#include "TIMBER/Framework/ext/BTagCalibrationStandalone.h" +#include "TIMBER/Framework/ext/BTagCalibrationStandalone.cpp" +#include + +using namespace ROOT::VecOps; + +/** + * @class AK4Btag_SF + * @brief b tagging scale factor lookup. + */ +class AK4Btag_SF { + public: + /** + * @brief Construct a new b tag scale factor lookup object + * + * @param year 16, 17, or 18. + * @param tagger Ex. DeepCSV, DeepJet + * @param op_string "loose", "medium", "tight", "reshaping" + */ + AK4Btag_SF(std::string year, std::string tagger, std::string op_string); + ~AK4Btag_SF(){}; + /** + * @brief Per-event evaluation function + * + * @param pt \f$p_{T}\f$ of subjet + * @param eta \f$\eta\f$ of subjet + * @return RVec Nominal, up, down scale factor values. + */ + RVec eval(float pt, float eta,int flav, float disc); + RVec evalCollection(int nJet, RVec pt, RVec eta, RVec flav, RVec disc,int var); + private: + std::string csv_file; + BTagEntry::OperatingPoint operating_point; + BTagCalibration calib; + BTagCalibrationReader reader; +}; + +AK4Btag_SF::AK4Btag_SF(std::string year, std::string tagger, std::string op_string){ + std::cout< AK4Btag_SF::eval(float pt, float eta, int flav, float disc) { + RVec jet_scalefactor(3); + + BTagEntry::JetFlavor fl = static_cast(flav); + + float nom = reader.eval_auto_bounds("central", fl, eta, pt, disc);//eta, pt, discr + //float up = reader.eval_auto_bounds("up_hf", fl, eta, pt, disc); + //float down = reader.eval_auto_bounds("down_hf", fl, eta, pt, disc); + float down = 0.98*nom; + float up = 1.02*nom; + + jet_scalefactor[0] = nom; + jet_scalefactor[1] = down; + jet_scalefactor[2] = up; + + return jet_scalefactor; +}; + +RVec AK4Btag_SF::evalCollection(int nJet, RVec pt, RVec eta, RVec flav, RVec disc,int var) { + //int var 0,1,2 = nom,down,up + //evaluate at central, apply 2% unc if var>0 + RVec recalib_disc(nJet); + BTagEntry::JetFlavor fl; + for(int i=0; i(2);//b + } + else if(flav[i]==4){ + fl = static_cast(1);//c + } + else{ + fl = static_cast(0);//udsg + } + float sf = reader.eval_auto_bounds("central", fl, eta[i], pt[i], disc[i]); + if(var==1){ + sf = sf*0.98; + } + else if(var==2){ + sf = sf * 1.02; + } + recalib_disc[i] = sf*disc[i]; + } + + return recalib_disc; +}; \ No newline at end of file diff --git a/TIMBER/Framework/Zbb_modules/BranchCorrection.cc b/TIMBER/Framework/Zbb_modules/BranchCorrection.cc new file mode 100644 index 0000000..8d39910 --- /dev/null +++ b/TIMBER/Framework/Zbb_modules/BranchCorrection.cc @@ -0,0 +1,22 @@ +#include +/** + * @class BranchCorrection + * @brief Trivial class to load a branch as correction in TIMBER + */ +using namespace ROOT::VecOps; +class BranchCorrection { + + public: + BranchCorrection(){}; + ~BranchCorrection(){}; + RVec eval(float val); + +}; + + +RVec BranchCorrection::eval(float val){ + RVec correction(1); + correction[0]=val; + return correction; +}; + diff --git a/TIMBER/Framework/Zbb_modules/TTstitching.cc b/TIMBER/Framework/Zbb_modules/TTstitching.cc new file mode 100644 index 0000000..1530a5a --- /dev/null +++ b/TIMBER/Framework/Zbb_modules/TTstitching.cc @@ -0,0 +1,101 @@ +#include +#include +#include +#include +#include +#include "ROOT/RVec.hxx" + +using namespace ROOT::VecOps; +using rvec_i = ROOT::VecOps::RVec; +using rvec_f = ROOT::VecOps::RVec; +using LVector = ROOT::Math::PtEtaPhiMVector; + +Int_t highHTFlag(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_f GenPart_pt, rvec_f GenPart_phi, rvec_f GenPart_eta, rvec_f GenPart_mass, Int_t nGenJetAK8,rvec_f GenJetAK8_pt, rvec_f GenJetAK8_phi, rvec_f GenJetAK8_eta, rvec_f GenJetAK8_mass); +Float_t deltaR(Float_t eta1, Float_t phi1, Float_t eta2, Float_t phi2); +Float_t getMTT(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_f GenPart_pt, rvec_f GenPart_phi, rvec_f GenPart_eta, rvec_f GenPart_mass); +Float_t getPartIdx(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_i GenPart_statusFlags, Int_t pdgId); + +Float_t getPartIdx(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_i GenPart_statusFlags, Int_t pdgId){ + //returns idx of the first hard process parton with GenPart_pdgId == pdgId, -1 otherwise + // statusFlags bit 7 : isHardProcess, bit counting starts from zero! + for(Int_t i=0;i topVecs; + Float_t invMass = 0.0; + + for(Int_t i=0;i1){ + break; + } + if(GenPart_pdgId[i]==6 || GenPart_pdgId[i]==-6){ + topVecs.push_back(LVector(GenPart_pt[i],GenPart_eta[i],GenPart_phi[i],GenPart_mass[i])); + nTops=nTops+1; + } + } + + if(nTops==2){ + invMass = (topVecs[0]+topVecs[1]).M(); + } + + return invMass; + +} + + + +Int_t highHTFlag(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_f GenPart_pt, rvec_f GenPart_phi, rvec_f GenPart_eta, rvec_f GenPart_mass, Int_t nGenJetAK8,rvec_f GenJetAK8_pt, rvec_f GenJetAK8_phi, rvec_f GenJetAK8_eta, rvec_f GenJetAK8_mass){ + if(nGenJetAK8<1){ + return 0; + } + std::vector jetVectors; + std::vector nuVectors; + + for(Int_t i=0;i1){ + break; + } + jetVectors.push_back(LVector(GenJetAK8_pt[i],GenJetAK8_eta[i],GenJetAK8_phi[i],GenJetAK8_mass[i])); + } + + for(auto& nuVector: nuVectors){ + for(auto& jetVector: jetVectors){ + Float_t dR = deltaR(nuVector.Eta(),nuVector.Phi(),jetVector.Eta(),jetVector.Phi()); + if(dR<0.8){ + jetVector = jetVector+nuVector; + } + } + } + Float_t highestpT = 0; + for(const auto& jetVector: jetVectors){ + Float_t pT = jetVector.Pt(); + if(pT>highestpT){ + highestpT=pT; + } + } + + if(highestpT>649.0){ + return 1; + } + else{ + return 0; + } + +} \ No newline at end of file diff --git a/TIMBER/Framework/Zbb_modules/TrigEff.cc b/TIMBER/Framework/Zbb_modules/TrigEff.cc new file mode 100644 index 0000000..577eef3 --- /dev/null +++ b/TIMBER/Framework/Zbb_modules/TrigEff.cc @@ -0,0 +1,87 @@ +#include +#include "TFile.h" +#include "TEfficiency.h" +#include +/** + * @class TrigEff + * @brief Generic histogram loader with methods to return bin values. + */ +class TrigEff { + private: + TFile *file; + TEfficiency *efficiency; //!< Histogram object + int binx; + int globalbin; + float effval; + float effup; + float effdown; + + public: + /** + * @brief Empty constructor + */ + TrigEff(){}; + /** + * @brief Construct a new TrigEff object + * + * @param filename File to access. + * @param histname Histogram name in the file. + */ + TrigEff(std::string filename, std::string histname); + /** + * @brief Evaluate by global bin number. + * + * @param globalbin + * @return std::vector {nominal value, up error+nominal, down error+nominal} + */ + std::vector eval_byglobal(int globalbin); + /** + * @brief Evaluate by per-axis bin numbers. + * + * @param binx + * @param biny + * @param binz + * @return std::vector {nominal value, up error+nominal, down error+nominal} + */ + std::vector eval_bybin(int binx, int biny = 0, int binz = 0); + /** + * @brief Evaluate by axis value. + * + * @param xval + * @param yval + * @param zval + * @return std::vector {nominal value, up error+nominal, down error+nominal} + */ + std::vector eval(float xval, float yval = 0, float zval = 0); + +}; + +TrigEff::TrigEff(std::string filename, std::string effname) { + file = TFile::Open(filename.c_str()); + efficiency = (TEfficiency*)file->Get(effname.c_str()); +} + +std::vector TrigEff::eval_byglobal(int globalbin){ + effval = efficiency->GetEfficiency(globalbin); + effup = effval + efficiency->GetEfficiencyErrorUp(globalbin)+0.01;//1% additional uncertainty to account for JetHT/SingleMuon differences + effdown = effval - efficiency->GetEfficiencyErrorLow(globalbin)-0.01; + + if(effup>1.0){ + effup = 1.0; + } + + if(effdown<0.0){ + effdown = 0.0; + } + return {effval,effup,effdown}; +} + +std::vector TrigEff::eval_bybin(int binx, int biny, int binz){ + globalbin = efficiency->GetGlobalBin(binx, biny, binz); + return eval_byglobal(globalbin); +} + +std::vector TrigEff::eval(float xval, float yval, float zval){ + globalbin = efficiency->FindFixBin(xval, yval, zval); + return eval_byglobal(globalbin); +} diff --git a/TIMBER/Framework/Zbb_modules/UncLoader.cc b/TIMBER/Framework/Zbb_modules/UncLoader.cc new file mode 100644 index 0000000..a4f9b1d --- /dev/null +++ b/TIMBER/Framework/Zbb_modules/UncLoader.cc @@ -0,0 +1,117 @@ +#include +#include "TFile.h" +#include "TH1.h" +#include "TH2.h" +#include "TH3.h" + +/** + * @class UncLoader + * @brief Load two histograms (up, down) and return their values. Hist up and down need to be of same shape + */ +class UncLoader { + private: + TFile *file; + int dim; + + /** + * @brief Sanity check that the dimensionality of the + * arguements and the histogram make sense + * + * @param x + * @param y + * @param z + */ + void checkDim(int x, int y, int z); + public: + TH1 *histUp; //!< Histogram object + TH1 *histDown; //!< Histogram object + /** + * @brief Empty constructor + */ + UncLoader(){}; + /** + * @brief Construct a new UncLoader object + * + * @param filename File to access. + * @param histname Histogram names in the file. + */ + UncLoader(std::string filename, std::string histUpName, std::string histDownName); + /** + * @brief Evaluate by bin numbers. + * + * @param binx + * @param biny + * @param binz + * @return std::vector {up unc, down unc} + */ + std::vector eval_bybin(int binx, int biny = 0, int binz = 0); + /** + * @brief Evaluate by axis value. + * + * @param xval + * @param yval + * @param zval + * @return std::vector {up unc, down unc} + */ + std::vector eval(float xval, float yval = 0., float zval = 0.); + +}; + +UncLoader::UncLoader(std::string filename, std::string histUpName, std::string histDownName) { + file = TFile::Open(filename.c_str()); + histUp = (TH1*)file->Get(histUpName.c_str()); + histDown = (TH1*)file->Get(histDownName.c_str()); + if (dynamic_cast(histUp) != nullptr) { + dim = 2; + } else if (dynamic_cast(histUp) != nullptr) { + dim = 3; + } else { + dim = 1; + } +} + +void UncLoader::checkDim(int x, int y, int z){ + if (dim == 1) { + if ((y != 0) || (z != 0)) { + throw "Dimension of hist is 1 but Y and Z components were provided"; + } + } + if (dim == 2) { + if (z != 0) { + throw "Dimension of hist is 2 but Z component was provided"; + } + } +} + +std::vector UncLoader::eval_bybin(int binx, int biny, int binz){ + UncLoader::checkDim(binx,biny,binz); + float valUp; + float valDown; + if (dim == 1){ + valUp = histUp->GetBinContent(binx); + valDown = histDown->GetBinContent(binx); + } else if (dim == 2) { + valUp = histUp->GetBinContent(binx,biny); + valDown = histDown->GetBinContent(binx,biny); + } else if (dim == 3) { + valUp = histUp->GetBinContent(binx,biny,binz); + valDown = histDown->GetBinContent(binx,biny,binz); + } else { + throw "Dimensionality not supported."; + } + + return {valUp,valDown}; +} + +std::vector UncLoader::eval(float xval, float yval, float zval){ + UncLoader::checkDim(xval,yval,zval); + int binx = 0; + int biny = 0; + int binz = 0; + if (dim >= 1) {binx = histUp->GetXaxis()->FindBin(xval);} + if (dim >= 2) {biny = histUp->GetYaxis()->FindBin(yval);} + if (dim == 3) {binz = histUp->GetZaxis()->FindBin(zval);} + + return UncLoader::eval_bybin(binx,biny,binz); +} + diff --git a/TIMBER/Framework/Zbb_modules/Zbb_Functions.cc b/TIMBER/Framework/Zbb_modules/Zbb_Functions.cc new file mode 100644 index 0000000..66b2768 --- /dev/null +++ b/TIMBER/Framework/Zbb_modules/Zbb_Functions.cc @@ -0,0 +1,235 @@ +#include +#include +#include +#include +#include +#include "ROOT/RVec.hxx" +#include "../include/common.h" + +using namespace ROOT::VecOps; +using namespace ROOT::VecOps; +using rvec_i = ROOT::VecOps::RVec; +using rvec_f = ROOT::VecOps::RVec; +using LVector = ROOT::Math::PtEtaPhiMVector; + + +Int_t VinJet(Float_t FatJet_phi, Float_t FatJet_eta,Int_t nGenPart, rvec_f GenPart_phi,rvec_f GenPart_eta, rvec_i GenPart_pdgId,rvec_i GenPart_statusFlags ) +//returns 1 if W/Z within jet cone, 0 otherwise +{ + Int_t pid; + for(Int_t i=0; i0.8 from FatJet satisfying pt>30, |eta|0.8; + kinematicFlag = TMath::Abs(Jet_eta[i])30; + btagFlag = Jet_bTag[i]>bTagCut; + if(kinematicFlag && DRflag && btagFlag){ + return 1; + } + } + return 0; +} + + +Int_t VmatchedFatJetIdx(Int_t nFatJet, rvec_f FatJet_phi, rvec_f FatJet_eta,Int_t nGenPart,rvec_f GenPart_phi,rvec_f GenPart_eta,rvec_i GenPart_pdgId, rvec_i GenPart_statusFlags) +{ + + Int_t vFlag; + for(Int_t i=0; i +#include +#include +#include +#include +#include "ROOT/RVec.hxx" + +using namespace ROOT::VecOps; +using rvec_i = ROOT::VecOps::RVec; +using rvec_f = ROOT::VecOps::RVec; +using rvec_c = ROOT::VecOps::RVec; +using rvec_b = ROOT::VecOps::RVec; + + +Int_t nMuons(Int_t nMuon, rvec_b Muon_id, rvec_c Muon_pfIsoId, Int_t iso_cut, rvec_f Muon_pt, Float_t pt_cut, rvec_f Muon_eta); +//variation of the goodMuon function which was used for skimming +//returns number of muons with Muon_id==True, pt>cut and passing required isolation +Int_t nElectrons(Int_t nElectron, rvec_i Electron_cutBased, Int_t id_cut, rvec_f Electron_pt, Float_t pt_cut, rvec_f Electron_eta); +//variation of the goodElectron function which was used for skimming +//returns number of electrons with cutbased_id > id_cut and pt>cut + + +Int_t nElectrons(Int_t nElectron, rvec_i Electron_cutBased, Int_t id_cut, rvec_f Electron_pt, Float_t pt_cut, rvec_f Electron_eta){ + Int_t n = 0; + for(Int_t i=0; iid_cut && Electron_pt[i]>pt_cut && TMath::Abs(Electron_eta[i])<2.4){ + //0:fail,1:veto,2:loose,3:medium,4:tight + n=n+1; + } + } + return n; +} + + +Int_t nMuons(Int_t nMuon, rvec_b Muon_id, rvec_c Muon_pfIsoId, Int_t iso_cut, rvec_f Muon_pt, Float_t pt_cut, rvec_f Muon_eta){ + Int_t n = 0; + for(Int_t i=0; iiso_cut && Muon_pt[i]>pt_cut && TMath::Abs(Muon_eta[i])<2.4){ + //1=PFIsoVeryLoose, 2=PFIsoLoose, 3=PFIsoMedium, 4=PFIsoTight, 5=PFIsoVeryTight, 6=PFIsoVeryVeryTight + //1=MiniIsoLoose, 2=MiniIsoMedium, 3=MiniIsoTight, 4=MiniIsoVeryTight) + n=n+1; + } + } + return n; +} + From 8356bfc2b20be98ce762f980376a01702e57b199 Mon Sep 17 00:00:00 2001 From: Matej Roguljic Date: Mon, 9 May 2022 15:38:52 +0200 Subject: [PATCH 3/4] zbb update --- TIMBER/Analyzer.py | 8 +-- .../Framework/Zbb_modules/BranchCorrection.cc | 21 +++++++- TIMBER/Framework/Zbb_modules/TTstitching.cc | 50 ------------------- TIMBER/Framework/include/JMR_weight.h | 13 ++--- TIMBER/Framework/include/JMS_weight.h | 13 ++--- 5 files changed, 33 insertions(+), 72 deletions(-) diff --git a/TIMBER/Analyzer.py b/TIMBER/Analyzer.py index f01051e..d719e47 100755 --- a/TIMBER/Analyzer.py +++ b/TIMBER/Analyzer.py @@ -124,7 +124,7 @@ def __init__(self,fileName,eventsTreeName="Events",runTreeName="Runs",multiSampl self.isData = False else: self.isData = True - + # Count number of generated events if not data self.genEventSumw = 0.0 self.genEventCount = 0 @@ -167,10 +167,11 @@ def __init__(self,fileName,eventsTreeName="Events",runTreeName="Runs",multiSampl if 'CMSSW_BASE' not in os.environ.keys(): skipHeaders = ['JME_common.h','JetSmearer.h','JetRecalibrator.h','JES_weight.h','JER_weight.h','JMS_weight.h','JMR_weight.h'] + for f in glob.glob(os.environ["TIMBERPATH"]+'TIMBER/Framework/include/*.h'): if f.split('/')[-1] in skipHeaders: continue CompileCpp('#include "%s"\n'%f) - + def _addFile(self,f): '''Add file to TChains being tracked. @@ -1931,8 +1932,7 @@ def __init__(self,name,script,constructor=[],mainFunc='eval',columnList=None,isC # Correction name self.name = name self._script = self._getScript(script) - if not isClone: self._funcInfo = self._getFuncInfo(mainFunc) - else: self._funcInfo = cloneFuncInfo + self._funcInfo = self._getFuncInfo(mainFunc) self._mainFunc = list(self._funcInfo.keys())[0] self._columnNames = LoadColumnNames() if columnList == None else columnList self._constructor = constructor diff --git a/TIMBER/Framework/Zbb_modules/BranchCorrection.cc b/TIMBER/Framework/Zbb_modules/BranchCorrection.cc index 8d39910..30b8b58 100644 --- a/TIMBER/Framework/Zbb_modules/BranchCorrection.cc +++ b/TIMBER/Framework/Zbb_modules/BranchCorrection.cc @@ -9,14 +9,31 @@ class BranchCorrection { public: BranchCorrection(){}; ~BranchCorrection(){}; - RVec eval(float val); + RVec evalCorrection(float val); + RVec evalWeight(float val,float valUp,float valDown); + RVec evalUncert(float valUp,float valDown); }; -RVec BranchCorrection::eval(float val){ +RVec BranchCorrection::evalCorrection(float val){ RVec correction(1); correction[0]=val; return correction; }; +RVec BranchCorrection::evalWeight(float val,float valUp,float valDown){ + RVec weight(3); + weight[0]=val; + weight[1]=valUp; + weight[2]=valDown; + return weight; +}; + +RVec BranchCorrection::evalUncert(float valUp,float valDown){ + RVec uncert(2); + uncert[0]=valUp; + uncert[1]=valDown; + return uncert; +}; + diff --git a/TIMBER/Framework/Zbb_modules/TTstitching.cc b/TIMBER/Framework/Zbb_modules/TTstitching.cc index 1530a5a..377c9a2 100644 --- a/TIMBER/Framework/Zbb_modules/TTstitching.cc +++ b/TIMBER/Framework/Zbb_modules/TTstitching.cc @@ -10,8 +10,6 @@ using rvec_i = ROOT::VecOps::RVec; using rvec_f = ROOT::VecOps::RVec; using LVector = ROOT::Math::PtEtaPhiMVector; -Int_t highHTFlag(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_f GenPart_pt, rvec_f GenPart_phi, rvec_f GenPart_eta, rvec_f GenPart_mass, Int_t nGenJetAK8,rvec_f GenJetAK8_pt, rvec_f GenJetAK8_phi, rvec_f GenJetAK8_eta, rvec_f GenJetAK8_mass); -Float_t deltaR(Float_t eta1, Float_t phi1, Float_t eta2, Float_t phi2); Float_t getMTT(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_f GenPart_pt, rvec_f GenPart_phi, rvec_f GenPart_eta, rvec_f GenPart_mass); Float_t getPartIdx(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_i GenPart_statusFlags, Int_t pdgId); @@ -51,51 +49,3 @@ Float_t getMTT(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_f GenPart_pt, rvec_f G } - - -Int_t highHTFlag(Int_t nGenPart, rvec_i GenPart_pdgId, rvec_f GenPart_pt, rvec_f GenPart_phi, rvec_f GenPart_eta, rvec_f GenPart_mass, Int_t nGenJetAK8,rvec_f GenJetAK8_pt, rvec_f GenJetAK8_phi, rvec_f GenJetAK8_eta, rvec_f GenJetAK8_mass){ - if(nGenJetAK8<1){ - return 0; - } - std::vector jetVectors; - std::vector nuVectors; - - for(Int_t i=0;i1){ - break; - } - jetVectors.push_back(LVector(GenJetAK8_pt[i],GenJetAK8_eta[i],GenJetAK8_phi[i],GenJetAK8_mass[i])); - } - - for(auto& nuVector: nuVectors){ - for(auto& jetVector: jetVectors){ - Float_t dR = deltaR(nuVector.Eta(),nuVector.Phi(),jetVector.Eta(),jetVector.Phi()); - if(dR<0.8){ - jetVector = jetVector+nuVector; - } - } - } - Float_t highestpT = 0; - for(const auto& jetVector: jetVectors){ - Float_t pT = jetVector.Pt(); - if(pT>highestpT){ - highestpT=pT; - } - } - - if(highestpT>649.0){ - return 1; - } - else{ - return 0; - } - -} \ No newline at end of file diff --git a/TIMBER/Framework/include/JMR_weight.h b/TIMBER/Framework/include/JMR_weight.h index 786ba95..dc0fe6a 100644 --- a/TIMBER/Framework/include/JMR_weight.h +++ b/TIMBER/Framework/include/JMR_weight.h @@ -7,18 +7,15 @@ using namespace ROOT::VecOps; /** - * @brief C++ class to directly handle JMR weights in the case of tau21 - * jet substructure. The values used (nominal, up, down) are: - * - 2016: 1.00, 1.2, 0.8 - * - 2017: 1.09, 1.14, 1.04 - * - 2018: 1.09, 1.14, 1.04 + * @brief C++ class to directly handle JMR weights + * jet substructure. The values are from AN2020/231 v8 */ class JMR_weight { private: std::map< int, std::vector > _jmrTable { - {2016, {1.00, 1.2, 0.8 } }, - {2017, {1.09, 1.14, 1.04} }, - {2018, {1.09, 1.14, 1.04} } + {2016, {1.028, 1.063, 1.007} }, + {2017, {1.026, 1.059, 1.009} }, + {2018, {1.031, 1.075, 1.006} } }; JetSmearer _smearer; diff --git a/TIMBER/Framework/include/JMS_weight.h b/TIMBER/Framework/include/JMS_weight.h index a03a7d5..7cc2d66 100644 --- a/TIMBER/Framework/include/JMS_weight.h +++ b/TIMBER/Framework/include/JMS_weight.h @@ -9,18 +9,15 @@ using namespace ROOT::VecOps; /** - * @brief C++ class to directly handle JMS weights in the case of tau21 - * jet substructure. The values used (nominal, up, down) are: - * - 2016: 1.000, 1.0094, 0.9906 - * - 2017: 0.982, 0.986, 0.978 - * - 2018: 0.982, 0.986, 0.978 + * @brief C++ class to directly handle JMS weights + * jet substructure. The values are from AN2020/231 v8 */ class JMS_weight { private: std::map< int, std::vector > _jmsTable { - {2016, {1.000, 1.0094, 0.9906} }, - {2017, {0.982, 0.986 , 0.978 } }, - {2018, {0.982, 0.986 , 0.978 } } + {2016, {1.000, 1.002, 0.998 } }, + {2017, {1.002, 1.008 ,0.996 } }, + {2018, {0.994, 0.995 ,0.987 } } }; std::vector _jmsVals; public: From 675bcc660b8d9a858c947bb4d882673d59635381 Mon Sep 17 00:00:00 2001 From: Matej Roguljic Date: Mon, 9 May 2022 15:41:35 +0200 Subject: [PATCH 4/4] setup --- Makefile | 6 ++++-- setup.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 59ada48..e0bb39e 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,12 @@ SOURCE_DIR=TIMBER/Framework/src/ HEADER_DIR=TIMBER/Framework/include/ EXT_DIR=TIMBER/Framework/ext/ BIN_DIR=bin/libtimber/ +BOOST_DIR=bin/libboost/include/ +FMT_DIR=bin/fmt/include CC=gcc -INCLUDE=-I/usr/include/ -I bin/ -I./ `root-config --cflags --ldflags --glibs` -I/usr/include/ -I$(EXT_DIR) -LIBS=-lstdc++ -l boost_wserialization -l boost_filesystem -L bin/libarchive/lib/ -Wl,-rpath=bin/libarchive/lib/ -l archive +INCLUDE=-I/usr/include/ -I bin/ -I./ `root-config --cflags --ldflags --glibs` -I/usr/include/ -I$(EXT_DIR) -I$(BOOST_DIR) -I$(FMT_DIR) +LIBS=-lstdc++ -L bin/libarchive/lib/ -Wl,-rpath=bin/libarchive/lib/ -l archive CFLAGS=-g -Wno-attributes -fPIC -c CVMFS=/cvmfs/cms.cern.ch/$(SCRAM_ARCH)/cms/cmssw/$(CMSSW_VERSION) CMSSW=-I$(CVMFS)/src -I/cvmfs/cms.cern.ch/$(SCRAM_ARCH)/external/boost/1.72.0-bcolbf/include -L/cvmfs/cms.cern.ch/$(SCRAM_ARCH)/external/boost/1.72.0-bcolbf/lib -L$(CVMFS)/lib/$(SCRAM_ARCH) diff --git a/setup.py b/setup.py index d781775..cc73f93 100644 --- a/setup.py +++ b/setup.py @@ -16,14 +16,14 @@ include_package_data=True, # cmdclass={'install': AddToPath}, install_requires = [ - "decorator==4.4.2", - "pyparsing==2.4.7", - "graphviz==0.14.2", - "pydot==1.4.1", - "networkx==2.2", - "clang==6.0.0.2", - "numpy==1.16.6", - "pandas==0.24.2" + "decorator>=4.4.2", + "pyparsing>=2.4.7", + "graphviz>=0.14.2", + "pydot>=1.4.1", + "networkx>=2.2", + "clang>=6.0.0.2", + "numpy>=1.16.6", + "pandas>=0.24.2" ] )