CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
13 
15 
16 //----------------------------------------------------------------------------
18 {
19  if( !theInstance ) {
20  theInstance = new EntryMgr;
25  }
26 
27  return theInstance;
28 
29 }
30 
31 
32 //----------------------------------------------------------------------------
33 ALIbool EntryMgr::readEntryFromReportOut( const std::vector<ALIstring>& wl )
34 {
35  //- std::cout << " EntryMgr::readEntryFromReportOut " << wl[0] << std::endl;
36  if( wl[0] == "DIMENSIONS:" ) {
37  //----- Set dimensions of all the file
39  if(ALIUtils::debug >= 6) std::cout << " dimOutLengthVal " << dimOutLengthVal << " " << ALIUtils::getDimensionValue( wl[3],"Length") << " " << ALIUtils::LengthValueDimensionFactor() << std::endl;
42  if(ALIUtils::debug >= 6) std::cout << " dimOutAngleVal " << dimOutAngleVal << " " << ALIUtils::getDimensionValue( wl[8],"Angle") << " " << ALIUtils::AngleValueDimensionFactor() << std::endl;
43 
45  } else if( wl[0] == "FIX:" || wl[0] == "CAL:" || wl[0] == "UNK:" ) {
46  //----- check if it exists
47  EntryData* data = findEntry( wl );
48  if( !data ) {
49  data = new EntryData();
50  theEntryData.push_back( data );
51  }
52  data->fill( wl );
53  }
54 
55  return 1;
56 }
57 
58 
59 //----------------------------------------------------------------------------
60 EntryData* EntryMgr::findEntryByShortName( const ALIstring& optoName, const ALIstring& entryName )
61 {
62  EntryData* data = 0;
63 
64  int icount = 0;
65  std::vector<EntryData*>::iterator ite;
66  for( ite = theEntryData.begin(); ite != theEntryData.end(); ++ite ) {
67  if( (*ite)->shortOptOName() == extractShortName(optoName) &&
68  ( (*ite)->entryName() == entryName || entryName == "" ) ) {
69  if( icount == 0 ) data = (*ite);
70  if( entryName != "" ) icount++;
71  }
72  //- std::cout << icount << " findEntryByShortName " << (*ite)->shortOptOName() << " =?= " << extractShortName(optoName) << std::endl << (*ite)->entryName() << " =?= " <<entryName << std::endl;
73  }
74 
75  if( icount > 1 ) {
76  std::cerr << "!!! WARNING: >1 objects with OptO name= " << optoName << " and entry Name = " << entryName << std::endl;
77  }
78  return data;
79 }
80 
81 
82 //----------------------------------------------------------------------------
83 EntryData* EntryMgr::findEntryByLongName( const ALIstring& optoName, const ALIstring& entryName )
84 {
85  EntryData* data = 0;
86 
87  int icount = 0;
88  std::vector<EntryData*>::iterator ite;
89  if(ALIUtils::debug >= 6) std::cout << " findEntryByLongName theEntryData size = " << theEntryData.size() << std::endl;
90  for( ite = theEntryData.begin(); ite != theEntryData.end(); ++ite ) {
91  if( (*ite)->longOptOName() == optoName &&
92  ( (*ite)->entryName() == entryName || entryName == "" ) ) {
93  //- if( (*ite)->longOptOName() == optoName ) {
94  //- std::cout << " equal optoName " << std::endl;
95  //- if( (*ite)->entryName() == entryName || entryName == "" ) {
96  if( icount == 0 ) data = (*ite);
97  if(ALIUtils::debug >= 6) std::cout << data << " " << icount << " data longOptOName " << (*ite)->longOptOName() << " entryName " << (*ite)->entryName() << " " << (*ite)->valueOriginal() << std::endl;
98 
99  if( entryName != "" ) icount++;
100  }
101  //- std::cout << " looking for longOptOName " << optoName << " entryName " << entryName << std::endl;
102  }
103 
104  if( icount > 1 ) {
105  std::cerr << "!!! FATAL ERROR in EntryMgr::findEntryByLongName: >1 objects with OptO name= " << optoName << " and entry name = " << entryName << std::endl;
106  abort();
107  }
108  return data;
109 }
110 
111 
112 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
113 EntryData* EntryMgr::findEntry( const std::vector<ALIstring>& wl )
114 {
115  EntryData* data = 0;
116  ALIstring optoName = wl[2];
117  ALIstring entryName = wl[3];
118  data = findEntryByLongName( optoName, entryName );
119 
120  return data;
121 
122 }
123 
124 
125 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
127 {
128  ALIint isl = name.rfind("/");
129  if( isl == -1 ) {
130  return name ;
131  } else {
132  return name.substr( isl+1, name.size() );
133  }
134 }
static EntryMgr * theInstance
Definition: EntryMgr.h:53
EntryData * findEntry(const std::vector< ALIstring > &wl)
Definition: EntryMgr.cc:113
ALIdouble dimOutAngleVal
Definition: EntryMgr.h:55
void fill(const std::vector< ALIstring > &wordlist)
Definition: EntryData.cc:20
ALIdouble dimOutLengthSig
Definition: EntryMgr.h:55
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:35
EntryData * findEntryByShortName(const ALIstring &optoName, const ALIstring &entryName="")
Definition: EntryMgr.cc:60
const ALIstring & longOptOName() const
Definition: EntryData.h:27
bool ALIbool
Definition: CocoaGlobals.h:19
ALIstring extractShortName(const ALIstring &name)
Definition: EntryMgr.cc:126
ALIdouble dimOutLengthVal
Definition: EntryMgr.h:55
EntryMgr()
Definition: EntryMgr.h:18
static EntryMgr * getInstance()
Definition: EntryMgr.cc:17
static ALIdouble getDimensionValue(const ALIstring &dim, const ALIstring &dimType)
Definition: ALIUtils.cc:515
ALIdouble dimOutAngleSig
Definition: EntryMgr.h:55
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::string ALIstring
Definition: CocoaGlobals.h:9
std::vector< EntryData * > theEntryData
Definition: EntryMgr.h:56
ALIbool readEntryFromReportOut(const std::vector< ALIstring > &wl)
Definition: EntryMgr.cc:33
static ALIdouble AngleValueDimensionFactor()
Definition: ALIUtils.h:75
tuple cout
Definition: gather_cfg.py:121
EntryData * findEntryByLongName(const ALIstring &optoName, const ALIstring &entryName="")
Definition: EntryMgr.cc:83
static ALIdouble LengthValueDimensionFactor()
Definition: ALIUtils.h:71