Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-14 11:45:06

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/Framework
0004 // Class  :     global::EDAnalyzerBase
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Thu, 02 May 2013 21:56:04 GMT
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "FWCore/Framework/interface/global/EDAnalyzerBase.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/LuminosityBlock.h"
0019 #include "FWCore/Framework/interface/ProcessBlock.h"
0020 #include "FWCore/Framework/interface/Run.h"
0021 #include "FWCore/Framework/interface/EventSetup.h"
0022 #include "FWCore/Framework/src/edmodule_mightGet_config.h"
0023 #include "FWCore/Framework/interface/PreallocationConfiguration.h"
0024 #include "FWCore/Framework/src/EventSignalsSentry.h"
0025 #include "FWCore/Framework/interface/TransitionInfoTypes.h"
0026 
0027 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0029 
0030 #include "DataFormats/Provenance/interface/ProductRegistry.h"
0031 
0032 #include "FWCore/ServiceRegistry/interface/Service.h"
0033 #include "FWCore/ServiceRegistry/interface/ESParentContext.h"
0034 #include "FWCore/Framework/interface/ConstProductRegistry.h"
0035 
0036 //
0037 // constants, enums and typedefs
0038 //
0039 namespace edm {
0040   namespace global {
0041     //
0042     // static data member definitions
0043     //
0044 
0045     //
0046     // constructors and destructor
0047     //
0048     EDAnalyzerBase::EDAnalyzerBase() : moduleDescription_() {}
0049 
0050     EDAnalyzerBase::~EDAnalyzerBase() {}
0051 
0052     bool EDAnalyzerBase::doEvent(EventTransitionInfo const& info,
0053                                  ActivityRegistry* act,
0054                                  ModuleCallingContext const* mcc) {
0055       Event e(info, moduleDescription_, mcc);
0056       e.setConsumer(this);
0057       EventSignalsSentry sentry(act, mcc);
0058       ESParentContext parentC(mcc);
0059       const EventSetup c{
0060           info, static_cast<unsigned int>(Transition::Event), esGetTokenIndices(Transition::Event), parentC};
0061       this->analyze(e.streamID(), e, c);
0062       return true;
0063     }
0064 
0065     void EDAnalyzerBase::doPreallocate(PreallocationConfiguration const& iPrealloc) {
0066       preallocStreams(iPrealloc.numberOfStreams());
0067       preallocLumis(iPrealloc.numberOfLuminosityBlocks());
0068       preallocLumisSummary(iPrealloc.numberOfLuminosityBlocks());
0069       preallocate(iPrealloc);
0070     }
0071 
0072     void EDAnalyzerBase::doBeginJob() { this->beginJob(); }
0073 
0074     void EDAnalyzerBase::doEndJob() { this->endJob(); }
0075 
0076     void EDAnalyzerBase::doBeginProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0077       ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0078       processBlock.setConsumer(this);
0079       ProcessBlock const& constProcessBlock = processBlock;
0080       this->doBeginProcessBlock_(constProcessBlock);
0081     }
0082 
0083     void EDAnalyzerBase::doAccessInputProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0084       ProcessBlock processBlock(pbp, moduleDescription_, mcc, false);
0085       processBlock.setConsumer(this);
0086       ProcessBlock const& constProcessBlock = processBlock;
0087       this->doAccessInputProcessBlock_(constProcessBlock);
0088     }
0089 
0090     void EDAnalyzerBase::doEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) {
0091       ProcessBlock processBlock(pbp, moduleDescription_, mcc, true);
0092       processBlock.setConsumer(this);
0093       ProcessBlock const& constProcessBlock = processBlock;
0094       this->doEndProcessBlock_(constProcessBlock);
0095     }
0096 
0097     void EDAnalyzerBase::doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0098       Run r(info, moduleDescription_, mcc, false);
0099       r.setConsumer(this);
0100       Run const& cnstR = r;
0101       ESParentContext parentC(mcc);
0102       const EventSetup c{
0103           info, static_cast<unsigned int>(Transition::BeginRun), esGetTokenIndices(Transition::BeginRun), parentC};
0104       this->doBeginRun_(cnstR, c);
0105       this->doBeginRunSummary_(cnstR, c);
0106     }
0107 
0108     void EDAnalyzerBase::doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0109       Run r(info, moduleDescription_, mcc, true);
0110       r.setConsumer(this);
0111       Run const& cnstR = r;
0112       ESParentContext parentC(mcc);
0113       const EventSetup c{
0114           info, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC};
0115       this->doEndRunSummary_(r, c);
0116       this->doEndRun_(cnstR, c);
0117     }
0118 
0119     void EDAnalyzerBase::doBeginLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0120       LuminosityBlock lb(info, moduleDescription_, mcc, false);
0121       lb.setConsumer(this);
0122       LuminosityBlock const& cnstLb = lb;
0123       ESParentContext parentC(mcc);
0124       const EventSetup c{info,
0125                          static_cast<unsigned int>(Transition::BeginLuminosityBlock),
0126                          esGetTokenIndices(Transition::BeginLuminosityBlock),
0127                          parentC};
0128       this->doBeginLuminosityBlock_(cnstLb, c);
0129       this->doBeginLuminosityBlockSummary_(cnstLb, c);
0130     }
0131 
0132     void EDAnalyzerBase::doEndLuminosityBlock(LumiTransitionInfo const& info, ModuleCallingContext const* mcc) {
0133       LuminosityBlock lb(info, moduleDescription_, mcc, true);
0134       lb.setConsumer(this);
0135       LuminosityBlock const& cnstLb = lb;
0136       ESParentContext parentC(mcc);
0137       const EventSetup c{info,
0138                          static_cast<unsigned int>(Transition::EndLuminosityBlock),
0139                          esGetTokenIndices(Transition::EndLuminosityBlock),
0140                          parentC};
0141       this->doEndLuminosityBlockSummary_(cnstLb, c);
0142       this->doEndLuminosityBlock_(cnstLb, c);
0143     }
0144 
0145     void EDAnalyzerBase::doBeginStream(StreamID id) { doBeginStream_(id); }
0146     void EDAnalyzerBase::doEndStream(StreamID id) { doEndStream_(id); }
0147     void EDAnalyzerBase::doStreamBeginRun(StreamID id, RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0148       Run r(info, moduleDescription_, mcc, false);
0149       r.setConsumer(this);
0150       ESParentContext parentC(mcc);
0151       const EventSetup c{
0152           info, static_cast<unsigned int>(Transition::BeginRun), esGetTokenIndices(Transition::BeginRun), parentC};
0153       this->doStreamBeginRun_(id, r, c);
0154     }
0155     void EDAnalyzerBase::doStreamEndRun(StreamID id, RunTransitionInfo const& info, ModuleCallingContext const* mcc) {
0156       Run r(info, moduleDescription_, mcc, true);
0157       r.setConsumer(this);
0158       ESParentContext parentC(mcc);
0159       const EventSetup c{
0160           info, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC};
0161       this->doStreamEndRun_(id, r, c);
0162       this->doStreamEndRunSummary_(id, r, c);
0163     }
0164     void EDAnalyzerBase::doStreamBeginLuminosityBlock(StreamID id,
0165                                                       LumiTransitionInfo const& info,
0166                                                       ModuleCallingContext const* mcc) {
0167       LuminosityBlock lb(info, moduleDescription_, mcc, false);
0168       lb.setConsumer(this);
0169       ESParentContext parentC(mcc);
0170       const EventSetup c{info,
0171                          static_cast<unsigned int>(Transition::BeginLuminosityBlock),
0172                          esGetTokenIndices(Transition::BeginLuminosityBlock),
0173                          parentC};
0174       this->doStreamBeginLuminosityBlock_(id, lb, c);
0175     }
0176 
0177     void EDAnalyzerBase::doStreamEndLuminosityBlock(StreamID id,
0178                                                     LumiTransitionInfo const& info,
0179                                                     ModuleCallingContext const* mcc) {
0180       LuminosityBlock lb(info, moduleDescription_, mcc, true);
0181       lb.setConsumer(this);
0182       ESParentContext parentC(mcc);
0183       const EventSetup c{info,
0184                          static_cast<unsigned int>(Transition::EndLuminosityBlock),
0185                          esGetTokenIndices(Transition::EndLuminosityBlock),
0186                          parentC};
0187       this->doStreamEndLuminosityBlock_(id, lb, c);
0188       this->doStreamEndLuminosityBlockSummary_(id, lb, c);
0189     }
0190 
0191     void EDAnalyzerBase::preallocStreams(unsigned int) {}
0192     void EDAnalyzerBase::preallocLumis(unsigned int) {}
0193     void EDAnalyzerBase::preallocLumisSummary(unsigned int) {}
0194     void EDAnalyzerBase::preallocate(PreallocationConfiguration const&) {}
0195     void EDAnalyzerBase::doBeginStream_(StreamID id) {}
0196     void EDAnalyzerBase::doEndStream_(StreamID id) {}
0197     void EDAnalyzerBase::doStreamBeginRun_(StreamID id, Run const& rp, EventSetup const& c) {}
0198     void EDAnalyzerBase::doStreamEndRun_(StreamID id, Run const& rp, EventSetup const& c) {}
0199     void EDAnalyzerBase::doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c) {}
0200     void EDAnalyzerBase::doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c) {}
0201     void EDAnalyzerBase::doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c) {}
0202     void EDAnalyzerBase::doStreamEndLuminosityBlockSummary_(StreamID id,
0203                                                             LuminosityBlock const& lbp,
0204                                                             EventSetup const& c) {}
0205     void EDAnalyzerBase::doBeginProcessBlock_(ProcessBlock const&) {}
0206     void EDAnalyzerBase::doAccessInputProcessBlock_(ProcessBlock const&) {}
0207     void EDAnalyzerBase::doEndProcessBlock_(ProcessBlock const&) {}
0208     void EDAnalyzerBase::doBeginRun_(Run const& rp, EventSetup const& c) {}
0209     void EDAnalyzerBase::doEndRun_(Run const& rp, EventSetup const& c) {}
0210     void EDAnalyzerBase::doBeginRunSummary_(Run const& rp, EventSetup const& c) {}
0211     void EDAnalyzerBase::doEndRunSummary_(Run const& rp, EventSetup const& c) {}
0212 
0213     void EDAnalyzerBase::doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0214     void EDAnalyzerBase::doEndLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c) {}
0215     void EDAnalyzerBase::doBeginLuminosityBlockSummary_(LuminosityBlock const& rp, EventSetup const& c) {}
0216     void EDAnalyzerBase::doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c) {}
0217 
0218     void EDAnalyzerBase::clearInputProcessBlockCaches() {}
0219 
0220     void EDAnalyzerBase::fillDescriptions(ConfigurationDescriptions& descriptions) {
0221       ParameterSetDescription desc;
0222       desc.setUnknown();
0223       descriptions.addDefault(desc);
0224     }
0225 
0226     void EDAnalyzerBase::prevalidate(ConfigurationDescriptions& iConfig) { edmodule_mightGet_config(iConfig); }
0227 
0228     void EDAnalyzerBase::registerProductsAndCallbacks(EDAnalyzerBase*, ProductRegistry* reg) {
0229       if (callWhenNewProductsRegistered_) {
0230         reg->callForEachBranch(callWhenNewProductsRegistered_);
0231 
0232         Service<ConstProductRegistry> regService;
0233         regService->watchProductAdditions(callWhenNewProductsRegistered_);
0234       }
0235     }
0236     static const std::string kBaseType("EDAnalyzer");
0237 
0238     const std::string& EDAnalyzerBase::baseType() { return kBaseType; }
0239 
0240   }  // namespace global
0241 }  // namespace edm