CMS 3D CMS Logo

L1TkHTMissProducer.cc
Go to the documentation of this file.
1 // Original Author: Emmanuelle Perez,40 1-A28,+41227671915,
2 // Created: Tue Nov 12 17:03:19 CET 2013
3 
4 // system include files
5 #include <memory>
6 
7 // user include files
20 
21 using namespace l1t;
22 
24 public:
25  explicit L1TkHTMissProducer(const edm::ParameterSet&);
26  ~L1TkHTMissProducer() override;
27 
28 private:
29  //void beginJob() override;
30  void produce(edm::Event&, const edm::EventSetup&) override;
31  //void endJob() override;
32 
33  // ----------member data ---------------------------
34  float jetMinPt_; // [GeV]
35  float jetMaxEta_; // [rad]
36  bool doVtxConstrain_; // require vertex constraint
37  bool primaryVtxConstrain_; // use event primary vertex instead of leading jet (if doVtxConstrain)
38  bool useCaloJets_; // Determines whether or not calo jets are used
39  float deltaZ_; // for jets [cm] (if DoTvxConstrain)
40  float minJetEtLowPt_; // for track jets, minimum et required, depending on number of low pT tracks
42  bool displaced_; // Use prompt/displaced tracks
43  unsigned int minNtracksHighPt_;
44  unsigned int minNtracksLowPt_;
47 };
48 
50  : pvToken_(consumes<TkPrimaryVertexCollection>(iConfig.getParameter<edm::InputTag>("L1VertexInputTag"))),
51  jetToken_(consumes<TkJetCollection>(iConfig.getParameter<edm::InputTag>("L1TkJetInputTag"))) {
52  jetMinPt_ = (float)iConfig.getParameter<double>("jet_minPt");
53  jetMaxEta_ = (float)iConfig.getParameter<double>("jet_maxEta");
54  doVtxConstrain_ = iConfig.getParameter<bool>("doVtxConstrain");
55  useCaloJets_ = iConfig.getParameter<bool>("useCaloJets");
56  primaryVtxConstrain_ = iConfig.getParameter<bool>("primaryVtxConstrain");
57  deltaZ_ = (float)iConfig.getParameter<double>("deltaZ");
58  minNtracksHighPt_ = iConfig.getParameter<int>("jet_minNtracksHighPt");
59  minNtracksLowPt_ = iConfig.getParameter<int>("jet_minNtracksLowPt");
60  minJetEtLowPt_ = iConfig.getParameter<double>("jet_minJetEtLowPt");
61  minJetEtHighPt_ = iConfig.getParameter<double>("jet_minJetEtHighPt");
62  displaced_ = iConfig.getParameter<bool>("displaced");
63 
64  if (useCaloJets_)
65  produces<TkHTMissCollection>("TkCaloHTMiss");
66  else if (displaced_)
67  produces<TkHTMissCollection>("L1TrackerHTMissExtended");
68  else
69  produces<TkHTMissCollection>("L1TrackerHTMiss");
70 }
71 
73 
75  using namespace edm;
76  std::unique_ptr<TkHTMissCollection> MHTCollection(new TkHTMissCollection);
77 
78  // L1 primary vertex
80  iEvent.getByToken(pvToken_, L1VertexHandle);
81 
82  // L1 track-trigger jets
83  edm::Handle<TkJetCollection> L1TkJetsHandle;
84  iEvent.getByToken(jetToken_, L1TkJetsHandle);
85  std::vector<TkJet>::const_iterator jetIter;
86 
87  if (!L1TkJetsHandle.isValid() && !displaced_) {
88  LogError("TkHTMissProducer") << "\nWarning: TkJetCollection not found in the event. Exit\n";
89  return;
90  }
91 
92  if (!L1TkJetsHandle.isValid() && displaced_) {
93  LogError("TkHTMissProducer") << "\nWarning: TkJetExtendedCollection not found in the event. Exit\n";
94  return;
95  }
96 
97  // ----------------------------------------------------------------------------------------------
98  // if primaryVtxConstrain_, use the primary vertex instead of z position from leading jet
99  // ----------------------------------------------------------------------------------------------
100  float evtZVtx = 999;
101  bool foundVtx = false;
102  edm::Ref<TkPrimaryVertexCollection> L1VtxRef; // null reference
103 
104  if (useCaloJets_) {
106  if (!L1VertexHandle.isValid()) {
107  LogError("L1TkHTMissProducer") << "\nWarning: TkPrimaryVertexCollection not found in the event. Exit\n";
108  return;
109  } else {
110  std::vector<TkPrimaryVertex>::const_iterator vtxIter = L1VertexHandle->begin();
111  // by convention, the first vertex in the collection is the one that should
112  // be used by default
113  evtZVtx = vtxIter->zvertex();
114  foundVtx = true;
115  int ivtx = 0;
116  edm::Ref<TkPrimaryVertexCollection> vtxRef(L1VertexHandle, ivtx);
117  L1VtxRef = vtxRef;
118  }
119  } //endif primaryVtxConstrain_
120 
121  // ----------------------------------------------------------------------------------------------
122  // using z position of leading jet to define "event vertex"
123  // ----------------------------------------------------------------------------------------------
124  float zvtx_jetpt = -1.0; //pt of jet determining the event vertex
125  float jetVtxMax = 99.; //find z position of leading jet that has a z vertex!
126 
128  for (jetIter = L1TkJetsHandle->begin(); jetIter != L1TkJetsHandle->end(); ++jetIter) {
129  int ibx = jetIter->bx(); // only consider jets from the central BX
130  if (ibx != 0)
131  continue;
132 
133  float tmp_jet_vtx = jetIter->jetVtx();
134  float tmp_jet_pt = jetIter->pt();
135  float tmp_jet_eta = jetIter->eta();
136  if (tmp_jet_pt < jetMinPt_)
137  continue;
138  if (fabs(tmp_jet_eta) > jetMaxEta_)
139  continue;
140  if (fabs(tmp_jet_vtx) > jetVtxMax)
141  continue;
142 
143  // find vertex position of leading jet
144  if (tmp_jet_pt > zvtx_jetpt) {
145  evtZVtx = tmp_jet_vtx;
146  zvtx_jetpt = tmp_jet_pt;
147  foundVtx = true;
148  }
149  } //end loop over jets
150  } //endif z position from leading jet
151 
152  float sumPx_calo = 0;
153  float sumPy_calo = 0;
154  float HT_calo = 0;
155 
156  if (doVtxConstrain_ && !foundVtx)
157  LogWarning("L1TkHTMissProducer") << "Didn't find any z vertex (based on jet vertices) for this event!\n";
158 
159  // loop over jets
160  for (jetIter = L1TkJetsHandle->begin(); jetIter != L1TkJetsHandle->end(); ++jetIter) {
161  int ibx = jetIter->bx(); // only consider jets from the central BX
162  if (ibx != 0)
163  continue;
164 
165  float tmp_jet_px = jetIter->px();
166  float tmp_jet_py = jetIter->py();
167  float tmp_jet_et = jetIter->et();
168  float tmp_jet_vtx = jetIter->jetVtx();
169  if (jetIter->pt() < jetMinPt_)
170  continue;
171  if (fabs(jetIter->eta()) > jetMaxEta_)
172  continue;
173 
174  // vertex consistency requirement
175  bool VtxRequirement = false;
176  if (foundVtx)
177  VtxRequirement = fabs(tmp_jet_vtx - evtZVtx) < deltaZ_;
178 
179  if (!doVtxConstrain_ || VtxRequirement) {
180  sumPx_calo += tmp_jet_px;
181  sumPy_calo += tmp_jet_py;
182  HT_calo += tmp_jet_et;
183  }
184  } //end loop over jets
185 
186  // define missing HT
187  float et = sqrt(sumPx_calo * sumPx_calo + sumPy_calo * sumPy_calo);
188  math::XYZTLorentzVector missingEt(-sumPx_calo, -sumPy_calo, 0, et);
189  edm::RefProd<TkJetCollection> jetCollRef(L1TkJetsHandle);
190  TkHTMiss tkHTM(missingEt, HT_calo, jetCollRef, L1VtxRef);
191 
193  tkHTM.setVtx(evtZVtx);
194  }
195 
196  MHTCollection->push_back(tkHTM);
197  iEvent.put(std::move(MHTCollection), "L1TkCaloHTMiss");
198  }
199 
200  else { // Using standalone jets
201  float sumPx = 0;
202  float sumPy = 0;
203  float HT = 0;
204 
205  // loop over jets
206  for (jetIter = L1TkJetsHandle->begin(); jetIter != L1TkJetsHandle->end(); ++jetIter) {
207  float tmp_jet_px = jetIter->px();
208  float tmp_jet_py = jetIter->py();
209  float tmp_jet_et = jetIter->et();
210  float tmp_jet_pt = jetIter->pt();
211  if (tmp_jet_pt < jetMinPt_)
212  continue;
213  if (fabs(jetIter->eta()) > jetMaxEta_)
214  continue;
215  if (jetIter->ntracks() < minNtracksLowPt_ && tmp_jet_et > minJetEtLowPt_)
216  continue;
217  if (jetIter->ntracks() < minNtracksHighPt_ && tmp_jet_et > minJetEtHighPt_)
218  continue;
219  sumPx += tmp_jet_px;
220  sumPy += tmp_jet_py;
221  HT += tmp_jet_pt;
222  } // end jet loop
223 
224  // define missing HT
225  float et = sqrt(sumPx * sumPx + sumPy * sumPy);
226  math::XYZTLorentzVector missingEt(-sumPx, -sumPy, 0, et);
227  edm::RefProd<TkJetCollection> jetCollRef(L1TkJetsHandle);
228  TkHTMiss tkHTM(missingEt, HT, jetCollRef, L1VtxRef);
229 
230  MHTCollection->push_back(tkHTM);
231  if (displaced_)
232  iEvent.put(std::move(MHTCollection), "L1TrackerHTMissExtended");
233  else
234  iEvent.put(std::move(MHTCollection), "L1TrackerHTMiss");
235  }
236 } //end producer
237 
238 //void L1TkHTMissProducer::beginJob() {}
239 
240 //void L1TkHTMissProducer::endJob() {}
241 
edm::RefProd< TkJetCollection >
L1TkHTMissProducer::displaced_
bool displaced_
Definition: L1TkHTMissProducer.cc:42
TkPrimaryVertex.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
EDProducer.h
ESHandle.h
TkHTMiss.h
edm::EDGetTokenT< TkPrimaryVertexCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
L1TkHTMissProducer::minJetEtLowPt_
float minJetEtLowPt_
Definition: L1TkHTMissProducer.cc:40
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
EDProducer.h
L1TkHTMissProducer::jetMinPt_
float jetMinPt_
Definition: L1TkHTMissProducer.cc:34
l1t::TkHTMiss::setVtx
void setVtx(const float &zvtx)
Definition: TkHTMiss.h:41
pat::MHTCollection
std::vector< pat::MHT > MHTCollection
Definition: MHT.h:39
L1TkHTMissProducer::doVtxConstrain_
bool doVtxConstrain_
Definition: L1TkHTMissProducer.cc:36
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
L1TkHTMissProducer::useCaloJets_
bool useCaloJets_
Definition: L1TkHTMissProducer.cc:38
edm::Ref< TkPrimaryVertexCollection >
L1TkHTMissProducer::pvToken_
const edm::EDGetTokenT< TkPrimaryVertexCollection > pvToken_
Definition: L1TkHTMissProducer.cc:45
MakerMacros.h
HT
Definition: HT.h:21
L1TkHTMissProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: L1TkHTMissProducer.cc:74
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
l1t::TkPrimaryVertexCollection
std::vector< TkPrimaryVertex > TkPrimaryVertexCollection
Definition: TkPrimaryVertex.h:30
l1t::TkJetCollection
std::vector< TkJet > TkJetCollection
Definition: TkJetFwd.h:20
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
L1TkHTMissProducer::deltaZ_
float deltaZ_
Definition: L1TkHTMissProducer.cc:39
L1TkHTMissProducer::jetMaxEta_
float jetMaxEta_
Definition: L1TkHTMissProducer.cc:35
l1t::TkHTMiss
Definition: TkHTMiss.h:15
L1TkHTMissProducer
Definition: L1TkHTMissProducer.cc:23
TkHTMissFwd.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
L1TkHTMissProducer::jetToken_
const edm::EDGetTokenT< TkJetCollection > jetToken_
Definition: L1TkHTMissProducer.cc:46
l1t
delete x;
Definition: CaloConfig.h:22
L1TkHTMissProducer::primaryVtxConstrain_
bool primaryVtxConstrain_
Definition: L1TkHTMissProducer.cc:37
LorentzVector.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:36
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
L1TkHTMissProducer::minNtracksHighPt_
unsigned int minNtracksHighPt_
Definition: L1TkHTMissProducer.cc:43
L1TkHTMissProducer::L1TkHTMissProducer
L1TkHTMissProducer(const edm::ParameterSet &)
Definition: L1TkHTMissProducer.cc:49
l1t::TkHTMissCollection
std::vector< TkHTMiss > TkHTMissCollection
Definition: TkHTMissFwd.h:10
eostools.move
def move(src, dest)
Definition: eostools.py:511
L1TkHTMissProducer::minJetEtHighPt_
float minJetEtHighPt_
Definition: L1TkHTMissProducer.cc:41
Frameworkfwd.h
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
L1TkHTMissProducer::~L1TkHTMissProducer
~L1TkHTMissProducer() override
Definition: L1TkHTMissProducer.cc:72
L1TkHTMissProducer::minNtracksLowPt_
unsigned int minNtracksLowPt_
Definition: L1TkHTMissProducer.cc:44