We build a sample of 298 spectroscopically-confirmed galaxies at redshift z~2, selected in the z-band from the GOODS-MUSIC catalog. By exploiting the rest frame 8 um luminosity as a proxy of the star formation rate (SFR) we check the accuracy of the standard SED-fitting technique, finding it is not accurate enough to provide reliable estimates of the galaxy physical parameters. We then develop a new SED-fitting method that includes the IR luminosity as a prior and a generalized Calzetti law with a variable RV . Then we exploit such a new method to re-analyze our galaxy sample, and to robustly determine SFRs, stellar masses and ages. We find that there is a general trend of increasing attenuation with the SFR. Moreover, we find that the SFRs range between a few to 1000 solar mass per year, the masses from one billion to 400 billion solar masses, while the ages from a few tens of Myr to more than 1 Gyr. We discuss how individual age easurements of highly attenuated objects indicate that dust must form within a few tens of Myr and be copious already at ~100 Myr. In addition, we find that low luminous galaxies harbor, on average, significantly older stellar populations and are also less massive than brighter ones; we discuss how these findings and the well known downsizing scenario are consistent in a framework where less massive galaxies form first, but their star formation lasts longer. Finally, we find that the near-IR attenuation is not scarce for luminous objects, contrary to what is customarily assumed; we discuss how this affects the interpretation of the observed mass-to-light ratios.