Skip to content

Commit 735cf53

Browse files
author
Michael Peters
committed
2 parents 479fedc + d780913 commit 735cf53

File tree

79 files changed

+3396
-546
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3396
-546
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Fix missing final newline (CodeRabbit docstring PRs)
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: read
10+
11+
jobs:
12+
fix_eof_newline:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Guard - only CodeRabbit docstring PRs from same repo
16+
id: guard
17+
shell: bash
18+
run: |
19+
set -euo pipefail
20+
21+
AUTHOR='${{ github.event.pull_request.user.login }}'
22+
BASE_REPO='${{ github.event.pull_request.base.repo.full_name }}'
23+
HEAD_REPO='${{ github.event.pull_request.head.repo.full_name }}'
24+
TITLE='${{ github.event.pull_request.title }}'
25+
26+
if [[ "$AUTHOR" != "coderabbitai[bot]" ]]; then
27+
echo "run=false" >> "$GITHUB_OUTPUT"
28+
exit 0
29+
fi
30+
31+
# Safety: only push to branches within the same repo
32+
if [[ "$BASE_REPO" != "$HEAD_REPO" ]]; then
33+
echo "run=false" >> "$GITHUB_OUTPUT"
34+
exit 0
35+
fi
36+
37+
# only run for docstring PRs
38+
if ! echo "$TITLE" | grep -qi "docstring"; then
39+
echo "run=false" >> "$GITHUB_OUTPUT"
40+
exit 0
41+
fi
42+
43+
echo "run=true" >> "$GITHUB_OUTPUT"
44+
45+
- name: Checkout PR head
46+
if: steps.guard.outputs.run == 'true'
47+
uses: actions/checkout@v4
48+
with:
49+
ref: ${{ github.event.pull_request.head.ref }}
50+
repository: ${{ github.event.pull_request.head.repo.full_name }}
51+
fetch-depth: 0
52+
53+
- name: Append final newline when missing (changed files only)
54+
if: steps.guard.outputs.run == 'true'
55+
shell: bash
56+
run: |
57+
set -euo pipefail
58+
59+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
60+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
61+
62+
files=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- \
63+
'*.C' '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' || true)
64+
65+
if [[ -z "${files}" ]]; then
66+
echo "No relevant files changed."
67+
exit 0
68+
fi
69+
70+
changed=0
71+
for f in $files; do
72+
[[ -f "$f" ]] || continue
73+
74+
# For non-empty files: ensure last byte is '\n'
75+
if [[ -s "$f" ]]; then
76+
last_byte="$(tail -c 1 "$f" || true)"
77+
if [[ "$last_byte" != $'\n' ]]; then
78+
printf '\n' >> "$f"
79+
echo "Fixed EOF newline: $f"
80+
changed=1
81+
fi
82+
fi
83+
done
84+
85+
if [[ "$changed" -eq 0 ]]; then
86+
echo "All files already end with a newline."
87+
exit 0
88+
fi
89+
90+
git status --porcelain
91+
git add -A
92+
93+
git config user.name "github-actions[bot]"
94+
git config user.email "github-actions[bot]@users.noreply.github.com"
95+
96+
git commit -m "Fix missing final newline in docstring PR"
97+
98+
- name: Push fix commit back to PR branch
99+
if: steps.guard.outputs.run == 'true'
100+
shell: bash
101+
run: |
102+
set -euo pipefail
103+
# If no commit was created, pushing will fail; so only push if HEAD is ahead.
104+
if git rev-parse HEAD~1 >/dev/null 2>&1; then
105+
git push origin "HEAD:${{ github.event.pull_request.head.ref }}"
106+
fi

calibrations/tpc/dEdx/Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = foreign
22

33
AM_CPPFLAGS = \
44
-I$(includedir) \
5-
-I$(OFFLINE_MAIN)/include \
5+
-isystem$(OFFLINE_MAIN)/include \
66
-isystem$(ROOTSYS)/include
77

88
AM_LDFLAGS = \
@@ -14,7 +14,7 @@ pkginclude_HEADERS = \
1414
dEdxFitter.h \
1515
GlobaldEdxFitter.h \
1616
bethe_bloch.h
17-
17+
1818
lib_LTLIBRARIES = \
1919
libdedxfitter.la
2020

@@ -26,8 +26,8 @@ libdedxfitter_la_LIBADD = \
2626
-lphool \
2727
-ltrack_io \
2828
-lg4detectors \
29+
-ltrackbase_historic \
2930
-ltrackbase_historic_io \
30-
-ltrack_reco \
3131
-lglobalvertex \
3232
-lSubsysReco
3333

calibrations/tpc/dEdx/configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ AC_PROG_CXX(CC g++)
66

77
LT_INIT([disable-static])
88

9-
dnl no point in suppressing warnings people should
10-
dnl at least see them, so here we go for g++: -Wall
9+
dnl enable more warnings and make them fatal
10+
dnl this package needs openmp which requires -fopenmp for clang
1111
if test $ac_cv_prog_gxx = yes; then
12-
CXXFLAGS="$CXXFLAGS -Wall -Werror"
12+
CXXFLAGS="$CXXFLAGS -Wall -Wshadow -Wextra -Werror"
1313
fi
1414

1515
AC_CONFIG_FILES([Makefile])

generators/Herwig/HepMCTrigger/HepMCJetTrigger.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ HepMCJetTrigger::HepMCJetTrigger(float trigger_thresh, int n_incom, bool up_lim,
3131
int HepMCJetTrigger::process_event(PHCompositeNode* topNode)
3232
{
3333
// std::cout << "HepMCJetTrigger::process_event(PHCompositeNode *topNode) Processing Event" << std::endl;
34-
n_evts++;
3534
if (this->set_event_limit == true)
3635
{ // needed to keep all HepMC output at the same number of events
3736
if (n_good >= this->goal_event_number)
3837
{
3938
return Fun4AllReturnCodes::ABORTEVENT;
4039
}
4140
}
41+
n_evts++;
4242
PHHepMCGenEventMap* phg = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
4343
if (!phg)
4444
{

generators/Herwig/HepMCTrigger/HepMCJetTrigger.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@ class HepMCJetTrigger : public SubsysReco
4747
/// Called at the end of all processing.
4848

4949
/// Reset
50+
int getNevts(){return this->n_evts;}
51+
int getNgood(){return this->n_good;}
5052

5153
private:
5254
bool isGoodEvent(HepMC::GenEvent* e1);
5355
std::vector<fastjet::PseudoJet> findAllJets(HepMC::GenEvent* e1);
5456
int jetsAboveThreshold(const std::vector<fastjet::PseudoJet>& jets) const;
5557
float threshold{0.};
5658
int goal_event_number{1000};
59+
bool set_event_limit{false};
5760
int n_evts{0};
5861
int n_good{0};
59-
bool set_event_limit{false};
6062
};
6163

6264
#endif // HEPMCJETTRIGGER_H

generators/Herwig/HepMCTrigger/HepMCParticleTrigger.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ HepMCParticleTrigger::HepMCParticleTrigger(float trigger_thresh, int n_incom, bo
6868
int HepMCParticleTrigger::process_event(PHCompositeNode* topNode)
6969
{
7070
// std::cout << "HepMCParticleTrigger::process_event(PHCompositeNode *topNode) Processing Event" << std::endl;
71-
n_evts++;
7271
if (this->set_event_limit == true)
7372
{ // needed to keep all HepMC output at the same number of events
7473
if (n_good >= this->goal_event_number)
7574
{
7675
return Fun4AllReturnCodes::ABORTEVENT;
7776
}
7877
}
78+
n_evts++;
7979
bool good_event{false};
8080
PHHepMCGenEventMap* phg = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
8181
if (!phg)

generators/Herwig/HepMCTrigger/HepMCParticleTrigger.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class HepMCParticleTrigger : public SubsysReco
6666
void SetPzHighLow(double, double);
6767

6868
void SetStableParticleOnly(bool b) { m_doStableParticleOnly = b; }
69+
int getNevts(){return this->n_evts;}
70+
int getNgood(){return this->n_good;}
6971

7072
private:
7173
bool isGoodEvent(HepMC::GenEvent* e1);
@@ -76,9 +78,9 @@ class HepMCParticleTrigger : public SubsysReco
7678
bool m_doStableParticleOnly{true};
7779
float threshold{0.};
7880
int goal_event_number{1000};
81+
bool set_event_limit{false};
7982
int n_evts{0};
8083
int n_good{0};
81-
bool set_event_limit{false};
8284

8385
float _theEtaHigh{1.1};
8486
float _theEtaLow{-1.1};

generators/PHPythia8/PHPythia8.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,13 @@ int PHPythia8::Init(PHCompositeNode *topNode)
123123
std::cout << "PHPythia8 random seed: " << seed << std::endl;
124124

125125

126-
// this is empirical - something in the pythia8::init() method interferes
127-
// with our macros (it sets the tpc drift verlocity back to 0)
128-
// not the feintest idea right now what this could be
129-
// but saving the old cout state and restoring it aftwerwards
130-
// gets our tpc drift velocity back
126+
// pythia again messes with the cout formatting
131127
std::ios old_state(nullptr);
132-
old_state.copyfmt(std::cout);
128+
old_state.copyfmt(std::cout); // save current state
133129

134130
m_Pythia8->init();
135131

136-
std::cout.copyfmt(old_state);
132+
std::cout.copyfmt(old_state); // restore state to saved state
137133

138134
return Fun4AllReturnCodes::EVENT_OK;
139135
}
@@ -211,6 +207,9 @@ int PHPythia8::process_event(PHCompositeNode * /*topNode*/)
211207
bool passedGen = false;
212208
bool passedTrigger = false;
213209
// int genCounter = 0;
210+
// pythia again messes with the cout formatting in its event loop
211+
std::ios old_state(nullptr);
212+
old_state.copyfmt(std::cout); // save current state
214213

215214
while (!passedTrigger)
216215
{
@@ -286,6 +285,7 @@ int PHPythia8::process_event(PHCompositeNode * /*topNode*/)
286285
if (!success)
287286
{
288287
std::cout << "PHPythia8::process_event - Failed to add event to HepMC record!" << std::endl;
288+
std::cout.copyfmt(old_state); // restore state to saved state
289289
return Fun4AllReturnCodes::ABORTRUN;
290290
}
291291

@@ -306,6 +306,8 @@ int PHPythia8::process_event(PHCompositeNode * /*topNode*/)
306306

307307
++m_EventCount;
308308

309+
std::cout.copyfmt(old_state); // restore state to saved state
310+
309311
// save statistics
310312
if (m_IntegralNode)
311313
{

0 commit comments

Comments
 (0)