CMS 3D CMS Logo

L1THLTTauMatching.cc
Go to the documentation of this file.
2 #include "Math/GenVector/VectorUtil.h"
12 
13 //
14 // class declaration
15 //
16 using namespace reco;
17 using namespace std;
18 using namespace edm;
19 using namespace trigger;
20 
22  : jetSrc(consumes<PFTauCollection>(iConfig.getParameter<InputTag>("JetSrc"))),
23  tauTrigger(consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<InputTag>("L1TauTrigger"))),
24  mEt_Min(iConfig.getParameter<double>("EtMin")),
25  reduceTauContent(iConfig.getParameter<bool>("ReduceTauContent")),
26  keepOriginalVertex(iConfig.getParameter<bool>("KeepOriginalVertex")) {
27  produces<PFTauCollection>();
28 }
29 
31  unique_ptr<PFTauCollection> tauL2jets(new PFTauCollection);
32 
33  constexpr double matchingR2 = 0.5 * 0.5;
34 
35  // Getting HLT jets to be matched
37  iEvent.getByToken(jetSrc, tauJets);
38 
40  iEvent.getByToken(tauTrigger, l1TriggeredTaus);
41 
42  l1t::TauVectorRef tauCandRefVec;
43  l1TriggeredTaus->getObjects(trigger::TriggerL1Tau, tauCandRefVec);
44 
45  math::XYZPoint a(0., 0., 0.);
46 
47  for (unsigned int iL1Tau = 0; iL1Tau < tauCandRefVec.size(); iL1Tau++) {
48  for (unsigned int iJet = 0; iJet < tauJets->size(); iJet++) {
49  // Find the relative L2TauJets, to see if it has been reconstructed
50  const PFTau& myJet = (*tauJets)[iJet];
51  double deltaR2 = ROOT::Math::VectorUtil::DeltaR2(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect());
52  if (deltaR2 < matchingR2) {
53  if (myJet.leadChargedHadrCand().isNonnull()) {
54  a = myJet.leadChargedHadrCand()->vertex();
55  }
56 
57  auto myPFTau =
58  reduceTauContent ? PFTau(std::numeric_limits<int>::quiet_NaN(), myJet.p4(), myJet.vertex()) : PFTau(myJet);
59 
60  if (!keepOriginalVertex) {
61  myPFTau.setVertex(a);
62  }
63 
64  if (myPFTau.pt() > mEt_Min) {
65  tauL2jets->push_back(myJet);
66  }
67  break;
68  }
69  }
70  }
71 
72  iEvent.put(std::move(tauL2jets));
73 }
74 
77  desc.add<edm::InputTag>("L1TauTrigger", edm::InputTag("hltL1sDoubleIsoTau40er"))
78  ->setComment("Name of trigger filter");
79  desc.add<edm::InputTag>("JetSrc", edm::InputTag("hltSelectedPFTausTrackPt1MediumIsolationReg"))
80  ->setComment("Input collection of PFTaus");
81  desc.add<double>("EtMin", 0.0)->setComment("Minimal pT of PFTau to match");
82  desc.add<bool>("ReduceTauContent", true)->setComment("Should produce taus with reduced content (Only p4 and vertex)");
83  desc.add<bool>("KeepOriginalVertex", false)
84  ->setComment("Should use original vertex instead of setting the vertex to that of the leading charged hadron");
85  descriptions.setComment("This module produces collection of PFTaus matched to L1 Taus / Jets passing a HLT filter.");
86  descriptions.add("L1THLTTauMatching", desc);
87 }
88 
const edm::EDGetTokenT< reco::PFTauCollection > jetSrc
L1THLTTauMatching(const edm::ParameterSet &)
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
const CandidatePtr & leadChargedHadrCand() const
Definition: PFTau.cc:63
const Point & vertex() const override
vertex position (overwritten by PF...)
const LorentzVector & p4() const final
four-momentum Lorentz vector
const bool keepOriginalVertex
int iEvent
Definition: GenABIO.cc:224
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tauTrigger
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
std::vector< TauRef > TauVectorRef
Definition: Tau.h:14
virtual const Point & vertex() const =0
vertex position
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const double mEt_Min
void setComment(std::string const &value)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const bool reduceTauContent
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:119
def move(src, dest)
Definition: eostools.py:511