Hi @huachengcai92, welcome to the ROOT forum and thanks for the interesting post!
You are encountering exactly the kind of problem that made me want to deprecate the PDF binding: they are not persistable, and there are better alternatives.
The better alternative is to use RooGenericPdf, where you can use any C++ function, also if it’s from a custom header. I have written down and example on how to do this here. With the RooGenericPdf, only the declaring string is written to the workspace, so that’s not a problem.
Would that be a solution for you?
Cheers,
Jonas