Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:43

0001 // makes CaloTowerCandidates from CaloTowers
0002 // original author: L.Lista INFN, modifyed by: F.Ratnikov UMd
0003 // Author for regionality A. Nikitenko
0004 // Modified by S. Gennai + T. Strebler
0005 
0006 #include "DataFormats/RecoCandidate/interface/RecoCaloTowerCandidate.h"
0007 #include "DataFormats/Common/interface/Handle.h"
0008 #include "DataFormats/Math/interface/deltaR.h"
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "RecoTauTag/HLTProducers/interface/CaloTowerFromL1TSeededCreatorForTauHLT.h"
0013 // Math
0014 #include "Math/GenVector/VectorUtil.h"
0015 #include <cmath>
0016 
0017 using namespace edm;
0018 using namespace reco;
0019 using namespace std;
0020 
0021 CaloTowerFromL1TSeededCreatorForTauHLT::CaloTowerFromL1TSeededCreatorForTauHLT(const ParameterSet& p)
0022     : m_verbose(p.getUntrackedParameter<int>("verbose", 0)),
0023       m_towers_token(consumes<CaloTowerCollection>(p.getParameter<InputTag>("towers"))),
0024       m_cone(p.getParameter<double>("UseTowersInCone")),
0025       m_tauTrigger_token(consumes<trigger::TriggerFilterObjectWithRefs>(p.getParameter<InputTag>("TauTrigger"))),
0026       m_EtThreshold(p.getParameter<double>("minimumEt")),
0027       m_EThreshold(p.getParameter<double>("minimumE")) {
0028   produces<CaloTowerCollection>();
0029 }
0030 
0031 CaloTowerFromL1TSeededCreatorForTauHLT::~CaloTowerFromL1TSeededCreatorForTauHLT() = default;
0032 
0033 void CaloTowerFromL1TSeededCreatorForTauHLT::produce(StreamID sid, Event& evt, const EventSetup& stp) const {
0034   edm::Handle<CaloTowerCollection> caloTowers;
0035   evt.getByToken(m_towers_token, caloTowers);
0036 
0037   double m_cone2 = m_cone * m_cone;
0038 
0039   // L1 seeds
0040   edm::Handle<trigger::TriggerFilterObjectWithRefs> l1TriggeredTaus;
0041   evt.getByToken(m_tauTrigger_token, l1TriggeredTaus);
0042 
0043   auto cands = std::make_unique<CaloTowerCollection>();
0044   cands->reserve(caloTowers->size());
0045 
0046   l1t::TauVectorRef tauCandRefVec;
0047   l1TriggeredTaus->getObjects(trigger::TriggerL1Tau, tauCandRefVec);
0048 
0049   for (auto const& tauCandRef : tauCandRefVec) {
0050     for (auto const& cal : *caloTowers) {
0051       bool isAccepted = false;
0052       if (m_verbose == 2) {
0053         edm::LogInfo("JetDebugInfo") << "CaloTowerFromL1TSeededCreatorForTauHLT::produce->  tower et/eta/phi/e: "
0054                                      << cal.et() << '/' << cal.eta() << '/' << cal.phi() << '/' << cal.energy()
0055                                      << " is...";
0056       }
0057       if (cal.et() >= m_EtThreshold && cal.energy() >= m_EThreshold) {
0058         math::PtEtaPhiELorentzVector p(cal.et(), cal.eta(), cal.phi(), cal.energy());
0059         double delta2 = deltaR2((tauCandRef->p4()).Vect(), p);
0060         if (delta2 < m_cone2) {
0061           isAccepted = true;
0062           cands->push_back(cal);
0063         }
0064       }
0065 
0066       if (m_verbose == 2) {
0067         if (isAccepted)
0068           edm::LogInfo("JetDebugInfo") << "accepted \n";
0069         else
0070           edm::LogInfo("JetDebugInfo") << "rejected \n";
0071       }
0072     }
0073   }
0074 
0075   evt.put(std::move(cands));
0076 }
0077 
0078 void CaloTowerFromL1TSeededCreatorForTauHLT::fillDescriptions(edm::ConfigurationDescriptions& desc) {
0079   edm::ParameterSetDescription aDesc;
0080 
0081   aDesc.add<edm::InputTag>("TauTrigger", edm::InputTag("hltL1sDoubleIsoTau40er"))
0082       ->setComment("Name of trigger filter for L1 seeds");
0083   aDesc.add<edm::InputTag>("towers", edm::InputTag("towerMaker"))->setComment("Input tower collection");
0084   aDesc.add<double>("UseTowersInCone", 0.8)->setComment("Radius of cone around seed");
0085   aDesc.add<double>("minimumE", 0.8)->setComment("Minimum tower energy");
0086   aDesc.add<double>("minimumEt", 0.5)->setComment("Minimum tower ET");
0087   aDesc.addUntracked<int>("verbose", 0)->setComment("Verbosity level; 0=silent");
0088 
0089   desc.add("CaloTowerFromL1TSeededCreatorForTauHLT", aDesc);
0090   desc.setComment("Produce tower collection around L1 particle seed.");
0091 }
0092 
0093 #include "FWCore/Framework/interface/MakerMacros.h"
0094 DEFINE_FWK_MODULE(CaloTowerFromL1TSeededCreatorForTauHLT);