The classic tuned mass damper (TMD) is a passive vibration control device composed of an auxiliary mass connected to a vibrating object with a spring and an energy-dissipative element. When its parameters are optimized, it can reduce the vibration effectively. Recently, the authors proposed simultaneous vibration control and energy harvesting from tall buildings by replacing the energy-dissipative element of the TMD with electromagnetic transducers, which is called electricity-generating TMD. However, the electromagnetic transducers and the energy harvesting circuit, the modeling of which is an essentially a RL circuit, will introduce extra dynamics into the system, which has significant influence on the vibration mitigation performance. This paper investigates the influence, by optimizing the parameters. We found that the electricity-generating TMD can provide better vibration mitigation performance than the classic TMD and similar performance as the three-element TMD while harvesting the vibration energy at the same time. This paper utilizes the H2 criterions, which is to minimize the root-mean-square vibration under random excitation. The optimization method is presented in this paper, as well as the concise closed-form solution of the optimal parameters. A case study is also given to illustrate the effectiveness, robustness of the electricity-generating TMD and the sensitivity to the parameter changes.