Skip to content

Commit

Permalink
fixed LHCInfoPer* PopCons not recoginizing ongoing fills in duringFil…
Browse files Browse the repository at this point in the history
…l mode
  • Loading branch information
JanChyczynski committed Sep 25, 2023
1 parent 6b29f9a commit 9f25c47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 4 additions & 2 deletions CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ namespace theLHCInfoPerFillImpl {
auto energy = row.get<float>("energy");
auto creationTime = row.get<boost::posix_time::ptime>("start_time");
auto stableBeamStartTime = row.get<boost::posix_time::ptime>("start_stable_beam");
auto beamDumpTime = row.get<boost::posix_time::ptime>("end_time");
std::string endTimeStr = row.get<std::string>("end_time");
auto beamDumpTime =
(endTimeStr == "null") ? 0 : cond::time::from_boost(row.get<boost::posix_time::ptime>("end_time"));
auto injectionScheme = row.get<std::string>("injection_scheme");
targetPayload = std::make_unique<LHCInfoPerFill>();
targetPayload->setFillNumber(currentFill);
Expand All @@ -114,7 +116,7 @@ namespace theLHCInfoPerFillImpl {
targetPayload->setEnergy(energy);
targetPayload->setCreationTime(cond::time::from_boost(creationTime));
targetPayload->setBeginTime(cond::time::from_boost(stableBeamStartTime));
targetPayload->setEndTime(cond::time::from_boost(beamDumpTime));
targetPayload->setEndTime(beamDumpTime);
targetPayload->setInjectionScheme(injectionScheme);
ret = true;
}
Expand Down
13 changes: 10 additions & 3 deletions CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,18 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCIn
oms.connect(m_omsBaseUrl);
auto query = oms.query("fills");
query->addOutputVar("end_time");
query->addOutputVar("start_time");
query->filterEQ("fill_number", m_prevPayload->fillNumber());
bool foundFill = query->execute();
if (foundFill) {
auto result = query->result();

if (!result.empty()) {
auto endFillTime = (*result.begin()).get<boost::posix_time::ptime>("end_time");
m_prevEndFillTime = cond::time::from_boost(endFillTime);
std::string endTimeStr = (*result.begin()).get<std::string>("end_time");
m_prevEndFillTime =
(endTimeStr == "null")
? 0
: cond::time::from_boost((*result.begin()).get<boost::posix_time::ptime>("end_time"));
auto startFillTime = (*result.begin()).get<boost::posix_time::ptime>("start_time");
m_prevStartFillTime = cond::time::from_boost(startFillTime);
} else {
Expand Down Expand Up @@ -362,7 +366,9 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCIn
auto row = *queryResult.begin();
auto currentFill = row.get<unsigned short>("fill_number");
m_startFillTime = cond::time::from_boost(row.get<boost::posix_time::ptime>("start_time"));
m_endFillTime = cond::time::from_boost(row.get<boost::posix_time::ptime>("end_time"));
std::string endTimeStr = row.get<std::string>("end_time");
m_endFillTime =
(endTimeStr == "null") ? 0 : cond::time::from_boost(row.get<boost::posix_time::ptime>("end_time"));
m_startStableBeamTime = cond::time::from_boost(row.get<boost::posix_time::ptime>("start_stable_beam"));
m_endStableBeamTime = cond::time::from_boost(row.get<boost::posix_time::ptime>("end_stable_beam"));
targetPayload = std::make_unique<LHCInfoPerLS>();
Expand Down Expand Up @@ -431,6 +437,7 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCIn
}
return nlumi;
}

bool getCTPPSData(cond::persistency::Session& session,
const boost::posix_time::ptime& beginFillTime,
const boost::posix_time::ptime& endFillTime) {
Expand Down
6 changes: 3 additions & 3 deletions CondTools/RunInfo/test/test_lhcInfoNewPopCon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function assert_found_fills {

rm -f lhcinfo_pop_unit_test.db

echo "testing LHCInfoPerFillPopConAnalyzer in EndFill mode for startTime=\"2022-10-24 01:00:00.000\" endTime=\"2022-10-24 20:00:00.000\""
echo "testing LHCInfoPerFillPopConAnalyzer in endFill mode for startTime=\"2022-10-24 01:00:00.000\" endTime=\"2022-10-24 20:00:00.000\""
cmsRun ${SCRIPTS_DIR}/LHCInfoPerFillPopConAnalyzer.py mode=endFill \
destinationConnection="sqlite_file:lhcinfo_pop_unit_test.db" \
startTime="2022-10-24 01:00:00.000" endTime="2022-10-24 20:00:00.000" \
Expand All @@ -50,11 +50,11 @@ cmsRun ${SCRIPTS_DIR}/LHCInfoPerLSPopConAnalyzer.py mode=endFill \
destinationConnection="sqlite_file:lhcinfo_pop_unit_test.db" \
startTime="2022-07-11 22:00:00.000" endTime="2022-07-12 18:10:10.000" \
tag=ls_end_test2 > ls_end_test2.log || die "cmsRun LHCInfoPerLSPopConAnalyzer.py mode=endFill" $?
assert_equal 69 `cat ls_end_test2.log | grep -E '^Since ' | \
assert_equal 70 `cat ls_end_test2.log | grep -E '^Since ' | \
wc -l` "LHCInfoPerLSPopConAnalyzer in endFill mode written wrong number of payloads"
assert_found_fills ls_end_test2.log "LHCInfoPerLSPopConAnalyzer in endFill mode" 7967

echo "testing LHCInfoPerFillPopConAnalyzer in DuringFill mode for startTime=\"2022-10-24 01:00:00.000\" endTime=\"2022-10-24 20:00:00.000\""
echo "testing LHCInfoPerFillPopConAnalyzer in duringFill mode for startTime=\"2022-10-24 01:00:00.000\" endTime=\"2022-10-24 20:00:00.000\""
cmsRun ${SCRIPTS_DIR}/LHCInfoPerFillPopConAnalyzer.py mode=duringFill \
destinationConnection="sqlite_file:lhcinfo_pop_unit_test.db" \
startTime="2022-10-24 01:00:00.000" endTime="2022-10-24 20:00:00.000" \
Expand Down

0 comments on commit 9f25c47

Please sign in to comment.