Dense cold molecular cores/filaments are surrounded by an envelope of translucent gas. Some of the low-J emission lines of CO and HCO+ isotopologues are more sensitive to the conditions either in the translucent environment or in the dense cold one. We propose a cloud model composed of three homogeneous slabs of gas along each line of sight (LoS), representing an envelope and a shielded inner layer. IRAM-30m data from the ORION-B large program toward the Horsehead nebula are used to demonstrate the method's capability. We use the non-LTE radiative transfer code RADEX to model the line profiles from the kinetic temperature Tkin, the volume density nH2, kinematics and chemical properties of the different layers. We then use a maximum likelihood estimator to simultaneously fit the lines of the CO and HCO+ isotopologues. We constrain column density ratios to limit the variance on the estimates. This simple heterogeneous model provides good fits of the fitted lines over a large part of the cloud. The decomposition of the intensity into three layers allows to discuss the distribution of the estimated physical/chemical properties along the LoS. About 80% the CO integrated intensity comes from the envelope, while ∼55% of that of the (1-0) and (2-1) lines of C18O comes from the inner layer. The N(13CO)/N(C18O) in the envelope increases with decreasing Av, and reaches 25 in the pillar outskirts. The envelope Tkin varies from 25 to 40 K, that of the inner layer drops to ∼15 K in the western dense core. The inner layer nH2 is ∼3×104cm−3 toward the filament and it increases by a factor 10 toward dense cores. The proposed method correctly retrieves the physical/chemical properties of the Horsehead nebula and offers promising prospects for less supervised model fits of wider-field datasets.