CMS 3D CMS Logo

L1TJetsMatching.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RecoTauTag/HLTProducers
4 // Class: L1TJetsMatching
5 //
16 //
17 // Original Author: Vukasin Milosevic
18 // Created: Thu, 01 Jun 2017 17:23:00 GMT
19 //
20 //
21 
22 
23 
24 
25 #ifndef RecoTauTag_HLTProducers_L1TJetsMatching_h
26 #define RecoTauTag_HLTProducers_L1TJetsMatching_h
27 
28 // user include files
40 
41 #include "Math/GenVector/VectorUtil.h"
45 
48 
49 #include <map>
50 #include <vector>
51 
52 template< typename T>
54  public:
55  explicit L1TJetsMatching(const edm::ParameterSet&);
56  ~L1TJetsMatching() override;
57  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
58  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
59 
60  private:
61 
64  const double pt1Min_;
65  const double pt2Min_;
66  const double pt3Min_;
67  const double mjjMin_;
68  const double matchingR_;
69  const double matchingR2_;
70  };
71  //
72  // class decleration
73  //
74  template< typename T>
75  std::pair<std::vector<T>,std::vector<T>> categorise(const std::vector<T>& pfMatchedJets, double pt1, double pt2, double pt3, double Mjj)
76  {
77  std::pair<std::vector<T>,std::vector<T>> output;
78  unsigned int i1 = 0;
79  unsigned int i2 = 0;
80  double mjj = 0;
81  if (pfMatchedJets.size()>1){
82  for (unsigned int i = 0; i < pfMatchedJets.size()-1; i++){
83 
84  const T & myJet1 = (pfMatchedJets)[i];
85 
86  for (unsigned int j = i+1; j < pfMatchedJets.size(); j++)
87  {
88  const T & myJet2 = (pfMatchedJets)[j];
89 
90  const double mjj_test = (myJet1.p4()+myJet2.p4()).M();
91 
92  if (mjj_test > mjj){
93 
94  mjj =mjj_test;
95  i1 = i;
96  i2 = j;
97  }
98  }
99  }
100 
101  const T & myJet1 = (pfMatchedJets)[i1];
102  const T & myJet2 = (pfMatchedJets)[i2];
103 
104  if ((mjj > Mjj) && (myJet1.pt() >= pt1) && (myJet2.pt() > pt2) )
105  {
106 
107  output.first.push_back(myJet1);
108  output.first.push_back(myJet2);
109 
110  }
111 
112  if ((mjj > Mjj) && (myJet1.pt() < pt3) && (myJet1.pt() > pt2) && (myJet2.pt() > pt2))
113  {
114 
115  const T & myJetTest = (pfMatchedJets)[0];
116  if (myJetTest.pt()>pt3){
117  output.second.push_back(myJet1);
118  output.second.push_back(myJet2);
119  output.second.push_back(myJetTest);
120 
121  }
122  }
123 
124  }
125 
126  return output;
127 
128  }
129  template< typename T>
131  jetSrc_ ( consumes<std::vector<T>> (iConfig.getParameter<edm::InputTag>("JetSrc" ) ) ),
132  jetTrigger_( consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("L1JetTrigger") ) ),
133  pt1Min_ ( iConfig.getParameter<double>("pt1Min")),
134  pt2Min_ ( iConfig.getParameter<double>("pt2Min")),
135  pt3Min_ ( iConfig.getParameter<double>("pt3Min")),
136  mjjMin_ ( iConfig.getParameter<double>("mjjMin")),
137  matchingR_ ( iConfig.getParameter<double>("matchingR")),
139  {
140  produces<std::vector<T>>("TwoJets");
141  produces<std::vector<T>>("ThreeJets");
142 
143  }
144  template< typename T>
146 
147  template< typename T>
149  {
150 
151  unique_ptr<std::vector<T>> pfMatchedJets(new std::vector<T>);
152  std::pair<std::vector<T>,std::vector<T>> output;
153 
154 
155 
156  // Getting HLT jets to be matched
158  iEvent.getByToken( jetSrc_, pfJets );
159 
161  iEvent.getByToken(jetTrigger_,l1TriggeredJets);
162 
163  //l1t::TauVectorRef jetCandRefVec;
164  l1t::JetVectorRef jetCandRefVec;
165  l1TriggeredJets->getObjects( trigger::TriggerL1Jet,jetCandRefVec);
166 
167  math::XYZPoint a(0.,0.,0.);
168 
169  //std::cout<<"PFsize= "<<pfJets->size()<<endl<<" L1size= "<<jetCandRefVec.size()<<std::endl;
170  for(unsigned int iJet = 0; iJet < pfJets->size(); iJet++){
171  const T & myJet = (*pfJets)[iJet];
172  for(unsigned int iL1Jet = 0; iL1Jet < jetCandRefVec.size(); iL1Jet++){
173  // Find the relative L2pfJets, to see if it has been reconstructed
174  // if ((iJet<3) && (iL1Jet==0)) std::cout<<myJet.p4().Pt()<<" ";
175  if ((reco::deltaR2(myJet.p4(), jetCandRefVec[iL1Jet]->p4()) < matchingR2_ ) && (myJet.pt()>pt2Min_)) {
176  pfMatchedJets->push_back(myJet);
177  break;
178  }
179  }
180  }
181 
182  output= categorise(*pfMatchedJets,pt1Min_, pt2Min_, pt3Min_, mjjMin_);
183  unique_ptr<std::vector<T>> output1(new std::vector<T>(output.first));
184  unique_ptr<std::vector<T>> output2(new std::vector<T>(output.second));
185 
186  iEvent.put(std::move(output1),"TwoJets");
187  iEvent.put(std::move(output2),"ThreeJets");
188 
189  }
190  template< typename T>
192  {
194  desc.add<edm::InputTag>("L1JetTrigger", edm::InputTag("hltL1DiJetVBF"))->setComment("Name of trigger filter" );
195  desc.add<edm::InputTag>("JetSrc" , edm::InputTag("hltAK4PFJetsTightIDCorrected"))->setComment("Input collection of PFJets");
196  desc.add<double> ("pt1Min",110.0)->setComment("Minimal pT1 of PFJets to match");
197  desc.add<double> ("pt2Min",35.0)->setComment("Minimal pT2 of PFJets to match");
198  desc.add<double> ("pt3Min",110.0)->setComment("Minimum pT3 of PFJets to match");
199  desc.add<double> ("mjjMin",650.0)->setComment("Minimal mjj of matched PFjets");
200  desc.add<double> ("matchingR",0.5)->setComment("dR value used for matching");
201  descriptions.setComment("This module produces collection of PFJetss matched to L1 Taus / Jets passing a HLT filter (Only p4 and vertex of returned PFJetss are set).");
202  descriptions.add(defaultModuleLabel<L1TJetsMatching<T>>(), desc);
203  }
204 
205 
206 
207 #endif
void setComment(std::string const &value)
const double mjjMin_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
L1TJetsMatching(const edm::ParameterSet &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< JetRef > JetVectorRef
Definition: Jet.h:15
std::string defaultModuleLabel()
const edm::EDGetTokenT< std::vector< T > > jetSrc_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
~L1TJetsMatching() override
const double pt3Min_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:224
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > jetTrigger_
const double matchingR2_
void setComment(std::string const &value)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const double pt1Min_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
double a
Definition: hdecay.h:121
std::pair< std::vector< T >, std::vector< T > > categorise(const std::vector< T > &pfMatchedJets, double pt1, double pt2, double pt3, double Mjj)
const double matchingR_
long double T
const double pt2Min_
def move(src, dest)
Definition: eostools.py:511