CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1TkHTMissProducer Class Reference
Inheritance diagram for L1TkHTMissProducer:
edm::stream::EDProducer<>

Public Member Functions

 L1TkHTMissProducer (const edm::ParameterSet &)
 
 ~L1TkHTMissProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const float deltaZ_
 
const bool displaced_
 
const bool doVtxConstrain_
 
const float jetMaxEta_
 
const float jetMinPt_
 
const edm::EDGetTokenT< TkJetCollectionjetToken_
 
const float minJetEtHighPt_
 
const float minJetEtLowPt_
 
const unsigned int minNtracksHighPt_
 
const unsigned int minNtracksLowPt_
 
const bool primaryVtxConstrain_
 
const edm::EDGetTokenT< VertexCollectionpvToken_
 
const bool useCaloJets_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 21 of file L1TkHTMissProducer.cc.

Constructor & Destructor Documentation

◆ L1TkHTMissProducer()

L1TkHTMissProducer::L1TkHTMissProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 47 of file L1TkHTMissProducer.cc.

References displaced_, and useCaloJets_.

48  : jetMinPt_((float)iConfig.getParameter<double>("jet_minPt")),
49  jetMaxEta_((float)iConfig.getParameter<double>("jet_maxEta")),
50  doVtxConstrain_(iConfig.getParameter<bool>("doVtxConstrain")),
51  useCaloJets_(iConfig.getParameter<bool>("useCaloJets")),
52  primaryVtxConstrain_(iConfig.getParameter<bool>("primaryVtxConstrain")),
53  deltaZ_((float)iConfig.getParameter<double>("deltaZ")),
54  minNtracksHighPt_(iConfig.getParameter<int>("jet_minNtracksHighPt")),
55  minNtracksLowPt_(iConfig.getParameter<int>("jet_minNtracksLowPt")),
56  minJetEtLowPt_(iConfig.getParameter<double>("jet_minJetEtLowPt")),
57  minJetEtHighPt_(iConfig.getParameter<double>("jet_minJetEtHighPt")),
58  displaced_(iConfig.getParameter<bool>("displaced")),
59  pvToken_(consumes<VertexCollection>(iConfig.getParameter<edm::InputTag>("L1VertexInputTag"))),
60  jetToken_(consumes<TkJetCollection>(iConfig.getParameter<edm::InputTag>("L1TkJetInputTag"))) {
61  if (useCaloJets_)
62  produces<TkHTMissCollection>("TkCaloHTMiss");
63  else if (displaced_)
64  produces<TkHTMissCollection>("L1TrackerHTMissExtended");
65  else
66  produces<TkHTMissCollection>("L1TrackerHTMiss");
67 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< TkJetCollection > jetToken_
const unsigned int minNtracksLowPt_
const unsigned int minNtracksHighPt_
const bool primaryVtxConstrain_
const edm::EDGetTokenT< VertexCollection > pvToken_

◆ ~L1TkHTMissProducer()

L1TkHTMissProducer::~L1TkHTMissProducer ( )
override

Definition at line 69 of file L1TkHTMissProducer.cc.

69 {}

Member Function Documentation

◆ beginJob()

void L1TkHTMissProducer::beginJob ( void  )
privatevirtual

Definition at line 235 of file L1TkHTMissProducer.cc.

235 {}

◆ endJob()

void L1TkHTMissProducer::endJob ( void  )
privatevirtual

Definition at line 237 of file L1TkHTMissProducer.cc.

237 {}

◆ produce()

void L1TkHTMissProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 71 of file L1TkHTMissProducer.cc.

References funct::abs(), deltaZ_, displaced_, doVtxConstrain_, EgHLTOffHistBins_cfi::et, iEvent, edm::HandleBase::isValid(), jetMaxEta_, jetMinPt_, jetToken_, minJetEtHighPt_, minJetEtLowPt_, minNtracksHighPt_, minNtracksLowPt_, eostools::move(), primaryVtxConstrain_, pvToken_, l1t::TkHTMiss::setVtx(), mathSSE::sqrt(), and useCaloJets_.

71  {
72  using namespace edm;
73  std::unique_ptr<TkHTMissCollection> MHTCollection(new TkHTMissCollection);
74 
75  // L1 primary vertex
76  edm::Handle<VertexCollection> L1VertexHandle;
77  iEvent.getByToken(pvToken_, L1VertexHandle);
78 
79  // L1 track-trigger jets
80  edm::Handle<TkJetCollection> L1TkJetsHandle;
81  iEvent.getByToken(jetToken_, L1TkJetsHandle);
82  std::vector<TkJet>::const_iterator jetIter;
83 
84  if (!L1TkJetsHandle.isValid() && !displaced_) {
85  LogError("TkHTMissProducer") << "\nWarning: TkJetCollection not found in the event. Exit\n";
86  return;
87  }
88 
89  if (!L1TkJetsHandle.isValid() && displaced_) {
90  LogError("TkHTMissProducer") << "\nWarning: TkJetExtendedCollection not found in the event. Exit\n";
91  return;
92  }
93 
94  // ----------------------------------------------------------------------------------------------
95  // if primaryVtxConstrain_, use the primary vertex instead of z position from leading jet
96  // ----------------------------------------------------------------------------------------------
97  float evtZVtx = 999;
98  bool foundVtx = false;
99  edm::Ref<VertexCollection> L1VtxRef; // null reference
100 
101  if (useCaloJets_) {
103  if (!L1VertexHandle.isValid()) {
104  LogError("L1TkHTMissProducer") << "\nWarning: VertexCollection not found in the event. Exit\n";
105  return;
106  } else {
107  std::vector<Vertex>::const_iterator vtxIter = L1VertexHandle->begin();
108  // by convention, the first vertex in the collection is the one that should
109  // be used by default
110  evtZVtx = vtxIter->z0();
111  foundVtx = true;
112  int ivtx = 0;
113  edm::Ref<VertexCollection> vtxRef(L1VertexHandle, ivtx);
114  L1VtxRef = vtxRef;
115  }
116  } //endif primaryVtxConstrain_
117 
118  // ----------------------------------------------------------------------------------------------
119  // using z position of leading jet to define "event vertex"
120  // ----------------------------------------------------------------------------------------------
121  float zvtx_jetpt = -1.0; //pt of jet determining the event vertex
122  float jetVtxMax = 99.; //find z position of leading jet that has a z vertex!
123 
125  for (jetIter = L1TkJetsHandle->begin(); jetIter != L1TkJetsHandle->end(); ++jetIter) {
126  int ibx = jetIter->bx(); // only consider jets from the central BX
127  if (ibx != 0)
128  continue;
129 
130  float tmp_jet_vtx = jetIter->jetVtx();
131  float tmp_jet_pt = jetIter->pt();
132  float tmp_jet_eta = jetIter->eta();
133  if (tmp_jet_pt < jetMinPt_)
134  continue;
135  if (std::abs(tmp_jet_eta) > jetMaxEta_)
136  continue;
137  if (std::abs(tmp_jet_vtx) > jetVtxMax)
138  continue;
139 
140  // find vertex position of leading jet
141  if (tmp_jet_pt > zvtx_jetpt) {
142  evtZVtx = tmp_jet_vtx;
143  zvtx_jetpt = tmp_jet_pt;
144  foundVtx = true;
145  }
146  } //end loop over jets
147  } //endif z position from leading jet
148 
149  float sumPx_calo = 0;
150  float sumPy_calo = 0;
151  float HT_calo = 0;
152 
153  if (doVtxConstrain_ && !foundVtx)
154  LogWarning("L1TkHTMissProducer") << "Didn't find any z vertex (based on jet vertices) for this event!\n";
155 
156  // loop over jets
157  for (jetIter = L1TkJetsHandle->begin(); jetIter != L1TkJetsHandle->end(); ++jetIter) {
158  int ibx = jetIter->bx(); // only consider jets from the central BX
159  if (ibx != 0)
160  continue;
161 
162  float tmp_jet_px = jetIter->px();
163  float tmp_jet_py = jetIter->py();
164  float tmp_jet_et = jetIter->et();
165  float tmp_jet_vtx = jetIter->jetVtx();
166  if (jetIter->pt() < jetMinPt_)
167  continue;
168  if (std::abs(jetIter->eta()) > jetMaxEta_)
169  continue;
170 
171  // vertex consistency requirement
172  bool VtxRequirement = false;
173  if (foundVtx)
174  VtxRequirement = std::abs(tmp_jet_vtx - evtZVtx) < deltaZ_;
175 
176  if (!doVtxConstrain_ || VtxRequirement) {
177  sumPx_calo += tmp_jet_px;
178  sumPy_calo += tmp_jet_py;
179  HT_calo += tmp_jet_et;
180  }
181  } //end loop over jets
182 
183  // define missing HT
184  float et = sqrt(sumPx_calo * sumPx_calo + sumPy_calo * sumPy_calo);
185  math::XYZTLorentzVector missingEt(-sumPx_calo, -sumPy_calo, 0, et);
186  edm::RefProd<TkJetCollection> jetCollRef(L1TkJetsHandle);
187  TkHTMiss tkHTM(missingEt, HT_calo, jetCollRef, L1VtxRef);
188 
190  tkHTM.setVtx(evtZVtx);
191  }
192 
193  MHTCollection->push_back(tkHTM);
194  iEvent.put(std::move(MHTCollection), "L1TkCaloHTMiss");
195  }
196 
197  else { // Using standalone jets
198  float sumPx = 0;
199  float sumPy = 0;
200  float HT = 0;
201 
202  // loop over jets
203  for (jetIter = L1TkJetsHandle->begin(); jetIter != L1TkJetsHandle->end(); ++jetIter) {
204  float tmp_jet_px = jetIter->px();
205  float tmp_jet_py = jetIter->py();
206  float tmp_jet_et = jetIter->et();
207  float tmp_jet_pt = jetIter->pt();
208  if (tmp_jet_pt < jetMinPt_)
209  continue;
210  if (std::abs(jetIter->eta()) > jetMaxEta_)
211  continue;
212  if (jetIter->ntracks() < minNtracksLowPt_ && tmp_jet_et > minJetEtLowPt_)
213  continue;
214  if (jetIter->ntracks() < minNtracksHighPt_ && tmp_jet_et > minJetEtHighPt_)
215  continue;
216  sumPx += tmp_jet_px;
217  sumPy += tmp_jet_py;
218  HT += tmp_jet_pt;
219  } // end jet loop
220 
221  // define missing HT
222  float et = sqrt(sumPx * sumPx + sumPy * sumPy);
223  math::XYZTLorentzVector missingEt(-sumPx, -sumPy, 0, et);
224  edm::RefProd<TkJetCollection> jetCollRef(L1TkJetsHandle);
225  TkHTMiss tkHTM(missingEt, HT, jetCollRef, L1VtxRef);
226 
227  MHTCollection->push_back(tkHTM);
228  if (displaced_)
229  iEvent.put(std::move(MHTCollection), "L1TrackerHTMissExtended");
230  else
231  iEvent.put(std::move(MHTCollection), "L1TrackerHTMiss");
232  }
233 } //end producer
const edm::EDGetTokenT< TkJetCollection > jetToken_
const unsigned int minNtracksLowPt_
std::vector< TkHTMiss > TkHTMissCollection
Definition: TkHTMissFwd.h:10
Log< level::Error, false > LogError
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
const unsigned int minNtracksHighPt_
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< pat::MHT > MHTCollection
Definition: MHT.h:39
const bool primaryVtxConstrain_
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
const edm::EDGetTokenT< VertexCollection > pvToken_
Log< level::Warning, false > LogWarning
Definition: HT.h:21
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ deltaZ_

const float L1TkHTMissProducer::deltaZ_
private

Definition at line 37 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ displaced_

const bool L1TkHTMissProducer::displaced_
private

Definition at line 42 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

◆ doVtxConstrain_

const bool L1TkHTMissProducer::doVtxConstrain_
private

Definition at line 34 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ jetMaxEta_

const float L1TkHTMissProducer::jetMaxEta_
private

Definition at line 33 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ jetMinPt_

const float L1TkHTMissProducer::jetMinPt_
private

Definition at line 32 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ jetToken_

const edm::EDGetTokenT<TkJetCollection> L1TkHTMissProducer::jetToken_
private

Definition at line 44 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ minJetEtHighPt_

const float L1TkHTMissProducer::minJetEtHighPt_
private

Definition at line 41 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ minJetEtLowPt_

const float L1TkHTMissProducer::minJetEtLowPt_
private

Definition at line 40 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ minNtracksHighPt_

const unsigned int L1TkHTMissProducer::minNtracksHighPt_
private

Definition at line 38 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ minNtracksLowPt_

const unsigned int L1TkHTMissProducer::minNtracksLowPt_
private

Definition at line 39 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ primaryVtxConstrain_

const bool L1TkHTMissProducer::primaryVtxConstrain_
private

Definition at line 36 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ pvToken_

const edm::EDGetTokenT<VertexCollection> L1TkHTMissProducer::pvToken_
private

Definition at line 43 of file L1TkHTMissProducer.cc.

Referenced by produce().

◆ useCaloJets_

const bool L1TkHTMissProducer::useCaloJets_
private

Definition at line 35 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().