-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathL1TMuonLegacyConverter.cc
More file actions
174 lines (138 loc) · 5.99 KB
/
Copy pathL1TMuonLegacyConverter.cc
File metadata and controls
174 lines (138 loc) · 5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// -*- C++ -*-
//
// Package: L1TMuonLegacyConverter
// Class: L1TMuonLegacyConverter
//
/**\class L1TMuonLegacyConverter \file L1TMuonLegacyConverter.cc src/L1TMuonLegacyConverter/src/L1TMuonLegacyConverter.cc
*/
//
// Original Author: Bortignon Pierluigi
// Created: Sun March 6 EDT 2016
//
//
// system include files
#include <memory>
// user include files
#include "L1Trigger/L1TCommon/plugins/L1TMuonLegacyConverter.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "DataFormats/Common/interface/OrphanHandle.h"
#include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
#include "CondFormats/DataRecord/interface/L1CaloGeometryRecord.h"
#include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
#include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1HtMissScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1HfRingEtScaleRcd.h"
#include "CondFormats/L1TObjects/interface/L1GctJetFinderParams.h"
#include "CondFormats/DataRecord/interface/L1GctJetFinderParamsRcd.h"
#include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
#include "CondFormats/DataRecord/interface/L1MuTriggerScalesRcd.h"
#include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
#include "CondFormats/DataRecord/interface/L1MuTriggerPtScaleRcd.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
// #include "FWCore/Utilities/interface/EDMException.h"
//
// class decleration
//
//
// constants, enums and typedefs
//
using namespace l1t;
//
// static data member definitions
//
double const L1TMuonLegacyConverter::muonMassGeV_ = 0.105658369; // PDG06
//
// constructors and destructor
//
L1TMuonLegacyConverter::L1TMuonLegacyConverter(const edm::ParameterSet& iConfig) {
using namespace l1extra;
// moving inputTag here
muonSource_InputTag = iConfig.getParameter<edm::InputTag>("muonSource");
produceMuonParticles_ = iConfig.getUntrackedParameter<bool>("produceMuonParticles");
centralBxOnly_ = iConfig.getUntrackedParameter<bool>("centralBxOnly");
produces<MuonBxCollection>("imdMuonsLegacy");
muonSource_InputToken = consumes<L1MuGMTReadoutCollection>(muonSource_InputTag);
if (produceMuonParticles_) {
muScalesToken_ = esConsumes();
muPtScaleToken_ = esConsumes();
}
}
L1TMuonLegacyConverter::~L1TMuonLegacyConverter() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}
//
// member functions
//
// ------------ method called to produce the data ------------
void L1TMuonLegacyConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;
using namespace l1extra;
using namespace std;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~ Muons ~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
std::unique_ptr<MuonBxCollection> imdMuonsLegacy(new MuonBxCollection());
LogDebug("L1TMuonLegacyConverter") << "\nWarning: L1MuGMTReadoutCollection with " << muonSource_InputTag
<< "\nrequested in configuration, but not found in the event." << std::endl;
if (produceMuonParticles_) {
ESHandle<L1MuTriggerScales> muScales = iSetup.getHandle(muScalesToken_);
ESHandle<L1MuTriggerPtScale> muPtScale = iSetup.getHandle(muPtScaleToken_);
Handle<L1MuGMTReadoutCollection> simMuCollection;
iEvent.getByToken(muonSource_InputToken, simMuCollection);
vector<L1MuGMTExtendedCand> simMuCands;
if (!simMuCollection.isValid()) {
LogDebug("L1TMuonLegacyConverter") << "\nWarning: L1MuGMTReadoutCollection with " << muonSource_InputTag
<< "\nrequested in configuration, but not found in the event." << std::endl;
} else {
if (centralBxOnly_) {
// Get GMT candidates from central bunch crossing only
simMuCands = simMuCollection->getRecord().getGMTCands();
} else {
// Get GMT candidates from all bunch crossings
vector<L1MuGMTReadoutRecord> records = simMuCollection->getRecords();
vector<L1MuGMTReadoutRecord>::const_iterator rItr = records.begin();
vector<L1MuGMTReadoutRecord>::const_iterator rEnd = records.end();
for (; rItr != rEnd; ++rItr) {
vector<L1MuGMTExtendedCand> tmpCands = rItr->getGMTCands();
simMuCands.insert(simMuCands.end(), tmpCands.begin(), tmpCands.end());
}
}
vector<L1MuGMTExtendedCand>::const_iterator muItr = simMuCands.begin();
vector<L1MuGMTExtendedCand>::const_iterator muEnd = simMuCands.end();
for (; muItr != muEnd; ++muItr) {
if (!muItr->empty()) {
// keep x and y components non-zero and protect against roundoff.
double pt = muPtScale->getPtScale()->getLowEdge(muItr->ptIndex()) + 1.e-6;
std::cout << "pt from muPtScale = " << pt << std::endl;
double eta = muScales->getGMTEtaScale()->getCenter(muItr->etaIndex());
double phi = muScales->getPhiScale()->getLowEdge(muItr->phiIndex());
math::PtEtaPhiMLorentzVector p4(pt, eta, phi, muonMassGeV_);
Muon outMu{p4,
(int)0,
(int)0,
(int)0,
(int)muItr->quality(),
(int)muItr->charge(),
(int)muItr->charge_valid(),
(int)muItr->isol(),
(int)0,
(int)0,
true,
(int)0,
(int)0,
(int)0,
(int)muItr->rank()};
imdMuonsLegacy->push_back(muItr->bx(), outMu);
}
}
}
}
iEvent.put(std::move(imdMuonsLegacy), "imdMuonsLegacy");
} // closing produce
//define this as a plug-in
DEFINE_FWK_MODULE(L1TMuonLegacyConverter);