CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1TCaloSummary< INPUT, OUTPUT > Class Template Reference

#include <L1Trigger/L1TCaloSummary/plugins/L1TCaloSummary.cc>

Inheritance diagram for L1TCaloSummary< INPUT, OUTPUT >:
edm::stream::EDProducer<>

Public Member Functions

 L1TCaloSummary (const edm::ParameterSet &)
 
 ~L1TCaloSummary () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void print ()
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< L1CaloRegionCollectionbackupRegionToken
 
double boostedJetPtFactor
 
double caloScaleFactor
 
double eGammaIsolationFactor
 
uint32_t eGammaSeed
 
int fwVersion
 
uint32_t jetSeed
 
UCTLayer1 * layer1
 
hls4mlEmulator::ModelLoader loader
 
std::shared_ptr< hls4mlEmulator::Model > model
 
uint32_t nPumBins
 
bool overwriteWithTestPatterns
 
std::vector< std::vector< std::vector< uint32_t > > > pumLUT
 
edm::EDGetTokenT< L1CaloRegionCollectionregionToken
 
float tauIsolationFactor
 
uint32_t tauSeed
 
std::vector< edm::ParameterSettestPatterns
 
bool verbose
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<class INPUT, class OUTPUT>
class L1TCaloSummary< INPUT, OUTPUT >

Description: The package L1Trigger/L1TCaloSummary is prepared for monitoring the CMS Layer-1 Calorimeter Trigger.

Implementation: It prepares region objects and puts them in the event

Definition at line 77 of file L1TCaloSummary.cc.

Constructor & Destructor Documentation

◆ L1TCaloSummary()

template<class INPUT , class OUTPUT >
L1TCaloSummary< INPUT, OUTPUT >::L1TCaloSummary ( const edm::ParameterSet iConfig)
explicit

Definition at line 133 of file L1TCaloSummary.cc.

References L1TCaloSummary< INPUT, OUTPUT >::caloScaleFactor, edm::ParameterSet::getParameter(), l1tPhase2CaloJetEmulator_cfi::iEta, L1TCaloSummary< INPUT, OUTPUT >::loader, SiStripPI::max, L1TCaloSummary< INPUT, OUTPUT >::model, L1TCaloSummary< INPUT, OUTPUT >::nPumBins, L1TCaloSummary< INPUT, OUTPUT >::pumLUT, and ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::side().

134  : nPumBins(iConfig.getParameter<unsigned int>("nPumBins")),
135  pumLUT(nPumBins, std::vector<std::vector<uint32_t>>(2, std::vector<uint32_t>(13))),
136  caloScaleFactor(iConfig.getParameter<double>("caloScaleFactor")),
137  jetSeed(iConfig.getParameter<unsigned int>("jetSeed")),
138  tauSeed(iConfig.getParameter<unsigned int>("tauSeed")),
139  tauIsolationFactor(iConfig.getParameter<double>("tauIsolationFactor")),
140  eGammaSeed(iConfig.getParameter<unsigned int>("eGammaSeed")),
141  eGammaIsolationFactor(iConfig.getParameter<double>("eGammaIsolationFactor")),
142  boostedJetPtFactor(iConfig.getParameter<double>("boostedJetPtFactor")),
143  verbose(iConfig.getParameter<bool>("verbose")),
144  fwVersion(iConfig.getParameter<int>("firmwareVersion")),
145  regionToken(consumes<L1CaloRegionCollection>(iConfig.getParameter<edm::InputTag>("caloLayer1Regions"))),
146  backupRegionToken(consumes<L1CaloRegionCollection>(edm::InputTag("simCaloStage2Layer1Digis"))),
147  loader(hls4mlEmulator::ModelLoader(iConfig.getParameter<string>("CICADAModelVersion"))),
148  overwriteWithTestPatterns(iConfig.getParameter<bool>("useTestPatterns")),
149  testPatterns(iConfig.getParameter<std::vector<edm::ParameterSet>>("testPatterns")) {
150  std::vector<double> pumLUTData;
151  char pumLUTString[10];
152  for (uint32_t pumBin = 0; pumBin < nPumBins; pumBin++) {
153  for (uint32_t side = 0; side < 2; side++) {
154  if (side == 0)
155  sprintf(pumLUTString, "pumLUT%2.2dp", pumBin);
156  else
157  sprintf(pumLUTString, "pumLUT%2.2dn", pumBin);
158  pumLUTData = iConfig.getParameter<std::vector<double>>(pumLUTString);
159  for (uint32_t iEta = 0; iEta < std::max((uint32_t)pumLUTData.size(), MaxUCTRegionsEta); iEta++) {
160  pumLUT[pumBin][side][iEta] = (uint32_t)round(pumLUTData[iEta] / caloScaleFactor);
161  }
162  if (pumLUTData.size() != (MaxUCTRegionsEta))
163  edm::LogError("L1TCaloSummary") << "PUM LUT Data size integrity check failed; Expected size = "
164  << MaxUCTRegionsEta << "; Provided size = " << pumLUTData.size()
165  << "; Will use what is provided :(" << std::endl;
166  }
167  }
168  produces<L1JetParticleCollection>("Boosted");
169 
170  //anomaly trigger loading
171  model = loader.load_model();
172  produces<l1t::CICADABxCollection>("CICADAScore");
173 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool overwriteWithTestPatterns
Log< level::Error, false > LogError
std::vector< edm::ParameterSet > testPatterns
edm::EDGetTokenT< L1CaloRegionCollection > regionToken
edm::EDGetTokenT< L1CaloRegionCollection > backupRegionToken
std::shared_ptr< hls4mlEmulator::Model > model
double boostedJetPtFactor
double eGammaIsolationFactor
hls4mlEmulator::ModelLoader loader
std::vector< std::vector< std::vector< uint32_t > > > pumLUT
double caloScaleFactor

◆ ~L1TCaloSummary()

template<class INPUT , class OUTPUT >
L1TCaloSummary< INPUT, OUTPUT >::~L1TCaloSummary ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

template<class INPUT , class OUTPUT >
void L1TCaloSummary< INPUT, OUTPUT >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 341 of file L1TCaloSummary.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

341  {
342  //The following says we do not know what parameters are allowed so do no validation
343  // Please change this to state exactly what you do use, even if it is no parameters
345  desc.setUnknown();
346  descriptions.addDefault(desc);
347 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ print()

template<class INPUT , class OUTPUT >
void L1TCaloSummary< INPUT, OUTPUT >::print ( )
private

◆ produce()

template<class INPUT , class OUTPUT >
void L1TCaloSummary< INPUT, OUTPUT >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 181 of file L1TCaloSummary.cc.

References funct::abs(), simCaloStage2Layer1Summary_cfi::boostedJetPtFactor, simCaloStage2Layer1Summary_cfi::caloScaleFactor, FCDTask_cfi::crate, simCaloStage2Layer1Summary_cfi::eGammaIsolationFactor, simCaloStage2Layer1Summary_cfi::eGammaSeed, PVValHelper::eta, beamvalidation::exit(), amcDumpToRaw_cfi::fwVersion, g, edm::ParameterSet::getParameter(), mps_fire::i, l1tPhase2CaloJetEmulator_cfi::iEta, iEvent, simCaloStage2Layer1Summary_cfi::jetSeed, EgHLTOffHistBins_cfi::mass, ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi::model, eostools::move(), resolutioncreator_cfi::object, DiDispStaMuonMonitor_cfi::pt, nano_mu_digi_cff::region, l1CaloSummaryTree_cfi::regionToken, AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, simCaloStage2Layer1Summary_cfi::tauIsolationFactor, simCaloStage2Layer1Summary_cfi::tauSeed, and simCaloStage2Layer1Summary_cfi::testPatterns.

181  {
182  using namespace edm;
183 
184  std::unique_ptr<L1JetParticleCollection> bJetCands(new L1JetParticleCollection);
185 
186  std::unique_ptr<l1t::CICADABxCollection> CICADAScore = std::make_unique<l1t::CICADABxCollection>();
187  CICADAScore->setBXRange(-2, 2);
188 
189  UCTGeometry g;
190 
191  // Here we read region data from the region collection created by L1TCaloLayer1 instead of
192  // independently creating regions from TPGs for processing by the summary card. This results
193  // in a single region vector of size 252 whereas from independent creation we had 3*6 vectors
194  // of size 7*2. Indices are mapped in UCTSummaryCard accordingly.
195  UCTSummaryCard summaryCard =
197  std::vector<UCTRegion*> inputRegions;
198  inputRegions.clear();
199  edm::Handle<std::vector<L1CaloRegion>> regionCollection;
200  if (!iEvent.getByToken(regionToken, regionCollection))
201  edm::LogError("L1TCaloSummary") << "UCT: Failed to get regions from region collection!";
202  iEvent.getByToken(regionToken, regionCollection);
203 
204  if (regionCollection->size() == 0) {
205  iEvent.getByToken(backupRegionToken, regionCollection);
206  edm::LogWarning("L1TCaloSummary") << "Switched to emulated regions since data regions was empty.\n";
207  }
208 
209  //Model input
210  //This is done as a flat vector input, but future versions may involve 2D input
211  //This will have to be handled later
212  INPUT modelInput[252];
213  for (const L1CaloRegion& i : *regionCollection) {
214  UCTRegionIndex r = g.getUCTRegionIndexFromL1CaloRegion(i.gctEta(), i.gctPhi());
215  UCTTowerIndex t = g.getUCTTowerIndexFromL1CaloRegion(r, i.raw());
216  uint32_t absCaloEta = std::abs(t.first);
217  uint32_t absCaloPhi = std::abs(t.second);
218  bool negativeEta = false;
219  if (t.first < 0)
220  negativeEta = true;
221  uint32_t crate = g.getCrate(t.first, t.second);
222  uint32_t card = g.getCard(t.first, t.second);
223  uint32_t region = g.getRegion(absCaloEta, absCaloPhi);
224  UCTRegion* test = new UCTRegion(crate, card, negativeEta, region, fwVersion);
225  test->setRegionSummary(i.raw());
226  inputRegions.push_back(test);
227  //This *should* fill the tensor in the proper order to be fed to the anomaly model
228  //We take 4 off of the GCT eta/iEta.
229  //iEta taken from this ranges from 4-17, (I assume reserving lower and higher for forward regions)
230  //So our first index, index 0, is technically iEta=4, and so-on.
231  //CICADA reads this as a flat vector
232  modelInput[14 * i.gctPhi() + (i.gctEta() - 4)] = i.et();
233  }
234  // Check if we're using test patterns. If so, we overwrite the inputs with a test pattern
236  unsigned int evt = iEvent.id().event();
237  unsigned int totalTestPatterns = testPatterns.size();
238  unsigned int patternElement = evt % totalTestPatterns;
239  const edm::ParameterSet& element = testPatterns.at(patternElement);
240  std::stringstream inputStream;
241  std::string PhiRowString;
242 
243  edm::LogWarning("L1TCaloSummary") << "Overwriting existing CICADA input with test pattern!\n";
244 
245  for (unsigned short int iPhi = 1; iPhi <= 18; ++iPhi) {
246  PhiRowString = "";
247  std::stringstream PhiRowStringStream;
248  PhiRowStringStream << "iPhi_" << iPhi;
249  PhiRowString = PhiRowStringStream.str();
250  std::vector<unsigned int> phiRow = element.getParameter<std::vector<unsigned int>>(PhiRowString);
251  for (unsigned short int iEta = 1; iEta <= 14; ++iEta) {
252  modelInput[14 * (iPhi - 1) + (iEta - 1)] = phiRow.at(iEta - 1);
253  inputStream << phiRow.at(iEta - 1) << " ";
254  }
255  inputStream << "\n";
256  }
257  edm::LogInfo("L1TCaloSummary") << "Input Stream:\n" << inputStream.str();
258  }
259 
260  //Extract model output
261  OUTPUT modelResult[1] = {
262  OUTPUT("0.0", 10)}; //the 10 here refers to the fact that we read in "0.0" as a decimal number
263  model->prepare_input(modelInput);
264  model->predict();
265  model->read_result(modelResult);
266 
267  CICADAScore->push_back(0, modelResult[0].to_float());
268 
270  edm::LogInfo("L1TCaloSummary") << "Test Pattern Output: " << CICADAScore->at(0, 0);
271 
272  summaryCard.setRegionData(inputRegions);
273 
274  if (!summaryCard.process()) {
275  edm::LogError("L1TCaloSummary") << "UCT: Failed to process summary card" << std::endl;
276  exit(1);
277  }
278 
279  double pt = 0;
280  double eta = -999.;
281  double phi = -999.;
282  double mass = 0;
283 
284  std::list<UCTObject*> boostedJetObjs = summaryCard.getBoostedJetObjs();
285  for (std::list<UCTObject*>::const_iterator i = boostedJetObjs.begin(); i != boostedJetObjs.end(); i++) {
286  const UCTObject* object = *i;
287  pt = ((double)object->et()) * caloScaleFactor * boostedJetPtFactor;
288  eta = g.getUCTTowerEta(object->iEta());
289  phi = g.getUCTTowerPhi(object->iPhi());
290  bitset<3> activeRegionEtaPattern = 0;
291  for (uint32_t iEta = 0; iEta < 3; iEta++) {
292  bool activeStrip = false;
293  for (uint32_t iPhi = 0; iPhi < 3; iPhi++) {
294  if (object->boostedJetRegionET()[3 * iEta + iPhi] > 30 &&
295  object->boostedJetRegionET()[3 * iEta + iPhi] > object->et() * 0.0625)
296  activeStrip = true;
297  }
298  if (activeStrip)
299  activeRegionEtaPattern |= (0x1 << iEta);
300  }
301  bitset<3> activeRegionPhiPattern = 0;
302  for (uint32_t iPhi = 0; iPhi < 3; iPhi++) {
303  bool activeStrip = false;
304  for (uint32_t iEta = 0; iEta < 3; iEta++) {
305  if (object->boostedJetRegionET()[3 * iEta + iPhi] > 30 &&
306  object->boostedJetRegionET()[3 * iEta + iPhi] > object->et() * 0.0625)
307  activeStrip = true;
308  }
309  if (activeStrip)
310  activeRegionPhiPattern |= (0x1 << iPhi);
311  }
312  string regionEta = activeRegionEtaPattern.to_string<char, std::string::traits_type, std::string::allocator_type>();
313  string regionPhi = activeRegionPhiPattern.to_string<char, std::string::traits_type, std::string::allocator_type>();
314 
315  bool centralHighest = object->boostedJetRegionET()[4] >= object->boostedJetRegionET()[0] &&
316  object->boostedJetRegionET()[4] >= object->boostedJetRegionET()[1] &&
317  object->boostedJetRegionET()[4] >= object->boostedJetRegionET()[2] &&
318  object->boostedJetRegionET()[4] >= object->boostedJetRegionET()[3] &&
319  object->boostedJetRegionET()[4] >= object->boostedJetRegionET()[5] &&
320  object->boostedJetRegionET()[4] >= object->boostedJetRegionET()[6] &&
321  object->boostedJetRegionET()[4] >= object->boostedJetRegionET()[7] &&
322  object->boostedJetRegionET()[4] >= object->boostedJetRegionET()[8];
323 
324  if (abs(eta) < 2.5 && ((regionEta == "101" && (regionPhi == "110" || regionPhi == "101" || regionPhi == "010")) ||
325  ((regionEta == "110" || regionEta == "101" || regionEta == "010") && regionPhi == "101") ||
326  (regionEta == "111" && (regionPhi == "110" || regionPhi == "010")) ||
327  ((regionEta == "110" || regionEta == "010") && regionPhi == "111") ||
328  ((regionEta == "010" || regionPhi == "010" || regionEta == "110" || regionPhi == "110" ||
329  regionEta == "011" || regionPhi == "011") &&
330  centralHighest)))
331  bJetCands->push_back(L1JetParticle(math::PtEtaPhiMLorentzVector(pt, eta, phi, mass), L1JetParticle::kCentral));
332  }
333 
334  iEvent.put(std::move(bJetCands), "Boosted");
335  //Write out anomaly score
336  iEvent.put(std::move(CICADAScore), "CICADAScore");
337 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool overwriteWithTestPatterns
Log< level::Error, false > LogError
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< edm::ParameterSet > testPatterns
edm::EDGetTokenT< L1CaloRegionCollection > regionToken
Log< level::Info, false > LogInfo
edm::EDGetTokenT< L1CaloRegionCollection > backupRegionToken
std::shared_ptr< hls4mlEmulator::Model > model
double boostedJetPtFactor
double eGammaIsolationFactor
HLT enums.
std::vector< std::vector< std::vector< uint32_t > > > pumLUT
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:21
double caloScaleFactor
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511
def exit(msg="")

Member Data Documentation

◆ backupRegionToken

template<class INPUT , class OUTPUT >
edm::EDGetTokenT<L1CaloRegionCollection> L1TCaloSummary< INPUT, OUTPUT >::backupRegionToken
private

Definition at line 110 of file L1TCaloSummary.cc.

◆ boostedJetPtFactor

template<class INPUT , class OUTPUT >
double L1TCaloSummary< INPUT, OUTPUT >::boostedJetPtFactor
private

Definition at line 104 of file L1TCaloSummary.cc.

◆ caloScaleFactor

template<class INPUT , class OUTPUT >
double L1TCaloSummary< INPUT, OUTPUT >::caloScaleFactor
private

Definition at line 97 of file L1TCaloSummary.cc.

Referenced by L1TCaloSummary< INPUT, OUTPUT >::L1TCaloSummary().

◆ eGammaIsolationFactor

template<class INPUT , class OUTPUT >
double L1TCaloSummary< INPUT, OUTPUT >::eGammaIsolationFactor
private

Definition at line 103 of file L1TCaloSummary.cc.

◆ eGammaSeed

template<class INPUT , class OUTPUT >
uint32_t L1TCaloSummary< INPUT, OUTPUT >::eGammaSeed
private

Definition at line 102 of file L1TCaloSummary.cc.

◆ fwVersion

template<class INPUT , class OUTPUT >
int L1TCaloSummary< INPUT, OUTPUT >::fwVersion
private

Definition at line 107 of file L1TCaloSummary.cc.

◆ jetSeed

template<class INPUT , class OUTPUT >
uint32_t L1TCaloSummary< INPUT, OUTPUT >::jetSeed
private

Definition at line 99 of file L1TCaloSummary.cc.

◆ layer1

template<class INPUT , class OUTPUT >
UCTLayer1* L1TCaloSummary< INPUT, OUTPUT >::layer1
private

Definition at line 112 of file L1TCaloSummary.cc.

◆ loader

template<class INPUT , class OUTPUT >
hls4mlEmulator::ModelLoader L1TCaloSummary< INPUT, OUTPUT >::loader
private

Definition at line 114 of file L1TCaloSummary.cc.

Referenced by L1TCaloSummary< INPUT, OUTPUT >::L1TCaloSummary().

◆ model

template<class INPUT , class OUTPUT >
std::shared_ptr<hls4mlEmulator::Model> L1TCaloSummary< INPUT, OUTPUT >::model
private

◆ nPumBins

template<class INPUT , class OUTPUT >
uint32_t L1TCaloSummary< INPUT, OUTPUT >::nPumBins
private

Definition at line 93 of file L1TCaloSummary.cc.

Referenced by L1TCaloSummary< INPUT, OUTPUT >::L1TCaloSummary().

◆ overwriteWithTestPatterns

template<class INPUT , class OUTPUT >
bool L1TCaloSummary< INPUT, OUTPUT >::overwriteWithTestPatterns
private

Definition at line 117 of file L1TCaloSummary.cc.

◆ pumLUT

template<class INPUT , class OUTPUT >
std::vector<std::vector<std::vector<uint32_t> > > L1TCaloSummary< INPUT, OUTPUT >::pumLUT
private

Definition at line 95 of file L1TCaloSummary.cc.

Referenced by L1TCaloSummary< INPUT, OUTPUT >::L1TCaloSummary().

◆ regionToken

template<class INPUT , class OUTPUT >
edm::EDGetTokenT<L1CaloRegionCollection> L1TCaloSummary< INPUT, OUTPUT >::regionToken
private

Definition at line 109 of file L1TCaloSummary.cc.

◆ tauIsolationFactor

template<class INPUT , class OUTPUT >
float L1TCaloSummary< INPUT, OUTPUT >::tauIsolationFactor
private

Definition at line 101 of file L1TCaloSummary.cc.

◆ tauSeed

template<class INPUT , class OUTPUT >
uint32_t L1TCaloSummary< INPUT, OUTPUT >::tauSeed
private

Definition at line 100 of file L1TCaloSummary.cc.

◆ testPatterns

template<class INPUT , class OUTPUT >
std::vector<edm::ParameterSet> L1TCaloSummary< INPUT, OUTPUT >::testPatterns
private

Definition at line 118 of file L1TCaloSummary.cc.

◆ verbose

template<class INPUT , class OUTPUT >
bool L1TCaloSummary< INPUT, OUTPUT >::verbose
private