CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

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

Private Attributes

float deltaZ_
 
bool displaced_
 
bool doVtxConstrain_
 
float jetMaxEta_
 
float jetMinPt_
 
const edm::EDGetTokenT
< TkJetCollection
jetToken_
 
float minJetEtHighPt_
 
float minJetEtLowPt_
 
unsigned int minNtracksHighPt_
 
unsigned int minNtracksLowPt_
 
bool primaryVtxConstrain_
 
const edm::EDGetTokenT
< TkPrimaryVertexCollection
pvToken_
 
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 23 of file L1TkHTMissProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 49 of file L1TkHTMissProducer.cc.

References deltaZ_, displaced_, doVtxConstrain_, edm::ParameterSet::getParameter(), jetMaxEta_, jetMinPt_, minJetEtHighPt_, minJetEtLowPt_, minNtracksHighPt_, minNtracksLowPt_, primaryVtxConstrain_, and useCaloJets_.

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 }
const edm::EDGetTokenT< TkJetCollection > jetToken_
unsigned int minNtracksLowPt_
unsigned int minNtracksHighPt_
const edm::EDGetTokenT< TkPrimaryVertexCollection > pvToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
L1TkHTMissProducer::~L1TkHTMissProducer ( )
override

Definition at line 72 of file L1TkHTMissProducer.cc.

72 {}

Member Function Documentation

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

Definition at line 74 of file L1TkHTMissProducer.cc.

References deltaZ_, displaced_, doVtxConstrain_, edm::Event::getByToken(), jetMaxEta_, jetMinPt_, jetToken_, minJetEtHighPt_, minJetEtLowPt_, minNtracksHighPt_, minNtracksLowPt_, eostools::move(), primaryVtxConstrain_, edm::Event::put(), pvToken_, l1t::TkHTMiss::setVtx(), mathSSE::sqrt(), and useCaloJets_.

74  {
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
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EDGetTokenT< TkJetCollection > jetToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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
T sqrt(T t)
Definition: SSEVec.h:19
def move
Definition: eostools.py:511
std::vector< pat::MHT > MHTCollection
Definition: MHT.h:39
unsigned int minNtracksLowPt_
unsigned int minNtracksHighPt_
const edm::EDGetTokenT< TkPrimaryVertexCollection > pvToken_
Log< level::Warning, false > LogWarning
Definition: HT.h:21

Member Data Documentation

float L1TkHTMissProducer::deltaZ_
private

Definition at line 39 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

bool L1TkHTMissProducer::displaced_
private

Definition at line 42 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

bool L1TkHTMissProducer::doVtxConstrain_
private

Definition at line 36 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

float L1TkHTMissProducer::jetMaxEta_
private

Definition at line 35 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

float L1TkHTMissProducer::jetMinPt_
private

Definition at line 34 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

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

Definition at line 46 of file L1TkHTMissProducer.cc.

Referenced by produce().

float L1TkHTMissProducer::minJetEtHighPt_
private

Definition at line 41 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

float L1TkHTMissProducer::minJetEtLowPt_
private

Definition at line 40 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

unsigned int L1TkHTMissProducer::minNtracksHighPt_
private

Definition at line 43 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

unsigned int L1TkHTMissProducer::minNtracksLowPt_
private

Definition at line 44 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

bool L1TkHTMissProducer::primaryVtxConstrain_
private

Definition at line 37 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().

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

Definition at line 45 of file L1TkHTMissProducer.cc.

Referenced by produce().

bool L1TkHTMissProducer::useCaloJets_
private

Definition at line 38 of file L1TkHTMissProducer.cc.

Referenced by L1TkHTMissProducer(), and produce().