Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-19 23:20:03

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