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