# Improved Measurements of Molecular Cloud Distances Based on Global Search

Qing-Zeng Yan Chang Yu-Che Fellow of Purple Mountain Observatory  Purple
Mountain Observatory and Key Laboratory of Radio Astronomy,
Chinese Academy of Sciences, 10 Yuanhua Road, Qixia District, Nanjing 210033,
People’s Republic of China  Ji Yang Purple Mountain Observatory and Key
Laboratory of Radio Astronomy,
Chinese Academy of Sciences, 10 Yuanhua Road, Qixia District, Nanjing 210033,
People’s Republic of China  Yang Su  Purple Mountain Observatory and Key
Laboratory of Radio Astronomy,
Chinese Academy of Sciences, 10 Yuanhua Road, Qixia District, Nanjing 210033,
People’s Republic of China  Yan Sun Purple Mountain Observatory and Key
Laboratory of Radio Astronomy,
Chinese Academy of Sciences, 10 Yuanhua Road, Qixia District, Nanjing 210033,
People’s Republic of China  Ye Xu Purple Mountain Observatory and Key
Laboratory of Radio Astronomy,
Chinese Academy of Sciences, 10 Yuanhua Road, Qixia District, Nanjing 210033,
People’s Republic of China  Hongchi Wang Purple Mountain Observatory and Key
Laboratory of Radio Astronomy,
Chinese Academy of Sciences, 10 Yuanhua Road, Qixia District, Nanjing 210033,
People’s Republic of China  Xin Zhou Purple Mountain Observatory and Key
Laboratory of Radio Astronomy,
Chinese Academy of Sciences, 10 Yuanhua Road, Qixia District, Nanjing 210033,
People’s Republic of China  Chen Wang Purple Mountain Observatory and Key
Laboratory of Radio Astronomy,
Chinese Academy of Sciences, 10 Yuanhua Road, Qixia District, Nanjing 210033,
People’s Republic of China

###### Abstract

The principle of the background-eliminated extinction-parallax (BEEP) method
is examining the extinction difference between on- and off-cloud regions to
reveal the extinction jump caused by molecular clouds, thereby revealing the
distance in complex dust environments. The BEEP method requires high-quality
images of molecular clouds and high-precision stellar parallaxes and
extinction data, which can be provided by the Milky Way Imaging Scroll
Painting (MWISP) CO survey and the Gaia DR2 catalog, as well as supplementary
$A_{V}$ extinction data. In this work, the BEEP method is further improved
(BEEP-II) to measure molecular cloud distances in a global search manner.
Applying the BEEP-II method to three regions mapped by the MWISP CO survey, we
collectively measured 238 distances for 234 molecular clouds. Compared with
previous BEEP results, the BEEP-II method measures distances efficiently,
particularly for those molecular clouds with large angular size or in
complicated environments, making it suitable for distance measurements of
molecular clouds in large samples.

Molecular clouds (1072); Interstellar medium(847); Interstellar molecules
(849); Interstellar dust extinction (837) ; Distance measure (395): Stellar
distance (1595);

††journal: ApJ††facilities: PMO 13.7 m, GAIA††software: astropy (Astropy
Collaboration et al., 2013), SciPy (Virtanen et al., 2020)

##  1 Introduction

The distance is a fundamental property of molecular clouds and is usually an
essential part of molecular cloud catalogs (e.g., Miville-Deschênes et al.,
2017; Colombo et al., 2019). Although distances are not intrinsic, they are
necessary for deriving physical properties of molecular clouds, such as the
mass and size.

Molecular cloud catalogs were empirically built with spectroscopic data in
position-position-velocity (PPV) space. For instance, Solomon et al. (1979)
and Solomon et al. (1987) used closed contours to define Giant Molecular
Clouds (GMCs), and apparently, different contour levels correspond to
different molecular cloud samples. With the expansion of data, mathematical
algorithms were involved to identify molecular clouds automatically in PPV
space. For example, Rice et al. (2016) identified 1064 high-mass molecular
clouds using dendrograms and the CfA-Chile survey (Dame et al., 2001), while
with the same data but an alternative hierarchical clustering algorithm,
(Miville-Deschênes et al., 2017) found 8107 molecular clouds.

However, in some regions, where molecular clouds are crowded in PPV space,
even mathematical algorithms are incapable of identifying molecular clouds
properly. In addition to the data quality effects, such as the resolution and
sensitivity (Yan et al., 2021b), the information provided by PPV data is
intrinsically incomplete. PPV data miss one dimension of position, and the
relationship between the radial velocity and the distance is not always one-
to-one. Here, we list three situations when identifying molecular clouds can
be problematic. First, low angular resolution observations would artificially
merge those molecular clouds that are close to each other (e.g., $<$ 1 pc),
and high angular resolutions are needed to distinguish them. Secondly, in the
first and fourth Galactic quadrants, one radial velocity may correspond to
both near and far distance components (Reid et al., 2009), and due to the
cloud-cloud velocity dispersion (about 5 km s-1, Su et al., 2021), the
association between the radial velocity and the distance of local molecular
clouds is also weak. Thirdly, toward the Galactic anticenter region (e.g.,
$l=180^{\circ}$), the radial velocity is close to zero and provides little
information about the distance. Consequently, measuring distances to molecular
clouds identified in PPV space is particularly important.

Various methods have been developed to obtain molecular cloud distances, but
they all have limitations. Those methods can be broadly categorized as either
“low accuracy” or “high accuracy”. For instance, counting stars (Wolf, 1923)
is a low accuracy method that suffers from the large systematic errors
introduced by the assumed distribution of stars. Another low accuracy method
is to consult close (judged by the angular distance) OB-associations (Marton
et al., 2019), but the relationships between OB-associations and their nearby
molecular clouds are largely unclear. The widely-used kinematic distances,
which are based on the rotation curve of the Milky Way, also yield large
errors, particularly for local molecular clouds (e.g., Reid et al., 2009).

Measuring molecular cloud distances accurately is difficult, but achievable.
For example, one can use the trigonometric parallaxes of masers as proxies for
distances of their host molecular clouds (Xu et al., 2006; Reid et al., 2019;
VERA Collaboration et al., 2020), and this maser-parallax method is
particularly useful for high-mass star-forming regions. However, not all
molecular clouds have maser emission (Duarte-Cabral et al., 2021), and being
point sources, masers may only poorly represent distances of extended
structures (Zucker et al., 2018). Young stellar objects (YSOs) is also able to
reveal the distances of their natal molecular clouds, and in addition, YSOs
can be used to investigate the structure and dynamic properties of local star-
forming regions (e.g., Roccatagliata et al., 2020). This YSO method is only
applicable to nearby star-forming regions (Zari et al., 2018; Dzib et al.,
2018), because distant YSOs are faint in the visible band due to the
interstellar extinction. The interstellar extinction, however, is not always a
bad thing, as it provides another approach to infer molecular cloud distances.
In principle, the extinction of stars behind (background) molecular clouds is
larger than that of stars in front of (foreground) molecular clouds along the
line of sight, and the extinction jump at specific distances corresponds to
molecular cloud distances. This extinction method belonged to low accuracy
methods, but its accuracy has been improved significantly owing to the release
of the Gaia DR2 catalog (Gaia Collaboration et al., 2016, 2018).

In regions where molecular clouds are well-separated in both position-
position-position (PPP) and PPV space, the difference between foreground and
background stellar extinction is sufficient to reveal molecular cloud
distances. For example, Zucker et al. (2019, 2020) and Yan et al. (2019b)
obtained distances to many molecular clouds at high Galactic latitudes, with
distance errors usually less than 10%.

However, large-scale CO surveys usually focus on the Galactic plane, where the
dust environment is complicated. In addition, with the increase of sensitivity
and angular resolutions, those surveys detect a large number of molecular
clouds that have no distance indicators (e.g., Yan et al., 2021a), such as
masers, YSOs, or adjacent OB stars. Consequently, we need more sophisticated
methods to measure molecular cloud distances for large-scale sensitive CO
surveys.

Yan et al. (2019a) proposed a background-eliminated extinction-parallax (BEEP)
method to accurately measure molecular cloud distances in the Galactic plane,
based on CO maps of the Milky Way Imaging Scroll Painting (MWISP) survey (Su
et al., 2019) and the Gaia DR2 catalog. The BEEP method classifies on- and
off-cloud stars with high-quality CO maps, and uses off-cloud stars to remove
the extinction background of on-cloud stars, thereby revealing molecular
distances accurately. The BEEP method has been shown to work well in three
regions mapped by the MWISP survey (Yan et al., 2019a, 2020, 2021a).

Nonetheless, applying the BEEP method to large or complicated molecular clouds
is not straightforward. Large-scale CO surveys with high sensitivity identify
many molecular clouds with large angular sizes or in complicated environments
(e.g., see the “Phoenix” and “River” clouds of Su et al., 2020), causing two
problems in applying the BEEP method: (1) low efficiency of selecting pairs of
on- and off-cloud stars and (2) significant variation of extinction background
across molecular clouds. The BEEP method requires pairs of on- and off-cloud
stars, and the choice of on- and off-cloud star samples is mostly determined
by eye. For example, the on- and off-cloud regions are usually chosen near the
edge of molecular clouds where the gradient of the integrated intensity is
large. Several pairs of on- and off-cloud stars may need to be tested before a
reliable distance is derived. Evidently, this requires careful scrutiny of
individual cases, is too laborious and time-consuming to be practical for
large samples, and the yielding results may not be optimal.

In this work, we refine the BEEP method to make it more feasible. The improved
method, BEEP-II, is designed to obtain comprehensive distances via building
pairs of on- and off-cloud stars across molecular clouds and applying the BEEP
method multiple times, so it should improve the distance precision and isolate
those molecular clouds that have multiple distance components. The BEEP-II
method is expected to be able to measure distances to molecular clouds with
large angular size or in complicated environments.

This paper is organized as follows. The next section (Section 2) describes the
CO and Gaia DR2 data, as well as the cloud identification method. Section 3
demonstrates the procedure of the BEEP-II method. Section 4 displays distances
of three regions mapped by the MWISP survey. Discussions are presented in
Section 5, and we summarize the conclusions in Section 6.

##  2 CO Data and Molecular Cloud catalogs

Table 1: Molecular Cloud Distances in the Literature Based on the MWISP CO Survey.  Quadrant | $l$ | $b$ | $V_{\rm LSR}$ | Algorithm | Total NumberaaThis only takes into account molecular clouds with angular areas larger than 0.015 deg2, including incomplete ones in PPV space. | Cloud Distances | Reference
---|---|---|---|---|---|---|---
| (∘) | (∘) | (km/s) |  |  |  |
First | [25.8, 49.7] | [-5, 5] | [-6, -30] | SCIMESbbSpectral Clustering for Interstellar Molecular Emission Segmentation (SCIMES, Colombo et al., 2015). | 898 | 28 | Yan et al. (2020)
Second | [104.75, 150.25] | [-5.25, 5.25] | [-95, 25] | DBSCAN | 1677 | 98ccIncluding 22 distances of the largest molecular cloud, see Figure 5 of Yan et al. (2021a). | Yan et al. (2021a)
Third | [209.75, 219.75] | [-5, 5] | [0, 70] | dendrogramsddSee Rosolowsky et al. (2008) for details of dendrograms. | 31 | 11 | Yan et al. (2019a)

###  2.1 CO and Gaia DR2 Catalog

The CO data are part of the MWISP111http://www.radioast.nsdc.cn/mwisp.php CO
survey (Su et al., 2019) conducted with the Purple Mountain Observatory (PMO)
13.7 m millimeter telescope. The MWISP survey maps three CO isotopologue
lines, ${}^{12}\mathrm{CO}~{}(J=1\rightarrow 0)$,
${}^{13}\mathrm{CO}~{}(J=1\rightarrow 0)$, and
$\mathrm{C}^{18}\mathrm{O}~{}(J=1\rightarrow 0)$; however, only
${}^{12}\mathrm{CO}$ is used in this work. The angular and velocity
resolutions of the ${}^{12}\mathrm{CO}$ maps are approximately 49″ and 0.2 km
s-1, respectively. CO maps are regridded into pixels of 30″, corresponding to
an rms noise of about 0.49 K.

In this work, the BEEP-II method is applied to three regions that have been
mapped by the MWISP survey. Table 1 lists their $l$, $b$, and $V_{\rm LSR}$
ranges, as well as the BEEP results (Yan et al., 2019a, 2020, 2021a).

The Gaia DR2 catalog (Gaia Collaboration et al., 2016, 2018) provides an
enormous number of measurements of stellar parallaxes and extinction in the
$G$ band ($A_{G}$), as well as an extra $V$-band extinction ($A_{V}$) catalog
(Anders et al., 2019). Although the Gaia Early Data Release 3 (EDR3) improves
the parallax precision by 30% (Gaia Collaboration et al., 2020), the $A_{G}$
and $A_{V}$ data have not been updated, so we still use the Gaia DR2 data.
Stellar parallax errors are required to be less than 20%, and all stars
farther than 4 kpc ($<$ 0.25 mas) are removed. Corrections of systematic
parallax errors follow Anders et al. (2019), and in the distance measurement,
$A_{G}$ and $A_{V}$ extinction data are used separately.

###  2.2 Molecular Cloud Samples

We use the DBSCAN222https://scikit-
learn.org/stable/modules/generated/sklearn.cluster.DBSCAN.html algorithm (Yan
et al., 2020) to draw molecular cloud samples from PPV data cubes. Integrated
intensity maps of molecular clouds identified with DBSCAN usually have clear
edges, suitable for distance measurements with the BEEP method, which requires
off-cloud regions to remove unrelated extinction fluctuations.

DBSCAN determines regions of molecular clouds in PPV space with two
parameters, eps and MinPts. Eps is a distance threshold in specified metrics,
and if the distance between two points is less than or equal to eps, they are
considered neighbors. For a three-dimensional array, eps has three canonical
values, 1, $\sqrt{2}$, and $\sqrt{3}$, which are referred to as connectivity
1, 2 and 3, respectively. Once the connectivity is assigned, MinPts specifies
the minimum neighbors for a voxel to be considered a core point. Connected
core points, as well as their neighbors, define molecular clouds.

Yan et al. (2020) found that low MinPts values readily identify noise
fluctuations and high MinPts values cause high fractions of missed flux. They
suggested intermediate MinPts values for each connectivity, and the difference
between three DBSCAN parameter combinations is insignificant. In this work, we
adopt the same parameter settings with Yan et al. (2021a), i.e., MinPts = 4
and connectivity = 1, because connectivity 1 possesses the highest
compactness, and the DBSCAN parameters are constant across the PPV space. The
brightness cutoff of CO data cubes is 2$\sigma$, about 1 K for
${}^{12}\mathrm{CO}$. $\sigma$ is calculated for each spectrum, approximated
by the rms of negative values. Criteria used to filter noise structures are
also applied: (1) the minimum voxel number is 16; (2) the minimum peak
brightness temperature is 5$\sigma$; (3) the integrated map contains at least
one compact 2$\times$2 (60″$\times$60″) region; (4) the minimum number of
velocity channels is 3. The third criterion requires at least a complete beam
in the integrated map.

In addition to the above-mentioned four criteria, we further remove molecular
clouds that touch the edge of PPV data cubes. Only a fraction of the mass and
angular areas is observed for those molecular clouds, and since the fraction
is unknown, they are excluded in the distance examination.

Molecular samples in the second Galactic quadrant are identical with those of
Yan et al. (2021a), except for the removal of incomplete clouds, but they are
significantly different from those in the first (Yan et al., 2019a) and third
(Yan et al., 2020) Galactic quadrant, due to the use of alternative
algorithms.

##  3 The BEEP-II method

In this section, we present details of the BEEP-II method, an improved version
of the BEEP method. A visualization of the BEEP and the BEEP-II methods is
presented in Figure 1.

The BEEP method (Yan et al., 2019a) is developed to measure molecular cloud
distances in the Galactic plane. Due to the dust component, background stars
in on-cloud regions have, on average, larger extinction than those in off-
cloud regions. For regions at high Galactic latitudes, there is usually only
one nearby molecular cloud along each line of sight, and the variation of
extinction is regular (Yan et al., 2019b). Specifically, the extinction of
both foreground and background on-cloud stars shows Gaussian distributions.
However, in the Galactic plane where molecular clouds are crowded, the
extinction variations are irregular, causing gradients, and special treatments
are needed. In principle, the BEEP method uses the extinction of off-cloud
stars as a baseline, thereby removing the extinction variation that is
unrelated to targeting molecular clouds.

The BEEP method requires two data sets: high-quality images of molecular
clouds and large numbers of stellar parallax and extinction measurements.
Images of molecular clouds are used to distinguish on- and off-cloud stars,
while stellar parallax and extinction are used to reveal the extinction jump
caused by molecular clouds. It has been shown that the BEEP method is
effective when applied to the MWISP CO survey and the Gaia DR2 catalog (Yan et
al., 2019a, 2020, 2021a). However, the BEEP method hinges on the selection of
on- and off-cloud stars, which is usually performed with a trial-and-error
strategy. The efficiency of this strategy is low, and it is hard to apply the
BEEP method to molecular clouds with large angular size or in complicated
environments.

Here, we propose a refinement of the BEEP method, called BEEP-II, which is
composed of three steps. First, we explore parameter combinations to select
pairs of on- and off-cloud stars, deriving distances with the BEEP method for
each pair. Secondly, because distances should be detected multiple times for a
molecular cloud with a clear extinction jump, we cluster distances of a
molecular cloud in 3D physical space and select the optimal parameter
combination for each cluster. In the third step, we double check distances of
clusters via MCMC sampling.

###  3.1 Parameter Combinations

Figure 1: Principles of the BEEP and BEEP-II methods. The green and blue dots
represent variations of $A_{V}$ against the heliocentric distances for on- and
off-cloud stars, respectively. The BEEP method removes extinction background
in on-cloud stars with off-cloud stars, while the BEEP-II method examines
multiple pairs of on- and off-cloud stars along the edge of molecular clouds.
$\sum$ signifies combining multiple BEEP cases, and the collection of BEEPCj
is the optimal cases selected for clusters of BEEPi.

To select a pair of on- and off-cloud stars, the BEEP-II method requires four
parameters. Each pair of on- and off-cloud stars is confined within a circular
region, which contributes two parameters: a center ($C_{0}$) and a radius
($R_{0}$). The remaining two parameters are the distance cutoff ($D_{\rm
cut}$, in pc) and on-cloud CO cutoff ($\rm CO_{cut}$, in K km s-1). All stars
with distances larger than $D_{\rm cut}$ are removed, and the setting of
$D_{\rm cut}$ avoids the interference of distant background stars, which is
necessary for measuring distances of nearby molecular clouds accurately.

On-cloud $\rm CO_{cut}$ and off-cloud $\rm CO_{cut}$ have different meanings.
On-cloud stars are removed if the integrated intensity toward them is less
than on-cloud $\rm CO_{cut}$, while off-cloud stars are removed if the
integrated intensity toward them is larger than off-cloud $\rm CO_{cut}$. On-
cloud $\rm CO_{cut}$ removes background stars that have low extinction, making
the extinction jump clear, while off-cloud $\rm CO_{cut}$ removes stars that
may have been significantly affected by other molecular clouds. High levels of
on-cloud $\rm CO_{cut}$ can only be used when on-cloud stars are sufficient to
trace foreground and background extinction distributions.

The $D_{\rm cut}$ list is 300, 500, 1000, 1500, 2000, 2500, and 3000 pc. As
demonstrated by Figure 3 of Yan et al. (2019b), the $D_{\rm cut}$ effect is
insignificant as long as the extinction jump is clear. Ideally, a fixed
$D_{\rm cut}$ of 3000 pc is sufficient, given that the extinction
distributions of both foreground and background stars are all Gaussian.
However, for nearby molecular clouds, we use large angular areas (usually
larger than 1 square degree) to collect as many on-cloud stars as possible,
and it is important to remember that large angular areas are likely to include
other molecular clouds along the line of sight at far distances, deforming the
Gaussian distribution of background stellar extinction. $D_{\rm cut}$ removes
distant stars to make sure that background stars are not too far from each
other. Since we have no prior information about molecular cloud distances, we
try many $D_{\rm cut}$ values. Considering the distance errors and the
insignificance of $D_{\rm cut}$ effects, a step of 500 pc suffices.

The on-cloud $\rm CO_{cut}$ list is 2, 3, 4, and 5 K km s-1, while the off-
cloud $\rm CO_{cut}$ is 1 K km s-1, which is fixed. Those settings are
determined according to the rms noise of the integrated intensity maps, which
is about 1 K km s-1. The off-cloud $\rm CO_{cut}$ corresponds to about
1$\sigma$, and the on-cloud $\rm CO_{cut}$ ranges from 2$\sigma$ to 5$\sigma$.
On-cloud $\rm CO_{cut}$ removes low-extinction stars to increase the contrast
between background and foreground extinction, at the cost of decreasing the
number of on-cloud stars. Consequently, there is a trade-off between the
clearness of extinction jump and the number of on-cloud stars. Yan et al.
(2021a) use a fixed value of 4 K km s-1 for on-cloud $\rm CO_{cut}$, but for
small molecular clouds, lower $\rm CO_{cut}$ values are better because lower
on-cloud $\rm CO_{cut}$ involves more on-cloud stars and yields more accurate
distance results. There is also a trade-off for off-cloud $\rm CO_{cut}$, with
1$\sigma$ threshold retaining most off-clouds stars that are not significantly
affected by other molecular clouds.

$C_{0}$ and $R_{0}$ determine the circle region that contains on- and off-
cloud stars. Considering $R_{0}$ as an angular size, it will be generally
larger for nearby molecular clouds than for distant molecular clouds of
comparable physical size. On the other hand, if we consider $R_{0}$ to
represent physical size, then it is independent of distance. However, the
conversion between physical and angular sizes requires prior knowledge of the
distance, which may be estimated to be $D_{\rm cut}/2$.

The $C_{0}$ list is built from edge points (pixels) of integrated intensity
maps of molecular clouds. (Voxels outside cloud regions are masked before the
integration.) Examining all edge points is computationally expensive, so we
designed a way to select a subset of edge points that are well separated from
each other but are still dense enough to discern molecular cloud components.
The typical size of molecular clouds is 10 pc (Heyer & Dame, 2015), so we use
5 pc as a separation between $C_{0}$. The angular size that corresponds to 5
pc is calculated by assuming that molecular clouds are at a distance of
$D_{\rm cut}/2$. Initially, we measure all angular distances from edge points
to the centroid position of molecular clouds, and append two edge points,
corresponding to the largest and smallest angular distance, to the $C_{0}$
list. The centroid position, provided by the molecular cloud catalog (Yan et
al., 2020), of molecular clouds is the average $l$ and $b$ (of voxels)
weighted by the brightness temperature. Secondly, we remove edge points that
are within 5 pc of the current $C_{0}$ list. The distance from a point to the
$C_{0}$ list is defined to be the minimum distance between the point and
elements of $C_{0}$. Thirdly, if there are any edge points left, we add the
closest to the $C_{0}$ list and repeat the second step. The distance to the
third step is recursively performed until no edge points are left.

The $R_{0}$ list for each $C_{0}$ is 5, 10, and 15 pc, and the corresponding
angular size is calculated by assuming that the molecular cloud distance is
$D_{\rm cut}/2$. For a molecular cloud at 500 pc, 15 pc is equivalent to
1$\fdg$7, too far from molecular clouds on the sky. Consequently, we restrict
all off-cloud stars within 0$\fdg$5 of molecular cloud edge points.

Lengths of $\rm CO_{cut}$, $D_{\rm cut}$, and $R_{0}$ lists are 4, 7, and 3,
respectively, while the list of $C_{0}$ depends on the sizes of molecular
clouds. Since the $C_{0}$ list contains at least 2 points, the minimum number
of parameter combinations is 168 (4$\times$7$\times$3$\times$2). The $C_{0}$
length grows fast for large molecular clouds, and to keep the total number of
parameter combinations low, we require lengths of $\rm CO_{cut}$, $D_{\rm
cut}$, and $R_{0}$ as short as possible. For each parameter combination, we
select on- and off-cloud stars accordingly and estimate a distance with the
method described in the next section.

###  3.2 Fast Distance Estimate

Figure 2: A demonstration of distance detection with the integrated
extinction, $I$. This molecular cloud is simulated at 800 pc with foreground
extinction of 0.1 mag and background extinction of 0.5 mag, both of which have
a standard deviation of 0.5 mag. The left panel shows the variation of $A_{V}$
with respect to the distance. The middle panel plots values of $I$ derived
with Equation 4. The blue line represents the foreground part of $I$, while
the green line represents the background part. The solid and dashed red lines
mark the distance and error derived with $I$. The right panel zooms in the
cross point in the middle panel, and presents the 1$\sigma$ range (vertically)
with dashed blue and green lines, where $\sigma$ is the rms residual of the
$I$ fitting. The distance error is defined to be the overlapping distance
range of foreground and background $I$ strips with dashed blue and green lines
as boundaries.

In practice, the BEEP-II method hinges on fast and accurate distance
estimates, because it examines a large number of parameter combinations. MCMC
sampling, however, is too time-consuming to satisfy this requirement, so we
propose to use piecewise linear regression to solve this problem.

Ideally, the foreground and background extinction of on-cloud stars show
Gaussian distributions after removing the background extinction with off-cloud
stars. The background extinction is expressed in a monotonically increasing
function with respect to the distance to the Sun, and is subtracted from the
on-cloud stellar extinction (Yan et al., 2019a). However, a direct piecewise
linear regression (with slope zero) between the extinction and the distance of
on-cloud stars usually yields incorrect results, due to the large dispersion
of extinction.

An alternative approach is to integrate the extinction against the distance,
making the foreground and background extinction-distance relationships more
distinguishable. Specifically, given $N$ on-cloud stars, with distances,
$D_{i}$ (in increasing order), and extinction, $A_{i}$ (with standard
deviation $\Delta A_{i}$), where $1\leq i\leq N$, the integration interval for
each $A_{i}$ is defined as

$\mathrm{d}D_{i}=\left\\{\begin{array}[]{ll}\frac{1}{2}\left(D_{2}-D_{1}\right),\
i=1,\\\
\frac{1}{2}\left(D_{i+1}-D_{i}\right)+\frac{1}{2}\left(D_{i}-D_{i-1}\right),\
2\leq i\leq N-1,\\\ \frac{1}{2}\left(D_{N}-D_{N-1}\right),\
i=N,\end{array}\right.$ (1)

and the integrated extinction, $I_{i}$, is defined as

$I_{i}=\sum_{j=1}^{i}A_{j}\mathrm{d}D_{j},$ (2)

where $1\leq i\leq N$ and $A_{j}$ is the stellar extinction with background
extinction removed using off-cloud stars. $I_{i}$ is still a piecewise linear
function with two steps, and slopes of the first and second segments
correspond to the mean of foreground and background extinction. The standard
deviation of $I_{i}$ is

$\Delta I_{i}=\sqrt{\sum_{j=1}^{i}\left(\Delta
A_{j}\mathrm{d}D_{j}\right)^{2}}.$ (3)

The relative error of $\Delta I_{i}$ is usually larger than 50%, much larger
than the distance error of $D_{i}$, so only the error of $I_{i}$ is considered
in piecewise linear regression. However, both the distance and extinction
errors are taken into account in the step of MCMC sampling.

The effect of Equation 2 is demonstrated in Figure 2, using a molecular cloud
at 800 pc. The foreground and background extinctions are 0.1 and 0.5 mag,
respectively, both having standard deviations of 0.5 mag. The left-hand panel
displays the distribution of $A_{i}$, while the middle panel plots values of
$I_{i}$.

We use a two-step piecewise linear function to fit four parameters: $D$, $Y$,
$\mu_{1}$, and $\mu_{2}$. $D$ and $Y$ represent the distance and the
integrated extinction of the breakpoint, while $\mu_{1}$ and $\mu_{2}$ are the
slopes of the foreground and background $I$, respectively. Based on the
definition of $I$, $\mu_{1}$ and $\mu_{2}$ also represent average values of
the foreground and background extinction, respectively. The specific form of
$I_{i}$ is

$I_{i}=\left\\{\begin{array}[]{ll}Y+\mu_{1}*(D_{i}-D),\ \mathrm{for}\
D_{i}\leq D,\\\ Y+\mu_{2}*(D_{i}-D),\ \mathrm{for}\
D_{i}>D,\end{array}\right.$ (4)

where $D_{i}$ is the corresponding distance of $I_{i}$. We fit Equation 4 with
curve_fit in the Python package of scipy. As shown in Figure 2, the integrated
extinction, $I$, reveals the distance accurately.

However, the error of $D$ given by curve_fit is too small to represent true
distance errors. Alternatively, we define a distance error based on the
residual rms of the $I$ fitting. As shown in the right-hand panel of Figure 2,
the distance error is defined as the overlapping distance range of foreground
and background $I$ strips, which have vertical widths of 2$\sigma$, where
$\sigma$ is the residual rms, different for foreground and background stars.

In this case of simulation, the BEEP-II method derives the molecular distance
accurately, even for foreground and background star samples with large
extinction dispersion. In the next section, we propose extra criteria to
reject nonoptimal or incorrect distance results.

###  3.3 Rejecting False Distance Detections

In this section, we describe the criteria used to reject nonoptimal parameters
or incorrect distance estimates. The fast distance estimation method described
in the previous section always provides solutions, but some may be false or
nonoptimal. For instance, if a molecular cloud is at 900 pc, all distances
produced with $\rm CO_{cut}$ 300 or 500 pc are incorrect. $\rm CO_{cut}$ 1000
pc may give correct distances, but $\rm CO_{cut}$ 1500 pc is obviously a
better choice, because more background stars are used to describe the
background extinction distribution.

The following criteria place constraints on $D$, $\mu_{1}$, $\mu_{2}$, and the
extinction of off-cloud stars:

  1. 1.

The relative $D$ error defined in the right panel of Figure 2 is at most 20%.

  2. 2.

If $D\leq\left(D_{\rm cut}-1500\right)\ \rm pc$, this parameter combination is
rejected, because there is a better one, which is $\left(D_{\rm
cut}-500\right)$ pc. To keep on- and off-cloud stars close to each other,
$D_{\rm cut}$ should not be too large.

  3. 3.

If $D>\left(D_{\rm cut}-100\right)\ \rm pc$ and $D_{\rm cut}<3000\ \rm pc$,
this parameter combination is rejected, because there is a better one, which
is $\left(D_{\rm cut}+500\right)$ pc. $D_{\rm cut}$ should be large enough to
include sufficient background stars.

  4. 4.

If $D<200\ \rm pc$ and $D_{\rm cut}>300\ \rm pc$, this parameter combination
is rejected, because there is a better one, which is 300 pc.

  5. 5.

If $\mu_{1}$ is larger than $\mu_{2}$, this parameter combination is rejected.
This criterion means that the foreground extinction should be smaller than the
background extinction.

  6. 6.

The number of background off-cloud stars is required to be at least half the
number of background on-cloud stars. This criterion is used to reject regions
where off-cloud stars are insufficient to trace the extinction variation near
molecular clouds.

  7. 7.

The Gaussian distributions of the extinction of background and foreground on-
cloud stars are separated from each other, as well as those of background on-
cloud stars and background off-cloud stars. The separation of two Gaussian
distributions, $\mathcal{N}(A_{1},\,\sigma_{1})$ and
$\mathcal{N}(A_{2},\,\sigma_{2})$, requires $|A_{1}-A_{2}|>\sigma_{2}$ or
$|A_{1}-A_{2}|>\sigma_{1}$, where $A_{1}$ and $A_{2}$ are the means of two
Gaussian distributions and $\sigma_{1}$ and $\sigma_{2}$ are their standard
deviations.

Those seven criteria effectively reject false detections. We cluster remaining
distance results and select optimal parameters in the next section.

###  3.4 Clustering

The clustering operation is used to determine distance components of molecular
clouds. For small molecular clouds, this refers to distance components along
the line of sight, while for large molecular clouds, this also includes
components that are far from each other across the sky. In addition, the
clustering significantly reduces the number of parameter combinations fed to
MCMC sampling.

The clustering is done in the 3D physical space, calculated with $C_{0}$ and
distances of circular regions. The X axis corresponds to
$\left(l,b\right)=\left(90{{}^{\circ}},0{{}^{\circ}}\right)$, while the Y axis
corresponds to $\left(l,b\right)=\left(180{{}^{\circ}},0{{}^{\circ}}\right)$.
The Z axis is perpendicular to the X-Y plane, i.e., $b=90{{}^{\circ}}$. The
algorithm we used is a hybrid of DBSCAN and k-means. DBSCAN is efficient in
identifying outliers, while k-means is useful to split samples into a desired
number of parts.

DBSCAN has two parameters, eps and MinPts. Eps specifies the maximum distance
between two neighbors in the above-mentioned 3D physical space. MinPts is the
minimum number of neighbours for a point to form a dense region, and dense
regions together with their neighbors form clusters. Because DBSCAN is only
used to identify evident outliers, we adopt loose parameters: 200 pc for eps
and 3 for MinPts. Distances not included in DBSCAN clusters are considered
outliers.

After removing obvious outliers with DBSCAN, we cluster the remaining
molecular cloud distances with k-means, weighted by the reciprocal of the
distance variance. K-means splits data points by minimizing the variance with
respect to a certain number of centroids. The problem of k-means is that we
have to specify the total number of clusters, which is unknown.

However, for molecular cloud distances, we can set criteria to prevent them
from being split into too many small pieces, and we require that the
coordinate differences between cluster centroids in all three axes are larger
than 20% and 10 pc. 20% follows the parallax error threshold of Gaia DR2
stars, and 10 pc is the typical size of molecular clouds. Specifically, we
adopted a binary-splitting process to generate k-means clusters. Starting from
one single cluster that includes all distances, existing clusters are
recursively divided into two. If no clusters can be split without violating
the above-mentioned criteria, k-means stops.

###  3.5 The Optimal Parameter Combination

For each cluster produced in Section 3.4, we select one optimal parameter
combination (i.e. a combination of $D_{\rm cut}$, $\rm CO_{cut}$, $C_{0}$, and
$R_{0}$) corresponding to a distance derived with a pair of on- and off-cloud
star samples. Because the distance error is required to be small, we reject
half of the parameter combinations that yield the largest distance errors. The
optimal parameter combination is selected from the remaining half.

In general, the optimal parameter combination of a cluster is selected by
maximizing the number of foreground ($\leq D$) or background ($>D$) on-cloud
stars, depending on whichever has fewer stars. Specifically, if the mean (over
all cases in a cluster) number of foreground on-cloud stars is less than half
the mean number of background on-cloud stars, the optimal parameter
combination is the one that has the largest number of foreground on-cloud
stars. Likewise, if the mean number of foreground on-cloud stars is larger
than half the number of background on-cloud stars, the optimal parameter
combination is the one that has the largest number of background on-cloud
stars. However, when numbers of foreground and background on-cloud stars are
balanced, i.e., the difference is less than half, we choose the parameter that
maximizes the total number of on-cloud stars.

If the foreground or background on-cloud stars are abundant, a smaller $D_{\rm
cut}$, a smaller $R_{0}$, or a higher $\rm CO_{\rm cut}$ is tried. The
abundance of on-cloud stars means that at least one parameter combination
yields a total number of on-cloud stars exceeding 100, with the number of
foreground and background on-cloud stars each exceeding 50. In this scenario,
we try stricter parameter combinations which include fewer on-cloud stars, but
with less contamination of background stars (a smaller $D_{\rm cut}$), more
accurate background extinction elimination (a smaller $R_{0}$), or clearer
jumps of extinction (a higher $\rm CO_{\rm cut}$).

If on-cloud stars are abundant, we use a trial-and-error approach to obtain
better parameter combinations. Specifically, we keep removing the second
largest $D_{\rm cut}$ until on-cloud stars will be no longer abundant after
removing parameter combinations with the maximum $D_{\rm cut}$. Similar
procedures are applied to $R_{0}$ and $\rm CO_{\rm cut}$, and the trial
sequence of parameters is $D_{\rm cut}$, $R_{0}$, and $\rm CO_{\rm cut}$.
Because $D_{\text{cut}}$ and $R_{0}$ have a less significant effect on the on-
cloud stars sample, they are adjusted before $\rm CO_{\rm cut}$. This trial-
and-error approach only operates on cases with abundant on-cloud stars, and at
least one abundant case remains afterward.

We impose an extra criterion on $D_{\rm cut}$ to prevent the process of
rejecting abundant cases from going too far. In all rejected cases, $D_{\rm
cut}$ is required to be at least 1.5$\times$$D_{\rm avg}$ pc, where $D_{\rm
avg}$ is the average distance (weighted by the inverse distance variance) of
the cluster.

Table 2: Statistics of Molecular Cloud Distances in Three RegionsaaSee Table 1 for a comparison with previous BEEP results..  Quadrant | $l$ | $b$ | $V_{\rm LSR}$ | Algorithm | Total NumberbbThis only takes into account molecular clouds that are complete in the PPV space with angular areas larger than 0.015 deg2. | Measured Clouds | Cloud Distances
---|---|---|---|---|---|---|---
| (deg) | (deg) | (km/s) |  |  |  |
First | [25.8, 49.7] | [-5, 5] | [-6, -30] | DBSCAN | 359 | 27 | 27
Second | [104.75, 150.25] | [-5.25, 5.25] | [-95, 25] | DBSCAN | 1618 | 155 | 159ccOne clouds has multiple distances.
Third | [209.75, 219.75] | [-5, 5] | [0, 70] | DBSCAN | 237 | 52 | 52
Figure 3: Fast distance estimate with the BEEP-II method in regions of (a)
G134.8$+$01.4 and (b) G109.7$+$01.8. Green and gray dots represent raw on- and
off-cloud stars with the extinction background removed, respectively. Blue
lines indicate piecewise linear regression of $A_{V}$ integration according to
Equation 4. Distances derived from $A_{V}$ integration are displayed in the
left and middle panel, and as a comparison, a direct fitting of foreground and
background extinction is shown in the right panel.

The optimal parameter combination is used to derive the distance of each
cluster, and the extinction jump is required to be clear. If the distance to a
molecular cloud is measured using both $A_{G}$ and $A_{V}$, the one with a
smaller distance error or with a clearer extinction jump was selected. The
selection of good MCMC sampling results and the choice of $A_{G}$ or $A_{V}$
distances is judged by eye.

Figure 4: Clustering of (a) G134.8$+$01.4 with $A_{V}$ and (b) G109.7$+$01.8
with $A_{G}$. For each molecular cloud, the above left panel displays the
distance and error, and the other three panels show the 2D projection of
clusters in three planes. The coordinate origin is placed at the location of
the Sun, and colors represent distinct clusters. The X axis corresponds to
$l=90^{\circ}$, while the Y axis corresponds to $l=180^{\circ}$. The Z axis is
perpendicular to the X-Y plane.  Figure 5: Distances of (a) G134.8$+$01.4 and
(b) G109.7$+$01.8 derived with MCMC sampling using parameters provided by the
BEEP-II method. The left-hand side shows the integrated images (top) of
molecular clouds and their foreground emission (bottom), as well as positions
of on- (green) and off-cloud (cyan) stars. In the top right panel, green dots
represent binned on-cloud stars, while blue dots represent binned off-cloud
stars. Gray dots in the top right panel represent raw on-clouds, while in the
bottom right panels, they represent background-removed on-cloud stars.

###  3.6 Removing Foreground Detections

The foreground emission is defined with radial velocity. Denoting the weighted
average (by intensity) and the weighted standard derivation of the radial
velocity with $V$ and $\Delta V$, respectively, and letting $V_{0}$ be the
local velocity (close to 0 km s-1 but changing with the Galactic longitude),
the integration velocity range of foreground emission is from $V_{0}$ to
$\left(V+3\Delta V\right)$ or $\left(V-3\Delta V\right)$, depending on which
one is closer to $V_{0}$. It is possible that the foreground emission defined
in this way is actually background emission, but this does not adversely
affect the distance measurement because removing stars towards those molecular
clouds only makes the background extinction more closely fit a Gaussian
distribution.

In both the BEEP and the BEEP-II methods, we remove stars that are severely
($>$ 3 K km s-1) affected by foreground emission, but distances to foreground
dust can still be measured under certain favorable conditions, in the presence
of high dust extinction near large CO clouds. Despite low CO emission, those
regions may cause significant extinction, and if a distant molecular cloud is
occasionally located behind those regions, distances to its foreground
emission are often measurable.

To remove foreground detections, we examine the extinction variation toward
foreground emission with the BEEP method. For foreground molecular clouds, we
distinguish on- and off-cloud stars with only CO integrated intensity $>$ 4 K
km s-1 for on-cloud stars and $<$ 1 K km s-1 for off-cloud stars, keeping
other parameters the same for targeting molecular clouds.

Table 3: Distances to Molecular Clouds. Name | $l$ | $b$ | $V_{\rm LSR}$ | Area |  $D_{\rm Gaia}$aaThe distance error is the standard deviation, and the 5% systematic error is not included. Only molecular cloud distances in the first Galactic quadrant are displayed, and a machine readable table and all figures of all 238 distances of 234 molecular clouds are publicly accessible on the Harvard Dataverse (https://doi.org/10.7910/DVN/0J76GM). | Region CenterbbCircular regions that contain on- and off-cloud stars. | RadiusbbCircular regions that contain on- and off-cloud stars. | COcutccThe lower threshold of CO emission for on-cloud stars. | $D_{\rm cut}$ | NddTotal number of on-cloud stars. | MasseeThe mass estimate only takes into account CO-bright molecular gas, and only the distance error is considered, including the 5% systematic error. Only molecular clouds with unique distances have masses calculated. |  $A_{V}$/$A_{G}$
---|---|---|---|---|---|---|---|---|---|---|---|---
| (∘) | (∘) | (km/s) | deg2 | (pc) | (∘,∘) | (∘) | (K km/s) | (pc) |  | ($10^{3}$ $M_{\odot}$) |
G026.9-03.5 | 26.913 | -3.571 | 16.3 | 0.33 | $445\pm 17$ | ( 26.533,-3.992) | 10.00 | 3.0 | 1000 | 239 | $0.45\pm 0.06$ | $A_{V}$
G027.8-02.1 | 27.893 | -2.170 | 18.0 | 1.92 | $484\pm 8$ | ( 27.508,-2.333) | 10.00 | 5.0 | 1000 | 407 | $9.34\pm 0.98$ | $A_{G}$
G028.6-02.9 | 28.635 | -2.946 | 18.5 | 0.04 | $826\pm 94$ | ( 28.633,-2.950) | 10.00 | 2.0 | 2000 | 69 | $0.08\pm 0.02$ | $A_{V}$
G032.9-01.8 | 32.954 | -1.842 | 22.4 | 0.02 | $2392\pm 192$ | ( 32.950,-1.842) | 5.00 | 2.0 | 3000 | 61 | $0.36\pm 0.07$ | $A_{V}$
G034.2-01.7 | 34.254 | -1.707 | 6.6 | 0.14 | $532\pm 61$ | ( 33.942,-1.608) | 10.00 | 2.0 | 2000 | 164 | $0.25\pm 0.06$ | $A_{G}$
G037.0+04.6 | 37.053 | 4.660 | 22.8 | 0.04 | $1016\pm 85$ | ( 37.067, 4.667) | 5.00 | 3.0 | 1500 | 30 | $0.19\pm 0.04$ | $A_{V}$
G038.1-01.2 | 38.159 | -1.227 | 7.7 | 0.20 | $698\pm 64$ | ( 38.158,-1.225) | 5.00 | 3.0 | 1000 | 63 | $0.37\pm 0.08$ | $A_{V}$
G038.4-03.3 | 38.432 | -3.388 | 7.5 | 0.11 | $872\pm 66$ | ( 38.467,-3.417) | 10.00 | 2.0 | 1500 | 94 | $0.26\pm 0.05$ | $A_{V}$
G039.4-02.7 | 39.454 | -2.741 | 15.0 | 0.21 | $493\pm 20$ | ( 39.433,-2.750) | 10.00 | 3.0 | 1500 | 235 | $0.30\pm 0.04$ | $A_{V}$
G041.5+02.3 | 41.581 | 2.328 | 17.6 | 1.11 | $909\pm 13$ | ( 41.550, 2.625) | 10.00 | 5.0 | 1500 | 518 | $10.4\pm 1.1$ | $A_{G}$
G041.5-01.8 | 41.583 | -1.820 | 16.8 | 0.14 | $708\pm 65$ | ( 41.458,-1.550) | 15.00 | 2.0 | 2000 | 94 | $0.38\pm 0.08$ | $A_{G}$
G041.9+02.2 | 41.981 | 2.300 | 5.4 | 1.75 | $314\pm 15$ | ( 41.542, 2.633) | 10.00 | 3.0 | 1000 | 390 | $1.09\pm 0.15$ | $A_{G}$
G042.1-02.1 | 42.160 | -2.105 | 23.4 | 0.06 | $1066\pm 55$ | ( 42.167,-2.100) | 10.00 | 2.0 | 1500 | 53 | $0.48\pm 0.07$ | $A_{G}$
G042.9+04.4 | 42.975 | 4.423 | 22.7 | 0.02 | $1441\pm 68$ | ( 42.967, 4.425) | 10.00 | 2.0 | 2500 | 89 | $0.18\pm 0.02$ | $A_{V}$
G043.3+03.1 | 43.386 | 3.154 | 10.2 | 0.22 | $723\pm 16$ | ( 43.450, 3.100) | 5.00 | 4.0 | 1000 | 153 | $0.98\pm 0.11$ | $A_{V}$
G043.4-04.2 | 43.427 | -4.273 | 26.1 | 0.03 | $1021\pm 52$ | ( 43.483,-4.142) | 10.00 | 2.0 | 2500 | 109 | $0.13\pm 0.02$ | $A_{V}$
G044.5+02.7 | 44.553 | 2.707 | 14.6 | 0.17 | $621\pm 16$ | ( 44.500, 2.808) | 5.00 | 2.0 | 1000 | 162 | $0.37\pm 0.04$ | $A_{V}$
G044.7-04.2 | 44.757 | -4.203 | 22.8 | 0.03 | $1154\pm 166$ | ( 44.800,-4.175) | 15.00 | 2.0 | 2000 | 73 | $0.20\pm 0.06$ | $A_{V}$
G044.7+04.0 | 44.760 | 4.035 | 20.0 | 0.85 | $829\pm 13$ | ( 45.308, 4.092) | 5.00 | 4.0 | 1500 | 246 | $4.82\pm 0.50$ | $A_{V}$
G045.1-03.4 | 45.166 | -3.435 | 20.7 | 0.07 | $923\pm 72$ | ( 45.167,-3.442) | 15.00 | 2.0 | 2000 | 125 | $0.18\pm 0.03$ | $A_{V}$
G045.4-04.2 | 45.478 | -4.271 | 18.8 | 0.40 | $931\pm 25$ | ( 45.383,-4.217) | 5.00 | 3.0 | 1500 | 206 | $2.56\pm 0.29$ | $A_{G}$
G045.5-03.3 | 45.541 | -3.331 | 20.2 | 0.07 | $873\pm 41$ | ( 45.275,-3.483) | 10.00 | 2.0 | 2000 | 172 | $0.24\pm 0.03$ | $A_{V}$
G046.9-04.8 | 46.956 | -4.889 | 15.7 | 0.04 | $841\pm 45$ | ( 46.975,-4.942) | 10.00 | 2.0 | 1500 | 59 | $0.10\pm 0.02$ | $A_{V}$
G046.9+01.7 | 46.978 | 1.774 | 6.8 | 0.46 | $491\pm 103$ | ( 47.042, 1.683) | 10.00 | 2.0 | 1000 | 157 | $0.63\pm 0.27$ | $A_{G}$
G047.3-03.1 | 47.353 | -3.175 | 18.7 | 0.04 | $912\pm 99$ | ( 47.375,-3.200) | 5.00 | 2.0 | 2000 | 151 | $0.24\pm 0.06$ | $A_{V}$
G047.3-03.0 | 47.355 | -3.035 | 24.4 | 0.03 | $1127\pm 88$ | ( 47.400,-3.058) | 10.00 | 2.0 | 2000 | 36 | $0.18\pm 0.03$ | $A_{G}$
G049.4-04.6 | 49.413 | -4.626 | 18.7 | 0.02 | $957\pm 96$ | ( 49.517,-4.642) | 15.00 | 2.0 | 2500 | 86 | $0.10\pm 0.02$ | $A_{V}$
… | … | … | … | … | … | … | … | … | … | … | … | …

If the extinction jump of a molecular cloud and that of its foreground
emission are close, we cannot judge which distance is measured, and so we
exclude this kind of molecular clouds from our sample. In addition, if the
angular size of a molecular cloud is overwhelmingly small compared with the
foreground emission, its distance is unreliable, and this cloud is also
excluded.

##  4 Results

In this section, we display distances derived with the BEEP-II method in three
regions listed in Table 1. As examples, we display results of G134.8$+$01.4
and G109.7$+$01.8. G134.8$+$01.4 is located in the W4 region (e.g., Heyer &
Terebey, 1998; Sun et al., 2020), while G109.7$+$01.8 is a molecular cloud
close to the Sun, both in the second Galactic quadrant.

###  4.1 Fast Distance Estimate

Figure 3 displays distances measured with piecewise linear regression with
integrated extinction in the BEEP-II method. As a comparison, we show direct
fitting results with piecewise linear regression (slopes are set to zero)
using the extinction data. In both cases, the direct fitting approach does not
gauge the right extinction jump, and in contrast, the BEEP-II method derives
distances accurately. Figure 3 demonstrates that the BEEP-II method works well
even when the numbers of foreground and background stars are unbalanced,
provided that the extinction jump is evident.

Figure 6: Demonstration of the foreground ambiguity. Distances of (a)
G123.2$-$00.5 and (b) its foreground are close, causing ambiguity. In panel
(b), only the brightness of CO is used to classify on- and off-cloud stars for
foreground emission. See Figure 5 for other details.

###  4.2 Clustering and MCMC Sampling

Figure 4 shows the clustering results of G134.8$+$01.4 and G109.7$+$01.8. One
cluster ($A_{V}$) was found for G134.8$+$01.4, while five clusters ($A_{G}$)
were found for G109.7$+$01.8. The clustering procedure proposed in Section 3.4
works well in both sparse and crowded environments.

Each circle in Figure 4 represents a distance derived with piecewise linear
regression, corresponding to a specific parameter combination. For each
cluster, we selected an optimal parameter combination with the method
described in Section 3.5 and ran MCMC sampling accordingly.

Figure 5 displays MCMC sampling results for the clusters found for
G134.8$+$01.4 and G109.7$+$01.8 (one of its five clusters with $A_{G}$). For
each panel, the left-hand side displays the integrated (top) and foreground
(bottom) images, and the right-hand side shows raw (top) and background-
removed (bottom) extinction of on-cloud stars. For both molecular clouds, MCMC
sampling derives distances accurately.

###  4.3 The Distance Catalog

We examine MCMC results of each cluster and only keep those with evident
extinction jumps. If two circular regions largely overlap, only one is kept,
usually the one with a smaller error. As described in Section 3.6, if the
foreground emission of molecular cloud shows an extinction jump at a close
distance, this molecular cloud is excluded due to the foreground ambiguity.

An overview of the distance results is described in Table 2. In total, we
derived distances to 234 molecular clouds, including 238 positions. The BEEP-
II method allowed us to measure many more distances than the original BEEP
method.

The distance catalog is displayed in Table 3. Table 3 only contains molecular
clouds in the first Galactic quadrant, and the full catalog and all distance
figures are publicly accessible on the Harvard Dataverse
(https://doi.org/10.7910/DVN/0J76GM).

Figure 7: Comparisons of distances with previous BEEP results: (a) eight
molecular clouds in the first Galactic quadrant (Yan et al., 2020), (b) 63
molecular clouds in the second Galactic quadrant (Yan et al., 2021a), and (c)
five molecular clouds in the third Galactic quadrant (Yan et al., 2019a). One
molecular cloud, G148.1$-$00.2, marked in red, shows a large distance
discrepancy.

##  5 Discussion

###  5.1 Foreground Ambiguity

To demonstrate the effect of foreground contamination, we display distances to
G123.2$-$00.5 in Figure 6. The foreground distance of G123.2$-$00.5 is about
1000 pc, close to that the distance to G123.2$-$00.5 itself. In this case, it
is unclear which distance is measured, so G123.2$-$00.5 is rejected.

In total, 14 molecular clouds are rejected due to the foreground ambiguity.
Eleven are in the second Galactic quadrant, and three are in the third
Galactic quadrant. In the second Galactic quadrant, according to the radial
velocity (Sun et al., 2020), six of the eleven molecular clouds are located in
the Perseus arm, and the rest five are in the local arm.

###  5.2 Comparison With Previous Studies

In this section, we compare molecular cloud distances with previous BEEP
results (Yan et al., 2019a, 2020, 2021a). Yan et al. (2021a) use the same
molecular cloud catalog (except for the including of incomplete clouds), so we
first compare the results in the second Galactic quadrant.

Figure 8: Same as Figure 5 but for a molecular cloud whose distance is not
measured with MCMC sampling. The distance given by piecewise linear regression
in the BEEP-II method is about 950 pc, and the non-detection of MCMC sampling
is due to several low extinction background stars. See Figure 5 for other
details.

Yan et al. (2021a) measured distances to 77 molecular clouds (including the
largest molecular cloud), and in this work, we measured distances to 155
molecular clouds, of which 64 are in common. Among the commonly detected
molecular clouds, 63 have unique distances, which are plotted in panel (b) of
Figure 7. Most molecular cloud distances are compatible within errors, and one
molecular cloud, G148.1$-$00.2, shows a large discrepancy, i.e., $>$ 25% of
this work. The extinction jump of G148.1$-$00.2 is small compared with that
caused by background molecular clouds, implying that the measurement of the
distance of background molecular clouds made by Yan et al. (2021a) is
incorrect.

The BEEP-II method slightly improves the precision of distances. For 63
molecular clouds in the second Galactic quadrant shown in Figure 7, the mean
relative statistic error of the BEEP-II distances is 4.81%, about 0.04%
smaller than those of the BEEP distances.

In the results of Yan et al. (2021a), nine molecular clouds are excluded due
to the incompleteness in PPV space, and distances of four molecular clouds are
not measured in this work. It is interesting to examine the reason for non-
detections, which potentially reveals shortages of the BEEP-II method. Two
molecular clouds, G112.2$-$01.5 and G131.8$+$00.0, have their distances
measured in the clustering step, and both distances are close to that of Yan
et al. (2021a). However, their distance errors provided by MCMC sampling are
large. The rest two molecular clouds, G114.5$-$00.1 and G131.8$-$02.5, did not
yield distance clusters due to the unclear extinction jump, and more accurate
extinction data are needed to confirm their distances.

In the first Galactic quadrant, Yan et al. (2020) use SCIMES to split large
structures in PPV space, and the molecular cloud samples are largely
different. However, some small molecular clouds were not split by SCIMES, and
can be matched with DBSCAN molecular cloud samples, where the matching
criteria are that both $l$ and $b$ differences are less than 0$\fdg$1 and the
$V_{\rm LSR}$ difference is less than 0.5 km s-1. As shown in panel (a) of
Figure 7, eight molecular clouds have their distances commonly measured by
both this work and Yan et al. (2020), and their results agree well with each
other.

In the third Galactic quadrant, we measured many more molecular cloud
distances than Yan et al. (2019a). This is because Yan et al. (2019a) only
measured large molecular clouds, ignoring small ones, and in addition, they
only used $A_{G}$ data. Using the same match criteria mentioned above, we
found distances of five molecular clouds are commonly measured. The distances
of Yan et al. (2019a) are systematically larger (by about 133 pc) than that of
this work, as demonstrated in panel (c) of Figure 7. In this work, distances
of those five molecular clouds are measured with $A_{V}$, while they are
measured with $A_{G}$ in Yan et al. (2019a), so this systematic discrepancy is
mostly due to the $A_{G}$ and $A_{V}$ data.

###  5.3 Structure of DBSCAN Clouds

The global search feature of the BEEP-II method makes it capable of examining
the structure of molecular clouds identified with DBSCAN. Limited by the
precision of stellar parallaxes and extinction, however, detailed analyses of
3D structures of molecular clouds are beyond the scope of this work, but the
BEEP-II method can roughly provide the number of distance components for each
molecular cloud.

Among the 234 molecular clouds, one, G134.7$-$00.3, shows multiple distance
components. In terms of the angular area, G134.7$-$00.3 is the second largest
molecular cloud with an angular area of 11 deg2, while the next large
molecular cloud has an area of about 7 deg2. Roughly, G134.7$-$00.3 has three
components at about 740, 900, and 1400 pc. Yan et al. (2021a) also derived 22
distances for a large-scale molecular cloud, which is excluded in this work
due to its incompleteness. Consequently, for small molecular clouds ($<$ 7
deg2), the velocity crowding effect in PPV space is not severe, and at least
local molecular clouds are not entangled with each other. However, there is
still a chance that local molecular clouds overlap with distant components
($>$ 3 kpc) in PPV space, but distinguishing them is beyond the scope of Gaia
DR2 data.

###  5.4 Ability of the BEEP-II Method

The BEEP-II method examines the distance twice, first by piecewise linear
regression and then by MCMC sampling. There are molecular clouds whose
distances are detected with piecewise linear regression but not with MCMC
sampling, e.g., see Figure 8 for the MCMC sampling result of G214.1$+$04.1.
The failure of MCMC sampling is due to the unclear extinction jump. The
distance given by piecewise linear regression, however, is about 950 pc,
consistent with the jump position as judged by eye.

The BEEP-II method is a powerful tool for measuring molecular cloud distances.
First, the automatic selection of on- and off-cloud star sample pairs improves
the efficiency of the BEEP method significantly. The computational time (on an
intel Core i9-10920X desktop in Ubuntu operating system and in Python code)
used to examine molecular cloud distances in the first, second, and third
Galactic quadrants is about 2 (359 clouds), 10 (1618 clouds), and 2 hours (237
clouds), respectively. At present, we confine the distance search within 3
kpc, but updated Gaia and extinction data in future will enable distance
measurements for more distant molecular clouds. Secondly, the BEEP-II method
determines the optimal region for distance measuring. These two features are
the essential improvements of the BEEP-II method over the BEEP method.

The number of molecular cloud distances measured by the BEEP-II method has
surpassed that of masers. Reid et al. (2019) reported 199 maser parallaxes
measured by the Bar and Spiral Structure Legacy (BeSSeL) Survey and the
Japanese VLBI Exploration of Radio Astrometry (VERA) project, while the BEEP-
II method measures distances to 234 molecular clouds.

###  5.5 Molecular Cloud Catalogs

Large-scale CO surveys are gradually transforming molecular cloud researches
from case studies to sample studies. For instance, using the CfA-Chile survey,
Rice et al. (2016) and (Miville-Deschênes et al., 2017) built two different
molecular cloud catalogs with different algorithms. Based on the
${}^{13}\mathrm{CO}~{}(J=2\rightarrow 1)$ data of the Structure, Excitation
and Dynamics of the Inner Galactic Interstellar Medium (SEDIGISM, Schuller et
al., 2021) survey and the SCIMES algorithm, Duarte-Cabral et al. (2021) find
10663 molecular clouds. With the same algorithm but using the JCMT
${}^{12}\mathrm{CO}~{}(J=3\rightarrow 2)$ High-Resolution Survey (COHRS,
Dempsey et al., 2013) data, Colombo et al. (2019) build a catalog with more
than 85000 molecular clouds.

Statistical studies of molecular cloud properties hinge on the distance
information, but the fraction of molecular clouds with accurate distances is
small. In this work, we collectively identified 2214 molecular clouds with
angular areas larger than 0.015 deg2 and complete in PPV space, but the
fraction of samples with measured distances is only 11%. In addition to
physical property statistics, delineating the large-scale distribution of
local molecular clouds also needs high completeness of molecular cloud
distances. Consequently, distance measurements are still far from keeping up
with demand.

##  6 Summary

We have improved the BEEP method and developed a procedure of measuring
distances to molecular clouds through a global search method, which is called
the BEEP-II method. This improved method examines distances across the surface
of molecular clouds, analyzing distance components accordingly. Compared with
the BEEP method, the BEEP-II method is suitable for measuring distances of
molecular clouds with large angular size or in complicated environments. In
addition, the high efficiency of the BEEP-II method enables systematic
distance measurements of molecular clouds mapped by large-scale CO surveys.

In three regions mapped by the MWISP CO survey, the BEEP-II method measures
distances to 234 molecular clouds in total, including 238 positions, more than
double the number of previous BEEP results. The statistical error is about
7.28% on average, and comparisons of distances in the second Galactic quadrant
indicate that the BEEP-II method improves the distance precision by about
0.04%. The augmentation of molecular cloud samples with high-precision
distances will help reveal the distribution and properties of molecular
clouds.

We thank Sammy McSweeney for his careful proofreading. We are grateful to all
the members of the MWISP working group, particularly the staff members at
PMO-13.7m telescope, for their long-term support. MWISP was sponsored by
National Key R&D Program of China with grant no. 2017YFA0402701 and CAS Key
Research Program of Frontier Sciences with grant no. QYZDJ-SSW-SLH047. JY is
supported by National Natural Science Foundation of China through grant
12041305. This work was also sponsored by National Natural Science Foundation
of China grant No. 12003071, 11773077, U1831136, and the Youth Innovation
Promotion Association, CAS (2018355).

## References

  * Anders et al. (2019) Anders, F., Khalatyan, A., Chiappini, C., et al. 2019, A&A, 628, A94, doi: 10.1051/0004-6361/201935765
  * Astropy Collaboration et al. (2013) Astropy Collaboration, Robitaille, T. P., Tollerud, E. J., et al. 2013, A&A, 558, A33, doi: 10.1051/0004-6361/201322068
  * Colombo et al. (2015) Colombo, D., Rosolowsky, E., Ginsburg, A., Duarte-Cabral, A., & Hughes, A. 2015, MNRAS, 454, 2067, doi: 10.1093/mnras/stv2063
  * Colombo et al. (2019) Colombo, D., Rosolowsky, E., Duarte-Cabral, A., et al. 2019, MNRAS, 483, 4291, doi: 10.1093/mnras/sty3283
  * Dame et al. (2001) Dame, T. M., Hartmann, D., & Thaddeus, P. 2001, ApJ, 547, 792, doi: 10.1086/318388
  * Dempsey et al. (2013) Dempsey, J. T., Thomas, H. S., & Currie, M. J. 2013, ApJS, 209, 8, doi: 10.1088/0067-0049/209/1/8
  * Duarte-Cabral et al. (2021) Duarte-Cabral, A., Colombo, D., Urquhart, J. S., et al. 2021, MNRAS, 500, 3027, doi: 10.1093/mnras/staa2480
  * Dzib et al. (2018) Dzib, S. A., Loinard, L., Ortiz-León, G. N., Rodríguez, L. F., & Galli, P. A. B. 2018, ApJ, 867, 151, doi: 10.3847/1538-4357/aae687
  * Gaia Collaboration et al. (2020) Gaia Collaboration, Brown, A. G. A., Vallenari, A., et al. 2020, arXiv e-prints, arXiv:2012.01533.  https://arxiv.org/abs/2012.01533
  * Gaia Collaboration et al. (2016) Gaia Collaboration, Prusti, T., de Bruijne, J. H. J., et al. 2016, A&A, 595, A1, doi: 10.1051/0004-6361/201629272
  * Gaia Collaboration et al. (2018) Gaia Collaboration, Brown, A. G. A., Vallenari, A., et al. 2018, A&A, 616, A1, doi: 10.1051/0004-6361/201833051
  * Heyer & Dame (2015) Heyer, M., & Dame, T. M. 2015, ARA&A, 53, 583, doi: 10.1146/annurev-astro-082214-122324
  * Heyer & Terebey (1998) Heyer, M. H., & Terebey, S. 1998, ApJ, 502, 265, doi: 10.1086/305881
  * Marton et al. (2019) Marton, G., Ábrahám, P., Szegedi-Elek, E., et al. 2019, MNRAS, 487, 2522, doi: 10.1093/mnras/stz1301
  * Miville-Deschênes et al. (2017) Miville-Deschênes, M.-A., Murray, N., & Lee, E. J. 2017, ApJ, 834, 57, doi: 10.3847/1538-4357/834/1/57
  * Reid et al. (2009) Reid, M. J., Menten, K. M., Zheng, X. W., et al. 2009, ApJ, 700, 137, doi: 10.1088/0004-637X/700/1/137
  * Reid et al. (2019) Reid, M. J., Menten, K. M., Brunthaler, A., et al. 2019, ApJ, 885, 131, doi: 10.3847/1538-4357/ab4a11
  * Rice et al. (2016) Rice, T. S., Goodman, A. A., Bergin, E. A., Beaumont, C., & Dame, T. M. 2016, ApJ, 822, 52, doi: 10.3847/0004-637X/822/1/52
  * Roccatagliata et al. (2020) Roccatagliata, V., Franciosini, E., Sacco, G. G., Rand ich, S., & Sicilia-Aguilar, A. 2020, A&A, 638, A85, doi: 10.1051/0004-6361/201936401
  * Rosolowsky et al. (2008) Rosolowsky, E. W., Pineda, J. E., Kauffmann, J., & Goodman, A. A. 2008, ApJ, 679, 1338, doi: 10.1086/587685
  * Schuller et al. (2021) Schuller, F., Urquhart, J. S., Csengeri, T., et al. 2021, MNRAS, 500, 3064, doi: 10.1093/mnras/staa2369
  * Solomon et al. (1987) Solomon, P. M., Rivolo, A. R., Barrett, J., & Yahil, A. 1987, ApJ, 319, 730, doi: 10.1086/165493
  * Solomon et al. (1979) Solomon, P. M., Sanders, D. B., & Scoville, N. Z. 1979, in IAU Symposium, Vol. 84, The Large-Scale Characteristics of the Galaxy, ed. W. B. Burton, 35
  * Su et al. (2019) Su, Y., Yang, J., Zhang, S., et al. 2019, ApJS, 240, 9, doi: 10.3847/1538-4365/aaf1c8
  * Su et al. (2020) Su, Y., Yang, J., Yan, Q.-Z., et al. 2020, ApJ, 893, 91, doi: 10.3847/1538-4357/ab7fff
  * Su et al. (2021) —. 2021, ApJ, 910, 131, doi: 10.3847/1538-4357/abe5ab
  * Sun et al. (2020) Sun, Y., Yang, J., Xu, Y., et al. 2020, ApJS, 246, 7, doi: 10.3847/1538-4365/ab5b97
  * VERA Collaboration et al. (2020) VERA Collaboration, Hirota, T., Nagayama, T., et al. 2020, PASJ, 72, 50, doi: 10.1093/pasj/psaa018
  * Virtanen et al. (2020) Virtanen, P., Gommers, R., Oliphant, T. E., et al. 2020, Nature Methods, 17, 261, doi: 10.1038/s41592-019-0686-2
  * Wolf (1923) Wolf, M. 1923, Astronomische Nachrichten, 219, 109, doi: 10.1002/asna.19232190702
  * Xu et al. (2006) Xu, Y., Reid, M. J., Zheng, X. W., & Menten, K. M. 2006, Science, 311, 54, doi: 10.1126/science.1120914
  * Yan et al. (2020) Yan, Q.-Z., Yang, J., Su, Y., Sun, Y., & Wang, C. 2020, ApJ, 898, 80, doi: 10.3847/1538-4357/ab9f9c
  * Yan et al. (2019a) Yan, Q.-Z., Yang, J., Sun, Y., Su, Y., & Xu, Y. 2019a, ApJ, 885, 19, doi: 10.3847/1538-4357/ab458e
  * Yan et al. (2021a) Yan, Q.-Z., Yang, J., Sun, Y., et al. 2021a, A&A, 645, A129, doi: 10.1051/0004-6361/202039768
  * Yan et al. (2021b) Yan, Q.-Z., Yang, J., Yang, S., Sun, Y., & Wang, C. 2021b, ApJ, 910, 109, doi: 10.3847/1538-4357/abe628
  * Yan et al. (2019b) Yan, Q.-Z., Zhang, B., Xu, Y., et al. 2019b, A&A, 624, A6, doi: 10.1051/0004-6361/201834337
  * Zari et al. (2018) Zari, E., Hashemi, H., Brown, A. G. A., Jardine, K., & de Zeeuw, P. T. 2018, A&A, 620, A172, doi: 10.1051/0004-6361/201834150
  * Zucker et al. (2018) Zucker, C., Schlafly, E. F., Speagle, J. S., et al. 2018, ApJ, 869, 83, doi: 10.3847/1538-4357/aae97c
  * Zucker et al. (2020) Zucker, C., Speagle, J. S., Schlafly, E. F., et al. 2020, A&A, 633, A51, doi: 10.1051/0004-6361/201936145
  * Zucker et al. (2019) —. 2019, ApJ, 879, 125, doi: 10.3847/1538-4357/ab2388