I am looking for an easy way to convert numbers (Int_t, Double_t) into strings.
What i want to do is to create dynamical columns in my ntuple and fill them. Something that should look like:
string nameA=“ColumnNameA”, nameB=“ColumnNameB”;
Int_t intA[42], intB[42]; //or Double_t
…
loop over x
{
intA[x] = 123;
intA --> to string --> stringA
_myTuple->column(nameA+stringA+"additionalString",(double) value);
}
Maybe somebody knows a nifty way to do something like that.
Another way to do the conversion is by using string streams (from STL).You can use them as regular string streams and then recover the string:
Example:
#include <sstream>
ostringstream mysstream;
int number = 23;
string tip = "show";
mysstream << tip << " number " << number;
string line = mysstream.str();
cout << line << endl;