Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-12 23:30:39

0001 #ifndef FastTimingSimProducers_FastTimingCommon_MTDDigitizerBase_h
0002 #define FastTimingSimProducers_FastTimingCommon_MTDDigitizerBase_h
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Utilities/interface/InputTag.h"
0006 #include "FWCore/Framework/interface/ConsumesCollector.h"
0007 #include "FWCore/Framework/interface/ProducesCollector.h"
0008 
0009 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0010 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0011 
0012 #include "DataFormats/FTLDigi/interface/FTLDigiCollections.h"
0013 #include "DataFormats/FTLDigi/interface/PMTDSimAccumulator.h"
0014 #include "SimFastTiming/FastTimingCommon/interface/MTDDigitizerTypes.h"
0015 
0016 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0017 
0018 #include <string>
0019 
0020 namespace CLHEP {
0021   class HepRandomEngine;
0022 }
0023 
0024 namespace edm {
0025   class Event;
0026   class EventSetup;
0027 }  // namespace edm
0028 
0029 class PileUpEventPrincipal;
0030 
0031 class MTDDigitizerBase {
0032 public:
0033   MTDDigitizerBase(const edm::ParameterSet& config,
0034                    edm::ProducesCollector producesCollector,
0035                    edm::ConsumesCollector& iC)
0036       : inputSimHits_(config.getParameter<edm::InputTag>("inputSimHits")),
0037         digiCollection_(config.getParameter<std::string>("digiCollectionTag")),
0038         verbosity_(config.getUntrackedParameter<uint32_t>("verbosity", 0)),
0039         refSpeed_(0.1 * CLHEP::c_light),
0040         premixStage1MinCharge_(config.getParameter<double>("premixStage1MinCharge")),
0041         premixStage1MaxCharge_(config.getParameter<double>("premixStage1MaxCharge")),
0042         premixStage1_(config.getParameter<bool>("premixStage1")),
0043         name_(config.getParameter<std::string>("digitizerName")) {
0044     iC.consumes<std::vector<PSimHit> >(inputSimHits_);
0045 
0046     if (name_ == "BTLDigitizer") {
0047       if (premixStage1_) {
0048         producesCollector.produces<PMTDSimAccumulator>(digiCollection_);
0049       } else {
0050         producesCollector.produces<BTLDigiCollection>(digiCollection_);
0051       }
0052     } else if (name_ == "ETLDigitizer")
0053       if (premixStage1_) {
0054         producesCollector.produces<PMTDSimAccumulator>(digiCollection_);
0055       } else {
0056         producesCollector.produces<ETLDigiCollection>(digiCollection_);
0057       }
0058     else
0059       throw cms::Exception("[MTDDigitizerBase::MTDDigitizerBase]") << name_ << " is an invalid MTD digitizer name";
0060   }
0061 
0062   virtual ~MTDDigitizerBase() {}
0063 
0064   /**
0065      @short handle SimHit accumulation
0066   */
0067   virtual void accumulate(edm::Event const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre) = 0;
0068   virtual void accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre) = 0;
0069   virtual void accumulate(edm::Handle<edm::PSimHitContainer> const& hits,
0070                           int bxCrossing,
0071                           CLHEP::HepRandomEngine* hre) = 0;
0072   // for premixing
0073   virtual void accumulate(const PMTDSimAccumulator& simAccumulator) = 0;
0074 
0075   /**
0076      @short actions at the start/end of event
0077   */
0078   virtual void initializeEvent(edm::Event const& e, edm::EventSetup const& c) = 0;
0079   virtual void finalizeEvent(edm::Event& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre) = 0;
0080 
0081   const std::string& name() const { return name_; }
0082 
0083 protected:
0084   //input/output names
0085   const edm::InputTag inputSimHits_;
0086   const std::string digiCollection_;
0087 
0088   //misc switches
0089   const uint32_t verbosity_;
0090 
0091   //reference speed to evaluate time of arrival at the sensititive detector, assuming the center of CMS
0092   const float refSpeed_;
0093 
0094   // Minimum charge threshold for premixing stage1
0095   double premixStage1MinCharge_;
0096   // Maximum charge for packing in premixing stage1
0097   double premixStage1MaxCharge_;
0098 
0099   // flag telling whether we are runing in premixing stage1
0100   const bool premixStage1_;
0101 
0102 private:
0103   std::string name_;
0104 };
0105 
0106 #include "FWCore/PluginManager/interface/PluginFactory.h"
0107 typedef edmplugin::PluginFactory<MTDDigitizerBase*(
0108     const edm::ParameterSet&, edm::ProducesCollector, edm::ConsumesCollector&)>
0109     MTDDigitizerFactory;
0110 
0111 #endif