ROOT & stringstream

Dear Wile (Simon?) and Wolf:

Thank you for your helpful replies. Adding the #include’s suggested by Wile fixed the second problem, but did not affect the first. Nor did removing the assertion help. The relevant code now reads:

// Electron card
if (!getline(inFile,line)) {break;}
countLines++;
lineStream.str(line);
//assert(lineStream>>label>>epx>>epy>>epz>>ee);
lineStream>>label>>epx>>epy>>epz>>ee;
if (eventNmb < 5) {
cout<<line<<endl;
cout <<"SOURCE: reads “<<label<<” “<<epx<<” “<<epy<<” “<<epz<<” "<<ee<<endl;
}
assert(label == “SOURCE:”);

and produces the following output:

Opening slight.out
slight.out open
Reached Event 1
Gamma reads 0.006637261.69041e-11
SOURCE: 0 0 9.96273 9.96273
SOURCE: reads GAMMA: 1.89227e-321 1.97626e-323 2.29311e-314 6.95322e-310
Assertion failed: (label == “SOURCE:”), function eTTreemaker, file /Users/sklein/estarlight/STARlight/trunk/build/eTTreemaker.C, line 90.
SRKlein-m87:build sklein$

In other words, ‘line’ is read in correctly, but somehow the linestream command is going awry on the third use here. ‘label’ is not reassigned, and the four doubles are garbage.

The assertion was failing because it should. I can remove the other assertions and check for file opening in the preferred manner, but I don’t think that either of those things is causing the problem.

Spencer

Any more ideas?

Spencer