CMS 3D CMS Logo

Phase1L1TJetSumsProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1CaloTrigger
4 // Class: Phase1L1TJetSumsProducer
5 //
23 //
24 // Original Simone Bologna
25 //
26 
40 
41 #include <cmath>
42 
43 class Phase1L1TJetSumsProducer : public edm::one::EDProducer<edm::one::SharedResources> {
44 public:
46  ~Phase1L1TJetSumsProducer() override;
47 
48  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
49 
50 private:
51  void produce(edm::Event&, const edm::EventSetup&) override;
52 
53  // computes ht, adds jet pt to ht only if the pt of the jet is above the ht calculation threshold
54  l1t::EtSum computeHT(const edm::Handle<std::vector<reco::CaloJet> > inputJets) const;
55 
56  // computes MHT
57  // adds jet pt to mht only if the pt of the jet is above the mht calculation threshold
58  // performs some calculations with digitised/integer quantities to ensure agreement with firmware
59  l1t::EtSum computeMHT(const edm::Handle<std::vector<reco::CaloJet> > inputJets) const;
60 
62 
63  // holds the sin and cos for HLs LUT emulation
64  std::vector<double> sinPhi_;
65  std::vector<double> cosPhi_;
66  unsigned int nBinsPhi_;
67 
68  // lower phi value
69  double phiLow_;
70  // higher phi value
71  double phiUp_;
72  // size of a phi bin
73  double phiStep_;
74  // threshold for ht calculation
76  // threshold for ht calculation
78  // jet eta cut for ht calculation
79  double htAbsEtaCut_;
80  // jet eta cut for mht calculation
81  double mhtAbsEtaCut_;
82  // LSB of pt quantity
83  double ptlsb_;
84  // label of sums
86 };
87 
88 // initialises plugin configuration and prepares ROOT file for saving the sums
90  : inputJetCollectionTag_{consumes<std::vector<reco::CaloJet> >(
91  iConfig.getParameter<edm::InputTag>("inputJetCollectionTag"))},
92  sinPhi_(iConfig.getParameter<std::vector<double> >("sinPhi")),
93  cosPhi_(iConfig.getParameter<std::vector<double> >("cosPhi")),
94  nBinsPhi_(iConfig.getParameter<unsigned int>("nBinsPhi")),
95  phiLow_(iConfig.getParameter<double>("phiLow")),
96  phiUp_(iConfig.getParameter<double>("phiUp")),
97  htPtThreshold_(iConfig.getParameter<double>("htPtThreshold")),
98  mhtPtThreshold_(iConfig.getParameter<double>("mhtPtThreshold")),
99  htAbsEtaCut_(iConfig.getParameter<double>("htAbsEtaCut")),
100  mhtAbsEtaCut_(iConfig.getParameter<double>("mhtAbsEtaCut")),
101  ptlsb_(iConfig.getParameter<double>("ptlsb")),
102  outputCollectionName_(iConfig.getParameter<std::string>("outputCollectionName")) {
103  phiStep_ = (phiUp_ - phiLow_) / nBinsPhi_;
104  produces<std::vector<l1t::EtSum> >(outputCollectionName_).setBranchAlias(outputCollectionName_);
105 }
106 
108 
110  edm::Handle<std::vector<reco::CaloJet> > jetCollectionHandle;
111  iEvent.getByToken(inputJetCollectionTag_, jetCollectionHandle);
112 
113  // computing sums and storing them in sum object
114  l1t::EtSum lHT = computeHT(jetCollectionHandle);
115  l1t::EtSum lMHT = computeMHT(jetCollectionHandle);
116 
117  //packing sums in vector for event saving
118  std::unique_ptr<std::vector<l1t::EtSum> > lSumVectorPtr(new std::vector<l1t::EtSum>(0));
119  lSumVectorPtr->push_back(lHT);
120  lSumVectorPtr->push_back(lMHT);
121  iEvent.put(std::move(lSumVectorPtr), outputCollectionName_);
122 
123  return;
124 }
125 
126 l1t::EtSum Phase1L1TJetSumsProducer::computeHT(const edm::Handle<std::vector<reco::CaloJet> > inputJets) const {
127  double lHT = 0;
128  for (const auto& jet : *inputJets) {
129  double lJetPt = jet.pt();
130  double lJetPhi = jet.phi();
131  double lJetEta = jet.eta();
132  if ((lJetPhi < phiLow_) || (lJetPhi >= phiUp_))
133  continue;
134 
135  lHT += (lJetPt >= htPtThreshold_ && std::fabs(lJetEta) < htAbsEtaCut_) ? lJetPt : 0;
136  }
137 
139  lHTVector.SetPt(lHT);
140  lHTVector.SetEta(0);
141  lHTVector.SetPhi(0);
142  l1t::EtSum lHTSum(lHTVector, l1t::EtSum::EtSumType::kTotalHt, 0, 0, 0, 0);
143  return lHTSum;
144 }
145 
146 l1t::EtSum Phase1L1TJetSumsProducer::computeMHT(const edm::Handle<std::vector<reco::CaloJet> > inputJets) const {
147  int lTotalJetPx = 0;
148  int lTotalJetPy = 0;
149 
150  std::vector<unsigned int> jetPtInPhiBins(nBinsPhi_, 0);
151 
152  for (const auto& jet : *inputJets) {
153  double lJetPhi = jet.phi();
154 
155  if ((lJetPhi < phiLow_) || (lJetPhi >= phiUp_))
156  continue;
157 
158  unsigned int iPhi = (lJetPhi - phiLow_) / phiStep_;
159 
160  if (jet.pt() >= mhtPtThreshold_ && std::fabs(jet.eta()) < mhtAbsEtaCut_) {
161  unsigned int digiJetPt = floor(jet.pt() / ptlsb_);
162  jetPtInPhiBins[iPhi] += digiJetPt;
163  }
164  }
165 
166  for (unsigned int iPhi = 0; iPhi < jetPtInPhiBins.size(); ++iPhi) {
167  unsigned int digiJetPtSum = jetPtInPhiBins[iPhi];
168 
169  // retrieving sin cos from LUT emulator
170  double lSinPhi = sinPhi_[iPhi];
171  double lCosPhi = cosPhi_[iPhi];
172 
173  // checking if above threshold
174  lTotalJetPx += trunc(digiJetPtSum * lCosPhi);
175  lTotalJetPy += trunc(digiJetPtSum * lSinPhi);
176  }
177 
178  double lMHT = floor(sqrt(lTotalJetPx * lTotalJetPx + lTotalJetPy * lTotalJetPy)) * ptlsb_;
179  math::PtEtaPhiMLorentzVector lMHTVector(lMHT, 0, acos(lTotalJetPx / (lMHT / ptlsb_)), 0);
180  l1t::EtSum lMHTSum(lMHTVector, l1t::EtSum::EtSumType::kMissingHt, 0, 0, 0, 0);
181 
182  return lMHTSum;
183 }
184 
187  desc.add<edm::InputTag>("inputJetCollectionTag",
188  edm::InputTag("Phase1L1TJetCalibrator", "Phase1L1TJetFromPfCandidates"));
189  desc.add<std::vector<double> >("sinPhi");
190  desc.add<std::vector<double> >("cosPhi");
191  desc.add<unsigned int>("nBinsPhi", 72);
192  desc.add<double>("phiLow", -M_PI);
193  desc.add<double>("phiUp", M_PI);
194  desc.add<double>("htPtThreshold", 30);
195  desc.add<double>("mhtPtThreshold", 30);
196  desc.add<double>("htAbsEtaCut", 3);
197  desc.add<double>("mhtAbsEtaCut", 3);
198  desc.add<double>("ptlsb", 0.25), desc.add<string>("outputCollectionName", "Sums");
199  descriptions.add("Phase1L1TJetSumsProducer", desc);
200 }
201 
202 // creates the plugin for later use in python
CaloJet.h
Phase1L1TJetSumsProducer
Definition: Phase1L1TJetSumsProducer.cc:43
EDProducer.h
Phase1L1TJetSumsProducer::phiStep_
double phiStep_
Definition: Phase1L1TJetSumsProducer.cc:73
HLT_FULL_cff.inputJets
inputJets
Definition: HLT_FULL_cff.py:98489
Phase1L1TJetSumsProducer::nBinsPhi_
unsigned int nBinsPhi_
Definition: Phase1L1TJetSumsProducer.cc:66
Phase1L1TJetSumsProducer::computeMHT
l1t::EtSum computeMHT(const edm::Handle< std::vector< reco::CaloJet > > inputJets) const
Definition: Phase1L1TJetSumsProducer.cc:146
ESHandle.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
Phase1L1TJetSumsProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: Phase1L1TJetSumsProducer.cc:109
reco::Candidate::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
Phase1L1TJetSumsProducer::htPtThreshold_
double htPtThreshold_
Definition: Phase1L1TJetSumsProducer.cc:75
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::one::EDProducer
Definition: EDProducer.h:30
edm::Handle
Definition: AssociativeIterator.h:50
Phase1L1TJetSumsProducer::phiUp_
double phiUp_
Definition: Phase1L1TJetSumsProducer.cc:71
MakerMacros.h
Phase1L1TJetSumsProducer::ptlsb_
double ptlsb_
Definition: Phase1L1TJetSumsProducer.cc:83
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
Phase1L1TJetSumsProducer::Phase1L1TJetSumsProducer
Phase1L1TJetSumsProducer(const edm::ParameterSet &)
Definition: Phase1L1TJetSumsProducer.cc:89
Service.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
Phase1L1TJetSumsProducer::htAbsEtaCut_
double htAbsEtaCut_
Definition: Phase1L1TJetSumsProducer.cc:79
TFileService.h
edm::ParameterSet
Definition: ParameterSet.h:47
Phase1L1TJetSumsProducer::outputCollectionName_
std::string outputCollectionName_
Definition: Phase1L1TJetSumsProducer.cc:85
Event.h
Phase1L1TJetSumsProducer::inputJetCollectionTag_
edm::EDGetTokenT< std::vector< reco::CaloJet > > inputJetCollectionTag_
Definition: Phase1L1TJetSumsProducer.cc:61
l1t::EtSum
Definition: EtSum.h:20
LorentzVector.h
iEvent
int iEvent
Definition: GenABIO.cc:224
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
L1Analysis::kMissingHt
Definition: L1AnalysisL1UpgradeDataFormat.h:20
edm::EventSetup
Definition: EventSetup.h:58
Phase1L1TJetSumsProducer::sinPhi_
std::vector< double > sinPhi_
Definition: Phase1L1TJetSumsProducer.cc:64
Phase1L1TJetSumsProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Phase1L1TJetSumsProducer.cc:185
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Phase1L1TJetSumsProducer::cosPhi_
std::vector< double > cosPhi_
Definition: Phase1L1TJetSumsProducer.cc:65
Phase1L1TJetSumsProducer::computeHT
l1t::EtSum computeHT(const edm::Handle< std::vector< reco::CaloJet > > inputJets) const
Definition: Phase1L1TJetSumsProducer.cc:126
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
metsig::jet
Definition: SignAlgoResolutions.h:47
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
math::PtEtaPhiMLorentzVector
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
Candidate.h
View.h
ParameterSet.h
EtSum.h
Phase1L1TJetSumsProducer::~Phase1L1TJetSumsProducer
~Phase1L1TJetSumsProducer() override
Definition: Phase1L1TJetSumsProducer.cc:107
L1Analysis::kTotalHt
Definition: L1AnalysisL1UpgradeDataFormat.h:18
Phase1L1TJetSumsProducer::phiLow_
double phiLow_
Definition: Phase1L1TJetSumsProducer.cc:69
edm::Event
Definition: Event.h:73
Phase1L1TJetSumsProducer::mhtAbsEtaCut_
double mhtAbsEtaCut_
Definition: Phase1L1TJetSumsProducer.cc:81
pileupReCalc_HLTpaths.trunc
trunc
Definition: pileupReCalc_HLTpaths.py:143
edm::InputTag
Definition: InputTag.h:15
Phase1L1TJetSumsProducer::mhtPtThreshold_
double mhtPtThreshold_
Definition: Phase1L1TJetSumsProducer.cc:77