Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:59

0001 #ifndef SiStripDigitizer_h
0002 #define SiStripDigitizer_h
0003 
0004 #include <map>
0005 #include <memory>
0006 #include <string>
0007 #include <vector>
0008 #include <bitset>
0009 #include "CalibFormats/SiStripObjects/interface/SiStripGain.h"
0010 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0011 #include "CalibTracker/Records/interface/SiStripDependentRecords.h"
0012 #include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"
0013 #include "CondFormats/SiStripObjects/interface/SiStripApvSimulationParameters.h"
0014 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
0015 #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
0016 #include "CondFormats/SiStripObjects/interface/SiStripThreshold.h"
0017 #include "FWCore/Framework/interface/ProducesCollector.h"
0018 #include "FWCore/Utilities/interface/ESGetToken.h"
0019 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0020 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0021 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0022 #include "SimDataFormats/PileupSummaryInfo/interface/PileupMixingContent.h"
0023 #include "SimGeneral/MixingModule/interface/DigiAccumulatorMixMod.h"
0024 
0025 class TrackerTopology;
0026 
0027 namespace CLHEP {
0028   class HepRandomEngine;
0029 }
0030 
0031 namespace edm {
0032   class ConsumesCollector;
0033   class Event;
0034   class EventSetup;
0035   class ParameterSet;
0036   template <typename T>
0037   class Handle;
0038   class StreamID;
0039 }  // namespace edm
0040 
0041 class MagneticField;
0042 class PileUpEventPrincipal;
0043 class PSimHit;
0044 class SiStripDigitizerAlgorithm;
0045 class StripGeomDetUnit;
0046 class TrackerGeometry;
0047 class SiStripBadStrip;
0048 
0049 /** @brief Accumulator to perform digitisation on the strip tracker sim hits.
0050  *
0051  * @author original author unknown; converted from a producer to a MixingModule accumulator by Bill
0052  * Tanenbaum; functionality to create digi-sim links moved from Bill's DigiSimLinkProducer into here
0053  * by Mark Grimes (mark.grimes@bristol.ac.uk).
0054  * @date original date unknown; moved into a MixingModule accumulator mid to late 2012; digi sim links
0055  * eventually finished May 2013
0056  */
0057 class SiStripDigitizer : public DigiAccumulatorMixMod {
0058 public:
0059   explicit SiStripDigitizer(const edm::ParameterSet& conf, edm::ProducesCollector, edm::ConsumesCollector& iC);
0060 
0061   ~SiStripDigitizer() override;
0062 
0063   void initializeEvent(edm::Event const& e, edm::EventSetup const& c) override;
0064   void accumulate(edm::Event const& e, edm::EventSetup const& c) override;
0065   void accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& c, edm::StreamID const&) override;
0066   void finalizeEvent(edm::Event& e, edm::EventSetup const& c) override;
0067 
0068   void StorePileupInformation(std::vector<int>& numInteractionList,
0069                               std::vector<int>& bunchCrossingList,
0070                               std::vector<float>& TrueInteractionList,
0071                               std::vector<edm::EventID>& eventInfoList,
0072                               int bunchSpacing) override {
0073     PileupInfo_ = std::make_unique<PileupMixingContent>(
0074         numInteractionList, bunchCrossingList, TrueInteractionList, eventInfoList, bunchSpacing);
0075   }
0076 
0077   PileupMixingContent* getEventPileupInfo() override { return PileupInfo_.get(); }
0078 
0079 private:
0080   void accumulateStripHits(edm::Handle<std::vector<PSimHit>>,
0081                            const TrackerTopology* tTopo,
0082                            size_t globalSimHitIndex,
0083                            const unsigned int tofBin);
0084 
0085   typedef std::vector<std::string> vstring;
0086   typedef std::map<unsigned int, std::vector<std::pair<const PSimHit*, int>>, std::less<unsigned int>> simhit_map;
0087   typedef simhit_map::iterator simhit_map_iterator;
0088 
0089   const std::string hitsProducer;
0090   const vstring trackerContainers;
0091   const std::string ZSDigi;
0092   const std::string SCDigi;
0093   const std::string VRDigi;
0094   const std::string PRDigi;
0095   const bool useConfFromDB;
0096   const bool zeroSuppression;
0097   const bool makeDigiSimLinks_;
0098   const bool includeAPVSimulation_;
0099   const double fracOfEventsToSimAPV_;
0100   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0101   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> pDDToken_;
0102   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> pSetupToken_;
0103   const edm::ESGetToken<SiStripGain, SiStripGainSimRcd> gainToken_;
0104   const edm::ESGetToken<SiStripNoises, SiStripNoisesRcd> noiseToken_;
0105   const edm::ESGetToken<SiStripThreshold, SiStripThresholdRcd> thresholdToken_;
0106   const edm::ESGetToken<SiStripPedestals, SiStripPedestalsRcd> pedestalToken_;
0107   const edm::ESGetToken<SiStripBadStrip, SiStripBadChannelRcd> deadChannelToken_;
0108   edm::ESGetToken<SiStripDetCabling, SiStripDetCablingRcd> detCablingToken_;
0109   edm::ESGetToken<SiStripApvSimulationParameters, SiStripApvSimulationParametersRcd> apvSimulationParametersToken_;
0110 
0111   unsigned long long ddCacheID_ = 0;
0112   unsigned long long deadChannelCacheID_ = 0;
0113 
0114   ///< Whether or not to create the association to sim truth collection. Set in configuration.
0115   /** @brief Offset to add to the index of each sim hit to account for which crossing it's in.
0116    *
0117    * I need to know what each sim hit index will be when the hits from all crossing frames are merged into
0118    * one collection (assuming the MixingModule is configured to create the crossing frame for all sim hits).
0119    * To do this I'll record how many hits were in each crossing, and then add that on to the index for a given
0120    * hit in a given crossing. This assumes that the crossings are processed in the same order here as they are
0121    * put into the crossing frame, which I'm pretty sure is true.<br/>
0122    * The key is the name of the sim hit collection. */
0123   std::map<std::string, size_t> crossingSimHitIndexOffset_;
0124 
0125   std::unique_ptr<SiStripDigitizerAlgorithm> theDigiAlgo;
0126   std::map<uint32_t, std::vector<int>> theDetIdList;
0127   const TrackerGeometry* pDD = nullptr;
0128   const MagneticField* pSetup = nullptr;
0129   std::map<unsigned int, StripGeomDetUnit const*> detectorUnits;
0130   CLHEP::HepRandomEngine* randomEngine_ = nullptr;
0131   std::vector<std::pair<int, std::bitset<6>>> theAffectedAPVvector;
0132 
0133   std::unique_ptr<PileupMixingContent> PileupInfo_;
0134 };
0135 
0136 #endif