CMS 3D CMS Logo

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

#include <InitMsgCollection.h>

Public Member Functions

bool addIfUnique (InitMsgView const &initMsgView)
 
bool addIfUnique (I2OChain const &, InitMsgSharedPtr &)
 
void clear ()
 
InitMsgSharedPtr getElementAt (const unsigned int index) const
 
InitMsgSharedPtr getElementForOutputModuleId (const uint32_t &) const
 
InitMsgSharedPtr getElementForOutputModuleLabel (const std::string &) const
 
std::string getOutputModuleName (const uint32_t outputModuleId) const
 
std::string getSelectionHelpString () const
 
 InitMsgCollection ()
 
size_t size () const
 
 ~InitMsgCollection ()
 

Static Public Member Functions

static std::string stringsToText (Strings const &list, unsigned int maxCount=0)
 

Private Types

typedef std::map< uint32_t,
InitMsgSharedPtr
InitMsgMap
 

Private Member Functions

void checkOutputModuleLabel (InitMsgView const &) const
 

Private Attributes

InitMsgMap initMsgMap_
 
boost::mutex listLock_
 

Detailed Description

Definition at line 35 of file InitMsgCollection.h.

Member Typedef Documentation

typedef std::map<uint32_t,InitMsgSharedPtr> stor::InitMsgCollection::InitMsgMap
private

Definition at line 174 of file InitMsgCollection.h.

Constructor & Destructor Documentation

InitMsgCollection::InitMsgCollection ( )

InitMsgCollection constructor.

Definition at line 21 of file InitMsgCollection.cc.

References hitfit::clear().

22 {
23  clear();
24 }
InitMsgCollection::~InitMsgCollection ( )

InitMsgCollection destructor.

Definition at line 27 of file InitMsgCollection.cc.

28 {
29 }

Member Function Documentation

bool InitMsgCollection::addIfUnique ( InitMsgView const &  initMsgView)

Adds the specified INIT message to the collection if it has a unique HLT output module label.

If we already have an INIT message with the same output module label as the input INIT message, the duplicate message is not added to the collection, and this method returns false.

If the output module label inside the INIT message is empty, an exception is thrown.

Parameters
initMsgViewThe INIT message to be added to the collection.
Returns
true if the message was added to the collection, false otherwise.
Exceptions
cms::Exceptionif one of the consistency checks fails.

Definition at line 32 of file InitMsgCollection.cc.

References filterCSVwithJSON::copy, InitMsgView::outputModuleId(), pos, InitMsgView::size(), and InitMsgView::startAddress().

33 {
34  boost::mutex::scoped_lock sl(listLock_);
35 
36  // check if the outputModuleId was already seen
37  const uint32_t outputModuleId = initMsgView.outputModuleId();
38  InitMsgMap::iterator pos = initMsgMap_.lower_bound(outputModuleId);
39  if ( pos != initMsgMap_.end() && !(initMsgMap_.key_comp()(outputModuleId, pos->first)))
40  return false; // init message already exists
41 
42  checkOutputModuleLabel(initMsgView);
43 
44  // add the message to the internal list
45  InitMsgSharedPtr serializedProds(new InitMsgBuffer(initMsgView.size()));
46  std::copy(
47  initMsgView.startAddress(),
48  initMsgView.startAddress()+initMsgView.size(),
49  &(*serializedProds)[0]
50  );
51  initMsgMap_.insert(pos, InitMsgMap::value_type(outputModuleId,serializedProds));
52 
53  return true; // new init message
54 }
std::vector< unsigned char > InitMsgBuffer
boost::shared_ptr< InitMsgBuffer > InitMsgSharedPtr
void checkOutputModuleLabel(InitMsgView const &) const
Container::value_type value_type
bool InitMsgCollection::addIfUnique ( I2OChain const &  i2oChain,
InitMsgSharedPtr serializedProds 
)

Adds the INIT message contained in the specified I2OChain to the collection if it has a unique HLT output module label.

If we already have an INIT message with the same output module label as the input INIT message, the duplicate message is not added to the collection, and this method returns false.

If the INIT message is new, the InitMsgView will contain the view of INIT message and the method returns true.

If the output module label inside the INIT message is empty, an exception is thrown.

Parameters
i2oChainthe I2OChain containing an INIT message
initMsgViewthe INIT view which was added to the collection.
Returns
true if the message was added to the collection, false otherwise.
Exceptions
cms::Exceptionif one of the consistency checks fails.

Definition at line 57 of file InitMsgCollection.cc.

References stor::I2OChain::copyFragmentsIntoBuffer(), stor::I2OChain::outputModuleId(), pos, and stor::I2OChain::totalDataSize().

58 {
59  boost::mutex::scoped_lock sl(listLock_);
60 
61  // check if the outputModuleId was already seen
62  const uint32_t outputModuleId = i2oChain.outputModuleId();
63  InitMsgMap::iterator pos = initMsgMap_.lower_bound(outputModuleId);
64  if ( pos != initMsgMap_.end() && !(initMsgMap_.key_comp()(outputModuleId, pos->first)))
65  return false; // init message already exists
66 
67  // build the init message view
68  serializedProds.reset( new InitMsgBuffer(i2oChain.totalDataSize()) );
69  i2oChain.copyFragmentsIntoBuffer( *serializedProds );
70  InitMsgView initMsgView(&(*serializedProds)[0]);
71 
72  checkOutputModuleLabel(initMsgView);
73 
74  // add the message to the internal list
75  initMsgMap_.insert(pos, InitMsgMap::value_type(outputModuleId,serializedProds));
76 
77  return true; // new init message
78 }
std::vector< unsigned char > InitMsgBuffer
void checkOutputModuleLabel(InitMsgView const &) const
Container::value_type value_type
void InitMsgCollection::checkOutputModuleLabel ( InitMsgView const &  initMsgView) const
private

Definition at line 81 of file InitMsgCollection.cc.

References edm::hlt::Exception, InitMsgView::outputModuleLabel(), and AlCaHLTBitMon_QueryRunRegistry::string.

82 {
83  const std::string inputOMLabel = initMsgView.outputModuleLabel();
84  const std::string trimmedOMLabel = boost::algorithm::trim_copy(inputOMLabel);
85  if (trimmedOMLabel.empty()) {
86  throw cms::Exception("InitMsgCollection", "addIfUnique:")
87  << "Invalid INIT message: the HLT output module label is empty!"
88  << std::endl;
89  }
90 }
void InitMsgCollection::clear ( void  )
InitMsgSharedPtr InitMsgCollection::getElementAt ( const unsigned int  index) const

Returns a shared pointer to the requested element in the collection or an empty pointer if the requested index if out of bounds.

Parameters
indexThe index of the requested element.
Returns
the InitMsgSharedPtr at the requested index in the collection.

Definition at line 153 of file InitMsgCollection.cc.

References alignCSCRings::e.

154 {
155  boost::mutex::scoped_lock sl(listLock_);
156 
157  InitMsgSharedPtr ptrToElement;
158  try
159  {
160  ptrToElement = initMsgMap_.at(index);
161  }
162  catch (std::out_of_range& e)
163  { }
164 
165  return ptrToElement;
166 }
boost::shared_ptr< InitMsgBuffer > InitMsgSharedPtr
InitMsgSharedPtr InitMsgCollection::getElementForOutputModuleId ( const uint32_t &  requestedOutputModuleId) const

Fetches the single INIT message that matches the requested HLT output module id. If no messages match the request, an empty pointer is returned.

Parameters
requestedOutputModuleIdThe HLT output module id of the INIT message to be returned.
Returns
a pointer to the INIT message that matches. If no matching INIT message is found, and empty pointer is returned.

Definition at line 94 of file InitMsgCollection.cc.

95 {
96  boost::mutex::scoped_lock sl(listLock_);
97  InitMsgSharedPtr serializedProds;
98 
99  InitMsgMap::const_iterator it = initMsgMap_.find(requestedOutputModuleId);
100  if (it != initMsgMap_.end())
101  serializedProds = it->second;
102 
103  return serializedProds;
104 }
boost::shared_ptr< InitMsgBuffer > InitMsgSharedPtr
InitMsgSharedPtr InitMsgCollection::getElementForOutputModuleLabel ( const std::string &  requestedOutputModuleLabel) const

Fetches the single INIT message that matches the requested HLT output module label. If no messages match the request, an empty pointer is returned.

If the requested HLT output module label is empty, and there is only one INIT message in the collection, that INIT message is returned. However, if there is more than one INIT message in the collection, and an empty request is passed into this method, an exception will be thrown. (How can we decide which is the best match when we have nothing to work with?)

Parameters
requestedOutputModuleLabelThe HLT output module label of the INIT message to be returned.
Returns
a pointer to the INIT message that matches. If no matching INIT message is found, and empty pointer is returned.
Exceptions
cms::Exceptionif the input HLT output module label string is empty and there is more than one INIT message in the collection.

Definition at line 108 of file InitMsgCollection.cc.

References edm::hlt::Exception, lumiQueryAPI::msg, InitMsgView::outputModuleLabel(), and AlCaHLTBitMon_QueryRunRegistry::string.

109 {
110  boost::mutex::scoped_lock sl(listLock_);
111  InitMsgSharedPtr serializedProds;
112 
113  // handle the special case of an empty request
114  // (If we want to use class methods to check the collection size and
115  // fetch the last element in the collection, then we would need to
116  // switch to recursive mutexes...)
117  if (requestedOutputModuleLabel.empty()) {
118  if (initMsgMap_.size() == 1) {
119  serializedProds = initMsgMap_.begin()->second;
120  }
121  else if (initMsgMap_.size() > 1) {
122  std::string msg = "Invalid INIT message lookup: the requested ";
123  msg.append("HLT output module label is empty but there are multiple ");
124  msg.append("HLT output modules to choose from.");
125  throw cms::Exception("InitMsgCollection", "getElementForOutputModule:")
126  << msg << std::endl;
127  }
128  }
129 
130  else {
131  // loop over the existing messages
132  for (InitMsgMap::const_iterator msgIter = initMsgMap_.begin(),
133  msgIterEnd = initMsgMap_.end();
134  msgIter != msgIterEnd;
135  msgIter++)
136  {
137  InitMsgSharedPtr workingMessage = msgIter->second;
138  InitMsgView existingInitMsg(&(*workingMessage)[0]);
139  std::string existingOMLabel = existingInitMsg.outputModuleLabel();
140 
141  // check if the output module labels match
142  if (requestedOutputModuleLabel == existingOMLabel) {
143  serializedProds = workingMessage;
144  break;
145  }
146  }
147  }
148 
149  return serializedProds;
150 }
boost::shared_ptr< InitMsgBuffer > InitMsgSharedPtr
std::string InitMsgCollection::getOutputModuleName ( const uint32_t  outputModuleId) const

Returns the name of the output module with the specified module ID, or an empty string of the specified module ID is not known.

Returns
the output module label or an empty string

Definition at line 233 of file InitMsgCollection.cc.

References InitMsgView::outputModuleLabel().

234 {
235  boost::mutex::scoped_lock sl(listLock_);
236 
237  InitMsgMap::const_iterator it = initMsgMap_.find(outputModuleId);
238 
239  if (it == initMsgMap_.end())
240  {
241  return "";
242  }
243  else {
244  InitMsgSharedPtr serializedProds = it->second;
245  const InitMsgView initMsgView(&(*serializedProds)[0]);
246  return initMsgView.outputModuleLabel();
247  }
248 }
boost::shared_ptr< InitMsgBuffer > InitMsgSharedPtr
std::string InitMsgCollection::getSelectionHelpString ( ) const

Returns a string with information on which selections are available.

Returns
the help string.

Definition at line 183 of file InitMsgCollection.cc.

References InitMsgView::hltTriggerNames(), InitMsgView::hltTriggerSelections(), customizeTrackingMonitorSeedNumber::idx, InitMsgView::outputModuleLabel(), and AlCaHLTBitMon_QueryRunRegistry::string.

184 {
185  boost::mutex::scoped_lock sl(listLock_);
186 
187  // nothing much we can say if the collection is empty
188  if (initMsgMap_.empty()) {
189  return "No information is available about the available triggers.";
190  }
191 
192  // list the full set of available triggers
193  std::string helpString;
194  helpString.append("The full list of trigger paths is the following:");
195 
196  // we can just use the list from the first entry since all
197  // subsequent entries are forced to be the same
198  InitMsgSharedPtr serializedProds = initMsgMap_.begin()->second;
199  InitMsgView existingInitMsg(&(*serializedProds)[0]);
200  Strings existingTriggerList;
201  existingInitMsg.hltTriggerNames(existingTriggerList);
202  for (unsigned int idx = 0; idx < existingTriggerList.size(); idx++) {
203  helpString.append("\n " + existingTriggerList[idx]);
204  }
205 
206  // list the output modules (INIT messages)
207  helpString.append("\nThe registered HLT output modules and their ");
208  helpString.append("trigger selections are the following:");
209 
210  // loop over the existing messages
211  for (InitMsgMap::const_iterator msgIter = initMsgMap_.begin(),
212  msgIterEnd = initMsgMap_.end();
213  msgIter != msgIterEnd;
214  msgIter++)
215  {
216  serializedProds = msgIter->second;
217  InitMsgView workingInitMsg(&(*serializedProds)[0]);
218  helpString.append("\n *** Output module \"");
219  helpString.append(workingInitMsg.outputModuleLabel());
220  helpString.append("\" ***");
221  Strings workingSelectionList;
222  workingInitMsg.hltTriggerSelections(workingSelectionList);
223  for (unsigned int idx = 0; idx < workingSelectionList.size(); idx++) {
224  helpString.append("\n " + workingSelectionList[idx]);
225  }
226  }
227 
228  // return the result
229  return helpString;
230 }
std::vector< std::string > Strings
Definition: MsgTools.h:18
boost::shared_ptr< InitMsgBuffer > InitMsgSharedPtr
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
size_t InitMsgCollection::size ( void  ) const

Returns the number of unique INIT messages in the collection.

Returns
the integer number of messages.

Definition at line 176 of file InitMsgCollection.cc.

177 {
178  boost::mutex::scoped_lock sl(listLock_);
179  return initMsgMap_.size();
180 }
std::string InitMsgCollection::stringsToText ( Strings const &  list,
unsigned int  maxCount = 0 
)
static

Creates a single text string from the elements in the specified list of strings. The specified maximum number of elements are included, however a zero value for the maximum number will include all elements.

Parameters
listthe list of strings to include (std::vector of strings);
maxCountthe maximum number of list elements to include.
Returns
the text string with the formatted list elements.

Definition at line 251 of file InitMsgCollection.cc.

References customizeTrackingMonitorSeedNumber::idx, and AlCaHLTBitMon_QueryRunRegistry::string.

253 {
254  std::string resultString = "";
255  unsigned int elementCount = list.size();
256  if (maxCount > 0 && maxCount < elementCount) {elementCount = maxCount;}
257  for (unsigned int idx = 0; idx < elementCount; idx++)
258  {
259  resultString.append(list[idx]);
260  if (idx < (elementCount-1)) {
261  resultString.append(", ");
262  }
263  }
264  if (elementCount < list.size())
265  {
266  resultString.append(", ...");
267  }
268  return resultString;
269 }
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run

Member Data Documentation

InitMsgMap stor::InitMsgCollection::initMsgMap_
private

Definition at line 175 of file InitMsgCollection.h.

boost::mutex stor::InitMsgCollection::listLock_
mutableprivate

Definition at line 176 of file InitMsgCollection.h.