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 if(!layer->specificTopology().isWireValid(digi.wire())) return false;
00060 LocalPoint locWirePos(layer->specificTopology().wirePosition(digi.wire()), 0, 0);
00061 const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
00062
00063 return compute(layer, wireId, digi.time(), globWirePos, leftPoint, rightPoint, error, 1);
00064 }
00065
00066
00067
00068
00069 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00070 const DTRecHit1D& recHit1D,
00071 const float& angle,
00072 DTRecHit1D& newHit1D) const {
00073 newHit1D.setPositionAndError(recHit1D.localPosition(), recHit1D.localPositionError());
00074 return true;
00075 }
00076
00077
00078
00079
00080 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00081 const DTRecHit1D& recHit1D,
00082 const float& angle,
00083 const GlobalPoint& globPos,
00084 DTRecHit1D& newHit1D) const {
00085 return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), globPos, newHit1D, 3);
00086 }
00087
00088
00089
00090
00091 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00092 const DTWireId& wireId,
00093 const float digiTime,
00094 const GlobalPoint& globPos,
00095 LocalPoint& leftPoint,
00096 LocalPoint& rightPoint,
00097 LocalError& error,
00098 int step) const {
00099
00100 float driftTime = digiTime - theSync->offset(layer, wireId, globPos);
00101
00102
00103 if (driftTime < minTime || driftTime > maxTime) {
00104 if (debug) cout << "[DTLinearDriftAlgo]*** Drift time out of window for in-time hits "
00105 << driftTime << endl;
00106
00107 if(step == 1) {
00108
00109
00110 return false;
00111 }
00112 }
00113
00114
00115 if (driftTime<0.) driftTime=0;
00116
00117
00118
00119 float vd=vDrift;
00120
00121
00122
00123
00124
00125 float drift = driftTime * vd;
00126
00127
00128 if(!layer->specificTopology().isWireValid(wireId.wire())) return false;
00129 LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
00130
00131 leftPoint = LocalPoint(locWirePos.x()-drift,
00132 locWirePos.y(),
00133 locWirePos.z());
00134 rightPoint = LocalPoint(locWirePos.x()+drift,
00135 locWirePos.y(),
00136 locWirePos.z());
00137 error = LocalError(hitResolution*hitResolution,0.,0.);
00138
00139
00140 if(debug) {
00141 cout << "[DTLinearDriftAlgo] Compute drift distance, for digi at wire: " << wireId << endl
00142 << " Step: " << step << endl
00143 << " Digi time: " << digiTime << endl
00144 << " Drift time: " << driftTime << endl
00145 << " Drift distance: " << drift << endl
00146 << " Hit Resolution: " << hitResolution << endl
00147 << " Left point: " << leftPoint << endl
00148 << " Right point: " << rightPoint << endl
00149 << " Error: " << error << endl;
00150 }
00151
00152 return true;
00153
00154 }
00155
00156
00157
00158 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00159 const DTWireId& wireId,
00160 const float digiTime,
00161 const GlobalPoint& globPos,
00162 DTRecHit1D& newHit1D,
00163 int step) const {
00164 LocalPoint leftPoint;
00165 LocalPoint rightPoint;
00166 LocalError error;
00167
00168 if(compute(layer, wireId, digiTime, globPos, leftPoint, rightPoint, error, step)) {
00169
00170 switch(newHit1D.lrSide()) {
00171
00172 case DTEnums::Left:
00173 {
00174
00175
00176 LocalPoint leftPoint3D(leftPoint.x(), newHit1D.localPosition().y(), leftPoint.z());
00177 newHit1D.setPositionAndError(leftPoint3D, error);
00178 break;
00179 }
00180
00181 case DTEnums::Right:
00182 {
00183
00184 LocalPoint rightPoint3D(rightPoint.x(), newHit1D.localPosition().y(), rightPoint.z());
00185 newHit1D.setPositionAndError(rightPoint3D, error);
00186 break;
00187 }
00188
00189 default:
00190 throw cms::Exception("InvalidDTCellSide") << "[DTLinearDriftAlgo] Compute at Step "
00191 << step << ", Hit side "
00192 << newHit1D.lrSide()
00193 << " is invalid!" << endl;
00194 return false;
00195 }
00196
00197 return true;
00198 }else {
00199 return false;
00200 }
00201 }
00202
00203
00204 float DTLinearDriftAlgo::vDrift;
00205
00206
00207
00208 float DTLinearDriftAlgo::hitResolution;
00209
00210
00211 float DTLinearDriftAlgo::minTime;
00212
00213
00214 float DTLinearDriftAlgo::maxTime;
00215
00216
00217 bool DTLinearDriftAlgo::debug;