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/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       mTauTrigger_token(consumes<l1t::TauBxCollection>(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 CaloTowerFromL1TCreatorForTauHLT::~CaloTowerFromL1TCreatorForTauHLT() {}
0033 
0034 void CaloTowerFromL1TCreatorForTauHLT::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<l1t::TauBxCollection> 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   if (jetsgen.isValid()) {
0047     for (auto myL1Jet = jetsgen->begin(mBX); myL1Jet != jetsgen->end(mBX); myL1Jet++) {
0048       if (idTau == mTauId) {
0049         double Sum08 = 0.;
0050         unsigned idx = 0;
0051         for (; idx < caloTowers->size(); idx++) {
0052           const CaloTower* cal = &((*caloTowers)[idx]);
0053           bool isAccepted = false;
0054           if (mVerbose == 2) {
0055             edm::LogInfo("JetDebugInfo") << "CaloTowerFromL1TCreatorForTauHLT::produce-> " << idx
0056                                          << " tower et/eta/phi/e: " << cal->et() << '/' << cal->eta() << '/'
0057                                          << cal->phi() << '/' << cal->energy() << " is...";
0058           }
0059           if (cal->et() >= mEtThreshold && cal->energy() >= mEThreshold) {
0060             math::PtEtaPhiELorentzVector p(cal->et(), cal->eta(), cal->phi(), cal->energy());
0061             double delta = ROOT::Math::VectorUtil::DeltaR((*myL1Jet).p4().Vect(), p);
0062             if (delta < mCone) {
0063               isAccepted = true;
0064               Sum08 += cal->et();
0065               cands->push_back(*cal);
0066             }
0067           }
0068           if (mVerbose == 2) {
0069             if (isAccepted)
0070               edm::LogInfo("JetDebugInfo") << "accepted \n";
0071             else
0072               edm::LogInfo("JetDebugInfo") << "rejected \n";
0073           }
0074         }
0075       }
0076       idTau++;
0077     }
0078   } else {
0079     edm::LogWarning("MissingProduct") << "L1Upgrade jet bx collection not found." << std::endl;
0080   }
0081 
0082   evt.put(std::move(cands));
0083 }
0084 
0085 void CaloTowerFromL1TCreatorForTauHLT::fillDescriptions(edm::ConfigurationDescriptions& desc) {
0086   edm::ParameterSetDescription aDesc;
0087 
0088   aDesc.add<edm::InputTag>("TauTrigger", edm::InputTag("caloStage2Digis"))->setComment("L1 Tau collection for seeding");
0089   aDesc.add<edm::InputTag>("towers", edm::InputTag("towerMaker"))->setComment("Input tower collection");
0090   aDesc.add<int>("TauId", 0)->setComment("Item from L1 Tau collection used for seeding. From 0 to 11");
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.add<int>("BX", 0)->setComment("Set bunch crossing; 0 = in time, -1 = previous, 1 = following");
0095   aDesc.addUntracked<int>("verbose", 0)->setComment("Verbosity level; 0=silent");
0096 
0097   desc.add("CaloTowerFromL1TCreatorForTauHLT", aDesc);
0098   desc.setComment("Produce tower collection around L1 particle seed.");
0099 }
0100 
0101 #include "FWCore/Framework/interface/MakerMacros.h"
0102 DEFINE_FWK_MODULE(CaloTowerFromL1TCreatorForTauHLT);