File indexing completed on 2024-04-06 12:27:43
0001
0002
0003
0004
0005
0006 #include "DataFormats/RecoCandidate/interface/RecoCaloTowerCandidate.h"
0007 #include "DataFormats/Common/interface/Handle.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "RecoTauTag/HLTProducers/interface/CaloTowerCreatorForTauHLT.h"
0012
0013 #include "Math/GenVector/VectorUtil.h"
0014 #include <cmath>
0015
0016 using namespace edm;
0017 using namespace reco;
0018 using namespace std;
0019 using namespace l1extra;
0020
0021 CaloTowerCreatorForTauHLT::CaloTowerCreatorForTauHLT(const ParameterSet& p)
0022 : mVerbose(p.getUntrackedParameter<int>("verbose", 0)),
0023 mtowers_token(consumes<CaloTowerCollection>(p.getParameter<InputTag>("towers"))),
0024 mCone(p.getParameter<double>("UseTowersInCone")),
0025 mCone2(mCone * mCone),
0026 mTauTrigger_token(consumes<L1JetParticleCollection>(p.getParameter<InputTag>("TauTrigger"))),
0027 mEtThreshold(p.getParameter<double>("minimumEt")),
0028 mEThreshold(p.getParameter<double>("minimumE")),
0029 mTauId(p.getParameter<int>("TauId")) {
0030 produces<CaloTowerCollection>();
0031 }
0032
0033 void CaloTowerCreatorForTauHLT::produce(StreamID sid, Event& evt, const EventSetup& stp) const {
0034 edm::Handle<CaloTowerCollection> caloTowers;
0035 evt.getByToken(mtowers_token, caloTowers);
0036
0037
0038 edm::Handle<L1JetParticleCollection> jetsgen;
0039 evt.getByToken(mTauTrigger_token, jetsgen);
0040
0041 std::unique_ptr<CaloTowerCollection> cands(new CaloTowerCollection);
0042 cands->reserve(caloTowers->size());
0043
0044 if (mCone < 0.) {
0045 evt.put(std::move(cands));
0046 return;
0047 }
0048
0049 int idTau = 0;
0050 L1JetParticleCollection::const_iterator myL1Jet = jetsgen->begin();
0051 for (; myL1Jet != jetsgen->end(); myL1Jet++) {
0052 if (idTau == mTauId) {
0053 unsigned idx = 0;
0054 for (; idx < caloTowers->size(); idx++) {
0055 const CaloTower* cal = &((*caloTowers)[idx]);
0056 bool isAccepted = false;
0057 if (mVerbose == 2) {
0058 edm::LogInfo("JetDebugInfo") << "CaloTowerCreatorForTauHLT::produce-> " << idx
0059 << " tower et/eta/phi/e: " << cal->et() << '/' << cal->eta() << '/' << cal->phi()
0060 << '/' << cal->energy() << " is...";
0061 }
0062 if (cal->et() >= mEtThreshold && cal->energy() >= mEThreshold) {
0063 math::PtEtaPhiELorentzVector p(cal->et(), cal->eta(), cal->phi(), cal->energy());
0064 double delta2 = ROOT::Math::VectorUtil::DeltaR2((*myL1Jet).p4().Vect(), p);
0065
0066 if (delta2 < mCone2) {
0067 isAccepted = true;
0068 cands->push_back(*cal);
0069 }
0070 }
0071 if (mVerbose == 2) {
0072 if (isAccepted)
0073 edm::LogInfo("JetDebugInfo") << "accepted \n";
0074 else
0075 edm::LogInfo("JetDebugInfo") << "rejected \n";
0076 }
0077 }
0078 }
0079 idTau++;
0080 }
0081
0082 evt.put(std::move(cands));
0083 }
0084
0085 void CaloTowerCreatorForTauHLT::fillDescriptions(edm::ConfigurationDescriptions& desc) {
0086 edm::ParameterSetDescription aDesc;
0087 aDesc.add<edm::InputTag>("TauTrigger", edm::InputTag("l1extraParticles", "Tau"))
0088 ->setComment("L1ExtraJet collection for seeding");
0089 aDesc.add<int>("TauId", 0)->setComment("Item from L1ExtraJet collection used for seeding");
0090 aDesc.add<edm::InputTag>("towers", edm::InputTag("towerMaker"))->setComment("Input tower collection");
0091 aDesc.add<double>("UseTowersInCone", 0.8)->setComment("Radius of cone around seed");
0092 aDesc.add<double>("minimumE", 0.8)->setComment("Minimum tower energy");
0093 aDesc.add<double>("minimumEt", 0.5)->setComment("Minimum tower ET");
0094 aDesc.addUntracked<int>("verbose", 0)->setComment("Verbosity level; 0=silent");
0095 desc.setComment("Produce tower collection around L1ExtraJetParticle seed.");
0096 desc.add("caloTowerMakerHLT", aDesc);
0097 }
0098
0099 #include "FWCore/Framework/interface/MakerMacros.h"
0100 DEFINE_FWK_MODULE(CaloTowerCreatorForTauHLT);