ATLAS Offline Software
interpretSeeds.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <boost/lexical_cast.hpp>
6 #include <boost/tokenizer.hpp>
7 
8 #include "interpretSeeds.h"
9 
10 //get the luxury level, if specified. In that case moves token past it
11 inline
12 void getLuxury( boost::tokenizer<boost::char_separator<char> >::iterator& token, short& luxLevel) {
13  if ((*token) == "LUXURY") {
14  luxLevel = boost::lexical_cast<uint32_t>(*(++token));
15  ++token;
16  }
17 }
18 
19 //get the luxury level, if specified. In that case moves token past it
20 inline
21 void getOffset( boost::tokenizer<boost::char_separator<char> >::iterator& token, uint32_t& offset) {
22  if ((*token) == "OFFSET") {
23  offset = boost::lexical_cast<uint32_t>(*(++token));
24  ++token;
25  }
26 }
27 
28 bool interpretSeeds(const std::string& buffer,
29  std::string& stream, uint32_t& seed1, uint32_t& seed2, short& luxury, uint32_t& offset)
30 {
31  //split the space-separated string in 3 or 5 or 7 words:
32  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
33  boost::char_separator<char> sep(" ");
34  tokenizer tokens(buffer, sep);
35  int nToks(distance(tokens.begin(), tokens.end()));
36  bool status = (nToks == 3 || nToks == 5 || nToks == 7);
37  if (status) {
38  tokenizer::iterator token(tokens.begin());
39  stream = *token++;
40  //FIXME, try permutations by hand. With more than two we'd need a parser
41  getOffset(token, offset);
42  getLuxury(token, luxury);
43  getOffset(token, offset);
44 
45  try {
46 #if defined(__GNUC__) && !defined(__clang__)
47 #pragma GCC diagnostic push
48 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
49 #endif
50  seed1 = boost::lexical_cast<uint32_t>(*token++);
51  seed2 = boost::lexical_cast<uint32_t>(*token++);
52 #if defined(__GNUC__) && !defined(__clang__)
53 #pragma GCC diagnostic pop
54 #endif
55  } catch (const boost::bad_lexical_cast& e) {
56  status = false;
57  }
58  }
59  return status;
60 }
61 
62 bool interpretSeeds(const std::string& buffer,
63  std::string& stream, std::vector<uint32_t>& seeds)
64 {
65  //split the space-separated string in 31 or 33 words:
66  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
67  boost::char_separator<char> sep(" ");
68  tokenizer tokens(buffer, sep);
69  int nToks(distance(tokens.begin(), tokens.end()));
70  bool status = (nToks == 31 || nToks == 33 || nToks == 771);
71  if (status) {
72  tokenizer::iterator token(tokens.begin());
73  stream = *token++;
74  --nToks;
75  try {
76  if (nToks == 32) nToks=30; //ranlux (FIXME NEEDED?)
77  for (int i=0; i<nToks; i++) {
78 #if defined(__GNUC__) && !defined(__clang__)
79 #pragma GCC diagnostic push
80 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
81 #endif
82  seeds.push_back(boost::lexical_cast<uint32_t>(*token++));
83 #if defined(__GNUC__) && !defined(__clang__)
84 #pragma GCC diagnostic pop
85 #endif
86  }
87  } catch (const boost::bad_lexical_cast& e) {
88  status = false;
89  }
90  }
91  return status;
92 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
getLuxury
void getLuxury(boost::tokenizer< boost::char_separator< char > >::iterator &token, short &luxLevel)
Definition: interpretSeeds.cxx:12
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
genPbPbJobOpt.seed2
seed2
Definition: genPbPbJobOpt.py:57
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
lumiFormat.i
int i
Definition: lumiFormat.py:85
interpretSeeds
bool interpretSeeds(const std::string &buffer, std::string &stream, uint32_t &seed1, uint32_t &seed2, short &luxury, uint32_t &offset)
Definition: interpretSeeds.cxx:28
interpretSeeds.h
grepfile.sep
sep
Definition: grepfile.py:38
genPbPbJobOpt.seed1
seed1
Definition: genPbPbJobOpt.py:56
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
merge.status
status
Definition: merge.py:17
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
getOffset
void getOffset(boost::tokenizer< boost::char_separator< char > >::iterator &token, uint32_t &offset)
Definition: interpretSeeds.cxx:21