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::EDProducer edm::ProducerBase 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::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

edm::InputTag m_l1GtObjectMapTag
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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
Date:
2012/03/02 22:03:25
Revision:
1.1

Description: see header file.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna
: W. David Dagenhart
Date:
2012/03/02 22:03:26
Revision:
1.1

Definition at line 29 of file ConvertObjectMapRecord.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file ConvertObjectMapRecord.cc.

36  :
37  m_l1GtObjectMapTag(pset.getParameter<edm::InputTag>("L1GtObjectMapTag")) {
38 
39  produces<L1GlobalTriggerObjectMaps>();
40 }
T getParameter(std::string const &) const
ConvertObjectMapRecord::~ConvertObjectMapRecord ( )

Definition at line 42 of file ConvertObjectMapRecord.cc.

42  {
43 }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 46 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_l1GtObjectMapTag, max(), L1GlobalTriggerObjectMap::operandTokenVector(), edm::ParameterSet::registerIt(), and edm::sort_all().

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

Definition at line 38 of file ConvertObjectMapRecord.h.

Referenced by produce().