24 #include <TStopwatch.h>
48 TFile inFile(inFileName,
"READ");
49 if (!inFile.IsOpen()) {
50 std::cerr <<
"Unable to open " << inFileName << std::endl;
53 inFile.GetObject(
"EICTree", mcTree);
55 std::cerr <<
"Unable to find EICTree in " << inFileName << std::endl;
58 std::unique_ptr<erhic::VirtualEventFactory> builder;
61 TClass* branchClass = TClass::GetClass(mcTree->GetBranch(
"event")->GetClassName());
62 if (branchClass->InheritsFrom(
"erhic::EventDis")) {
64 *(mcTree->GetBranch(
"event"))));
66 }
else if (branchClass->InheritsFrom(
"erhic::hadronic::EventMC")) {
68 *(mcTree->GetBranch(
"event"))));
71 std::cerr << branchClass->GetName() <<
" is not supported for smearing" <<
76 TString outName(outFileName);
77 if (outName.IsNull()) {
78 outName = TString(inFileName).ReplaceAll(
".root",
".smear.root");
80 TFile outFile(outName,
"RECREATE");
81 if (!outFile.IsOpen()) {
82 std::cerr <<
"Unable to create " << outName << std::endl;
85 TTree smearedTree(
"Smeared",
"A tree of smeared Monte Carlo events");
86 TBranch* eventbranch = builder->
Branch(smearedTree,
"eventS");
87 if (mcTree->GetEntries() < nEvents || nEvents < 1) {
88 nEvents = mcTree->GetEntries();
91 "/-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-/"
94 "/ Commencing Smearing of " << nEvents <<
" events."
97 "/-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-/"
99 for (Long64_t i(0); i <
nEvents; i++) {
100 if (i % 10000 == 0 && i != 0) {
101 std::cout <<
"Processing event " << i << std::endl;
104 builder->
Fill(*eventbranch);
107 detector.Write(
"detector");
110 "|~~~~~~~~~~~~~~~~~~ Completed Successfully ~~~~~~~~~~~~~~~~~~~|"