00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "RecoLocalMuon/DTRecHit/plugins/DTLinearDriftAlgo.h"
00010 #include "CalibMuon/DTDigiSync/interface/DTTTrigBaseSync.h"
00011 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00012 #include "Geometry/DTGeometry/interface/DTLayer.h"
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/Utilities/interface/Exception.h"
00016
00017 using namespace std;
00018 using namespace edm;
00019
00020 DTLinearDriftAlgo::DTLinearDriftAlgo(const ParameterSet& config) :
00021 DTRecHitBaseAlgo(config) {
00022
00023 vDrift = config.getParameter<double>("driftVelocity");
00024
00025
00026 minTime = config.getParameter<double>("minTime");
00027
00028 maxTime = config.getParameter<double>("maxTime");
00029
00030 hitResolution = config.getParameter<double>("hitResolution");
00031
00032 debug = config.getUntrackedParameter<bool>("debug");
00033
00034 }
00035
00036
00037
00038 DTLinearDriftAlgo::~DTLinearDriftAlgo(){}
00039
00040
00041
00042 void DTLinearDriftAlgo::setES(const EventSetup& setup) {
00043 theSync->setES(setup);
00044 }
00045
00046
00047
00048
00049 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00050 const DTDigi& digi,
00051 LocalPoint& leftPoint,
00052 LocalPoint& rightPoint,
00053 LocalError& error) const {
00054
00055 DTLayerId layerId = layer->id();
00056 const DTWireId wireId(layerId, digi.wire());
00057
00058
00059 LocalPoint locWirePos(layer->specificTopology().wirePosition(digi.wire()), 0, 0);
00060 const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
00061
00062 return compute(layer, wireId, digi.time(), globWirePos, leftPoint, rightPoint, error, 1);
00063 }
00064
00065
00066
00067
00068 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00069 const DTRecHit1D& recHit1D,
00070 const float& angle,
00071 DTRecHit1D& newHit1D) const {
00072 newHit1D.setPositionAndError(recHit1D.localPosition(), recHit1D.localPositionError());
00073 return true;
00074 }
00075
00076
00077
00078
00079 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00080 const DTRecHit1D& recHit1D,
00081 const float& angle,
00082 const GlobalPoint& globPos,
00083 DTRecHit1D& newHit1D) const {
00084 return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), globPos, newHit1D, 3);
00085 }
00086
00087
00088
00089
00090 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00091 const DTWireId& wireId,
00092 const float digiTime,
00093 const GlobalPoint& globPos,
00094 LocalPoint& leftPoint,
00095 LocalPoint& rightPoint,
00096 LocalError& error,
00097 int step) const {
00098
00099 float driftTime = digiTime - theSync->offset(layer, wireId, globPos);
00100
00101
00102 if (driftTime < minTime || driftTime > maxTime) {
00103 if (debug) cout << "[DTLinearDriftAlgo]*** Drift time out of window for in-time hits "
00104 << driftTime << endl;
00105
00106 if(step == 1) {
00107
00108
00109 return false;
00110 }
00111 }
00112
00113
00114 if (driftTime<0.) driftTime=0;
00115
00116
00117
00118 float vd=vDrift;
00119
00120
00121
00122
00123
00124 float drift = driftTime * vd;
00125
00126
00127 LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
00128
00129 leftPoint = LocalPoint(locWirePos.x()-drift,
00130 locWirePos.y(),
00131 locWirePos.z());
00132 rightPoint = LocalPoint(locWirePos.x()+drift,
00133 locWirePos.y(),
00134 locWirePos.z());
00135 error = LocalError(hitResolution*hitResolution,0.,0.);
00136
00137
00138 if(debug) {
00139 cout << "[DTLinearDriftAlgo] Compute drift distance, for digi at wire: " << wireId << endl
00140 << " Step: " << step << endl
00141 << " Digi time: " << digiTime << endl
00142 << " Drift time: " << driftTime << endl
00143 << " Drift distance: " << drift << endl
00144 << " Hit Resolution: " << hitResolution << endl
00145 << " Left point: " << leftPoint << endl
00146 << " Right point: " << rightPoint << endl
00147 << " Error: " << error << endl;
00148 }
00149
00150 return true;
00151
00152 }
00153
00154
00155
00156 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00157 const DTWireId& wireId,
00158 const float digiTime,
00159 const GlobalPoint& globPos,
00160 DTRecHit1D& newHit1D,
00161 int step) const {
00162 LocalPoint leftPoint;
00163 LocalPoint rightPoint;
00164 LocalError error;
00165
00166 if(compute(layer, wireId, digiTime, globPos, leftPoint, rightPoint, error, step)) {
00167
00168 switch(newHit1D.lrSide()) {
00169
00170 case DTEnums::Left:
00171 {
00172
00173
00174 LocalPoint leftPoint3D(leftPoint.x(), newHit1D.localPosition().y(), leftPoint.z());
00175 newHit1D.setPositionAndError(leftPoint3D, error);
00176 break;
00177 }
00178
00179 case DTEnums::Right:
00180 {
00181
00182 LocalPoint rightPoint3D(rightPoint.x(), newHit1D.localPosition().y(), rightPoint.z());
00183 newHit1D.setPositionAndError(rightPoint3D, error);
00184 break;
00185 }
00186
00187 default:
00188 throw cms::Exception("InvalidDTCellSide") << "[DTLinearDriftAlgo] Compute at Step "
00189 << step << ", Hit side "
00190 << newHit1D.lrSide()
00191 << " is invalid!" << endl;
00192 return false;
00193 }
00194
00195 return true;
00196 }else {
00197 return false;
00198 }
00199 }
00200
00201
00202 float DTLinearDriftAlgo::vDrift;
00203
00204
00205
00206 float DTLinearDriftAlgo::hitResolution;
00207
00208
00209 float DTLinearDriftAlgo::minTime;
00210
00211
00212 float DTLinearDriftAlgo::maxTime;
00213
00214
00215 bool DTLinearDriftAlgo::debug;