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