00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "RecoLocalMuon/DTRecHit/plugins/DTNoDriftAlgo.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 DTNoDriftAlgo::DTNoDriftAlgo(const ParameterSet& config) :
00021 DTRecHitBaseAlgo(config) {
00022
00023 minTime = config.getParameter<double>("minTime");
00024
00025 maxTime = config.getParameter<double>("maxTime");
00026
00027 fixedDrift = config.getParameter<double>("fixedDrift");
00028
00029 hitResolution = config.getParameter<double>("hitResolution");
00030
00031 debug = config.getUntrackedParameter<bool>("debug");
00032
00033 }
00034
00035
00036
00037 DTNoDriftAlgo::~DTNoDriftAlgo(){}
00038
00039
00040
00041 void DTNoDriftAlgo::setES(const EventSetup& setup) {
00042
00043 }
00044
00045
00046
00047
00048
00049 OwnVector<DTRecHit1DPair> DTNoDriftAlgo::reconstruct(const DTLayer* layer,
00050 const DTLayerId& layerId,
00051 const DTDigiCollection::Range& digiRange) {
00052 OwnVector<DTRecHit1DPair> result;
00053
00054
00055 for (DTDigiCollection::const_iterator digi = digiRange.first;
00056 digi != digiRange.second;
00057 digi++) {
00058
00059 DTWireId wireId(layerId, (*digi).wire());
00060
00061 bool isDouble = false;
00062 for (OwnVector<DTRecHit1DPair>::const_iterator doubleWireCheck = result.begin();
00063 doubleWireCheck != result.end();
00064 doubleWireCheck++) {
00065 if( wireId == (*doubleWireCheck).wireId()) {
00066 isDouble = true;
00067
00068 break;
00069 }
00070 }
00071
00072 if (isDouble) continue;
00073
00074 LocalError tmpErr;
00075 LocalPoint lpoint, rpoint;
00076
00077 bool OK = compute(layer, *digi, lpoint, rpoint, tmpErr);
00078
00079 if (!OK) continue;
00080
00081
00082 DTRecHit1DPair* recHitPair = new DTRecHit1DPair(wireId, *digi);
00083
00084
00085 recHitPair->setPositionAndError(DTEnums::Left, lpoint, tmpErr);
00086 recHitPair->setPositionAndError(DTEnums::Right, rpoint, tmpErr);
00087
00088 result.push_back(recHitPair);
00089 }
00090 return result;
00091 }
00092
00093
00094
00095
00096
00097
00098 bool DTNoDriftAlgo::compute(const DTLayer* layer,
00099 const DTDigi& digi,
00100 LocalPoint& leftPoint,
00101 LocalPoint& rightPoint,
00102 LocalError& error) const {
00103
00104 DTLayerId layerId = layer->id();
00105 const DTWireId wireId(layerId, digi.wire());
00106
00107
00108 LocalPoint locWirePos(layer->specificTopology().wirePosition(digi.wire()), 0, 0);
00109 const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
00110
00111 return compute(layer, wireId, digi.time(), globWirePos, leftPoint, rightPoint, error, 1);
00112 }
00113
00114
00115
00116
00117 bool DTNoDriftAlgo::compute(const DTLayer* layer,
00118 const DTRecHit1D& recHit1D,
00119 const float& angle,
00120 DTRecHit1D& newHit1D) const {
00121 newHit1D.setPositionAndError(recHit1D.localPosition(), recHit1D.localPositionError());
00122 return true;
00123 }
00124
00125
00126
00127
00128 bool DTNoDriftAlgo::compute(const DTLayer* layer,
00129 const DTRecHit1D& recHit1D,
00130 const float& angle,
00131 const GlobalPoint& globPos,
00132 DTRecHit1D& newHit1D) const {
00133 return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), globPos, newHit1D, 3);
00134 }
00135
00136
00137
00138
00139 bool DTNoDriftAlgo::compute(const DTLayer* layer,
00140 const DTWireId& wireId,
00141 const float digiTime,
00142 const GlobalPoint& globPos,
00143 LocalPoint& leftPoint,
00144 LocalPoint& rightPoint,
00145 LocalError& error,
00146 int step) const {
00147
00148
00149
00150
00151
00152
00153
00154 if (digiTime < minTime || digiTime > maxTime) {
00155 if (debug) cout << "[DTNoDriftAlgo]*** Drift time out of window for in-time hits "
00156 << digiTime << endl;
00157
00158 if(step == 1) {
00159
00160
00161 return false;
00162 }
00163 }
00164
00165
00166
00167 float drift = fixedDrift;
00168
00169
00170 LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
00171
00172 leftPoint = LocalPoint(locWirePos.x()-drift,
00173 locWirePos.y(),
00174 locWirePos.z());
00175 rightPoint = LocalPoint(locWirePos.x()+drift,
00176 locWirePos.y(),
00177 locWirePos.z());
00178 error = LocalError(hitResolution*hitResolution,0.,0.);
00179
00180
00181 if(debug) {
00182 cout << "[DTNoDriftAlgo] Compute drift distance, for digi at wire: " << wireId << endl
00183 << " Step: " << step << endl
00184 << " Digi time: " << digiTime << endl
00185
00186 << " Fixed Drift distance: " << drift << endl
00187 << " Hit Resolution: " << hitResolution << endl
00188 << " Left point: " << leftPoint << endl
00189 << " Right point: " << rightPoint << endl
00190 << " Error: " << error << endl;
00191 }
00192
00193
00194
00195 return true;
00196
00197 }
00198
00199
00200
00201 bool DTNoDriftAlgo::compute(const DTLayer* layer,
00202 const DTWireId& wireId,
00203 const float digiTime,
00204 const GlobalPoint& globPos,
00205 DTRecHit1D& newHit1D,
00206 int step) const {
00207 LocalPoint leftPoint;
00208 LocalPoint rightPoint;
00209 LocalError error;
00210
00211 if(compute(layer, wireId, digiTime, globPos, leftPoint, rightPoint, error, step)) {
00212
00213 switch(newHit1D.lrSide()) {
00214
00215 case DTEnums::Left:
00216 newHit1D.setPositionAndError(leftPoint, error);
00217 break;
00218
00219 case DTEnums::Right:
00220 newHit1D.setPositionAndError(rightPoint, error);
00221 break;
00222
00223 default:
00224 throw cms::Exception("InvalidDTCellSide") << "[DTNoDriftAlgo] Compute at Step "
00225 << step << ", Hit side "
00226 << newHit1D.lrSide()
00227 << " is invalid!" << endl;
00228 return false;
00229 }
00230
00231 return true;
00232 }else {
00233 return false;
00234 }
00235 }
00236
00237
00238 float DTNoDriftAlgo::fixedDrift;
00239
00240
00241 float DTNoDriftAlgo::hitResolution;
00242
00243
00244 float DTNoDriftAlgo::minTime;
00245
00246
00247 float DTNoDriftAlgo::maxTime;
00248
00249
00250 bool DTNoDriftAlgo::debug;