CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Namespaces | Typedefs | Functions
DDLogicalPart.h File Reference
#include <iosfwd>
#include <vector>
#include <string>
#include <map>
#include "DetectorDescription/Core/interface/DDName.h"
#include "DetectorDescription/Core/interface/DDBase.h"
#include "DetectorDescription/Core/interface/DDEnums.h"
#include "DetectorDescription/Base/interface/Singleton.h"
#include "DetectorDescription/Core/interface/DDsvalues.h"

Go to the source code of this file.

Classes

class  DDLogicalPart
 A DDLogicalPart aggregates information concerning material, solid and sensitveness ... More...
 

Namespaces

 DDI
 A DDDivision contains the parameterization that Geant4 needs in order to do its divisions.
 

Typedefs

typedef DDI::Singleton
< std::map< std::string,
std::vector< DDName > > > 
LPNAMES
 

Functions

void DD_NC (const DDName &)
 
std::pair< bool, std::string > DDIsValid (const std::string &ns, const std::string &name, std::vector< DDLogicalPart > &result, bool doRegex=true)
 
std::ostream & operator<< (std::ostream &, const DDLogicalPart &)
 

Typedef Documentation

typedef DDI::Singleton<std::map<std::string, std::vector<DDName> > > LPNAMES

Definition at line 135 of file DDLogicalPart.h.

Function Documentation

void DD_NC ( const DDName )

Definition at line 9 of file DDLogicalPart.cc.

References DDI::Singleton< I >::instance(), DDName::name(), DDName::ns(), and AlCaHLTBitMon_ParallelJobs::p.

Referenced by DDLogicalPart::DDLogicalPart().

10 {
11  std::vector<DDName> & ns = LPNAMES::instance()[n.name()];
12  typedef std::vector<DDName>::iterator IT;
13  bool alreadyIn( false );
14  for( IT p = ns.begin(); p != ns.end(); ++p )
15  {
16  if( p->ns() == n.ns())
17  {
18  alreadyIn = true;
19  break;
20  }
21  }
22  if( !alreadyIn )
23  {
24  ns.push_back( n );
25  }
26 }
static value_type & instance()
std::vector< LinkConnSpec >::const_iterator IT
std::pair<bool, std::string> DDIsValid ( const std::string &  ns,
const std::string &  name,
std::vector< DDLogicalPart > &  result,
bool  doRegex = true 
)

Definition at line 311 of file DDLogicalPart.cc.

References begin, end, i, DDI::Singleton< I >::instance(), python.rootplot.argparse::message, and ntuplemaker::status.

Referenced by DDI::Specific::createPartSelections().

312 {
313  if( !doRegex )
314  {
315  DDName ddnm( nm, ns );
316  result.push_back( DDLogicalPart( ddnm ));
317  return std::make_pair( true, "" );
318  }
319  std::string status;
320  Regex aRegex( nm );
321  Regex aNsRegex( ns );
322  bool emptyNs = aNsRegex.empty();
323 
324  // THIS IS THE SLOW PART: I have to compare every namespace & name of every
325  // logical part with a regex-comparison .... a linear search always through the
326  // full range of logical parts!!!!
327  /*
328  Algorithm description:
329  x. empty nm and ns argument of method means: use all matching regex ^.*$
330  a. iterate over all logical part names, match against regex for names
331  b. iterate over all namespaces of names found in a & match against regex for namespaces
332  */
333  LPNAMES::value_type::const_iterator bn(LPNAMES::instance().begin()),
334  ed(LPNAMES::instance().end());
335  typedef std::vector< LPNAMES::value_type::const_iterator> Candidates;
336  Candidates candidates;
337  if ( aRegex.notRegex() ) {
338  LPNAMES::value_type::const_iterator it = LPNAMES::instance().find(aRegex.value());
339  if (it!=ed) candidates.push_back(it);
340  }
341  else {
342  if ( !aRegex.range().first.empty()) {
343  bn = LPNAMES::instance().lower_bound(aRegex.range().first);
344  ed = LPNAMES::instance().upper_bound(aRegex.range().second);
345  }
346  for (LPNAMES::value_type::const_iterator it=bn; it != ed; ++it)
347  if(aRegex.match(it->first)) candidates.push_back(it);
348  }
349  for (int i=0; i<int(candidates.size()); ++i) {
350  LPNAMES::value_type::const_iterator it = candidates[i];
351  //if (doit) edm::LogInfo("DDLogicalPart") << "rgx: " << aName << ' ' << it->first << ' ' << doit << std::endl;
352  std::vector<DDName>::size_type sz = it->second.size(); // no of 'compatible' namespaces
353  if ( emptyNs && (sz==1) ) { // accept all logical parts in all the namespaces
354  result.push_back(it->second[0]);
355  //std::vector<DDName>::const_iterator nsIt(it->second.begin()), nsEd(it->second.end());
356  //for(; nsIt != nsEd; ++nsIt) {
357  // result.push_back(DDLogicalPart(*nsIt));
358  // edm::LogInfo("DDLogicalPart") << "DDD-WARNING: multiple namespaces match (in SpecPars PartSelector): " << *nsIt << std::endl;
359  //}
360  }
361  else if ( !emptyNs ) { // only accept matching namespaces
362  std::vector<DDName>::const_iterator nsit(it->second.begin()), nsed(it->second.end());
363  for (; nsit !=nsed; ++nsit) {
364  //edm::LogInfo("DDLogicalPart") << "comparing " << aNs << " with " << *nsit << std::endl;
365  bool another_doit = aNsRegex.match(nsit->ns());
366  if ( another_doit ) {
367  //temp.push_back(std::make_pair(it->first,*nsit));
368  result.push_back(DDLogicalPart(*nsit));
369  }
370  }
371  }
372  else { // emtpyNs and sz>1 -> error, too ambigous
373  std::string message = "DDLogicalPart-name \"" + it->first +"\" matching regex \""
374  + nm + "\" has been found at least in following namespaces:\n";
375  std::vector<DDName>::const_iterator vit = it->second.begin();
376  for(; vit != it->second.end(); ++vit) {
377  message += vit->ns();
378  message += " ";
379  }
380  message += "\nQualify the name with a regexp for the namespace, i.e \".*:name-regexp\" !";
381  return std::make_pair(false,message);
382  }
383  }
384  bool flag=true;
385  std::string message;
386 
387  // check whether the found logical-parts are also defined (i.e. have material, solid ...)
388  if (result.size()) {
389  std::vector<DDLogicalPart>::const_iterator lpit(result.begin()), lped(result.end());
390  for (; lpit != lped; ++lpit) {
391  // std::cout << "VI- " << std::string(lpit->name()) << std::endl;
392  if (!lpit->isDefined().second) {
393  message = message + "LogicalPart " + lpit->name().fullname() + " not (yet) defined!\n";
394  flag = false;
395  }
396  }
397  }
398  else {
399  flag = false;
400  message = "No regex-match for namespace=" + ns + " name=" + nm + "\n";
401  }
402 
403  return std::make_pair(flag,message);
404 }
int i
Definition: DBlmapReader.cc:9
long int flag
Definition: mlp_lapack.h:47
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
uint16_t size_type
static value_type & instance()
tuple result
Definition: query.py:137
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
#define end
Definition: vmac.h:38
#define begin
Definition: vmac.h:31
tuple status
Definition: ntuplemaker.py:245
std::ostream& operator<< ( std::ostream &  ,
const DDLogicalPart  
)

Definition at line 29 of file DDLogicalPart.cc.

References DDBase< N, C >::isDefined(), and DDBase< N, C >::rep().

30 {
32  if( defined.first )
33  {
34  os << *(defined.first) << " ";
35  if( defined.second )
36  {
37  part.rep().stream( os );
38  }
39  else
40  {
41  os << "* logicalpart not defined * ";
42  }
43  }
44  else
45  {
46  os << "* logicalpart not declared * ";
47  }
48  return os;
49 }
Definition: DDBase.h:14
const DDI::rep_traits< N, C >::reference rep() const
Definition: DDBase.h:89
part
Definition: HCALResponse.h:21