00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "FWCore/Services/src/Tracer.h"
00015
00016 #include "DataFormats/Provenance/interface/EventID.h"
00017 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
00018 #include "DataFormats/Provenance/interface/ModuleDescription.h"
00019 #include "DataFormats/Provenance/interface/RunID.h"
00020 #include "DataFormats/Provenance/interface/Timestamp.h"
00021
00022 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00023 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00024
00025
00026 #include <iostream>
00027
00028 using namespace edm::service;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 Tracer::Tracer(ParameterSet const& iPS, ActivityRegistry&iRegistry) :
00041 indention_(iPS.getUntrackedParameter<std::string>("indention")),
00042 depth_(0) {
00043 iRegistry.watchPostBeginJob(this, &Tracer::postBeginJob);
00044 iRegistry.watchPostEndJob(this, &Tracer::postEndJob);
00045
00046 iRegistry.watchPreModule(this, &Tracer::preModuleEvent);
00047 iRegistry.watchPostModule(this, &Tracer::postModuleEvent);
00048
00049 iRegistry.watchPreSourceConstruction(this, &Tracer::preSourceConstruction);
00050 iRegistry.watchPostSourceConstruction(this, &Tracer::postSourceConstruction);
00051
00052 iRegistry.watchPreModuleConstruction(this, &Tracer::preModuleConstruction);
00053 iRegistry.watchPostModuleConstruction(this, &Tracer::postModuleConstruction);
00054
00055 iRegistry.watchPreModuleBeginJob(this, &Tracer::preModuleBeginJob);
00056 iRegistry.watchPostModuleBeginJob(this, &Tracer::postModuleBeginJob);
00057
00058 iRegistry.watchPreModuleEndJob(this, &Tracer::preModuleEndJob);
00059 iRegistry.watchPostModuleEndJob(this, &Tracer::postModuleEndJob);
00060
00061 iRegistry.watchPreModuleBeginRun(this, &Tracer::preModuleBeginRun);
00062 iRegistry.watchPostModuleBeginRun(this, &Tracer::postModuleBeginRun);
00063
00064 iRegistry.watchPreModuleEndRun(this, &Tracer::preModuleEndRun);
00065 iRegistry.watchPostModuleEndRun(this, &Tracer::postModuleEndRun);
00066
00067 iRegistry.watchPreModuleBeginLumi(this, &Tracer::preModuleBeginLumi);
00068 iRegistry.watchPostModuleBeginLumi(this, &Tracer::postModuleBeginLumi);
00069
00070 iRegistry.watchPreModuleEndLumi(this, &Tracer::preModuleEndLumi);
00071 iRegistry.watchPostModuleEndLumi(this, &Tracer::postModuleEndLumi);
00072
00073 iRegistry.watchPreProcessPath(this, &Tracer::prePathEvent);
00074 iRegistry.watchPostProcessPath(this, &Tracer::postPathEvent);
00075
00076 iRegistry.watchPrePathBeginRun(this, &Tracer::prePathBeginRun);
00077 iRegistry.watchPostPathBeginRun(this, &Tracer::postPathBeginRun);
00078
00079 iRegistry.watchPrePathEndRun(this, &Tracer::prePathEndRun);
00080 iRegistry.watchPostPathEndRun(this, &Tracer::postPathEndRun);
00081
00082 iRegistry.watchPrePathBeginLumi(this, &Tracer::prePathBeginLumi);
00083 iRegistry.watchPostPathBeginLumi(this, &Tracer::postPathBeginLumi);
00084
00085 iRegistry.watchPrePathEndLumi(this, &Tracer::prePathEndLumi);
00086 iRegistry.watchPostPathEndLumi(this, &Tracer::postPathEndLumi);
00087
00088 iRegistry.watchPreProcessEvent(this, &Tracer::preEvent);
00089 iRegistry.watchPostProcessEvent(this, &Tracer::postEvent);
00090
00091 iRegistry.watchPreBeginRun(this, &Tracer::preBeginRun);
00092 iRegistry.watchPostBeginRun(this, &Tracer::postBeginRun);
00093
00094 iRegistry.watchPreEndRun(this, &Tracer::preEndRun);
00095 iRegistry.watchPostEndRun(this, &Tracer::postEndRun);
00096
00097 iRegistry.watchPreBeginLumi(this, &Tracer::preBeginLumi);
00098 iRegistry.watchPostBeginLumi(this, &Tracer::postBeginLumi);
00099
00100 iRegistry.watchPreEndLumi(this, &Tracer::preEndLumi);
00101 iRegistry.watchPostEndLumi(this, &Tracer::postEndLumi);
00102
00103 iRegistry.watchPreSource(this, &Tracer::preSourceEvent);
00104 iRegistry.watchPostSource(this, &Tracer::postSourceEvent);
00105
00106 iRegistry.watchPreOpenFile(this, &Tracer::preOpenFile);
00107 iRegistry.watchPostOpenFile(this, &Tracer::postOpenFile);
00108
00109 iRegistry.watchPreCloseFile(this, &Tracer::preCloseFile);
00110 iRegistry.watchPostCloseFile(this, &Tracer::postCloseFile);
00111
00112 iRegistry.watchPreSourceRun(this, &Tracer::preSourceRun);
00113 iRegistry.watchPostSourceRun(this, &Tracer::postSourceRun);
00114
00115 iRegistry.watchPreSourceLumi(this, &Tracer::preSourceLumi);
00116 iRegistry.watchPostSourceLumi(this, &Tracer::postSourceLumi);
00117
00118 }
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 void
00130 Tracer::fillDescriptions(edm::ConfigurationDescriptions & descriptions) {
00131
00132 edm::ParameterSetDescription desc;
00133 desc.addUntracked<std::string>("indention", "++")->setComment("Prefix characters for output. The characters are repeated to form the indentation.");
00134 descriptions.add("Tracer", desc);
00135 descriptions.setComment("This service prints each phase the framework is processing, e.g. constructing a module,running a module, etc.");
00136 }
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 void
00154 Tracer::postBeginJob() {
00155 std::cout << indention_ << " Job started" << std::endl;
00156 }
00157 void
00158 Tracer::postEndJob() {
00159 std::cout << indention_ << " Job ended" << std::endl;
00160 }
00161
00162 void
00163 Tracer::preSourceEvent() {
00164 std::cout << indention_ << indention_ << "source event" << std::endl;
00165 }
00166 void
00167 Tracer::postSourceEvent () {
00168 std::cout << indention_ << indention_ << "finished: source event" << std::endl;
00169 }
00170
00171 void
00172 Tracer::preSourceLumi() {
00173 std::cout << indention_ << indention_ << "source lumi" << std::endl;
00174 }
00175 void
00176 Tracer::postSourceLumi () {
00177 std::cout << indention_ << indention_ << "finished: source lumi" << std::endl;
00178 }
00179
00180 void
00181 Tracer::preSourceRun() {
00182 std::cout << indention_ << indention_ << "source run" << std::endl;
00183 }
00184 void
00185 Tracer::postSourceRun () {
00186 std::cout << indention_ << indention_ << "finished: source run" << std::endl;
00187 }
00188
00189 void
00190 Tracer::preOpenFile() {
00191 std::cout << indention_ << indention_ << "open input file" << std::endl;
00192 }
00193 void
00194 Tracer::postOpenFile () {
00195 std::cout << indention_ << indention_ << "finished: open input file" << std::endl;
00196 }
00197
00198 void
00199 Tracer::preCloseFile() {
00200 std::cout << indention_ << indention_ << "close input file" << std::endl;
00201 }
00202 void
00203 Tracer::postCloseFile () {
00204 std::cout << indention_ << indention_ << "finished: close input file" << std::endl;
00205 }
00206
00207 void
00208 Tracer::preEvent(EventID const& iID, Timestamp const& iTime) {
00209 depth_=0;
00210 std::cout << indention_ << indention_ << " processing event:" << iID << " time:" << iTime.value() << std::endl;
00211 }
00212 void
00213 Tracer::postEvent(Event const&, EventSetup const&) {
00214 std::cout << indention_ << indention_ << " finished event:" << std::endl;
00215 }
00216
00217 void
00218 Tracer::prePathEvent(std::string const& iName) {
00219 std::cout << indention_ << indention_ << indention_ << " processing path for event:" << iName << std::endl;
00220 }
00221 void
00222 Tracer::postPathEvent(std::string const& iName, HLTPathStatus const&) {
00223 std::cout << indention_ << indention_ << indention_ << " finished path for event:" << iName << std::endl;
00224 }
00225
00226 void
00227 Tracer::preModuleEvent(ModuleDescription const& iDescription) {
00228 ++depth_;
00229 std::cout << indention_ << indention_ << indention_;
00230 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00231 std::cout << indention_;
00232 }
00233 std::cout << " module for event:" << iDescription.moduleLabel() << std::endl;
00234 }
00235 void
00236 Tracer::postModuleEvent(ModuleDescription const& iDescription) {
00237 --depth_;
00238 std::cout << indention_ << indention_ << indention_ << indention_;
00239 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00240 std::cout << indention_;
00241 }
00242
00243 std::cout << " finished for event:" << iDescription.moduleLabel() << std::endl;
00244 }
00245
00246 void
00247 Tracer::preBeginRun(RunID const& iID, Timestamp const& iTime) {
00248 depth_=0;
00249 std::cout << indention_ << indention_ << " processing begin run:" << iID << " time:" << iTime.value() << std::endl;
00250 }
00251 void
00252 Tracer::postBeginRun(Run const&, EventSetup const&) {
00253 std::cout << indention_ << indention_ << " finished begin run:" << std::endl;
00254 }
00255
00256 void
00257 Tracer::prePathBeginRun(std::string const& iName) {
00258 std::cout << indention_ << indention_ << indention_ << " processing path for begin run:" << iName << std::endl;
00259 }
00260 void
00261 Tracer::postPathBeginRun(std::string const& iName, HLTPathStatus const&) {
00262 std::cout << indention_ << indention_ << indention_ << " finished path for begin run:" << iName << std::endl;
00263 }
00264
00265 void
00266 Tracer::preModuleBeginRun(ModuleDescription const& iDescription) {
00267 ++depth_;
00268 std::cout << indention_ << indention_ << indention_;
00269 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00270 std::cout << indention_;
00271 }
00272 std::cout << " module for begin run:" << iDescription.moduleLabel() << std::endl;
00273 }
00274 void
00275 Tracer::postModuleBeginRun(ModuleDescription const& iDescription) {
00276 --depth_;
00277 std::cout << indention_ << indention_ << indention_ << indention_;
00278 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00279 std::cout << indention_;
00280 }
00281
00282 std::cout << " finished for begin run:" << iDescription.moduleLabel() << std::endl;
00283 }
00284
00285 void
00286 Tracer::preEndRun(RunID const& iID, Timestamp const& iTime) {
00287 depth_=0;
00288 std::cout << indention_ << indention_ << " processing end run:" << iID << " time:" << iTime.value() << std::endl;
00289 }
00290 void
00291 Tracer::postEndRun(Run const&, EventSetup const&) {
00292 std::cout << indention_ << indention_ << " finished end run:" << std::endl;
00293 }
00294
00295 void
00296 Tracer::prePathEndRun(std::string const& iName) {
00297 std::cout << indention_ << indention_ << indention_ << " processing path for end run:" << iName << std::endl;
00298 }
00299 void
00300 Tracer::postPathEndRun(std::string const& iName, HLTPathStatus const&) {
00301 std::cout << indention_ << indention_ << indention_ << " finished path for end run:" << iName << std::endl;
00302 }
00303
00304 void
00305 Tracer::preModuleEndRun(ModuleDescription const& iDescription) {
00306 ++depth_;
00307 std::cout << indention_ << indention_ << indention_;
00308 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00309 std::cout << indention_;
00310 }
00311 std::cout << " module for end run:" << iDescription.moduleLabel() << std::endl;
00312 }
00313 void
00314 Tracer::postModuleEndRun(ModuleDescription const& iDescription) {
00315 --depth_;
00316 std::cout << indention_ << indention_ << indention_ << indention_;
00317 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00318 std::cout << indention_;
00319 }
00320
00321 std::cout << " finished for end run:" << iDescription.moduleLabel() << std::endl;
00322 }
00323
00324 void
00325 Tracer::preBeginLumi(LuminosityBlockID const& iID, Timestamp const& iTime) {
00326 depth_=0;
00327 std::cout << indention_ << indention_ << " processing begin lumi:" << iID << " time:" << iTime.value() << std::endl;
00328 }
00329 void
00330 Tracer::postBeginLumi(LuminosityBlock const&, EventSetup const&) {
00331 std::cout << indention_ << indention_ << " finished begin lumi:" << std::endl;
00332 }
00333
00334 void
00335 Tracer::prePathBeginLumi(std::string const& iName) {
00336 std::cout << indention_ << indention_ << indention_ << " processing path for begin lumi:" << iName << std::endl;
00337 }
00338 void
00339 Tracer::postPathBeginLumi(std::string const& iName, HLTPathStatus const&) {
00340 std::cout << indention_ << indention_ << indention_ << " finished path for begin lumi:" << iName << std::endl;
00341 }
00342
00343 void
00344 Tracer::preModuleBeginLumi(ModuleDescription const& iDescription) {
00345 ++depth_;
00346 std::cout << indention_ << indention_ << indention_;
00347 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00348 std::cout << indention_;
00349 }
00350 std::cout << " module for begin lumi:" << iDescription.moduleLabel() << std::endl;
00351 }
00352 void
00353 Tracer::postModuleBeginLumi(ModuleDescription const& iDescription) {
00354 --depth_;
00355 std::cout << indention_ << indention_ << indention_ << indention_;
00356 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00357 std::cout << indention_;
00358 }
00359
00360 std::cout << " finished for begin lumi:" << iDescription.moduleLabel() << std::endl;
00361 }
00362
00363 void
00364 Tracer::preEndLumi(LuminosityBlockID const& iID, Timestamp const& iTime) {
00365 depth_ = 0;
00366 std::cout << indention_ << indention_ << " processing end lumi:" << iID << " time:" << iTime.value() << std::endl;
00367 }
00368 void
00369 Tracer::postEndLumi(LuminosityBlock const&, EventSetup const&) {
00370 std::cout << indention_ << indention_ << " finished end lumi:" << std::endl;
00371 }
00372
00373 void
00374 Tracer::prePathEndLumi(std::string const& iName) {
00375 std::cout << indention_ << indention_ << indention_ << " processing path for end lumi:" << iName << std::endl;
00376 }
00377
00378 void
00379 Tracer::postPathEndLumi(std::string const& iName, HLTPathStatus const&) {
00380 std::cout << indention_ << indention_ << indention_ << " finished path for end lumi:" << iName << std::endl;
00381 }
00382
00383 void
00384 Tracer::preModuleEndLumi(ModuleDescription const& iDescription) {
00385 ++depth_;
00386 std::cout << indention_ << indention_ << indention_;
00387 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00388 std::cout << indention_;
00389 }
00390 std::cout << " module for end lumi:" << iDescription.moduleLabel() << std::endl;
00391 }
00392
00393 void
00394 Tracer::postModuleEndLumi(ModuleDescription const& iDescription) {
00395 --depth_;
00396 std::cout << indention_ << indention_ << indention_ << indention_;
00397 for(unsigned int depth = 0; depth !=depth_; ++depth) {
00398 std::cout << indention_;
00399 }
00400
00401 std::cout << " finished for end lumi:" << iDescription.moduleLabel() << std::endl;
00402 }
00403
00404 void
00405 Tracer::preSourceConstruction(ModuleDescription const& iDescription) {
00406 std::cout << indention_;
00407 std::cout << " constructing source:" << iDescription.moduleName() << std::endl;
00408 }
00409
00410 void
00411 Tracer::postSourceConstruction(ModuleDescription const& iDescription) {
00412 std::cout << indention_;
00413 std::cout << " construction finished:" << iDescription.moduleName() << std::endl;
00414 }
00415
00416 void
00417 Tracer::preModuleConstruction(ModuleDescription const& iDescription) {
00418 std::cout << indention_;
00419 std::cout << " constructing module:" << iDescription.moduleLabel() << std::endl;
00420 }
00421
00422 void
00423 Tracer::postModuleConstruction(ModuleDescription const& iDescription) {
00424 std::cout << indention_;
00425 std::cout << " construction finished:" << iDescription.moduleLabel() << std::endl;
00426 }
00427
00428 void
00429 Tracer::preModuleBeginJob(ModuleDescription const& iDescription) {
00430 std::cout << indention_;
00431 std::cout << " beginJob module:" << iDescription.moduleLabel() << std::endl;
00432 }
00433
00434 void
00435 Tracer::postModuleBeginJob(ModuleDescription const& iDescription) {
00436 std::cout << indention_;
00437 std::cout << " beginJob finished:" << iDescription.moduleLabel() << std::endl;
00438 }
00439
00440 void
00441 Tracer::preModuleEndJob(ModuleDescription const& iDescription) {
00442 std::cout << indention_;
00443 std::cout << " endJob module:" << iDescription.moduleLabel() << std::endl;
00444 }
00445
00446 void
00447 Tracer::postModuleEndJob(ModuleDescription const& iDescription) {
00448 std::cout << indention_;
00449 std::cout << " endJob finished:" << iDescription.moduleLabel() << std::endl;
00450 }
00451
00452
00453
00454
00455
00456
00457
00458
00459