CMS 3D CMS Logo

HLTRHemisphere.cc
Go to the documentation of this file.
4 
7 
9 
12 
13 #include "TVector3.h"
14 #include "TLorentzVector.h"
15 
19 
21 
23 
24 #include <vector>
25 
26 //
27 // constructors and destructor
28 //
30  : inputTag_(iConfig.getParameter<edm::InputTag>("inputTag")),
31  muonTag_(iConfig.getParameter<edm::InputTag>("muonTag")),
32  doMuonCorrection_(iConfig.getParameter<bool>("doMuonCorrection")),
33  muonEta_(iConfig.getParameter<double>("maxMuonEta")),
34  min_Jet_Pt_(iConfig.getParameter<double>("minJetPt")),
35  max_Eta_(iConfig.getParameter<double>("maxEta")),
36  max_NJ_(iConfig.getParameter<int>("maxNJ")),
37  accNJJets_(iConfig.getParameter<bool>("acceptNJ")) {
38  LogDebug("") << "Input/minJetPt/maxEta/maxNJ/acceptNJ : " << inputTag_.encode() << " " << min_Jet_Pt_ << "/"
39  << max_Eta_ << "/" << max_NJ_ << "/" << accNJJets_ << ".";
40 
41  m_theJetToken = consumes<edm::View<reco::Jet>>(inputTag_);
42  m_theMuonToken = consumes<std::vector<reco::RecoChargedCandidate>>(muonTag_);
43  //register your products
44  produces<std::vector<math::XYZTLorentzVector>>();
45 }
46 
48 
51  desc.add<edm::InputTag>("inputTag", edm::InputTag("hltMCJetCorJetIcone5HF07"));
52  desc.add<edm::InputTag>("muonTag", edm::InputTag(""));
53  desc.add<bool>("doMuonCorrection", false);
54  desc.add<double>("maxMuonEta", 2.1);
55  desc.add<double>("minJetPt", 30.0);
56  desc.add<double>("maxEta", 3.0);
57  desc.add<int>("maxNJ", 7);
58  desc.add<bool>("acceptNJ", true);
59  descriptions.add("hltRHemisphere", desc);
60 }
61 
62 //
63 // member functions
64 //
65 
66 // ------------ method called to produce the data ------------
68  using namespace std;
69  using namespace edm;
70  using namespace reco;
71  using namespace math;
72  using namespace trigger;
73 
75 
76  // get hold of collection of objects
77  // Handle<CaloJetCollection> jets;
79  iEvent.getByToken(m_theJetToken, jets);
80 
81  // get hold of the muons, if necessary
84  iEvent.getByToken(m_theMuonToken, muons);
85 
86  // The output Collection
87  std::unique_ptr<vector<math::XYZTLorentzVector>> Hemispheres(new vector<math::XYZTLorentzVector>);
88 
89  // look at all objects, check cuts and add to filter object
90  int n(0);
91  vector<math::XYZTLorentzVector> JETS;
92  for (auto const& i : *jets) {
93  if (std::abs(i.eta()) < max_Eta_ && i.pt() >= min_Jet_Pt_) {
94  JETS.push_back(i.p4());
95  n++;
96  }
97  }
98 
99  if (n > max_NJ_ && max_NJ_ != -1) {
100  iEvent.put(std::move(Hemispheres));
101  return accNJJets_; // too many jets, accept for timing
102  }
103 
104  if (doMuonCorrection_) {
105  const int nMu = 2;
106  int muonIndex[nMu] = {-1, -1};
107  std::vector<reco::RecoChargedCandidate>::const_iterator muonIt;
108  int index = 0;
109  int nPassMu = 0;
110  for (muonIt = muons->begin(); muonIt != muons->end(); muonIt++, index++) {
111  if (std::abs(muonIt->eta()) > muonEta_ || muonIt->pt() < min_Jet_Pt_)
112  continue; // skip muons out of eta range or too low pT
113  if (nPassMu >= 2) { // if we have already accepted two muons, accept the event
114  iEvent.put(std::move(Hemispheres)); // too many muons, accept for timing
115  return true;
116  }
117  muonIndex[nPassMu++] = index;
118  }
119  //muons as MET
120  this->ComputeHemispheres(Hemispheres, JETS);
121  //lead muon as jet
122  if (nPassMu > 0) {
123  std::vector<math::XYZTLorentzVector> muonJets;
124  reco::RecoChargedCandidate leadMu = muons->at(muonIndex[0]);
125  muonJets.push_back(leadMu.p4());
126  Hemispheres->push_back(leadMu.p4());
127  this->ComputeHemispheres(Hemispheres, JETS, &muonJets); // lead muon as jet
128  if (nPassMu > 1) { // two passing muons
129  muonJets.pop_back();
130  reco::RecoChargedCandidate secondMu = muons->at(muonIndex[1]);
131  muonJets.push_back(secondMu.p4());
132  Hemispheres->push_back(secondMu.p4());
133  this->ComputeHemispheres(Hemispheres, JETS, &muonJets); // lead muon as v, second muon as jet
134  muonJets.push_back(leadMu.p4());
135  this->ComputeHemispheres(Hemispheres, JETS, &muonJets); // both muon as jets
136  }
137  }
138  } else { // do MuonCorrection==false
139  if (n < 2)
140  return false; // not enough jets and not adding in muons
141  this->ComputeHemispheres(Hemispheres, JETS); // don't do the muon isolation, just run once and done
142  }
143  //Format:
144  // 0 muon: 2 hemispheres (2)
145  // 1 muon: 2 hemisheress + leadMuP4 + 2 hemispheres (5)
146  // 2 muon: 2 hemispheres + leadMuP4 + 2 hemispheres + 2ndMuP4 + 4 Hemispheres (10)
147  iEvent.put(std::move(Hemispheres));
148  return true;
149 }
150 
151 void HLTRHemisphere::ComputeHemispheres(std::unique_ptr<std::vector<math::XYZTLorentzVector>>& hlist,
152  const std::vector<math::XYZTLorentzVector>& JETS,
153  std::vector<math::XYZTLorentzVector>* extraJets) {
154  using namespace math;
155  using namespace reco;
156  XYZTLorentzVector j1R(0.1, 0., 0., 0.1);
157  XYZTLorentzVector j2R(0.1, 0., 0., 0.1);
158  int nJets = JETS.size();
159  if (extraJets)
160  nJets += extraJets->size();
161 
162  if (nJets < 2) { // put empty hemispheres if not enough jets
163  hlist->push_back(j1R);
164  hlist->push_back(j2R);
165  return;
166  }
167  unsigned int N_comb = pow(2, nJets); // compute the number of combinations of jets possible
168  //Make the hemispheres
169  double M_minR = 9999999999.0;
170  unsigned int j_count;
171  for (unsigned int i = 0; i < N_comb; i++) {
172  XYZTLorentzVector j_temp1, j_temp2;
173  unsigned int itemp = i;
174  j_count = N_comb / 2;
175  unsigned int count = 0;
176  while (j_count > 0) {
177  if (itemp / j_count == 1) {
178  if (count < JETS.size())
179  j_temp1 += JETS.at(count);
180  else
181  j_temp1 += extraJets->at(count - JETS.size());
182  } else {
183  if (count < JETS.size())
184  j_temp2 += JETS.at(count);
185  else
186  j_temp2 += extraJets->at(count - JETS.size());
187  }
188  itemp -= j_count * (itemp / j_count);
189  j_count /= 2;
190  count++;
191  }
192  double M_temp = j_temp1.M2() + j_temp2.M2();
193  if (M_temp < M_minR) {
194  M_minR = M_temp;
195  j1R = j_temp1;
196  j2R = j_temp2;
197  }
198  }
199 
200  hlist->push_back(j1R);
201  hlist->push_back(j2R);
202  return;
203 }
204 
ConfigurationDescriptions.h
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
Handle.h
HLTRHemisphere
Definition: HLTRHemisphere.h:28
electrons_cff.bool
bool
Definition: electrons_cff.py:366
HLTRHemisphere::doMuonCorrection_
bool doMuonCorrection_
Definition: HLTRHemisphere.h:40
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
ESHandle.h
HLTRHemisphere::accNJJets_
bool accNJJets_
Definition: HLTRHemisphere.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TriggerFilterObjectWithRefs.h
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
XYZTLorentzVector
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:25
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
HLTRHemisphere::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: HLTRHemisphere.cc:67
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HLTRHemisphere::~HLTRHemisphere
~HLTRHemisphere() override
HLTRHemisphere::m_theJetToken
edm::EDGetTokenT< edm::View< reco::Jet > > m_theJetToken
Definition: HLTRHemisphere.h:36
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLTRHemisphere::min_Jet_Pt_
double min_Jet_Pt_
Definition: HLTRHemisphere.h:42
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
HLTRHemisphere::max_Eta_
double max_Eta_
Definition: HLTRHemisphere.h:43
HLTRHemisphere::inputTag_
edm::InputTag inputTag_
Definition: HLTRHemisphere.h:38
HLTRHemisphere::muonEta_
double muonEta_
Definition: HLTRHemisphere.h:41
HLTRHemisphere::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTRHemisphere.cc:49
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::LeafCandidate::p4
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:114
HLTRHemisphere::muonTag_
edm::InputTag muonTag_
Definition: HLTRHemisphere.h:39
edm::InputTag::encode
std::string encode() const
Definition: InputTag.cc:159
HLTRHemisphere::max_NJ_
int max_NJ_
Definition: HLTRHemisphere.h:44
reco::RecoChargedCandidate
Definition: RecoChargedCandidate.h:15
edm::EventSetup
Definition: EventSetup.h:58
HLTRHemisphere::m_theMuonToken
edm::EDGetTokenT< std::vector< reco::RecoChargedCandidate > > m_theMuonToken
Definition: HLTRHemisphere.h:37
InputTag.h
reco::JetExtendedAssociation::LorentzVector
math::PtEtaPhiELorentzVectorF LorentzVector
Definition: JetExtendedAssociation.h:25
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Ref.h
math
Definition: choleskyInversion.h:19
RecoChargedCandidate.h
EventSetup.h
HLTRHemisphere.h
HLTRHemisphere::ComputeHemispheres
void ComputeHemispheres(std::unique_ptr< std::vector< math::XYZTLorentzVector >> &hlist, const std::vector< math::XYZTLorentzVector > &JETS, std::vector< math::XYZTLorentzVector > *extraJets=nullptr)
Definition: HLTRHemisphere.cc:151
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
trigger
Definition: HLTPrescaleTableCond.h:8
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
HLTRHemisphere::HLTRHemisphere
HLTRHemisphere(const edm::ParameterSet &)
Definition: HLTRHemisphere.cc:29
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15