CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
DDI::Specific Class Reference

#include <Specific.h>

Public Member Functions

std::pair< bool, DDExpandedViewnode () const
 gives the geometrical history of a fully specified PartSelector More...
 
const std::vector< DDPartSelection > & selection () const
 
 Specific (const std::vector< std::string > &selections, const DDsvalues_type &specs, bool doRegex=true)
 
 Specific (const std::vector< DDPartSelection > &selections, const DDsvalues_type &specs)
 
const DDsvalues_typespecifics () const
 
void stream (std::ostream &) const
 
void tokenize ()
 
void updateLogicalPart (std::vector< std::pair< DDLogicalPart, std::pair< const DDPartSelection *, const DDsvalues_type * > > > &) const
 
 ~Specific ()
 

Protected Member Functions

void addSelectionLevel (std::vector< DDLogicalPart > &lpv, int copyno, ddselection_type st, std::vector< DDPartSelection > &selv)
 
void createPartSelections (const std::string &selString)
 

Protected Attributes

bool doRegex_
 
std::vector< DDPartSelectionpartSelections_
 
DDsvalues_type specifics_
 
bool valid_
 

Detailed Description

Definition at line 21 of file Specific.h.

Constructor & Destructor Documentation

DDI::Specific::Specific ( const std::vector< std::string > &  selections,
const DDsvalues_type specs,
bool  doRegex = true 
)

Definition at line 19 of file Specific.cc.

References createPartSelections().

22  : specifics_(specs),
23  partSelections_(0),
24  valid_(false),
25  doRegex_(doRegex)
26  {
27  for( const auto& it : selections ) {
29  }
30  }
std::vector< DDPartSelection > partSelections_
Definition: Specific.h:50
bool valid_
Definition: Specific.h:51
DDsvalues_type specifics_
Definition: Specific.h:49
bool doRegex_
Definition: Specific.h:52
void createPartSelections(const std::string &selString)
Definition: Specific.cc:37
DDI::Specific::Specific ( const std::vector< DDPartSelection > &  selections,
const DDsvalues_type specs 
)

Definition at line 32 of file Specific.cc.

34  : specifics_(specs), partSelections_(selections), valid_(false), doRegex_(false)
35  { }
std::vector< DDPartSelection > partSelections_
Definition: Specific.h:50
bool valid_
Definition: Specific.h:51
DDsvalues_type specifics_
Definition: Specific.h:49
bool doRegex_
Definition: Specific.h:52
DDI::Specific::~Specific ( )
inline

Definition at line 31 of file Specific.h.

References selection(), tokenize(), and updateLogicalPart().

31 { }

Member Function Documentation

void DDI::Specific::addSelectionLevel ( std::vector< DDLogicalPart > &  lpv,
int  copyno,
ddselection_type  st,
std::vector< DDPartSelection > &  selv 
)
protected

Definition at line 65 of file Specific.cc.

References mps_fire::result.

Referenced by createPartSelections(), and specifics().

67  {
68  if (!selv.size()) { // create one, no entry yet!
69  selv.push_back(DDPartSelection());
70  }
71  typedef std::vector<DDLogicalPart>::size_type lpv_sizetype;
72  typedef std::vector<DDPartSelection>::size_type ps_sizetype;
73  ps_sizetype ps_sz = selv.size();
74  lpv_sizetype lpv_sz = lpv.size();
75  lpv_sizetype lpv_i = 0;
76  std::vector<DDPartSelection> result;
77  for (; lpv_i < lpv_sz; ++lpv_i) {
78  std::vector<DDPartSelection>::const_iterator ps_it = selv.begin();
79  for (; ps_it != selv.end(); ++ps_it) {
80  result.push_back(*ps_it);
81  }
82  }
83  ps_sizetype ps_i = 0;
84  for(lpv_i=0; lpv_i < lpv_sz; ++lpv_i) {
85  for(ps_i = ps_sz*lpv_i; ps_i < ps_sz*(lpv_i+1); ++ps_i) {
86  result[ps_i].push_back(DDPartSelectionLevel(lpv[lpv_i],copyno,st));
87  }
88  }
89  selv = result;
90  }
uint16_t size_type
void DDI::Specific::createPartSelections ( const std::string &  selString)
protected

Definition at line 37 of file Specific.cc.

References addSelectionLevel(), DDIsValid(), DDTokenize2(), doRegex_, mps_alisetup::msg, partSelections_, AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by Specific(), and specifics().

38  {
39  std::vector<DDPartSelRegExpLevel> regv;
40  std::vector<DDPartSelection> temp;
41  DDTokenize2(selString,regv);
42 
43  if (!regv.size()) throw cms::Exception("DDException") << "Could not evaluate the selection-std::string ->" << selString << "<-";
44  std::pair<bool,std::string> res;
45  for( const auto& it : regv ) {
46  std::vector<DDLogicalPart> lpv;
47  res = DDIsValid( it.ns_, it.nm_, lpv, doRegex_ );
48  if (!res.first) {
49  std::string msg("Could not process q-name of a DDLogicalPart, reason:\n"+res.second);
50  msg+="\nSpecPar selection is:\n" + selString + "\n";
51  //throw cms::Exception("DDException") << "Could not process q-name of a DDLogicalPart, reason:\n" << res.second;
52  edm::LogError("Specific") << msg;
53  break; //EXIT for loop
54  }
55  addSelectionLevel( lpv, it.copyno_, it.selectionType_, temp );
56  }
57  if ( res.first ) { // i.e. it wasn't "thrown" out of the loop
58  partSelections_.reserve(temp.size() + partSelections_.size());
59  for( const auto& iit : temp ) {
60  partSelections_.push_back( iit );
61  }
62  }
63  }
void addSelectionLevel(std::vector< DDLogicalPart > &lpv, int copyno, ddselection_type st, std::vector< DDPartSelection > &selv)
Definition: Specific.cc:65
std::vector< DDPartSelection > partSelections_
Definition: Specific.h:50
Definition: Electron.h:4
bool doRegex_
Definition: Specific.h:52
std::pair< bool, std::string > DDIsValid(const std::string &ns, const std::string &name, std::vector< DDLogicalPart > &result, bool doRegex=true)
void DDTokenize2(const std::string &selectionString, std::vector< DDPartSelRegExpLevel > &result)
std::pair< bool, DDExpandedView > DDI::Specific::node ( ) const

gives the geometrical history of a fully specified PartSelector

node() will only work, if

  • there is only one PartSelection std::string
  • the PartSelection std::string specifies exactly one full path concatenating always direct children including their copy-number and will return (true,const DDGeoHistory&) if the std::string matches an expanded-part in the ExpandedView, else it will return (false, xxx), whereas xxx is a history which is not valid.

Definition at line 145 of file Specific.cc.

References EnergyCorrector::c, DDExpandedView::copyno(), ddanyposp, ddchildposp, MillePedeFileConverter_cfg::e, DDExpandedView::firstChild(), DDExpandedView::logicalPart(), DDExpandedView::nextSibling(), partSelections_, and mps_fire::result.

Referenced by specifics().

146  {
148  DDExpandedView e(c);
149 
150  if (partSelections_.size() != 1) {
151  edm::LogError("Specific") << " >> more or less than one part-selector, currently NOT SUPPORTED! <<" << std::endl;
152  return std::make_pair(false,e);
153  }
154  const DDPartSelection & ps = partSelections_[0];
155 
156  DDPartSelection::const_iterator it = ps.begin();
157  DDPartSelection::const_iterator ed = ps.end();
158  if ( (it != ed) && ( it->selectionType_ != ddanyposp) ) {
159  edm::LogError("Specific") << " >> part-selector must start with //Name[no] ! << " << std::endl;
160  return std::make_pair(false,e);
161  }
162  ++it;
163  for (; it != ps.end(); ++it) {
164  if ( it->selectionType_ != ddchildposp ) {
165  edm::LogError("Specific") << " >> part-selector must be a concatenation of direct children\n"
166  << " including their copy-number only, CURRENT LIMITATION! <<" << std::endl;
167  return std::make_pair(false,e);
168  }
169  }
170 
171  it = ps.begin();
172  bool result = true;
173  for (; it != ed; ++it) {
174  while(result) {
175  if( (it->copyno_ == e.copyno()) && (it->lp_ == e.logicalPart())) {
176  break;
177  }
178  else {
179  result = e.nextSibling();
180  }
181  }
182  if ((ed-it)>1) {
183  result = e.firstChild();
184  }
185  }
186  return std::make_pair(result,e);
187  }
std::vector< DDPartSelection > partSelections_
Definition: Specific.h:50
type of data representation of DDCompactView
Definition: DDCompactView.h:90
Provides an exploded view of the detector (tree-view)
const std::vector< DDPartSelection > & DDI::Specific::selection ( ) const
const DDsvalues_type& DDI::Specific::specifics ( void  ) const
inline

Definition at line 39 of file Specific.h.

References addSelectionLevel(), createPartSelections(), node(), specifics_, stream(), and AlCaHLTBitMon_QueryRunRegistry::string.

39 { return specifics_; }
DDsvalues_type specifics_
Definition: Specific.h:49
void DDI::Specific::stream ( std::ostream &  os) const

Definition at line 97 of file Specific.cc.

References mps_fire::i, DDValue::isEvaluated(), DDValue::name(), partSelections_, alignCSCRings::s, DDValue::size(), specifics_, DDValue::strings(), and findQualityFiles::v.

Referenced by specifics().

98  {
99  os << " Size: " << specifics_.size() << std::endl;
100  os << "\tSelections:" << std::endl;
101  for( const auto& pit : partSelections_ ) {
102  os << pit << std::endl;
103  }
104  for( const auto& vit : specifics_ ) {
105  const DDValue & v = vit.second;
106  os << "\tParameter name= \"" << v.name() << "\" " << std::endl;
107  os << "\t\t Value pairs: " << std::endl;
108  size_t s=v.size();
109  size_t i=0;
110  if ( v.isEvaluated() ) {
111  for( ; i<s; ++i) {
112  os << "\t\t\t\"" << v[i].first << "\"" << ", " << v[i].second << std::endl;
113  }
114  } else { // v is not evaluated
115  for( const auto& i : v.strings()) {
116  os << "\t\t\t\"" << i << "\"" << ", not evaluated" << std::endl;
117  }
118  }
119  }
120  }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:54
std::vector< DDPartSelection > partSelections_
Definition: Specific.h:50
bool isEvaluated(void) const
true, if values are numerical evaluated; else false.
Definition: DDValue.cc:201
DDsvalues_type specifics_
Definition: Specific.h:49
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
Definition: DDValue.h:61
unsigned int size() const
the size of the stored value-pairs (std::string,double)
Definition: DDValue.h:68
void DDI::Specific::tokenize ( )

Referenced by ~Specific().

void DDI::Specific::updateLogicalPart ( std::vector< std::pair< DDLogicalPart, std::pair< const DDPartSelection *, const DDsvalues_type * > > > &  result) const

Definition at line 122 of file Specific.cc.

References partSelections_, mps_fire::result, and specifics_.

Referenced by ~Specific().

123  {
124  if (partSelections_.size()) {
125  const DDsvalues_type* sv = (&specifics_);
126  for( const auto& it : partSelections_ ) {
127  DDLogicalPart logp = it.back().lp_;
128  const DDPartSelection * ps = (&it);
129  assert(ps);
130  assert(sv);
131  std::pair<const DDPartSelection*,const DDsvalues_type*> pssv(ps,sv);
132  result.push_back(std::make_pair(logp,pssv));
133  }
134  }
135  }
std::vector< DDPartSelection > partSelections_
Definition: Specific.h:50
DDsvalues_type specifics_
Definition: Specific.h:49
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:20
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92

Member Data Documentation

bool DDI::Specific::doRegex_
protected

Definition at line 52 of file Specific.h.

Referenced by createPartSelections().

std::vector<DDPartSelection> DDI::Specific::partSelections_
protected

Definition at line 50 of file Specific.h.

Referenced by createPartSelections(), node(), selection(), stream(), and updateLogicalPart().

DDsvalues_type DDI::Specific::specifics_
protected

Definition at line 49 of file Specific.h.

Referenced by specifics(), stream(), and updateLogicalPart().

bool DDI::Specific::valid_
protected

Definition at line 51 of file Specific.h.