Please fill out the following information to help in answering your question, and also see tips for posting codeghsnippets. If you don’t provide this information it will take more time to help with your problem!
Geant4 Version: geant4_10_07_p03 Operating System: mint Compiler/Version: gcc version 7.5.0 CMake Version: cmake version 3.10.2
Hello, dear all!
I need everybody very well!
I have a problem:
i need convertation from int-variable to string-variable in geant4. i have know so do it in c++: using tostring and itoa command, but i do not understand do it using geant4.
You’re writing C++ code anyway, so you can certainly just use std::tostring, or itoa from old-style C. You could also use stringstream, and format the output of your numbers, as John Allison pointed out.
I take it you have many G4Tubs to which you want to give a distinctive name, dimensions and position.
I don’t think there’s need to keep the pointers to the G4Tubs yourself. Geant4 will do it for you.
I assume this is in a loop of some sort.
When you create your G4Tubsobjects with your distinctive name and dimensions and positions in a loop, just new a G4Tubs, then new a G4LogicalVolume, then a G4PVPlacement, all using local (discardable) variable names. The Geant4 geometry system stores them.
You code is declaring an array (in fact, a 2D array), and then assigning a single object to that whole array. You declare the array outside a loop, then you do nested loops over i and j, and then you assign a new object to a single array element inside the loop.
You have declared an array of objects, when what you want is an array of pointers. Then you assign each element of the array via a new G4Tubs(...)call.
for { ...
asd[1]=beltIn[0][1];
//asd=beltIn[0][1];
asd[0] = new G4Tubs(beltIn[0][1], 0.5*1254*mm, 0.5*1254.4*mm, 0.5*200*mm, startAngle, spanningAngle);
G4LogicalVolume* logic_inner_tyvek11 = new G4LogicalVolume(solid_inner_tyvek11, tyvek, "inner_tyvek11"); }
and new problem:
error: cannot convert ‘G4String’ to ‘__gnu_cxx::__alloc_traits<std::allocator<G4Tubs*> >::value_type {aka G4Tubs*}’ in assignment
asd[1]=beltIn[0][1];
I have known about it, that beltIn and g4Tubs are different variables . But my question is in follow: how i can convert string-variable to G4Tube-variable? there is not G4Tubs-class in C++ language.