LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
Worker.cc
Go to the documentation of this file.
4 
5 using mf::LogError;
6 
8  : md_{iMD}, actions_{iWP.actions_}
9 {}
10 
11 void
12 art::Worker::setActivityRegistry(cet::exempt_ptr<ActivityRegistry> areg)
13 {
14  actReg_ = std::move(areg);
15 }
16 
17 void
19  assert(actReg_.get() != nullptr);
20  actReg_->sPreModuleBeginJob.invoke(md_);
21  implBeginJob();
22  actReg_->sPostModuleBeginJob.invoke(md_);
23 }
24 catch (cet::exception& e) {
25  // should event id be included?
26  LogError("BeginJob") << "A cet::exception is going through " << workerType()
27  << ":\n";
28 
29  e << "A cet::exception is going through " << workerType() << ":\n"
30  << description();
31  throw art::Exception(errors::OtherArt, std::string(), e);
32 }
33 catch (std::bad_alloc& e) {
34  LogError("BeginJob") << "A std::bad_alloc is going through " << workerType()
35  << ":\n"
36  << description() << "\n";
37  throw;
38 }
39 catch (std::exception& e) {
40  LogError("BeginJob") << "A std::exception is going through " << workerType()
41  << ":\n"
42  << description() << "\n";
44  << "A std::exception is going through " << workerType() << ":\n"
45  << description() << "\n";
46 }
47 catch (std::string& s) {
48  LogError("BeginJob") << "module caught an std::string during beginJob\n";
49 
51  << "std::string = " << s << "\n"
52  << description() << "\n";
53 }
54 catch (char const* c) {
55  LogError("BeginJob") << "module caught an const char* during beginJob\n";
56 
57  throw art::Exception(errors::BadExceptionType) << "cstring = " << c << "\n"
58  << description();
59 }
60 catch (...) {
61  LogError("BeginJob") << "An unknown Exception occurred in\n"
62  << description() << "\n";
63  throw art::Exception(errors::Unknown) << "An unknown Exception occurred in\n"
64  << description() << "\n";
65 }
66 
67 void
69  assert(actReg_.get() != nullptr);
70  actReg_->sPreModuleEndJob.invoke(md_);
71  implEndJob();
72  actReg_->sPostModuleEndJob.invoke(md_);
73 }
74 catch (cet::exception& e) {
75  LogError("EndJob") << "A cet::exception is going through " << workerType()
76  << ":\n";
77 
78  // should event id be included?
79  e << "A cet::exception is going through " << workerType() << ":\n"
80  << description();
81  throw art::Exception(errors::OtherArt, std::string(), e);
82 }
83 catch (std::bad_alloc& e) {
84  LogError("EndJob") << "A std::bad_alloc is going through " << workerType()
85  << ":\n"
86  << description() << "\n";
87  throw;
88 }
89 catch (std::exception& e) {
90  LogError("EndJob") << "An std::exception is going through " << workerType()
91  << ":\n"
92  << description() << "\n";
94  << "A std::exception is going through " << workerType() << ":\n"
95  << description() << "\n"
96  << e.what();
97 }
98 catch (std::string& s) {
99  LogError("EndJob") << "module caught an std::string during endJob\n";
100 
102  << "std::string = " << s << "\n"
103  << description() << "\n";
104 }
105 catch (char const* c) {
106  LogError("EndJob") << "module caught an const char* during endJob\n";
107 
108  throw art::Exception(errors::BadExceptionType) << "cstring = " << c << "\n"
109  << description() << "\n";
110 }
111 catch (...) {
112  LogError("EndJob") << "An unknown Exception occurred in\n"
113  << description() << "\n";
114  throw art::Exception(errors::Unknown) << "An unknown Exception occurred in\n"
115  << description() << "\n";
116 }
117 
118 void
120 {
121  assert(actReg_.get() != nullptr);
122  actReg_->sPreModuleRespondToOpenInputFile.invoke(md_);
124  actReg_->sPostModuleRespondToOpenInputFile.invoke(md_);
125 }
126 
127 void
129 {
130  assert(actReg_.get() != nullptr);
131  actReg_->sPreModuleRespondToCloseInputFile.invoke(md_);
133  actReg_->sPostModuleRespondToCloseInputFile.invoke(md_);
134 }
135 
136 void
138 {
139  assert(actReg_.get() != nullptr);
140  actReg_->sPreModuleRespondToOpenOutputFiles.invoke(md_);
142  actReg_->sPostModuleRespondToOpenOutputFiles.invoke(md_);
143 }
144 
145 void
147 {
148  assert(actReg_.get() != nullptr);
149  actReg_->sPreModuleRespondToCloseOutputFiles.invoke(md_);
151  actReg_->sPostModuleRespondToCloseOutputFiles.invoke(md_);
152 }
void setActivityRegistry(cet::exempt_ptr< ActivityRegistry > areg)
Definition: Worker.cc:12
Float_t s
Definition: plot.C:23
void endJob()
Definition: Worker.cc:68
void respondToOpenOutputFiles(FileBlock const &fb)
Definition: Worker.cc:137
void respondToCloseOutputFiles(FileBlock const &fb)
Definition: Worker.cc:146
void beginJob()
Definition: Worker.cc:18
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
ActionTable const & actions_
Definition: Worker.h:161
virtual void implRespondToOpenInputFile(FileBlock const &fb)=0
virtual void implBeginJob()=0
virtual void implRespondToCloseOutputFiles(FileBlock const &fb)=0
cet::exempt_ptr< ActivityRegistry > actReg_
Definition: Worker.h:164
virtual std::string workerType() const =0
ModuleDescription const & description() const
Definition: Worker.h:74
TFile fb("Li6.root")
ModuleDescription md_
Definition: Worker.h:160
void respondToOpenInputFile(FileBlock const &fb)
Definition: Worker.cc:119
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
virtual void implRespondToCloseInputFile(FileBlock const &fb)=0
Worker(ModuleDescription const &iMD, WorkerParams const &iWP)
Definition: Worker.cc:7
virtual void implEndJob()=0
void respondToCloseInputFile(FileBlock const &fb)
Definition: Worker.cc:128
Float_t e
Definition: plot.C:34
virtual void implRespondToOpenOutputFiles(FileBlock const &fb)=0
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33