#include <Toolbox.hh>
Collaboration diagram for Toolbox:
Public Member Functions | |
~Toolbox () | |
Static Public Member Functions | |
static void | readSteerFile (std::string fileNamne, bool verbose) |
static unsigned short | bigTolittle (short value) |
static void | addIntToString (std::string &chaine, int value) |
static void | addFloatToString (std::string &chaine, float value) |
static void | printRepere (bool xRotation, bool yRotation, int zRotation) |
static std::string | getTempFileName (void) |
static bool | getDetector (ui32 runId, Detector &detector) |
Static Public Attributes | |
static const unsigned int | MASK_LSB = 0x00ff |
static const unsigned int | MASK_MSB = 0xff00 |
static const unsigned long | MASK_CHANNEL_DATA = 0x00000fff |
static const unsigned long | MASK_CHANNEL_NUMBER = 0x007ff000 |
static const unsigned int | MASK_12BIT = 0x0fff |
Private Member Functions | |
Toolbox () |
Definition at line 22 of file Toolbox.hh.
Toolbox::~Toolbox | ( | ) |
Toolbox::Toolbox | ( | ) | [private] |
static void Toolbox::readSteerFile | ( | std::string | fileNamne, | |
bool | verbose | |||
) | [static] |
unsigned short Toolbox::bigTolittle | ( | short | value | ) | [static] |
Definition at line 79 of file Toolbox.cpp.
00080 { 00081 00082 unsigned short lsb = value & MASK_LSB ; 00083 lsb = lsb << 8 ; 00084 00085 unsigned short msb = value & MASK_MSB; 00086 msb = msb >> 8 ; 00087 00088 00089 00090 unsigned short result = lsb + msb; 00091 return result; 00092 }
void Toolbox::addIntToString | ( | std::string & | chaine, | |
int | value | |||
) | [static] |
Definition at line 105 of file Toolbox.cpp.
Referenced by EventDisplay::DisplayCaloEvent(), EventDisplay::DisplayMTEvent(), BeamProfile::DrawDeltaT(), BeamProfile::DrawHitPerChannelDist(), BeamProfile::DrawHitPerChipDist(), BeamProfile::FillXyDist(), and main().
00106 { 00107 00108 std::string s; 00109 std::stringstream out; 00110 out << value; 00111 s = out.str(); 00112 chaine = chaine.append(s); 00113 }
void Toolbox::addFloatToString | ( | std::string & | chaine, | |
float | value | |||
) | [static] |
Definition at line 95 of file Toolbox.cpp.
Referenced by main().
00096 { 00097 00098 std::string s; 00099 std::stringstream out; 00100 out << value; 00101 s = out.str(); 00102 chaine = chaine.append(s); 00103 }
void Toolbox::printRepere | ( | bool | xRotation, | |
bool | yRotation, | |||
int | zRotation | |||
) | [static] |
Definition at line 42 of file Toolbox.cpp.
Referenced by main().
00043 { 00044 cout <<" \n ------------- ROTATIONS" << endl; 00045 00046 int result = (xRotation== false) ? 0 : 180; 00047 cout << "### xRotation " << result << " degree." << endl; 00048 00049 result = (yRotation== false) ? 0 : 180; 00050 cout << "### yRotation " << result << " degree." << endl; 00051 00052 cout << "### zRotation " << zRotation << " degree." << endl; 00053 00054 00055 cout << endl << "### Nous utilisons un repere irthonorme directe ###" <<endl; 00056 cout << "" << endl; 00057 cout << " X" << endl; 00058 cout << " " << endl; 00059 cout << " ^" << endl; 00060 cout << " / \\ " << endl; 00061 cout << " |" << endl; 00062 cout << " |" << endl; 00063 cout << " |" << endl; 00064 cout << " |" << endl; 00065 cout << " |" << endl; 00066 cout << " |" << endl; 00067 cout << "SYSTEM de COORDONNEES: (0,0) au centre ----X----------> Y " << endl; 00068 cout << " Z rentrant. |" << endl; 00069 cout << " |" << endl; 00070 cout << " |" << endl; 00071 cout << " |" << endl; 00072 00073 }
string Toolbox::getTempFileName | ( | void | ) | [static] |
Definition at line 215 of file Toolbox.cpp.
Referenced by getDetector().
00216 { 00217 00218 FILE *sfp = NULL; 00219 int fd = -1; 00220 char sfn[22] = ""; 00221 strncpy(sfn, "/tmp/micromegas.XXXXXX", sizeof sfn); 00222 if ((fd = mkstemp(sfn)) == -1 ) 00223 { 00224 unlink(sfn); 00225 close(fd); 00226 fprintf(stderr, "%s: %s\n", sfn, strerror(errno)); 00227 throw MicroException("Cannot create temporaly file"); 00228 } 00229 00230 string result = sfn; 00231 return result; 00232 }
bool Toolbox::getDetector | ( | ui32 | runId, | |
Detector & | detector | |||
) | [static] |
Definition at line 235 of file Toolbox.cpp.
Referenced by main().
00236 { 00237 Mysql mysql; 00238 MYSQL_ROW row; 00239 00240 string detectorXMLValue = mysql.getDetectorStringFromRunId(runId) ; 00241 00242 00243 string fileName = Toolbox::getTempFileName(); 00244 00245 00246 00247 for (unsigned int i = 0 ; i < detectorXMLValue.size(); i++ ) 00248 { 00249 if( detectorXMLValue[i] == '\r' ) detectorXMLValue[i] = ' '; 00250 } 00251 00252 ofstream myfile; 00253 myfile.open (fileName.c_str()); 00254 myfile << "<micromegas xmlns:run=\"http://lappweb.in2p3.fr/LC\">" ; 00255 myfile << detectorXMLValue + "\n" ; 00256 myfile << "</micromegas>" ; 00257 myfile.close(); 00258 00259 SteerDesc steerDesc; 00260 XMLTool xml; 00261 xml.parse(steerDesc, fileName); // parse steer file and fill steerDesc 00262 00263 //Detector detector; 00264 if ( ! detector.build(steerDesc) == steerDesc.chambers.size() ) 00265 { 00266 FILE_LOG(logERROR) << "Geometry Error. Please check your XML file." << endl; 00267 return false; 00268 } 00269 00270 00271 unlink(fileName.c_str()); 00272 return true; 00273 }
const unsigned int Toolbox::MASK_LSB = 0x00ff [static] |
const unsigned int Toolbox::MASK_MSB = 0xff00 [static] |
const unsigned long Toolbox::MASK_CHANNEL_DATA = 0x00000fff [static] |
const unsigned long Toolbox::MASK_CHANNEL_NUMBER = 0x007ff000 [static] |
const unsigned int Toolbox::MASK_12BIT = 0x0fff [static] |