CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OpticalObjectMgr.cc
Go to the documentation of this file.
4 #include <cstdlib>
5 
7 
8 //-----------------------------------------------------------------------
10 {
11  if( !theInstance ) {
14  // theInstance->verbose = ALIUtils::verbosity();
15  }
16  return theInstance;
17 }
18 
19 
20 //-----------------------------------------------------------------------
21 OpticalObject* OpticalObjectMgr::findOptO( const ALIstring& longName, bool exists ) const
22 {
23  OpticalObject* opto = 0;
24  msopto::const_iterator cite = theOptODict.find( longName );
25  if( cite == theOptODict.end() ) {
26  if( exists ) {
27  std::cerr << "!!!! EXITING: OptO not found: " << longName << std::endl;
28  exit(1);
29  } else {
30  std::cerr << "!! WARNING: OptO not found: " << longName << std::endl;
31  }
32  } else {
33  opto = (*cite).second;
34  }
35 
36  return opto;
37 
38 }
39 
40 
41 //-----------------------------------------------------------------------
42 std::vector<OpticalObject*> OpticalObjectMgr::findOptOs( const ALIstring& name, bool exists ) const
43 {
44  std::vector<OpticalObject*> vopto;
45  msopto::const_iterator cite;
46  //----- Look for OptO's that contains 'name' in its longName as the last word (after the last '/')
47  for( cite = theOptODict.begin(); cite != theOptODict.end(); cite++ ) {
48  ALIstring oname = (*cite).first;
49  int nf = oname.rfind( name );
50  int sf = oname.rfind( '/' );
51  if( nf != -1 && sf <= nf ) {
52  vopto.push_back( (*cite).second );
53  }
54  }
55 
56  if( vopto.size() == 0 ) {
57  if( exists ) {
58  std::cerr << "!!!! EXITING: OptO not found: " << name << std::endl;
59  exit(1);
60  } else {
61  std::cerr << "!! WARNING: OptO not found: " << name << std::endl;
62  }
63  }
64 
65  return vopto;
66 
67 }
68 
69 
70 //-----------------------------------------------------------------------
71 void OpticalObjectMgr::dumpOptOs( std::ostream& out ) const
72 {
73  std::cout << "OPTICALOBJECT list size " << theOptODict.size() << std::endl;
74  std::vector< OpticalObject* >::const_iterator vocite;
75  for( vocite = Model::OptOList().begin(); vocite != Model::OptOList().end(); vocite++ ) {
76  ALIstring name = (*vocite)->name();
77  ALIUtils::dump3v( (*vocite)->centreGlobal(), (name + " CENTRE GLOBAL: ").c_str() );
78  if( (*vocite)->parent() != 0 ) ALIUtils::dump3v( (*vocite)->centreLocal(), (name + " CENTRE LOCAL: ").c_str() ); //not for the 'system'
79  }
80 
81 }
82 
83 
84 //-----------------------------------------------------------------------
86 {
87  return theLastCmsSwID++;
88 }
OpticalObject * findOptO(const ALIstring &longName, bool exists=0) const
static OpticalObjectMgr * theInstance
std::vector< OpticalObject * > findOptOs(const ALIstring &name, bool exists=0) const
static OpticalObjectMgr * getInstance()
Get the only instance.
void dumpOptOs(std::ostream &out=std::cout) const
static std::vector< OpticalObject * > & OptOList()
Definition: Model.h:71
tuple out
Definition: dbtoconf.py:99
static void dump3v(const CLHEP::Hep3Vector &vec, const std::string &msg)
Definition: ALIUtils.cc:61
#define begin
Definition: vmac.h:30
std::string ALIstring
Definition: CocoaGlobals.h:9
tuple cout
Definition: gather_cfg.py:121
unsigned int ALIuint
Definition: CocoaGlobals.h:17