CMS 3D CMS Logo

L1TrackerEtMissProducer.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 // Modified by Emily MacDonald, 30 Nov 2018
4 // Modified by Christopher Brown 27 March 2021
5 
6 // system include files
7 #include <memory>
8 
9 // user include files
24 
25 // detector geometry
30 
31 using namespace l1t;
32 
34 public:
36  typedef std::vector<L1TTTrackType> L1TTTrackCollectionType;
37 
40 
42  ~L1TrackerEtMissProducer() override;
43 
44 private:
45  virtual void beginJob();
46  void produce(edm::Event&, const edm::EventSetup&) override;
47  virtual void endJob();
48 
49  // ----------member data ---------------------------
50  const float maxZ0_; // in cm
51  float deltaZ_; // in cm
52  const float Chi2RphidofMax_;
53  const float Chi2RzdofMax_;
54  const float bendChi2Max_;
55  const float minPt_; // in GeV
56  const int nStubsmin_;
57  const int nPSStubsMin_; // minimum number of stubs in PS modules
58  const float maxPt_;
59  const float maxEta_;
60  const int highPtTracks_; // saturate or truncate
61  const bool displaced_; // prompt/displaced tracks
62  vector<double> z0Thresholds_; // Threshold for track to vertex association
63  vector<double> etaRegions_; // Eta bins for choosing deltaZ threshold
64  bool debug_;
65 
68 
72 };
73 
74 // constructor//
76  : maxZ0_((float)iConfig.getParameter<double>("maxZ0")),
77  deltaZ_((float)iConfig.getParameter<double>("deltaZ")),
78  Chi2RphidofMax_((float)iConfig.getParameter<double>("chi2rphidofMax")),
79  Chi2RzdofMax_((float)iConfig.getParameter<double>("chi2rzdofMax")),
80  bendChi2Max_((float)iConfig.getParameter<double>("bendChi2Max")),
81  minPt_((float)iConfig.getParameter<double>("minPt")),
82  nStubsmin_(iConfig.getParameter<int>("nStubsmin")),
83  nPSStubsMin_(iConfig.getParameter<int>("nPSStubsMin")),
84  maxPt_((float)iConfig.getParameter<double>("maxPt")),
85  maxEta_((float)iConfig.getParameter<double>("maxEta")),
86  highPtTracks_(iConfig.getParameter<int>("highPtTracks")),
87  displaced_(iConfig.getParameter<bool>("displaced")),
88  z0Thresholds_(iConfig.getParameter<std::vector<double>>("z0Thresholds")),
89  etaRegions_(iConfig.getParameter<std::vector<double>>("etaRegions")),
90  debug_(iConfig.getParameter<bool>("debug")),
91  pvToken_(consumes<L1VertexCollectionType>(iConfig.getParameter<edm::InputTag>("L1VertexInputTag"))),
92  trackToken_(consumes<L1TTTrackCollectionType>(iConfig.getParameter<edm::InputTag>("L1TrackInputTag"))),
94  L1MetCollectionName = (std::string)iConfig.getParameter<std::string>("L1MetCollectionName");
95 
96  if (displaced_) {
97  L1ExtendedMetCollectionName = (std::string)iConfig.getParameter<std::string>("L1MetExtendedCollectionName");
98  produces<TkEtMissCollection>(L1ExtendedMetCollectionName);
99  } else
100  produces<TkEtMissCollection>(L1MetCollectionName);
101 }
102 
104 
106  using namespace edm;
107 
108  std::unique_ptr<TkEtMissCollection> METCollection(new TkEtMissCollection);
109 
110  // Tracker Topology
111  const TrackerTopology& tTopo = iSetup.getData(tTopoToken_);
112 
114  iEvent.getByToken(pvToken_, L1VertexHandle);
115 
116  edm::Handle<L1TTTrackCollectionType> L1TTTrackHandle;
117  iEvent.getByToken(trackToken_, L1TTTrackHandle);
118  L1TTTrackCollectionType::const_iterator trackIter;
119 
120  if (!L1VertexHandle.isValid()) {
121  LogError("L1TrackerEtMissProducer") << "\nWarning: VertexCollection not found in the event. Exit\n";
122  return;
123  }
124 
125  if (!L1TTTrackHandle.isValid()) {
126  LogError("L1TrackerEtMissProducer") << "\nWarning: L1TTTrackCollection not found in the event. Exit\n";
127  return;
128  }
129 
130  float sumPx = 0;
131  float sumPy = 0;
132  float etTot = 0;
133  double sumPx_PU = 0;
134  double sumPy_PU = 0;
135  double etTot_PU = 0;
136  float zVTX = L1VertexHandle->begin()->z0();
137 
138  int numtracks = 0;
139  int numqualitytracks = 0;
140  int numassoctracks = 0;
141 
142  for (trackIter = L1TTTrackHandle->begin(); trackIter != L1TTTrackHandle->end(); ++trackIter) {
143  numtracks++;
144  float pt = trackIter->momentum().perp();
145  float phi = trackIter->momentum().phi();
146  float eta = trackIter->momentum().eta();
147  float chi2rphidof = trackIter->chi2XYRed();
148  float chi2rzdof = trackIter->chi2ZRed();
149  float bendChi2 = trackIter->stubPtConsistency();
150  float z0 = trackIter->z0();
151  //unsigned int Sector = trackIter->phiSector();
152  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>, TTStub<Ref_Phase2TrackerDigi_>>>
153  theStubs = trackIter->getStubRefs();
154  int nstubs = (int)theStubs.size();
155 
156  if (pt < minPt_)
157  continue;
158  if (std::abs(z0) > maxZ0_)
159  continue;
160  if (std::abs(eta) > maxEta_)
161  continue;
162  if (chi2rphidof > Chi2RphidofMax_)
163  continue;
164  if (chi2rzdof > Chi2RzdofMax_)
165  continue;
166  if (bendChi2 > bendChi2Max_)
167  continue;
168 
169  if (maxPt_ > 0 && pt > maxPt_) {
170  if (highPtTracks_ == 0)
171  continue; // ignore these very high PT tracks: truncate
172  if (highPtTracks_ == 1)
173  pt = maxPt_; // saturate
174  }
175 
176  int nPS = 0; // number of stubs in PS modules
177  // loop over the stubs
178  for (unsigned int istub = 0; istub < (unsigned int)theStubs.size(); istub++) {
179  DetId detId(theStubs.at(istub)->getDetId());
180  if (detId.det() == DetId::Detector::Tracker) {
181  if ((detId.subdetId() == StripSubdetector::TOB && tTopo.tobLayer(detId) <= 3) ||
182  (detId.subdetId() == StripSubdetector::TID && tTopo.tidRing(detId) <= 9))
183  nPS++;
184  }
185  }
186 
187  if (nstubs < nStubsmin_)
188  continue;
189  if (nPS < nPSStubsMin_)
190  continue;
191 
192  numqualitytracks++;
193 
194  if (!displaced_) { // if displaced, deltaZ = 3.0 cm, very loose
195  // construct deltaZ cut to be based on track eta
196  for (unsigned int reg = 0; reg < etaRegions_.size() - 1; reg++) {
197  if (std::abs(eta) >= etaRegions_[reg] && std::abs(eta) < etaRegions_[reg + 1]) {
198  deltaZ_ = z0Thresholds_[reg];
199  break;
200  }
201  }
202  if (std::abs(eta) >= etaRegions_[etaRegions_.size() - 1]) {
203  deltaZ_ = z0Thresholds_[etaRegions_.size() - 1];
204  break;
205  }
206  }
207 
208  if (std::abs(z0 - zVTX) <= deltaZ_) {
209  numassoctracks++;
210  sumPx += pt * cos(phi);
211  sumPy += pt * sin(phi);
212  etTot += pt;
213  } else { // PU sums
214  sumPx_PU += pt * cos(phi);
215  sumPy_PU += pt * sin(phi);
216  etTot_PU += pt;
217  }
218  } // end loop over tracks
219 
220  float et = sqrt(sumPx * sumPx + sumPy * sumPy);
221  double etphi = atan2(sumPy, sumPx);
222 
223  math::XYZTLorentzVector missingEt(-sumPx, -sumPy, 0, et);
224 
225  if (debug_) {
226  edm::LogVerbatim("L1TrackerEtMissProducer") << "====Global Pt===="
227  << "\n"
228  << "Px: " << sumPx << "| Py: " << sumPy << "\n"
229  << "====MET==="
230  << "\n"
231  << "MET: " << et << "| Phi: " << etphi << "\n"
232 
233  << "# Intial Tracks: " << numtracks << "\n"
234  << "# Tracks after Quality Cuts: " << numqualitytracks << "\n"
235  << "# Tracks Associated to Vertex: " << numassoctracks << "\n"
236  << "========================================================"
237  << "\n";
238  }
239 
240  int ibx = 0;
241  METCollection->push_back(TkEtMiss(missingEt, TkEtMiss::kMET, etphi, numassoctracks, ibx));
242 
243  if (displaced_)
245  else
247 } // end producer
248 
250 
252 
std::vector< TkEtMiss > TkEtMissCollection
Definition: TkEtMissFwd.h:10
Log< level::Info, true > LogVerbatim
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
unsigned int tobLayer(const DetId &id) const
const float maxZ0_
Definition: Constants.h:71
std::vector< L1TTTrackType > L1TTTrackCollectionType
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
VertexCollection L1VertexCollectionType
delete x;
Definition: CaloConfig.h:22
Log< level::Error, false > LogError
std::vector< Vertex > VertexCollection
Definition: Vertex.h:31
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:22
void beginJob()
Definition: Breakpoints.cc:14
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
TTTrack< Ref_Phase2TrackerDigi_ > L1TTTrackType
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getData(T &iHolder) const
Definition: EventSetup.h:122
static constexpr auto TOB
Collection of MET.
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
Definition: DetId.h:17
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
const edm::EDGetTokenT< VertexCollection > pvToken_
void produce(edm::Event &, const edm::EventSetup &) override
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
const edm::EDGetTokenT< L1TTTrackCollectionType > trackToken_
unsigned int tidRing(const DetId &id) const
L1TrackerEtMissProducer(const edm::ParameterSet &)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
static constexpr auto TID
def move(src, dest)
Definition: eostools.py:511