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 <algorithm>
8 #include <memory>
9 
10 // user include files
24 
25 using namespace l1t;
26 
28 public:
30  typedef std::vector<L1TTTrackType> L1TTTrackCollectionType;
32 
34  ~L1TrackerEtMissProducer() override = default;
35 
36 private:
37  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
38 
39  // ----------member data ---------------------------
43  const float maxPt_; // in GeV
44  const int highPtTracks_; // saturate or truncate
45  const bool debug_;
46 };
47 
48 // constructor
50  : trackToken_(consumes<L1TTTrackRefCollectionType>(iConfig.getParameter<edm::InputTag>("L1TrackInputTag"))),
51  vtxAssocTrackToken_(
52  consumes<L1TTTrackRefCollectionType>(iConfig.getParameter<edm::InputTag>("L1TrackAssociatedInputTag"))),
53  L1MetCollectionName(iConfig.getParameter<std::string>("L1MetCollectionName")),
54  maxPt_(iConfig.getParameter<double>("maxPt")),
55  highPtTracks_(iConfig.getParameter<int>("highPtTracks")),
56  debug_(iConfig.getParameter<bool>("debug")) {
57  produces<TkEtMissCollection>(L1MetCollectionName);
58 }
59 
61  using namespace edm;
62 
63  std::unique_ptr<TkEtMissCollection> METCollection(new TkEtMissCollection);
64 
66  iEvent.getByToken(trackToken_, L1TTTrackHandle);
67 
68  edm::Handle<L1TTTrackRefCollectionType> L1TTTrackAssociatedHandle;
69  iEvent.getByToken(vtxAssocTrackToken_, L1TTTrackAssociatedHandle);
70 
71  if (!L1TTTrackHandle.isValid()) {
72  LogError("L1TrackerEtMissProducer") << "\nWarning: L1TTTrackCollection not found in the event. Exit\n";
73  return;
74  }
75 
76  if (!L1TTTrackAssociatedHandle.isValid()) {
77  LogError("L1TrackerEtMissProducer") << "\nWarning: L1TTTrackAssociatedCollection not found in the event. Exit\n";
78  return;
79  }
80 
81  float sumPx = 0;
82  float sumPy = 0;
83 
84  int numqualitytracks = 0;
85  int numassoctracks = 0;
86 
87  for (const auto& track : *L1TTTrackHandle) {
88  float pt = track->momentum().perp();
89  float phi = track->momentum().phi();
90 
91  if (maxPt_ > 0 && pt > maxPt_) {
92  if (highPtTracks_ == 0)
93  continue; // ignore these very high PT tracks: truncate
94  if (highPtTracks_ == 1)
95  pt = maxPt_; // saturate
96  }
97 
98  numqualitytracks++;
99 
100  if (std::find(L1TTTrackAssociatedHandle->begin(), L1TTTrackAssociatedHandle->end(), track) !=
101  L1TTTrackAssociatedHandle->end()) {
102  numassoctracks++;
103  sumPx += pt * cos(phi);
104  sumPy += pt * sin(phi);
105  }
106  } // end loop over tracks
107 
108  float et = sqrt(sumPx * sumPx + sumPy * sumPy);
109  double etphi = atan2(sumPy, sumPx);
110 
111  math::XYZTLorentzVector missingEt(-sumPx, -sumPy, 0, et);
112 
113  if (debug_) {
114  edm::LogVerbatim("L1TrackerEtMissProducer") << "====Global Pt===="
115  << "\n"
116  << "Px: " << sumPx << "| Py: " << sumPy << "\n"
117  << "====MET==="
118  << "\n"
119  << "MET: " << et << "| Phi: " << etphi << "\n"
120 
121  << "# Tracks after quality cuts: " << L1TTTrackHandle->size() << "\n"
122  << "# Tacks after additional highPt Cuts: " << numqualitytracks << "\n"
123  << "# Tracks associated to vertex: " << numassoctracks << "\n"
124  << "========================================================"
125  << "\n";
126  }
127 
128  int ibx = 0;
129  METCollection->push_back(TkEtMiss(missingEt, TkEtMiss::kMET, etphi, numassoctracks, ibx));
130 
132 } // end producer
133 
edm::RefVector< L1TTTrackCollectionType > L1TTTrackRefCollectionType
std::vector< TkEtMiss > TkEtMissCollection
Definition: TkEtMissFwd.h:10
Log< level::Info, true > LogVerbatim
std::vector< L1TTTrackType > L1TTTrackCollectionType
const edm::EDGetTokenT< L1TTTrackRefCollectionType > trackToken_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const std::string L1MetCollectionName
delete x;
Definition: CaloConfig.h:22
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:22
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:23
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Collection of MET.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const edm::EDGetTokenT< L1TTTrackRefCollectionType > vtxAssocTrackToken_
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
L1TrackerEtMissProducer(const edm::ParameterSet &)
def move(src, dest)
Definition: eostools.py:511
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)
Definition: Matriplex.h:648