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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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: see header file.

Implementation: <TODO: enter implementation details>

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

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

Definition at line 29 of file ConvertObjectMapRecord.h.

Constructor & Destructor Documentation

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

Definition at line 34 of file ConvertObjectMapRecord.cc.

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

Definition at line 40 of file ConvertObjectMapRecord.cc.

40  {
41 }

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 44 of file ConvertObjectMapRecord.cc.

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

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