CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
5 // system include files
6 #include <memory>
7 
8 // user include files
21 
22 // detector geometry
27 
28 using namespace l1t;
29 
31 public:
33  typedef std::vector<L1TTTrackType> L1TTTrackCollectionType;
34 
36  ~L1TrackerEtMissProducer() override;
37 
38 private:
39  //void beginJob() override;
40  void produce(edm::Event&, const edm::EventSetup&) override;
41  //void endJob() override;
42 
43  // ----------member data ---------------------------
44  float maxZ0_; // in cm
45  float deltaZ_; // in cm
46  float maxEta_;
47  float chi2dofMax_;
48  float bendChi2Max_;
49  float minPt_; // in GeV
51  int nPSStubsMin_; // minimum number of stubs in PS modules
52  float maxPt_; // in GeV
53  int highPtTracks_; // saturate or truncate
54  bool displaced_; //prompt/displaced tracks
55 
59 };
60 
61 //constructor//
63  : pvToken_(consumes<TkPrimaryVertexCollection>(iConfig.getParameter<edm::InputTag>("L1VertexInputTag"))),
64  trackToken_(consumes<std::vector<TTTrack<Ref_Phase2TrackerDigi_> > >(
65  iConfig.getParameter<edm::InputTag>("L1TrackInputTag"))),
67  maxZ0_ = (float)iConfig.getParameter<double>("maxZ0");
68  deltaZ_ = (float)iConfig.getParameter<double>("deltaZ");
69  chi2dofMax_ = (float)iConfig.getParameter<double>("chi2dofMax");
70  bendChi2Max_ = (float)iConfig.getParameter<double>("bendChi2Max");
71  minPt_ = (float)iConfig.getParameter<double>("minPt");
72  nStubsmin_ = iConfig.getParameter<int>("nStubsmin");
73  nPSStubsMin_ = iConfig.getParameter<int>("nPSStubsMin");
74  maxPt_ = (float)iConfig.getParameter<double>("maxPt");
75  maxEta_ = (float)iConfig.getParameter<double>("maxEta");
76  highPtTracks_ = iConfig.getParameter<int>("highPtTracks");
77  displaced_ = iConfig.getParameter<bool>("displaced");
78 
79  if (displaced_)
80  produces<TkEtMissCollection>("L1TrackerEtMissExtended");
81  else
82  produces<TkEtMissCollection>("L1TrackerEtMiss");
83 }
84 
86 
88  using namespace edm;
89 
90  std::unique_ptr<TkEtMissCollection> METCollection(new TkEtMissCollection);
91 
92  // Tracker Topology
93  const TrackerTopology& tTopo = iSetup.getData(tTopoToken_);
94 
96  iEvent.getByToken(pvToken_, L1VertexHandle);
97 
99  iEvent.getByToken(trackToken_, L1TTTrackHandle);
100  L1TTTrackCollectionType::const_iterator trackIter;
101 
102  if (!L1VertexHandle.isValid()) {
103  LogError("L1TrackerEtMissProducer") << "\nWarning: TkPrimaryVertexCollection not found in the event. Exit\n";
104  return;
105  }
106 
107  if (!L1TTTrackHandle.isValid()) {
108  LogError("L1TrackerEtMissProducer") << "\nWarning: L1TTTrackCollection not found in the event. Exit\n";
109  return;
110  }
111 
112  float sumPx = 0;
113  float sumPy = 0;
114  float etTot = 0;
115  double sumPx_PU = 0;
116  double sumPy_PU = 0;
117  double etTot_PU = 0;
118  float zVTX = L1VertexHandle->begin()->zvertex();
119 
120  for (trackIter = L1TTTrackHandle->begin(); trackIter != L1TTTrackHandle->end(); ++trackIter) {
121  float pt = trackIter->momentum().perp();
122  float phi = trackIter->momentum().phi();
123  float eta = trackIter->momentum().eta();
124  float chi2dof = trackIter->chi2Red();
125  float bendChi2 = trackIter->stubPtConsistency();
126  float z0 = trackIter->z0();
127  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
128  theStubs = trackIter->getStubRefs();
129  int nstubs = (int)theStubs.size();
130 
131  if (pt < minPt_)
132  continue;
133  if (fabs(z0) > maxZ0_)
134  continue;
135  if (fabs(eta) > maxEta_)
136  continue;
137  if (chi2dof > chi2dofMax_)
138  continue;
139  if (bendChi2 > bendChi2Max_)
140  continue;
141 
142  if (maxPt_ > 0 && pt > maxPt_) {
143  if (highPtTracks_ == 0)
144  continue; // ignore these very high PT tracks: truncate
145  if (highPtTracks_ == 1)
146  pt = maxPt_; // saturate
147  }
148 
149  int nPS = 0; // number of stubs in PS modules
150  // loop over the stubs
151  for (unsigned int istub = 0; istub < (unsigned int)theStubs.size(); istub++) {
152  DetId detId(theStubs.at(istub)->getDetId());
153  if (detId.det() == DetId::Detector::Tracker) {
154  if ((detId.subdetId() == StripSubdetector::TOB && tTopo.tobLayer(detId) <= 3) ||
155  (detId.subdetId() == StripSubdetector::TID && tTopo.tidRing(detId) <= 9))
156  nPS++;
157  }
158  }
159 
160  if (nstubs < nStubsmin_)
161  continue;
162  if (nPS < nPSStubsMin_)
163  continue;
164 
165  if (!displaced_) { // if displaced, deltaZ = 3.0 cm, very loose
166  // construct deltaZ cut to be based on track eta
167  if (fabs(eta) >= 0 && fabs(eta) < 0.7)
168  deltaZ_ = 0.4;
169  else if (fabs(eta) >= 0.7 && fabs(eta) < 1.0)
170  deltaZ_ = 0.6;
171  else if (fabs(eta) >= 1.0 && fabs(eta) < 1.2)
172  deltaZ_ = 0.76;
173  else if (fabs(eta) >= 1.2 && fabs(eta) < 1.6)
174  deltaZ_ = 1.0;
175  else if (fabs(eta) >= 1.6 && fabs(eta) < 2.0)
176  deltaZ_ = 1.7;
177  else if (fabs(eta) >= 2.0 && fabs(eta) <= 2.4)
178  deltaZ_ = 2.2;
179  }
180 
181  if (fabs(z0 - zVTX) <= deltaZ_) {
182  sumPx += pt * cos(phi);
183  sumPy += pt * sin(phi);
184  etTot += pt;
185  } else { // PU sums
186  sumPx_PU += pt * cos(phi);
187  sumPy_PU += pt * sin(phi);
188  etTot_PU += pt;
189  }
190  } // end loop over tracks
191 
192  float et = sqrt(sumPx * sumPx + sumPy * sumPy);
193  double etmiss_PU = sqrt(sumPx_PU * sumPx_PU + sumPy_PU * sumPy_PU);
194 
195  math::XYZTLorentzVector missingEt(-sumPx, -sumPy, 0, et);
196  int ibx = 0;
197  METCollection->push_back(TkEtMiss(missingEt, TkEtMiss::kMET, etTot, etmiss_PU, etTot_PU, ibx));
198 
199  if (displaced_)
200  iEvent.put(std::move(METCollection), "L1TrackerEtMissExtended");
201  else
202  iEvent.put(std::move(METCollection), "L1TrackerEtMiss");
203 } // end producer
204 
205 //void L1TrackerEtMissProducer::beginJob() {}
206 
207 //void L1TrackerEtMissProducer::endJob() {}
208 
std::vector< TkEtMiss > TkEtMissCollection
Definition: TkEtMissFwd.h:10
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::vector< L1TTTrackType > L1TTTrackCollectionType
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Log< level::Error, false > LogError
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:22
bool getData(T &iHolder) const
Definition: EventSetup.h:128
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
const edm::EDGetTokenT< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > trackToken_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def move
Definition: eostools.py:511
static constexpr auto TOB
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
std::vector< TkPrimaryVertex > TkPrimaryVertexCollection
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< TkPrimaryVertexCollection > pvToken_
L1TrackerEtMissProducer(const edm::ParameterSet &)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
static constexpr auto TID
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tTopoToken_