CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
Phase1L1TJetProducer Class Reference

#include <L1Trigger/L1CaloTrigger/plugin/Phase1L1TJetProducer.cc>

Inheritance diagram for Phase1L1TJetProducer:
edm::one::EDProducer<> edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 Phase1L1TJetProducer (const edm::ParameterSet &)
 
template<class Handle >
std::vector< std::vector
< edm::Ptr< reco::Candidate > > > 
prepareInputsIntoRegions (const Handle triggerPrimitives)
 
 ~Phase1L1TJetProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector
< edm::ProductResolverIndex >
const & 
putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

reco::CaloJet buildJetFromSeed (const std::tuple< int, int > &seed) const
 
std::vector< reco::CaloJetbuildJetsFromSeeds (const std::vector< std::tuple< int, int >> &seeds) const
 
std::vector< reco::CaloJetbuildJetsFromSeedsWithPUSubtraction (const std::vector< std::tuple< int, int >> &seeds, bool killZeroPt) const
 
l1t::EtSum computeMET (const double etaCut, l1t::EtSum::EtSumType sumType) const
 
template<class Container >
void fillCaloGrid (TH2F &caloGrid, const Container &triggerPrimitives, const unsigned int regionIndex)
 
std::vector< std::tuple< int,
int > > 
findSeeds (float seedThreshold) const
 Finds the seeds in the caloGrid, seeds are saved in a vector that contain the index in the TH2F of each seed. More...
 
std::pair< float, float > getCandidateDigiEtaPhi (const float eta, const float phi, const unsigned int regionIndex) const
 
unsigned int getRegionIndex (const unsigned int phiRegion, const unsigned int etaRegion) const
 
float getTowerEnergy (int iEta, int iPhi) const
 Get the energy of a certain tower while correctly handling phi periodicity in case of overflow. More...
 
template<class Handle >
std::vector< std::vector
< reco::CandidatePtr > > 
prepareInputsIntoRegions (const Handle triggerPrimitives)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
std::pair< double, double > regionEtaPhiLowEdges (const unsigned int regionIndex) const
 
std::pair< double, double > regionEtaPhiUpEdges (const unsigned int regionIndex) const
 
void subtract9x9Pileup (reco::CaloJet &jet) const
 
bool trimTower (const int etaIndex, const int phiIndex) const
 

Private Attributes

std::unique_ptr< TH2F > caloGrid_
 
std::vector< double > cosPhi_
 
std::vector< double > etaBinning_
 
double etalsb_
 
std::vector< double > etaRegionEdges_
 
edm::EDGetTokenT< edm::View
< reco::Candidate > > 
inputCollectionTag_
 
unsigned int jetIEtaSize_
 
unsigned int jetIPhiSize_
 
unsigned int maxInputsPerRegion_
 
double metAbsEtaCut_
 
double metHFAbsEtaCut_
 
size_t nBinsEta_
 
unsigned int nBinsPhi_
 
std::string outputCollectionName_
 
double phiLow_
 
double philsb_
 
std::vector< double > phiRegionEdges_
 
double phiUp_
 
double ptlsb_
 
bool puSubtraction_
 
double seedPtThreshold_
 
std::vector< double > sinPhi_
 
bool trimmedGrid_
 
bool vetoZeroPt_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: Produces jets with a phase-1 like sliding window algorithm using a collection of reco::Candidates in input. Also calculates MET from the histogram used to find the jets.

INPUT PARAMETERS ***
etaBinning: vdouble with eta binning (allows non-homogeneous binning in eta)
nBinsPhi: uint32, number of bins in phi
phiLow: double, min phi (typically -pi)
phiUp: double, max phi (typically +pi)
jetIEtaSize: uint32, jet cluster size in ieta
jetIPhiSize: uint32, jet cluster size in iphi
trimmedGrid: Flag (bool) to remove three bins in each corner of grid in jet finding
seedPtThreshold: double, threshold of the seed tower
pt/eta/philsb : lsb of quantities used in firmware implementation
puSubtraction: bool, runs chunky doughnut pile-up subtraction, 9x9 jet only
eta/phiRegionEdges: Boundaries of the input (PF) regions
maxInputsPerRegion: Truncate number of inputes per input (PF) region
sin/cosPhi: Value of sin/cos phi in the middle of each bin of the grid.
met{HF}AbsETaCut: Eta selection of input candidates for calculation of MET
outputCollectionName: string, tag for the output collection
vetoZeroPt: bool, controls whether jets with 0 pt should be save. 
It matters if PU is ON, as you can get negative or zero pt jets after it.
inputCollectionTag: inputtag, collection of reco::candidates used as input to the algo

Definition at line 63 of file Phase1L1TJetProducer.cc.

Constructor & Destructor Documentation

Phase1L1TJetProducer::Phase1L1TJetProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 166 of file Phase1L1TJetProducer.cc.

References edm::ParameterSet::getParameter().

167  : // getting configuration settings
169  consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("inputCollectionTag"))},
170  etaBinning_(iConfig.getParameter<std::vector<double>>("etaBinning")),
171  nBinsEta_(etaBinning_.size() - 1),
172  nBinsPhi_(iConfig.getParameter<unsigned int>("nBinsPhi")),
173  phiLow_(iConfig.getParameter<double>("phiLow")),
174  phiUp_(iConfig.getParameter<double>("phiUp")),
175  jetIEtaSize_(iConfig.getParameter<unsigned int>("jetIEtaSize")),
176  jetIPhiSize_(iConfig.getParameter<unsigned int>("jetIPhiSize")),
177  trimmedGrid_(iConfig.getParameter<bool>("trimmedGrid")),
178  seedPtThreshold_(iConfig.getParameter<double>("seedPtThreshold")),
179  ptlsb_(iConfig.getParameter<double>("ptlsb")),
180  philsb_(iConfig.getParameter<double>("philsb")),
181  etalsb_(iConfig.getParameter<double>("etalsb")),
182  puSubtraction_(iConfig.getParameter<bool>("puSubtraction")),
183  vetoZeroPt_(iConfig.getParameter<bool>("vetoZeroPt")),
184  etaRegionEdges_(iConfig.getParameter<std::vector<double>>("etaRegions")),
185  phiRegionEdges_(iConfig.getParameter<std::vector<double>>("phiRegions")),
186  maxInputsPerRegion_(iConfig.getParameter<unsigned int>("maxInputsPerRegion")),
187  sinPhi_(iConfig.getParameter<std::vector<double>>("sinPhi")),
188  cosPhi_(iConfig.getParameter<std::vector<double>>("cosPhi")),
189  metAbsEtaCut_(iConfig.getParameter<double>("metAbsEtaCut")),
190  metHFAbsEtaCut_(iConfig.getParameter<double>("metHFAbsEtaCut")),
191  outputCollectionName_(iConfig.getParameter<std::string>("outputCollectionName")) {
192  caloGrid_ =
193  std::make_unique<TH2F>("caloGrid", "Calorimeter grid", nBinsEta_, etaBinning_.data(), nBinsPhi_, phiLow_, phiUp_);
194  caloGrid_->GetXaxis()->SetTitle("#eta");
195  caloGrid_->GetYaxis()->SetTitle("#phi");
196  produces<std::vector<reco::CaloJet>>(outputCollectionName_).setBranchAlias(outputCollectionName_);
197  produces<std::vector<l1t::EtSum>>(outputCollectionName_ + "MET").setBranchAlias(outputCollectionName_ + "MET");
198 }
std::vector< double > phiRegionEdges_
std::vector< double > cosPhi_
std::vector< double > sinPhi_
std::vector< double > etaBinning_
std::unique_ptr< TH2F > caloGrid_
std::vector< double > etaRegionEdges_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::View< reco::Candidate > > inputCollectionTag_
Phase1L1TJetProducer::~Phase1L1TJetProducer ( )
override

Definition at line 200 of file Phase1L1TJetProducer.cc.

200 {}

Member Function Documentation

reco::CaloJet Phase1L1TJetProducer::buildJetFromSeed ( const std::tuple< int, int > &  seed) const
private

Definition at line 362 of file Phase1L1TJetProducer.cc.

References caloGrid_, getTowerEnergy(), metsig::jet, jetIEtaSize_, jetIPhiSize_, fileCollector::seed, reco::LeafCandidate::setP4(), trimmedGrid_, and trimTower().

Referenced by buildJetsFromSeeds(), and buildJetsFromSeedsWithPUSubtraction().

362  {
363  int iEta = std::get<0>(seed);
364  int iPhi = std::get<1>(seed);
365 
366  int etaHalfSize = (int)jetIEtaSize_ / 2;
367  int phiHalfSize = (int)jetIPhiSize_ / 2;
368 
369  float ptSum = 0;
370  // Scanning through the grid centered on the seed
371  for (int etaIndex = -etaHalfSize; etaIndex <= etaHalfSize; etaIndex++) {
372  for (int phiIndex = -phiHalfSize; phiIndex <= phiHalfSize; phiIndex++) {
373  if (trimmedGrid_) {
374  if (trimTower(etaIndex, phiIndex))
375  continue;
376  }
377  ptSum += getTowerEnergy(iEta + etaIndex, iPhi + phiIndex);
378  }
379  }
380 
381  // Creating a jet with eta phi centered on the seed and momentum equal to the sum of the pt of the components
383  ptVector.SetPt(ptSum);
384  ptVector.SetEta(caloGrid_->GetXaxis()->GetBinCenter(iEta));
385  ptVector.SetPhi(caloGrid_->GetYaxis()->GetBinCenter(iPhi));
387  jet.setP4(ptVector);
388  return jet;
389 }
Jets made from CaloTowers.
Definition: CaloJet.h:27
bool trimTower(const int etaIndex, const int phiIndex) const
float getTowerEnergy(int iEta, int iPhi) const
Get the energy of a certain tower while correctly handling phi periodicity in case of overflow...
std::unique_ptr< TH2F > caloGrid_
void setP4(const LorentzVector &p4) final
set 4-momentum
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
std::vector< reco::CaloJet > Phase1L1TJetProducer::buildJetsFromSeeds ( const std::vector< std::tuple< int, int >> &  seeds) const
private

Definition at line 407 of file Phase1L1TJetProducer.cc.

References buildJetFromSeed(), metsig::jet, fwrapper::jets, fileCollector::seed, and DetachedQuadStep_cff::seeds.

Referenced by produce().

408  {
409  // For each seed take a grid centered on the seed of the size specified by the user
410  // Sum the pf in the grid, that will be the pt of the l1t jet. Eta and phi of the jet is taken from the seed.
411  std::vector<reco::CaloJet> jets;
412  for (const auto& seed : seeds) {
414  jets.push_back(jet);
415  }
416  return jets;
417 }
Jets made from CaloTowers.
Definition: CaloJet.h:27
vector< PseudoJet > jets
reco::CaloJet buildJetFromSeed(const std::tuple< int, int > &seed) const
std::vector< reco::CaloJet > Phase1L1TJetProducer::buildJetsFromSeedsWithPUSubtraction ( const std::vector< std::tuple< int, int >> &  seeds,
bool  killZeroPt 
) const
private

Definition at line 391 of file Phase1L1TJetProducer.cc.

References buildJetFromSeed(), metsig::jet, fwrapper::jets, reco::LeafCandidate::pt(), fileCollector::seed, DetachedQuadStep_cff::seeds, subtract9x9Pileup(), and vetoZeroPt_.

Referenced by produce().

392  {
393  // For each seed take a grid centered on the seed of the size specified by the user
394  // Sum the pf in the grid, that will be the pt of the l1t jet. Eta and phi of the jet is taken from the seed.
395  std::vector<reco::CaloJet> jets;
396  for (const auto& seed : seeds) {
398  subtract9x9Pileup(jet);
399  //killing jets with 0 pt
400  if ((vetoZeroPt_) && (jet.pt() <= 0))
401  continue;
402  jets.push_back(jet);
403  }
404  return jets;
405 }
Jets made from CaloTowers.
Definition: CaloJet.h:27
double pt() const final
transverse momentum
void subtract9x9Pileup(reco::CaloJet &jet) const
vector< PseudoJet > jets
reco::CaloJet buildJetFromSeed(const std::tuple< int, int > &seed) const
l1t::EtSum Phase1L1TJetProducer::computeMET ( const double  etaCut,
l1t::EtSum::EtSumType  sumType 
) const
private

Definition at line 573 of file Phase1L1TJetProducer.cc.

References caloGrid_, cosPhi_, mps_fire::i, DiDispStaMuonMonitor_cfi::pt, ptlsb_, sinPhi_, mathSSE::sqrt(), and pileupReCalc_HLTpaths::trunc.

Referenced by produce().

573  {
574  const auto lowEtaBin = caloGrid_->GetXaxis()->FindBin(-1.0 * etaCut);
575  const auto highEtaBin = caloGrid_->GetXaxis()->FindBin(etaCut) - 1;
576  const auto phiProjection = caloGrid_->ProjectionY("temp", lowEtaBin, highEtaBin);
577 
578  // Use digitised quantities when summing to improve agreement with firmware
579  int totalDigiPx{0};
580  int totalDigiPy{0};
581 
582  for (int i = 1; i < phiProjection->GetNbinsX() + 1; ++i) {
583  double pt = phiProjection->GetBinContent(i);
584  totalDigiPx += trunc(floor(pt / ptlsb_) * cosPhi_[i - 1]);
585  totalDigiPy += trunc(floor(pt / ptlsb_) * sinPhi_[i - 1]);
586  }
587 
588  double lMET = floor(sqrt(totalDigiPx * totalDigiPx + totalDigiPy * totalDigiPy)) * ptlsb_;
589 
590  math::PtEtaPhiMLorentzVector lMETVector(lMET, 0, acos(totalDigiPx / (lMET / ptlsb_)), 0);
591  l1t::EtSum lMETSum(lMETVector, sumType, 0, 0, 0, 0);
592  return lMETSum;
593 }
std::vector< double > cosPhi_
std::vector< double > sinPhi_
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
T sqrt(T t)
Definition: SSEVec.h:19
std::unique_ptr< TH2F > caloGrid_
template<class Container >
void Phase1L1TJetProducer::fillCaloGrid ( TH2F &  caloGrid,
const Container &  triggerPrimitives,
const unsigned int  regionIndex 
)
private

Definition at line 420 of file Phase1L1TJetProducer.cc.

References getCandidateDigiEtaPhi().

422  {
423  //Filling the calo grid with the primitives
424  for (const auto& primitiveIterator : triggerPrimitives) {
425  // Get digitised (floating point with reduced precision) eta and phi
426  std::pair<float, float> digi_EtaPhi =
427  getCandidateDigiEtaPhi(primitiveIterator->eta(), primitiveIterator->phi(), regionIndex);
428 
429  caloGrid.Fill(static_cast<float>(digi_EtaPhi.first),
430  static_cast<float>(digi_EtaPhi.second),
431  static_cast<float>(primitiveIterator->pt()));
432  }
433 }
std::pair< float, float > getCandidateDigiEtaPhi(const float eta, const float phi, const unsigned int regionIndex) const
void Phase1L1TJetProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 489 of file Phase1L1TJetProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, and M_PI.

489  {
491  desc.add<edm::InputTag>("inputCollectionTag", edm::InputTag("l1pfCandidates", "Puppi"));
492  desc.add<std::vector<double>>("etaBinning");
493  desc.add<unsigned int>("nBinsPhi", 72);
494  desc.add<double>("phiLow", -M_PI);
495  desc.add<double>("phiUp", M_PI);
496  desc.add<unsigned int>("jetIEtaSize", 7);
497  desc.add<unsigned int>("jetIPhiSize", 7);
498  desc.add<bool>("trimmedGrid", false);
499  desc.add<double>("seedPtThreshold", 5);
500  desc.add<double>("ptlsb", 0.25), desc.add<double>("philsb", 0.0043633231), desc.add<double>("etalsb", 0.0043633231),
501  desc.add<bool>("puSubtraction", false);
502  desc.add<string>("outputCollectionName", "UncalibratedPhase1L1TJetFromPfCandidates");
503  desc.add<bool>("vetoZeroPt", true);
504  desc.add<std::vector<double>>("etaRegions");
505  desc.add<std::vector<double>>("phiRegions");
506  desc.add<unsigned int>("maxInputsPerRegion", 18);
507  desc.add<std::vector<double>>("sinPhi");
508  desc.add<std::vector<double>>("cosPhi");
509  desc.add<double>("metAbsEtaCut", 3);
510  desc.add<double>("metHFAbsEtaCut", 5);
511  descriptions.add("Phase1L1TJetProducer", desc);
512 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define M_PI
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< std::tuple< int, int > > Phase1L1TJetProducer::findSeeds ( float  seedThreshold) const
private

Finds the seeds in the caloGrid, seeds are saved in a vector that contain the index in the TH2F of each seed.

Definition at line 307 of file Phase1L1TJetProducer.cc.

References caloGrid_, getTowerEnergy(), jetIEtaSize_, jetIPhiSize_, DetachedQuadStep_cff::seeds, trimmedGrid_, and trimTower().

Referenced by produce().

307  {
308  int nBinsX = caloGrid_->GetNbinsX();
309  int nBinsY = caloGrid_->GetNbinsY();
310 
311  std::vector<std::tuple<int, int>> seeds;
312 
313  int etaHalfSize = (int)jetIEtaSize_ / 2;
314  int phiHalfSize = (int)jetIPhiSize_ / 2;
315 
316  // for each point of the grid check if it is a local maximum
317  // to do so I take a point, and look if is greater than the points around it (in the 9x9 neighborhood)
318  // to prevent mutual exclusion, I check greater or equal for points above and right to the one I am considering (including the top-left point)
319  // to prevent mutual exclusion, I check greater for points below and left to the one I am considering (including the bottom-right point)
320 
321  for (int iPhi = 1; iPhi <= nBinsY; iPhi++) {
322  for (int iEta = 1; iEta <= nBinsX; iEta++) {
323  float centralPt = caloGrid_->GetBinContent(iEta, iPhi);
324  if (centralPt < seedThreshold)
325  continue;
326  bool isLocalMaximum = true;
327 
328  // Scanning through the grid centered on the seed
329  for (int etaIndex = -etaHalfSize; etaIndex <= etaHalfSize; etaIndex++) {
330  for (int phiIndex = -phiHalfSize; phiIndex <= phiHalfSize; phiIndex++) {
331  if (trimmedGrid_) {
332  if (trimTower(etaIndex, phiIndex))
333  continue;
334  }
335 
336  if ((etaIndex == 0) && (phiIndex == 0))
337  continue;
338  if (phiIndex > 0) {
339  if (phiIndex > -etaIndex) {
340  isLocalMaximum = ((isLocalMaximum) && (centralPt > getTowerEnergy(iEta + etaIndex, iPhi + phiIndex)));
341  } else {
342  isLocalMaximum = ((isLocalMaximum) && (centralPt >= getTowerEnergy(iEta + etaIndex, iPhi + phiIndex)));
343  }
344  } else {
345  if (phiIndex >= -etaIndex) {
346  isLocalMaximum = ((isLocalMaximum) && (centralPt > getTowerEnergy(iEta + etaIndex, iPhi + phiIndex)));
347  } else {
348  isLocalMaximum = ((isLocalMaximum) && (centralPt >= getTowerEnergy(iEta + etaIndex, iPhi + phiIndex)));
349  }
350  }
351  }
352  }
353  if (isLocalMaximum) {
354  seeds.emplace_back(iEta, iPhi);
355  }
356  }
357  }
358 
359  return seeds;
360 }
bool trimTower(const int etaIndex, const int phiIndex) const
float getTowerEnergy(int iEta, int iPhi) const
Get the energy of a certain tower while correctly handling phi periodicity in case of overflow...
std::unique_ptr< TH2F > caloGrid_
std::pair< float, float > Phase1L1TJetProducer::getCandidateDigiEtaPhi ( const float  eta,
const float  phi,
const unsigned int  regionIndex 
) const
private

Definition at line 435 of file Phase1L1TJetProducer.cc.

References caloGrid_, etalsb_, mps_fire::i, philsb_, regionEtaPhiLowEdges(), and regionEtaPhiUpEdges().

Referenced by fillCaloGrid().

437  {
438  std::pair<double, double> regionLowEdges = regionEtaPhiLowEdges(regionIndex);
439 
440  int digitisedEta = floor((eta - regionLowEdges.second) / etalsb_);
441  int digitisedPhi = floor((phi - regionLowEdges.first) / philsb_);
442 
443  // If eta or phi is on a bin edge
444  // Put in bin above, to match behaviour of HLS
445  // Unless it's on the last bin of this pf region
446  // Then it is placed in the last bin, not the overflow
447  TAxis* etaAxis = caloGrid_->GetXaxis();
448  std::pair<double, double> regionUpEdges = regionEtaPhiUpEdges(regionIndex);
449  int digiEtaEdgeLastBinUp = floor((regionUpEdges.second - regionLowEdges.second) / etalsb_);
450  // If the digi eta is outside the last bin of this pf region
451  // Set the digitised quantity so it would be in the last bin
452  // These cases could be avoided by sorting input candidates based on digitised eta/phi
453  if (digitisedEta >= digiEtaEdgeLastBinUp) {
454  digitisedEta = digiEtaEdgeLastBinUp - 1;
455  } else {
456  for (int i = 0; i < etaAxis->GetNbins(); ++i) {
457  if (etaAxis->GetBinUpEdge(i) < regionLowEdges.second)
458  continue;
459  int digiEdgeBinUp = floor((etaAxis->GetBinUpEdge(i) - regionLowEdges.second) / etalsb_);
460  if (digiEdgeBinUp == digitisedEta) {
461  digitisedEta += 1;
462  }
463  }
464  }
465 
466  // Similar for phi
467  TAxis* phiAxis = caloGrid_->GetYaxis();
468  int digiPhiEdgeLastBinUp = floor((regionUpEdges.first - regionLowEdges.first) / philsb_);
469  if (digitisedPhi >= digiPhiEdgeLastBinUp) {
470  digitisedPhi = digiPhiEdgeLastBinUp - 1;
471  } else {
472  for (int i = 0; i < phiAxis->GetNbins(); ++i) {
473  if (phiAxis->GetBinUpEdge(i) < regionLowEdges.first)
474  continue;
475  int digiEdgeBinUp = floor((phiAxis->GetBinUpEdge(i) - regionLowEdges.first) / philsb_);
476  if (digiEdgeBinUp == digitisedPhi) {
477  digitisedPhi += 1;
478  }
479  }
480  }
481 
482  // Convert digitised eta and phi back to floating point quantities with reduced precision
483  float floatDigitisedEta = (digitisedEta + 0.5) * etalsb_ + regionLowEdges.second;
484  float floatDigitisedPhi = (digitisedPhi + 0.5) * philsb_ + regionLowEdges.first;
485 
486  return std::pair<float, float>{floatDigitisedEta, floatDigitisedPhi};
487 }
std::pair< double, double > regionEtaPhiUpEdges(const unsigned int regionIndex) const
std::pair< double, double > regionEtaPhiLowEdges(const unsigned int regionIndex) const
std::unique_ptr< TH2F > caloGrid_
unsigned int Phase1L1TJetProducer::getRegionIndex ( const unsigned int  phiRegion,
const unsigned int  etaRegion 
) const
private

Definition at line 551 of file Phase1L1TJetProducer.cc.

References phiRegionEdges_.

Referenced by prepareInputsIntoRegions().

551  {
552  return etaRegion * (phiRegionEdges_.size() - 1) + phiRegion;
553 }
std::vector< double > phiRegionEdges_
float Phase1L1TJetProducer::getTowerEnergy ( int  iEta,
int  iPhi 
) const
private

Get the energy of a certain tower while correctly handling phi periodicity in case of overflow.

Definition at line 202 of file Phase1L1TJetProducer.cc.

References caloGrid_.

Referenced by buildJetFromSeed(), findSeeds(), and subtract9x9Pileup().

202  {
203  // We return the pt of a certain bin in the calo grid, taking account of the phi periodicity when overflowing (e.g. phi > phiSize), and returning 0 for the eta out of bounds
204 
205  int nBinsEta = caloGrid_->GetNbinsX();
206  int nBinsPhi = caloGrid_->GetNbinsY();
207  while (iPhi < 1) {
208  iPhi += nBinsPhi;
209  }
210  while (iPhi > nBinsPhi) {
211  iPhi -= nBinsPhi;
212  }
213  if (iEta < 1) {
214  return 0;
215  }
216  if (iEta > nBinsEta) {
217  return 0;
218  }
219  return caloGrid_->GetBinContent(iEta, iPhi);
220 }
std::unique_ptr< TH2F > caloGrid_
template<class Handle >
std::vector<std::vector<reco::CandidatePtr> > Phase1L1TJetProducer::prepareInputsIntoRegions ( const Handle  triggerPrimitives)
private
template<class Handle >
std::vector<std::vector<edm::Ptr<reco::Candidate> > > Phase1L1TJetProducer::prepareInputsIntoRegions ( const Handle  triggerPrimitives)

Definition at line 515 of file Phase1L1TJetProducer.cc.

References etaRegionEdges_, getRegionIndex(), mps_fire::i, PixelMapPlotter::inputs, maxInputsPerRegion_, phiRegionEdges_, cmsswSequenceInfo::tp, and cuda_std::upper_bound().

516  {
517  std::vector<std::vector<reco::CandidatePtr>> inputsInRegions{etaRegionEdges_.size() * (phiRegionEdges_.size() - 1)};
518 
519  for (unsigned int i = 0; i < triggerPrimitives->size(); ++i) {
520  reco::CandidatePtr tp(triggerPrimitives, i);
521 
522  if (tp->phi() < phiRegionEdges_.front() || tp->phi() >= phiRegionEdges_.back() ||
523  tp->eta() < etaRegionEdges_.front() || tp->eta() >= etaRegionEdges_.back())
524  continue;
525 
526  // Which phi region does this tp belong to
527  auto it_phi = phiRegionEdges_.begin();
528  it_phi = std::upper_bound(phiRegionEdges_.begin(), phiRegionEdges_.end(), tp->phi()) - 1;
529 
530  // Which eta region does this tp belong to
531  auto it_eta = etaRegionEdges_.begin();
532  it_eta = std::upper_bound(etaRegionEdges_.begin(), etaRegionEdges_.end(), tp->eta()) - 1;
533 
534  if (it_phi != phiRegionEdges_.end() && it_eta != etaRegionEdges_.end()) {
535  auto phiRegion = it_phi - phiRegionEdges_.begin();
536  auto etaRegion = it_eta - etaRegionEdges_.begin();
537  inputsInRegions[getRegionIndex(phiRegion, etaRegion)].emplace_back(tp);
538  }
539  }
540 
541  // Truncate number of inputs in each pf region
542  for (auto& inputs : inputsInRegions) {
543  if (inputs.size() > maxInputsPerRegion_) {
544  inputs.resize(maxInputsPerRegion_);
545  }
546  }
547 
548  return inputsInRegions;
549 }
unsigned int getRegionIndex(const unsigned int phiRegion, const unsigned int etaRegion) const
std::vector< double > phiRegionEdges_
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
std::vector< double > etaRegionEdges_
void Phase1L1TJetProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 222 of file Phase1L1TJetProducer.cc.

References buildJetsFromSeeds(), buildJetsFromSeedsWithPUSubtraction(), caloGrid_, computeMET(), findSeeds(), edm::Event::getByToken(), inputCollectionTag_, L1Analysis::kMissingEt, L1Analysis::kMissingEtHF, metAbsEtaCut_, metHFAbsEtaCut_, eostools::move(), outputCollectionName_, reco::LeafCandidate::pt(), puSubtraction_, edm::Event::put(), seedPtThreshold_, and vetoZeroPt_.

222  {
223  edm::Handle<edm::View<reco::Candidate>> inputCollectionHandle;
224  iEvent.getByToken(inputCollectionTag_, inputCollectionHandle);
225 
226  // sort inputs into PF regions
227  std::vector<std::vector<reco::CandidatePtr>> inputsInRegions = prepareInputsIntoRegions<>(inputCollectionHandle);
228 
229  // histogramming the data
230  caloGrid_->Reset();
231  for (unsigned int iInputRegion = 0; iInputRegion < inputsInRegions.size(); ++iInputRegion) {
232  fillCaloGrid<>(*(caloGrid_), inputsInRegions[iInputRegion], iInputRegion);
233  }
234 
235  // find the seeds
236  const auto& seedsVector = findSeeds(seedPtThreshold_); // seedPtThreshold = 5
237  // build jets from the seeds
238  auto l1jetVector =
240 
241  // sort by pt
242  std::sort(l1jetVector.begin(), l1jetVector.end(), [](const reco::CaloJet& jet1, const reco::CaloJet& jet2) {
243  return jet1.pt() > jet2.pt();
244  });
245 
246  auto l1jetVectorPtr = std::make_unique<std::vector<reco::CaloJet>>(l1jetVector);
247  iEvent.put(std::move(l1jetVectorPtr), outputCollectionName_);
248 
249  // calculate METs
252  std::unique_ptr<std::vector<l1t::EtSum>> lSumVectorPtr(new std::vector<l1t::EtSum>(0));
253  lSumVectorPtr->push_back(lMET);
254  lSumVectorPtr->push_back(lMETHF);
255  iEvent.put(std::move(lSumVectorPtr), this->outputCollectionName_ + "MET");
256 
257  return;
258 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Jets made from CaloTowers.
Definition: CaloJet.h:27
double pt() const final
transverse momentum
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< reco::CaloJet > buildJetsFromSeeds(const std::vector< std::tuple< int, int >> &seeds) const
def move
Definition: eostools.py:511
std::vector< reco::CaloJet > buildJetsFromSeedsWithPUSubtraction(const std::vector< std::tuple< int, int >> &seeds, bool killZeroPt) const
std::unique_ptr< TH2F > caloGrid_
l1t::EtSum computeMET(const double etaCut, l1t::EtSum::EtSumType sumType) const
std::vector< std::tuple< int, int > > findSeeds(float seedThreshold) const
Finds the seeds in the caloGrid, seeds are saved in a vector that contain the index in the TH2F of ea...
edm::EDGetTokenT< edm::View< reco::Candidate > > inputCollectionTag_
std::pair< double, double > Phase1L1TJetProducer::regionEtaPhiLowEdges ( const unsigned int  regionIndex) const
private

Definition at line 555 of file Phase1L1TJetProducer.cc.

References etaRegionEdges_, and phiRegionEdges_.

Referenced by getCandidateDigiEtaPhi().

555  {
556  unsigned int phiRegion = regionIndex % (phiRegionEdges_.size() - 1);
557  unsigned int etaRegion = (regionIndex - phiRegion) / (phiRegionEdges_.size() - 1);
558  return std::pair<double, double>{phiRegionEdges_.at(phiRegion), etaRegionEdges_.at(etaRegion)};
559 }
std::vector< double > phiRegionEdges_
std::vector< double > etaRegionEdges_
std::pair< double, double > Phase1L1TJetProducer::regionEtaPhiUpEdges ( const unsigned int  regionIndex) const
private

Definition at line 561 of file Phase1L1TJetProducer.cc.

References etaRegionEdges_, and phiRegionEdges_.

Referenced by getCandidateDigiEtaPhi().

561  {
562  unsigned int phiRegion = regionIndex % (phiRegionEdges_.size() - 1);
563  unsigned int etaRegion = (regionIndex - phiRegion) / (phiRegionEdges_.size() - 1);
564  if (phiRegion == phiRegionEdges_.size() - 1) {
565  return std::pair<double, double>{phiRegionEdges_.at(phiRegion), etaRegionEdges_.at(etaRegion + 1)};
566  } else if (etaRegion == etaRegionEdges_.size() - 1) {
567  return std::pair<double, double>{phiRegionEdges_.at(phiRegion + 1), etaRegionEdges_.at(etaRegion)};
568  }
569 
570  return std::pair<double, double>{phiRegionEdges_.at(phiRegion + 1), etaRegionEdges_.at(etaRegion + 1)};
571 }
std::vector< double > phiRegionEdges_
std::vector< double > etaRegionEdges_
void Phase1L1TJetProducer::subtract9x9Pileup ( reco::CaloJet jet) const
private

Definition at line 260 of file Phase1L1TJetProducer.cc.

References caloGrid_, reco::LeafCandidate::eta(), getTowerEnergy(), SiStripPI::max, reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), reco::LeafCandidate::setP4(), reco::Jet::setPileup(), x, x_scroll_max, x_scroll_min, y, y_scroll_max, and y_scroll_min.

Referenced by buildJetsFromSeedsWithPUSubtraction().

260  {
261  // these variables host the total pt in each sideband and the total pileup contribution
262  float topBandPt = 0;
263  float leftBandPt = 0;
264  float rightBandPt = 0;
265  float bottomBandPt = 0;
266  float pileUpEnergy;
267 
268  // hold the jet's x-y (and z, as I have to use it, even if 2D) location in the histo
269  int xCenter, yCenter, zCenter;
270  // Retrieving histo-coords for seed
271  caloGrid_->GetBinXYZ(caloGrid_->FindFixBin(jet.eta(), jet.phi()), xCenter, yCenter, zCenter);
272 
273  // Computing pileup
274  for (int x = x_scroll_min; x <= x_scroll_max; x++) {
275  for (int y = y_scroll_min; y < y_scroll_max; y++) {
276  // top band, I go up 5 squares to reach the bottom of the top band
277  // +x scrolls from left to right, +y scrolls up
278  topBandPt += getTowerEnergy(xCenter + x, yCenter + (5 + y));
279  // left band, I go left 5 squares (-5) to reach the bottom of the top band
280  // +x scrolls from bottom to top, +y scrolls left
281  leftBandPt += getTowerEnergy(xCenter - (5 + y), yCenter + x);
282  // right band, I go right 5 squares (+5) to reach the bottom of the top band
283  // +x scrolls from bottom to top, +y scrolls right
284  rightBandPt += getTowerEnergy(xCenter + (5 + y), yCenter + x);
285  // right band, I go right 5 squares (+5) to reach the bottom of the top band
286  // +x scrolls from bottom to top, +y scrolls right
287  bottomBandPt += getTowerEnergy(xCenter + x, yCenter - (5 + y));
288  }
289  }
290  // adding bands and removing the maximum band (equivalent to adding the three minimum bands)
291  pileUpEnergy = topBandPt + leftBandPt + rightBandPt + bottomBandPt -
292  std::max(topBandPt, std::max(leftBandPt, std::max(rightBandPt, bottomBandPt)));
293 
294  //preparing the new 4-momentum vector
296  // removing pu contribution
297  float ptAfterPUSubtraction = jet.pt() - pileUpEnergy;
298  ptVector.SetPt((ptAfterPUSubtraction > 0) ? ptAfterPUSubtraction : 0);
299  ptVector.SetEta(jet.eta());
300  ptVector.SetPhi(jet.phi());
301  //updating the jet
302  jet.setP4(ptVector);
303  jet.setPileup(pileUpEnergy);
304  return;
305 }
double pt() const final
transverse momentum
virtual void setPileup(float fEnergy)
Set pileup energy contribution as calculated by algorithm.
Definition: Jet.h:106
float getTowerEnergy(int iEta, int iPhi) const
Get the energy of a certain tower while correctly handling phi periodicity in case of overflow...
constexpr int x_scroll_max
std::unique_ptr< TH2F > caloGrid_
constexpr int y_scroll_max
constexpr int y_scroll_min
constexpr int x_scroll_min
double phi() const final
momentum azimuthal angle
void setP4(const LorentzVector &p4) final
set 4-momentum
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
double eta() const final
momentum pseudorapidity
bool Phase1L1TJetProducer::trimTower ( const int  etaIndex,
const int  phiIndex 
) const
private

Definition at line 595 of file Phase1L1TJetProducer.cc.

References jetIEtaSize_, and jetIPhiSize_.

Referenced by buildJetFromSeed(), and findSeeds().

595  {
596  int etaHalfSize = jetIEtaSize_ / 2;
597  int phiHalfSize = jetIPhiSize_ / 2;
598 
599  if (etaIndex == -etaHalfSize || etaIndex == etaHalfSize) {
600  if (phiIndex <= -phiHalfSize + 1 || phiIndex >= phiHalfSize - 1) {
601  return true;
602  }
603  } else if (etaIndex == -etaHalfSize + 1 || etaIndex == etaHalfSize - 1) {
604  if (phiIndex == -phiHalfSize || phiIndex == phiHalfSize) {
605  return true;
606  }
607  }
608 
609  return false;
610 }

Member Data Documentation

std::unique_ptr<TH2F> Phase1L1TJetProducer::caloGrid_
private
std::vector<double> Phase1L1TJetProducer::cosPhi_
private

Definition at line 158 of file Phase1L1TJetProducer.cc.

Referenced by computeMET().

std::vector<double> Phase1L1TJetProducer::etaBinning_
private

Definition at line 137 of file Phase1L1TJetProducer.cc.

double Phase1L1TJetProducer::etalsb_
private

Definition at line 148 of file Phase1L1TJetProducer.cc.

Referenced by getCandidateDigiEtaPhi().

std::vector<double> Phase1L1TJetProducer::etaRegionEdges_
private
edm::EDGetTokenT<edm::View<reco::Candidate> > Phase1L1TJetProducer::inputCollectionTag_
private

Definition at line 133 of file Phase1L1TJetProducer.cc.

Referenced by produce().

unsigned int Phase1L1TJetProducer::jetIEtaSize_
private

Definition at line 142 of file Phase1L1TJetProducer.cc.

Referenced by buildJetFromSeed(), findSeeds(), and trimTower().

unsigned int Phase1L1TJetProducer::jetIPhiSize_
private

Definition at line 143 of file Phase1L1TJetProducer.cc.

Referenced by buildJetFromSeed(), findSeeds(), and trimTower().

unsigned int Phase1L1TJetProducer::maxInputsPerRegion_
private

Definition at line 155 of file Phase1L1TJetProducer.cc.

Referenced by prepareInputsIntoRegions().

double Phase1L1TJetProducer::metAbsEtaCut_
private

Definition at line 160 of file Phase1L1TJetProducer.cc.

Referenced by produce().

double Phase1L1TJetProducer::metHFAbsEtaCut_
private

Definition at line 162 of file Phase1L1TJetProducer.cc.

Referenced by produce().

size_t Phase1L1TJetProducer::nBinsEta_
private

Definition at line 138 of file Phase1L1TJetProducer.cc.

unsigned int Phase1L1TJetProducer::nBinsPhi_
private

Definition at line 139 of file Phase1L1TJetProducer.cc.

std::string Phase1L1TJetProducer::outputCollectionName_
private

Definition at line 163 of file Phase1L1TJetProducer.cc.

Referenced by produce().

double Phase1L1TJetProducer::phiLow_
private

Definition at line 140 of file Phase1L1TJetProducer.cc.

double Phase1L1TJetProducer::philsb_
private

Definition at line 147 of file Phase1L1TJetProducer.cc.

Referenced by getCandidateDigiEtaPhi().

std::vector<double> Phase1L1TJetProducer::phiRegionEdges_
private
double Phase1L1TJetProducer::phiUp_
private

Definition at line 141 of file Phase1L1TJetProducer.cc.

double Phase1L1TJetProducer::ptlsb_
private

Definition at line 146 of file Phase1L1TJetProducer.cc.

Referenced by computeMET().

bool Phase1L1TJetProducer::puSubtraction_
private

Definition at line 149 of file Phase1L1TJetProducer.cc.

Referenced by produce().

double Phase1L1TJetProducer::seedPtThreshold_
private

Definition at line 145 of file Phase1L1TJetProducer.cc.

Referenced by produce().

std::vector<double> Phase1L1TJetProducer::sinPhi_
private

Definition at line 157 of file Phase1L1TJetProducer.cc.

Referenced by computeMET().

bool Phase1L1TJetProducer::trimmedGrid_
private

Definition at line 144 of file Phase1L1TJetProducer.cc.

Referenced by buildJetFromSeed(), and findSeeds().

bool Phase1L1TJetProducer::vetoZeroPt_
private

Definition at line 150 of file Phase1L1TJetProducer.cc.

Referenced by buildJetsFromSeedsWithPUSubtraction(), and produce().