79 bool killZeroPt)
const;
96 template <
class Container>
97 void fillCaloGrid(TH2F& caloGrid,
const Container& triggerPrimitives,
const unsigned int regionIndex);
105 const unsigned int regionIndex)
const;
109 template <
class Handle>
130 bool trimTower(
const int etaIndex,
const int phiIndex)
const;
169 etaBinning_(iConfig.getParameter<std::vector<double>>(
"etaBinning")),
170 nBinsEta_(etaBinning_.size() - 1),
171 nBinsPhi_(iConfig.getParameter<
unsigned int>(
"nBinsPhi")),
172 phiLow_(iConfig.getParameter<
double>(
"phiLow")),
173 phiUp_(iConfig.getParameter<
double>(
"phiUp")),
174 jetIEtaSize_(iConfig.getParameter<
unsigned int>(
"jetIEtaSize")),
175 jetIPhiSize_(iConfig.getParameter<
unsigned int>(
"jetIPhiSize")),
176 trimmedGrid_(iConfig.getParameter<
bool>(
"trimmedGrid")),
177 seedPtThreshold_(iConfig.getParameter<
double>(
"seedPtThreshold")),
178 ptlsb_(iConfig.getParameter<
double>(
"ptlsb")),
179 philsb_(iConfig.getParameter<
double>(
"philsb")),
180 etalsb_(iConfig.getParameter<
double>(
"etalsb")),
181 puSubtraction_(iConfig.getParameter<
bool>(
"puSubtraction")),
182 vetoZeroPt_(iConfig.getParameter<
bool>(
"vetoZeroPt")),
183 etaRegionEdges_(iConfig.getParameter<std::vector<double>>(
"etaRegions")),
184 phiRegionEdges_(iConfig.getParameter<std::vector<double>>(
"phiRegions")),
185 maxInputsPerRegion_(iConfig.getParameter<
unsigned int>(
"maxInputsPerRegion")),
186 sinPhi_(iConfig.getParameter<std::vector<double>>(
"sinPhi")),
187 cosPhi_(iConfig.getParameter<std::vector<double>>(
"cosPhi")),
188 metAbsEtaCut_(iConfig.getParameter<
double>(
"metAbsEtaCut")),
189 metHFAbsEtaCut_(iConfig.getParameter<
double>(
"metHFAbsEtaCut")),
190 outputCollectionName_(iConfig.getParameter<
std::string>(
"outputCollectionName")) {
192 std::make_unique<TH2F>(
"caloGrid",
"Calorimeter grid", nBinsEta_, etaBinning_.data(), nBinsPhi_, phiLow_, phiUp_);
193 caloGrid_->GetXaxis()->SetTitle(
"#eta");
194 caloGrid_->GetYaxis()->SetTitle(
"#phi");
195 produces<std::vector<reco::CaloJet>>(outputCollectionName_).setBranchAlias(outputCollectionName_);
196 produces<std::vector<l1t::EtSum>>(outputCollectionName_ +
"MET").setBranchAlias(outputCollectionName_ +
"MET");
226 std::vector<std::vector<reco::CandidatePtr>> inputsInRegions = prepareInputsIntoRegions<>(inputCollectionHandle);
230 for (
unsigned int iInputRegion = 0; iInputRegion < inputsInRegions.size(); ++iInputRegion) {
231 fillCaloGrid<>(*(
caloGrid_), inputsInRegions[iInputRegion], iInputRegion);
242 return jet1.
pt() > jet2.pt();
245 auto l1jetVectorPtr = std::make_unique<std::vector<reco::CaloJet>>(l1jetVector);
251 std::unique_ptr<std::vector<l1t::EtSum>> lSumVectorPtr(
new std::vector<l1t::EtSum>(0));
252 lSumVectorPtr->push_back(lMET);
253 lSumVectorPtr->push_back(lMETHF);
262 float leftBandPt = 0;
263 float rightBandPt = 0;
264 float bottomBandPt = 0;
268 int xCenter, yCenter, zCenter;
290 pileUpEnergy = topBandPt + leftBandPt + rightBandPt + bottomBandPt -
296 float ptAfterPUSubtraction =
jet.pt() - pileUpEnergy;
297 ptVector.SetPt((ptAfterPUSubtraction > 0) ? ptAfterPUSubtraction : 0);
298 ptVector.SetEta(
jet.eta());
299 ptVector.SetPhi(
jet.phi());
302 jet.setPileup(pileUpEnergy);
310 std::vector<std::tuple<int, int>>
seeds;
320 for (
int iPhi = 1; iPhi <= nBinsY; iPhi++) {
325 bool isLocalMaximum =
true;
328 for (
int etaIndex = -etaHalfSize; etaIndex <= etaHalfSize; etaIndex++) {
329 for (
int phiIndex = -phiHalfSize; phiIndex <= phiHalfSize; phiIndex++) {
335 if ((etaIndex == 0) && (phiIndex == 0))
338 if (phiIndex > -etaIndex) {
339 isLocalMaximum = ((isLocalMaximum) && (centralPt >
getTowerEnergy(
iEta + etaIndex, iPhi + phiIndex)));
341 isLocalMaximum = ((isLocalMaximum) && (centralPt >=
getTowerEnergy(
iEta + etaIndex, iPhi + phiIndex)));
344 if (phiIndex >= -etaIndex) {
345 isLocalMaximum = ((isLocalMaximum) && (centralPt >
getTowerEnergy(
iEta + etaIndex, iPhi + phiIndex)));
347 isLocalMaximum = ((isLocalMaximum) && (centralPt >=
getTowerEnergy(
iEta + etaIndex, iPhi + phiIndex)));
352 if (isLocalMaximum) {
363 int iPhi = std::get<1>(
seed);
370 for (
int etaIndex = -etaHalfSize; etaIndex <= etaHalfSize; etaIndex++) {
371 for (
int phiIndex = -phiHalfSize; phiIndex <= phiHalfSize; phiIndex++) {
382 ptVector.SetPt(ptSum);
384 ptVector.SetPhi(
caloGrid_->GetYaxis()->GetBinCenter(iPhi));
394 std::vector<reco::CaloJet>
jets;
410 std::vector<reco::CaloJet>
jets;
418 template <
class Container>
421 const unsigned int regionIndex) {
423 for (
const auto& primitiveIterator : triggerPrimitives) {
425 std::pair<float, float> digi_EtaPhi =
428 caloGrid.Fill(static_cast<float>(digi_EtaPhi.first),
429 static_cast<float>(digi_EtaPhi.second),
430 static_cast<float>(primitiveIterator->pt()));
436 const unsigned int regionIndex)
const {
439 int digitisedEta = floor((
eta - regionLowEdges.second) /
etalsb_);
440 int digitisedPhi = floor((
phi - regionLowEdges.first) /
philsb_);
448 int digiEtaEdgeLastBinUp = floor((regionUpEdges.second - regionLowEdges.second) /
etalsb_);
452 if (digitisedEta >= digiEtaEdgeLastBinUp) {
453 digitisedEta = digiEtaEdgeLastBinUp - 1;
455 for (
int i = 0;
i < etaAxis->GetNbins(); ++
i) {
456 if (etaAxis->GetBinUpEdge(
i) < regionLowEdges.second)
458 int digiEdgeBinUp = floor((etaAxis->GetBinUpEdge(
i) - regionLowEdges.second) /
etalsb_);
459 if (digiEdgeBinUp == digitisedEta) {
467 int digiPhiEdgeLastBinUp = floor((regionUpEdges.first - regionLowEdges.first) /
philsb_);
468 if (digitisedPhi >= digiPhiEdgeLastBinUp) {
469 digitisedPhi = digiPhiEdgeLastBinUp - 1;
471 for (
int i = 0;
i < phiAxis->GetNbins(); ++
i) {
472 if (phiAxis->GetBinUpEdge(
i) < regionLowEdges.first)
474 int digiEdgeBinUp = floor((phiAxis->GetBinUpEdge(
i) - regionLowEdges.first) /
philsb_);
475 if (digiEdgeBinUp == digitisedPhi) {
482 float floatDigitisedEta = (digitisedEta + 0.5) *
etalsb_ + regionLowEdges.second;
483 float floatDigitisedPhi = (digitisedPhi + 0.5) *
philsb_ + regionLowEdges.first;
485 return std::pair<float, float>{floatDigitisedEta, floatDigitisedPhi};
491 desc.add<std::vector<double>>(
"etaBinning");
492 desc.add<
unsigned int>(
"nBinsPhi", 72);
495 desc.add<
unsigned int>(
"jetIEtaSize", 7);
496 desc.add<
unsigned int>(
"jetIPhiSize", 7);
497 desc.add<
bool>(
"trimmedGrid",
false);
498 desc.add<
double>(
"seedPtThreshold", 5);
499 desc.add<
double>(
"ptlsb", 0.25),
desc.add<
double>(
"philsb", 0.0043633231),
desc.add<
double>(
"etalsb", 0.0043633231),
500 desc.add<
bool>(
"puSubtraction",
false);
501 desc.add<
string>(
"outputCollectionName",
"UncalibratedPhase1L1TJetFromPfCandidates");
502 desc.add<
bool>(
"vetoZeroPt",
true);
503 desc.add<std::vector<double>>(
"etaRegions");
504 desc.add<std::vector<double>>(
"phiRegions");
505 desc.add<
unsigned int>(
"maxInputsPerRegion", 18);
506 desc.add<std::vector<double>>(
"sinPhi");
507 desc.add<std::vector<double>>(
"cosPhi");
508 desc.add<
double>(
"metAbsEtaCut", 3);
509 desc.add<
double>(
"metHFAbsEtaCut", 5);
510 descriptions.
add(
"Phase1L1TJetProducer",
desc);
513 template <
class Handle>
515 const Handle triggerPrimitives) {
518 for (
unsigned int i = 0;
i < triggerPrimitives->size(); ++
i) {
541 for (
auto&
inputs : inputsInRegions) {
547 return inputsInRegions;
575 const auto phiProjection =
caloGrid_->ProjectionY(
"temp", lowEtaBin, highEtaBin);
581 for (
int i = 1;
i < phiProjection->GetNbinsX() + 1; ++
i) {
582 double pt = phiProjection->GetBinContent(
i);
587 double lMET = floor(
sqrt(totalDigiPx * totalDigiPx + totalDigiPy * totalDigiPy)) *
ptlsb_;
590 l1t::EtSum lMETSum(lMETVector, sumType, 0, 0, 0, 0);
598 if (etaIndex == -etaHalfSize || etaIndex == etaHalfSize) {
599 if (phiIndex <= -phiHalfSize + 1 || phiIndex >= phiHalfSize - 1) {
602 }
else if (etaIndex == -etaHalfSize + 1 || etaIndex == etaHalfSize - 1) {
603 if (phiIndex == -phiHalfSize || phiIndex == phiHalfSize) {
l1t::EtSum computeMET(const double etaCut, l1t::EtSum::EtSumType sumType) const
T getParameter(std::string const &) const
std::vector< double > phiRegionEdges_
std::vector< double > cosPhi_
Jets made from CaloTowers.
double pt() const final
transverse momentum
std::string outputCollectionName_
std::pair< float, float > getCandidateDigiEtaPhi(const float eta, const float phi, const unsigned int regionIndex) const
std::vector< reco::CaloJet > buildJetsFromSeedsWithPUSubtraction(const std::vector< std::tuple< int, int >> &seeds, bool killZeroPt) const
std::pair< double, double > regionEtaPhiLowEdges(const unsigned int regionIndex) const
unsigned int jetIEtaSize_
Phase1L1TJetProducer(const edm::ParameterSet &)
void subtract9x9Pileup(reco::CaloJet &jet) 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.
unsigned int getRegionIndex(const unsigned int phiRegion, const unsigned int etaRegion) const
constexpr int x_scroll_max
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...
std::vector< double > etaBinning_
void produce(edm::Event &, const edm::EventSetup &) override
std::unique_ptr< TH2F > caloGrid_
void fillCaloGrid(TH2F &caloGrid, const Container &triggerPrimitives, const unsigned int regionIndex)
#define DEFINE_FWK_MODULE(type)
unsigned int maxInputsPerRegion_
constexpr int y_scroll_max
~Phase1L1TJetProducer() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr int y_scroll_min
std::vector< double > etaRegionEdges_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
constexpr int x_scroll_min
std::pair< double, double > regionEtaPhiUpEdges(const unsigned int regionIndex) const
unsigned int jetIPhiSize_
std::vector< reco::CaloJet > buildJetsFromSeeds(const std::vector< std::tuple< int, int >> &seeds) const
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
reco::CaloJet buildJetFromSeed(const std::tuple< int, int > &seed) const
bool trimTower(const int etaIndex, const int phiIndex) const
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
edm::EDGetTokenT< edm::View< reco::Candidate > > inputCollectionTag_