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  auto & ns = LPNAMES::instance()[n.name()];
12  bool alreadyIn( false );
13  for( const auto& p : ns )
14  {
15  if( p.ns() == n.ns())
16  {
17  alreadyIn = true;
18  break;
19  }
20  }
21  if( !alreadyIn )
22  {
23  ns.push_back( n );
24  }
25 }
static value_type & instance()
std::pair<bool, std::string> DDIsValid ( const std::string &  ns,
const std::string &  name,
std::vector< DDLogicalPart > &  result,
bool  doRegex = true 
)

Definition at line 310 of file DDLogicalPart.cc.

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

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

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

Definition at line 28 of file DDLogicalPart.cc.

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

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