74 std::vector<std::tuple<int, int>>
findSeeds(
float seedThreshold)
const;
80 bool killZeroPt)
const;
97 template <
class Container>
98 void fillCaloGrid(TH2F& caloGrid,
const Container& triggerPrimitives,
const unsigned int regionIndex);
106 const unsigned int regionIndex)
const;
110 template <
class Handle>
131 bool trimTower(
const int etaIndex,
const int phiIndex)
const;
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")),
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");
210 while (iPhi > nBinsPhi) {
216 if (iEta > nBinsEta) {
219 return caloGrid_->GetBinContent(iEta, iPhi);
227 std::vector<std::vector<reco::CandidatePtr>> inputsInRegions = prepareInputsIntoRegions<>(inputCollectionHandle);
231 for (
unsigned int iInputRegion = 0; iInputRegion < inputsInRegions.size(); ++iInputRegion) {
232 fillCaloGrid<>(*(
caloGrid_), inputsInRegions[iInputRegion], iInputRegion);
243 return jet1.
pt() > jet2.pt();
246 auto l1jetVectorPtr = std::make_unique<std::vector<reco::CaloJet>>(l1jetVector);
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);
263 float leftBandPt = 0;
264 float rightBandPt = 0;
265 float bottomBandPt = 0;
269 int xCenter, yCenter, zCenter;
291 pileUpEnergy = topBandPt + leftBandPt + rightBandPt + bottomBandPt -
297 float ptAfterPUSubtraction = jet.
pt() - pileUpEnergy;
298 ptVector.SetPt((ptAfterPUSubtraction > 0) ? ptAfterPUSubtraction : 0);
299 ptVector.SetEta(jet.
eta());
300 ptVector.SetPhi(jet.
phi());
311 std::vector<std::tuple<int, int>>
seeds;
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)
326 bool isLocalMaximum =
true;
329 for (
int etaIndex = -etaHalfSize; etaIndex <= etaHalfSize; etaIndex++) {
330 for (
int phiIndex = -phiHalfSize; phiIndex <= phiHalfSize; phiIndex++) {
336 if ((etaIndex == 0) && (phiIndex == 0))
339 if (phiIndex > -etaIndex) {
340 isLocalMaximum = ((isLocalMaximum) && (centralPt >
getTowerEnergy(iEta + etaIndex, iPhi + phiIndex)));
342 isLocalMaximum = ((isLocalMaximum) && (centralPt >=
getTowerEnergy(iEta + etaIndex, iPhi + phiIndex)));
345 if (phiIndex >= -etaIndex) {
346 isLocalMaximum = ((isLocalMaximum) && (centralPt >
getTowerEnergy(iEta + etaIndex, iPhi + phiIndex)));
348 isLocalMaximum = ((isLocalMaximum) && (centralPt >=
getTowerEnergy(iEta + etaIndex, iPhi + phiIndex)));
353 if (isLocalMaximum) {
354 seeds.emplace_back(iEta, iPhi);
363 int iEta = std::get<0>(
seed);
364 int iPhi = std::get<1>(
seed);
371 for (
int etaIndex = -etaHalfSize; etaIndex <= etaHalfSize; etaIndex++) {
372 for (
int phiIndex = -phiHalfSize; phiIndex <= phiHalfSize; phiIndex++) {
383 ptVector.SetPt(ptSum);
384 ptVector.SetEta(
caloGrid_->GetXaxis()->GetBinCenter(iEta));
385 ptVector.SetPhi(
caloGrid_->GetYaxis()->GetBinCenter(iPhi));
395 std::vector<reco::CaloJet>
jets;
411 std::vector<reco::CaloJet>
jets;
419 template <
class Container>
422 const unsigned int regionIndex) {
424 for (
const auto& primitiveIterator : triggerPrimitives) {
426 std::pair<float, float> digi_EtaPhi =
429 caloGrid.Fill(static_cast<float>(digi_EtaPhi.first),
430 static_cast<float>(digi_EtaPhi.second),
431 static_cast<float>(primitiveIterator->pt()));
437 const unsigned int regionIndex)
const {
440 int digitisedEta = floor((eta - regionLowEdges.second) /
etalsb_);
441 int digitisedPhi = floor((phi - regionLowEdges.first) /
philsb_);
449 int digiEtaEdgeLastBinUp = floor((regionUpEdges.second - regionLowEdges.second) /
etalsb_);
453 if (digitisedEta >= digiEtaEdgeLastBinUp) {
454 digitisedEta = digiEtaEdgeLastBinUp - 1;
456 for (
int i = 0;
i < etaAxis->GetNbins(); ++
i) {
457 if (etaAxis->GetBinUpEdge(
i) < regionLowEdges.second)
459 int digiEdgeBinUp = floor((etaAxis->GetBinUpEdge(
i) - regionLowEdges.second) /
etalsb_);
460 if (digiEdgeBinUp == digitisedEta) {
468 int digiPhiEdgeLastBinUp = floor((regionUpEdges.first - regionLowEdges.first) /
philsb_);
469 if (digitisedPhi >= digiPhiEdgeLastBinUp) {
470 digitisedPhi = digiPhiEdgeLastBinUp - 1;
472 for (
int i = 0;
i < phiAxis->GetNbins(); ++
i) {
473 if (phiAxis->GetBinUpEdge(
i) < regionLowEdges.first)
475 int digiEdgeBinUp = floor((phiAxis->GetBinUpEdge(
i) - regionLowEdges.first) /
philsb_);
476 if (digiEdgeBinUp == digitisedPhi) {
483 float floatDigitisedEta = (digitisedEta + 0.5) *
etalsb_ + regionLowEdges.second;
484 float floatDigitisedPhi = (digitisedPhi + 0.5) *
philsb_ + regionLowEdges.first;
486 return std::pair<float, float>{floatDigitisedEta, floatDigitisedPhi};
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);
514 template <
class Handle>
516 const Handle triggerPrimitives) {
519 for (
unsigned int i = 0;
i < triggerPrimitives->size(); ++
i) {
542 for (
auto&
inputs : inputsInRegions) {
548 return inputsInRegions;
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);
582 for (
int i = 1;
i < phiProjection->GetNbinsX() + 1; ++
i) {
583 double pt = phiProjection->GetBinContent(
i);
588 double lMET = floor(
sqrt(totalDigiPx * totalDigiPx + totalDigiPy * totalDigiPy)) *
ptlsb_;
591 l1t::EtSum lMETSum(lMETVector, sumType, 0, 0, 0, 0);
599 if (etaIndex == -etaHalfSize || etaIndex == etaHalfSize) {
600 if (phiIndex <= -phiHalfSize + 1 || phiIndex >= phiHalfSize - 1) {
603 }
else if (etaIndex == -etaHalfSize + 1 || etaIndex == etaHalfSize - 1) {
604 if (phiIndex == -phiHalfSize || phiIndex == phiHalfSize) {
unsigned int getRegionIndex(const unsigned int phiRegion, const unsigned int etaRegion) const
std::vector< double > phiRegionEdges_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< double > cosPhi_
Jets made from CaloTowers.
double pt() const final
transverse momentum
std::string outputCollectionName_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void setPileup(float fEnergy)
Set pileup energy contribution as calculated by algorithm.
std::pair< double, double > regionEtaPhiUpEdges(const unsigned int regionIndex) const
void subtract9x9Pileup(reco::CaloJet &jet) const
#define DEFINE_FWK_MODULE(type)
bool trimTower(const int etaIndex, const int phiIndex) const
unsigned int jetIEtaSize_
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Phase1L1TJetProducer(const edm::ParameterSet &)
std::pair< float, float > getCandidateDigiEtaPhi(const float eta, const float phi, const unsigned int regionIndex) 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::vector< std::vector< reco::CandidatePtr > > prepareInputsIntoRegions(const Handle triggerPrimitives)
std::vector< double > sinPhi_
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
constexpr int x_scroll_max
std::pair< double, double > regionEtaPhiLowEdges(const unsigned int regionIndex) const
std::vector< double > etaBinning_
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< reco::CaloJet > buildJetsFromSeeds(const std::vector< std::tuple< int, int >> &seeds) const
std::vector< reco::CaloJet > buildJetsFromSeedsWithPUSubtraction(const std::vector< std::tuple< int, int >> &seeds, bool killZeroPt) const
std::unique_ptr< TH2F > caloGrid_
void fillCaloGrid(TH2F &caloGrid, const Container &triggerPrimitives, const unsigned int regionIndex)
l1t::EtSum computeMET(const double etaCut, l1t::EtSum::EtSumType sumType) const
unsigned int maxInputsPerRegion_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr int y_scroll_max
~Phase1L1TJetProducer() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr int y_scroll_min
std::vector< double > etaRegionEdges_
reco::CaloJet buildJetFromSeed(const std::tuple< int, int > &seed) const
T getParameter(std::string const &) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
constexpr int x_scroll_min
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...
unsigned int jetIPhiSize_
double phi() const final
momentum azimuthal angle
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
void setP4(const LorentzVector &p4) final
set 4-momentum
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
double eta() const final
momentum pseudorapidity
edm::EDGetTokenT< edm::View< reco::Candidate > > inputCollectionTag_