Skip to content

Commit

Permalink
Fix some json syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
pslocum committed Nov 11, 2024
1 parent 6ffb244 commit 4aa5808
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions Source/Kassiopeia/LMCEventHold.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ namespace locust
aRootTreeWriter->SetFilename(sFileName);
if (fAccumulateTruthInfo)
{
// TO-DO: This option should be used when running pileup. We will need to
// figure out how to explicitly increment the event structure ID, given that the
// same (identical) simulation is being run multiple times in this case.
aRootTreeWriter->OpenFile("UPDATE");
}
else
Expand Down Expand Up @@ -164,7 +161,7 @@ namespace locust
std::string line;
while (std::getline(jsonFile, line))
{
std::cout << line << "\n";
LPROG( lmclog, line );
bNewRun = !line.find("run-id");
if (line != "}") // Avoid saving the last "}". It will be appended below.
{
Expand All @@ -185,38 +182,52 @@ namespace locust
if (bNewRun) // If there are no run parameters in the json file yet, write them now:
{
ost << "{\n";
ost << " \"run-id:\": "<< "\"" << fInterface->aRunParameter->fRunID << "\",\n";
ost << " \"run-id\": "<< "\"" << fInterface->aRunParameter->fRunID << "\",\n";
ost << " {\n";
ost << " \"run-type:\": "<< "\"" << fInterface->aRunParameter->fDataType << "\",\n";
ost << " \"simulation-type:\": "<< "\"" << fInterface->aRunParameter->fSimulationType << "\",\n";
ost << " \"simulation-subtype:\": "<< "\"" << fInterface->aRunParameter->fSimulationSubType << "\",\n";
ost << " \"sampling-freq-mega-hz:\": "<< "\"" << fInterface->aRunParameter->fSamplingRateMHz << "\"\n";
ost << " }\n";
ost << " \"run-type\": "<< "\"" << fInterface->aRunParameter->fDataType << "\",\n";
ost << " \"simulation-type\": "<< "\"" << fInterface->aRunParameter->fSimulationType << "\",\n";
ost << " \"simulation-subtype\": "<< "\"" << fInterface->aRunParameter->fSimulationSubType << "\",\n";
ost << " \"sampling-freq-mega-hz\": "<< "\"" << fInterface->aRunParameter->fSamplingRateMHz << "\"\n";
ost << " },\n";
}
else // otherwise re-write the file:
{
for (int i = 0; i < v.size(); i++)
{
ost << v[i] << "\n";
if (i < v.size()-1)
{
ost << v[i] << "\n";
}
else
{
ost << v[i] << ",\n";
}
}
}


// Write the latest event information here:

ost << " \"event-id:\": "<< "\"" << fInterface->anEvent->fEventID << "\"\n";
ost << " \"event-id\": "<< "\"" << fInterface->anEvent->fEventID << "\"\n";
ost << " {\n";
ost << " \"ntracks:\": "<< "\"" << fInterface->anEvent->fNTracks << "\"\n";
ost << " \"ntracks\": "<< "\"" << fInterface->anEvent->fNTracks << "\",\n";
for (int i=0; i<fInterface->anEvent->fNTracks; i++)
{
ost << " \"track-id:\": "<< "\"" << fInterface->anEvent->fTrackIDs[i] << "\"\n";
ost << " \"track-id\": "<< "\"" << fInterface->anEvent->fTrackIDs[i] << "\"\n";
ost << " {\n";
ost << " \"start-time:\": "<< "\"" << fInterface->anEvent->fStartTimes[i] << "\"\n";
ost << " \"end-time:\": "<< "\"" << fInterface->anEvent->fEndTimes[i] << "\"\n";
ost << " \"output-avg-frequency:\": "<< "\"" << fInterface->anEvent->fOutputAvgFrequencies[i] << "\"\n";
ost << " \"pitch-angle:\": "<< "\"" << fInterface->anEvent->fPitchAngles[i] << "\"\n";
ost << " \"avg-axial-frequency:\": "<< "\"" << fInterface->anEvent->fAvgAxialFrequencies[i] << "\"\n";
ost << " }\n";
ost << " \"start-time\": "<< "\"" << fInterface->anEvent->fStartTimes[i] << "\",\n";
ost << " \"end-time\": "<< "\"" << fInterface->anEvent->fEndTimes[i] << "\",\n";
ost << " \"output-avg-frequency\": "<< "\"" << fInterface->anEvent->fOutputAvgFrequencies[i] << "\",\n";
ost << " \"pitch-angle\": "<< "\"" << fInterface->anEvent->fPitchAngles[i] << "\",\n";
ost << " \"avg-axial-frequency\": "<< "\"" << fInterface->anEvent->fAvgAxialFrequencies[i] << "\"\n";
if (i < fInterface->anEvent->fNTracks-1)
{
ost << " },\n";
}
else
{
ost << " }\n";
}
}
ost << " }\n";
ost << "}\n";
Expand Down

0 comments on commit 4aa5808

Please sign in to comment.