Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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