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
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/CaloTowerFromL1TCreatorForTauHLT.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 
0020 CaloTowerFromL1TCreatorForTauHLT::CaloTowerFromL1TCreatorForTauHLT(const ParameterSet& p)
0021     : mBX(p.getParameter<int>("BX")),
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<l1t::TauBxCollection>(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 CaloTowerFromL1TCreatorForTauHLT::produce(StreamID sid, Event& evt, const EventSetup& stp) const {
0034   edm::Handle<CaloTowerCollection> caloTowers;
0035   evt.getByToken(mtowers_token, caloTowers);
0036 
0037   // imitate L1 seeds
0038   edm::Handle<l1t::TauBxCollection> 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   if (jetsgen.isValid()) {
0051     for (auto myL1Jet = jetsgen->begin(mBX); myL1Jet != jetsgen->end(mBX); 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") << "CaloTowerFromL1TCreatorForTauHLT::produce-> " << idx
0059                                          << " tower et/eta/phi/e: " << cal->et() << '/' << cal->eta() << '/'
0060                                          << cal->phi() << '/' << 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             if (delta2 < mCone2) {
0066               isAccepted = true;
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   } else {
0081     edm::LogWarning("MissingProduct") << "L1Upgrade jet bx collection not found." << std::endl;
0082   }
0083 
0084   evt.put(std::move(cands));
0085 }
0086 
0087 void CaloTowerFromL1TCreatorForTauHLT::fillDescriptions(edm::ConfigurationDescriptions& desc) {
0088   edm::ParameterSetDescription aDesc;
0089 
0090   aDesc.add<edm::InputTag>("TauTrigger", edm::InputTag("caloStage2Digis"))->setComment("L1 Tau collection for seeding");
0091   aDesc.add<edm::InputTag>("towers", edm::InputTag("towerMaker"))->setComment("Input tower collection");
0092   aDesc.add<int>("TauId", 0)->setComment("Item from L1 Tau collection used for seeding. From 0 to 11");
0093   aDesc.add<double>("UseTowersInCone", 0.8)->setComment("Radius of cone around seed");
0094   aDesc.add<double>("minimumE", 0.8)->setComment("Minimum tower energy");
0095   aDesc.add<double>("minimumEt", 0.5)->setComment("Minimum tower ET");
0096   aDesc.add<int>("BX", 0)->setComment("Set bunch crossing; 0 = in time, -1 = previous, 1 = following");
0097   aDesc.addUntracked<int>("verbose", 0)->setComment("Verbosity level; 0=silent");
0098 
0099   desc.add("CaloTowerFromL1TCreatorForTauHLT", aDesc);
0100   desc.setComment("Produce tower collection around L1 particle seed.");
0101 }
0102 
0103 #include "FWCore/Framework/interface/MakerMacros.h"
0104 DEFINE_FWK_MODULE(CaloTowerFromL1TCreatorForTauHLT);