How to implement EndOfRun method for a class derived from the G4VSensitiveDetector class?

Dear All,
What I am looking for, is if it is possible to implement a method that captures the end of a thread-run “EndOfRun” , similarly as provided one for capturing the end of event called “EndOfEvent”.

Not directly. As you can see from G4VSensitiveDetector.hh, only event-level actions are defined, Initialize() at the beginning, and EndOfEvent() at the end.

You could write an EndOfRun() function as part of your own SD subclass, and then call it from your thread-local RunAction::EndOfRunAction(). To do this, you’d fetch the SD from G4SDManager by name, then use dynamic_cast<> to turn it into your concrete subtype, in order to call the function.

Thank you Mkelesey for your solution.It is easy to implement, it seems work fine.