File indexing completed on 2023-10-25 10:00:22
0001
0002
0003
0004
0005
0006
0007 #include "RecoLocalMuon/DTRecHit/plugins/DTLinearDriftAlgo.h"
0008 #include "CalibMuon/DTDigiSync/interface/DTTTrigBaseSync.h"
0009 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0010 #include "Geometry/DTGeometry/interface/DTLayer.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/ConsumesCollector.h"
0014 #include "FWCore/Utilities/interface/Exception.h"
0015
0016 using namespace std;
0017 using namespace edm;
0018
0019 DTLinearDriftAlgo::DTLinearDriftAlgo(const ParameterSet& config, edm::ConsumesCollector cc)
0020 : DTRecHitBaseAlgo(config, cc),
0021
0022 vDrift(config.getParameter<double>("driftVelocity")),
0023 hitResolution(config.getParameter<double>("hitResolution")),
0024
0025 minTime(config.getParameter<double>("minTime")),
0026 maxTime(config.getParameter<double>("maxTime")),
0027
0028 debug(config.getUntrackedParameter<bool>("debug")) {}
0029
0030 DTLinearDriftAlgo::~DTLinearDriftAlgo() {}
0031
0032 void DTLinearDriftAlgo::setES(const EventSetup& setup) { theSync->setES(setup); }
0033
0034
0035 bool DTLinearDriftAlgo::compute(
0036 const DTLayer* layer, const DTDigi& digi, LocalPoint& leftPoint, LocalPoint& rightPoint, LocalError& error) const {
0037
0038 DTLayerId layerId = layer->id();
0039 const DTWireId wireId(layerId, digi.wire());
0040
0041
0042 if (!layer->specificTopology().isWireValid(digi.wire()))
0043 return false;
0044 LocalPoint locWirePos(layer->specificTopology().wirePosition(digi.wire()), 0, 0);
0045 const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
0046
0047 return compute(layer, wireId, digi.time(), globWirePos, leftPoint, rightPoint, error, 1);
0048 }
0049
0050
0051 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
0052 const DTRecHit1D& recHit1D,
0053 const float& angle,
0054 DTRecHit1D& newHit1D) const {
0055 newHit1D.setPositionAndError(recHit1D.localPosition(), recHit1D.localPositionError());
0056 return true;
0057 }
0058
0059
0060 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
0061 const DTRecHit1D& recHit1D,
0062 const float& angle,
0063 const GlobalPoint& globPos,
0064 DTRecHit1D& newHit1D) const {
0065 return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), globPos, newHit1D, 3);
0066 }
0067
0068
0069 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
0070 const DTWireId& wireId,
0071 const float digiTime,
0072 const GlobalPoint& globPos,
0073 LocalPoint& leftPoint,
0074 LocalPoint& rightPoint,
0075 LocalError& error,
0076 int step) const {
0077
0078 float driftTime = digiTime - theSync->offset(layer, wireId, globPos);
0079
0080
0081 if (driftTime < minTime || driftTime > maxTime) {
0082 if (debug)
0083 cout << "[DTLinearDriftAlgo]*** Drift time out of window for in-time hits " << driftTime << endl;
0084
0085 if (step == 1) {
0086
0087
0088 return false;
0089 }
0090 }
0091
0092
0093 if (driftTime < 0.)
0094 driftTime = 0;
0095
0096
0097
0098 float vd = vDrift;
0099
0100
0101
0102
0103
0104 float drift = driftTime * vd;
0105
0106
0107 if (!layer->specificTopology().isWireValid(wireId.wire()))
0108 return false;
0109 LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
0110
0111 leftPoint = LocalPoint(locWirePos.x() - drift, locWirePos.y(), locWirePos.z());
0112 rightPoint = LocalPoint(locWirePos.x() + drift, locWirePos.y(), locWirePos.z());
0113 error = LocalError(hitResolution * hitResolution, 0., 0.);
0114
0115 if (debug) {
0116 cout << "[DTLinearDriftAlgo] Compute drift distance, for digi at wire: " << wireId << endl
0117 << " Step: " << step << endl
0118 << " Digi time: " << digiTime << endl
0119 << " Drift time: " << driftTime << endl
0120 << " Drift distance: " << drift << endl
0121 << " Hit Resolution: " << hitResolution << endl
0122 << " Left point: " << leftPoint << endl
0123 << " Right point: " << rightPoint << endl
0124 << " Error: " << error << endl;
0125 }
0126
0127 return true;
0128 }
0129
0130
0131 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
0132 const DTWireId& wireId,
0133 const float digiTime,
0134 const GlobalPoint& globPos,
0135 DTRecHit1D& newHit1D,
0136 int step) const {
0137 LocalPoint leftPoint;
0138 LocalPoint rightPoint;
0139 LocalError error;
0140
0141 if (compute(layer, wireId, digiTime, globPos, leftPoint, rightPoint, error, step)) {
0142
0143 switch (newHit1D.lrSide()) {
0144 case DTEnums::Left: {
0145
0146
0147 LocalPoint leftPoint3D(leftPoint.x(), newHit1D.localPosition().y(), leftPoint.z());
0148 newHit1D.setPositionAndError(leftPoint3D, error);
0149 break;
0150 }
0151
0152 case DTEnums::Right: {
0153
0154 LocalPoint rightPoint3D(rightPoint.x(), newHit1D.localPosition().y(), rightPoint.z());
0155 newHit1D.setPositionAndError(rightPoint3D, error);
0156 break;
0157 }
0158
0159 default:
0160 throw cms::Exception("InvalidDTCellSide") << "[DTLinearDriftAlgo] Compute at Step " << step << ", Hit side "
0161 << newHit1D.lrSide() << " is invalid!" << endl;
0162 return false;
0163 }
0164
0165 return true;
0166 } else {
0167 return false;
0168 }
0169 }