test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTJetL1TMatchProducer.cc
Go to the documentation of this file.
1 #include <string>
2 
7 
12 
13 template<typename T>
15 {
16  jetsInput_ = iConfig.template getParameter<edm::InputTag>("jetsInput");
17  L1Jets_ = iConfig.template getParameter<edm::InputTag>("L1Jets");
18  DeltaR_ = iConfig.template getParameter<double>("DeltaR");
19 
20  typedef std::vector<T> TCollection;
21  m_theJetToken = consumes<TCollection>(jetsInput_);
22  m_theL1JetToken = consumes<l1t::JetBxCollection>(L1Jets_);
23  produces<TCollection> ();
24 
25 }
26 
27 template<typename T>
29 {
30 
31 }
32 
33 template<typename T>
35 {
36 
37 }
38 
39 template<typename T>
42  desc.add<edm::InputTag>("jetsInput",edm::InputTag("hltAntiKT5PFJets"));
43  desc.add<edm::InputTag>("L1Jets",edm::InputTag("hltCaloStage2Digis"));
44  desc.add<double>("DeltaR",0.5);
45  descriptions.add(defaultModuleLabel<HLTJetL1TMatchProducer<T>>(), desc);
46 }
47 
48 template<typename T>
50 {
51 
52  typedef std::vector<T> TCollection;
53 
55  iEvent.getByToken(m_theJetToken, jets);
56 
57  std::unique_ptr<TCollection> result (new TCollection);
58 
59 
61  iEvent.getByToken(m_theL1JetToken,l1Jets);
62  bool trigger_bx_only = true; // selection of BX not implemented
63 
64  if (l1Jets.isValid()){
65  typename TCollection::const_iterator jet_iter;
66  for (jet_iter = jets->begin(); jet_iter != jets->end(); ++jet_iter) {
67  bool isMatched=false;
68  for (int ibx = l1Jets->getFirstBX(); ibx <= l1Jets->getLastBX(); ++ibx) {
69  if (trigger_bx_only && (ibx != 0)) continue;
70  for (auto it=l1Jets->begin(ibx); it!=l1Jets->end(ibx); it++){
71  if (it->et() == 0) continue; // if you don't care about L1T candidates with zero ET.
72  const double deltaeta=jet_iter->eta()-it->eta();
73  const double deltaphi=deltaPhi(jet_iter->phi(),it->phi());
74  if (sqrt(deltaeta*deltaeta+deltaphi*deltaphi) < DeltaR_) isMatched=true;
75  //cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\n";
76  }
77  }
78  if (isMatched==true) result->push_back(*jet_iter);
79  } // jet_iter
80  } else {
81  edm::LogWarning("MissingProduct") << "L1Upgrade l1Jets bx collection not found." << std::endl;
82  }
83 
84  iEvent.put(std::move(result));
85 
86 }
87 
88 
std::string defaultModuleLabel()
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
virtual void produce(edm::Event &, const edm::EventSetup &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
tuple result
Definition: mps_fire.py:84
int iEvent
Definition: GenABIO.cc:230
T sqrt(T t)
Definition: SSEVec.h:18
vector< PseudoJet > jets
def move
Definition: eostools.py:510
bool isMatched(TrackingRecHit const &hit)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:75
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLTJetL1TMatchProducer(const edm::ParameterSet &)