cwevent: Expanded event descriptor¶
cwevent is a command-line tool which extracts detailed
information about individual events (plays) in the data file. These
are grouped into two categories. There are 97 fields which are
compatible with the Retrosheet BEVENT event descriptor tool. These
are specified using the -f command-line flag. In addition, cwevent
offers a number “extended” fields which expand upon or give more
detailed information not easily accessed via the standard
fields. These are specified using the -x command-line flag.
Player substitutions are not events and therefore do not produce cwevent records. Use cwsub alongside cwevent when substitution data is needed, including changes made during a plate appearance.
Note
cwevent guarantees that the standard field numbers will match those used by BEVENT. Standard field numbers therefore can be treated as stable, and it should be safe to write scripts referring to them. Extended fields are provisional, and extended fields may be added or withdrawn in future versions. Extended fields are assigned numbers to maintain a logical cohesion, with related fields being grouped. Therefore, extended field numbers are not promised to be stable. It is recommended to use the field labels instead in writing scripts to process the output of cwevent extended fields.
See also
Command-line options for the command-line options shared by all Chadwick tools.
Field number |
Description |
Header |
|---|---|---|
0 |
Game ID |
|
1 |
Visiting team |
|
2 |
Inning |
|
3 |
Batting team |
|
4 |
Outs |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
Visitor score |
|
9 |
Home score |
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
Catcher |
|
19 |
First baseman |
|
20 |
Second baseman |
|
21 |
Third baseman |
|
22 |
Shortstop |
|
23 |
Left fielder |
|
24 |
Center fielder |
|
25 |
Right fielder |
|
26 |
Runner on first |
|
27 |
Runner on second |
|
28 |
Runner on third |
|
29 |
Event text |
|
30 |
Leadoff flag |
|
31 |
|
|
32 |
Defensive position |
|
33 |
Lineup position |
|
34 |
|
|
35 |
Batter event flag |
|
36 |
|
|
37 |
Hit value |
|
38 |
|
|
39 |
|
|
40 |
Outs on play |
|
41 |
Double play flag |
|
42 |
Triple play flag |
|
43 |
RBI on play |
|
44 |
Wild pitch flag |
|
45 |
Passed ball flag |
|
46 |
Fielded by |
|
47 |
Batted ball type |
|
48 |
Bunt flag |
|
49 |
Foul flag |
|
50 |
Hit location |
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
Stolen base for runner on first |
|
67 |
Stolen base for runner on second |
|
68 |
Stolen base for runner on third |
|
69 |
Caught stealing for runner on first |
|
70 |
Caught stealing for runner on second |
|
71 |
Caught stealing for runner on third |
|
72 |
Pickoff of runner on first |
|
73 |
Pickoff of runner on second |
|
74 |
Pickoff of runner on third |
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
New game flag |
|
79 |
End game flag |
|
80 |
Pinch-runner on first |
|
81 |
Pinch-runner on second |
|
82 |
Pinch-runner on third |
|
83 |
Runner removed for pinch-runner on first |
|
84 |
Runner removed for pinch-runner on second |
|
85 |
Runner removed for pinch-runner on third |
|
86 |
Batter removed for pinch-hitter |
|
87 |
Position of batter removed for pinch-hitter |
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
Event number |
|
Field number |
Description |
Header |
|---|---|---|
0 |
home team id |
|
1 |
batting team id |
|
2 |
fielding team id |
|
3 |
half inning (differs from batting team if home team bats first) |
|
4 |
start of half inning flag |
|
5 |
end of half inning flag |
|
6 |
score for team on offense |
|
7 |
score for team on defense |
|
8 |
runs scored in this half inning |
|
9 |
number of plate appearances in game for team on offense |
|
10 |
number of plate appearances in inning for team on offense |
|
11 |
start of plate appearance flag |
|
12 |
truncated plate appearance flag |
|
13 |
base state at start of play |
|
14 |
base state at end of play |
|
15 |
batter is starter flag |
|
16 |
result batter is starter flag |
|
17 |
ID of the batter on deck |
|
18 |
ID of the batter in the hold |
|
19 |
pitcher is starter flag |
|
20 |
result pitcher is starter flag |
|
21 |
defensive position of runner on first |
|
22 |
lineup position of runner on first |
|
23 |
event number on which runner on first reached base |
|
24 |
defensive position of runner on second |
|
25 |
lineup position of runner on second |
|
26 |
event number on which runner on second reached base |
|
27 |
defensive position of runner on third |
|
28 |
lineup position of runner on third |
|
29 |
event number on which runner on third reached base |
|
30 |
Responsible catcher for runner on first |
|
31 |
Responsible catcher for runner on second |
|
32 |
Responsible catcher for runner on third |
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
number of runs on play |
|
46 |
id of player fielding batted ball |
|
47 |
force play at second flag |
|
48 |
force play at third flag |
|
49 |
force play at home flag |
|
50 |
batter safe on error flag |
|
51 |
fate of batter (base ultimately advanced to) |
|
52 |
fate of runner on first |
|
53 |
fate of runner on second |
|
54 |
fate of runner on third |
|
55 |
runs scored in half inning after this event |
|
56 |
fielder with sixth assist |
|
57 |
fielder with seventh assist |
|
58 |
fielder with eighth assist |
|
59 |
fielder with ninth assist |
|
60 |
fielder with tenth assist |
|
61 |
unknown fielding credit flag |
|
62 |
uncertain play flag |
|
63 |
|
|
64 |
whether runner on first is an automatic runner |
|
65 |
whether runner on second is an automatic runner |
|
66 |
whether runner on third is an automatic runner |
|
Result batters and pitchers (fields 10-17)¶
In most cases, the pitcher and batter charged or credited with an event are the players in the game when the event occurs. However, Rule 9.15(b) governs how a strikeout is charged when a substitute batter enters with two strikes, and Rule 9.16(h) governs how a walk is charged when a relief pitcher enters during a plate appearance. The batter and pitcher fields identify the players in the game at the time of the event; the result batter and result pitcher fields identify the players credited or charged with the event.
Because a mid-plate-appearance substitution is not itself an event, cwevent does not emit a record at the point when the batter or pitcher changes. cwsub reports these substitutions together with the count and pitch sequence accumulated through the time of the change.
There is one known bug in the Retrosheet-provided tools regarding the result pitcher. When a relief pitcher enters the game, and then the next batter is retired on a fielder’s choice, the pitcher responsible for the runner put out is shown in the result pitcher field. While it is correct that the batter reaching base in this case would be charged to the former pitcher should he score, the purpose of the result pitcher field is to indicate the pitcher charged with the outcome of this particular event. In this case, for example, the relief pitcher is awarded one-third of an inning pitched; therefore, he should be the result pitcher, and then the previous pitcher should be (and is) listed in the responsible pitcher field for the batter in subsequent events.
In the case of switch-hitters, the batter hand and result batter hand fields are set to L or R, as appropriate, based upon the hand with which the pitcher throws. If the pitcher’s throwing hand is unknown, or if the batter’s batting hand is unknown, a question mark appears in these fields.
Pinch-hit flag (field 31)¶
This field is T if the batter is a pinch-hitter, and F if he is not. If a player enters the game as a pinch-hitter, and then bats again in the same inning because his team bats around, this field will be F for the player’s second plate appearance. To identify the cases where this occurs, consult the defensive position field (field 32), which will continue to be equal to 11 (or 12 for a pinch-runner) until that player assumes a defensive position.
Event type code (field 34)¶
All plays are categorized by their primary event type. Here is a list of all types and the corresponding codes used in this field. Codes marked “obsolete” are no longer used, or no longer appear in Retrosheet-produced play-by-play files.
Code |
Primary event |
|---|---|
0 |
Unknown (obsolete) |
1 |
None (obsolete) |
2 |
Generic out |
3 |
Strikeout |
4 |
Stolen base |
5 |
Defensive indifference |
6 |
Caught stealing |
7 |
Pickoff error (obsolete) |
8 |
Pickoff |
9 |
Wild pitch |
10 |
Passed ball |
11 |
Balk |
12 |
Other advance/out advancing |
13 |
Foul error |
14 |
Walk |
15 |
Intentional walk |
16 |
Hit by pitch |
17 |
Interference |
18 |
Error |
19 |
Fielder’s choice |
20 |
Single |
21 |
Double |
22 |
Triple |
23 |
Home run |
24 |
Missing play (obsolete) |
Sacrifice flags and eras (fields 36, 38, 39)¶
Chadwick in all cases applies the modern rules concerning the awarding of sacrifice hits, sacrifice flies, and official times at bat, regardless of the year indicated with the -y flag.
Plays on runners (fields 58-65)¶
Fields 58 through 65 give the destination of all runners, including the batter, as well as the fielding play made on them, if any. For the purposes of the destination fields, a code of 5 indicates the runner scored, and is charged as unearned, and a code of 6 indicates the runner scored, and is charged as unearned to the team, but earned to the pitcher. These codes only appear when the (NR) or (TUR) modifiers are explicitly used on the advancement code. There is no internal logic in Chadwick to ferret out which runs should be earned or unearned, as in many cases there is insufficient information, or the situation requires the judgment of the official scorer. Runners which are put out are reported as having an advancement of 0.
Automatic runners are reported using the extended fields
RUN1_AUTO_FL, RUN2_AUTO_FL, and RUN3_AUTO_FL. Each flag
indicates whether the runner occupying that base at the start of the
play is the result of an automatic-runner placement. Automatic
runners use the same destination codes as other runners.
For the purposes of tracking automatic runners, Chadwick follows the same convention as is used for assigning responsibility for runners to pitchers: in the event that an automatic runner is put out by batter action, the subsequent runner becomes marked as an automatic runner.
In most cases, the play on a runner indicates the fielding credits involved in putting him out. Chadwick also reports a fielding play on a runner when the runner is safe on a dropped throw, such as 3E1 or FC6.1X2(6E4).
Fielding errors (fields 51-57)¶
Up to three errors can be indicated in cwevent output. Supported error types are:
Ffor generic fielding errors;Dfor dropped or muffed balls; andTfor throwing errors.
Pitcher responsibility for runs (fields 75-77)¶
The Official Rules for charging runs to pitchers stipulate that if a pitcher is relieved in the middle of an inning with runners left on base, he is charged with runs if those runners (or the ones who replace them in the event of fielder’s choices) subsequently score in the inning. The current rule is Rule 9.16(g), the comment on which in the rules states:
It is the intent of Rule 9.16(g) to charge each pitcher with the number of runners he put on base, rather than with the individual runners. When a pitcher puts runners on base and is relieved, such pitcher shall be charged with all runs subsequently scored up to and including the number of runners such pitcher left on base when such pitcher left the game, unless such runners are put out without action by the batter.
Chadwick implements this by assigning “responsibility” for runners, and shifting those runners after fielder’s choices as appropriate to implement the rule. Fields 75 through 77 report the pitcher currently “charged” with runners on base using this method.
There is one special case to note in reporting these fields. As noted, a fielder’s choice does not absolve a departed pitcher for responsibility for a potential run. Ordinarily it is good enough to report the shift in responsibility at the start of the next play. However, consider the following scenario: The bases are loaded, with the runner on third (R3) the responsibility of Pitcher A and runners on second and first (R2 and R1) the responsibility of Pitcher B. The batter hits a ground ball and R3 is forced at home. Then, the catcher throws wildly trying to complete the double play, and as a result R2 scores. In this case, the run scored by R2 is charged to Pitcher A, not Pitcher B, i.e., the responsibility shifts in the middle of the play. In order to facilitate calculation of runs and earned runs allowed correctly from cwevent output, in this case, the record for the play will report R2 as being the responsibility of Pitcher A, i.e., it will report the responsibility after the mid-play shift.
This convention will not affect most applications. Indeed, the Official Rules technically do not have a concept of assigning responsibility to particular runners, and the contents of fields 75-77 only have meaning on plays in which the corresponding runners score. This convention may confuse certain calculations, however, including those which try to track what happens to inherited runners, if one does not take appropriate care to handle this very unusual case.
Catcher responsibility (extended fields 30-32)¶
Catcher responsibility is not an official statistic. Chadwick defines it as an analogue of pitcher responsibility, intended to support calculations such as catcher ERA.
When a batter becomes a runner, responsibility is assigned to the catcher who was in the game at the end of the batter’s plate appearance. Chadwick does not implement an analogue of the special pitcher-responsibility rule for a pitching change during a plate appearance. An automatically placed runner is assigned to the catcher in the game when the runner is placed. Subsequent catcher substitutions do not change responsibility for existing runners, and replacing a runner with a pinch-runner or courtesy runner also preserves the assignment.
On fielder’s choices, catcher responsibility shifts between runners
using the same rules Chadwick applies to pitcher responsibility.
Consequently, RUN1_RESP_CAT_ID, RUN2_RESP_CAT_ID, and
RUN3_RESP_CAT_ID report the catcher currently associated with each
runner under this convention; they do not represent an official
scoring credit or charge.
Fielding credits (fields 88-95)¶
The order in which Chadwick and the Retrosheet-provided tools list putouts and assists may vary. The number of plays on which this occurs is quite few, and generally in cases where there is a putout in the primary event as well as one in the baserunning modifiers. The words “first”, “second” and so on do not necessarily indicate chronological order of the credits, though in most cases they do.
Reporting of counts¶
The count element of a play record gives the ball-strike count
at the beginning of its pitch sequence. Standard fields 5 and 6,
BALLS_CT and STRIKES_CT, report the first and second characters
of this element, respectively, provided that it contains at least two
characters and neither character is ?. If either part of the count
is unknown, or the element is otherwise too short, both fields report
zero. Thus these fields cannot distinguish an unknown count from a
genuine count of 0-0.
The DiamondWare data model originally assumed that pitch-level data
for a game was one of all pitches, count only, or no pitches (see the
info,pitches metadata field). However, many Retrosheet files
contain count data for selected plate appearances, where known, and
use ? for an unknown number of balls or strikes.
Extended field 63, COUNT_TX, reports the count element verbatim,
including question marks. It therefore preserves the distinction
between an unknown count and 0-0. Together with PITCH_SEQ_TX and
EVENT_TX, it makes all three of the main elements of the play
record accessible in cwevent output.
For substitutions during a plate appearance,
cwsub reports the count, pitch sequence, and
cumulative pitch-type counts at the point of the substitution. Its
BALLS_CT and STRIKES_CT fields report zero for an unknown count,
following the same convention as cwevent, and its own
COUNT_TX field likewise reports the count verbatim so that an
unknown count can be distinguished from a genuine 0-0.
Pitch-type counts (extended fields 33-44)¶
These fields count pitch codes in PITCH_SEQ_TX for the plate
appearance represented by the event record. Each pitch code is
classified as follows:
Field |
Category |
Pitch codes |
|---|---|---|
|
balls |
|
|
called balls |
|
|
intentional balls |
|
|
pitchouts |
|
|
hit batters |
|
|
other balls |
|
|
strikes |
|
|
called strikes |
|
|
swinging strikes |
|
|
foul balls |
|
|
balls in play |
|
|
other strikes |
|
The fields count pitch-sequence entries, not changes to the official
ball-strike count. For example, a foul with two strikes is still
counted in PA_FOUL_STRIKE_CT. Codes in the pitch sequence which
are not listed above, such as pickoff attempts and other non-pitch
markers, are not counted.
Automatic balls (V) and automatic strikes (A) are classified
in the corresponding PA_OTHER_* fields, but are not included in
PA_BALL_CT or PA_STRIKE_CT because no pitch was thrown.
Consequently, the component fields do not necessarily sum to the ball
and strike totals.
These counts are only as complete as the pitch sequence in the source event file. A missing or partial pitch sequence produces zero or partial counts; the fields do not reconstruct pitches from the reported ball-strike count. For a substitution during a plate appearance, cwsub reports the same pitch-type counts as accumulated at the time of the substitution.