Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-16 00:05:53

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
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 // Math
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       mTauTrigger_token(consumes<L1JetParticleCollection>(p.getParameter<InputTag>("TauTrigger"))),
0026       mEtThreshold(p.getParameter<double>("minimumEt")),
0027       mEThreshold(p.getParameter<double>("minimumE")),
0028       mTauId(p.getParameter<int>("TauId")) {
0029   produces<CaloTowerCollection>();
0030 }
0031 
0032 CaloTowerCreatorForTauHLT::~CaloTowerCreatorForTauHLT() {}
0033 
0034 void CaloTowerCreatorForTauHLT::produce(StreamID sid, Event& evt, const EventSetup& stp) const {
0035   edm::Handle<CaloTowerCollection> caloTowers;
0036   evt.getByToken(mtowers_token, caloTowers);
0037 
0038   // imitate L1 seeds
0039   edm::Handle<L1JetParticleCollection> jetsgen;
0040   evt.getByToken(mTauTrigger_token, jetsgen);
0041 
0042   std::unique_ptr<CaloTowerCollection> cands(new CaloTowerCollection);
0043   cands->reserve(caloTowers->size());
0044 
0045   int idTau = 0;
0046   L1JetParticleCollection::const_iterator myL1Jet = jetsgen->begin();
0047   for (; myL1Jet != jetsgen->end(); myL1Jet++) {
0048     if (idTau == mTauId) {
0049       double Sum08 = 0.;
0050 
0051       unsigned idx = 0;
0052       for (; idx < caloTowers->size(); idx++) {
0053         const CaloTower* cal = &((*caloTowers)[idx]);
0054         bool isAccepted = false;
0055         if (mVerbose == 2) {
0056           edm::LogInfo("JetDebugInfo") << "CaloTowerCreatorForTauHLT::produce-> " << idx
0057                                        << " tower et/eta/phi/e: " << cal->et() << '/' << cal->eta() << '/' << cal->phi()
0058                                        << '/' << cal->energy() << " is...";
0059         }
0060         if (cal->et() >= mEtThreshold && cal->energy() >= mEThreshold) {
0061           math::PtEtaPhiELorentzVector p(cal->et(), cal->eta(), cal->phi(), cal->energy());
0062           double delta = ROOT::Math::VectorUtil::DeltaR((*myL1Jet).p4().Vect(), p);
0063 
0064           if (delta < mCone) {
0065             isAccepted = true;
0066             Sum08 += cal->et();
0067             cands->push_back(*cal);
0068           }
0069         }
0070         if (mVerbose == 2) {
0071           if (isAccepted)
0072             edm::LogInfo("JetDebugInfo") << "accepted \n";
0073           else
0074             edm::LogInfo("JetDebugInfo") << "rejected \n";
0075         }
0076       }
0077     }
0078     idTau++;
0079   }
0080 
0081   evt.put(std::move(cands));
0082 }
0083 
0084 void CaloTowerCreatorForTauHLT::fillDescriptions(edm::ConfigurationDescriptions& desc) {
0085   edm::ParameterSetDescription aDesc;
0086   aDesc.add<edm::InputTag>("TauTrigger", edm::InputTag("l1extraParticles", "Tau"))
0087       ->setComment("L1ExtraJet collection for seeding");
0088   aDesc.add<int>("TauId", 0)->setComment("Item from L1ExtraJet collection used for seeding");
0089   aDesc.add<edm::InputTag>("towers", edm::InputTag("towerMaker"))->setComment("Input tower collection");
0090   aDesc.add<double>("UseTowersInCone", 0.8)->setComment("Radius of cone around seed");
0091   aDesc.add<double>("minimumE", 0.8)->setComment("Minimum tower energy");
0092   aDesc.add<double>("minimumEt", 0.5)->setComment("Minimum tower ET");
0093   aDesc.addUntracked<int>("verbose", 0)->setComment("Verbosity level; 0=silent");
0094   desc.setComment("Produce tower collection around L1ExtraJetParticle seed.");
0095   desc.add("caloTowerMakerHLT", aDesc);
0096 }
0097 
0098 #include "FWCore/Framework/interface/MakerMacros.h"
0099 DEFINE_FWK_MODULE(CaloTowerCreatorForTauHLT);