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  float etTot = 0;
84  double sumPx_PU = 0;
85  double sumPy_PU = 0;
86  double etTot_PU = 0;
87 
88  int numqualitytracks = 0;
89  int numassoctracks = 0;
90 
91  for (const auto& track : *L1TTTrackHandle) {
92  float pt = track->momentum().perp();
93  float phi = track->momentum().phi();
94 
95  if (maxPt_ > 0 && pt > maxPt_) {
96  if (highPtTracks_ == 0)
97  continue; // ignore these very high PT tracks: truncate
98  if (highPtTracks_ == 1)
99  pt = maxPt_; // saturate
100  }
101 
102  numqualitytracks++;
103 
104  if (std::find(L1TTTrackAssociatedHandle->begin(), L1TTTrackAssociatedHandle->end(), track) !=
105  L1TTTrackAssociatedHandle->end()) {
106  numassoctracks++;
107  sumPx += pt * cos(phi);
108  sumPy += pt * sin(phi);
109  etTot += pt;
110  } else { // PU sums
111  sumPx_PU += pt * cos(phi);
112  sumPy_PU += pt * sin(phi);
113  etTot_PU += pt;
114  }
115  } // end loop over tracks
116 
117  float et = sqrt(sumPx * sumPx + sumPy * sumPy);
118  double etphi = atan2(sumPy, sumPx);
119 
120  math::XYZTLorentzVector missingEt(-sumPx, -sumPy, 0, et);
121 
122  if (debug_) {
123  edm::LogVerbatim("L1TrackerEtMissProducer") << "====Global Pt===="
124  << "\n"
125  << "Px: " << sumPx << "| Py: " << sumPy << "\n"
126  << "====MET==="
127  << "\n"
128  << "MET: " << et << "| Phi: " << etphi << "\n"
129 
130  << "# Tracks after quality cuts: " << L1TTTrackHandle->size() << "\n"
131  << "# Tacks after additional highPt Cuts: " << numqualitytracks << "\n"
132  << "# Tracks associated to vertex: " << numassoctracks << "\n"
133  << "========================================================"
134  << "\n";
135  }
136 
137  int ibx = 0;
138  METCollection->push_back(TkEtMiss(missingEt, TkEtMiss::kMET, etphi, numassoctracks, ibx));
139 
141 } // end producer
142 
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:19
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