CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1TExtCondProducer Class Reference
Inheritance diagram for L1TExtCondProducer:
edm::stream::EDProducer<>

Public Member Functions

 L1TExtCondProducer (const ParameterSet &)
 
 ~L1TExtCondProducer () override
 
- 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 (ConfigurationDescriptions &descriptions)
 

Private Member Functions

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

Private Attributes

int bxFirst_
 
int bxLast_
 
edm::ESGetToken
< L1TUtmTriggerMenu,
L1TUtmTriggerMenuRcd
l1GtMenuToken_
 
std::map< std::string,
unsigned int > 
m_extBitMap
 
unsigned long long m_l1GtMenuCacheID
 
unsigned int m_triggerRulePrefireVetoBit
 
bool makeTriggerRulePrefireVetoBit_
 
bool setBptxAND_
 
bool setBptxMinus_
 
bool setBptxOR_
 
bool setBptxPlus_
 
edm::InputTag tcdsInputTag_
 
edm::EDGetTokenT< TCDSRecordtcdsRecordToken_
 

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

Definition at line 45 of file L1TExtCondProducer.cc.

Constructor & Destructor Documentation

L1TExtCondProducer::L1TExtCondProducer ( const ParameterSet iConfig)
explicit

Definition at line 84 of file L1TExtCondProducer.cc.

References m_l1GtMenuCacheID, m_triggerRulePrefireVetoBit, makeTriggerRulePrefireVetoBit_, GlobalExtBlk::maxExternalConditions, tcdsInputTag_, and tcdsRecordToken_.

85  : bxFirst_(iConfig.getParameter<int>("bxFirst")),
86  bxLast_(iConfig.getParameter<int>("bxLast")),
87  setBptxAND_(iConfig.getParameter<bool>("setBptxAND")),
88  setBptxPlus_(iConfig.getParameter<bool>("setBptxPlus")),
89  setBptxMinus_(iConfig.getParameter<bool>("setBptxMinus")),
90  setBptxOR_(iConfig.getParameter<bool>("setBptxOR")),
91  tcdsInputTag_(iConfig.getParameter<edm::InputTag>("tcdsRecordLabel")),
92  l1GtMenuToken_(esConsumes<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd>()) {
94 
96 
97  // Note that the tcdsRecord input tag should be used as InputTag("unpackTcds","tcdsRecord") only for data
98  if (!(tcdsInputTag_ == edm::InputTag(""))) {
99  tcdsRecordToken_ = consumes<TCDSRecord>(tcdsInputTag_);
101  }
102 
103  // Register what you produce
104  produces<GlobalExtBlkBxCollection>();
105 
106  // Initialize parameters
107  m_l1GtMenuCacheID = 0ULL;
108 }
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1GtMenuToken_
edm::EDGetTokenT< TCDSRecord > tcdsRecordToken_
static const unsigned int maxExternalConditions
Definition: GlobalExtBlk.h:43
unsigned int m_triggerRulePrefireVetoBit
edm::InputTag tcdsInputTag_
unsigned long long m_l1GtMenuCacheID
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
L1TExtCondProducer::~L1TExtCondProducer ( )
override

Definition at line 110 of file L1TExtCondProducer.cc.

110 {}

Member Function Documentation

void L1TExtCondProducer::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 240 of file L1TExtCondProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

240  {
241  // simGtExtFakeProd
243  desc.add<bool>("setBptxMinus", true);
244  desc.add<bool>("setBptxAND", true);
245  desc.add<int>("bxFirst", -2);
246  desc.add<bool>("setBptxOR", true);
247  desc.add<int>("bxLast", 2);
248  desc.add<bool>("setBptxPlus", true);
249  desc.add<edm::InputTag>("tcdsRecordLabel", edm::InputTag(""));
250  descriptions.add("simGtExtFakeProd", desc);
251 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void L1TExtCondProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 117 of file L1TExtCondProducer.cc.

References Exception, edm::EventSetup::get(), edm::Event::getByToken(), l1t::TriggerMenuParser::getExternalSignals(), edm::EventSetup::getHandle(), edm::EventBase::isRealData(), LogDebug, eostools::move(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), edm::Event::put(), and GlobalExtBlk::setExternalDecision().

117  {
118  LogDebug("L1TExtCondProducer") << "L1TExtCondProducer::produce function called...\n";
119 
120  // Get / update the trigger menu from the EventSetup
121  // local cache & check on cacheIdentifier
122  unsigned long long l1GtMenuCacheID = iSetup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();
123 
124  if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
126  const L1TUtmTriggerMenu* utml1GtMenu = l1GtMenu.product();
127 
128  // Instantiate Parser
130 
131  std::map<std::string, unsigned int> extBitMap = gtParser.getExternalSignals(utml1GtMenu);
132 
133  m_l1GtMenuCacheID = l1GtMenuCacheID;
134  m_extBitMap = extBitMap;
135  }
136 
137  bool TriggerRulePrefireVetoBit(false);
138  // The following list of checks on the tcdsRecord is relevant only for data;
139  // code taken from Nick Smith's EventFilter/L1TRawToDigi/plugins/TriggerRulePrefireVetoFilter.cc
140  if (iEvent.isRealData() && makeTriggerRulePrefireVetoBit_) {
141  edm::Handle<TCDSRecord> tcdsRecordH;
142  iEvent.getByToken(tcdsRecordToken_, tcdsRecordH);
143  const auto& tcdsRecord = *tcdsRecordH.product();
144 
145  uint64_t thisEvent = (tcdsRecord.getBXID() - 1) + tcdsRecord.getOrbitNr() * 3564ull;
146 
147  std::vector<uint64_t> eventHistory;
148  for (auto&& l1a : tcdsRecord.getFullL1aHistory()) {
149  eventHistory.push_back(thisEvent - ((l1a.getBXID() - 1) + l1a.getOrbitNr() * 3564ull));
150  }
151 
152  // It should be 16 according to TCDSRecord.h, we only care about the last 4
153  if (eventHistory.size() < 4) {
154  throw cms::Exception("L1TExtCondProducer")
155  << "Unexpectedly small L1A history from TCDSRecord: (size = " << eventHistory.size() << " < 4)";
156  }
157 
158  // No more than 1 L1A in 3 BX
159  if (eventHistory[0] < 3ull) {
160  edm::LogError("L1TExtCondProducer") << "Found an L1A in an impossible location?! (1 in 3)";
161  }
162 
163  if (eventHistory[0] == 3ull)
164  TriggerRulePrefireVetoBit = true;
165 
166  // No more than 2 L1As in 25 BX
167  if (eventHistory[0] < 25ull and eventHistory[1] < 25ull) {
168  edm::LogError("L1TExtCondProducer") << "Found an L1A in an impossible location?! (2 in 25)";
169  }
170  if (eventHistory[0] < 25ull and eventHistory[1] == 25ull)
171  TriggerRulePrefireVetoBit = true;
172 
173  // No more than 3 L1As in 100 BX
174  if (eventHistory[0] < 100ull and eventHistory[1] < 100ull and eventHistory[2] < 100ull) {
175  edm::LogError("L1TExtCondProducer") << "Found an L1A in an impossible location?! (3 in 100)";
176  }
177  if (eventHistory[0] < 100ull and eventHistory[1] < 100ull and eventHistory[2] == 100ull)
178  TriggerRulePrefireVetoBit = true;
179 
180  // No more than 4 L1As in 240 BX
181  if (eventHistory[0] < 240ull and eventHistory[1] < 240ull and eventHistory[2] < 240ull and
182  eventHistory[3] < 240ull) {
183  edm::LogError("L1TExtCondProducer") << "Found an L1A in an impossible location?! (4 in 240)";
184  }
185  if (eventHistory[0] < 240ull and eventHistory[1] < 240ull and eventHistory[2] < 240ull and
186  eventHistory[3] == 240ull)
187  TriggerRulePrefireVetoBit = true;
188  }
189 
190  // Setup vectors
191  GlobalExtBlk extCond_bx;
192 
193  // Outputs
194  std::unique_ptr<GlobalExtBlkBxCollection> extCond(new GlobalExtBlkBxCollection(0, bxFirst_, bxLast_));
195 
196  bool foundBptxAND = (m_extBitMap.find("BPTX_plus_AND_minus.v0") != m_extBitMap.end());
197  bool foundBptxPlus = (m_extBitMap.find("BPTX_plus.v0") != m_extBitMap.end());
198  bool foundBptxMinus = (m_extBitMap.find("BPTX_minus.v0") != m_extBitMap.end());
199  bool foundBptxOR = (m_extBitMap.find("BPTX_plus_OR_minus.v0") != m_extBitMap.end());
200 
201  // Fill in some external conditions for testing
202  if (setBptxAND_ && foundBptxAND)
203  extCond_bx.setExternalDecision(m_extBitMap["BPTX_plus_AND_minus.v0"], true);
204  if (setBptxPlus_ && foundBptxPlus)
205  extCond_bx.setExternalDecision(m_extBitMap["BPTX_plus.v0"], true);
206  if (setBptxMinus_ && foundBptxMinus)
207  extCond_bx.setExternalDecision(m_extBitMap["BPTX_minus.v0"], true);
208  if (setBptxOR_ && foundBptxOR)
209  extCond_bx.setExternalDecision(m_extBitMap["BPTX_plus_OR_minus.v0"], true);
210 
211  // Check for updated Bptx names as well
212  foundBptxAND = (m_extBitMap.find("ZeroBias_BPTX_AND_VME") != m_extBitMap.end());
213  foundBptxPlus = (m_extBitMap.find("BPTX_B1_VME") != m_extBitMap.end());
214  foundBptxMinus = (m_extBitMap.find("BPTX_B2_VME") != m_extBitMap.end());
215  foundBptxOR = (m_extBitMap.find("BPTX_OR_VME") != m_extBitMap.end());
216 
217  // Fill in some external conditions for testing
218  if (setBptxAND_ && foundBptxAND)
219  extCond_bx.setExternalDecision(m_extBitMap["ZeroBias_BPTX_AND_VME"], true);
220  if (setBptxPlus_ && foundBptxPlus)
221  extCond_bx.setExternalDecision(m_extBitMap["BPTX_B1_VME"], true);
222  if (setBptxMinus_ && foundBptxMinus)
223  extCond_bx.setExternalDecision(m_extBitMap["BPTX_B2_VME"], true);
224  if (setBptxOR_ && foundBptxOR)
225  extCond_bx.setExternalDecision(m_extBitMap["BPTX_OR_VME"], true);
226 
227  // Set the bit for the TriggerRulePrefireVeto if true
228  if (TriggerRulePrefireVetoBit)
230 
231  // Fill Externals
232  for (int iBx = bxFirst_; iBx <= bxLast_; iBx++) {
233  extCond->push_back(iBx, extCond_bx);
234  }
235 
236  iEvent.put(std::move(extCond));
237 }
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1GtMenuToken_
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
Definition: GlobalExtBlk.h:29
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< TCDSRecord > tcdsRecordToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::map< std::string, unsigned int > getExternalSignals(const L1TUtmTriggerMenu *utmMenu)
Log< level::Error, false > LogError
bool isRealData() const
Definition: EventBase.h:62
unsigned int m_triggerRulePrefireVetoBit
def move
Definition: eostools.py:511
void setExternalDecision(unsigned int bit, bool val)
Set decision bits.
Definition: GlobalExtBlk.cc:40
unsigned long long m_l1GtMenuCacheID
T const * product() const
Definition: Handle.h:70
unsigned long long uint64_t
Definition: Time.h:13
T const * product() const
Definition: ESHandle.h:86
T get() const
Definition: EventSetup.h:82
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
std::map< std::string, unsigned int > m_extBitMap
#define LogDebug(id)

Member Data Documentation

int L1TExtCondProducer::bxFirst_
private

Definition at line 62 of file L1TExtCondProducer.cc.

int L1TExtCondProducer::bxLast_
private

Definition at line 63 of file L1TExtCondProducer.cc.

edm::ESGetToken<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd> L1TExtCondProducer::l1GtMenuToken_
private

Definition at line 78 of file L1TExtCondProducer.cc.

std::map<std::string, unsigned int> L1TExtCondProducer::m_extBitMap
private

Definition at line 71 of file L1TExtCondProducer.cc.

unsigned long long L1TExtCondProducer::m_l1GtMenuCacheID
private

Definition at line 70 of file L1TExtCondProducer.cc.

Referenced by L1TExtCondProducer().

unsigned int L1TExtCondProducer::m_triggerRulePrefireVetoBit
private

Definition at line 73 of file L1TExtCondProducer.cc.

Referenced by L1TExtCondProducer().

bool L1TExtCondProducer::makeTriggerRulePrefireVetoBit_
private

Definition at line 75 of file L1TExtCondProducer.cc.

Referenced by L1TExtCondProducer().

bool L1TExtCondProducer::setBptxAND_
private

Definition at line 65 of file L1TExtCondProducer.cc.

bool L1TExtCondProducer::setBptxMinus_
private

Definition at line 67 of file L1TExtCondProducer.cc.

bool L1TExtCondProducer::setBptxOR_
private

Definition at line 68 of file L1TExtCondProducer.cc.

bool L1TExtCondProducer::setBptxPlus_
private

Definition at line 66 of file L1TExtCondProducer.cc.

edm::InputTag L1TExtCondProducer::tcdsInputTag_
private

Definition at line 77 of file L1TExtCondProducer.cc.

Referenced by L1TExtCondProducer().

edm::EDGetTokenT<TCDSRecord> L1TExtCondProducer::tcdsRecordToken_
private

Definition at line 76 of file L1TExtCondProducer.cc.

Referenced by L1TExtCondProducer().