CMS 3D CMS Logo

EntryMgr.cc
Go to the documentation of this file.
1 // COCOA class implementation file
2 //Id: EntryMgr.cc
3 //CAT: Model
4 //
5 // History: v1.0 10/11/01 Pedro Arce
6 
10 #include <cstdlib>
11 //----------------------------------------------------------------------------
12 
14 
15 //----------------------------------------------------------------------------
17  if (!theInstance) {
18  theInstance = new EntryMgr;
23  }
24 
25  return theInstance;
26 }
27 
28 //----------------------------------------------------------------------------
29 ALIbool EntryMgr::readEntryFromReportOut(const std::vector<ALIstring>& wl) {
30  //- std::cout << " EntryMgr::readEntryFromReportOut " << wl[0] << std::endl;
31  if (wl[0] == "DIMENSIONS:") {
32  //----- Set dimensions of all the file
34  if (ALIUtils::debug >= 6)
35  std::cout << " dimOutLengthVal " << dimOutLengthVal << " " << ALIUtils::getDimensionValue(wl[3], "Length") << " "
36  << ALIUtils::LengthValueDimensionFactor() << std::endl;
39  if (ALIUtils::debug >= 6)
40  std::cout << " dimOutAngleVal " << dimOutAngleVal << " " << ALIUtils::getDimensionValue(wl[8], "Angle") << " "
41  << ALIUtils::AngleValueDimensionFactor() << std::endl;
42 
44  } else if (wl[0] == "FIX:" || wl[0] == "CAL:" || wl[0] == "UNK:") {
45  //----- check if it exists
47  if (!data) {
48  data = new EntryData();
49  theEntryData.push_back(data);
50  }
51  data->fill(wl);
52  }
53 
54  return true;
55 }
56 
57 //----------------------------------------------------------------------------
58 EntryData* EntryMgr::findEntryByShortName(const ALIstring& optoName, const ALIstring& entryName) {
59  EntryData* data = nullptr;
60 
61  int icount = 0;
62  std::vector<EntryData*>::iterator ite;
63  for (ite = theEntryData.begin(); ite != theEntryData.end(); ++ite) {
64  if ((*ite)->shortOptOName() == extractShortName(optoName) &&
65  ((*ite)->entryName() == entryName || entryName.empty())) {
66  if (icount == 0)
67  data = (*ite);
68  if (!entryName.empty())
69  icount++;
70  }
71  //- std::cout << icount << " findEntryByShortName " << (*ite)->shortOptOName() << " =?= " << extractShortName(optoName) << std::endl << (*ite)->entryName() << " =?= " <<entryName << std::endl;
72  }
73 
74  if (icount > 1) {
75  std::cerr << "!!! WARNING: >1 objects with OptO name= " << optoName << " and entry Name = " << entryName
76  << std::endl;
77  }
78  return data;
79 }
80 
81 //----------------------------------------------------------------------------
82 EntryData* EntryMgr::findEntryByLongName(const ALIstring& optoName, const ALIstring& entryName) {
83  EntryData* data = nullptr;
84 
85  int icount = 0;
86  std::vector<EntryData*>::iterator ite;
87  if (ALIUtils::debug >= 6)
88  std::cout << " findEntryByLongName theEntryData size = " << theEntryData.size() << std::endl;
89  for (ite = theEntryData.begin(); ite != theEntryData.end(); ++ite) {
90  if ((*ite)->longOptOName() == optoName && ((*ite)->entryName() == entryName || entryName.empty())) {
91  //- if( (*ite)->longOptOName() == optoName ) {
92  //- std::cout << " equal optoName " << std::endl;
93  //- if( (*ite)->entryName() == entryName || entryName == "" ) {
94  if (icount == 0)
95  data = (*ite);
96  if (ALIUtils::debug >= 6)
97  std::cout << data << " " << icount << " data longOptOName " << (*ite)->longOptOName() << " entryName "
98  << (*ite)->entryName() << " " << (*ite)->valueOriginal() << std::endl;
99 
100  if (!entryName.empty())
101  icount++;
102  }
103  //- std::cout << " looking for longOptOName " << optoName << " entryName " << entryName << std::endl;
104  }
105 
106  if (icount > 1) {
107  std::cerr << "!!! FATAL ERROR in EntryMgr::findEntryByLongName: >1 objects with OptO name= " << optoName
108  << " and entry name = " << entryName << std::endl;
109  abort();
110  }
111  return data;
112 }
113 
114 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
115 EntryData* EntryMgr::findEntry(const std::vector<ALIstring>& wl) {
116  EntryData* data = nullptr;
117  const ALIstring& optoName = wl[2];
118  const ALIstring& entryName = wl[3];
119  data = findEntryByLongName(optoName, entryName);
120 
121  return data;
122 }
123 
124 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
126  ALIint isl = name.rfind('/');
127  if (isl == -1) {
128  return name;
129  } else {
130  return name.substr(isl + 1, name.size());
131  }
132 }
static EntryMgr * theInstance
Definition: EntryMgr.h:45
EntryData * findEntry(const std::vector< ALIstring > &wl)
Definition: EntryMgr.cc:115
ALIdouble dimOutAngleVal
Definition: EntryMgr.h:47
ALIdouble dimOutLengthSig
Definition: EntryMgr.h:47
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:34
EntryData * findEntryByShortName(const ALIstring &optoName, const ALIstring &entryName="")
Definition: EntryMgr.cc:58
bool ALIbool
Definition: CocoaGlobals.h:19
ALIstring extractShortName(const ALIstring &name)
Definition: EntryMgr.cc:125
ALIdouble dimOutLengthVal
Definition: EntryMgr.h:47
EntryMgr()
Definition: EntryMgr.h:17
static EntryMgr * getInstance()
Definition: EntryMgr.cc:16
static ALIdouble getDimensionValue(const ALIstring &dim, const ALIstring &dimType)
Definition: ALIUtils.cc:477
ALIdouble dimOutAngleSig
Definition: EntryMgr.h:47
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::string ALIstring
Definition: CocoaGlobals.h:9
std::vector< EntryData * > theEntryData
Definition: EntryMgr.h:48
ALIbool readEntryFromReportOut(const std::vector< ALIstring > &wl)
Definition: EntryMgr.cc:29
static ALIdouble AngleValueDimensionFactor()
Definition: ALIUtils.h:64
EntryData * findEntryByLongName(const ALIstring &optoName, const ALIstring &entryName="")
Definition: EntryMgr.cc:82
static ALIdouble LengthValueDimensionFactor()
Definition: ALIUtils.h:62