Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef SimMuon_DTDigitizer_h
0002 #define SimMuon_DTDigitizer_h
0003 
0004 /** \class DTDigitizer
0005  *  Digitize the muon drift tubes.
0006  *  The parametrisation function in DTDriftTimeParametrization
0007  *  from P.G.Abia, J.Puerta is used in all cases where it is applicable.
0008  *
0009  *  \authors: G. Bevilacqua, N. Amapane, G. Cerminara, R. Bellan
0010  */
0011 
0012 #include "FWCore/Framework/interface/stream/EDProducer.h"
0013 
0014 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
0015 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0016 #include "FWCore/Framework/interface/ConsumesCollector.h"
0017 #include "SimDataFormats/DigiSimLinks/interface/DTDigiSimLinkCollection.h"
0018 #include "FWCore/Utilities/interface/ESGetToken.h"
0019 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0020 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0021 
0022 #include "DataFormats/GeometryVector/interface/LocalVector.h"
0023 // SimHits
0024 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0025 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0026 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0027 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0028 // Magnetic Field
0029 #include "MagneticField/Engine/interface/MagneticField.h"
0030 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0031 
0032 #include <memory>
0033 #include <vector>
0034 
0035 namespace CLHEP {
0036   class HepRandomEngine;
0037 }
0038 
0039 class DTLayer;
0040 class PSimHit;
0041 class DTWireType;
0042 class DTBaseDigiSync;
0043 class DTTopology;
0044 class DTDigiSyncBase;
0045 
0046 namespace edm {
0047   class ParameterSet;
0048   class Event;
0049   class EventSetup;
0050 }  // namespace edm
0051 
0052 class DTDigitizer : public edm::stream::EDProducer<> {
0053 public:
0054   explicit DTDigitizer(const edm::ParameterSet &);
0055 
0056   void produce(edm::Event &, const edm::EventSetup &) override;
0057 
0058 private:
0059   typedef std::pair<const PSimHit *, float> hitAndT;  // hit & corresponding time
0060   typedef std::vector<hitAndT> TDContainer;           // hits & times for one wire
0061 
0062   typedef std::map<DTWireId, std::vector<const PSimHit *>> DTWireIdMap;
0063   typedef DTWireIdMap::iterator DTWireIdMapIter;
0064   typedef DTWireIdMap::const_iterator DTWireIdMapConstIter;
0065 
0066   // Sort hits container by time.
0067   struct hitLessT {
0068     bool operator()(const hitAndT &h1, const hitAndT &h2) {
0069       if (h1.second < h2.second)
0070         return true;
0071       return false;
0072     }
0073   };
0074 
0075   // Calculate the drift time for one hit.
0076   // if status flag == false, hit has to be discarded.
0077   std::pair<float, bool> computeTime(const DTLayer *layer,
0078                                      const DTWireId &wireId,
0079                                      const PSimHit *hit,
0080                                      const LocalVector &BLoc,
0081                                      CLHEP::HepRandomEngine *);  // FIXME??
0082 
0083   // Calculate the drift time using the GARFIELD cell parametrization,
0084   // taking care of all conversions from CMSSW local coordinates
0085   // to the conventions used for the parametrization.
0086   std::pair<float, bool> driftTimeFromParametrization(
0087       float x, float alpha, float By, float Bz, CLHEP::HepRandomEngine *) const;
0088 
0089   // Calculate the drift time for the cases where it is not possible
0090   // to use the GARFIELD cell parametrization.
0091   std::pair<float, bool> driftTimeFromTimeMap() const;
0092 
0093   // Add all delays other than drift times (signal propagation along the wire,
0094   // TOF etc.; subtract calibration time.
0095   float externalDelays(const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit) const;
0096 
0097   // Store digis for one wire, taking into account the dead time.
0098   // FiXME put alias for the map.
0099   void storeDigis(DTWireId &wireId, TDContainer &hits, DTDigiCollection &output, DTDigiSimLinkCollection &outputLinks);
0100 
0101   // Debug output
0102   void dumpHit(const PSimHit *hit, float xEntry, float xExit, const DTTopology &topo);
0103 
0104   // Double half-gaussian smearing.
0105   float asymGausSmear(double mean, double sigmaLeft, double sigmaRight, CLHEP::HepRandomEngine *) const;
0106 
0107   // Allow debugging and testing.
0108   friend class DTDigitizerAnalysis;
0109 
0110   // Its Atributes:
0111   double vPropWire;
0112   float deadTime;
0113   float smearing;
0114   bool debug;
0115   bool interpolate;
0116   bool onlyMuHits;
0117   int base;
0118 
0119   std::string syncName;
0120   std::unique_ptr<DTDigiSyncBase> theSync;
0121 
0122   std::string geometryType;
0123 
0124   // Ideal model. Used for debug
0125   bool IdealModel;
0126   float theConstVDrift;
0127 
0128   // to configure the creation of Digi-Sim links
0129   bool MultipleLinks;
0130   float LinksTimeWindow;
0131 
0132   // Name of Collection use for create the XF
0133   std::string mix_;
0134   std::string collection_for_XF;
0135 
0136   edm::EDGetTokenT<CrossingFrame<PSimHit>> cf_token;
0137   edm::ESGetToken<DTGeometry, MuonGeometryRecord> muonGeom_token;
0138   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magnField_token;
0139 };
0140 #endif