#include #include "elementDrift.h" #include "mathematicalTools.h" #include "mixedTools.h" elementDrift::elementDrift() : abstractElement() { setDefaultValues(); setDefaults(); elementName_ = nomdElements("drift"); nbParam_ = elementName_.getElementNbParameters(); parametersString_ = new string[nbParam_+1]; } void elementDrift::setDefaultValues() { defaultSpecificName_ = "drift"; } void elementDrift::setDefaults() { specificName_ = defaultSpecificName_; } string* elementDrift::getParametersString() const { int compteur = -1; parametersString_[++compteur]= mixedTools::intToString(nbParam_); parametersString_[++compteur]= specificName_; parametersString_[++compteur]= mixedTools::doubleToString(lenghtElem_); parametersString_[++compteur]= mixedTools::doubleToString(aperture_); if ( compteur != nbParam_ ) { cerr << " elementDrift::getParametersString() : ERROR nr pf parameters dosnt match " << endl; return NULL; } return parametersString_; } void elementDrift::setParametersString(string* param) { if ( param == NULL ) { cerr << " elementDrift::setParametersString parameters empty parameter set"; return; } int compteur = -1; int nbparam = atoi(param[++compteur].c_str()); if ( nbparam != nbParam_ ) { cerr << " elementDrift::setParametersString parameters do not match for a DRIFT"; return; } specificName_ = param[++compteur]; lenghtElem_ = atof(param[++compteur].c_str()); aperture_ = atof(param[++compteur].c_str()); } // string elementDrift::parmelaOutputFlow() const // { // ostringstream sortie; // sortie << "DRIFT /l=" << lenghtElem_ << " /aper=" << aperture_ << " /iout=1" << endl; // return sortie.str(); // } // string elementDrift::transportOutputFlow() const // { // ostringstream sortie; // // longueur en m // sortie << specificName_ << ":" << " DRIFT, L=" << 0.01*lenghtElem_ << ";" << endl; // return sortie.str(); // } // string elementDrift::FileOutputFlow() const // { // ostringstream sortie; // // sortie << elementName_.getElementType() << endl; // sortie << elementName_.getGenericLabel() << endl; // sortie << specificName_ << endl; // sortie << lenghtElem_ << " " << aperture_ < > > elementDrift::parametersToSoftware () const { vector< pair > > sortie; sortie.push_back( pair >("labelsGenericSpecific", vector() ) ); sortie.back().second.push_back(elementName_.getGenericLabel()); sortie.back().second.push_back(specificName_); sortie.push_back( pair >("lenghtAperture", vector() ) ); sortie.back().second.push_back(mixedTools::doubleToString(lenghtElem_)); sortie.back().second.push_back(mixedTools::doubleToString(aperture_)); return sortie; } // void elementDrift::FileInput(ifstream& ifs) // { // ifs >> specificName_; // ifs >> lenghtElem_ >> aperture_; // } string elementDrift::print() { string txt = ""; txt += specificName_; txt += "\nlength (cm) : "; txt += mixedTools::doubleToString(lenghtElem_); txt += "\naperture (cm) : "; txt += mixedTools::doubleToString(aperture_); return txt; } void elementDrift::InputRep(UAPNode* root) { // UAPNode* ele = root->addChild("element"); // ele->addAttribute("name",specificName_); UAPNode* ele = setAMLelementHeader(root); string txt = ""; txt = mixedTools::doubleToString(lenghtElem_); ele->addChild("length")->addAttribute("design",txt); UAPNode* node = ele->addChild("aperture"); node->addAttribute("at","EXIT"); node->addAttribute("shape","CIRCLE"); txt = mixedTools::doubleToString(aperture_); node->addChild("xy_limit")->addAttribute("design",txt); } void elementDrift::FileAMLInput(UAPNode* entree) { if ( !checkAMLelementGenericName(entree) ) return; AMLtools::readAMLParameterAttribut(entree, "length", "design", lenghtElem_); UAPNode* ouverture = entree->getChildByName("aperture"); if ( !ouverture ) { cout << " elementDrift::FileAMLInput ERREUR pas de noeud AML " << endl; return; } AMLtools::readAMLParameterAttribut(ouverture, "xy_limit", "design", aperture_); }