Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:31

0001 /** \class DTTTrigSyncT0Only
0002  *  Concrete implementation of a DTTTrigBaseSync.
0003  *  This plugin reads only the t0 from pulses from the DB.
0004  *
0005  *
0006  *  \author G. Cerminara - INFN Torino
0007  */
0008 
0009 #include "CalibMuon/DTDigiSync/interface/DTTTrigBaseSync.h"
0010 #include "FWCore/Framework/interface/ConsumesCollector.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0016 #include "CondFormats/DTObjects/interface/DTT0.h"
0017 #include "CondFormats/DataRecord/interface/DTT0Rcd.h"
0018 
0019 #include <iostream>
0020 
0021 namespace edm {
0022   class ParameterSet;
0023 }
0024 
0025 class DTTTrigSyncT0Only : public DTTTrigBaseSync {
0026 public:
0027   /// Constructor
0028   DTTTrigSyncT0Only(const edm::ParameterSet& config, edm::ConsumesCollector);
0029 
0030   /// Destructor
0031   ~DTTTrigSyncT0Only() override;
0032 
0033   // Operations
0034 
0035   /// Pass the Event Setup to the algo at each event
0036   void setES(const edm::EventSetup& setup) override;
0037 
0038   /// Time (ns) to be subtracted to the digi time,
0039   /// Parameters are the layer and the wireId to which the
0040   /// digi is referred and the estimation of
0041   /// the 3D hit position (globPos)
0042   double offset(const DTLayer* layer,
0043                 const DTWireId& wireId,
0044                 const GlobalPoint& globPos,
0045                 double& tTrig,
0046                 double& wirePropCorr,
0047                 double& tofCorr) const override;
0048 
0049   double offset(const DTWireId& wireId) const override;
0050 
0051   /// Time (ns) to be subtracted to the digi time for emulation purposes
0052   /// Returns just 0 in this implementation of the plugin
0053   double emulatorOffset(const DTWireId& wireId, double& tTrig, double& t0cell) const override;
0054 
0055 private:
0056   const DTT0* tZeroMap;
0057   edm::ESGetToken<DTT0, DTT0Rcd> t0Token_;
0058 
0059   // Set the verbosity level
0060   const bool debug;
0061 };
0062 
0063 using namespace std;
0064 using namespace edm;
0065 
0066 DTTTrigSyncT0Only::DTTTrigSyncT0Only(const ParameterSet& config, edm::ConsumesCollector cc)
0067     : t0Token_(cc.esConsumes()), debug(config.getUntrackedParameter<bool>("debug")) {}
0068 
0069 DTTTrigSyncT0Only::~DTTTrigSyncT0Only() {}
0070 
0071 void DTTTrigSyncT0Only::setES(const EventSetup& setup) {
0072   tZeroMap = &setup.getData(t0Token_);
0073 
0074   if (debug) {
0075     edm::LogPrint("[DTTTrigSyncT0Only]") << "T0 version: " << tZeroMap->version() << endl;
0076   }
0077 }
0078 
0079 double DTTTrigSyncT0Only::offset(const DTLayer* layer,
0080                                  const DTWireId& wireId,
0081                                  const GlobalPoint& globPos,
0082                                  double& tTrig,
0083                                  double& wirePropCorr,
0084                                  double& tofCorr) const {
0085   tTrig = offset(wireId);
0086   wirePropCorr = 0;
0087   tofCorr = 0;
0088 
0089   if (debug) {
0090     edm::LogPrint("[DTTTrigSyncT0Only]") << "Offset (ns): " << tTrig + wirePropCorr - tofCorr << endl
0091                                          << "      various contributions are: "
0092                                          << endl
0093                                          //<< "      tZero (ns):   " << t0 << endl
0094                                          << "      Propagation along wire delay (ns): " << wirePropCorr << endl
0095                                          << "      TOF correction (ns): " << tofCorr << endl
0096                                          << endl;
0097   }
0098   //The global offset is the sum of various contributions
0099   return tTrig + wirePropCorr - tofCorr;
0100 }
0101 
0102 double DTTTrigSyncT0Only::offset(const DTWireId& wireId) const {
0103   float t0 = 0;
0104   float t0rms = 0;
0105   tZeroMap->get(wireId, t0, t0rms, DTTimeUnits::ns);
0106 
0107   return t0;
0108 }
0109 
0110 double DTTTrigSyncT0Only::emulatorOffset(const DTWireId& wireId, double& tTrig, double& t0cell) const {
0111   tTrig = 0.;
0112   t0cell = 0.;
0113   return 0.;
0114 }
0115 
0116 #include "FWCore/PluginManager/interface/PluginFactory.h"
0117 #include "CalibMuon/DTDigiSync/interface/DTTTrigSyncFactory.h"
0118 
0119 DEFINE_EDM_PLUGIN(DTTTrigSyncFactory, DTTTrigSyncT0Only, "DTTTrigSyncT0Only");