CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1TStage1Layer2Producer Class Reference
Inheritance diagram for L1TStage1Layer2Producer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TStage1Layer2Producer (const ParameterSet &)
 
 ~L1TStage1Layer2Producer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Private Member Functions

void beginJob () override
 
void beginRun (Run const &iR, EventSetup const &iE) override
 
void endJob () override
 
void endRun (Run const &iR, EventSetup const &iE) override
 
void produce (Event &, EventSetup const &) override
 

Private Attributes

EDGetToken candsToken
 
std::string m_conditionsLabel
 
CaloConfigHelper m_config
 
unsigned long long m_configCacheId
 
Stage1Layer2FirmwareFactory m_factory
 
std::shared_ptr< Stage1Layer2MainProcessorm_fw
 
CaloParamsHelperm_params
 
unsigned long long m_paramsCacheId
 
EDGetToken regionToken
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 70 of file L1TStage1Layer2Producer.cc.

Constructor & Destructor Documentation

L1TStage1Layer2Producer::L1TStage1Layer2Producer ( const ParameterSet iConfig)
explicit

Definition at line 106 of file L1TStage1Layer2Producer.cc.

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

107  {
108  // register what you produce
109  produces<BXVector<EGamma>>();
110  produces<BXVector<Tau>>("rlxTaus");
111  produces<BXVector<Tau>>("isoTaus");
112  produces<BXVector<Jet>>();
113  produces<BXVector<Jet>>("preGtJets");
114  produces<BXVector<EtSum>>();
115  produces<BXVector<CaloSpare>>("HFRingSums");
116  produces<BXVector<CaloSpare>>("HFBitCounts");
117 
118  // register what you consume and keep token for later access:
119  regionToken = consumes<BXVector<CaloRegion>>(iConfig.getParameter<InputTag>("CaloRegions"));
120  candsToken = consumes<BXVector<CaloEmCand>>(iConfig.getParameter<InputTag>("CaloEmCands"));
121  //int ifwv=iConfig.getParameter<unsigned>("FirmwareVersion"); // LenA make configurable for now
122 
123  m_conditionsLabel = iConfig.getParameter<std::string>("conditionsLabel");
124 
126 
127  // set cache id to zero, will be set at first beginRun:
128  m_paramsCacheId = 0;
129  m_configCacheId = 0;
130  }
T getParameter(std::string const &) const
unsigned long long m_paramsCacheId
unsigned long long m_configCacheId
L1TStage1Layer2Producer::~L1TStage1Layer2Producer ( )
override

Definition at line 133 of file L1TStage1Layer2Producer.cc.

134  {
135  }

Member Function Documentation

void L1TStage1Layer2Producer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 255 of file L1TStage1Layer2Producer.cc.

256 {
257 }
void L1TStage1Layer2Producer::beginRun ( Run const &  iR,
EventSetup const &  iE 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 266 of file L1TStage1Layer2Producer.cc.

References edm::EventSetup::get(), triggerObjects_cff::id, wplusjetsAnalysis_cfi::jetScale, LogDebug, and edm::ESHandle< T >::product().

266  {
267  unsigned long long id = 0;
268 
269  id = iE.get<L1TCaloParamsRcd>().cacheIdentifier();
270  if (id != m_paramsCacheId) {
271 
273 
274  edm::ESHandle<CaloParams> paramsHandle;
275 
276  iE.get<L1TCaloParamsRcd>().get(m_conditionsLabel, paramsHandle);
277 
278  // replace our local copy of the parameters with a new one using placement new
280  m_params = new (m_params) CaloParamsHelper(*paramsHandle.product());
281 
282  LogDebug("L1TDebug") << *m_params << std::endl;
283 
284  if (! m_params){
285  edm::LogError("l1t|caloStage1") << "Could not retrieve params from Event Setup" << std::endl;
286  }
287 
288  }
289 
290  id = iE.get<L1TCaloConfigRcd>().cacheIdentifier();
291  if (id != m_configCacheId) {
293 
294  edm::ESHandle<CaloConfig> configHandle;
295 
296  iE.get<L1TCaloConfigRcd>().get(m_conditionsLabel, configHandle);
297 
298 
299  if (! configHandle.product()){
300  edm::LogError("l1t|caloStage1") << "Could not retrieve config from Event Setup" << std::endl;
301  } else {
302  //update our DB payload in CaloConfigHelper:
303  m_config.UpdatePayload(configHandle.product());
304  //cout << "DEBUG: L1T Calo Config reports the Layer2 firmware version is " << m_config.fwv() << "\n";
305  }
306  }
307 
308 
309 
310 
311 
312 
313  LogDebug("l1t|stage 1 jets") << "L1TStage1Layer2Producer::beginRun function called...\n";
314 
315  //get the proper scales for conversion to physical et AND gt scales
317  iE.get< L1EmEtScaleRcd >().get( m_conditionsLabel, emScale ) ;
318  m_params->setEmScale(*emScale);
319 
321  iE.get< L1JetEtScaleRcd >().get( m_conditionsLabel, jetScale ) ;
322  m_params->setJetScale(*jetScale);
323 
324  edm::ESHandle< L1CaloEtScale > HtMissScale;
325  iE.get< L1HtMissScaleRcd >().get( m_conditionsLabel, HtMissScale ) ;
326  m_params->setHtMissScale(*HtMissScale);
327 
328  //not sure if I need this one
329  edm::ESHandle< L1CaloEtScale > HfRingScale;
330  iE.get< L1HfRingEtScaleRcd >().get( m_conditionsLabel, HfRingScale );
331  m_params->setHfRingScale(*HfRingScale);
332 
333 
334  //unsigned long long id = iE.get<CaloParamsRcd>().cacheIdentifier();
335 
336  //if (id != m_paramsCacheId)
337  { // Need to update:
338  //m_paramsCacheId = id;
339 
340  //ESHandle<CaloParams> parameters;
341  //iE.get<CaloParamsRcd>().get(parameters);
342 
343  // LenA move the setting of the firmware version to the L1TStage1Layer2Producer constructor
344 
345  //m_params = std::shared_ptr<const CaloParams>(parameters.product());
346  //m_fwv = std::shared_ptr<const FirmwareVersion>(new FirmwareVersion());
347  //printf("Begin.\n");
348  //m_fwv = std::make_shared<FirmwareVersion>(); //not const during testing
349  //printf("Success m_fwv.\n");
350  //m_fwv->setFirmwareVersion(1); //hardcode for now, 1=HI, 2=PP
351  //printf("Success m_fwv version set.\n");
352 
353  // if (! m_params){
354  // LogError("l1t|stage 1 jets") << "L1TStage1Layer2Producer: could not retreive DB params from Event Setup\n";
355  // }
356 
357  // Set the current algorithm version based on DB pars from database:
358  //m_fw = m_factory.create(*m_fwv /*,*m_params*/);
359  //printf("Success create.\n");
360 
361  //if (! m_fw) {
362  // // we complain here once per run
363  // LogError("l1t|stage 1 jets") << "L1TStage1Layer2Producer: firmware could not be configured.\n";
364  //}
365  }
366 
367 
368 
369  int ifwv=m_config.fwv();
370  //cout << "DEBUG: ifwv is " << ifwv << "\n";
371  //m_fwv = std::make_shared<FirmwareVersion>(); //not const during testing
372  if (ifwv == 1){
373  LogDebug("l1t|stage1firmware") << "L1TStage1Layer2Producer -- Running HI implementation\n";
374  //std::cout << "L1TStage1Layer2Producer -- Running HI implementation\n";
375  }else if (ifwv == 2){
376  LogDebug("l1t|stage1firmware") << "L1TStage1Layer2Producer -- Running pp implementation\n";
377  //std::cout << "L1TStage1Layer2Producer -- Running pp implementation\n";
378  } else if (ifwv == 3){
379  LogDebug("l1t|stage1firmware") << "L1TStage1Layer2Producer -- Running SimpleHW implementation\n";
380  //std::cout << "L1TStage1Layer2Producer -- Running SimpleHW implementation -- for testing only\n";
381  }else{
382  LogError("l1t|stage1firmware") << "L1TStage1Layer2Producer -- Unknown implementation.\n";
383  //std::cout << "L1TStage1Layer2Producer -- Unknown implementation.\n";
384  }
385  //m_fwv->setFirmwareVersion(ifwv); // =1 HI, =2 PP
386  // m_fw = m_factory.create(*m_fwv /*,*m_params*/);
387  //m_fwv = ifwv;
388  m_fw = m_factory.create(ifwv ,m_params);
389  //printf("Success create.\n");
390  if (! m_fw) {
391  // we complain here once per job
392  LogError("l1t|stage1firmware") << "L1TStage1Layer2Producer: firmware could not be configured.\n";
393  }
394 
395 
396 
397 
398 }
#define LogDebug(id)
void setJetScale(L1CaloEtScale jetScale)
void setHfRingScale(L1CaloEtScale HfRingScale)
unsigned long long m_paramsCacheId
void setHtMissScale(L1CaloEtScale HtMissScale)
Stage1Layer2FirmwareFactory m_factory
std::shared_ptr< Stage1Layer2MainProcessor > m_fw
unsigned long long m_configCacheId
void setEmScale(L1CaloEtScale emScale)
ReturnType create(const int fwv, CaloParamsHelper const *dbPars)
T const * product() const
Definition: ESHandle.h:86
void UpdatePayload(const CaloConfig *db)
void L1TStage1Layer2Producer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 261 of file L1TStage1Layer2Producer.cc.

261  {
262 }
void L1TStage1Layer2Producer::endRun ( Run const &  iR,
EventSetup const &  iE 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 401 of file L1TStage1Layer2Producer.cc.

401  {
402 
403 }
void L1TStage1Layer2Producer::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 408 of file L1TStage1Layer2Producer.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

408  {
409  //The following says we do not know what parameters are allowed so do no validation
410  // Please change this to state exactly what you do use, even if it is no parameters
412  desc.setUnknown();
413  descriptions.addDefault(desc);
414 }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TStage1Layer2Producer::produce ( Event ,
EventSetup const &   
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 145 of file L1TStage1Layer2Producer.cc.

References edm::Event::getByToken(), mps_fire::i, metsig::jet, fwrapper::jets, LogDebug, eostools::move(), edm::Event::put(), l1t::CaloSpare::setType(), metsig::tau, and nano_cff::taus.

146 {
147 
148  LogDebug("l1t|stage 1 jets") << "L1TStage1Layer2Producer::produce function called...\n";
149 
150  //return;
151 
152  //inputs
153  Handle<BXVector<CaloRegion>> caloRegions;
154  iEvent.getByToken(regionToken,caloRegions);
155 
156  Handle<BXVector<CaloEmCand>> caloEmCands;
157  iEvent.getByToken(candsToken, caloEmCands);
158 
159  int bxFirst = caloRegions->getFirstBX();
160  int bxLast = caloRegions->getLastBX();
161 
162  //outputs
163  std::unique_ptr<EGammaBxCollection> egammas (new EGammaBxCollection);
164  std::unique_ptr<TauBxCollection> taus (new TauBxCollection);
165  std::unique_ptr<TauBxCollection> isoTaus (new TauBxCollection);
166  std::unique_ptr<JetBxCollection> jets (new JetBxCollection);
167  std::unique_ptr<JetBxCollection> preGtJets (new JetBxCollection);
168  std::unique_ptr<EtSumBxCollection> etsums (new EtSumBxCollection);
169  std::unique_ptr<CaloSpareBxCollection> hfSums (new CaloSpareBxCollection);
170  std::unique_ptr<CaloSpareBxCollection> hfCounts (new CaloSpareBxCollection);
171 
172  egammas->setBXRange(bxFirst, bxLast);
173  taus->setBXRange(bxFirst, bxLast);
174  isoTaus->setBXRange(bxFirst, bxLast);
175  jets->setBXRange(bxFirst, bxLast);
176  preGtJets->setBXRange(bxFirst, bxLast);
177  etsums->setBXRange(bxFirst, bxLast);
178  hfSums->setBXRange(bxFirst, bxLast);
179  hfCounts->setBXRange(bxFirst, bxLast);
180 
181  //producer is responsible for splitting the BXVector into pieces for
182  //the firmware to handle
183  for(int i = bxFirst; i <= bxLast; ++i)
184  {
185  //make local inputs
186  std::vector<CaloRegion> *localRegions = new std::vector<CaloRegion>();
187  std::vector<CaloEmCand> *localEmCands = new std::vector<CaloEmCand>();
188 
189  //make local outputs
190  std::vector<EGamma> *localEGammas = new std::vector<EGamma>();
191  std::vector<Tau> *localTaus = new std::vector<Tau>();
192  std::vector<Tau> *localIsoTaus = new std::vector<Tau>();
193  std::vector<Jet> *localJets = new std::vector<Jet>();
194  std::vector<Jet> *localPreGtJets = new std::vector<Jet>();
195  std::vector<EtSum> *localEtSums = new std::vector<EtSum>();
196  CaloSpare *localHfSums = new CaloSpare();
197  localHfSums->setType(CaloSpare::HFRingSum);
198  CaloSpare *localHfCounts = new CaloSpare();
199  localHfCounts->setType(CaloSpare::HFBitCount);
200 
201  // copy over the inputs -> there must be a better way to do this
202  for(std::vector<CaloRegion>::const_iterator region = caloRegions->begin(i);
203  region != caloRegions->end(i); ++region)
204  localRegions->push_back(*region);
205  for(std::vector<CaloEmCand>::const_iterator emcand = caloEmCands->begin(i);
206  emcand != caloEmCands->end(i); ++emcand)
207  localEmCands->push_back(*emcand);
208 
209  //run the firmware on one event
210  m_fw->processEvent(*localEmCands, *localRegions,
211  localEGammas, localTaus, localIsoTaus, localJets, localPreGtJets, localEtSums,
212  localHfSums, localHfCounts);
213 
214  // copy the output into the BXVector -> there must be a better way
215  for(std::vector<EGamma>::const_iterator eg = localEGammas->begin(); eg != localEGammas->end(); ++eg)
216  egammas->push_back(i, *eg);
217  for(std::vector<Tau>::const_iterator tau = localTaus->begin(); tau != localTaus->end(); ++tau)
218  taus->push_back(i, *tau);
219  for(std::vector<Tau>::const_iterator isotau = localIsoTaus->begin(); isotau != localIsoTaus->end(); ++isotau)
220  isoTaus->push_back(i, *isotau);
221  for(std::vector<Jet>::const_iterator jet = localJets->begin(); jet != localJets->end(); ++jet)
222  jets->push_back(i, *jet);
223  for(std::vector<Jet>::const_iterator jet = localPreGtJets->begin(); jet != localPreGtJets->end(); ++jet)
224  preGtJets->push_back(i, *jet);
225  for(std::vector<EtSum>::const_iterator etsum = localEtSums->begin(); etsum != localEtSums->end(); ++etsum)
226  etsums->push_back(i, *etsum);
227  hfSums->push_back(i, *localHfSums);
228  hfCounts->push_back(i, *localHfCounts);
229 
230  delete localRegions;
231  delete localEmCands;
232  delete localEGammas;
233  delete localTaus;
234  delete localIsoTaus;
235  delete localJets;
236  delete localPreGtJets;
237  delete localEtSums;
238  delete localHfSums;
239  delete localHfCounts;
240  }
241 
242 
243  iEvent.put(std::move(egammas));
244  iEvent.put(std::move(taus),"rlxTaus");
245  iEvent.put(std::move(isoTaus),"isoTaus");
246  iEvent.put(std::move(jets));
247  iEvent.put(std::move(preGtJets),"preGtJets");
248  iEvent.put(std::move(etsums));
249  iEvent.put(std::move(hfSums),"HFRingSums");
250  iEvent.put(std::move(hfCounts),"HFBitCounts");
251 }
#define LogDebug(id)
void setType(CaloSpareType type)
Definition: CaloSpare.cc:32
int iEvent
Definition: GenABIO.cc:224
vector< PseudoJet > jets
std::shared_ptr< Stage1Layer2MainProcessor > m_fw
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

EDGetToken L1TStage1Layer2Producer::candsToken
private

Definition at line 99 of file L1TStage1Layer2Producer.cc.

std::string L1TStage1Layer2Producer::m_conditionsLabel
private

Definition at line 95 of file L1TStage1Layer2Producer.cc.

CaloConfigHelper L1TStage1Layer2Producer::m_config
private

Definition at line 88 of file L1TStage1Layer2Producer.cc.

unsigned long long L1TStage1Layer2Producer::m_configCacheId
private

Definition at line 86 of file L1TStage1Layer2Producer.cc.

Stage1Layer2FirmwareFactory L1TStage1Layer2Producer::m_factory
private

Definition at line 93 of file L1TStage1Layer2Producer.cc.

std::shared_ptr<Stage1Layer2MainProcessor> L1TStage1Layer2Producer::m_fw
private

Definition at line 91 of file L1TStage1Layer2Producer.cc.

CaloParamsHelper* L1TStage1Layer2Producer::m_params
private

Definition at line 87 of file L1TStage1Layer2Producer.cc.

unsigned long long L1TStage1Layer2Producer::m_paramsCacheId
private

Definition at line 85 of file L1TStage1Layer2Producer.cc.

EDGetToken L1TStage1Layer2Producer::regionToken
private

Definition at line 98 of file L1TStage1Layer2Producer.cc.