CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ConvertObjectMapRecord Class Reference

#include <ConvertObjectMapRecord.h>

Inheritance diagram for ConvertObjectMapRecord:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ConvertObjectMapRecord (const edm::ParameterSet &pset)
 
virtual void produce (edm::Event &event, const edm::EventSetup &es)
 
 ~ConvertObjectMapRecord ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::EDGetTokenT
< L1GlobalTriggerObjectMapRecord
m_l1GtObjectMapToken
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 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

Description: Reads in the L1GlobalTriggerObjectMapRecord and copies the information it contains into a L1GlobalTriggerObjectMaps object and also puts the names it contains into the ParameterSet registry.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna
: W. David Dagenhart

Description: see header file.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna
: W. David Dagenhart

Definition at line 29 of file ConvertObjectMapRecord.h.

Constructor & Destructor Documentation

ConvertObjectMapRecord::ConvertObjectMapRecord ( const edm::ParameterSet pset)
explicit

Definition at line 33 of file ConvertObjectMapRecord.cc.

33  :
34  m_l1GtObjectMapToken(consumes<L1GlobalTriggerObjectMapRecord>(pset.getParameter<edm::InputTag>("L1GtObjectMapTag"))) {
35 
36  produces<L1GlobalTriggerObjectMaps>();
37 }
T getParameter(std::string const &) const
edm::EDGetTokenT< L1GlobalTriggerObjectMapRecord > m_l1GtObjectMapToken
ConvertObjectMapRecord::~ConvertObjectMapRecord ( )

Definition at line 39 of file ConvertObjectMapRecord.cc.

39  {
40 }

Member Function Documentation

void ConvertObjectMapRecord::produce ( edm::Event event,
const edm::EventSetup es 
)
virtual

Implements edm::stream::EDProducerBase.

Definition at line 43 of file ConvertObjectMapRecord.cc.

References cms::Exception::addContext(), edm::ParameterSet::addParameter(), L1GlobalTriggerObjectMap::algoBitNumber(), L1GlobalTriggerObjectMap::algoGtlResult(), L1GlobalTriggerObjectMap::algoName(), first, L1GlobalTriggerObjectMap::getCombinationsInCond(), i, edm::ParameterSet::id(), edm::HandleBase::isValid(), m_l1GtObjectMapToken, max(), L1GlobalTriggerObjectMap::operandTokenVector(), edm::ParameterSet::registerIt(), edm::sort_all(), and AlCaHLTBitMon_QueryRunRegistry::string.

43  {
44 
45  // Read in the existing object from the data
47  event.getByToken(m_l1GtObjectMapToken, gtObjectMapRecord);
48 
49  if (!gtObjectMapRecord.isValid()) {
50  return;
51  }
52 
53  // Create the new object we are going to copy the information to
54  std::auto_ptr<L1GlobalTriggerObjectMaps> gtObjectMaps(new L1GlobalTriggerObjectMaps);
55 
56  // get the algorithm bit numbers and sort them
57  std::vector<int> algoBitNumbers;
58  std::vector<L1GlobalTriggerObjectMap> const& vectorInRecord = gtObjectMapRecord->gtObjectMap();
59  algoBitNumbers.reserve(vectorInRecord.size());
60  for (std::vector<L1GlobalTriggerObjectMap>::const_iterator i = vectorInRecord.begin(),
61  iEnd = vectorInRecord.end();
62  i != iEnd; ++i) {
63  algoBitNumbers.push_back(i->algoBitNumber());
64  }
65  edm::sort_all(algoBitNumbers);
66 
67  gtObjectMaps->reserveForAlgorithms(algoBitNumbers.size());
68 
69  if (!algoBitNumbers.empty() && algoBitNumbers[0] < 0) {
70  cms::Exception ex("L1GlobalTrigger");
71  ex << "Negative algorithm bit number";
72  ex.addContext("Calling ConvertObjectMapRecord::produce");
73  throw ex;
74  }
75 
76  unsigned sizeOfNamesVector = 0;
77  if (!algoBitNumbers.empty()) {
78  sizeOfNamesVector = static_cast<unsigned>(algoBitNumbers.back()) + 1;
79  }
80  std::vector<std::string> savedNames(sizeOfNamesVector);
81 
82  // Loop over the object map record and copy the algorithm information
83  // Just count the condition and index information so we can reserve
84  // memory for them before filling them.
85  unsigned startIndexOfConditions = 0;
86  unsigned nIndexes = 0;
87 
88  for (std::vector<int>::const_iterator iBit = algoBitNumbers.begin(), endBits = algoBitNumbers.end();
89  iBit != endBits; ++iBit) {
90  L1GlobalTriggerObjectMap const* objMap = gtObjectMapRecord->getObjectMap(*iBit);
91 
92  gtObjectMaps->pushBackAlgorithm(startIndexOfConditions,
93  objMap->algoBitNumber(),
94  objMap->algoGtlResult());
95 
96  savedNames.at(static_cast<unsigned>(*iBit)) = objMap->algoName();
97 
98  std::vector<L1GtLogicParser::OperandToken> const& operandTokens =
99  objMap->operandTokenVector();
100 
101  startIndexOfConditions += operandTokens.size();
102 
103  int tokenCounter = 0;
104  for (std::vector<L1GtLogicParser::OperandToken>::const_iterator iToken = operandTokens.begin(),
105  endTokens = operandTokens.end();
106  iToken != endTokens;
107  ++iToken, ++tokenCounter) {
108 
109  if (tokenCounter != iToken->tokenNumber) {
110  cms::Exception ex("L1GlobalTrigger");
111  ex << "Token numbers not sequential";
112  ex.addContext("Calling ConvertObjectMapRecord::produce");
113  throw ex;
114  }
115 
116  CombinationsInCond const* combos = objMap->getCombinationsInCond(iToken->tokenNumber);
117  for (CombinationsInCond::const_iterator iCombo = combos->begin(),
118  endCombos = combos->end();
119  iCombo != endCombos; ++iCombo) {
120  for (std::vector<int>::const_iterator iIndex = iCombo->begin(),
121  endIndexes = iCombo->end();
122  iIndex != endIndexes; ++iIndex) {
123  ++nIndexes;
124  }
125  }
126  }
127  }
128  gtObjectMaps->reserveForConditions(startIndexOfConditions);
129  gtObjectMaps->reserveForObjectIndexes(nIndexes);
130 
131  edm::ParameterSet namesPset;
132  namesPset.addParameter<std::vector<std::string> >(std::string("@algorithmNames"), savedNames);
133 
134  // Now loop a second time and fill the condition and index
135  // information.
136  unsigned startIndexOfCombinations = 0;
137  for (std::vector<int>::const_iterator iBit = algoBitNumbers.begin(), endBits = algoBitNumbers.end();
138  iBit != endBits; ++iBit) {
139  L1GlobalTriggerObjectMap const* objMap = gtObjectMapRecord->getObjectMap(*iBit);
140 
141  std::vector<L1GtLogicParser::OperandToken> const& operandTokens =
142  objMap->operandTokenVector();
143 
144  savedNames.clear();
145  if (savedNames.capacity() < operandTokens.size()) {
146  savedNames.reserve(operandTokens.size());
147  }
148 
149  for (std::vector<L1GtLogicParser::OperandToken>::const_iterator iToken = operandTokens.begin(),
150  endTokens = operandTokens.end();
151  iToken != endTokens; ++iToken) {
152 
153  savedNames.push_back(iToken->tokenName);
154 
155  unsigned short nObjectsPerCombination = 0;
156  bool first = true;
157  unsigned nIndexesInCombination = 0;
158 
159  CombinationsInCond const* combos = objMap->getCombinationsInCond(iToken->tokenNumber);
160  for (CombinationsInCond::const_iterator iCombo = combos->begin(),
161  endCombos = combos->end();
162  iCombo != endCombos; ++iCombo) {
163  if (first) {
164  if (iCombo->size() > std::numeric_limits<unsigned short>::max()) {
165  cms::Exception ex("L1GlobalTrigger");
166  ex << "Number of objects per combination out of range";
167  ex.addContext("Calling ConvertObjectMapRecord::produce");
168  throw ex;
169  }
170  nObjectsPerCombination = iCombo->size();
171  first = false;
172  } else {
173  if (nObjectsPerCombination != iCombo->size()) {
174  cms::Exception ex("L1GlobalTrigger");
175  ex << "inconsistent number of objects per condition";
176  ex.addContext("Calling ConvertObjectMapRecord::produce");
177  throw ex;
178  }
179  }
180 
181  for (std::vector<int>::const_iterator iIndex = iCombo->begin(),
182  endIndexes = iCombo->end();
183  iIndex != endIndexes; ++iIndex) {
184 
185  if (*iIndex < 0 || *iIndex > std::numeric_limits<unsigned char>::max()) {
186  cms::Exception ex("L1GlobalTrigger");
187  ex << "object index too large, out of range";
188  ex.addContext("Calling ConvertObjectMapRecord::produce");
189  throw ex;
190  }
191  gtObjectMaps->pushBackObjectIndex(*iIndex);
192  ++nIndexesInCombination;
193  }
194  }
195  gtObjectMaps->pushBackCondition(startIndexOfCombinations,
196  nObjectsPerCombination,
197  iToken->tokenResult);
198  startIndexOfCombinations += nIndexesInCombination;
199  }
200  namesPset.addParameter<std::vector<std::string> >(objMap->algoName(), savedNames);
201  }
202  namesPset.registerIt();
203  gtObjectMaps->setNamesParameterSetID(namesPset.id());
204 
205  gtObjectMaps->consistencyCheck();
206  event.put(gtObjectMaps);
207 }
int i
Definition: DBlmapReader.cc:9
ParameterSetID id() const
const std::vector< L1GtLogicParser::OperandToken > & operandTokenVector() const
const std::string & algoName() const
get / set name for algorithm in the object map
const T & max(const T &a, const T &b)
const CombinationsInCond * getCombinationsInCond(const std::string &condNameVal) const
return all the combinations passing the requirements imposed in condition condNameVal ...
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:142
edm::EDGetTokenT< L1GlobalTriggerObjectMapRecord > m_l1GtObjectMapToken
bool first
Definition: L1TdeRCT.cc:75
bool isValid() const
Definition: HandleBase.h:76
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
int algoBitNumber() const
get / set bit number for algorithm in the object map
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
ParameterSet const & registerIt()

Member Data Documentation

edm::EDGetTokenT<L1GlobalTriggerObjectMapRecord> ConvertObjectMapRecord::m_l1GtObjectMapToken
private

Definition at line 38 of file ConvertObjectMapRecord.h.

Referenced by produce().