CMS 3D CMS Logo

L1GctEmulator.cc
Go to the documentation of this file.
2 
3 // system includes
4 #include <memory>
5 #include <vector>
6 
7 // EDM includes
15 
17 
18 // GCT include files
20 
21 // RCT data includes
23 
24 // GCT data includes
26 
27 using std::vector;
28 
30  : m_jetEtCalibLuts(),
31  m_writeInternalData(ps.getParameter<bool>("writeInternalData")),
32  m_verbose(ps.getUntrackedParameter<bool>("verbose", false)),
33  m_conditionsLabel(ps.getParameter<std::string>("conditionsLabel")) {
34  // list of products
35  produces<L1GctEmCandCollection>("isoEm");
36  produces<L1GctEmCandCollection>("nonIsoEm");
37  produces<L1GctJetCandCollection>("cenJets");
38  produces<L1GctJetCandCollection>("forJets");
39  produces<L1GctJetCandCollection>("tauJets");
40  produces<L1GctInternJetDataCollection>();
41  produces<L1GctEtTotalCollection>();
42  produces<L1GctEtHadCollection>();
43  produces<L1GctEtMissCollection>();
44  produces<L1GctHtMissCollection>();
45  produces<L1GctInternEtSumCollection>();
46  produces<L1GctInternHtMissCollection>();
47  produces<L1GctHFBitCountsCollection>();
48  produces<L1GctHFRingEtSumsCollection>();
49 
50  // get the input label
52  m_inputLabel = inputTag.label();
53 
54  // Get the number of bunch crossings to be processed
55  int firstBx = -ps.getParameter<unsigned>("preSamples");
56  int lastBx = ps.getParameter<unsigned>("postSamples");
57 
58  // instantiate the GCT. Argument selects the type of jetFinder to be used.
60  std::string jfTypeStr = ps.getParameter<std::string>("jetFinderType");
61  if (jfTypeStr == "tdrJetFinder") {
63  } else if (jfTypeStr != "hardwareJetFinder") {
64  edm::LogWarning("L1GctEmulatorSetup")
65  << "Unrecognised jetFinder option " << jfTypeStr << "\nHardware jetFinder will be used";
66  }
67  bool hwTest = ps.getParameter<bool>("hardwareTest");
68  if (hwTest) {
69  unsigned mask = ps.getUntrackedParameter<unsigned>("jetLeafMask", 0);
70  m_gct = std::make_unique<L1GlobalCaloTrigger>(jfType, mask);
71  edm::LogWarning("L1GctEmulatorSetup") << "Emulator has been configured in hardware test mode with mask " << mask
72  << "\nThis mode should NOT be used for Physics studies!";
73  } else {
74  m_gct = std::make_unique<L1GlobalCaloTrigger>(jfType);
75  }
76  m_gct->setBxRange(firstBx, lastBx);
77 
78  // Fill the jetEtCalibLuts vector
79  lutPtr nextLut(new L1GctJetEtCalibrationLut());
80 
81  for (unsigned ieta = 0; ieta < L1GctJetFinderParams::NUMBER_ETA_VALUES; ieta++) {
82  nextLut->setEtaBin(ieta);
83  m_jetEtCalibLuts.push_back(nextLut);
84  nextLut.reset(new L1GctJetEtCalibrationLut());
85  }
86 
87  // Setup the tau algorithm parameters
88  bool useImprovedTauAlgo = ps.getParameter<bool>("useImprovedTauAlgorithm");
89  bool ignoreTauVetoBitsForIsolation = ps.getParameter<bool>("ignoreRCTTauVetoBitsForIsolation");
90  m_gct->setupTauAlgo(useImprovedTauAlgo, ignoreTauVetoBitsForIsolation);
91 
92  // set verbosity (not implemented yet!)
93  // m_gct->setVerbose(m_verbose);
94 
95  // print debug info?
96  if (m_verbose) {
97  m_gct->print();
98  }
99  m_emToken = consumes<L1CaloEmCollection>(inputTag);
100  m_regionToken = consumes<L1CaloRegionCollection>(inputTag);
101  m_jfParsToken = esConsumes<L1GctJetFinderParams, L1GctJetFinderParamsRcd>(edm::ESInputTag("", m_conditionsLabel));
102  m_chanMaskToken = esConsumes<L1GctChannelMask, L1GctChannelMaskRcd>(edm::ESInputTag("", m_conditionsLabel));
103  m_etScaleToken = esConsumes<L1CaloEtScale, L1JetEtScaleRcd>(edm::ESInputTag("", m_conditionsLabel));
104  m_htMissScaleToken = esConsumes<L1CaloEtScale, L1HtMissScaleRcd>(edm::ESInputTag("", m_conditionsLabel));
105  m_hfRingEtScaleToken = esConsumes<L1CaloEtScale, L1HfRingEtScaleRcd>(edm::ESInputTag("", m_conditionsLabel));
106 }
107 
109  int success = 0;
110 
111  if (success == 0) {
112  // get data from EventSetup
114  edm::ESHandle<L1GctChannelMask> chanMask = c.getHandle(m_chanMaskToken);
116  edm::ESHandle<L1CaloEtScale> htMissScale = c.getHandle(m_htMissScaleToken);
117  edm::ESHandle<L1CaloEtScale> hfRingEtScale = c.getHandle(m_hfRingEtScaleToken);
118 
119  if (jfPars.product() == nullptr) {
120  success = -1;
121  if (m_verbose) {
122  edm::LogWarning("L1GctConfigFailure")
123  << "Failed to find a L1GctJetFinderParamsRcd:L1GctJetFinderParams in EventSetup!" << std::endl;
124  }
125  }
126 
127  if (chanMask.product() == nullptr) {
128  success = -1;
129  if (m_verbose) {
130  edm::LogWarning("L1GctConfigFailure")
131  << "Failed to find a L1GctChannelMaskRcd:L1GctChannelMask in EventSetup!" << std::endl;
132  }
133  }
134 
135  if (hfRingEtScale.product() == nullptr) {
136  success = -1;
137  if (m_verbose) {
138  edm::LogWarning("L1GctConfigFailure")
139  << "Failed to find a L1HfRingEtScaleRcd:L1HfRingEtScaleRcd in EventSetup!" << std::endl;
140  }
141  }
142 
143  if (success == 0) {
144  // tell the jet Et Luts about the scales
145  for (unsigned ieta = 0; ieta < m_jetEtCalibLuts.size(); ieta++) {
146  m_jetEtCalibLuts.at(ieta)->setFunction(jfPars.product());
147  m_jetEtCalibLuts.at(ieta)->setOutputEtScale(etScale.product());
148  }
149 
150  // pass all the setup info to the gct
151  m_gct->setJetEtCalibrationLuts(m_jetEtCalibLuts);
152  m_gct->setJetFinderParams(jfPars.product());
153  m_gct->setHtMissScale(htMissScale.product());
154  m_gct->setupHfSumLuts(hfRingEtScale.product());
155  m_gct->setChannelMask(chanMask.product());
156  }
157  }
158 
159  if (success != 0 && m_verbose) {
160  edm::LogError("L1GctConfigError") << "Configuration failed - GCT emulator will not be run" << std::endl;
161  }
162  return success;
163 }
164 
166  // The emulator will always produce output collections, which get filled as long as
167  // the setup and input data are present. Start by making empty output collections.
168 
169  // create the em and jet collections
170  std::unique_ptr<L1GctEmCandCollection> isoEmResult(new L1GctEmCandCollection());
171  std::unique_ptr<L1GctEmCandCollection> nonIsoEmResult(new L1GctEmCandCollection());
172  std::unique_ptr<L1GctJetCandCollection> cenJetResult(new L1GctJetCandCollection());
173  std::unique_ptr<L1GctJetCandCollection> forJetResult(new L1GctJetCandCollection());
174  std::unique_ptr<L1GctJetCandCollection> tauJetResult(new L1GctJetCandCollection());
175 
176  // create the energy sum digis
177  std::unique_ptr<L1GctEtTotalCollection> etTotResult(new L1GctEtTotalCollection());
178  std::unique_ptr<L1GctEtHadCollection> etHadResult(new L1GctEtHadCollection());
179  std::unique_ptr<L1GctEtMissCollection> etMissResult(new L1GctEtMissCollection());
180  std::unique_ptr<L1GctHtMissCollection> htMissResult(new L1GctHtMissCollection());
181 
182  // create the Hf sums digis
183  std::unique_ptr<L1GctHFBitCountsCollection> hfBitCountResult(new L1GctHFBitCountsCollection());
184  std::unique_ptr<L1GctHFRingEtSumsCollection> hfRingEtSumResult(new L1GctHFRingEtSumsCollection());
185 
186  // create internal data collections
187  std::unique_ptr<L1GctInternJetDataCollection> internalJetResult(new L1GctInternJetDataCollection());
188  std::unique_ptr<L1GctInternEtSumCollection> internalEtSumResult(new L1GctInternEtSumCollection());
189  std::unique_ptr<L1GctInternHtMissCollection> internalHtMissResult(new L1GctInternHtMissCollection());
190 
191  // get config data from EventSetup.
192  // check this has been done successfully before proceeding
193  if (configureGct(c) == 0) {
194  // get the RCT data
197  bool gotEm = e.getByToken(m_emToken, em);
198  bool gotRgn = e.getByToken(m_regionToken, rgn);
199 
200  // check the data
201  if (!gotEm && m_verbose) {
202  edm::LogError("L1GctInputFailedError") << "Failed to get em candidates with label " << m_inputLabel
203  << " - GCT emulator will not be run" << std::endl;
204  }
205 
206  if (!gotRgn && m_verbose) {
207  edm::LogError("L1GctInputFailedError")
208  << "Failed to get calo regions with label " << m_inputLabel << " - GCT emulator will not be run" << std::endl;
209  }
210 
211  if (gotEm && !em.isValid()) {
212  gotEm = false;
213  if (m_verbose) {
214  edm::LogError("L1GctInputFailedError") << "isValid() flag set to false for em candidates with label "
215  << m_inputLabel << " - GCT emulator will not be run" << std::endl;
216  }
217  }
218 
219  if (gotRgn && !rgn.isValid()) {
220  gotRgn = false;
221  if (m_verbose) {
222  edm::LogError("L1GctInputFailedError") << "isValid() flag set to false for calo regions with label "
223  << m_inputLabel << " - GCT emulator will not be run" << std::endl;
224  }
225  }
226 
227  // if all is ok, proceed with GCT processing
228  if (gotEm && gotRgn) {
229  // reset the GCT internal buffers
230  m_gct->reset();
231 
232  // fill the GCT source cards
233  m_gct->fillEmCands(*em);
234  m_gct->fillRegions(*rgn);
235 
236  // process the event
237  m_gct->process();
238 
239  // fill the em and jet collections
240  *isoEmResult = m_gct->getIsoElectrons();
241  *nonIsoEmResult = m_gct->getNonIsoElectrons();
242  *cenJetResult = m_gct->getCentralJets();
243  *forJetResult = m_gct->getForwardJets();
244  *tauJetResult = m_gct->getTauJets();
245 
246  // fill the energy sum digis
247  *etTotResult = m_gct->getEtSumCollection();
248  *etHadResult = m_gct->getEtHadCollection();
249  *etMissResult = m_gct->getEtMissCollection();
250  *htMissResult = m_gct->getHtMissCollection();
251 
252  // fill the Hf sums digis
253  *hfBitCountResult = m_gct->getHFBitCountsCollection();
254  *hfRingEtSumResult = m_gct->getHFRingEtSumsCollection();
255 
256  // fill internal data collections if required
257  if (m_writeInternalData) {
258  *internalJetResult = m_gct->getInternalJets();
259  *internalEtSumResult = m_gct->getInternalEtSums();
260  *internalHtMissResult = m_gct->getInternalHtMiss();
261  }
262  }
263  }
264 
265  // put the collections into the event
266  e.put(std::move(isoEmResult), "isoEm");
267  e.put(std::move(nonIsoEmResult), "nonIsoEm");
268  e.put(std::move(cenJetResult), "cenJets");
269  e.put(std::move(forJetResult), "forJets");
270  e.put(std::move(tauJetResult), "tauJets");
271  e.put(std::move(etTotResult));
272  e.put(std::move(etHadResult));
273  e.put(std::move(etMissResult));
274  e.put(std::move(htMissResult));
275  e.put(std::move(hfBitCountResult));
276  e.put(std::move(hfRingEtSumResult));
277 
278  e.put(std::move(internalJetResult));
279  e.put(std::move(internalEtSumResult));
280  e.put(std::move(internalHtMissResult));
281 }
282 
L1GctJetLeafCard::jetFinderType
jetFinderType
Definition: L1GctJetLeafCard.h:31
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
L1GctEmulator::L1GctEmulator
L1GctEmulator(const edm::ParameterSet &ps)
constructor
Definition: L1GctEmulator.cc:29
L1GctJetEtCalibrationLut.h
L1GctInternEtSumCollection
std::vector< L1GctInternEtSum > L1GctInternEtSumCollection
Definition: L1GctCollections.h:25
L1GctEmulator::m_regionToken
edm::EDGetTokenT< L1CaloRegionCollection > m_regionToken
Definition: L1GctEmulator.h:57
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
L1GctEmulator::m_inputLabel
std::string m_inputLabel
Definition: L1GctEmulator.h:55
funct::false
false
Definition: Factorize.h:29
EDProducer.h
L1GctEmulator::m_emToken
edm::EDGetTokenT< L1CaloEmCollection > m_emToken
Definition: L1GctEmulator.h:56
ESHandle.h
L1GctCollections.h
L1GctJetCandCollection
std::vector< L1GctJetCand > L1GctJetCandCollection
Definition: L1GctCollections.h:31
L1GctEmulator::m_chanMaskToken
edm::ESGetToken< L1GctChannelMask, L1GctChannelMaskRcd > m_chanMaskToken
Definition: L1GctEmulator.h:61
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
L1GctEmulator::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: L1GctEmulator.cc:165
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
L1GctJetLeafCard::tdrJetFinder
Definition: L1GctJetLeafCard.h:31
L1GctEmulator::m_verbose
const bool m_verbose
Definition: L1GctEmulator.h:76
L1GctEtMissCollection
std::vector< L1GctEtMiss > L1GctEtMissCollection
Definition: L1GctCollections.h:34
L1GctEmulator::m_gct
std::unique_ptr< L1GlobalCaloTrigger > m_gct
Definition: L1GctEmulator.h:67
MakerMacros.h
L1GctJetEtCalibrationLut
Jet Et calibration LUT.
Definition: L1GctJetEtCalibrationLut.h:28
L1GctEmulator::lutPtr
L1GlobalCaloTrigger::lutPtr lutPtr
typedefs
Definition: L1GctEmulator.h:43
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1GctEmulator::m_jfParsToken
edm::ESGetToken< L1GctJetFinderParams, L1GctJetFinderParamsRcd > m_jfParsToken
Definition: L1GctEmulator.h:60
L1GctJetLeafCard::hardwareJetFinder
Definition: L1GctJetLeafCard.h:31
L1GctEmulator
Definition: L1GctEmulator.h:40
L1GctInternHtMissCollection
std::vector< L1GctInternHtMiss > L1GctInternHtMissCollection
Definition: L1GctCollections.h:27
edm::ESHandle
Definition: DTSurvey.h:22
summarizeEdmComparisonLogfiles.success
success
Definition: summarizeEdmComparisonLogfiles.py:114
L1GctEmulator::m_htMissScaleToken
edm::ESGetToken< L1CaloEtScale, L1HtMissScaleRcd > m_htMissScaleToken
Definition: L1GctEmulator.h:63
L1GctEtTotalCollection
std::vector< L1GctEtTotal > L1GctEtTotalCollection
Definition: L1GctCollections.h:35
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
L1GctEmulator::m_hfRingEtScaleToken
edm::ESGetToken< L1CaloEtScale, L1HfRingEtScaleRcd > m_hfRingEtScaleToken
Definition: L1GctEmulator.h:64
L1GctEmulator::m_conditionsLabel
const std::string m_conditionsLabel
Definition: L1GctEmulator.h:79
ModuleDef.h
L1CaloCollections.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
L1GctHFBitCountsCollection
std::vector< L1GctHFBitCounts > L1GctHFBitCountsCollection
Definition: L1GctCollections.h:39
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
L1GctEmCandCollection
std::vector< L1GctEmCand > L1GctEmCandCollection
Definition: L1GctCollections.h:30
Frameworkfwd.h
L1GctEmulator.h
L1GctEmulator::m_jetEtCalibLuts
lutPtrVector m_jetEtCalibLuts
Definition: L1GctEmulator.h:70
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
L1GctInternJetDataCollection
std::vector< L1GctInternJetData > L1GctInternJetDataCollection
Definition: L1GctCollections.h:24
L1GctEmulator::m_etScaleToken
edm::ESGetToken< L1CaloEtScale, L1JetEtScaleRcd > m_etScaleToken
Definition: L1GctEmulator.h:62
L1GctEtHadCollection
std::vector< L1GctEtHad > L1GctEtHadCollection
Definition: L1GctCollections.h:33
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
SimL1EmulatorRepack_Full_cff.inputTag
inputTag
Definition: SimL1EmulatorRepack_Full_cff.py:56
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
L1GctHFRingEtSumsCollection
std::vector< L1GctHFRingEtSums > L1GctHFRingEtSumsCollection
Definition: L1GctCollections.h:38
L1GctEmulator::configureGct
int configureGct(const edm::EventSetup &c)
Definition: L1GctEmulator.cc:108
edm::InputTag
Definition: InputTag.h:15
L1GctJetFinderParams::NUMBER_ETA_VALUES
static const unsigned NUMBER_ETA_VALUES
Number of eta bins used in correction.
Definition: L1GctJetFinderParams.h:12
L1GctHtMissCollection
std::vector< L1GctHtMiss > L1GctHtMissCollection
Definition: L1GctCollections.h:36
L1GctEmulator::m_writeInternalData
const bool m_writeInternalData
Definition: L1GctEmulator.h:73
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
photonValidator_cfi.etScale
etScale
Definition: photonValidator_cfi.py:47