CMS 3D CMS Logo

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