diff --git a/NtupleProducer/README.md b/NtupleProducer/README.md index b57b151e6de8b..a8ad972bcf703 100644 --- a/NtupleProducer/README.md +++ b/NtupleProducer/README.md @@ -4,13 +4,17 @@ Basic Instructions cmsrel CMSSW_9_1_0_pre2 cd CMSSW_9_1_0_pre2/src cmsenv -git clone git@github.com:nhanvtran/FastPUPPI.git -b 91X +git cms-init +git remote add cms-l1t-offline git@github.com:cms-l1t-offline/cmssw.git +git fetch cms-l1t-offline +git cms-merge-topic -u cms-l1t-offline:phase2-l1t-integration-CMSSW_9_1_0_pre2 +git-cms-addpkg L1Trigger/L1THGCal +git clone https://github.com/cms-data/L1Trigger-L1THGCal.git L1Trigger/L1THGCal/data +git clone git@github.com:nhanvtran/FastPUPPI.git -b 91X_newClusterer scram b -j8 ``` -The current basic config is: -`FastPUPPI/NtupleProducer/python/runNtupleProducer_cfg.py` +The first step is to produce the inputs: +`FastPUPPI/NtupleProducer/python/runInputs.py` -Relval samples are located in: -`/store/relval/CMSSW_9_1_0_pre1/RelValZMM_14/` -n.b. the \_14 samples are for upgrade, and they are not in every pre-release so we are using pre1 instead of pre2 +The trigger MC can be found on DAS `dataset=/*/*PhaseIISpring17D*/*` diff --git a/NtupleProducer/interface/CaloClusterer.h b/NtupleProducer/interface/CaloClusterer.h index ff643c8c0f734..01ad27df080d7 100644 --- a/NtupleProducer/interface/CaloClusterer.h +++ b/NtupleProducer/interface/CaloClusterer.h @@ -174,7 +174,7 @@ namespace l1pf_calo { } } - std::vector fetch(bool corrected=true) const ; + std::unique_ptr> fetch(bool corrected=true) const ; private: std::unique_ptr grid_; const SingleCaloClusterer & ecal_, & hcal_; diff --git a/NtupleProducer/interface/DiscretePF.h b/NtupleProducer/interface/DiscretePF.h index 526d8a9b164ef..8e8128e63d0ee 100644 --- a/NtupleProducer/interface/DiscretePF.h +++ b/NtupleProducer/interface/DiscretePF.h @@ -119,7 +119,6 @@ namespace l1tpf_int { }; struct PFParticle { - enum PID { CH=0, EL=1, NH=2, GAMMA=3, MU=4 }; int16_t hwPt; int16_t hwEta; // at calo face int16_t hwPhi; diff --git a/NtupleProducer/interface/L1TPFParticle.h b/NtupleProducer/interface/L1TPFParticle.h index f2e4983eb29b5..f7551172d3284 100644 --- a/NtupleProducer/interface/L1TPFParticle.h +++ b/NtupleProducer/interface/L1TPFParticle.h @@ -8,44 +8,51 @@ namespace l1tpf { class Particle : public reco::LeafCandidate { public: + enum MyParticleId { CH=0, EL=1, NH=2, GAMMA=3, MU=4 }; Particle() {} Particle(double iEt,double iEta,double iPhi,double iM,int iId,double iSigma=0,double iDZ=0,double iCaloEta=0,double iCaloPhi=0, double iCharge = 0, double iQuality = -999, double iIsPV = 0, float alphaF = -999, float alphaC = -999, float puppiWeight = -99) : LeafCandidate(iCharge, reco::LeafCandidate::PolarLorentzVector(iEt,iEta,iPhi,iM), reco::LeafCandidate::Point(), iId), dZ_(iDZ), sigma_(iSigma), - caloEta_(iCaloEta), - caloPhi_(iCaloPhi), - eta_(iEta),phi_(iPhi), + caloEta_(-999), + caloPhi_(-999), quality_(iQuality), isPV_(iIsPV), + hOverE_(0.), chi2n_(0), alphaF_(alphaF), alphaC_(alphaC), puppiWeight_(puppiWeight) {} float dz() const { return dZ_; } float sigma() const { return sigma_; } - float caloEta() const { return caloEta_; } - float caloPhi() const { return caloPhi_; } + float caloEta() const { return caloEta_ == -999 ? eta() : caloEta_; } + float caloPhi() const { return caloPhi_ == -999 ? phi() : caloPhi_; } //iEta,iPhi (usuals) - int iEta() const { return l1tpf::translateIEta(eta_);} - int iPhi() const { return l1tpf::translateIPhi(phi_,eta_);} + int iEta() const { return l1tpf::translateIEta(eta());} + int iPhi() const { return l1tpf::translateIPhi(phi(),eta());} //iEta,iPhi as they are stored in Arrays int aEta() const { return l1tpf::translateAEta(iEta());} int aPhi() const { return l1tpf::translateAPhi(iPhi());} //Center of the trigger tower - float dEta() const { return l1tpf::towerEta(l1tpf::translateIEta(eta_));} - float dPhi() const { return l1tpf::towerPhi(l1tpf::translateIEta(eta_),l1tpf::translateIPhi(phi_,eta_));} + float dEta() const { return l1tpf::towerEta(l1tpf::translateIEta(eta()));} + float dPhi() const { return l1tpf::towerPhi(l1tpf::translateIEta(eta()),l1tpf::translateIPhi(phi(),eta()));} //Other stuff float quality() const { return quality_; } float alphaF() const { return alphaF_; } float alphaC() const { return alphaC_; } float puppiWeight() const { return puppiWeight_; } int isPV() const { return isPV_; } + float hOverE() const { return hOverE_; } + float emEt() const { + if (hOverE_ == -1) return 0; + return pt() / ( 1 + hOverE_ ); + } + // for L1Tk + float normalizedChi2() const { return chi2n_; } + void setCaloEta(float caloEta) { caloEta_ = caloEta; } void setCaloPhi(float caloPhi) { caloPhi_ = caloPhi; } - void setEta(float iEta) { eta_ = iEta; } - void setPhi(float iPhi) { phi_ = iPhi; } void setCaloEtaPhi(float caloEta, float caloPhi) { caloEta_ = caloEta; caloPhi_ = caloPhi; } //void setIEtaIPhi(int iEta, int iPhi) { iEta_ = iEta; iPhi_ = iPhi; } @@ -57,6 +64,13 @@ namespace l1tpf { void setPuppiWeight(float puppiWeight) { puppiWeight_ = puppiWeight; } void setIsPV(int isPV) { isPV_ = isPV; } + /// for HGC 3D clusters, or our own linked ecal+hcal clusters + /// -1 if E is zero. + void setHOverE(float hOverE) { hOverE_ = hOverE; } + + // for L1Tk + void setNormalizedChi2(float normalizedChi2) { chi2n_ = normalizedChi2; } + TLorentzVector tp4() const { TLorentzVector ret; ret.SetPtEtaPhiM(pt(),eta(),phi(),mass()); @@ -73,9 +87,9 @@ namespace l1tpf { float dZ_; float sigma_; float caloEta_, caloPhi_; - float eta_, phi_; float quality_; int isPV_; + float hOverE_, chi2n_; float alphaF_, alphaC_, puppiWeight_; }; // class } // namespace diff --git a/NtupleProducer/interface/combiner.hh b/NtupleProducer/interface/combiner.hh index 5e654fd1e1e5f..411bb2edddfda 100644 --- a/NtupleProducer/interface/combiner.hh +++ b/NtupleProducer/interface/combiner.hh @@ -14,7 +14,6 @@ class combiner { public: - enum MyParticleId { CH=0, EL=1, NH=2, GAMMA=3, MU=4 }; typedef l1tpf::Particle Particle; combiner(const std::string &iPionFile,const std::string & iElectronFile,const std::string &iTrackFile,const std::string &iFile,double iEtaCharged,double iPuppiPt,double iVtxRes,int debug=0); diff --git a/NtupleProducer/plugins/BuildFile.xml b/NtupleProducer/plugins/BuildFile.xml index 7110d784e45d8..6e29ab52dfcb1 100644 --- a/NtupleProducer/plugins/BuildFile.xml +++ b/NtupleProducer/plugins/BuildFile.xml @@ -21,6 +21,8 @@ + + diff --git a/NtupleProducer/plugins/CaloNtupleProducer.cc b/NtupleProducer/plugins/CaloNtupleProducer.cc new file mode 100644 index 0000000000000..fb1b5ba884dd4 --- /dev/null +++ b/NtupleProducer/plugins/CaloNtupleProducer.cc @@ -0,0 +1,440 @@ +// -*- C++ -*- +// +// Package: CaloNtupleProducer +// Class: CaloNtupleProducer +// +/**\class CaloNtupleProducer CaloNtupleProducer.cc Ntuplizer/CaloNtupleProducer/plugins/CaloNtupleProducer.cc + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Stanislava Sevova +// Created: Fri, 24 Jun 2016 14:57:31 GMT +// $Id$ +// +// + + +// system include files +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" + +#include "FastPUPPI/NtupleProducer/interface/corrector.hh" +#include "FastPUPPI/NtupleProducer/interface/CaloClusterer.h" + +#include "DataFormats/Math/interface/deltaR.h" + +// ROOT classes +#include +#include +#include +#include +#include +#include +#include + +typedef std::vector PFOutputCollection; +typedef std::vector L1PFCollection; + +//-------------------------------------------------------------------------------------------------- +class CaloNtupleProducer : public edm::EDProducer { +public: + explicit CaloNtupleProducer(const edm::ParameterSet&); + ~CaloNtupleProducer(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + const bool zeroSuppress_; + const std::vector EcalTPTags_; + const std::vector HcalTPTags_; + const edm::InputTag GenParTag_; + const std::string CorrectorTag_; + const std::string ECorrectorTag_; + +private: + inline std::string getFilePath(const edm::ParameterSet & pset, const std::string & name) const { + std::string ret = pset.getParameter(name); + if (ret[0] != '/') ret = edm::FileInPath(ret).fullPath(); + return ret; + } + + virtual void beginJob() override; + virtual void produce(edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override; + void genMatch(std::vector &iGenVars, int iType, double iEta, double iPhi, double iPt, const reco::GenParticleCollection &iGenParticles); + void addPF(const L1PFCollection &iCandidates, const std::string &iLabel, edm::Event& iEvent); + + edm::EDGetTokenT TokGenPar_; + std::vector> TokEcalTPTags_; + std::vector> TokHcalTPTags_; + std::unique_ptr corrector_; + std::unique_ptr ecorrector_; + // new calo clusterer (float) + l1pf_calo::SingleCaloClusterer ecalClusterer_, hcalClusterer_; + l1pf_calo::SimpleCaloLinker caloLinker_; + + // declare variables for output file + std::string fOutputName; + TFile *fOutputFile; + TH1D *fTotalEvents; + + TTree *fEcalInfoTree; + TTree *fHcalInfoTree; + float runNum, lumiSec, evtNum; + float genPt, genEta, genPhi, genId; + + float ecal_subdet, ecal_ieta, ecal_iphi, ecal_curTwrEta, ecal_curTwrPhi, ecal_et, ecal_num,ecal_dr; + float hcal_subdet, hcal_ieta, hcal_iphi, hcal_TwrR, hcal_et, hcal_num, hcal_ecal_et,hcal_ecal_etcorr,hcal_ecal_eta,hcal_ecal_phi,hcal_dr; + float ecal_clust_et,ecal_clust_eta,ecal_clust_phi,ecal_corr_et; + float hcal_clust_et,hcal_clust_eta,hcal_clust_phi,hcal_clust_emf,hcal_corr_et,hcal_corr_emf; + float ecal_genPt, ecal_genEta, ecal_genPhi, ecal_genId; + float hcal_genPt, hcal_genEta, hcal_genPhi, hcal_genId; +}; + +// +// constructors and destructor +// +CaloNtupleProducer::CaloNtupleProducer(const edm::ParameterSet& iConfig): + zeroSuppress_ (iConfig.getParameter("zeroSuppress")), + EcalTPTags_ (iConfig.getParameter>("EcalTPTags")), + HcalTPTags_ (iConfig.getParameter>("HcalTPTags")), + GenParTag_ (iConfig.getParameter("genParTag")), + CorrectorTag_ (getFilePath(iConfig,"corrector")), + ECorrectorTag_ (getFilePath(iConfig,"ecorrector")), + corrector_ (new corrector(CorrectorTag_,11,iConfig.getUntrackedParameter("debug",0))), + ecorrector_ (new corrector(ECorrectorTag_,1,iConfig.getUntrackedParameter("debug",0))), + ecalClusterer_ (iConfig.getParameter("caloClusterer").getParameter("ecal")), + hcalClusterer_ (iConfig.getParameter("caloClusterer").getParameter("hcal")), + caloLinker_ (iConfig.getParameter("caloClusterer").getParameter("linker"), ecalClusterer_, hcalClusterer_), + fOutputName (iConfig.getUntrackedParameter("outputName", "ntuple.root")), + fOutputFile (0), + fTotalEvents (0), + fEcalInfoTree (0), + fHcalInfoTree (0) +{ + TokGenPar_ = consumes(GenParTag_); + for (const edm::InputTag &tag : EcalTPTags_) { + TokEcalTPTags_.push_back(consumes(tag)); + } + for (const edm::InputTag &tag : HcalTPTags_) { + TokHcalTPTags_.push_back(consumes(tag)); + } + + produces("uncalibrated"); + produces("calibrated"); + produces("uncalibrated"); + produces("calibrated"); +} + +CaloNtupleProducer::~CaloNtupleProducer() +{ +} + + +// +// member functions +// + +// ------------ method called to produce the data ------------ +void +CaloNtupleProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + //fOutputFile->cd(); + if (!fOutputName.empty()) fTotalEvents->Fill(1); + using namespace edm; + + edm::Handle hGenParProduct; + iEvent.getByToken(TokGenPar_,hGenParProduct); + const reco::GenParticleCollection genParticles = *(hGenParProduct.product()); + + ecalClusterer_.clear(); + hcalClusterer_.clear(); + /// ----------------ECAL INFO------------------- + edm::Handle ecals; + for (const auto & token : TokEcalTPTags_) { + iEvent.getByToken(token, ecals); + for (const l1tpf::Particle & it : *ecals) { + ecalClusterer_.add(it); + } + } + + ecalClusterer_.run(); + //// ---- Dummy calibration == no calibration + // ecalClusterer_.correct( [](const l1pf_calo::Cluster &c, int ieta, int iphi) -> double { return c.et; } ); + // + //// ---- Trivial calibration by hand + /* + ecalClusterer_.correct( [](const l1pf_calo::Cluster &c, int ieta, int iphi) -> double { + if (std::abs(c.eta)<1.5) { + return c.et - (3.0 - std::abs(c.eta)); // it looks like otherwise there's an offset + } else if (std::abs(c.eta)<3) { + return c.et/1.2; // HGCal scale is off by ~1.2% + } else { + return c.et; + } + } ); + */ + //// ---- Calibration from Phil's workflow + ecalClusterer_.correct( [&](const l1pf_calo::Cluster &c, int ieta, int iphi) -> double { + return ecorrector_->correct(0., c.et, ieta, iphi); + } ); + + // write debug output tree + if (!fOutputName.empty()) { + unsigned int ne = 0; + const auto & ecraw = ecalClusterer_.raw(); + const auto & ecals = ecalClusterer_.clusters(); + for (unsigned int i = 0, ncells = ecals.size(); i < ncells; ++i) { + if (ecals[i].et == 0) continue; + ecal_num = ne++; + ecal_et = ecraw[i]; + ecal_ieta = ecals.ieta(i); + ecal_iphi = ecals.iphi(i); + ecal_curTwrEta = ecals.eta(i); + ecal_curTwrPhi = ecals.phi(i); + ecal_clust_et = ecals[i].et; + ecal_clust_eta = ecals[i].eta; + ecal_clust_phi = ecals[i].phi; + ecal_corr_et = ecals[i].et_corr; + + std::vector lGenVars; + genMatch(lGenVars,1,ecal_clust_eta,ecal_clust_phi,ecal_clust_et,genParticles); + ecal_genPt=0; ecal_genEta=0; ecal_genPhi=0; ecal_genId=0; ecal_dr = 0; + if(lGenVars.size() > 3) { + ecal_genPt = float(lGenVars[0]); + ecal_genEta = float(lGenVars[1]); + ecal_genPhi = float(lGenVars[2]); + ecal_genId = float(lGenVars[3]); + ecal_dr = reco::deltaR( ecal_genEta, ecal_genPhi, ecal_clust_eta,ecal_clust_phi ); + } + if (zeroSuppress_) { + if(ecal_genPt > 1.) fEcalInfoTree->Fill(); + } else { + if(ecal_et > 1.) fEcalInfoTree->Fill(); + } + } + } + + // / ----------------HCAL INFO------------------- + + edm::Handle hcals; + for (const auto & token : TokHcalTPTags_) { + iEvent.getByToken(token, hcals); + for (const l1tpf::Particle & it : *hcals) { + hcalClusterer_.add(it); + } + } + hcalClusterer_.run(); + + // Calorimeter linking + caloLinker_.run(); + //// ---- Trivial calibration by hand + /* + caloLinker_.correct( [](const l1pf_calo::CombinedCluster &c, int ieta, int iphi) -> double { + if (std::abs(c.eta)<3.0) { + return c.ecal_et + c.hcal_et * 1.25; + } else { + return c.et; + } + } ); + */ + //// ---- Dummy calibration (no calibration at all) + // caloLinker_.correct( [](const l1pf_calo::CombinedCluster &c, int ieta, int iphi) -> double { return c.et; } ); + // + //// ---- Calibration from Phil's workflow + caloLinker_.correct( [&](const l1pf_calo::CombinedCluster &c, int ieta, int iphi) -> double { + return corrector_->correct(c.et, c.ecal_et, ieta, iphi); + } ); + + // write debug output tree + if (!fOutputName.empty()) { + const auto & clusters = caloLinker_.clusters(); + unsigned int nh = 0; + for (unsigned int i = 0, ncells = clusters.size(); i < ncells; ++i) { + if (clusters[i].et == 0) continue; + hcal_num = nh++; + hcal_et = clusters[i].hcal_et; + hcal_ecal_et = clusters[i].ecal_et; + hcal_ecal_eta = -999; // FIXME missing + hcal_ecal_phi = -999; // FIXME missing + hcal_ieta = clusters.ieta(i); + hcal_iphi = clusters.iphi(i); + hcal_clust_et = clusters[i].et; // all these are of the combined + hcal_clust_eta = clusters[i].eta; // cluster (ecal+hcal) + hcal_clust_phi = clusters[i].phi; + hcal_clust_emf = clusters[i].ecal_et / clusters[i].et; // note: this is raw EMF + hcal_corr_et = clusters[i].et_corr; + hcal_corr_emf = -999; // FIXME + std::vector lGenVars; + genMatch(lGenVars,1,hcal_clust_eta,hcal_clust_phi,hcal_clust_et,genParticles); + hcal_genPt=0; hcal_genEta=0; hcal_genPhi=0; hcal_genId=0; hcal_dr = 0; + if(lGenVars.size() > 3) { + hcal_genPt = float(lGenVars[0]); + hcal_genEta = float(lGenVars[1]); + hcal_genPhi = float(lGenVars[2]); + hcal_genId = float(lGenVars[3]); + hcal_dr = reco::deltaR( hcal_genEta, hcal_genPhi, hcal_clust_eta,hcal_clust_phi ); + } + if (zeroSuppress_) { + if(hcal_genPt > 1.) fHcalInfoTree->Fill(); + } else { + if(hcal_et > 1.) fHcalInfoTree->Fill(); + } + } + } + + // Get particles from the clusterer + std::unique_ptr RawCalo = caloLinker_.fetch(false); + std::unique_ptr CorrCalo = caloLinker_.fetch(true); + + addPF(*RawCalo, "uncalibrated", iEvent); + addPF(*CorrCalo, "calibrated", iEvent); + + iEvent.put(std::move(RawCalo), "uncalibrated"); + iEvent.put(std::move(CorrCalo), "calibrated"); + +} + +void CaloNtupleProducer::addPF(const L1PFCollection &iCandidates, const std::string &iLabel, edm::Event& iEvent) { + std::unique_ptr corrCandidates( new PFOutputCollection ); + corrCandidates->reserve(iCandidates.size()); + for(unsigned int i0 = 0; i0 < iCandidates.size(); i0++) { + reco::PFCandidate::ParticleType id = reco::PFCandidate::ParticleType::X; + int pCharge=0; + if(iCandidates[i0].pdgId() == l1tpf::Particle::CH) id = reco::PFCandidate::ParticleType::h; + if(iCandidates[i0].pdgId() == l1tpf::Particle::EL) id = reco::PFCandidate::ParticleType::e; + if(iCandidates[i0].pdgId() == l1tpf::Particle::NH) id = reco::PFCandidate::ParticleType::h0; + if(iCandidates[i0].pdgId() == l1tpf::Particle::GAMMA) id = reco::PFCandidate::ParticleType::gamma; + if(iCandidates[i0].pdgId() == l1tpf::Particle::MU) id = reco::PFCandidate::ParticleType::mu; + if(iCandidates[i0].pdgId() == l1tpf::Particle::CH || iCandidates[i0].pdgId() == l1tpf::Particle::EL) pCharge = 1; + if(iCandidates[i0].pdgId() == l1tpf::Particle::MU) pCharge = iCandidates[i0].charge(); + reco::PFCandidate pCand(pCharge,iCandidates[i0].p4(),id); + corrCandidates->push_back(pCand); + } + //Fill! + iEvent.put(std::move(corrCandidates),iLabel); +} + +//////////////////////////// ------------------------------------------------------ +//////////////////////////// ------------------------------------------------------ + +//--- Gen Matching +void CaloNtupleProducer::genMatch(std::vector &iGenVars, int iType, double iEta, double iPhi, double iPt, const reco::GenParticleCollection &iGenParticles) { + int lId = -999; + double lPt = -1; + double lDeltaRMin = 100; + TLorentzVector lVec; lVec.SetPtEtaPhiM(0,0,0,0); + for (reco::GenParticleCollection::const_iterator itGenP = iGenParticles.begin(); itGenP!=iGenParticles.end(); ++itGenP) { + if(iType == 0 && itGenP->charge() == 0) continue; + double deltaEta = itGenP->eta()-iEta; + double deltaPhi = fabs(itGenP->phi()-iPhi); if(deltaPhi > 2.*TMath::Pi()-deltaPhi) deltaPhi = 2.*TMath::Pi()-deltaPhi; + double deltaR = sqrt(deltaEta*deltaEta+deltaPhi*deltaPhi); + if(deltaR > 0.2) continue; + if(iType == 0 && deltaR > lDeltaRMin) continue; + if(iType == 0) lId = itGenP->pdgId(); + if(iType == 1 && itGenP->pt() > lPt) { + lPt = itGenP->pt(); + lId = itGenP->pdgId(); + } + lDeltaRMin = deltaR; + TLorentzVector pVec; pVec.SetPtEtaPhiM(itGenP->pt(),itGenP->eta(),itGenP->phi(),itGenP->mass()); + if(iType == 0) lVec = pVec; + if(iType == 1) lVec += pVec; + } + if(lVec.Pt() > 0) iGenVars.push_back(lVec.Pt()); + if(lVec.Pt() > 0) iGenVars.push_back(lVec.Eta()); + if(lVec.Pt() > 0) iGenVars.push_back(lVec.Phi()); + if(lVec.Pt() > 0) iGenVars.push_back(lId); +} + +// ------------ method called once each job just before starting event loop ------------ +void +CaloNtupleProducer::beginJob() +{ + if (fOutputName.empty()) return; + // + // Create output file, trees, and histograms + // + fOutputFile = new TFile(fOutputName.c_str(), "RECREATE"); + fTotalEvents = new TH1D("TotalEvents","TotalEvents",1,-10,10); + fEcalInfoTree = new TTree("EcalInfo", "EcalInfo"); + fHcalInfoTree = new TTree("HcalInfo", "HcalInfo"); + + fEcalInfoTree->Branch("ecal_ieta", &ecal_ieta, "ecal_ieta/F"); + fEcalInfoTree->Branch("ecal_iphi", &ecal_iphi, "ecal_iphi/F"); + fEcalInfoTree->Branch("ecal_curTwrEta", &ecal_curTwrEta, "ecal_curTwrEta/F"); + fEcalInfoTree->Branch("ecal_curTwrPhi", &ecal_curTwrPhi, "ecal_curTwrPhi/F"); + fEcalInfoTree->Branch("ecal_et", &ecal_et, "ecal_et/F"); + fEcalInfoTree->Branch("ecal_num",&ecal_num, "ecal_num/F"); + fEcalInfoTree->Branch("ecal_clust_et", &ecal_clust_et , "ecal_clust_et/F"); + fEcalInfoTree->Branch("ecal_clust_eta", &ecal_clust_eta, "ecal_clust_eta/F"); + fEcalInfoTree->Branch("ecal_clust_phi", &ecal_clust_phi, "ecal_clust_phi/F"); + fEcalInfoTree->Branch("ecal_corr_et" , &ecal_corr_et , "ecal_corr_et/F"); + fEcalInfoTree->Branch("genPt", &ecal_genPt,"ecal_genPt/F"); + fEcalInfoTree->Branch("genEta", &ecal_genEta,"ecal_genEta/F"); + fEcalInfoTree->Branch("genPhi", &ecal_genPhi,"ecal_genPhi/F"); + fEcalInfoTree->Branch("genid", &ecal_genId, "ecal_genid/F"); + fEcalInfoTree->Branch("gendr", &ecal_dr, "ecal_dr/F"); + + + //fHcalInfoTree->Branch("hcal_subdet", &hcal_subdet, "hcal_subdet/F"); + fHcalInfoTree->Branch("hcal_ieta", &hcal_ieta, "hcal_ieta/F"); + fHcalInfoTree->Branch("hcal_iphi", &hcal_iphi, "hcal_iphi/F"); + //fHcalInfoTree->Branch("hcal_TwrR", &hcal_TwrR, "hcal_TwrR/F"); + fHcalInfoTree->Branch("hcal_num", &hcal_num, "hcal_num/F"); + fHcalInfoTree->Branch("hcal_et", &hcal_et, "hcal_et/F"); + fHcalInfoTree->Branch("hcal_clust_et", &hcal_clust_et , "hcal_clust_et/F"); + fHcalInfoTree->Branch("hcal_clust_eta", &hcal_clust_eta, "hcal_clust_eta/F"); + fHcalInfoTree->Branch("hcal_clust_phi", &hcal_clust_phi, "hcal_clust_phi/F"); + fHcalInfoTree->Branch("hcal_clust_emf" , &hcal_clust_emf , "hcal_clust_emf/F"); + fHcalInfoTree->Branch("hcal_corr_et" , &hcal_corr_et , "hcal_corr_et/F"); + fHcalInfoTree->Branch("hcal_corr_emf" , &hcal_corr_emf , "hcal_corr_emf/F"); + fHcalInfoTree->Branch("ecal_et", &hcal_ecal_et, "hcal_ecal_et/F"); + fHcalInfoTree->Branch("ecal_etcorr", &hcal_ecal_etcorr, "hcal_ecal_etcorr/F"); + //fHcalInfoTree->Branch("ecal_eta", &hcal_ecal_eta, "hcal_ecal_eta/F"); // FIXME + //fHcalInfoTree->Branch("ecal_phi", &hcal_ecal_phi, "hcal_ecal_phi/F"); // FIXME + fHcalInfoTree->Branch("genPt", &hcal_genPt ,"hcal_genPt/F"); + fHcalInfoTree->Branch("genEta", &hcal_genEta,"hcal_genEta/F"); + fHcalInfoTree->Branch("genPhi", &hcal_genPhi,"hcal_genPhi/F"); + fHcalInfoTree->Branch("genid", &hcal_genId, "hcal_genid/F"); + fHcalInfoTree->Branch("gendr", &hcal_dr ,"hcal_dr/F"); +} + +// ------------ method called once each job just after ending the event loop ------------ +void +CaloNtupleProducer::endJob() { + if (fOutputName.empty()) return; + // + // Save to ROOT file + // + fOutputFile->cd(); + fTotalEvents->Write(); + fOutputFile->Write(); + fOutputFile->Close(); +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +CaloNtupleProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(CaloNtupleProducer); diff --git a/NtupleProducer/plugins/L1TPFEcalProducerFromOfflineRechits.cc b/NtupleProducer/plugins/L1TPFEcalProducerFromOfflineRechits.cc index f7fdc8af0e817..e0e29331d5124 100644 --- a/NtupleProducer/plugins/L1TPFEcalProducerFromOfflineRechits.cc +++ b/NtupleProducer/plugins/L1TPFEcalProducerFromOfflineRechits.cc @@ -64,13 +64,13 @@ l1tpf::EcalProducerFromOfflineRechits::produce(edm::Event &iEvent, const edm::Ev edm::Handle src; iEvent.getByToken(src_, src); for (const EcalRecHit & hit : *src) { - if (hit.energy() < eCut_) continue; + if (hit.energy() <= eCut_) continue; if (hit.checkFlag(EcalRecHit::kOutOfTime) || hit.checkFlag(EcalRecHit::kL1SpikeFlag)) continue; const GlobalPoint & pos = caloGeom->getPosition(hit.detid()); double et = pos.perp()/pos.mag() * hit.energy(); if (et < etCut_) continue; EBDetId id(hit.detid()); - out_crystal->emplace_back(et, pos.eta(), pos.phi(), 0, 0, 0, 0, pos.eta(), pos.phi()); + out_crystal->emplace_back(et, pos.eta(), pos.phi(), 0., 0); //Using Local iEta,iPhi conventions since all the others are driving me nuts towers[make_pair(l1tpf::translateIEta(pos.eta()),l1tpf::translateIPhi(pos.phi(),pos.eta()))].emplace_back(et, pos.eta(), pos.phi()); //std::cout << "check ieta " << id.tower_ieta() << " -- " << id.tower_iphi() << " -- " << l1tpf::translateIEta(pos.eta()) << " -- " << l1tpf::translateIPhi(pos.phi(),pos.eta()) << std::endl; @@ -87,7 +87,7 @@ l1tpf::EcalProducerFromOfflineRechits::produce(edm::Event &iEvent, const edm::Ev etaetsum /= etsum; phietsum /= etsum; } - out_tower->emplace_back(etsum, etaetsum + reta, reco::deltaPhi(phietsum + rphi, 0.), 0, 0,0,0,etaetsum + reta,reco::deltaPhi(phietsum + rphi, 0.)); + out_tower->emplace_back(etsum, etaetsum + reta, reco::deltaPhi(phietsum + rphi, 0.), 0., 0); } iEvent.put(std::move(out_crystal), "crystals"); diff --git a/NtupleProducer/plugins/L1TPFEcalProducerFromTPDigi.cc b/NtupleProducer/plugins/L1TPFEcalProducerFromTPDigi.cc index 46b5e67d3364c..d93c88441fdca 100644 --- a/NtupleProducer/plugins/L1TPFEcalProducerFromTPDigi.cc +++ b/NtupleProducer/plugins/L1TPFEcalProducerFromTPDigi.cc @@ -1,59 +1,89 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "L1Trigger/L1TCalorimeter/interface/CaloTools.h" -#include "CondFormats/L1TObjects/interface/L1CaloEcalScale.h" +#include "DataFormats/EcalDetId/interface/EBDetId.h" #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" #include "FastPUPPI/NtupleProducer/interface/L1TPFParticle.h" -#include "FastPUPPI/NtupleProducer/interface/L1TPFUtils.h" +#include "DataFormats/Math/interface/deltaPhi.h" namespace l1tpf { - class EcalProducerFromTPDigi : public edm::EDProducer { + class EcalProducerFromTPDigi : public edm::stream::EDProducer<> { public: explicit EcalProducerFromTPDigi(const edm::ParameterSet&) ; ~EcalProducerFromTPDigi() {} private: - edm::EDGetTokenT EcalTPTag_; - std::unique_ptr ecalScale_; + edm::EDGetTokenT EcalTPTag_; + double etCut_; + edm::ESHandle pG; virtual void produce(edm::Event&, const edm::EventSetup&) override; + struct SimpleHit { + float et, eta, phi; + SimpleHit(float aet, float aeta, float aphi) : et(aet), eta(aeta), phi(aphi) {} + }; + }; // class } // namespace l1tpf::EcalProducerFromTPDigi::EcalProducerFromTPDigi(const edm::ParameterSet & iConfig) : - EcalTPTag_(consumes(iConfig.getParameter("EcalTPTag"))), - ecalScale_(new L1CaloEcalScale(0.5)) // ECAL LSB = 0.5 + EcalTPTag_(consumes(iConfig.getParameter("EcalTPTag"))), + etCut_(iConfig.getParameter("etMin")) + { - produces>(); + produces>("crystals"); + produces>("towers"); } void l1tpf::EcalProducerFromTPDigi::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { - std::unique_ptr> out(new std::vector()); - - /// ----------------ECAL INFO------------------- - /// 72 in phi and 56 in eta - /// Ecal TPs - edm::Handle< EcalTrigPrimDigiCollection > ecalTPs; - iEvent.getByToken(EcalTPTag_, ecalTPs); - for (EcalTrigPrimDigiCollection::const_iterator it = ecalTPs->begin(); it != ecalTPs->end(); ++it) { - short sign = 1; if(it->id().ieta() < 0) sign=-1; - double et = ecalScale_->et( it->compressedEt(),(unsigned short)abs(it->id().ieta()), sign); - if(et < 0.1) continue; - //!!!!Check ME - float curTowerEta = l1tpf::towerEta(it->id().ieta()); - float curTowerPhi = l1tpf::towerPhi(it->id().ieta(),it->id().iphi()); - out->emplace_back( et, curTowerEta, curTowerPhi, 0, 0,0,0, curTowerEta, curTowerPhi, 0 ); - } - - iEvent.put(std::move(out)); + std::unique_ptr> out_crystal(new std::vector()); + std::unique_ptr> out_tower(new std::vector()); + + std::map,std::vector> towers; + + //Get Calo Geometry + iSetup.get().get(pG); + const CaloGeometry* caloGeom = pG.product(); + + edm::Handle< EcalEBTrigPrimDigiCollection > ecalTPs; + iEvent.getByToken(EcalTPTag_, ecalTPs); + for (const EcalEBTriggerPrimitiveDigi & digi: *ecalTPs) { + //https://github.com/cms-sw/cmssw/blob/master/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimAnalyzer.cc#L173-L207 + const EBDetId TPid = digi.id(); + float et = digi.encodedEt()/8.; // 8 ADCcounts/GeV + if (et <= etCut_) continue; + const GlobalPoint & pos = caloGeom->getPosition(TPid); + out_crystal->emplace_back(et, pos.eta(), pos.phi(), 0., 0); + towers[std::make_pair(TPid.tower_ieta(),TPid.tower_iphi())].emplace_back(et, pos.eta(), pos.phi()); + } + + for (const auto & pair : towers) { + double etsum = 0., etaetsum = 0., phietsum = 0.; + double reta = pair.second.front().eta, rphi = pair.second.front().phi; + for (const SimpleHit & hit : pair.second) { + etsum += hit.et; + etaetsum += (hit.eta - reta) * hit.et; + phietsum += reco::deltaPhi(hit.phi, rphi) * hit.et; + } + if(etsum > 0) { + etaetsum /= etsum; + phietsum /= etsum; + } + out_tower->emplace_back(etsum, etaetsum + reta, reco::deltaPhi(phietsum + rphi, 0.), 0., 0); + } + + iEvent.put(std::move(out_crystal), "crystals"); + iEvent.put(std::move(out_tower), "towers"); } using l1tpf::EcalProducerFromTPDigi; DEFINE_FWK_MODULE(EcalProducerFromTPDigi); diff --git a/NtupleProducer/plugins/L1TPFHFProducerFromOfflineRechits.cc b/NtupleProducer/plugins/L1TPFHFProducerFromOfflineRechits.cc index 01638c9fb471f..c8a697856a714 100644 --- a/NtupleProducer/plugins/L1TPFHFProducerFromOfflineRechits.cc +++ b/NtupleProducer/plugins/L1TPFHFProducerFromOfflineRechits.cc @@ -62,7 +62,7 @@ l1tpf::HFProducerFromOfflineRechits::produce(edm::Event &iEvent, const edm::Even edm::Handle src; iEvent.getByToken(src_, src); for (const HFRecHit & hit : *src) { - if (hit.energy() < eCut_) continue; + if (hit.energy() <= eCut_) continue; const GlobalPoint & pos = caloGeom->getPosition(hit.detid()); double et = pos.perp()/pos.mag() * hit.energy(); if (et < etCut_) continue; diff --git a/NtupleProducer/plugins/L1TPFHGCalBHProducerFromOfflineRechits.cc b/NtupleProducer/plugins/L1TPFHGCalBHProducerFromOfflineRechits.cc index 4614f20d8f365..47bc20f3632b4 100644 --- a/NtupleProducer/plugins/L1TPFHGCalBHProducerFromOfflineRechits.cc +++ b/NtupleProducer/plugins/L1TPFHGCalBHProducerFromOfflineRechits.cc @@ -66,7 +66,7 @@ l1tpf::HGCalBHProducerFromOfflineRechits::produce(edm::Event &iEvent, const edm: iEvent.getByToken(src_, src); for (const HGCRecHit & hit : *src) { assert(hit.detid().det() == DetId::Hcal && (hit.detid().subdetId() == 2)); - if (hit.energy() < eCut_) continue; + if (hit.energy() <= eCut_) continue; const GlobalPoint & pos = caloGeom->getPosition(hit.detid()); double et = pos.perp()/pos.mag() * hit.energy(); if (et < etCut_) continue; diff --git a/NtupleProducer/plugins/L1TPFHGCalProducerFrom3DTPs.cc b/NtupleProducer/plugins/L1TPFHGCalProducerFrom3DTPs.cc new file mode 100644 index 0000000000000..8127107ee0e29 --- /dev/null +++ b/NtupleProducer/plugins/L1TPFHGCalProducerFrom3DTPs.cc @@ -0,0 +1,49 @@ +#include "DataFormats/Common/interface/Handle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" +#include "FastPUPPI/NtupleProducer/interface/L1TPFParticle.h" + +namespace l1tpf { + class HGCalProducerFrom3DTPs : public edm::stream::EDProducer<> { + public: + explicit HGCalProducerFrom3DTPs(const edm::ParameterSet&) ; + ~HGCalProducerFrom3DTPs() {} + + private: + edm::EDGetTokenT src_; + double etCut_; + + virtual void produce(edm::Event&, const edm::EventSetup&) override; + }; // class +} // namespace + +l1tpf::HGCalProducerFrom3DTPs::HGCalProducerFrom3DTPs(const edm::ParameterSet & iConfig) : + src_(consumes(iConfig.getParameter("src"))), + etCut_(iConfig.getParameter("etMin")) +{ + produces>(); +} + + +void +l1tpf::HGCalProducerFrom3DTPs::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) +{ + std::unique_ptr> out(new std::vector()); + edm::Handle multiclusters; + iEvent.getByToken(src_, multiclusters); + + for(auto it = multiclusters->begin(0), ed = multiclusters->end(0); it != ed; ++it) { + if (it->pt() <= etCut_) continue; + out->emplace_back(it->pt(), it->eta(), it->phi(), 0, 0, 0, 0, it->eta(), it->phi()); + out->back().setHOverE(it->hOverE()); + } + + iEvent.put(std::move(out)); +} +using l1tpf::HGCalProducerFrom3DTPs; +DEFINE_FWK_MODULE(HGCalProducerFrom3DTPs); diff --git a/NtupleProducer/plugins/L1TPFHGCalProducerFromOfflineRechits.cc b/NtupleProducer/plugins/L1TPFHGCalProducerFromOfflineRechits.cc index 2e09d9832a67b..5a52c47b8122c 100644 --- a/NtupleProducer/plugins/L1TPFHGCalProducerFromOfflineRechits.cc +++ b/NtupleProducer/plugins/L1TPFHGCalProducerFromOfflineRechits.cc @@ -67,7 +67,7 @@ l1tpf::HGCalProducerFromOfflineRechits::produce(edm::Event &iEvent, const edm::E iEvent.getByToken(src_, src); for (const HGCRecHit & hit : *src) { assert(hit.detid().det() == DetId::Forward && (3 <= hit.detid().subdetId() && hit.detid().subdetId() <= 4)); - if (hit.energy() < eCut_) continue; + if (hit.energy() <= eCut_) continue; const GlobalPoint & pos = (hit.detid().subdetId() == 3 ? geomEE : geomFH)->getPosition(hit.detid()); double et = pos.perp()/pos.mag() * hit.energy(); if (et < etCut_) continue; diff --git a/NtupleProducer/plugins/L1TPFHGCalProducerFromTriggerCells.cc b/NtupleProducer/plugins/L1TPFHGCalProducerFromTriggerCells.cc new file mode 100644 index 0000000000000..e80cee26706ca --- /dev/null +++ b/NtupleProducer/plugins/L1TPFHGCalProducerFromTriggerCells.cc @@ -0,0 +1,80 @@ +#include "DataFormats/Common/interface/Handle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" +#include "DataFormats/Math/interface/deltaPhi.h" +#include "FastPUPPI/NtupleProducer/interface/L1TPFParticle.h" + +namespace l1tpf { + class HGCalProducerFromTriggerCells : public edm::stream::EDProducer<> { + public: + explicit HGCalProducerFromTriggerCells(const edm::ParameterSet&) ; + ~HGCalProducerFromTriggerCells() {} + + private: + edm::EDGetTokenT src_; + double etCut_; + + struct SimpleHit { + float et, eta, phi; + SimpleHit(float aet, float aeta, float aphi) : et(aet), eta(aeta), phi(aphi) {} + }; + + virtual void produce(edm::Event&, const edm::EventSetup&) override; + }; // class +} // namespace + +l1tpf::HGCalProducerFromTriggerCells::HGCalProducerFromTriggerCells(const edm::ParameterSet & iConfig) : + src_(consumes(iConfig.getParameter("src"))), + etCut_(iConfig.getParameter("etMin")) +{ + produces>(); + produces>("towersEE"); + produces>("towersFHBH"); +} + + +void +l1tpf::HGCalProducerFromTriggerCells::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) +{ + std::unique_ptr> out(new std::vector()); + edm::Handle multiclusters; + iEvent.getByToken(src_, multiclusters); + + std::map,std::vector> towersEE, towersFHBH; + + for(auto it = multiclusters->begin(0), ed = multiclusters->end(0); it != ed; ++it) { + if (it->pt() <= etCut_) continue; + HGCalDetId id(it->detId()); + bool em = id.subdetId() == HGCEE; + (em ? towersEE : towersFHBH)[make_pair(id.zside(), id.wafer())].emplace_back(it->pt(), it->eta(), it->phi()); + out->emplace_back(it->pt(), it->eta(), it->phi(), 0., em ? l1tpf::Particle::GAMMA : l1tpf::Particle::NH); + } + + iEvent.put(std::move(out)); + + for (int em = 0; em <= 1; ++em) { + std::unique_ptr> out_tower(new std::vector()); + for (const auto & pair : (em ? towersEE : towersFHBH)) { + double etsum = 0., etaetsum = 0., phietsum = 0.; + double reta = pair.second.front().eta, rphi = pair.second.front().phi; + for (const SimpleHit & hit : pair.second) { + etsum += hit.et; + etaetsum += (hit.eta - reta) * hit.et; + phietsum += reco::deltaPhi(hit.phi, rphi) * hit.et; + } + etaetsum /= etsum; + phietsum /= etsum; + float eta = etaetsum + reta, phi = reco::deltaPhi(phietsum + rphi, 0.); + out_tower->emplace_back(etsum, eta, phi, 0., em ? l1tpf::Particle::GAMMA : l1tpf::Particle::NH); + } + iEvent.put(std::move(out_tower), em ? "towersEE" : "towersFHBH"); + } + +} +using l1tpf::HGCalProducerFromTriggerCells; +DEFINE_FWK_MODULE(HGCalProducerFromTriggerCells); diff --git a/NtupleProducer/plugins/L1TPFHcalProducerFromTPDigi.cc b/NtupleProducer/plugins/L1TPFHcalProducerFromTPDigi.cc index 5ea2bb37c36e3..e980b2639eca0 100644 --- a/NtupleProducer/plugins/L1TPFHcalProducerFromTPDigi.cc +++ b/NtupleProducer/plugins/L1TPFHcalProducerFromTPDigi.cc @@ -5,19 +5,20 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" -#include "CondFormats/L1TObjects/interface/L1CaloHcalScale.h" #include "L1Trigger/L1TCalorimeter/interface/CaloTools.h" #include "FastPUPPI/NtupleProducer/interface/L1TPFParticle.h" -#include "FastPUPPI/NtupleProducer/interface/L1TPFUtils.h" +//#include "FastPUPPI/NtupleProducer/interface/L1TPFUtils.h" #include "FWCore/Framework/interface/ESHandle.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" -#include "DataFormats/DetId/interface/DetId.h" -#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" -#include "Geometry/HcalTowerAlgo/interface/HcalTrigTowerGeometry.h" +//#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +//#include "Geometry/Records/interface/CaloGeometryRecord.h" +//include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" +//#include "DataFormats/DetId/interface/DetId.h" +//#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" +//#include "Geometry/HcalTowerAlgo/interface/HcalTrigTowerGeometry.h" +#include "DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h" +#include "CalibFormats/CaloTPG/interface/CaloTPGTranscoder.h" +#include "CalibFormats/CaloTPG/interface/CaloTPGRecord.h" -const double PI = 3.1415926535897; namespace l1tpf { class HcalProducerFromTPDigi : public edm::EDProducer { @@ -27,9 +28,9 @@ namespace l1tpf { private: edm::EDGetTokenT HcalTPTag_; - std::unique_ptr hcalScale_; - edm::ESHandle calo; - edm::ESHandle theTrigTowerGeometry; + edm::ESHandle decoder_; + //edm::ESHandle calo; + //edm::ESHandle theTrigTowerGeometry; virtual void produce(edm::Event&, const edm::EventSetup&) override; @@ -38,61 +39,33 @@ namespace l1tpf { } // namespace l1tpf::HcalProducerFromTPDigi::HcalProducerFromTPDigi(const edm::ParameterSet & iConfig) : - HcalTPTag_(consumes(iConfig.getParameter("HcalTPTag"))), - hcalScale_(new L1CaloHcalScale(0.5)) // HCAL LSB = 0.5 + HcalTPTag_(consumes(iConfig.getParameter("HcalTPTag"))) { produces>(); } +// https://github.com/cms-l1t-offline/cmssw/blob/phase2-l1t-integration-CMSSW_9_1_0_pre2/L1Trigger/L1TNtuples/plugins/L1CaloTowerTreeProducer.cc void l1tpf::HcalProducerFromTPDigi::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { std::unique_ptr> out(new std::vector()); - iSetup.get().get(calo); - const CaloGeometry* geo = calo.product(); + iSetup.get().get(decoder_); - iSetup.get().get(theTrigTowerGeometry); - const HcalTrigTowerGeometry* geoTrig = theTrigTowerGeometry.product(); + //iSetup.get().get(calo); + //const CaloGeometry* geo = calo.product(); + //iSetup.get().get(theTrigTowerGeometry); + //const HcalTrigTowerGeometry* geoTrig = theTrigTowerGeometry.product(); - // / ----------------HCAL INFO------------------- - // / Stealing some other code! - // / https://github.com/cms-sw/cmssw/blob/0397259dd747cee94b68928f17976224c037057a/L1Trigger/L1TNtuples/src/L1AnalysisCaloTP.cc#L40 - // / 72 in phi and 56 in eta = 4032 - // / 144 TP is HF: 4 (in eta) * 18 (in phi) * 2 (sides) - // / Hcal TPs edm::Handle< HcalTrigPrimDigiCollection > hcalTPs; iEvent.getByToken(HcalTPTag_, hcalTPs); - for (HcalTrigPrimDigiCollection::const_iterator it = hcalTPs->begin(); it != hcalTPs->end(); ++it) { - double et = hcalScale_->et( it->SOI_compressedEt(),it->id().ietaAbs(), it->id().zside() ); - - // convert ieta-iphi to eta,phi - std::vector detids = geoTrig->detIds(it->id()); - unsigned int ndetsPerTower = detids.size(); - float towerEta = 0.; - float towerPhi = 0.; - float towerR = 0.; - float curphimax = -9999.; - float curphimin = 9999.; - for (unsigned int i = 0; i < ndetsPerTower; i++){ - const CaloCellGeometry *cell = geo->getGeometry( detids[i] ); - // std::cout << detids[i].det() << "," << detids[i].subdetId() << "," << detids[i].iphi() << "," << detids[i].ieta() << "," << cell->etaPos() << "," << cell->phiPos() << std::endl; - towerEta += cell->etaPos(); - towerR += cell->getPosition().mag(); - if (curphimax < cell->phiPos()) curphimax = cell->phiPos(); - if (curphimin > cell->phiPos()) curphimin = cell->phiPos(); - } - // std::cout << "curphimax = " << curphimax << ", curphimin = " << curphimin << std::endl; - if (curphimax - curphimin < PI){ towerPhi = (curphimax + curphimin)/2.; } - else{ towerPhi = -3.14159;} // special case - // else{ towerPhi = (curphimax - curphimin + 2*PI)/2.; } - // std::cout << "towerPhi = " << towerPhi << std::endl; - // if (fabs(towerPhi) > PI && towerPhi > 0) towerPhi -= PI; - // if (fabs(towerPhi) > PI && towerPhi < 0) towerPhi += PI; - towerPhi *= 1.; - towerEta /= float(ndetsPerTower); - towerR /= float(ndetsPerTower); + for (const auto & itr : *hcalTPs) { + HcalTrigTowerDetId id = itr.id(); + double et = decoder_->hcaletValue(itr.id(), itr.t0()); + if (et <= 0) continue; + float towerEta = l1t::CaloTools::towerEta(id.ieta()); + float towerPhi = l1t::CaloTools::towerPhi(id.ieta(), id.iphi()); out->emplace_back( et, towerEta, towerPhi, 0, 0,0,0, towerEta, towerPhi, 0 ); } diff --git a/NtupleProducer/plugins/L1TkProducerFromL1Tracks.cc b/NtupleProducer/plugins/L1TkProducerFromL1Tracks.cc new file mode 100644 index 0000000000000..1ee336cf10402 --- /dev/null +++ b/NtupleProducer/plugins/L1TkProducerFromL1Tracks.cc @@ -0,0 +1,109 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" + +#include "DataFormats/Math/interface/deltaR.h" + +#include "FastPUPPI/NtupleProducer/interface/L1TPFParticle.h" +#include "FastPUPPI/NtupleProducer/interface/L1TPFUtils.h" + +#define HASL1TK +#ifdef HASL1TK +#include "DataFormats/L1TrackTrigger/interface/TTTrack.h" +#include "DataFormats/L1TrackTrigger/interface/TTTypes.h" +#endif + + +namespace l1tpf { + class TkProducerFromL1Tracks : public edm::EDProducer { + public: + explicit TkProducerFromL1Tracks(const edm::ParameterSet&) ; + ~TkProducerFromL1Tracks() {} + + private: + edm::EDGetToken TrackTag_; + bool muonGunVeto_; + edm::EDGetTokenT GenTagForVeto_; + float fBz_; + + virtual void produce(edm::Event&, const edm::EventSetup&) override; + + virtual void beginRun(edm::Run const&, edm::EventSetup const& iSetup) override { + edm::ESHandle magneticField; + iSetup.get().get(magneticField); + fBz_ = magneticField->inTesla(GlobalPoint(0,0,0)).z(); + } + + }; // class +} // namespace + +l1tpf::TkProducerFromL1Tracks::TkProducerFromL1Tracks(const edm::ParameterSet&iConfig) : + muonGunVeto_(iConfig.getParameter("MuonGunVeto")) +{ +#ifdef HASL1TK + TrackTag_ = consumes>>(iConfig.getParameter("L1TrackTag")); +#endif + if (muonGunVeto_) GenTagForVeto_ = consumes(iConfig.getParameter("GenTagForVeto")); + produces>(); +} + + +void +l1tpf::TkProducerFromL1Tracks::produce(edm::Event & iEvent, const edm::EventSetup &) +{ + std::unique_ptr> out(new std::vector()); + std::vector vetos; + if (muonGunVeto_) { + edm::Handle gens; + iEvent.getByToken(GenTagForVeto_, gens); + for (const reco::Candidate & c : *gens) vetos.push_back(&c); + } + +#ifdef HASL1TK + // https://github.com/skinnari/cmssw/blob/80c19f1b721325c3a02ee0482f72fb974a4c3bf7/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker.cc + edm::Handle< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > tracks; + iEvent.getByToken(TrackTag_, tracks); + + unsigned L1Tk_nPar = 4; + for (const auto &tk : *tracks) { + + float pt = tk.getMomentum(L1Tk_nPar).perp(); + float eta = tk.getMomentum(L1Tk_nPar).eta(); + float phi = tk.getMomentum(L1Tk_nPar).phi(); + float z0 = tk.getPOCA(L1Tk_nPar).z(); //cm + int charge = tk.getRInv() > 0 ? +1 : -1; + + bool passveto = true; + for (const reco::Candidate * veto : vetos) { + if (::deltaR2(veto->eta(), veto->phi(), eta, phi) < 0.01 && pt > 0.5 * std::min(veto->pt(),100.)) { + passveto = false; break; + } + } + if (!passveto) continue; + + out->emplace_back(pt, eta, phi, 0.137, 0, 0.0, z0); + l1tpf::Particle & me = out->back(); + // More info + me.setQuality(tk.getStubRefs().size()); + me.setNormalizedChi2(tk.getChi2Red(L1Tk_nPar)); + me.setVertex(reco::Particle::Point(0,0,z0)); + me.setCharge(charge); + + // Calo propagation + math::XYZTLorentzVector tMom(me.px(), me.py(), me.pz(), me.energy()); + math::XYZTLorentzVector tVtx(0,0,z0,0.); + std::vector lVars; + l1tpf::propagate(1,lVars,tMom,tVtx,charge,fBz_); + me.setCaloEtaPhi(lVars[4], lVars[5]); + } +#endif + iEvent.put(std::move(out)); +} +using l1tpf::TkProducerFromL1Tracks; +DEFINE_FWK_MODULE(TkProducerFromL1Tracks); diff --git a/NtupleProducer/plugins/NtupleProducer.cc b/NtupleProducer/plugins/NtupleProducer.cc index fc75ef211976a..022075e67cf2d 100644 --- a/NtupleProducer/plugins/NtupleProducer.cc +++ b/NtupleProducer/plugins/NtupleProducer.cc @@ -39,26 +39,15 @@ #include "FastPUPPI/NtupleProducer/interface/metanalyzer.hh" #include "FastPUPPI/NtupleProducer/interface/jetanalyzer.hh" #include "FastPUPPI/NtupleProducer/interface/isoanalyzer.hh" -#include "FastPUPPI/NtupleProducer/interface/L1TPFUtils.h" #include "FastPUPPI/NtupleProducer/interface/DiscretePF.h" -#include "FastPUPPI/NtupleProducer/interface/CaloClusterer.h" -#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h" -#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h" -#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h" -#include "DataFormats/L1Trigger/interface/Muon.h" - -#include "L1Trigger/L1TCalorimeter/interface/CaloTools.h" #include "DataFormats/Math/interface/deltaR.h" -const double PI = 3.1415926535897; - // ROOT classes #include #include #include -#include #include #include #include @@ -74,14 +63,9 @@ class NtupleProducer : public edm::EDProducer { ~NtupleProducer(); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - const bool zeroSuppress_; const edm::InputTag L1TrackTag_; - const edm::InputTag EcalTPTag_; - const edm::InputTag HGEcalTPTag_; - const edm::InputTag HcalTPTag_; - const edm::InputTag HGHcalTPTag_; - const edm::InputTag BHHcalTPTag_; - const edm::InputTag HFTPTag_; + const std::vector CaloClusterTags_; + const bool correctCaloEnergies_; const edm::InputTag MuonTPTag_; const edm::InputTag GenParTag_; const std::string CorrectorTag_; @@ -90,7 +74,6 @@ class NtupleProducer : public edm::EDProducer { const std::string TrackResTag_; const std::string EleResTag_; const std::string PionResTag_; - std::unique_ptr corrCandidates_; private: inline std::string getFilePath(const edm::ParameterSet & pset, const std::string & name) const { @@ -99,29 +82,16 @@ class NtupleProducer : public edm::EDProducer { return ret; } - struct MyEcalCluster { - int ieta, iphi; float et, corr_et, eta, phi; - MyEcalCluster(int iIeta, int iIphi, float iEt, float iCorr_et, float iEta, float iPhi) : - ieta(iIeta), iphi(iIphi), et(iEt), corr_et(iCorr_et), eta(iEta), phi(iPhi) {} - bool operator<(const MyEcalCluster &other) const { return eta < other.eta; } - }; - virtual void beginJob() override; virtual void produce(edm::Event&, const edm::EventSetup&) override; virtual void endJob() override; - void genMatch(std::vector &iGenVars,int iType,double iEta,double iPhi,double iPt,const reco::GenParticleCollection &iGenParticles); - virtual void beginRun(edm::Run const&, edm::EventSetup const&) override; - void addPF(std::vector &iCandidates,std::string iLabel,edm::Event& iEvent); + void genMatch(std::vector &iGenVars, int iType, double iEta, double iPhi, double iPt, const reco::GenParticleCollection &iGenParticles); + void addPF(const std::vector &iCandidates, const std::string &iLabel, edm::Event& iEvent); void addUInt(unsigned int value,std::string iLabel,edm::Event& iEvent); edm::EDGetTokenT TokGenPar_; edm::EDGetTokenT TokL1TrackTPTag_; - edm::EDGetTokenT TokEcalTPTag_; - edm::EDGetTokenT TokHGEcalTPTag_; - edm::EDGetTokenT TokHcalTPTag_; - edm::EDGetTokenT TokHGHcalTPTag_; - edm::EDGetTokenT TokBHHcalTPTag_; - edm::EDGetTokenT TokHFTPTag_; + std::vector> TokCaloClusterTags_; edm::EDGetTokenT TokMuonTPTag_; double trkPt_; bool metRate_; @@ -138,9 +108,6 @@ class NtupleProducer : public edm::EDProducer { // discretized version l1tpf_int::RegionMapper l1regions_; l1tpf_int::PFAlgo l1pfalgo_; - // new calo clusterer (float) - l1pf_calo::SingleCaloClusterer ecalClusterer_, hcalClusterer_; - l1pf_calo::SimpleCaloLinker caloLinker_; // debug flag int fDebug; @@ -157,39 +124,15 @@ class NtupleProducer : public edm::EDProducer { float trkPx, trkPz, trkPy, trkPt, trkEta, trkPhi, trkz0, trkd0; float trkEcalEta, trkEcalPhi, trkEcalR; float genPt, genEta, genPhi, genId; - - float ecal_subdet, ecal_ieta, ecal_iphi, ecal_curTwrEta, ecal_curTwrPhi, ecal_et, ecal_num,ecal_dr; - float hcal_subdet, hcal_ieta, hcal_iphi, hcal_TwrR, hcal_et, hcal_num, hcal_ecal_et,hcal_ecal_etcorr,hcal_ecal_eta,hcal_ecal_phi,hcal_dr; - float ecal_clust_et,ecal_clust_eta,ecal_clust_phi,ecal_corr_et; - float hcal_clust_et,hcal_clust_eta,hcal_clust_phi,hcal_clust_emf,hcal_corr_et,hcal_corr_emf; - float ecal_genPt, ecal_genEta, ecal_genPhi, ecal_genId; - float hcal_genPt, hcal_genEta, hcal_genPhi, hcal_genId; - //virtual void endRun(edm::Run const&, edm::EventSetup const&) override; - //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; - //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; }; -// -// constants, enums and typedefs -// - - -// -// static data member definitions -// - // // constructors and destructor // NtupleProducer::NtupleProducer(const edm::ParameterSet& iConfig): - zeroSuppress_ (iConfig.getParameter("zeroSuppress")), L1TrackTag_ (iConfig.getParameter("L1TrackTag")), - EcalTPTag_ (iConfig.getParameter("EcalTPTag")), - HGEcalTPTag_ (iConfig.getParameter("HGEcalTPTag")), - HcalTPTag_ (iConfig.getParameter("HcalTPTag")), - HGHcalTPTag_ (iConfig.getParameter("HGHcalTPTag")), - BHHcalTPTag_ (iConfig.getParameter("BHHcalTPTag")), - HFTPTag_ (iConfig.getParameter("HFTPTag")), + CaloClusterTags_ (iConfig.getParameter>("CaloClusterTags")), + correctCaloEnergies_ (iConfig.getParameter("correctCaloEnergies")), MuonTPTag_ (iConfig.getParameter("MuonTPTag")), GenParTag_ (iConfig.getParameter("genParTag")), CorrectorTag_ (getFilePath(iConfig,"corrector")), @@ -204,16 +147,11 @@ NtupleProducer::NtupleProducer(const edm::ParameterSet& iConfig): vtxRes_ (iConfig.getParameter ("vtxRes")), l1regions_ (iConfig), l1pfalgo_ (iConfig), - ecalClusterer_ (iConfig.getParameter("caloClusterer").getParameter("ecal")), - hcalClusterer_ (iConfig.getParameter("caloClusterer").getParameter("hcal")), - caloLinker_ (iConfig.getParameter("caloClusterer").getParameter("linker"), ecalClusterer_, hcalClusterer_), fDebug (iConfig.getUntrackedParameter("debug",0)), fOutputName (iConfig.getUntrackedParameter("outputName", "ntuple.root")), fOutputFile (0), fTotalEvents (0), - fTrkInfoTree (0), - fEcalInfoTree (0), - fHcalInfoTree (0) + fTrkInfoTree (0) { //now do what ever other initialization is needed corrector_ = new corrector(CorrectorTag_,11,fDebug); @@ -240,12 +178,9 @@ NtupleProducer::NtupleProducer(const edm::ParameterSet& iConfig): produces("L1Puppi"); TokGenPar_ = consumes( GenParTag_ ); TokL1TrackTPTag_ = consumes( L1TrackTag_ ); - TokEcalTPTag_ = consumes( EcalTPTag_ ); - TokHGEcalTPTag_ = consumes( HGEcalTPTag_ ); - TokHcalTPTag_ = consumes( HcalTPTag_ ); - TokHGHcalTPTag_ = consumes( HGHcalTPTag_ ); - TokBHHcalTPTag_ = consumes( BHHcalTPTag_ ); - TokHFTPTag_ = consumes( HFTPTag_ ); + for (const edm::InputTag &tag : CaloClusterTags_) { + TokCaloClusterTags_.push_back(consumes(tag)); + } TokMuonTPTag_ = consumes( MuonTPTag_ ); produces("totNL1TK"); produces("totNL1Mu"); @@ -284,8 +219,6 @@ NtupleProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { connector_->clear(); rawconnector_->clear(); l1regions_.clear(); - ecalClusterer_.clear(); - hcalClusterer_.clear(); /// ----------------TRACK INFO------------------- edm::Handle> l1tks; iEvent.getByLabel(L1TrackTag_, l1tks); @@ -331,162 +264,36 @@ NtupleProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { l1regions_.addMuon(mu); } - /// ----------------ECAL INFO------------------- - edm::Handle classicecals; - iEvent.getByToken(TokEcalTPTag_, classicecals); - edm::Handle hgecals; - iEvent.getByToken(TokHGEcalTPTag_, hgecals); - for (const l1tpf::Particle & it : *classicecals) ecalClusterer_.add(it); - for (const l1tpf::Particle & it : *hgecals ) ecalClusterer_.add(it); - - ecalClusterer_.run(); - //// ---- Dummy calibration == no calibration - // ecalClusterer_.correct( [](const l1pf_calo::Cluster &c, int ieta, int iphi) -> double { return c.et; } ); - // - //// ---- Trivial calibration by hand - /* - ecalClusterer_.correct( [](const l1pf_calo::Cluster &c, int ieta, int iphi) -> double { - if (std::abs(c.eta)<1.5) { - return c.et - (3.0 - std::abs(c.eta)); // it looks like otherwise there's an offset - } else if (std::abs(c.eta)<3) { - return c.et/1.2; // HGCal scale is off by ~1.2% - } else { - return c.et; - } - } ); - */ - //// ---- Calibration from Phil's workflow - ecalClusterer_.correct( [&](const l1pf_calo::Cluster &c, int ieta, int iphi) -> double { - return ecorrector_->correct(0., c.et, ieta, iphi); - } ); - - // write debug output tree - if (!fOutputName.empty()) { - unsigned int ne = 0; - const auto & ecraw = ecalClusterer_.raw(); - const auto & ecals = ecalClusterer_.clusters(); - for (unsigned int i = 0, ncells = ecals.size(); i < ncells; ++i) { - if (ecals[i].et == 0) continue; - ecal_num = ne++; - ecal_et = ecraw[i]; - ecal_ieta = ecals.ieta(i); - ecal_iphi = ecals.iphi(i); - ecal_curTwrEta = ecals.eta(i); - ecal_curTwrPhi = ecals.phi(i); - ecal_clust_et = ecals[i].et; - ecal_clust_eta = ecals[i].eta; - ecal_clust_phi = ecals[i].phi; - ecal_corr_et = ecals[i].et_corr; - - std::vector lGenVars; - genMatch(lGenVars,1,ecal_clust_eta,ecal_clust_phi,ecal_clust_et,genParticles); - ecal_genPt=0; ecal_genEta=0; ecal_genPhi=0; ecal_genId=0; ecal_dr = 0; - if(lGenVars.size() > 3) { - ecal_genPt = float(lGenVars[0]); - ecal_genEta = float(lGenVars[1]); - ecal_genPhi = float(lGenVars[2]); - ecal_genId = float(lGenVars[3]); - ecal_dr = reco::deltaR( ecal_genEta, ecal_genPhi, ecal_clust_eta,ecal_clust_phi ); - } - if (zeroSuppress_) { - if(ecal_genPt > 1.) fEcalInfoTree->Fill(); - } else { - if(ecal_et > 1.) fEcalInfoTree->Fill(); - } - } + + /// ----------------Clustered Calo INFO------------------- + L1PFCollection calos; + edm::Handle hcals; + for (const auto & token : TokCaloClusterTags_) { + iEvent.getByToken(token, hcals); + calos.insert(calos.end(), hcals->begin(), hcals->end()); } - // / ----------------HCAL INFO------------------- - edm::Handle classichcals; - iEvent.getByToken(TokHcalTPTag_, classichcals); - edm::Handle hghcals; - iEvent.getByToken(TokHGHcalTPTag_, hghcals); - edm::Handle bhhcals; - iEvent.getByToken(TokBHHcalTPTag_, bhhcals); - edm::Handle hfhcals; - iEvent.getByToken(TokHFTPTag_, hfhcals); - for (const l1tpf::Particle & it : *classichcals) hcalClusterer_.add(it); - for (const l1tpf::Particle & it : *hfhcals ) hcalClusterer_.add(it); - for (const l1tpf::Particle & it : *hghcals ) hcalClusterer_.add(it); - for (const l1tpf::Particle & it : *bhhcals ) hcalClusterer_.add(it); - hcalClusterer_.run(); - - // Calorimeter linking - caloLinker_.run(); - ///=== FIXME calibration goes here ==== - //// ---- Trivial calibration by hand - /* - caloLinker_.correct( [](const l1pf_calo::CombinedCluster &c, int ieta, int iphi) -> double { - if (std::abs(c.eta)<3.0) { - return c.ecal_et + c.hcal_et * 1.25; - } else { - return c.et; - } - } ); - */ - //// ---- Dummy calibration (no calibration at all) - // caloLinker_.correct( [](const l1pf_calo::CombinedCluster &c, int ieta, int iphi) -> double { return c.et; } ); - // - //// ---- Calibration from Phil's workflow - caloLinker_.correct( [&](const l1pf_calo::CombinedCluster &c, int ieta, int iphi) -> double { - return corrector_->correct(c.et, c.ecal_et, ieta, iphi); - } ); - - // write debug output tree - if (!fOutputName.empty()) { - const auto & clusters = caloLinker_.clusters(); - unsigned int nh = 0; - for (unsigned int i = 0, ncells = clusters.size(); i < ncells; ++i) { - if (clusters[i].et == 0) continue; - hcal_num = nh++; - hcal_et = clusters[i].hcal_et; - hcal_ecal_et = clusters[i].ecal_et; - hcal_ecal_eta = -999; // FIXME missing - hcal_ecal_phi = -999; // FIXME missing - hcal_ieta = clusters.ieta(i); - hcal_iphi = clusters.iphi(i); - hcal_clust_et = clusters[i].et; // all these are of the combined - hcal_clust_eta = clusters[i].eta; // cluster (ecal+hcal) - hcal_clust_phi = clusters[i].phi; - hcal_clust_emf = clusters[i].ecal_et / clusters[i].et; // note: this is raw EMF - hcal_corr_et = clusters[i].et_corr; - hcal_corr_emf = -999; // FIXME - std::vector lGenVars; - genMatch(lGenVars,1,hcal_clust_eta,hcal_clust_phi,hcal_clust_et,genParticles); - hcal_genPt=0; hcal_genEta=0; hcal_genPhi=0; hcal_genId=0; hcal_dr = 0; - if(lGenVars.size() > 3) { - hcal_genPt = float(lGenVars[0]); - hcal_genEta = float(lGenVars[1]); - hcal_genPhi = float(lGenVars[2]); - hcal_genId = float(lGenVars[3]); - hcal_dr = reco::deltaR( hcal_genEta, hcal_genPhi, hcal_clust_eta,hcal_clust_phi ); - } - if (zeroSuppress_) { - if(hcal_genPt > 1.) fHcalInfoTree->Fill(); - } else { - if(hcal_et > 1.) fHcalInfoTree->Fill(); - } - } + // add uncalibrated (or at least un-recalibrated) calos to rawconnector + for (const l1tpf::Particle & calo : calos) { + rawconnector_->addCalo(calo); } - // Get particles from the clusterer - std::vector RawCaloCands = caloLinker_.fetch(false); - std::vector CaloCands = caloLinker_.fetch(true); - // FIXME the sigma is known to the combiner, not the calo clusterer, at the moment - for (l1tpf::Particle & calo : CaloCands) { - calo.setSigma(calo.pdgId() == combiner::GAMMA ? - connector_->getEleRes(calo.pt(), calo.eta(), calo.phi()) : - connector_->getPionRes(calo.pt(), calo.eta(), calo.phi())); + // ccalibrate and do the rest + for (l1tpf::Particle &calo : calos) { + if (correctCaloEnergies_) { + float ptcorr = corrector_->correct(calo.pt(), calo.emEt(), calo.iEta(), calo.iPhi()); + calo.setPt(ptcorr); + } + calo.setSigma(calo.pdgId() == combiner::Particle::GAMMA ? + connector_->getEleRes(calo.pt(), calo.eta(), calo.phi()) : + connector_->getPionRes(calo.pt(), calo.eta(), calo.phi())); } // pass to the PF algo - for (const l1tpf::Particle & calo : CaloCands) { + for (const l1tpf::Particle & calo : calos) { connector_->addCalo(calo); l1regions_.addCalo(calo); } - for (const l1tpf::Particle & calo : RawCaloCands) { - rawconnector_->addCalo(calo); - } std::vector lRawCalo = rawconnector_->candidates(); std::vector lCorrCalo = connector_->candidates(); @@ -550,13 +357,13 @@ NtupleProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { for (const auto & r : l1regions_.regions()) { totNL1Calo += r.calo.size(); totNL1TK += r.track.size(); - totNL1PF += r.muon.size(); + totNL1PF += r.pf.size(); totNL1Mu += r.muon.size(); totNL1Puppi += r.puppi.size(); maxNL1Calo = std::max( maxNL1Calo, r.calo.size() ); maxNL1TK = std::max( maxNL1TK, r.track.size() ); - maxNL1PF = std::max( maxNL1PF, r.muon.size() ); - maxNL1Mu = std::max( maxNL1Mu, r.pf.size() ); + maxNL1PF = std::max( maxNL1PF, r.pf.size() ); + maxNL1Mu = std::max( maxNL1Mu, r.muon.size() ); maxNL1Puppi = std::max( maxNL1Puppi, r.puppi.size() ); } addUInt(totNL1Calo, "totNL1Calo", iEvent); addUInt(maxNL1Calo, "maxNL1Calo", iEvent); @@ -603,23 +410,23 @@ NtupleProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { } } -void NtupleProducer::addPF(std::vector &iCandidates,std::string iLabel,edm::Event& iEvent) { - corrCandidates_.reset( new PFOutputCollection ); +void NtupleProducer::addPF(const L1PFCollection &iCandidates, const std::string &iLabel, edm::Event& iEvent) { + std::unique_ptr corrCandidates( new PFOutputCollection ); for(unsigned int i0 = 0; i0 < iCandidates.size(); i0++) { reco::PFCandidate::ParticleType id = reco::PFCandidate::ParticleType::X; int pCharge=0; - if(iCandidates[i0].pdgId() == combiner::CH) id = reco::PFCandidate::ParticleType::h; - if(iCandidates[i0].pdgId() == combiner::EL) id = reco::PFCandidate::ParticleType::e; - if(iCandidates[i0].pdgId() == combiner::NH) id = reco::PFCandidate::ParticleType::h0; - if(iCandidates[i0].pdgId() == combiner::GAMMA) id = reco::PFCandidate::ParticleType::gamma; - if(iCandidates[i0].pdgId() == combiner::MU) id = reco::PFCandidate::ParticleType::mu; - if(iCandidates[i0].pdgId() == combiner::CH || iCandidates[i0].pdgId() == combiner::EL) pCharge = 1; - if(iCandidates[i0].pdgId() == combiner::MU) pCharge = iCandidates[i0].charge(); + if(iCandidates[i0].pdgId() == combiner::Particle::CH) id = reco::PFCandidate::ParticleType::h; + if(iCandidates[i0].pdgId() == combiner::Particle::EL) id = reco::PFCandidate::ParticleType::e; + if(iCandidates[i0].pdgId() == combiner::Particle::NH) id = reco::PFCandidate::ParticleType::h0; + if(iCandidates[i0].pdgId() == combiner::Particle::GAMMA) id = reco::PFCandidate::ParticleType::gamma; + if(iCandidates[i0].pdgId() == combiner::Particle::MU) id = reco::PFCandidate::ParticleType::mu; + if(iCandidates[i0].pdgId() == combiner::Particle::CH || iCandidates[i0].pdgId() == combiner::Particle::EL) pCharge = 1; + if(iCandidates[i0].pdgId() == combiner::Particle::MU) pCharge = iCandidates[i0].charge(); reco::PFCandidate pCand(pCharge,iCandidates[i0].p4(),id); - corrCandidates_->push_back(pCand); + corrCandidates->push_back(pCand); } //Fill! - iEvent.put(std::move(corrCandidates_),iLabel); + iEvent.put(std::move(corrCandidates),iLabel); } void NtupleProducer::addUInt(unsigned int value,std::string iLabel,edm::Event& iEvent) { iEvent.put(std::make_unique(value), iLabel); @@ -668,8 +475,6 @@ NtupleProducer::beginJob() fOutputFile = new TFile(fOutputName.c_str(), "RECREATE"); fTotalEvents = new TH1D("TotalEvents","TotalEvents",1,-10,10); fTrkInfoTree = new TTree("TrkInfo", "TrkInfo"); - fEcalInfoTree = new TTree("EcalInfo", "EcalInfo"); - fHcalInfoTree = new TTree("HcalInfo", "HcalInfo"); fTrkInfoTree->Branch("runNum", &runNum, "runNum/F"); fTrkInfoTree->Branch("lumiSec", &lumiSec, "lumiSec/F"); @@ -690,45 +495,6 @@ NtupleProducer::beginJob() fTrkInfoTree->Branch("genEta", &genEta, "genEta/F"); fTrkInfoTree->Branch("genPhi", &genPhi, "genPhi/F"); fTrkInfoTree->Branch("genid", &genId, "genid/F"); - - fEcalInfoTree->Branch("ecal_ieta", &ecal_ieta, "ecal_ieta/F"); - fEcalInfoTree->Branch("ecal_iphi", &ecal_iphi, "ecal_iphi/F"); - fEcalInfoTree->Branch("ecal_curTwrEta", &ecal_curTwrEta, "ecal_curTwrEta/F"); - fEcalInfoTree->Branch("ecal_curTwrPhi", &ecal_curTwrPhi, "ecal_curTwrPhi/F"); - fEcalInfoTree->Branch("ecal_et", &ecal_et, "ecal_et/F"); - fEcalInfoTree->Branch("ecal_num",&ecal_num, "ecal_num/F"); - fEcalInfoTree->Branch("ecal_clust_et", &ecal_clust_et , "ecal_clust_et/F"); - fEcalInfoTree->Branch("ecal_clust_eta", &ecal_clust_eta, "ecal_clust_eta/F"); - fEcalInfoTree->Branch("ecal_clust_phi", &ecal_clust_phi, "ecal_clust_phi/F"); - fEcalInfoTree->Branch("ecal_corr_et" , &ecal_corr_et , "ecal_corr_et/F"); - fEcalInfoTree->Branch("genPt", &ecal_genPt,"ecal_genPt/F"); - fEcalInfoTree->Branch("genEta", &ecal_genEta,"ecal_genEta/F"); - fEcalInfoTree->Branch("genPhi", &ecal_genPhi,"ecal_genPhi/F"); - fEcalInfoTree->Branch("genid", &ecal_genId, "ecal_genid/F"); - fEcalInfoTree->Branch("gendr", &ecal_dr, "ecal_dr/F"); - - - //fHcalInfoTree->Branch("hcal_subdet", &hcal_subdet, "hcal_subdet/F"); - fHcalInfoTree->Branch("hcal_ieta", &hcal_ieta, "hcal_ieta/F"); - fHcalInfoTree->Branch("hcal_iphi", &hcal_iphi, "hcal_iphi/F"); - //fHcalInfoTree->Branch("hcal_TwrR", &hcal_TwrR, "hcal_TwrR/F"); - fHcalInfoTree->Branch("hcal_num", &hcal_num, "hcal_num/F"); - fHcalInfoTree->Branch("hcal_et", &hcal_et, "hcal_et/F"); - fHcalInfoTree->Branch("hcal_clust_et", &hcal_clust_et , "hcal_clust_et/F"); - fHcalInfoTree->Branch("hcal_clust_eta", &hcal_clust_eta, "hcal_clust_eta/F"); - fHcalInfoTree->Branch("hcal_clust_phi", &hcal_clust_phi, "hcal_clust_phi/F"); - fHcalInfoTree->Branch("hcal_clust_emf" , &hcal_clust_emf , "hcal_clust_emf/F"); - fHcalInfoTree->Branch("hcal_corr_et" , &hcal_corr_et , "hcal_corr_et/F"); - fHcalInfoTree->Branch("hcal_corr_emf" , &hcal_corr_emf , "hcal_corr_emf/F"); - fHcalInfoTree->Branch("ecal_et", &hcal_ecal_et, "hcal_ecal_et/F"); - fHcalInfoTree->Branch("ecal_etcorr", &hcal_ecal_etcorr, "hcal_ecal_etcorr/F"); - //fHcalInfoTree->Branch("ecal_eta", &hcal_ecal_eta, "hcal_ecal_eta/F"); // FIXME - //fHcalInfoTree->Branch("ecal_phi", &hcal_ecal_phi, "hcal_ecal_phi/F"); // FIXME - fHcalInfoTree->Branch("genPt", &hcal_genPt ,"hcal_genPt/F"); - fHcalInfoTree->Branch("genEta", &hcal_genEta,"hcal_genEta/F"); - fHcalInfoTree->Branch("genPhi", &hcal_genPhi,"hcal_genPhi/F"); - fHcalInfoTree->Branch("genid", &hcal_genId, "hcal_genid/F"); - fHcalInfoTree->Branch("gendr", &hcal_dr ,"hcal_dr/F"); } // ------------ method called once each job just after ending the event loop ------------ @@ -749,38 +515,6 @@ NtupleProducer::endJob() { fOutputFile->Close(); } -// ------------ method called when starting to processes a run ------------ - -void -NtupleProducer::beginRun(edm::Run const&, edm::EventSetup const& iSetup) -{ -} - - -// ------------ method called when ending the processing of a run ------------ -/* -void -NtupleProducer::endRun(edm::Run const&, edm::EventSetup const&) -{ -} -*/ - -// ------------ method called when starting to processes a luminosity block ------------ -/* -void -NtupleProducer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) -{ -} -*/ - -// ------------ method called when ending the processing of a luminosity block ------------ -/* -void -NtupleProducer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) -{ -} -*/ - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void NtupleProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/NtupleProducer/plugins/ResponseNTuplizer.cc b/NtupleProducer/plugins/ResponseNTuplizer.cc index 5a00ccd99e741..30c91c18248ec 100644 --- a/NtupleProducer/plugins/ResponseNTuplizer.cc +++ b/NtupleProducer/plugins/ResponseNTuplizer.cc @@ -298,6 +298,7 @@ ResponseNTuplizer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet recopair.first.get(iEvent); } for (auto & c : copyUInts_) c.get(iEvent); + mc_.id = 998; tree_->Fill(); // so that we write only one per event for (const reco::GenJet & j : *genjets) { bool ok = true; const reco::Candidate * match = nullptr; diff --git a/NtupleProducer/python/caloNtupleProducer_cfi.py b/NtupleProducer/python/caloNtupleProducer_cfi.py new file mode 100644 index 0000000000000..9087ef8ec1720 --- /dev/null +++ b/NtupleProducer/python/caloNtupleProducer_cfi.py @@ -0,0 +1,38 @@ +import FWCore.ParameterSet.Config as cms + +CaloInfoOut = cms.EDProducer('CaloNtupleProducer', + EcalTPTags = cms.VInputTag( cms.InputTag('l1tPFEcalProducerFromOfflineRechits','towers'), + cms.InputTag('l1tPFHGCalEEProducerFromOfflineRechits','towers') ), + HcalTPTags = cms.VInputTag( cms.InputTag('l1tPFHcalProducerFromOfflineRechits','towers'), + cms.InputTag('l1tPFHGCalFHProducerFromOfflineRechits','towers'), + cms.InputTag('l1tPFHGCalBHProducerFromOfflineRechits','towers'), + cms.InputTag('l1tPFHFProducerFromOfflineRechits','towers') ), + genParTag = cms.InputTag('genParticles'), + zeroSuppress = cms.bool(False), + corrector = cms.string("FastPUPPI/NtupleProducer/data/pion_eta_phi.root"), + ecorrector = cms.string("FastPUPPI/NtupleProducer/data/ecorr.root"), + caloClusterer = cms.PSet( + ecal = cms.PSet( + zsEt = cms.double(0.4), + seedEt = cms.double(0.5), + minClusterEt = cms.double(0.5), + energyWeightedPosition = cms.bool(True), + energyShareAlgo = cms.string("fractions"), + ), + hcal = cms.PSet( + zsEt = cms.double(0.4), + seedEt = cms.double(0.5), + minClusterEt = cms.double(0.8), + energyWeightedPosition = cms.bool(True), + energyShareAlgo = cms.string("fractions"), + ), + linker = cms.PSet( + hoeCut = cms.double(0.1), + minPhotonEt = cms.double(1.0), + minHadronEt = cms.double(1.0), + useCorrectedEcal = cms.bool(True), # use corrected ecal enery in linking + ), + ), + outputName = cms.untracked.string("calontuple.root"), + debug = cms.untracked.int32(0), +) diff --git a/NtupleProducer/python/l1tPFEcalProducerFromTPDigis_cfi.py b/NtupleProducer/python/l1tPFEcalProducerFromTPDigis_cfi.py new file mode 100644 index 0000000000000..82fe09eff2971 --- /dev/null +++ b/NtupleProducer/python/l1tPFEcalProducerFromTPDigis_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +l1tPFEcalProducerFromTPDigis = cms.EDProducer("EcalProducerFromTPDigi", + EcalTPTag = cms.InputTag("simEcalEBTriggerPrimitiveDigis"), + etMin = cms.double(0.0), +) diff --git a/NtupleProducer/python/l1tPFHGCalProducerFrom3DTPs_cfi.py b/NtupleProducer/python/l1tPFHGCalProducerFrom3DTPs_cfi.py new file mode 100644 index 0000000000000..9e45242461595 --- /dev/null +++ b/NtupleProducer/python/l1tPFHGCalProducerFrom3DTPs_cfi.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms + +l1tPFHGCalProducerFrom3DTPs = cms.EDProducer("HGCalProducerFrom3DTPs", + src = cms.InputTag("hgcalTriggerPrimitiveDigiProducer","cluster3D"), + etMin = cms.double(0.0), +) + + diff --git a/NtupleProducer/python/l1tPFHGCalProducerFromTriggerCells_cfi.py b/NtupleProducer/python/l1tPFHGCalProducerFromTriggerCells_cfi.py new file mode 100644 index 0000000000000..56e81870a5db9 --- /dev/null +++ b/NtupleProducer/python/l1tPFHGCalProducerFromTriggerCells_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +l1tPFHGCalProducerFromTriggerCells = cms.EDProducer("HGCalProducerFromTriggerCells", + src = cms.InputTag("hgcalTriggerPrimitiveDigiProducer","calibratedTriggerCells"), + etMin = cms.double(0.0), +) diff --git a/NtupleProducer/python/l1tPFHcalProducerFromTPDigis_cfi.py b/NtupleProducer/python/l1tPFHcalProducerFromTPDigis_cfi.py new file mode 100644 index 0000000000000..80c68c68efbf3 --- /dev/null +++ b/NtupleProducer/python/l1tPFHcalProducerFromTPDigis_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +l1tPFHcalProducerFromTPDigis = cms.EDProducer("HcalProducerFromTPDigi", + HcalTPTag = cms.InputTag("simHcalTriggerPrimitiveDigis"), + #subdets = cms.vuint32(1), # 1=HB +) diff --git a/NtupleProducer/python/l1tPFTkProducersFromL1Tracks_cfi.py b/NtupleProducer/python/l1tPFTkProducersFromL1Tracks_cfi.py new file mode 100644 index 0000000000000..429a8a3cef1cc --- /dev/null +++ b/NtupleProducer/python/l1tPFTkProducersFromL1Tracks_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +l1tPFTkProducersFromL1Tracks = cms.EDProducer("TkProducerFromL1Tracks", + L1TrackTag = cms.InputTag("TTTracksFromTracklet", "Level1TTTracks"), + MuonGunVeto = cms.bool(False), +) diff --git a/NtupleProducer/python/ntupleProducer_cfi.py b/NtupleProducer/python/ntupleProducer_cfi.py index 75cbeeb54e59e..764ff280e4335 100644 --- a/NtupleProducer/python/ntupleProducer_cfi.py +++ b/NtupleProducer/python/ntupleProducer_cfi.py @@ -2,15 +2,10 @@ InfoOut = cms.EDProducer('NtupleProducer', L1TrackTag = cms.InputTag('l1tPFTkProducersFromOfflineTracksStrips'), - EcalTPTag = cms.InputTag('l1tPFEcalProducerFromOfflineRechits','towers'), - HGEcalTPTag = cms.InputTag('l1tPFHGCalEEProducerFromOfflineRechits','towers'), - HcalTPTag = cms.InputTag('l1tPFHcalProducerFromOfflineRechits','towers'), - HGHcalTPTag = cms.InputTag('l1tPFHGCalFHProducerFromOfflineRechits','towers'), - BHHcalTPTag = cms.InputTag('l1tPFHGCalBHProducerFromOfflineRechits','towers'), - HFTPTag = cms.InputTag('l1tPFHFProducerFromOfflineRechits','towers'), + CaloClusterTags = cms.VInputTag( cms.InputTag('CaloInfoOut','calibrated') ), + correctCaloEnergies = cms.bool(False), MuonTPTag = cms.InputTag('l1tPFMuProducerFromL1Mu'), genParTag = cms.InputTag('genParticles'), - zeroSuppress = cms.bool(False), corrector = cms.string("FastPUPPI/NtupleProducer/data/pion_eta_phi.root"), ecorrector = cms.string("FastPUPPI/NtupleProducer/data/ecorr.root"), trackres = cms.string("FastPUPPI/NtupleProducer/data/tkres.root"), @@ -21,28 +16,6 @@ etaCharged = cms.double(2.5), puppiPtCut = cms.double(4.0), vtxRes = cms.double(0.333), - caloClusterer = cms.PSet( - ecal = cms.PSet( - zsEt = cms.double(0.4), - seedEt = cms.double(0.5), - minClusterEt = cms.double(0.5), - energyWeightedPosition = cms.bool(True), - energyShareAlgo = cms.string("fractions"), - ), - hcal = cms.PSet( - zsEt = cms.double(0.4), - seedEt = cms.double(0.5), - minClusterEt = cms.double(0.8), - energyWeightedPosition = cms.bool(True), - energyShareAlgo = cms.string("fractions"), - ), - linker = cms.PSet( - hoeCut = cms.double(0.1), - minPhotonEt = cms.double(1.0), - minHadronEt = cms.double(1.0), - useCorrectedEcal = cms.bool(True), # use corrected ecal enery in linking - ), - ), outputName = cms.untracked.string("ntuple.root"), debug = cms.untracked.int32(0), ) diff --git a/NtupleProducer/python/pfdiff.py b/NtupleProducer/python/pfdiff.py index a7daa2bb7f660..17473e06b5732 100644 --- a/NtupleProducer/python/pfdiff.py +++ b/NtupleProducer/python/pfdiff.py @@ -23,8 +23,14 @@ events = Events(args[0]) -pf1 = Handle("std::vector") -pf2 = Handle("std::vector") +if args[1].startswith("l1tPF"): + pf1 = Handle("std::vector") +else: + pf1 = Handle("std::vector") +if args[2].startswith("l1tPF"): + pf2 = Handle("std::vector") +else: + pf2 = Handle("std::vector") genj = Handle("std::vector") genp = Handle("std::vector") diff --git a/NtupleProducer/python/reprocess_L1Phase2_MC.py b/NtupleProducer/python/reprocess_L1Phase2_MC.py new file mode 100644 index 0000000000000..c6164f1c67d0c --- /dev/null +++ b/NtupleProducer/python/reprocess_L1Phase2_MC.py @@ -0,0 +1,217 @@ +######################### +# +# Configuration file for: +# 1. rerun L1 Stage2 emulation +# 2. produce TrackTriggerAssociator from available Stubs and Clusters +# +# +# +# Author: Vladimir.Rekovic@cern.ch +# Date : 10/03/2017 +# +# Script tested with release CMSSW_9_0_0_pre6 +# +######################### + +# Started from Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step2 --python_filename=rerun_step2_L1_L1TrackTrigger_onMCL1_FEVTHLTDEBUG.py --no_exec -s L1,L1TrackTrigger --datatier GEN-SIM-DIGI-RAW -n 1 --era Phase2C2 --eventcontent FEVTDEBUGHLT --pileup AVE_200_BX_25ns --filein file:/afs/cern.ch/user/r/rekovic/release/CMSSW_9_0_0_pre2_patch_Phase2-L1T-MC-test-v2/src/step2_ZEE_PU200_1ev-PR_EventContent-FEVTDEBUGHLT.root --conditions 90X_upgrade2023_realistic_v1 --era Phase2C2_timing --beamspot HLLHC14TeV --geometry Extended2023D4 --fileout file:step2_ZEE_PU200_1ev_rerun-L1-L1TrackTrigger.root +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('RERUNL1',eras.Phase2C2_timing) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mix_POISSON_average_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D4Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +process.load('SimCalorimetry.HcalTrigPrimProducers.hcalTTPDigis_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(20) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/004C6E8B-5F26-E711-AE46-0242AC130002.root' + ,'root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/00676CC3-5926-E711-9B46-0242AC130004.root' + ,'root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/009A927B-5726-E711-AC20-0242AC130002.root' + ,'root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/00AF6CB4-5226-E711-BC7C-0242AC130004.root' + ,'root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/00BFEB6C-6526-E711-ABE5-0242AC130005.root' + ,'root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/00F02746-6A26-E711-9B33-0242AC130004.root' + ,'root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/020F1518-6C26-E711-A67C-0242AC130004.root' + ,'root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/022EE4F8-6026-E711-89A2-0242AC130002.root' + ,'root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/023B88FC-6026-E711-BB4C-0242AC130002.root' + ,'root://cms-xrd-global.cern.ch///store/mc/PhaseIISpring17D/SingleNeutrino/GEN-SIM-DIGI-RAW/PU200_90X_upgrade2023_realistic_v9-v1/70000/026BAE30-6826-E711-9BCE-0242AC130002.root'), + secondaryFileNames = cms.untracked.vstring() +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step2 nevts:1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(10485760), + fileName = cms.untracked.string('file:reprocess_L1T_L1TTTTracklet_HGCalTP3D_step2_TT_PhaseIISpring17D-PU200_pilot.root'), + #fileName = cms.untracked.string('file:step2_ZEE_PU200_test.root'), + #fileName = cms.untracked.string('file:step2_ZEE_PU200_10ev_FEVTDEBUGHLT_customHigherPtTrackParticles-RERUN_L1T_TTAssociator_EcalEBtp_HGCtp.root'), + #fileName = cms.untracked.string('root://eoscms//eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/rekovic/PhaseIIFall16DR82-820_backport_L1TMC_v1.2.2/step2_ZEE_PU200_100ev_FEVTDEBUGHLT_customHigherPtTrackParticles-RERUN_L1T_TTAssociator_EcalEBtp_HGCtp.root'), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +process.FEVTDEBUGHLToutput.outputCommands.append('keep *_*_*_*') + +# Additional output definition + +#process.Timing = cms.Service("Timing") + + +# Other statements +process.mix.input.nbPileupEvents.averageNumber = cms.double(200.000000) +process.mix.bunchspace = cms.int32(25) +process.mix.minBunch = cms.int32(-12) +process.mix.maxBunch = cms.int32(3) +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '90X_upgrade2023_realistic_v9', '') + + +process.HcalHardcodeGeometryEP = cms.ESProducer("HcalHardcodeGeometryEP", + UseOldLoader = cms.bool(False) +) + + +process.HcalTPGCoderULUT = cms.ESProducer("HcalTPGCoderULUT", + FGLUTs = cms.FileInPath('CalibCalorimetry/HcalTPGAlgos/data/HBHE_FG_LUT.dat'), + LUTGenerationMode = cms.bool(True), + MaskBit = cms.int32(32768), + RCalibFile = cms.FileInPath('CalibCalorimetry/HcalTPGAlgos/data/RecHit-TPG-calib.dat'), + inputLUTs = cms.FileInPath('CalibCalorimetry/HcalTPGAlgos/data/inputLUTcoder_physics.dat'), + read_Ascii_LUTs = cms.bool(False), + read_FG_LUTs = cms.bool(False), + read_XML_LUTs = cms.bool(False) +) + + +process.HcalTrigTowerGeometryESProducer = cms.ESProducer("HcalTrigTowerGeometryESProducer") + +process.CaloGeometryBuilder = cms.ESProducer("CaloGeometryBuilder", + SelectedCalos = cms.vstring('HCAL', + 'ZDC', + 'EcalBarrel', + 'TOWER', + 'HGCalEESensitive', + 'HGCalHESiliconSensitive') +) + + +process.CaloTPGTranscoder = cms.ESProducer("CaloTPGTranscoderULUTs", + HFTPScaleShift = cms.PSet( + NCT = cms.int32(1), + RCT = cms.int32(3) + ), + LUTfactor = cms.vint32(1, 2, 5, 0), + RCTLSB = cms.double(0.25), + ZS = cms.vint32(4, 2, 1, 0), + hcalLUT1 = cms.FileInPath('CalibCalorimetry/CaloTPG/data/outputLUTtranscoder_physics.dat'), + hcalLUT2 = cms.FileInPath('CalibCalorimetry/CaloTPG/data/TPGcalcDecompress2.txt'), + ietaLowerBound = cms.vint32(1, 18, 27, 29), + ietaUpperBound = cms.vint32(17, 26, 28, 32), + nominal_gain = cms.double(0.177), + read_Ascii_Compression_LUTs = cms.bool(False), + read_Ascii_RCT_LUTs = cms.bool(False) +) + + +process.CaloTopologyBuilder = cms.ESProducer("CaloTopologyBuilder") + + +process.CaloTowerHardcodeGeometryEP = cms.ESProducer("CaloTowerHardcodeGeometryEP") + + +process.CaloTowerTopologyEP = cms.ESProducer("CaloTowerTopologyEP") + +#from SimTracker.TrackTriggerAssociation.TTTrackAssociation_cfi import * +#TrackTriggerAssociatorTracks = cms.Sequence(TTTrackAssociatorFromPixelDigis) + +process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') +# Remove best choice selection +process.hgcalTriggerPrimitiveDigiProducer.FECodec.NData = cms.uint32(999) +process.hgcalTriggerPrimitiveDigiProducer.FECodec.DataLength = cms.uint32(8) +process.hgcalTriggerPrimitiveDigiProducer.FECodec.triggerCellTruncationBits = cms.uint32(7) + +process.hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms[0].calib_parameters.cellLSB = cms.double( + process.hgcalTriggerPrimitiveDigiProducer.FECodec.linLSB.value() * + 2 ** process.hgcalTriggerPrimitiveDigiProducer.FECodec.triggerCellTruncationBits.value() +) + +cluster_algo_all = cms.PSet( AlgorithmName = cms.string('HGCClusterAlgoBestChoice'), + FECodec = process.hgcalTriggerPrimitiveDigiProducer.FECodec, + HGCalEESensitive_tag = cms.string('HGCalEESensitive'), + HGCalHESiliconSensitive_tag = cms.string('HGCalHESiliconSensitive'), + calib_parameters = process.hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms[0].calib_parameters, + C2d_parameters = process.hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms[0].C2d_parameters, + C3d_parameters = process.hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms[0].C3d_parameters + ) + + +process.hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms = cms.VPSet( cluster_algo_all ) + +process.hgcl1tpg_step = cms.Path(process.hgcalTriggerPrimitives) + + +# load ntuplizer +#process.load('L1Trigger.L1THGCal.hgcalTriggerNtuples_cff') +#process.ntuple_step = cms.Path(process.hgcalTriggerNtuples) + +process.load('SimCalorimetry.EcalEBTrigPrimProducers.ecalEBTriggerPrimitiveDigis_cff') +process.EcalEBtp_step = cms.Path(process.simEcalEBTriggerPrimitiveDigis) + +# Path and EndPath definitions +process.HcalTPsimulation_step = cms.Path(process.hcalTTPSequence) +process.L1simulation_step = cms.Path(process.SimL1Emulator) + +process.load('L1Trigger.TrackFindingTracklet.L1TrackletTracks_cff') +#process.load('SimTracker.TrackTriggerAssociation.TrackTriggerAssociator_cff') +#process.L1TrackTrigger_step = cms.Path(process.TrackTriggerAssociatorClustersStubs) +#process.L1TrackTrigger_step = cms.Path(process.TrackTriggerAssociatorClustersStubs*process.TrackTriggerAssociatorTracks) +#process.L1TrackTrigger_step = cms.Path(process.TrackTriggerAssociatorComplete) +#process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) +process.TTClusterAssociatorFromPixelDigis.digiSimLinks = cms.InputTag( "simSiPixelDigis","Tracker" ) +process.L1TrackTrigger_step = cms.Path(process.L1TrackletTracksWithAssociators) + +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# Schedule definition +#process.schedule = cms.Schedule(process.HcalTPsimulation_step,process.L1simulation_step,process.L1TrackTrigger_step,process.EcalEBtp_step,process.hgcl1tpg_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) +process.schedule = cms.Schedule(process.L1simulation_step,process.L1TrackTrigger_step,process.hgcl1tpg_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/NtupleProducer/python/reprocess_L1Phase2_MC_cff.py b/NtupleProducer/python/reprocess_L1Phase2_MC_cff.py new file mode 100644 index 0000000000000..3e39d26a8f7ed --- /dev/null +++ b/NtupleProducer/python/reprocess_L1Phase2_MC_cff.py @@ -0,0 +1,99 @@ +import FWCore.ParameterSet.Config as cms + +HcalHardcodeGeometryEP = cms.ESProducer("HcalHardcodeGeometryEP", + UseOldLoader = cms.bool(False) +) + + +HcalTPGCoderULUT = cms.ESProducer("HcalTPGCoderULUT", + FGLUTs = cms.FileInPath('CalibCalorimetry/HcalTPGAlgos/data/HBHE_FG_LUT.dat'), + LUTGenerationMode = cms.bool(True), + MaskBit = cms.int32(32768), + RCalibFile = cms.FileInPath('CalibCalorimetry/HcalTPGAlgos/data/RecHit-TPG-calib.dat'), + inputLUTs = cms.FileInPath('CalibCalorimetry/HcalTPGAlgos/data/inputLUTcoder_physics.dat'), + read_Ascii_LUTs = cms.bool(False), + read_FG_LUTs = cms.bool(False), + read_XML_LUTs = cms.bool(False) +) + + +HcalTrigTowerGeometryESProducer = cms.ESProducer("HcalTrigTowerGeometryESProducer") + +CaloGeometryBuilder = cms.ESProducer("CaloGeometryBuilder", + SelectedCalos = cms.vstring('HCAL', + 'ZDC', + 'EcalBarrel', + 'TOWER', + 'HGCalEESensitive', + 'HGCalHESiliconSensitive') +) + + +CaloTPGTranscoder = cms.ESProducer("CaloTPGTranscoderULUTs", + HFTPScaleShift = cms.PSet( + NCT = cms.int32(1), + RCT = cms.int32(3) + ), + LUTfactor = cms.vint32(1, 2, 5, 0), + RCTLSB = cms.double(0.25), + ZS = cms.vint32(4, 2, 1, 0), + hcalLUT1 = cms.FileInPath('CalibCalorimetry/CaloTPG/data/outputLUTtranscoder_physics.dat'), + hcalLUT2 = cms.FileInPath('CalibCalorimetry/CaloTPG/data/TPGcalcDecompress2.txt'), + ietaLowerBound = cms.vint32(1, 18, 27, 29), + ietaUpperBound = cms.vint32(17, 26, 28, 32), + nominal_gain = cms.double(0.177), + read_Ascii_Compression_LUTs = cms.bool(False), + read_Ascii_RCT_LUTs = cms.bool(False) +) + + +CaloTopologyBuilder = cms.ESProducer("CaloTopologyBuilder") + + +CaloTowerHardcodeGeometryEP = cms.ESProducer("CaloTowerHardcodeGeometryEP") + + +CaloTowerTopologyEP = cms.ESProducer("CaloTowerTopologyEP") + +from L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff import * +# Remove best choice selection +hgcalTriggerPrimitiveDigiProducer.FECodec.NData = cms.uint32(999) +hgcalTriggerPrimitiveDigiProducer.FECodec.DataLength = cms.uint32(8) +hgcalTriggerPrimitiveDigiProducer.FECodec.triggerCellTruncationBits = cms.uint32(7) + +hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms[0].calib_parameters.cellLSB = cms.double( + hgcalTriggerPrimitiveDigiProducer.FECodec.linLSB.value() * + 2 ** hgcalTriggerPrimitiveDigiProducer.FECodec.triggerCellTruncationBits.value() +) + +cluster_algo_all = cms.PSet( AlgorithmName = cms.string('HGCClusterAlgoBestChoice'), + FECodec = hgcalTriggerPrimitiveDigiProducer.FECodec, + HGCalEESensitive_tag = cms.string('HGCalEESensitive'), + HGCalHESiliconSensitive_tag = cms.string('HGCalHESiliconSensitive'), + calib_parameters = hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms[0].calib_parameters, + C2d_parameters = hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms[0].C2d_parameters, + C3d_parameters = hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms[0].C3d_parameters + ) + + +hgcalTriggerPrimitiveDigiProducer.BEConfiguration.algorithms = cms.VPSet( cluster_algo_all ) + +hgcl1tpg_step = cms.Sequence(hgcalTriggerPrimitives) + + +from SimCalorimetry.EcalEBTrigPrimProducers.ecalEBTriggerPrimitiveDigis_cff import * +EcalEBtp_step = cms.Sequence(simEcalEBTriggerPrimitiveDigis) + +from SimCalorimetry.HcalTrigPrimProducers.hcalTTPDigis_cff import * +HcalTPsimulation_step = cms.Sequence(hcalTTPSequence) + +from Configuration.StandardSequences.SimL1Emulator_cff import * +L1simulation_step = cms.Sequence(SimL1Emulator) + +from L1Trigger.TrackFindingTracklet.L1TrackletTracks_cff import * +#TTClusterAssociatorFromPixelDigis.digiSimLinks = cms.InputTag( "simSiPixelDigis","Tracker" ) +L1TrackTrigger_step = cms.Sequence(L1TrackletTracks) + +reprocess_L1Phase2_MC = cms.Sequence( + hgcl1tpg_step + EcalEBtp_step + L1TrackTrigger_step + HcalTPsimulation_step +) diff --git a/NtupleProducer/python/runInputs.py b/NtupleProducer/python/runInputs.py new file mode 100644 index 0000000000000..2b14edf57f190 --- /dev/null +++ b/NtupleProducer/python/runInputs.py @@ -0,0 +1,76 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process("IN", eras.Phase2C2_timing) +process.load('Configuration.StandardSequences.Services_cff') +process.load('Configuration.Geometry.GeometryExtended2023D4Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +#process.load('Configuration.StandardSequences.SimL1Emulator_cff') +#process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +#process.load('SimCalorimetry.HcalTrigPrimProducers.hcalTTPDigis_cff') +process.load('FastPUPPI.NtupleProducer.reprocess_L1Phase2_MC_cff') + +import EventFilter.EcalRawToDigi.EcalUnpackerData_cfi +process.ecalDigis = EventFilter.EcalRawToDigi.EcalUnpackerData_cfi.ecalEBunpacker.clone() +import EventFilter.ESRawToDigi.esRawToDigi_cfi +process.ecalPreshowerDigis = EventFilter.ESRawToDigi.esRawToDigi_cfi.esRawToDigi.clone() +import EventFilter.HcalRawToDigi.HcalRawToDigi_cfi +process.hcalDigis = EventFilter.HcalRawToDigi.HcalRawToDigi_cfi.hcalDigis.clone() +process.load('RecoLuminosity.LumiProducer.bunchSpacingProducer_cfi') +process.load('RecoLocalCalo.Configuration.RecoLocalCalo_cff') + +process.load('FastPUPPI.NtupleProducer.l1tPFCaloProducersFromOfflineRechits_cff') + +process.load('FastPUPPI.NtupleProducer.l1tPFEcalProducerFromTPDigis_cfi') +process.load('FastPUPPI.NtupleProducer.l1tPFHcalProducerFromTPDigis_cfi') +process.load('FastPUPPI.NtupleProducer.l1tPFHGCalProducerFrom3DTPs_cfi') +process.load('FastPUPPI.NtupleProducer.l1tPFHGCalProducerFromTriggerCells_cfi') +process.load('FastPUPPI.NtupleProducer.l1tPFTkProducersFromL1Tracks_cfi') +process.load('FastPUPPI.NtupleProducer.l1tPFMuProducerFromL1Mu_cfi') +process.l1tPFMuProducerFromL1Mu.MuonTag = "simGmtStage2Digis" + +#process.load('FastPUPPI.NtupleProducer._cfi') + +process.source = cms.Source("PoolSource", + #fileNames = cms.untracked.vstring('/store/mc/PhaseIISpring17D/SinglePhoton_FlatPt-8to150/GEN-SIM-DIGI-RAW/NoPU_90X_upgrade2023_realistic_v9-v1/70000/008FC219-132A-E711-893F-A0000420FE80.root') + fileNames = cms.untracked.vstring('file:SinglePion_17D.root',) +) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(40)) + +process.s = cms.Sequence( + process.reprocess_L1Phase2_MC + + process.ecalDigis + process.ecalPreshowerDigis + process.hcalDigis + process.bunchSpacingProducer + process.ecalLocalRecoSequence + process.hcalLocalRecoSequence + process.hcalGlobalRecoSequence + process.hgcalLocalRecoSequence + + process.l1tPFEcalProducerFromOfflineRechits + process.l1tPFHcalProducerFromOfflineRechits + process.l1tPFHFProducerFromOfflineRechits + process.l1tPFHGCalEEProducerFromOfflineRechits + process.l1tPFHGCalFHProducerFromOfflineRechits + process.l1tPFHGCalBHProducerFromOfflineRechits + + process.l1tPFEcalProducerFromTPDigis + + process.l1tPFHcalProducerFromTPDigis + + process.l1tPFHGCalProducerFrom3DTPs + + process.l1tPFHGCalProducerFromTriggerCells + + process.l1tPFTkProducersFromL1Tracks + + process.l1tPFMuProducerFromL1Mu +) + +process.p = cms.Path(process.s) + +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string("inputs_17D.root"), + outputCommands = cms.untracked.vstring("drop *", + "keep *_genParticles_*_*", + "keep *_ak4GenJetsNoNu_*_*", + "keep *_genMetTrue_*_*", + "keep *_l1tPF*_*_IN", + ), + compressionAlgorithm = cms.untracked.string('LZMA'), + compressionLevel = cms.untracked.int32(4), + dropMetaData = cms.untracked.string('ALL'), + fastCloning = cms.untracked.bool(False), + overrideInputFileSplitLevels = cms.untracked.bool(True), + eventAutoFlushCompressedSize = cms.untracked.int32(15728640), +) +process.e = cms.EndPath(process.out) + + diff --git a/NtupleProducer/python/runRespNTupler.py b/NtupleProducer/python/runRespNTupler.py index ab5d71eb9d75d..02ee917ff1e0a 100644 --- a/NtupleProducer/python/runRespNTupler.py +++ b/NtupleProducer/python/runRespNTupler.py @@ -18,11 +18,15 @@ genParticles = cms.InputTag("genParticles"), isParticleGun = cms.bool(False), objects = cms.PSet( - # -- inputs -- + # -- offline inputs -- Ecal = cms.VInputTag('l1tPFEcalProducerFromOfflineRechits:towers','l1tPFHGCalEEProducerFromOfflineRechits:towers', 'l1tPFHFProducerFromOfflineRechits:towers'), Hcal = cms.VInputTag('l1tPFHcalProducerFromOfflineRechits:towers','l1tPFHGCalFHProducerFromOfflineRechits:towers', 'l1tPFHGCalBHProducerFromOfflineRechits:towers', 'l1tPFHFProducerFromOfflineRechits:towers'), Calo = cms.VInputTag('l1tPFEcalProducerFromOfflineRechits:towers','l1tPFHGCalEEProducerFromOfflineRechits:towers', 'l1tPFHcalProducerFromOfflineRechits:towers', 'l1tPFHGCalFHProducerFromOfflineRechits:towers', 'l1tPFHGCalBHProducerFromOfflineRechits:towers', 'l1tPFHFProducerFromOfflineRechits:towers'), TK = cms.VInputTag('l1tPFTkProducersFromOfflineTracksStrips'), + # -- TP inputs -- + #TPEcal = cms.VInputTag('l1tPFEcalProducerFromTPDigis:towers','l1tPFHGCalProducerFromTriggerCells:towersEE',), + #TPHcal = cms.VInputTag('l1tPFHcalProducerFromTPDigis','l1tPFHGCalProducerFromTriggerCells:towersFHBH',), + #TPTK = cms.VInputTag('l1tPFTkProducersFromL1Tracks',), # -- processed -- L1RawCalo = cms.VInputTag("InfoOut:RawCalo",), L1Calo = cms.VInputTag("InfoOut:Calo",), @@ -48,12 +52,28 @@ ) process.p = cms.Path(process.ntuple) process.TFileService = cms.Service("TFileService", fileName = cms.string("respTupleNew.root")) + + if True: + process.load('FastPUPPI.NtupleProducer.caloNtupleProducer_cfi') process.load('FastPUPPI.NtupleProducer.ntupleProducer_cfi') process.load('FastPUPPI.NtupleProducer.l1tPFMuProducerFromL1Mu_cfi') + process.CaloInfoOut.outputName = ""; # turn off Ntuples process.InfoOut.outputName = ""; # turn off Ntuples - process.p = cms.Path(process.l1tPFMuProducerFromL1Mu + process.InfoOut + process.ntuple) -if False: + process.p = cms.Path(process.CaloInfoOut + process.InfoOut + process.ntuple) +def goGun(): + process.ntuple.isParticleGun = True +def goSpring17(): + del process.ntuple.objects.TK + process.ntuple.objects.TPEcal = cms.VInputTag('l1tPFEcalProducerFromTPDigis:towers', 'l1tPFHGCalProducerFromTriggerCells:towersEE',) + process.ntuple.objects.TPHcal = cms.VInputTag('l1tPFHcalProducerFromTPDigis', 'l1tPFHGCalProducerFromTriggerCells:towersFHBH',) + process.ntuple.objects.TPTK = cms.VInputTag('l1tPFTkProducersFromL1Tracks',) + if hasattr(process, 'InfoOut'): + process.InfoOut.L1TrackTag = 'l1tPFTkProducersFromL1Tracks' + process.CaloInfoOut.EcalTPTags = [ 'l1tPFEcalProducerFromTPDigis:towers', 'l1tPFHGCalProducerFromTriggerCells:towersEE' ] + process.CaloInfoOut.HcalTPTags = [ 'l1tPFHcalProducerFromTPDigis', 'l1tPFHGCalProducerFromTriggerCells:towersFHBH', ] + process.CaloInfoOut.caloClusterer.linker.useCorrectedEcal = False +def goRegional(inParallel=False): regions = cms.VPSet( cms.PSet( etaBoundaries = cms.vdouble(-5.5,-4,-3), @@ -74,11 +94,11 @@ phiExtra = cms.double(0.2), ), ) - if True: - process.InfoOut.regions = regions - else: + if inParallel: process.InfoOutReg = process.InfoOut.clone(regions = regions) - process.p = cms.Path(process.l1tPFMuProducerFromL1Mu + process.InfoOut + process.InfoOutReg + process.ntuple) + process.p = cms.Path(process.InfoOut + process.InfoOutReg + process.ntuple) + else: + process.InfoOut.regions = regions if False: process.out = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string("l1pf_remade.root"), diff --git a/NtupleProducer/python/scripts/objMultiplicityPlot.py b/NtupleProducer/python/scripts/objMultiplicityPlot.py new file mode 100644 index 0000000000000..87311cbc338fd --- /dev/null +++ b/NtupleProducer/python/scripts/objMultiplicityPlot.py @@ -0,0 +1,145 @@ +import os +from sys import argv +import ROOT +ROOT.PyConfig.IgnoreCommandLineOptions = True +ROOT.gROOT.SetBatch(True) +ROOT.gROOT.ProcessLine(".x %s/cpp/tdrstyle.cc" % os.environ['HOME']); +ROOT.gStyle.SetOptStat(False) +ROOT.gStyle.SetErrorX(0.5) +ROOT.gErrorIgnoreLevel = ROOT.kWarning + +from math import * + +def doRespEta(oname, tree, name, expr, cut): + return doRespEtaMedian(oname, tree, name, expr, cut) + +def quantiles(ys): + ys.sort() + ny = len(ys) + median = ys[ny/2] + u68 = ys[min(int(ceil(ny*0.84)),ny-1) ] + l68 = ys[int(floor(ny*0.16))] + return (median,l68,u68) + +def doRespEtaMedian(oname, tree, name, expr, cut, etabins=10, etamax=5.0): + ys = [[] for ieta in xrange(etabins)] + npoints = tree.Draw("("+expr+")/mc_pt:abs(mc_eta)", cut, ""); + if npoints <= 0: return None + graph = ROOT.gROOT.FindObject("Graph"); + xi, yi = graph.GetX(), graph.GetY() + for i in xrange(graph.GetN()): + if (xi[i] > etamax): continue + ieta = int(floor(etabins*xi[i]/etamax)) + ys[ieta].append(yi[i]) + ret = ROOT.TGraphAsymmErrors() + ret.SetName(name) + for ieta in xrange(etabins): + if len(ys[ieta]) == 0: continue + (median,lo,hi) = quantiles(ys[ieta]) + ipoint = ret.GetN() + ret.Set(ipoint+1) + ret.SetPoint(ipoint, (ieta+0.5)*etamax/etabins, median) + #ret.SetPointError(ieta, 0.5*etamax/etabins, 0.5*etamax/etabins, (median-lo),(hi-median)) + ret.SetPointError(ipoint, 0.5*etamax/etabins, 0.5*etamax/etabins, (median-lo)/sqrt(len(ys[ieta])),(hi-median)/sqrt(len(ys[ieta]))) + return ret +def doRespEtaProf(oname, tree, name, expr, cut): + tree.Draw("("+expr+")/mc_pt:abs(mc_eta)>>"+name+"(20,0,5.0)", cut, "PROF"); + return ROOT.gROOT.FindObject(name); +def doRespPt(oname, tree, name, expr, cut, resol=False): + if "jet" in oname: + ptbins = [20,25,30,35,40,45,50,55,60,70,80,90,100,120,140,160,200,250] + else: + ptbins = [2.5,5,7.5,10,15,20,25,30,35,40,45,50,55,60,70,80,90,100] + ys = [[] for ipt in ptbins] + npoints = tree.Draw("("+expr+")/mc_pt:mc_pt", cut, ""); + if npoints <= 0: return None + graph = ROOT.gROOT.FindObject("Graph"); + xi, yi = graph.GetX(), graph.GetY() + for i in xrange(graph.GetN()): + for ipt,ptmax in enumerate(ptbins): + if xi[i] < ptmax: + ys[ipt].append(yi[i]) + break + ret = ROOT.TGraphAsymmErrors() + ret.SetName(name) + for ipt,ptmax in enumerate(ptbins): + if len(ys[ipt]) == 0: continue + ptmin = ptbins[ipt-1] if ipt else 0 + ptc = 0.5*(ptmin+ptmax) + ptd = 0.5*(ptmax-ptmin) + (median,lo,hi) = quantiles(ys[ipt]) + ipoint = ret.GetN() + if not resol: + ret.Set(ipoint+1) + ret.SetPoint(ipoint, ptc, median) + ret.SetPointError(ipoint, ptd, ptd, (median-lo)/sqrt(len(ys[ipt])),(hi-median)/sqrt(len(ys[ipt]))) + else: + if median <= 0.2: continue + #print "for %s %s pt %g, median = %g high = %g lo = %g " % (oname, name, ptc, median, hi, lo) + ret.Set(ipoint+1) + ret.SetPoint(ipoint, ptc, (hi-lo)/2/median) + ret.SetPointError(ipoint, ptd, ptd, 0, 0) + if ret.GetN() <= 3: return None + print oname, name, ret.GetN() + if not resol: + tf1 = ROOT.TF1(name+"_f1","1/x++1", ret.GetX()[0]-ret.GetErrorXlow(0), ret.GetX()[ret.GetN()-1]+ret.GetErrorXhigh(ret.GetN()-1) ) + ret.Fit(tf1, "WQ0C EX0 ROB=0.95") + ret.fit = tf1 + else: + tf1 = ROOT.TF1(name+"_f1","1/x++1", ret.GetX()[0]-ret.GetErrorXlow(0), ret.GetX()[ret.GetN()-1]+ret.GetErrorXhigh(ret.GetN()-1) ) + ret.Fit(tf1, "WQ0C EX0 ROB=0.95") + ret.fit = tf1 + return ret + + +whats = [ + ('inputs',[ + ("Had", "Hcal$", ROOT.kAzure+1, 25, 2.0), + ("Em", "Ecal$", ROOT.kGreen+2, 21, 1.5), + ("Calo", "Calo$", ROOT.kViolet+2, 34, 1.5), + ("Trk", "TK$", ROOT.kRed+1, 20, 1.2), + ]), + #('inputs-simpleCorr',[ + # ("Had", "Hcal$", ROOT.kAzure+1, 25, 2.0), + # ("Em-C", "Ecal$/(1+0.20*(abs(mc_eta)<3)-0.15*(abs(mc_eta)<1.5))", ROOT.kGreen+2, 21, 1.5), + # ("Calo-C", "Hcal$ + (abs(mc_eta)<3)*Ecal$/(1+0.20*(abs(mc_eta)<3)-0.15*(abs(mc_eta)<1.5))", ROOT.kViolet+2, 34, 1.5), + # ("Trk", "TK$", ROOT.kRed+1, 20, 1.2), + #]), + ('l1pf',[ + ("Raw Calo", "L1RawCalo$", ROOT.kViolet-4, 21, 1.7), + ("Calo", "L1Calo$", ROOT.kViolet+2, 34, 1.5), + ("TK", "L1TK$", ROOT.kRed+1, 20, 1.2), + ("PF", "L1PF$", ROOT.kOrange+7, 34, 1.2), + ("Puppi", "L1Puppi$", ROOT.kGray+2, 25, 1.4), + ]), + ('il1pf',[ + ("iCalo", "L1ICalo$", ROOT.kViolet+2, 34, 1.5), + ("iTK", "L1ITK$", ROOT.kRed+1, 20, 1.2), + ("iPF", "L1IPF$", ROOT.kOrange+7, 34, 1.2), + ("iPuppi", "L1IPuppi$", ROOT.kGray+2, 25, 1.4), + ]), +] + +from optparse import OptionParser +parser = OptionParser("%(prog) infile [ src [ dst ] ]") +options, args = parser.parse_args() + +odir = args[1] # "plots/910pre2/test" +os.system("mkdir -p "+odir) +os.system("cp %s/php/index.php %s/" % (os.environ['HOME'], odir)); +ROOT.gROOT.ProcessLine(".x %s/cpp/tdrstyle.cc" % os.environ['HOME']); +c1 = ROOT.TCanvas("c1","c1") +particles = { + "Calo":(10000,200), "Mu":(100,100), "TK":(1000,1000), "PF":(1000,1000), "Puppi":(1000,1000) +}.items() +tfile = ROOT.TFile.Open(args[0]) +tree = tfile.Get("ntuple/tree") +ROOT.gStyle.SetOptStat("omr") +for particle, (nmax, nmaxtot) in particles: + for x,bins in ("tot",nmaxtot),("max",nmax): + print "%sNL1%s" % (x, particle) + n = tree.Draw("%sNL1%s" % (x, particle), "mc_id == 998", "") + if not n: continue + out = odir+'/'+particle+"_"+x+".png" + c1.Print(out) + diff --git a/NtupleProducer/python/scripts/respPlots.py b/NtupleProducer/python/scripts/respPlots.py new file mode 100644 index 0000000000000..52cd8dc6a321e --- /dev/null +++ b/NtupleProducer/python/scripts/respPlots.py @@ -0,0 +1,264 @@ +import os +from sys import argv +import ROOT +ROOT.PyConfig.IgnoreCommandLineOptions = True +ROOT.gROOT.SetBatch(True) +ROOT.gROOT.ProcessLine(".x %s/cpp/tdrstyle.cc" % os.environ['HOME']); +ROOT.gStyle.SetOptStat(False) +ROOT.gStyle.SetErrorX(0.5) +ROOT.gErrorIgnoreLevel = ROOT.kWarning + +from math import * + +def doRespEta(oname, tree, name, expr, cut): + return doRespEtaMedian(oname, tree, name, expr, cut) + +def quantiles(ys): + ys.sort() + ny = len(ys) + median = ys[ny/2] + u68 = ys[min(int(ceil(ny*0.84)),ny-1) ] + l68 = ys[int(floor(ny*0.16))] + return (median,l68,u68) + +def doRespEtaMedian(oname, tree, name, expr, cut, etabins=10, etamax=5.0): + ys = [[] for ieta in xrange(etabins)] + npoints = tree.Draw("("+expr+")/mc_pt:abs(mc_eta)", cut, ""); + if npoints <= 0: return None + graph = ROOT.gROOT.FindObject("Graph"); + xi, yi = graph.GetX(), graph.GetY() + for i in xrange(graph.GetN()): + if (xi[i] > etamax): continue + ieta = int(floor(etabins*xi[i]/etamax)) + ys[ieta].append(yi[i]) + ret = ROOT.TGraphAsymmErrors() + ret.SetName(name) + for ieta in xrange(etabins): + if len(ys[ieta]) == 0: continue + (median,lo,hi) = quantiles(ys[ieta]) + ipoint = ret.GetN() + ret.Set(ipoint+1) + ret.SetPoint(ipoint, (ieta+0.5)*etamax/etabins, median) + #ret.SetPointError(ieta, 0.5*etamax/etabins, 0.5*etamax/etabins, (median-lo),(hi-median)) + ret.SetPointError(ipoint, 0.5*etamax/etabins, 0.5*etamax/etabins, (median-lo)/sqrt(len(ys[ieta])),(hi-median)/sqrt(len(ys[ieta]))) + return ret +def doRespEtaProf(oname, tree, name, expr, cut): + tree.Draw("("+expr+")/mc_pt:abs(mc_eta)>>"+name+"(20,0,5.0)", cut, "PROF"); + return ROOT.gROOT.FindObject(name); +def doRespPt(oname, tree, name, expr, cut, resol=False): + if "jet" in oname: + ptbins = [20,25,30,35,40,45,50,55,60,70,80,90,100,120,140,160,200,250] + else: + ptbins = [2.5,5,7.5,10,15,20,25,30,35,40,45,50,55,60,70,80,90,100] + ys = [[] for ipt in ptbins] + npoints = tree.Draw("("+expr+")/mc_pt:mc_pt", cut, ""); + if npoints <= 0: return None + graph = ROOT.gROOT.FindObject("Graph"); + xi, yi = graph.GetX(), graph.GetY() + for i in xrange(graph.GetN()): + for ipt,ptmax in enumerate(ptbins): + if xi[i] < ptmax: + ys[ipt].append(yi[i]) + break + ret = ROOT.TGraphAsymmErrors() + ret.SetName(name) + for ipt,ptmax in enumerate(ptbins): + if len(ys[ipt]) == 0: continue + ptmin = ptbins[ipt-1] if ipt else 0 + ptc = 0.5*(ptmin+ptmax) + ptd = 0.5*(ptmax-ptmin) + (median,lo,hi) = quantiles(ys[ipt]) + ipoint = ret.GetN() + if not resol: + ret.Set(ipoint+1) + ret.SetPoint(ipoint, ptc, median) + ret.SetPointError(ipoint, ptd, ptd, (median-lo)/sqrt(len(ys[ipt])),(hi-median)/sqrt(len(ys[ipt]))) + else: + if median <= 0.2: continue + #print "for %s %s pt %g, median = %g high = %g lo = %g " % (oname, name, ptc, median, hi, lo) + ret.Set(ipoint+1) + ret.SetPoint(ipoint, ptc, (hi-lo)/2/median) + ret.SetPointError(ipoint, ptd, ptd, 0, 0) + if ret.GetN() <= 3: return None + print oname, name, ret.GetN() + if not resol: + tf1 = ROOT.TF1(name+"_f1","1/x++1", ret.GetX()[0]-ret.GetErrorXlow(0), ret.GetX()[ret.GetN()-1]+ret.GetErrorXhigh(ret.GetN()-1) ) + ret.Fit(tf1, "WQ0C EX0 ROB=0.95") + ret.fit = tf1 + else: + if "Trk" in name: + tf1 = ROOT.TF1(name+"_f1","1/x++x", ret.GetX()[0]-ret.GetErrorXlow(0), ret.GetX()[ret.GetN()-1]+ret.GetErrorXhigh(ret.GetN()-1) ) + else: + tf1 = ROOT.TF1(name+"_f1","1/x++1", ret.GetX()[0]-ret.GetErrorXlow(0), ret.GetX()[ret.GetN()-1]+ret.GetErrorXhigh(ret.GetN()-1) ) + ret.Fit(tf1, "WQ0C EX0 ROB=0.95") + ret.fit = tf1 + return ret + + +whats = [ + ('inputs',[ # On RelVals + ("Had", "Hcal$", ROOT.kAzure+1, 25, 2.0), + ("Em", "Ecal$", ROOT.kGreen+2, 21, 1.5), + ("Calo", "Calo$", ROOT.kViolet+2, 34, 1.5), + ("Trk", "TK$", ROOT.kRed+1, 20, 1.2), + ]), + ('debug-1',[ + ("EcalT", "EcalT$", ROOT.kAzure+1, 25, 2.0), + ("EcalC", "EcalC$", ROOT.kAzure+2, 21, 1.6), + ("HGC/E", "HGCalE$", ROOT.kAzure+3, 21, 1.5), + ("Hcal", "Hcal$", ROOT.kGreen+1, 25, 2.0), + ("HGC/H", "HGCalH$", ROOT.kGreen+2, 25, 2.0), + ("HF", "HF$", ROOT.kViolet+2, 34, 1.5), + ]), + ('debug-2',[ + ("EcalT", "TPEcalT$", ROOT.kAzure+1, 25, 2.0), + ("EcalC", "TPEcalC$", ROOT.kAzure+2, 21, 1.6), + ("Hcal", "TPHcal$", ROOT.kGreen+3, 25, 2.0), + ("HGC/TC", "TPHGCalTC$", ROOT.kGreen+2, 25, 2.0), + ("HGC/3D", "TPHGCal3D$", ROOT.kGreen+1, 21, 1.5), + ("TK", "TPL1Tk$", ROOT.kRed+2, 34, 1.5), + ]), + ('OfflineInputs',[ + ("Had", "Hcal$+HGCalH$+HF$", ROOT.kAzure+1, 25, 2.0), + ("Em", "Em$", ROOT.kGreen+2, 21, 1.5), + ("Calo", "Calo$", ROOT.kViolet+2, 34, 1.5), + ]), + ('TPs',[ + ("Em/T", "TPEcalT$+TPHGCalTE$", ROOT.kAzure+1, 21, 2.2), + ("Calo/T", "TPEcalT$+TPHGCalTE$+TPHGCalTH$+TPHcal$", ROOT.kGreen+1, 21, 1.9), + ("Calo/F", "TPEcalC$+TPHGCal3D$+TPHcal$", ROOT.kGreen+2, 33, 1.8), + ("Trk", "TPL1Tk$", ROOT.kRed+1, 20, 1.2), + ]), + ('l1pf',[ + ("Raw Calo", "L1RawCalo$", ROOT.kViolet-4, 21, 1.7), + ("Calo", "L1Calo$", ROOT.kViolet+2, 34, 1.5), + ("TK", "L1TK$", ROOT.kRed+1, 20, 1.2), + ("PF", "L1PF$", ROOT.kOrange+7, 34, 1.2), + ("Puppi", "L1Puppi$", ROOT.kGray+2, 25, 1.4), + ]), + ('il1pf',[ + ("iCalo", "L1ICalo$", ROOT.kViolet+2, 34, 1.5), + ("iTK", "L1ITK$", ROOT.kRed+1, 20, 1.2), + ("iPF", "L1IPF$", ROOT.kOrange+7, 34, 1.2), + ("iPuppi", "L1IPuppi$", ROOT.kGray+2, 25, 1.4), + ]), +] + +from optparse import OptionParser +parser = OptionParser("%(prog) infile [ src [ dst ] ]") +parser.add_option("-w", dest="what", default=None, help="Choose set (inputs, l1pf, ...)") +parser.add_option("-p", dest="particle", default=None, help="Choose particle (electron, ...)") +options, args = parser.parse_args() +selparticles = options.particle.split(",") if options.particle else [] + +sels = []; fname = args[0] # "respTupleNew_D4T_NoPU.root" +for (particle, pdgIdCut, minPt, maxEta) in [ + ("pion", "abs(mc_id) == 211", 10, 5), + ("pizero", "abs(mc_id) == 111", 10, 5), + ("photon", "abs(mc_id) == 22", 10, 5), + ("electron", "abs(mc_id) == 11", 10, 5), + ("muon", "abs(mc_id) == 13", 10, 5), + ("tau", "(abs(mc_id) == 15 || abs(mc_id) == 211)", 20, 5), + ("jet", "abs(mc_id) == 0", 30, 5), + ("null", "abs(mc_id) == 999", 0, 5) + ]: + if options.particle and (particle not in selparticles): + continue + sels.append(("%s_pt_%2d_inf" % (particle, minPt), fname, "mc_pt > %g && %s" % (minPt, pdgIdCut))) + if "null" in particle: continue; # not point in profiling random cones vs pt + sels.append(("%s_eta_00_15" % (particle), fname, "abs(mc_eta) < 1.5 && %s" % (pdgIdCut))) + sels.append(("%s_eta_00_15_res" % (particle), fname, "abs(mc_eta) < 1.5 && %s" % (pdgIdCut))) + sels.append(("%s_eta_15_25" % (particle), fname, "abs(mc_eta) > 1.5 && abs(mc_eta) < 2.5 && %s" % (pdgIdCut))) + sels.append(("%s_eta_15_25_res" % (particle), fname, "abs(mc_eta) > 1.5 && abs(mc_eta) < 2.5 && %s" % (pdgIdCut))) + sels.append(("%s_eta_25_30" % (particle), fname, "abs(mc_eta) > 2.5 && abs(mc_eta) < 3.0 && %s" % (pdgIdCut))) + sels.append(("%s_eta_25_30_res" % (particle), fname, "abs(mc_eta) > 2.5 && abs(mc_eta) < 3.0 && %s" % (pdgIdCut))) + sels.append(("%s_eta_30_50" % (particle), fname, "abs(mc_eta) > 3.0 && abs(mc_eta) < 5.0 && %s" % (pdgIdCut))) + sels.append(("%s_eta_30_50_res" % (particle), fname, "abs(mc_eta) > 3.0 && abs(mc_eta) < 5.0 && %s" % (pdgIdCut))) + +odir = args[1] # "plots/910pre2/test" +os.system("mkdir -p "+odir) +os.system("cp %s/php/index.php %s/" % (os.environ['HOME'], odir)); +ROOT.gROOT.ProcessLine(".x %s/cpp/tdrstyle.cc" % os.environ['HOME']); +c1 = ROOT.TCanvas("c1","c1") +for oname,fname,cut in sels: + tfile = ROOT.TFile.Open(fname) + tree = tfile.Get("ntuple/tree") + if "electron" in oname or "muon" in oname or "pion" in oname: + cut += " && abs(mc_iso04) < 0.05" # isolated + for kind,things in whats: + if options.what and (kind not in options.what.split(",")): + continue + if "tau" in oname: + ptdefs = [ "pt", "pt02" ] + elif "jet" in oname: + ptdefs = [ "pt" ] + elif "muon" in oname: + ptdefs = [ "pthighest" ] + else: + ptdefs = [ "pt02", "pthighest" ] + for ptdef in ptdefs: + resps = [] + for name,expr,col,msty,msiz in things: + exprptdef = expr.replace("$","_"+ptdef) + if "eta_25" in oname or "eta_30" in oname: + if "TK" in expr: continue + if "Puppi" in name and "PU0" in odir: continue + if "pt" in oname: + prof = doRespEta(oname,tree,name,exprptdef,cut) + if not prof: continue + else: + prof = doRespPt(oname,tree,name,exprptdef,cut,resol=("res" in oname)) + if not prof: continue + if getattr(prof,'fit',None): + prof.fit.SetLineWidth(2); prof.fit.SetLineColor(col) + prof.SetLineWidth(3); prof.SetLineColor(col); prof.SetMarkerColor(col) + prof.SetMarkerStyle(msty); prof.SetMarkerSize(msiz) + resps.append((name,prof)) + if not resps: + print oname, ptdef + continue + c1.SetLogy(False) + if "pt" in oname: + frame = ROOT.TH1F("stk","stk",100,0.0,5.0) + frame.GetYaxis().SetRangeUser(0,2.2) + frame.GetXaxis().SetTitle("|#eta|") + leg = ROOT.TLegend(0.6,0.99,0.95,0.99-0.05*len(things)) + frame.GetYaxis().SetTitle("median p_{T}^{rec}/p_{T}^{gen}") + else: + frame = ROOT.TH1F("stk","stk",100,0.0,250.0 if "jet" in oname else 100.0) + if "res" in oname: + frame.GetYaxis().SetTitle("#sigma_{eff}(p_{T}^{rec})/p_{T}^{rec}") + frame.GetYaxis().SetRangeUser(0.008,10.0) + c1.SetLogy(True) + else: + frame.GetYaxis().SetTitle("median p_{T}^{rec}/p_{T}^{gen}") + frame.GetYaxis().SetRangeUser(0,2.2) + frame.GetXaxis().SetTitle("p_{T} (GeV)") + leg = ROOT.TLegend(0.2,0.99,0.95,0.99-0.05*len(things)) + leg.SetNColumns(2) + frame.GetYaxis().SetDecimals(True) + frame.Draw() + line = ROOT.TLine() + line.SetLineStyle(7) + if "res" not in oname: + line.DrawLine(0.0,1,frame.GetXaxis().GetXmax(),1) + if "pt" in oname: + line.DrawLine(1.5,0,1.5,2.2) + line.DrawLine(2.5,0,2.5,2.2) + line.DrawLine(3.0,0,3.0,2.2) + for n,p in resps: + p.Draw("P SAME" if "TGraph" in p.ClassName() else "SAME") + if hasattr(p,'fit'): p.fit.Draw("SAME") + for n,p in resps: + leg.AddEntry(p, n, "LP") + if hasattr(p,'fit'): + if "res" not in oname: + eq = ("%.2f #timesp_{T} %+ 6.1f" % (p.fit.GetParameter(1), p.fit.GetParameter(0))).replace("-","#minus") + else: + eq = ("%.2f #timesp_{T} %+ 6.1f" % (p.fit.GetParameter(1), p.fit.GetParameter(0))).replace("-","#minus") + leg.AddEntry(p.fit, eq, "L") + leg.Draw() + out = odir+'/'+oname+"-"+kind+"_"+ptdef+".png" + c1.Print(out) + del frame + diff --git a/NtupleProducer/src/CaloClusterer.cc b/NtupleProducer/src/CaloClusterer.cc index 9ee765e0bc711..9731bb0c403bd 100644 --- a/NtupleProducer/src/CaloClusterer.cc +++ b/NtupleProducer/src/CaloClusterer.cc @@ -334,14 +334,15 @@ void l1pf_calo::SimpleCaloLinker::run() -std::vector l1pf_calo::SimpleCaloLinker::fetch(bool corrected) const { - std::vector ret; +std::unique_ptr> l1pf_calo::SimpleCaloLinker::fetch(bool corrected) const { + auto ret = std::make_unique>(); for (unsigned int i = 0, ncells = grid_->size(); i < ncells; ++i) { if (cluster_[i].et > 0) { bool photon = (cluster_[i].hcal_et < hoeCut_* cluster_[i].ecal_et); if (cluster_[i].et > (photon ? minPhotonEt_ : minHadronEt_)) { - ret.emplace_back(corrected ? cluster_[i].et_corr : cluster_[i].et, cluster_[i].eta, cluster_[i].phi, 0.0, photon ? 3 : 2); - ret.back().setCaloEtaPhi(cluster_[i].eta, cluster_[i].phi); + ret->emplace_back(corrected ? cluster_[i].et_corr : cluster_[i].et, cluster_[i].eta, cluster_[i].phi, 0.0, photon ? 3 : 2); + ret->back().setCaloEtaPhi(cluster_[i].eta, cluster_[i].phi); + ret->back().setHOverE( cluster_[i].ecal_et > 0 ? cluster_[i].hcal_et / cluster_[i].ecal_et : -1 ); } } } diff --git a/NtupleProducer/src/DiscretePF.cc b/NtupleProducer/src/DiscretePF.cc index b7ffab6c07797..0fcc85dccd82b 100644 --- a/NtupleProducer/src/DiscretePF.cc +++ b/NtupleProducer/src/DiscretePF.cc @@ -66,7 +66,7 @@ void RegionMapper::addCalo( const l1tpf::Particle &p ) { //float et, float etErr // we don't propagate anything // we don't worry about borders CaloCluster calo; - calo.fill(p.pt(), p.sigma(), p.eta(), p.phi(), p.pdgId() == PFParticle::GAMMA, 0); + calo.fill(p.pt(), p.sigma(), p.eta(), p.phi(), p.pdgId() == l1tpf::Particle::GAMMA, 0); for (Region &r : regions_) { if (r.contains(p.eta(), p.phi())) { r.calo.push_back(calo); @@ -97,7 +97,7 @@ std::vector RegionMapper::fetchCalo(float ptMin) const { if (!r.fiducial(p.floatEta(), p.floatPhi())) continue; } if (p.floatPt() > ptMin) { - ret.emplace_back( p.floatPt(), p.floatEta(), p.floatPhi(), 0.13f, p.isEM ? PFParticle::GAMMA : PFParticle::NH ); + ret.emplace_back( p.floatPt(), p.floatEta(), p.floatPhi(), 0.13f, p.isEM ? l1tpf::Particle::GAMMA : l1tpf::Particle::NH ); } } } @@ -112,7 +112,7 @@ std::vector RegionMapper::fetchTracks(float ptMin) const { if (!r.fiducial(p.floatVtxEta(), p.floatVtxPhi())) continue; } if (p.floatPt() > ptMin) { - ret.emplace_back( p.floatVtxPt(), p.floatVtxEta(), p.floatVtxPhi(), 0.13f, p.muonLink ? PFParticle::MU : PFParticle::CH, 0.f, p.floatDZ(), p.floatEta(), p.floatPhi(), p.intCharge() ); + ret.emplace_back( p.floatVtxPt(), p.floatVtxEta(), p.floatVtxPhi(), 0.13f, p.muonLink ? l1tpf::Particle::MU : l1tpf::Particle::CH, 0.f, p.floatDZ(), p.floatEta(), p.floatPhi(), p.intCharge() ); } } } @@ -219,7 +219,7 @@ PFParticle & PFAlgo::addTrackToPF(Region &r, const PropagatedTrack &tk) const { pf.hwVtxPhi = tk.hwPhi; // before propagation pf.track = tk; pf.cluster.hwPt = 0; - pf.hwId = (tk.muonLink ? PFParticle::MU : PFParticle::CH); + pf.hwId = (tk.muonLink ? l1tpf::Particle::MU : l1tpf::Particle::CH); r.pf.push_back(pf); return r.pf.back(); } @@ -232,7 +232,7 @@ PFParticle & PFAlgo::addCaloToPF(Region &r, const CaloCluster &calo) const { pf.hwVtxPhi = calo.hwPhi; pf.track.hwPt = 0; pf.cluster = calo; - pf.hwId = (calo.isEM ? PFParticle::GAMMA : PFParticle::NH); + pf.hwId = (calo.isEM ? l1tpf::Particle::GAMMA : l1tpf::Particle::NH); r.pf.push_back(pf); return r.pf.back(); } @@ -257,7 +257,7 @@ void PFAlgo::mergeTkCalo(Region &r, const PropagatedTrack &tk, CaloCluster & cal PFParticle & pf = addTrackToPF(r, tk); pf.hwPt = ptAvg; pf.cluster = calo; - pf.hwId = (calo.isEM ? PFParticle::EL : PFParticle::CH); + pf.hwId = (calo.isEM ? l1tpf::Particle::EL : l1tpf::Particle::CH); calo.used = true; // used, not to be added to the PF again if (debug_) printf("INT case 2: merge, avg pt %7.2f from calo (%7.2f +- %.2f), track (%7.2f +- %.2f) weights %.3f %.3f\n", pf.floatPt(), calo.floatPt(), calo.floatPtErr(), tk.floatPt(), tk.floatPtErr(), wcalo/(wcalo+wtk), wtk/(wcalo+wtk)); @@ -328,7 +328,7 @@ void PFAlgo::fillPuppi(Region &r) const { int16_t iptcutF = std::round(puppiPtCutF_ * CaloCluster::PT_SCALE); constexpr uint16_t PUPPIW_0p01 = std::round(0.01 * PFParticle::PUPPI_SCALE); for (PFParticle & p : r.pf) { - if (p.hwId == PFParticle::MU) { + if (p.hwId == l1tpf::Particle::MU) { r.puppi.push_back(p); } else if (p.hwId <= 1) { // charged if (p.hwPuppiWeight > 0) { diff --git a/NtupleProducer/src/classes_def.xml b/NtupleProducer/src/classes_def.xml index bdd5d58099802..df837da7b3845 100644 --- a/NtupleProducer/src/classes_def.xml +++ b/NtupleProducer/src/classes_def.xml @@ -1,5 +1,6 @@ - + + diff --git a/NtupleProducer/src/combiner.cc b/NtupleProducer/src/combiner.cc index 2b7dc70e38f35..40fa67e5543b3 100644 --- a/NtupleProducer/src/combiner.cc +++ b/NtupleProducer/src/combiner.cc @@ -64,7 +64,7 @@ l1tpf::Particle combiner::makeCalo(double iCalo,double iEcal,double iCaloEta,dou if(iCalo < 1.1*iEcal) lPhi = iEcalPhi; double lSigma = lEt; iCalo < 1.1*iEcal ? lSigma = getEleRes(lEt,lEta,lPhi) : lSigma = getPionRes(lEt,lEta,lPhi); - int lId = NH; if(iCalo < 1.1*iEcal) lId = GAMMA; + int lId = Particle::NH; if(iCalo < 1.1*iEcal) lId = Particle::GAMMA; return Particle(lEt,lEta,lPhi,0.,lId,lSigma,0.,lEta,lPhi); } void combiner::addCalo(const l1tpf::Particle & particle) { @@ -98,10 +98,10 @@ void combiner::link(bool iMetRate) { } if (curDR < 0.2 && (curDPT) < 4 && fabs(curDPT) < minPtDiff){ if (imatch > -1) { // we've found a new match, the previous one should be unmatched - fTkParticles[i1].setPdgId(CH); + fTkParticles[i1].setPdgId(Particle::CH); fTkParticles[i1].setMass(0.135); } - fTkParticles[i1].setPdgId(MU); + fTkParticles[i1].setPdgId(Particle::MU); fTkParticles[i1].setMass(0.105); minPtDiff = fabs(curDPT); imatch = i1; @@ -111,7 +111,7 @@ void combiner::link(bool iMetRate) { // then do track + calo linking if (fDebug) printf("Trying to link. I have %d tracks, %d calo\n", int(fTkParticles.size()), int(fParticles.size())); for(unsigned int i0 = 0; i0 < fTkParticles.size(); i0++) { - if(fTkParticles[i0].pdgId() == MU) continue; // skip muons for now, add them at the end + if(fTkParticles[i0].pdgId() == Particle::MU) continue; // skip muons for now, add them at the end if (fDebug>1) printf("\t track %d (pt %7.2f +- %5.2f)\n", i0, fTkParticles[i0].pt(), fTkParticles[i0].sigma()); bool pFilled = false; // if true, the track has already been added in the PF candidates; if false, it's still to be added int pIMatch = -1; double pPtMatch = -1; @@ -121,7 +121,7 @@ void combiner::link(bool iMetRate) { if(deltaR(fTkParticles[i0],fParticles[i1]) > fDRMatch) { if (fDebug>1) printf("outside dR (%.3f).\n",deltaR(fTkParticles[i0],fParticles[i1])); continue; } - if(fParticles[i1].pdgId() == CH || fParticles[i1].pdgId() == EL) { + if(fParticles[i1].pdgId() == Particle::CH || fParticles[i1].pdgId() == Particle::EL) { if (fDebug>1) printf("already linked.\n"); continue; } if(fParticles[i1].pt()+2.*fParticles[i1].sigma() < fTkParticles[i0].pt()) { @@ -148,7 +148,7 @@ void combiner::link(bool iMetRate) { // now do muons... when not using muon gun+PU as a neutrino gun if(!iMetRate) { for(unsigned int i0 = 0; i0 < fTkParticles.size(); i0++) { - if (fTkParticles[i0].pdgId() == MU) fParticles.push_back(fTkParticles[i0]); + if (fTkParticles[i0].pdgId() == Particle::MU) fParticles.push_back(fTkParticles[i0]); } } } @@ -173,7 +173,7 @@ void combiner::merge(Particle &iTkParticle,Particle &iParticle1,std::vector &iParticle){ // first find the muon matched to GEN for(unsigned int i0 = 0; i0 < iParticle.size(); i0++) { - if ((gmu1.Pt() > 0)&&(iParticle[i0].pdgId() == combiner::MU)){ + if ((gmu1.Pt() > 0)&&(iParticle[i0].pdgId() == combiner::Particle::MU)){ if (gmu1.DeltaR(iParticle[i0].tp4()) < 0.4){ // std::cout << "found a matching muon1!" << iParticle[i0].tp4().Pt() << std::endl; _mu1 = iParticle[i0].tp4(); } } - if ((gmu2.Pt() > 0)&&(iParticle[i0].pdgId() == combiner::MU)){ + if ((gmu2.Pt() > 0)&&(iParticle[i0].pdgId() == combiner::Particle::MU)){ if (gmu2.DeltaR(iParticle[i0].tp4()) < 0.4){ // std::cout << "found a matching muon2!" << iParticle[i0].tp4().Pt() << std::endl; _mu2 = iParticle[i0].tp4();