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 mjjMin_;
67  const double matchingR_;
68  const double matchingR2_;
69  };
70  //
71  // class decleration
72  //
73  using namespace reco ;
74  using namespace std ;
75  using namespace edm ;
76  using namespace trigger;
77 
78 
79  template< typename T>
80  std::pair<std::vector<T>,std::vector<T>> categorise(const std::vector<T>& pfMatchedJets, double pt1, double pt2, double Mjj)
81  {
82  std::pair<std::vector<T>,std::vector<T>> output;
83  unsigned int i1 = 0;
84  unsigned int i2 = 0;
85  double mjj = 0;
86  if (pfMatchedJets.size()>1){
87  for (unsigned int i = 0; i < pfMatchedJets.size()-1; i++){
88 
89  const T & myJet1 = (pfMatchedJets)[i];
90 
91  for (unsigned int j = i+1; j < pfMatchedJets.size(); j++)
92  {
93  const T & myJet2 = (pfMatchedJets)[j];
94 
95  const double mjj_test = (myJet1.p4()+myJet2.p4()).M();
96 
97  if (mjj_test > mjj){
98 
99  mjj =mjj_test;
100  i1 = i;
101  i2 = j;
102  }
103  }
104  }
105 
106  const T & myJet1 = (pfMatchedJets)[i1];
107  const T & myJet2 = (pfMatchedJets)[i2];
108 
109  if ((mjj > Mjj) && (myJet1.pt() >= pt1) && (myJet2.pt() > pt2) )
110  {
111 
112  output.first.push_back(myJet1);
113  output.first.push_back(myJet2);
114 
115  }
116 
117  if ((mjj > Mjj) && (myJet1.pt() < pt1) && (myJet1.pt() > pt2) && (myJet2.pt() > pt2))
118  {
119 
120  const T & myJetTest = (pfMatchedJets)[0];
121  if (myJetTest.pt()>pt1){
122  output.second.push_back(myJet1);
123  output.second.push_back(myJet2);
124  output.second.push_back(myJetTest);
125 
126  }
127  }
128 
129  }
130 
131  return output;
132 
133  }
134  template< typename T>
136  jetSrc_ ( consumes<std::vector<T>> (iConfig.getParameter<InputTag>("JetSrc" ) ) ),
137  jetTrigger_( consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<InputTag>("L1JetTrigger") ) ),
138  pt1Min_ ( iConfig.getParameter<double>("pt1Min")),
139  pt2Min_ ( iConfig.getParameter<double>("pt2Min")),
140  mjjMin_ ( iConfig.getParameter<double>("mjjMin")),
141  matchingR_ ( iConfig.getParameter<double>("matchingR")),
143  {
144  produces<std::vector<T>>("TwoJets");
145  produces<std::vector<T>>("ThreeJets");
146 
147  }
148  template< typename T>
150 
151  template< typename T>
153  {
154 
155  unique_ptr<std::vector<T>> pfMatchedJets(new std::vector<T>);
156  std::pair<std::vector<T>,std::vector<T>> output;
157 
158 
159 
160  // Getting HLT jets to be matched
162  iEvent.getByToken( jetSrc_, pfJets );
163 
165  iEvent.getByToken(jetTrigger_,l1TriggeredJets);
166 
167  //l1t::TauVectorRef jetCandRefVec;
168  l1t::JetVectorRef jetCandRefVec;
169  l1TriggeredJets->getObjects( trigger::TriggerL1Jet,jetCandRefVec);
170 
171  math::XYZPoint a(0.,0.,0.);
172 
173  //std::cout<<"PFsize= "<<pfJets->size()<<endl<<" L1size= "<<jetCandRefVec.size()<<std::endl;
174  for(unsigned int iJet = 0; iJet < pfJets->size(); iJet++){
175  const T & myJet = (*pfJets)[iJet];
176  for(unsigned int iL1Jet = 0; iL1Jet < jetCandRefVec.size(); iL1Jet++){
177  // Find the relative L2pfJets, to see if it has been reconstructed
178  // if ((iJet<3) && (iL1Jet==0)) std::cout<<myJet.p4().Pt()<<" ";
179  if ((reco::deltaR2(myJet.p4(), jetCandRefVec[iL1Jet]->p4()) < matchingR2_ ) && (myJet.pt()>pt2Min_)) {
180  pfMatchedJets->push_back(myJet);
181  break;
182  }
183  }
184  }
185 
186  output= categorise(*pfMatchedJets,pt1Min_,pt2Min_, mjjMin_);
187  unique_ptr<std::vector<T>> output1(new std::vector<T>(output.first));
188  unique_ptr<std::vector<T>> output2(new std::vector<T>(output.second));
189 
190  iEvent.put(std::move(output1),"TwoJets");
191  iEvent.put(std::move(output2),"ThreeJets");
192 
193  }
194  template< typename T>
196  {
198  desc.add<edm::InputTag>("L1JetTrigger", edm::InputTag("hltL1DiJetVBF"))->setComment("Name of trigger filter" );
199  desc.add<edm::InputTag>("JetSrc" , edm::InputTag("hltAK4PFJetsTightIDCorrected"))->setComment("Input collection of PFJets");
200  desc.add<double> ("pt1Min",95.0)->setComment("Minimal pT1 of PFJets to match");
201  desc.add<double> ("pt2Min",35.0)->setComment("Minimal pT2 of PFJets to match");
202  desc.add<double> ("mjjMin",650.0)->setComment("Minimal mjj of matched PFjets");
203  desc.add<double> ("matchingR",0.5)->setComment("dR value used for matching");
204  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).");
205  descriptions.add(defaultModuleLabel<L1TJetsMatching<T>>(), desc);
206  }
207 
208 
209 
210 #endif
std::string defaultModuleLabel()
void setComment(std::string const &value)
const double mjjMin_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
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:508
std::vector< JetRef > JetVectorRef
Definition: Jet.h:14
const edm::EDGetTokenT< std::vector< T > > jetSrc_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
~L1TJetsMatching() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:230
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::pair< std::vector< T >, std::vector< T > > categorise(const std::vector< T > &pfMatchedJets, double pt1, double pt2, double Mjj)
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > jetTrigger_
const double matchingR2_
void setComment(std::string const &value)
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)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:121
const double matchingR_
long double T
const double pt2Min_
def move(src, dest)
Definition: eostools.py:510