From 3343588916ade6e73e0a226166434a8452950895 Mon Sep 17 00:00:00 2001 From: "R. Alex Barbieri" Date: Wed, 14 May 2014 13:15:30 -0400 Subject: [PATCH] Fix memory leak in EGamma algo --- yaml --- svn_rev: 139994 current_ref: refs/heads/usePFclusteringInRegionsForMuonsBackUp current_commit: e4432b3e0e0ad1910e6fe182d344dcd4016a2d67 head_branch: refs/heads/CMSSW_4_1_X --- [refs] | 2 +- .../L1TObjects/interface/CaloParams.h | 60 ++-- .../interface/Stage1Layer2TauAlgorithmImp.h | 14 +- .../L1TCalorimeter/interface/legacyGtHelper.h | 40 --- .../plugins/L1TCaloUpgradeToGCTConverter.cc | 49 +++- .../L1TCalorimeter/plugins/PhysicalEtAdder.cc | 78 ++--- .../plugins/Stage1Layer2Producer.cc | 34 +-- .../src/JetCalibrationMethods.cc | 24 +- .../L1TCalorimeter/src/JetFinderMethods.cc | 270 ++++++++++++++++++ .../Stage1Layer2EtSumAlgorithmImpPP.cc | 20 +- .../firmware/Stage1Layer2JetAlgorithmImpHI.cc | 27 +- .../firmware/Stage1Layer2JetAlgorithmImpPP.cc | 33 ++- .../Stage1Layer2MainProcessorFirmwareImp1.cc | 8 +- .../src/firmware/Stage1Layer2SingleTrackHI.cc | 36 +-- .../firmware/Stage1Layer2TauAlgorithmImpPP.cc | 38 ++- .../L1TCalorimeter/src/legacyGtHelper.cc | 91 ------ 16 files changed, 458 insertions(+), 366 deletions(-) delete mode 100644 branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h delete mode 100644 branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/legacyGtHelper.cc diff --git a/[refs] b/[refs] index 728c288d878b5..fd47bff4da755 100644 --- a/[refs] +++ b/[refs] @@ -4,4 +4,4 @@ refs/heads/CMSSW_4_1_X: a4334f9063dcad3cb0c038ac911fd8357c3bbaaa refs/heads/with_VBF_Hbb_fragment: 5b1f2347e6db46cfd6288879a97056d280cf27c5 refs/heads/withOnlineToOfflineProducer: c0b9423e0d6c6d5315f93d1ee32e9bf68078d9c0 refs/heads/withNewDZ: a67661d3e05d8a51194ddc51d1ff68044af2314a -refs/heads/usePFclusteringInRegionsForMuonsBackUp: 252c4507d30da9c838013ec506616cf2103c9d63 +refs/heads/usePFclusteringInRegionsForMuonsBackUp: e4432b3e0e0ad1910e6fe182d344dcd4016a2d67 diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/CondFormats/L1TObjects/interface/CaloParams.h b/branches/usePFclusteringInRegionsForMuonsBackUp/CondFormats/L1TObjects/interface/CaloParams.h index 53863918f7719..5b6cd27d1e3ad 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/CondFormats/L1TObjects/interface/CaloParams.h +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/CondFormats/L1TObjects/interface/CaloParams.h @@ -4,7 +4,7 @@ /// Description: Placeholder for calorimeter trigger parameters /// /// Implementation: -/// +/// /// /// \author: Jim Brooke /// @@ -14,21 +14,15 @@ #include "CondFormats/L1TObjects/interface/LUT.h" -#include "CondFormats/L1TObjects/interface/L1CaloEtScale.h" -#include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h" -#include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h" -#include "CondFormats/DataRecord/interface/L1HtMissScaleRcd.h" -#include "CondFormats/DataRecord/interface/L1HfRingEtScaleRcd.h" - #include #include #include #include namespace l1t { - + class CaloParams { - + public: CaloParams() {} @@ -79,7 +73,7 @@ namespace l1t { double egMaxHcalEt() const { return egMaxHcalEt_; } int egEtToRemoveHECutHw() const {return floor(egEtToRemoveHECut_/egLsb_);} double egEtToRemoveHECut() const {return egEtToRemoveHECut_;} - double egMaxHOverE() const { return egMaxHOverE_; } + double egMaxHOverE() const { return egMaxHOverE_; } double egRelativeJetIsolationCut() const { return egRelativeJetIsolationCut_; } unsigned egIsoAreaNrTowersEta()const{return egIsoAreaNrTowersEta_;} unsigned egIsoAreaNrTowersPhi()const{return egIsoAreaNrTowersPhi_;} @@ -91,7 +85,7 @@ namespace l1t { l1t::LUT* egIsolationLUT() { return egIsolationLUT_.get(); } std::string egCalibrationType() const { return egCalibrationType_; } std::vector egCalibrationParams() { return egCalibrationParams_; } - L1CaloEtScale emScale() { return emScale_; } + void setEgLsb(double lsb) { egLsb_ = lsb; } void setEgSeedThreshold(double thresh) { egSeedThreshold_ = thresh; } @@ -100,7 +94,7 @@ namespace l1t { void setEgEtToRemoveHECut(double thresh) { egEtToRemoveHECut_ = thresh;} void setEgMaxHOverE(double cut) { egMaxHOverE_ = cut; } void setEgRelativeJetIsolationCut(double cutValue) { egRelativeJetIsolationCut_ = cutValue; } - + void setEgIsoAreaNrTowersEta(unsigned iEgIsoAreaNrTowersEta){egIsoAreaNrTowersEta_=iEgIsoAreaNrTowersEta;} void setEgIsoAreaNrTowersPhi(unsigned iEgIsoAreaNrTowersPhi){egIsoAreaNrTowersPhi_=iEgIsoAreaNrTowersPhi;} void setEgIsoVetoNrTowersPhi(unsigned iEgIsoVetoNrTowersPhi){egIsoVetoNrTowersPhi_=iEgIsoVetoNrTowersPhi;} @@ -111,7 +105,6 @@ namespace l1t { void setEgIsolationLUT(std::shared_ptr lut) { egIsolationLUT_ = lut; } void setEgCalibrationType(std::string type) { egCalibrationType_ = type; } void setEgCalibrationParams(std::vector params) { egCalibrationParams_ = params; } - void setEmScale(L1CaloEtScale emScale) { emScale_ = emScale; } // tau @@ -145,7 +138,6 @@ namespace l1t { std::vector jetPUSParams() { return jetPUSParams_; } std::string jetCalibrationType() const { return jetCalibrationType_; } std::vector jetCalibrationParams() { return jetCalibrationParams_; } - L1CaloEtScale jetScale() { return jetScale_; } void setJetLsb(double lsb) { jetLsb_ = lsb; } void setJetSeedThreshold(double thresh) { jetSeedThreshold_ = thresh; } @@ -154,24 +146,19 @@ namespace l1t { void setJetPUSParams(std::vector params) { jetPUSParams_ = params; } void setJetCalibrationType(std::string type) { jetCalibrationType_ = type; } void setJetCalibrationParams(std::vector params) { jetCalibrationParams_ = params; } - void setJetScale(L1CaloEtScale jetScale) { jetScale_ = jetScale; } - + // sums double etSumLsb() const { return etSumLsb_; } int etSumEtaMin(unsigned isum) const; int etSumEtaMax(unsigned isum) const; int etSumEtThresholdHw(unsigned isum) const { return floor(etSumEtThreshold(isum)/etSumLsb_); } double etSumEtThreshold(unsigned isum) const; - L1CaloEtScale HtMissScale() {return HtMissScale_;} - L1CaloEtScale HfRingScale() {return HfRingScale_;} - + void setEtSumLsb(double lsb) { etSumLsb_ = lsb; } void setEtSumEtaMin(unsigned isum, int eta); void setEtSumEtaMax(unsigned isum, int eta); - void setEtSumEtThreshold(unsigned isum, double thresh); - void setHtMissScale(L1CaloEtScale HtMissScale){HtMissScale_ = HtMissScale;} - void setHfRingScale(L1CaloEtScale HfRingScale){HfRingScale_ = HfRingScale;} + void setEtSumEtThreshold(unsigned isum, double thresh); // print parameters to stream: void print(std::ostream&) const; @@ -227,7 +214,7 @@ namespace l1t { // bitmask for storing ECAL/HCAL ratio in tower object int towerMaskRatio_; - + // turn encoding on/off bool towerDoEncoding_; @@ -262,7 +249,7 @@ namespace l1t { // Et threshold to remove the H/E cut from the EGammas double egEtToRemoveHECut_; - + // EG maximum value of H/E double egMaxHOverE_; @@ -270,16 +257,16 @@ namespace l1t { double egRelativeJetIsolationCut_; // isolation area in eta is seed tower +/- <=egIsoAreaNrTowersPhi - unsigned egIsoAreaNrTowersEta_; + unsigned egIsoAreaNrTowersEta_; // isolation area in phi is seed tower +/- <=egIsoAreaNrTowersPhi - unsigned egIsoAreaNrTowersPhi_; + unsigned egIsoAreaNrTowersPhi_; // veto region is seed tower +/- <=egIsoVetoNrTowersPhi - unsigned egIsoVetoNrTowersPhi_; - + unsigned egIsoVetoNrTowersPhi_; + // for # towers based PU estimator, estimator is #towers/egIsoPUEstTowerGranularity_ - unsigned egIsoPUEstTowerGranularity_; + unsigned egIsoPUEstTowerGranularity_; // eta range over which # towers is estimated unsigned egIsoMaxEtaAbsForTowerSum_; @@ -292,16 +279,14 @@ namespace l1t { // EG calibration coefficients std::vector egCalibrationParams_; - + // EG isolation PUS std::string egIsoPUSType_; // EG isolation LUT (indexed by eta, Et ?) std::shared_ptr egIsolationLUT_; - L1CaloEtScale emScale_; - - + /* Tau */ @@ -313,7 +298,7 @@ namespace l1t { // Et threshold on tau neighbour towers double tauNeighbourThreshold_; - + // Relative jet isolation cut for Taus (Stage1Layer2) double tauRelativeJetIsolationCut_; // Tau isolation PUS @@ -342,7 +327,7 @@ namespace l1t { double jetNeighbourThreshold_; // jet PUS scheme ("None" means no PU) - std::string jetPUSType_; + std::string jetPUSType_; // jet PU params std::vector jetPUSParams_; @@ -353,8 +338,6 @@ namespace l1t { // jet calibration coefficients std::vector jetCalibrationParams_; - L1CaloEtScale jetScale_; - /* Sums */ @@ -378,9 +361,6 @@ namespace l1t { int minGctEtaForSums_; int maxGctEtaForSums_; - L1CaloEtScale HtMissScale_; - L1CaloEtScale HfRingScale_; - }; }// namespace diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/interface/Stage1Layer2TauAlgorithmImp.h b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/interface/Stage1Layer2TauAlgorithmImp.h index 240a550888eb5..234a597487964 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/interface/Stage1Layer2TauAlgorithmImp.h +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/interface/Stage1Layer2TauAlgorithmImp.h @@ -12,16 +12,16 @@ namespace l1t { class Stage1Layer2SingleTrackHI : public Stage1Layer2TauAlgorithm { public: - Stage1Layer2SingleTrackHI(CaloParams* params); + Stage1Layer2SingleTrackHI(); virtual ~Stage1Layer2SingleTrackHI(); - virtual void processEvent(const std::vector & clusters, + virtual void processEvent(//const std::vector & clusters, + const std::vector & clusters, const std::vector & regions, const std::vector * jets, std::vector * taus); - private: - CaloParams* const params_; - + /* private: */ + /* double regionLSB_; */ }; class Stage1Layer2TauAlgorithmImpPP : public Stage1Layer2TauAlgorithm { @@ -33,7 +33,7 @@ namespace l1t { const std::vector * jets, std::vector * taus); - private: + private: CaloParams* const params_; @@ -41,7 +41,7 @@ namespace l1t { const std::vector & regions, double& isolation) const; - double JetIsolation(int et, int ieta, int iphi, + double JetIsolation(int et, int ieta, int iphi, const std::vector & jets) const; //int tauSeed; diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h deleted file mode 100644 index 4a27c22af40e3..0000000000000 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h +++ /dev/null @@ -1,40 +0,0 @@ -// legacyGtHelper.h -// Authors: Alex Barbieri -// -// This is a collection of helper methods to make sure that -// the objects passed to the legacy GT are using the proper -// Et scales and eta coordinates. - -#ifndef LEGACYGTHELPER_H -#define LEGACYGTHELPER_H - -#include "DataFormats/L1Trigger/interface/EGamma.h" -#include "DataFormats/L1Trigger/interface/Tau.h" -#include "DataFormats/L1Trigger/interface/Jet.h" -#include "DataFormats/L1Trigger/interface/EtSum.h" -#include "CondFormats/L1TObjects/interface/CaloParams.h" - -#include - -namespace l1t { - -void JetToGtScales(CaloParams *params, - const std::vector * input, - std::vector *output); - -void EGammaToGtScales(CaloParams *params, - const std::vector * input, - std::vector *output); - -void TauToGtScales(CaloParams *params, - const std::vector * input, - std::vector *output); - -void EtSumToGtScales(CaloParams *params, - const std::vector * input, - std::vector *output); - - -} - -#endif diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/L1TCaloUpgradeToGCTConverter.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/L1TCaloUpgradeToGCTConverter.cc index 79bf19af1a779..fb70a0159627d 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/L1TCaloUpgradeToGCTConverter.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/L1TCaloUpgradeToGCTConverter.cc @@ -70,6 +70,13 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es) Handle EtSum; e.getByToken(EtSumToken_,EtSum); + edm::ESHandle< L1CaloEtScale > emScale ; + es.get< L1EmEtScaleRcd >().get( emScale ) ; + + edm::ESHandle< L1CaloEtScale > jetScale ; + es.get< L1JetEtScaleRcd >().get( jetScale ) ; + + // create the em and jet collections std::auto_ptr isoEmResult(new L1GctEmCandCollection( ) ); std::auto_ptr nonIsoEmResult(new L1GctEmCandCollection( ) ); @@ -140,10 +147,15 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es) int tauCount = 0; //max 4 for(l1t::TauBxCollection::const_iterator itTau = Tau->begin(itBX); itTau != Tau->end(itBX); ++itTau){ - // taus are not allowed to be forward - const bool forward= false; + // forward def is okay for Taus + const bool forward= (itTau->hwEta() < 4 || itTau->hwEta() > 17); + const uint16_t rankPt = jetScale->rank((uint16_t)itTau->hwPt()); + + unsigned iEta = itTau->hwEta(); + unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11); + unsigned gtEta=(((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0)); - L1GctJetCand TauCand(itTau->hwPt(), itTau->hwPhi(), itTau->hwEta(), + L1GctJetCand TauCand(rankPt, itTau->hwPhi(), gtEta, true, forward,0, 0, itBX); //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta, // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx); @@ -160,7 +172,13 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es) itJet != Jet->end(itBX); ++itJet){ // use 2nd quality bit to define forward const bool forward = ((itJet->hwQual() & 0x2) != 0); - L1GctJetCand JetCand(itJet->hwPt(), itJet->hwPhi(), itJet->hwEta(), + const uint16_t rankPt = jetScale->rank((uint16_t)itJet->hwPt()); + + unsigned iEta = itJet->hwEta(); + unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11); + unsigned gtEta=(((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0)); + + L1GctJetCand JetCand(rankPt, itJet->hwPhi(), gtEta, false, forward,0, 0, itBX); //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta, // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx); @@ -177,7 +195,6 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es) } } } - //looping over EtSum elments with a specific BX for (l1t::EtSumBxCollection::const_iterator itEtSum = EtSum->begin(itBX); itEtSum != EtSum->end(itBX); ++itEtSum){ @@ -200,6 +217,28 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es) } } + + + //*isoEmResult = + //this->ConvertToNonIsoEmCand(EGamma); + // DataFormatter.ConvertToNonIsoEmCand(*EGamma, nonIsoEmResult); + // DataFormatter.ConvertToCenJetCand(*Jet, cenJetResult); + // DataFormatter.ConvertToForJetCand(*Jet, forJetResult); + // DataFormatter.ConvertToTauJetCand(*Tau, tauJetResult); + + // DataFormatter.ConvertToEtTotal(EtSum, etTotResult); + // DataFormatter.ConvertToEtHad(EtSum,etHadResult); + // DataFormatter.ConvertToEtMiss(EtSum,etMissResult); + // DataFormatter.ConvertToHtMiss(EtSum,htMissResult); + // DataFormatter.ConvertToHFBitCounts(EtSum,hfBitCountResult); + // DataFormatter.ConvertToHFRingEtSums(EtSum, hfRingEtSumResult); + + // DataFormatter.ConvertToIntJet(Jet, internalJetResult); + // DataFormatter.ConvertToIntEtSum(EtSum,internalEtSumResult); + // DataFormatter.ConvertToIntHtMiss(EtSum,internalHtMissResult); + + + e.put(isoEmResult,"isoEm"); e.put(nonIsoEmResult,"nonIsoEm"); e.put(cenJetResult,"cenJets"); diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/PhysicalEtAdder.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/PhysicalEtAdder.cc index 1808210e0d535..71f82e124d077 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/PhysicalEtAdder.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/PhysicalEtAdder.cc @@ -1,5 +1,4 @@ #include "L1Trigger/L1TCalorimeter/plugins/PhysicalEtAdder.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h" #include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h" @@ -19,9 +18,7 @@ #include "FWCore/Framework/interface/ESHandle.h" #include -#include - -double getPhysicalEta(int etaIndex, bool forward = false); +double getPhysicalEta(int etaIndex); double getPhysicalPhi(int phiIndex); l1t::PhysicalEtAdder::PhysicalEtAdder(const edm::ParameterSet& ps) { @@ -69,7 +66,11 @@ l1t::PhysicalEtAdder::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) edm::ESHandle< L1CaloEtScale > jetScale ; iSetup.get< L1JetEtScaleRcd >().get( jetScale ) ; + edm::ESHandle< L1CaloEtScale > hwForJetScale ; + iSetup.get< L1JetEtScaleRcd >().get( hwForJetScale ) ; + edm::ESHandle< L1CaloEtScale > htMissScale ; + std::vector< bool > htMissMatched ; iSetup.get< L1HtMissScaleRcd >().get( htMissScale ) ; int firstBX = old_egammas->getFirstBX(); @@ -85,11 +86,10 @@ l1t::PhysicalEtAdder::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for(l1t::EGammaBxCollection::const_iterator itEGamma = old_egammas->begin(bx); itEGamma != old_egammas->end(bx); ++itEGamma) { - //const double pt = itEGamma->hwPt() * emScale->linearLsb(); - const double et = emScale->et( itEGamma->hwPt() ); + const double pt = itEGamma->hwPt() * emScale->linearLsb(); const double eta = getPhysicalEta(itEGamma->hwEta()); const double phi = getPhysicalPhi(itEGamma->hwPhi()); - math::PtEtaPhiMLorentzVector *p4 = new math::PtEtaPhiMLorentzVector(et, eta, phi, 0); + math::PtEtaPhiMLorentzVector *p4 = new math::PtEtaPhiMLorentzVector(pt, eta, phi, 0); l1t::EGamma *eg = new l1t::EGamma(*p4, itEGamma->hwPt(), itEGamma->hwEta(), itEGamma->hwPhi(), @@ -107,18 +107,15 @@ l1t::PhysicalEtAdder::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) //const double et = jetScale->et( rankPt ) ; // or use the emScale to get finer-grained et - //const double et = itTau->hwPt() * emScale->linearLsb(); - - // we are now already in the rankPt - const double et = jetScale->et( itTau->hwPt() ); - + const double et = itTau->hwPt() * emScale->linearLsb(); + const double eta = getPhysicalEta(itTau->hwEta()); const double phi = getPhysicalPhi(itTau->hwPhi()); math::PtEtaPhiMLorentzVector *p4 = new math::PtEtaPhiMLorentzVector(et, eta, phi, 0); l1t::Tau *tau = new l1t::Tau(*p4, itTau->hwPt(), itTau->hwEta(), itTau->hwPhi(), - itTau->hwQual(), itTau->hwIso()); + itTau->hwQual()); new_taus->push_back(bx, *tau); } @@ -129,15 +126,11 @@ l1t::PhysicalEtAdder::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) // use the full-circle conversion to match l1extra, accounts for linearLsb and max value automatically //const uint16_t rankPt = jetScale->rank((uint16_t)itJet->hwPt()); //const double et = jetScale->et( rankPt ) ; - + // or use the emScale to get finer-grained et - //const double et = itJet->hwPt() * emScale->linearLsb(); - - // we are now already in the rankPt - const double et = jetScale->et( itJet->hwPt() ); - - const bool forward = ((itJet->hwQual() & 0x2) != 0); - const double eta = getPhysicalEta(itJet->hwEta(), forward); + const double et = itJet->hwPt() * emScale->linearLsb(); + + const double eta = getPhysicalEta(itJet->hwEta()); const double phi = getPhysicalPhi(itJet->hwPhi()); math::PtEtaPhiMLorentzVector *p4 = new math::PtEtaPhiMLorentzVector(et, eta, phi, 0); @@ -151,16 +144,12 @@ l1t::PhysicalEtAdder::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for(l1t::EtSumBxCollection::const_iterator itEtSum = old_etsums->begin(bx); itEtSum != old_etsums->end(bx); ++itEtSum) { - //const double pt = itEtSum->hwPt() * emScale->linearLsb(); - double et = emScale->et( itEtSum->hwPt() ); - const l1t::EtSum::EtSumType sumType = itEtSum->getType(); - if(sumType == EtSum::EtSumType::kMissingHt) - et = htMissScale->et( itEtSum->hwPt() ); - + const double pt = itEtSum->hwPt() * emScale->linearLsb(); const double eta = getPhysicalEta(itEtSum->hwEta()); const double phi = getPhysicalPhi(itEtSum->hwPhi()); - - math::PtEtaPhiMLorentzVector *p4 = new math::PtEtaPhiMLorentzVector(et, eta, phi, 0); + const l1t::EtSum::EtSumType sumType = itEtSum->getType(); + //std::cout << "SumType: " << sumType << std::endl; + math::PtEtaPhiMLorentzVector *p4 = new math::PtEtaPhiMLorentzVector(pt, eta, phi, 0); l1t::EtSum *eg = new l1t::EtSum(*p4, sumType, itEtSum->hwPt(), itEtSum->hwEta(), itEtSum->hwPhi(), @@ -235,36 +224,9 @@ l1t::PhysicalEtAdder::fillDescriptions(edm::ConfigurationDescriptions& descripti //define this as a plug-in DEFINE_FWK_MODULE(l1t::PhysicalEtAdder); -int getRegionEta(int gtEta, bool forward) +// grabbed these from the UCT2015 codebase. +double getPhysicalEta(int etaIndex) { - // backwards conversion is - // unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11); - // return (((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0)); - int centralGtEta[] = {11, 12, 13, 14, 15, 16, 17, -100, 10, 9, 8, 7, 6, 5, 4}; - int forwardGtEta[] = {18, 19, 20, 21, -100, -100, -100, -100, 3, 2, 1, 0}; - - //printf("%i, %i\n",gtEta,forward); - - int regionEta; - - if(!forward) - { - regionEta = centralGtEta[gtEta]; - } else - regionEta = forwardGtEta[gtEta]; - - if(regionEta == -100) - edm::LogError("EtaIndexError") - << "Bad eta index passed to PhysicalEtAdder::getRegionEta, " << gtEta << std::endl; - - return regionEta; -} - -// adapted these from the UCT2015 codebase. -double getPhysicalEta(int gtEta, bool forward) -{ - int etaIndex = getRegionEta(gtEta, forward); - const double rgnEtaValues[11] = { 0.174, // HB and inner HE bins are 0.348 wide 0.522, diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/Stage1Layer2Producer.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/Stage1Layer2Producer.cc index e6133684bf6f7..917f27c1f9509 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/Stage1Layer2Producer.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/plugins/Stage1Layer2Producer.cc @@ -27,8 +27,6 @@ #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h" #include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h" #include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h" -#include "CondFormats/DataRecord/interface/L1HtMissScaleRcd.h" -#include "CondFormats/DataRecord/interface/L1HfRingEtScaleRcd.h" #include #include "DataFormats/L1Trigger/interface/BXVector.h" @@ -264,8 +262,8 @@ Stage1Layer2Producer::endJob() { void Stage1Layer2Producer::beginRun(Run const&iR, EventSetup const&iE){ - unsigned long long id = iE.get().cacheIdentifier(); - + unsigned long long id = iE.get().cacheIdentifier(); + if (id != m_paramsCacheId) { m_paramsCacheId = id; @@ -276,11 +274,11 @@ void Stage1Layer2Producer::beginRun(Run const&iR, EventSetup const&iE){ // replace our local copy of the parameters with a new one using placement new m_params->~CaloParams(); m_params = new (m_params) CaloParams(*paramsHandle.product()); - + LogDebug("L1TDebug") << *m_params << std::endl; if (! m_params){ - edm::LogError("l1t|caloStage1") << "Could not retrieve params from Event Setup" << std::endl; + edm::LogError("l1t|caloStage1") << "Could not retrieve params from Event Setup" << std::endl; } } @@ -292,26 +290,16 @@ void Stage1Layer2Producer::beginRun(Run const&iR, EventSetup const&iE){ m_params->setMaxGctEtaForSums(maxGctEtaForSums); m_params->setEgRelativeJetIsolationCut(egRelativeJetIsolationCut); m_params->setTauRelativeJetIsolationCut(tauRelativeJetIsolationCut); - + LogDebug("l1t|stage 1 jets") << "Stage1Layer2Producer::beginRun function called...\n"; - //get the proper scales for conversion to physical et AND gt scales - edm::ESHandle< L1CaloEtScale > emScale ; - iE.get< L1EmEtScaleRcd >().get( emScale ) ; - m_params->setEmScale(*emScale); - - edm::ESHandle< L1CaloEtScale > jetScale ; - iE.get< L1JetEtScaleRcd >().get( jetScale ) ; - m_params->setJetScale(*jetScale); - - edm::ESHandle< L1CaloEtScale > HtMissScale; - iE.get< L1HtMissScaleRcd >().get( HtMissScale ) ; - m_params->setHtMissScale(*HtMissScale); + //get the proper scales for conversion to physical et + //right now just set them in the Params cfi, rename them egLsb, jetLsb + //edm::ESHandle< L1CaloEtScale > emScale ; + //iE.get< L1EmEtScaleRcd >().get( emScale ) ; - //not sure if I need this one - edm::ESHandle< L1CaloEtScale > HfRingScale; - iE.get< L1HfRingEtScaleRcd >().get( HfRingScale ); - m_params->setHfRingScale(*HfRingScale); + //edm::ESHandle< L1CaloEtScale > jetScale ; + //iE.get< L1JetEtScaleRcd >().get( jetScale ) ; //m_params->setEgLsb(emScale->linearLsb()); diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/JetCalibrationMethods.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/JetCalibrationMethods.cc index a00e538d94065..3dbafaab81d90 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/JetCalibrationMethods.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/JetCalibrationMethods.cc @@ -9,11 +9,15 @@ namespace l1t { + bool compareCorrJets (l1t::Jet m, l1t::Jet n){ + return (m.hwPt() < n.hwPt() ); + } + void JetCalibration(std::vector * uncalibjets, std::vector jetCalibrationParams, std::vector * jets, std::string jetCalibrationType, - double jetLSB) + double jetLSB) { for (std::vector::const_iterator uncalibjet = uncalibjets->begin(); uncalibjet != uncalibjets->end(); ++uncalibjet){ @@ -23,26 +27,34 @@ namespace l1t { jets->push_back(corrjets); continue; } - + if (jetCalibrationType == "Stage1JEC") { int jetPt = (uncalibjet->hwPt())*jetLSB; // correction factors are parameterized as functions of physical pt int jetPhi = uncalibjet->hwPhi(); int jetEta = uncalibjet->hwEta(); int jetQual = uncalibjet->hwQual(); double jpt = 0.0; - + double alpha = jetCalibrationParams[2*jetEta + 0]; //Scale factor (See jetSF_cfi.py) double gamma = ((jetCalibrationParams[2*jetEta + 1])); //Offset - + jpt = jetPt*alpha+gamma; unsigned int corjetET =(int) (jpt/jetLSB); - + ROOT::Math::LorentzVector > *jetLorentz = new ROOT::Math::LorentzVector >(); l1t::Jet corrjets(*jetLorentz, corjetET, jetEta, jetPhi, jetQual); - + jets->push_back(corrjets); } + } + + std::sort(jets->begin(), jets->end(), compareCorrJets); + std::reverse(jets->begin(), jets->end()); } } + + + + diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/JetFinderMethods.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/JetFinderMethods.cc index 76ddf00ef5b4c..bcbdff84216dc 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/JetFinderMethods.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/JetFinderMethods.cc @@ -4,6 +4,7 @@ // This file should contain the different algorithms used to find jets. // Currently the standard is the sliding window method, used by both // HI and PP. +// The sorting of the jets in pT order is handled here. #include "DataFormats/L1TCalorimeter/interface/CaloRegion.h" #include "DataFormats/L1Trigger/interface/Jet.h" @@ -26,6 +27,10 @@ namespace l1t { return diff; } + bool compareJets (l1t::Jet i, l1t::Jet j){ + return (i.hwPt() < j.hwPt() ); + } + void slidingWindowJetFinder(const int jetSeedThreshold, const std::vector * regions, std::vector * uncalibjets) { @@ -104,7 +109,23 @@ namespace l1t { unsigned int jetET = regionET + neighborN_et + neighborS_et + neighborE_et + neighborW_et + neighborNE_et + neighborSW_et + neighborSE_et + neighborNW_et; + /* + int jetPhi = region->hwPhi() * 4 + + ( - 2 * (neighborS_et + neighborSE_et + neighborSW_et) + + 2 * (neighborN_et + neighborNE_et + neighborNW_et) ) / jetET; + if(jetPhi < 0) { + } + else if(jetPhi >= ((int) N_JET_PHI)) { + jetPhi -= N_JET_PHI; + } + int jetEta = region->hwEta() * 4 + + ( - 2 * (neighborW_et + neighborNW_et + neighborSW_et) + + 2 * (neighborE_et + neighborNE_et + neighborSE_et) ) / jetET; + if(jetEta < 0) jetEta = 0; + if(jetEta >= ((int) N_JET_ETA)) jetEta = N_JET_ETA - 1; + */ + // Temporarily use the region granularity -- we will try to improve as above when code is debugged int jetPhi = region->hwPhi(); int jetEta = region->hwEta(); @@ -133,5 +154,254 @@ namespace l1t { uncalibjets->push_back(theJet); } } + + // // separate loops for the central jets at the edges of HF, composed of 6 regions only. + // for(std::vector::const_iterator region = regions->begin(); region != regions->end(); region++) { + // double regionET = region->hwPt(); + // // look at only the left eta wall + // if (region->hwEta() != 4) continue; + // if (regionET < jetSeedThreshold) continue; + // double neighborN_et = 0; + // double neighborS_et = 0; + // double neighborE_et = 0; + // //double neighborW_et = 0; + // double neighborNE_et = 0; + // //double neighborSW_et = 0; + // //double neighborNW_et = 0; + // double neighborSE_et = 0; + // unsigned int nNeighbors = 0; + // for(std::vector::const_iterator neighbor = regions->begin(); neighbor != regions->end(); neighbor++) { + + // double neighborET = neighbor->hwPt(); //regionPhysicalEt(*neighbor); + // if(deltaGctPhi(*region, *neighbor) == 1 && + // (region->hwEta() ) == neighbor->hwEta()) { + // neighborN_et = neighborET; + // nNeighbors++; + // continue; + // } + // else if(deltaGctPhi(*region, *neighbor) == -1 && + // (region->hwEta() ) == neighbor->hwEta()) { + // neighborS_et = neighborET; + // nNeighbors++; + // continue; + // } + // else if(deltaGctPhi(*region, *neighbor) == 0 && + // (region->hwEta() + 1) == neighbor->hwEta()) { + // neighborE_et = neighborET; + // nNeighbors++; + // continue; + // } + // // else if(deltaGctPhi(*region, *neighbor) == 0 && + // // (region->hwEta() - 1) == neighbor->hwEta()) { + // // neighborW_et = neighborET; + // // nNeighbors++; + // // continue; + // // } + // else if(deltaGctPhi(*region, *neighbor) == 1 && + // (region->hwEta() + 1) == neighbor->hwEta()) { + // neighborNE_et = neighborET; + // nNeighbors++; + // continue; + // } + // // else if(deltaGctPhi(*region, *neighbor) == -1 && + // // (region->hwEta() - 1) == neighbor->hwEta()) { + // // neighborSW_et = neighborET; + // // nNeighbors++; + // // continue; + // // } + // // else if(deltaGctPhi(*region, *neighbor) == 1 && + // // (region->hwEta() - 1) == neighbor->hwEta()) { + // // neighborNW_et = neighborET; + // // nNeighbors++; + // // continue; + // // } + // else if(deltaGctPhi(*region, *neighbor) == -1 && + // (region->hwEta() + 1) == neighbor->hwEta()) { + // neighborSE_et = neighborET; + // nNeighbors++; + // continue; + // } + // } + // if(regionET > neighborN_et && + // //regionET > neighborNW_et && + // //regionET > neighborW_et && + // //regionET > neighborSW_et && + // regionET >= neighborNE_et && + // regionET >= neighborE_et && + // regionET >= neighborSE_et && + // regionET >= neighborS_et) { + // unsigned int jetET = regionET + + // neighborN_et + neighborS_et + neighborE_et + /*neighborW_et +*/ + // neighborNE_et + /*neighborSW_et +*/ neighborSE_et;// + neighborNW_et; + // /* + // int jetPhi = region->hwPhi() * 4 + + // ( - 2 * (neighborS_et + neighborSE_et + neighborSW_et) + // + 2 * (neighborN_et + neighborNE_et + neighborNW_et) ) / jetET; + // if(jetPhi < 0) { + + // } + // else if(jetPhi >= ((int) N_JET_PHI)) { + // jetPhi -= N_JET_PHI; + // } + // int jetEta = region->hwEta() * 4 + + // ( - 2 * (neighborW_et + neighborNW_et + neighborSW_et) + // + 2 * (neighborE_et + neighborNE_et + neighborSE_et) ) / jetET; + // if(jetEta < 0) jetEta = 0; + // if(jetEta >= ((int) N_JET_ETA)) jetEta = N_JET_ETA - 1; + // */ + // // Temporarily use the region granularity -- we will try to improve as above when code is debugged + // int jetPhi = region->hwPhi(); + // int jetEta = region->hwEta(); + + // bool neighborCheck = (nNeighbors == 5); + // // On the eta edge we only expect 5 neighbors + // // if (!neighborCheck && (jetEta == 0 || jetEta == 21) && nNeighbors == 5) + // // neighborCheck = true; + + // if (!neighborCheck) { + // std::cout << "phi: " << jetPhi << " eta: " << jetEta << " n: " << nNeighbors << std::endl; + // assert(false); + // } + + // const bool forward = false; //by definition + // int jetQual = 0; + // if(forward) + // jetQual |= 0x2; + + // ROOT::Math::LorentzVector > *jetLorentz = + // new ROOT::Math::LorentzVector >(); + // l1t::Jet theJet(*jetLorentz, jetET, jetEta, jetPhi, jetQual); + // //l1t::Jet theJet(0, jetET, jetEta, jetPhi); + + // jets->push_back(theJet); + // } + // } + + // // separate loops for the central jets at the edges of HF, composed of 6 regions only. + // for(std::vector::const_iterator region = regions->begin(); region != regions->end(); region++) { + // double regionET = region->hwPt(); + // // look at only the right eta wall + // if (region->hwEta() != 17) continue; + // if (regionET < jetSeedThreshold) continue; + // double neighborN_et = 0; + // double neighborS_et = 0; + // //double neighborE_et = 0; + // double neighborW_et = 0; + // //double neighborNE_et = 0; + // double neighborSW_et = 0; + // double neighborNW_et = 0; + // //double neighborSE_et = 0; + // unsigned int nNeighbors = 0; + // for(std::vector::const_iterator neighbor = regions->begin(); neighbor != regions->end(); neighbor++) { + + // double neighborET = neighbor->hwPt(); //regionPhysicalEt(*neighbor); + // if(deltaGctPhi(*region, *neighbor) == 1 && + // (region->hwEta() ) == neighbor->hwEta()) { + // neighborN_et = neighborET; + // nNeighbors++; + // continue; + // } + // else if(deltaGctPhi(*region, *neighbor) == -1 && + // (region->hwEta() ) == neighbor->hwEta()) { + // neighborS_et = neighborET; + // nNeighbors++; + // continue; + // } + // // else if(deltaGctPhi(*region, *neighbor) == 0 && + // // (region->hwEta() + 1) == neighbor->hwEta()) { + // // neighborE_et = neighborET; + // // nNeighbors++; + // // continue; + // // } + // else if(deltaGctPhi(*region, *neighbor) == 0 && + // (region->hwEta() - 1) == neighbor->hwEta()) { + // neighborW_et = neighborET; + // nNeighbors++; + // continue; + // } + // // else if(deltaGctPhi(*region, *neighbor) == 1 && + // // (region->hwEta() + 1) == neighbor->hwEta()) { + // // neighborNE_et = neighborET; + // // nNeighbors++; + // // continue; + // // } + // else if(deltaGctPhi(*region, *neighbor) == -1 && + // (region->hwEta() - 1) == neighbor->hwEta()) { + // neighborSW_et = neighborET; + // nNeighbors++; + // continue; + // } + // else if(deltaGctPhi(*region, *neighbor) == 1 && + // (region->hwEta() - 1) == neighbor->hwEta()) { + // neighborNW_et = neighborET; + // nNeighbors++; + // continue; + // } + // // else if(deltaGctPhi(*region, *neighbor) == -1 && + // // (region->hwEta() + 1) == neighbor->hwEta()) { + // // neighborSE_et = neighborET; + // // nNeighbors++; + // // continue; + // // } + // } + // if(//regionET > neighborN_et && + // regionET > neighborNW_et && + // regionET > neighborW_et && + // regionET > neighborSW_et && + // //regionET >= neighborNE_et && + // //regionET >= neighborE_et && + // //regionET >= neighborSE_et && + // regionET >= neighborS_et) { + // unsigned int jetET = regionET + + // neighborN_et + neighborS_et + /*neighborE_et + */neighborW_et + + // /*neighborNE_et +*/ neighborSW_et + /*neighborSE_et + */neighborNW_et; + // /* + // int jetPhi = region->hwPhi() * 4 + + // ( - 2 * (neighborS_et + neighborSE_et + neighborSW_et) + // + 2 * (neighborN_et + neighborNE_et + neighborNW_et) ) / jetET; + // if(jetPhi < 0) { + + // } + // else if(jetPhi >= ((int) N_JET_PHI)) { + // jetPhi -= N_JET_PHI; + // } + // int jetEta = region->hwEta() * 4 + + // ( - 2 * (neighborW_et + neighborNW_et + neighborSW_et) + // + 2 * (neighborE_et + neighborNE_et + neighborSE_et) ) / jetET; + // if(jetEta < 0) jetEta = 0; + // if(jetEta >= ((int) N_JET_ETA)) jetEta = N_JET_ETA - 1; + // */ + // // Temporarily use the region granularity -- we will try to improve as above when code is debugged + // int jetPhi = region->hwPhi(); + // int jetEta = region->hwEta(); + + // bool neighborCheck = (nNeighbors == 5); + // // On the eta edge we only expect 5 neighbors + // // if (!neighborCheck && (jetEta == 0 || jetEta == 21) && nNeighbors == 5) + // // neighborCheck = true; + + // if (!neighborCheck) { + // std::cout << "phi: " << jetPhi << " eta: " << jetEta << " n: " << nNeighbors << std::endl; + // assert(false); + // } + + // const bool forward = false; //by definition + // int jetQual = 0; + // if(forward) + // jetQual |= 0x2; + + // ROOT::Math::LorentzVector > *jetLorentz = + // new ROOT::Math::LorentzVector >(); + // l1t::Jet theJet(*jetLorentz, jetET, jetEta, jetPhi, jetQual); + // //l1t::Jet theJet(0, jetET, jetEta, jetPhi); + + // jets->push_back(theJet); + // } + // } + + //the jets should be sorted, highest pT first. + // do not truncate the jet list, GT converter handles that + std::sort(uncalibjets->begin(), uncalibjets->end(), compareJets); + std::reverse(uncalibjets->begin(), uncalibjets->end()); } } diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2EtSumAlgorithmImpPP.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2EtSumAlgorithmImpPP.cc index c95409c1f0c27..a2b785a3905cc 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2EtSumAlgorithmImpPP.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2EtSumAlgorithmImpPP.cc @@ -8,7 +8,6 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "L1Trigger/L1TCalorimeter/interface/Stage1Layer2EtSumAlgorithmImp.h" #include "L1Trigger/L1TCalorimeter/interface/PUSubtractionMethods.h" -#include "L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h" #include "DataFormats/L1Trigger/interface/EtSum.h" #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h" @@ -17,7 +16,7 @@ l1t::Stage1Layer2EtSumAlgorithmImpPP::Stage1Layer2EtSumAlgorithmImpPP(CaloParams regionETCutForHT=params->regionETCutForHT(); regionETCutForMET=params->regionETCutForMET(); minGctEtaForSums=params->minGctEtaForSums(); - maxGctEtaForSums=params->maxGctEtaForSums(); + maxGctEtaForSums=params->maxGctEtaForSums(); egLsb=params_->egLsb(); jetLsb=params_->jetLsb(); @@ -59,8 +58,8 @@ void l1t::Stage1Layer2EtSumAlgorithmImpPP::processEvent(const std::vector *subRegions = new std::vector(); - - //Region Correction will return uncorrected subregions if + + //Region Correction will return uncorrected subregions if //regionPUSType is set to None in the config RegionCorrection(regions, EMCands, subRegions, regionPUSParams, regionPUSType); @@ -105,13 +104,10 @@ void l1t::Stage1Layer2EtSumAlgorithmImpPP::processEvent(const std::vector *preGtEtSums = new std::vector(); - - preGtEtSums->push_back(etMiss); - preGtEtSums->push_back(htMiss); - preGtEtSums->push_back(etTot); - preGtEtSums->push_back(htTot); - - EtSumToGtScales(params_, preGtEtSums, etsums); + etsums->push_back(etMiss); + etsums->push_back(htMiss); + etsums->push_back(etTot); + etsums->push_back(htTot); } + diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2JetAlgorithmImpHI.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2JetAlgorithmImpHI.cc index c76b79852e7b8..ab2b5d4895acd 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2JetAlgorithmImpHI.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2JetAlgorithmImpHI.cc @@ -10,39 +10,32 @@ #include "L1Trigger/L1TCalorimeter/interface/Stage1Layer2JetAlgorithmImp.h" #include "L1Trigger/L1TCalorimeter/interface/JetFinderMethods.h" #include "L1Trigger/L1TCalorimeter/interface/PUSubtractionMethods.h" -#include "L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h" + +// Taken from UCT code. Might not be appropriate. Refers to legacy L1 objects. +#include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h" + +//#include "DataFormats/Candidate/interface/LeafCandidate.h" +//#include using namespace std; using namespace l1t; Stage1Layer2JetAlgorithmImpHI::Stage1Layer2JetAlgorithmImpHI(CaloParams* params) : params_(params) { + double jetLsb=params_->jetLsb(); jetSeedThreshold= floor( params_->jetSeedThreshold()/jetLsb + 0.5); } +//: regionLSB_(0.5) {} Stage1Layer2JetAlgorithmImpHI::~Stage1Layer2JetAlgorithmImpHI(){}; void Stage1Layer2JetAlgorithmImpHI::processEvent(const std::vector & regions, const std::vector & EMCands, - std::vector * jets){ + std::vector * jets){ std::vector *subRegions = new std::vector(); - std::vector *preGtJets = new std::vector(); - HICaloRingSubtraction(regions, subRegions); - slidingWindowJetFinder(jetSeedThreshold, subRegions, preGtJets); - JetToGtScales(params_, preGtJets, jets); + slidingWindowJetFinder(jetSeedThreshold, subRegions, jets); delete subRegions; - delete preGtJets; - - //the jets should be sorted, highest pT first. - // do not truncate the tau list, GT converter handles that - auto comp = [&](l1t::Jet i, l1t::Jet j)-> bool { - return (i.hwPt() < j.hwPt() ); - }; - - std::sort(jets->begin(), jets->end(), comp); - std::reverse(jets->begin(), jets->end()); - } diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2JetAlgorithmImpPP.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2JetAlgorithmImpPP.cc index 546f24a3329e0..b851696fe8188 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2JetAlgorithmImpPP.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2JetAlgorithmImpPP.cc @@ -11,7 +11,11 @@ #include "L1Trigger/L1TCalorimeter/interface/JetFinderMethods.h" #include "L1Trigger/L1TCalorimeter/interface/PUSubtractionMethods.h" #include "L1Trigger/L1TCalorimeter/interface/JetCalibrationMethods.h" -#include "L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h" + +// Taken from UCT code. Might not be appropriate. Refers to legacy L1 objects. +#include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h" + +//#include "DataFormats/Candidate/interface/LeafCandidate.h" using namespace std; using namespace l1t; @@ -25,6 +29,7 @@ Stage1Layer2JetAlgorithmImpPP::Stage1Layer2JetAlgorithmImpPP(CaloParams* params) jetCalibrationType = params_->jetCalibrationType(); jetCalibrationParams = params_->jetCalibrationParams(); } +//: regionLSB_(0.5) {} Stage1Layer2JetAlgorithmImpPP::~Stage1Layer2JetAlgorithmImpPP(){}; @@ -36,33 +41,27 @@ void Stage1Layer2JetAlgorithmImpPP::processEvent(const std::vector * subRegions = new std::vector(); std::vector * uncalibjets = new std::vector(); - std::vector * preGtJets = new std::vector(); - - //Region Correction will return uncorrected subregions + + //Region Correction will return uncorrected subregions //if regionPUSType is set to None in the config RegionCorrection(regions, EMCands, subRegions, regionPUSParams, regionPUSType); - - + + slidingWindowJetFinder(jetSeedThreshold, subRegions, uncalibjets); //will return jets with no response corrections //if jetCalibrationType is set to None in the config - JetCalibration(uncalibjets, jetCalibrationParams, preGtJets, jetCalibrationType, jetLsb); + JetCalibration(uncalibjets, jetCalibrationParams, jets, jetCalibrationType, jetLsb); - // takes input jets (using region scales/eta) and outputs jets using Gt scales/eta - JetToGtScales(params_, preGtJets, jets); delete subRegions; delete uncalibjets; - delete preGtJets; - //the jets should be sorted, highest pT first. - // do not truncate the tau list, GT converter handles that - auto comp = [&](l1t::Jet i, l1t::Jet j)-> bool { - return (i.hwPt() < j.hwPt() ); - }; + // std::vector::const_iterator incell; + // for (incell = regions.begin(); incell != regions.end(); ++incell){ + // //do nothing for now + // } - std::sort(jets->begin(), jets->end(), comp); - std::reverse(jets->begin(), jets->end()); } + diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2MainProcessorFirmwareImp1.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2MainProcessorFirmwareImp1.cc index a118aed122e35..ede4dd767059e 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2MainProcessorFirmwareImp1.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2MainProcessorFirmwareImp1.cc @@ -32,15 +32,19 @@ void Stage1Layer2MainProcessorFirmwareImp1::processEvent(const std::vector HI algo - m_tauAlgo = new Stage1Layer2SingleTrackHI(m_db); //fwv=1 => single track seed + m_tauAlgo = new Stage1Layer2SingleTrackHI(/*m_db*/); } else if( m_fwv == 2 ) { //PP algorithm m_egAlgo = new Stage1Layer2EGammaAlgorithmImpPP(m_db); m_sumAlgo = new Stage1Layer2EtSumAlgorithmImpPP(m_db); m_jetAlgo = new Stage1Layer2JetAlgorithmImpPP(m_db); //fwv =2 => PP algo - m_tauAlgo = new Stage1Layer2TauAlgorithmImpPP(m_db); + m_tauAlgo = new Stage1Layer2TauAlgorithmImpPP(m_db); } + // else if( m_fwv.firmwareVersion() == 3 ) + // { + // //m_tauAlgo = new Stage1Layer2SingleTrackHI(/*m_db*/); + // } else{ // undefined fwv version edm::LogError("FWVersionError") << "Undefined firmware version passed to Stage1Layer2MainProcessorFirmwareImp1" << std::endl; diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2SingleTrackHI.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2SingleTrackHI.cc index 28917e7ee5a21..f0f0950dd5804 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2SingleTrackHI.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2SingleTrackHI.cc @@ -1,39 +1,25 @@ -// Stage1Layer2SingleTrackHI.cc -// Authors: Michael Northup -// Alex Barbieri -// -// This is a special-purpose single-track seed trigger which uses the -// Tau channel to communicate with GT. Be wary of any naming scheme -// because we are masquerading as both a tau and track trigger when -// we are really just looking for the hottest region. - - #include "L1Trigger/L1TCalorimeter/interface/Stage1Layer2TauAlgorithmImp.h" #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h" #include "L1Trigger/L1TCalorimeter/interface/PUSubtractionMethods.h" -#include "L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h" -l1t::Stage1Layer2SingleTrackHI::Stage1Layer2SingleTrackHI(CaloParams* params) : params_(params) {} +l1t::Stage1Layer2SingleTrackHI::Stage1Layer2SingleTrackHI() {} l1t::Stage1Layer2SingleTrackHI::~Stage1Layer2SingleTrackHI(){}; void findRegions(const std::vector * sr, std::vector * t); -void l1t::Stage1Layer2SingleTrackHI::processEvent(const std::vector & clusters, - const std::vector & regions, - const std::vector * jets, - std::vector * taus) +void l1t::Stage1Layer2SingleTrackHI::processEvent(/*const std::vector & clusters,*/ + const std::vector & clusters, + const std::vector & regions, + const std::vector * jets, + std::vector * taus) { - std::vector *subRegions = new std::vector(); - std::vector *preGtTaus = new std::vector(); + std::vector *subRegions = new std::vector(); + HICaloRingSubtraction(regions, subRegions); + findRegions(subRegions, taus); - HICaloRingSubtraction(regions, subRegions); - findRegions(subRegions, preGtTaus); - TauToGtScales(params_, preGtTaus, taus); - - delete subRegions; - delete preGtTaus; + delete subRegions; } void findRegions(const std::vector * sr, std::vector * t) @@ -45,7 +31,6 @@ void findRegions(const std::vector * sr, std::vector for(std::vector::const_iterator region = sr->begin(); region != sr->end(); region++) { int regionET = region->hwPt(); - if((region->hwEta() < 4) || (region->hwEta() > 17)) continue; if (regionET > regionETMax) { regionETMax = regionET; @@ -53,7 +38,6 @@ void findRegions(const std::vector * sr, std::vector regionETMaxPhi = region->hwPhi(); } } - ROOT::Math::LorentzVector > *TauLorentz = new ROOT::Math::LorentzVector >(); l1t::Tau taucand(*TauLorentz,regionETMax,regionETMaxEta,regionETMaxPhi); diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2TauAlgorithmImpPP.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2TauAlgorithmImpPP.cc index 696e86abb83ee..7cce1d48a03bf 100644 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2TauAlgorithmImpPP.cc +++ b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/firmware/Stage1Layer2TauAlgorithmImpPP.cc @@ -13,7 +13,6 @@ #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h" #include "L1Trigger/L1TCalorimeter/interface/PUSubtractionMethods.h" #include "L1Trigger/L1TCalorimeter/interface/JetFinderMethods.h" -#include "L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h" using namespace std; @@ -41,39 +40,38 @@ Stage1Layer2TauAlgorithmImpPP::~Stage1Layer2TauAlgorithmImpPP(){}; -void l1t::Stage1Layer2TauAlgorithmImpPP::processEvent(const std::vector & EMCands, - const std::vector & regions, +void l1t::Stage1Layer2TauAlgorithmImpPP::processEvent(const std::vector & EMCands, + const std::vector & regions, const std::vector * jets, std::vector * taus) { std::vector *subRegions = new std::vector(); - - //Region Correction will return uncorrected subregions if + + //Region Correction will return uncorrected subregions if //regionPUSType is set to None in the config RegionCorrection(regions, EMCands, subRegions, regionPUSParams, regionPUSType); - + // ----- need to cluster jets in order to compute jet isolation ---- std::vector *unCorrJets = new std::vector(); slidingWindowJetFinder(jetSeedThreshold, subRegions, unCorrJets); - std::vector *preGtTaus = new std::vector(); for(CaloRegionBxCollection::const_iterator region = subRegions->begin(); region != subRegions->end(); region++) { - int regionEt = region->hwPt(); + int regionEt = region->hwPt(); if(regionEt < tauSeedThreshold) continue; - + double isolation; - int associatedSecondRegionEt = + int associatedSecondRegionEt = AssociatedSecondRegionEt(region->hwEta(), region->hwPhi(), *subRegions, isolation); - + int tauEt=regionEt; if(do2x1Algo && associatedSecondRegionEt>tauSeedThreshold) tauEt +=associatedSecondRegionEt; @@ -87,20 +85,18 @@ void l1t::Stage1Layer2TauAlgorithmImpPP::processEvent(const std::vectorhwEta(), region->hwPhi(), *unCorrJets); // if (tauEt >200) // cout << "tauET: " << tauEt << " tauETA: " << region->hwEta() << " tauPHI: " << region->hwPhi() - // << " jetIso: " << jetIsolation << " Cut: " << tauRelativeJetIsolationCut + // << " jetIso: " << jetIsolation << " Cut: " << tauRelativeJetIsolationCut // << " Seed Threshold: " << tauSeedThreshold << endl; - if( tauEt >0 && (jetIsolation < tauRelativeJetIsolationCut || tauEt > switchOffTauIso)) - preGtTaus->push_back(theTau); + if( tauEt >0 && (jetIsolation < tauRelativeJetIsolationCut || tauEt > switchOffTauIso)) + taus->push_back(theTau); } - TauToGtScales(params_, preGtTaus, taus); - //the taus should be sorted, highest pT first. // do not truncate the tau list, GT converter handles that auto comp = [&](l1t::Tau i, l1t::Tau j)-> bool { - return (i.hwPt() < j.hwPt() ); + return (i.hwPt() < j.hwPt() ); }; std::sort(taus->begin(), taus->end(), comp); @@ -117,7 +113,7 @@ void l1t::Stage1Layer2TauAlgorithmImpPP::processEvent(const std::vector & regions, + const std::vector & regions, double& isolation) const { int highestNeighborEt = 0; isolation = 0; @@ -128,14 +124,14 @@ int l1t::Stage1Layer2TauAlgorithmImpPP::AssociatedSecondRegionEt(int ieta, int i int regionPhi = region->hwPhi(); int regionEta = region->hwEta(); unsigned int deltaPhi = iphi - regionPhi; - if (std::abs(deltaPhi) == L1CaloRegionDetId::N_PHI-1) + if (std::abs(deltaPhi) == L1CaloRegionDetId::N_PHI-1) deltaPhi = -deltaPhi/std::abs(deltaPhi); //18 regions in phi unsigned int deltaEta = std::abs(ieta - regionEta); if ((deltaPhi + deltaEta) > 0 && deltaPhi < 2 && deltaEta < 2) { - int regionEt = region->hwPt(); + int regionEt = region->hwPt(); isolation += regionEt; if (regionEt > highestNeighborEt) highestNeighborEt = regionEt; } @@ -157,7 +153,7 @@ double l1t::Stage1Layer2TauAlgorithmImpPP::JetIsolation(int et, int ieta, int ip jet != jets.end(); jet++) { if (ieta==jet->hwEta() && iphi==jet->hwPhi()){ - + //if (et >200) // cout << "ISOL: tauET: " << et << " jetET: " << jet->hwPt() << endl; diff --git a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/legacyGtHelper.cc b/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/legacyGtHelper.cc deleted file mode 100644 index 7af6fce973a85..0000000000000 --- a/branches/usePFclusteringInRegionsForMuonsBackUp/L1Trigger/L1TCalorimeter/src/legacyGtHelper.cc +++ /dev/null @@ -1,91 +0,0 @@ -// legacyGtHelper.cc -// Authors: Alex Barbieri -// -// This is a collection of helper methods to make sure that -// the objects passed to the legacy GT are using the proper -// Et scales and eta coordinates. - -#include "L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h" - -const unsigned int gtEta(const unsigned int iEta); - -namespace l1t { - - void JetToGtScales(CaloParams *params, - const std::vector * input, - std::vector *output){ - - for(std::vector::const_iterator itJet = input->begin(); - itJet != input->end(); ++itJet){ - const unsigned newEta = gtEta(itJet->hwEta()); - const uint16_t rankPt = params->jetScale().rank((uint16_t)itJet->hwPt()); - - ROOT::Math::LorentzVector > *lorentz = - new ROOT::Math::LorentzVector >(); - - l1t::Jet gtJet(*lorentz, rankPt, newEta, itJet->hwPhi(), itJet->hwQual()); - output->push_back(gtJet); - } - } - - void EGammaToGtScales(CaloParams *params, - const std::vector * input, - std::vector *output){ - - for(std::vector::const_iterator itEGamma = input->begin(); - itEGamma != input->end(); ++itEGamma){ - const unsigned newEta = gtEta(itEGamma->hwEta()); - const uint16_t rankPt = params->emScale().rank((uint16_t)itEGamma->hwPt()); - - ROOT::Math::LorentzVector > *lorentz = - new ROOT::Math::LorentzVector >(); - - l1t::EGamma gtEGamma(*lorentz, rankPt, newEta, itEGamma->hwPhi(), - itEGamma->hwQual(), itEGamma->hwIso()); - output->push_back(gtEGamma); - } - } - - void TauToGtScales(CaloParams *params, - const std::vector * input, - std::vector *output){ - for(std::vector::const_iterator itTau = input->begin(); - itTau != input->end(); ++itTau){ - const unsigned newEta = gtEta(itTau->hwEta()); - const uint16_t rankPt = params->jetScale().rank((uint16_t)itTau->hwPt()); - - ROOT::Math::LorentzVector > *lorentz = - new ROOT::Math::LorentzVector >(); - - l1t::Tau gtTau(*lorentz, rankPt, newEta, itTau->hwPhi(), itTau->hwQual()); - output->push_back(gtTau); - } - } - - void EtSumToGtScales(CaloParams *params, - const std::vector * input, - std::vector *output){ - for(std::vector::const_iterator itEtSum = input->begin(); - itEtSum != input->end(); ++itEtSum){ - - uint16_t rankPt; - rankPt = params->emScale().rank((uint16_t)itEtSum->hwPt()); - if (EtSum::EtSumType::kMissingHt == itEtSum->getType()) - rankPt = params->HtMissScale().rank((uint16_t)itEtSum->hwPt()); - - ROOT::Math::LorentzVector > *lorentz = - new ROOT::Math::LorentzVector >(); - - l1t::EtSum gtEtSum(*lorentz, itEtSum->getType(), rankPt, 0, - itEtSum->hwPhi(), itEtSum->hwQual()); - - output->push_back(gtEtSum); - } - } -} - -const unsigned int gtEta(const unsigned int iEta) -{ - unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11); - return (((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0)); -}