CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoLocalMuon/DTRecHit/plugins/DTLinearDriftAlgo.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2009/04/30 09:30:06 $
00005  *  $Revision: 1.3 $
00006  *  \author G. Cerminara - INFN Torino
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     // Get the Drift Velocity from parameter set. 
00023     vDrift = config.getParameter<double>("driftVelocity"); // FIXME: Default was 0.00543 cm/ns
00024     // vDriftMB1W1 = config.getParameter<double>("driftVelocityMB1W1"); // FIXME: Default was 0.00543 cm/ns
00025 
00026     minTime = config.getParameter<double>("minTime"); // FIXME: Default was -3 ns
00027 
00028     maxTime = config.getParameter<double>("maxTime"); // FIXME: Default was 415 ns
00029 
00030     hitResolution = config.getParameter<double>("hitResolution"); // FIXME: Default is 
00031     // Set verbose output
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 // First Step
00049 bool DTLinearDriftAlgo::compute(const DTLayer* layer,
00050                                 const DTDigi& digi,
00051                                 LocalPoint& leftPoint,
00052                                 LocalPoint& rightPoint,
00053                                 LocalError& error) const {
00054   // Get the wireId
00055   DTLayerId layerId = layer->id();
00056   const DTWireId wireId(layerId, digi.wire());
00057 
00058   // Get Wire position
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 // Second step: the same as 1st step
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 // Third step.
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 // Do the actual work.
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   // Subtract the offset to the digi time accordingly to the DTTTrigBaseSync concrete instance
00100   float driftTime = digiTime - theSync->offset(layer, wireId, globPos); 
00101   
00102   // check for out-of-time
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) { //FIXME: protection against failure at 2nd and 3rd steps, must be checked!!!
00108       // Hits are interpreted as coming from out-of-time pile-up and recHit
00109       // is ignored.
00110       return false;
00111     }
00112   }
00113 
00114   // Small negative times interpreted as hits close to the wire.
00115   if (driftTime<0.) driftTime=0;
00116 
00117   // Compute the drift distance
00118   // SL 21-Dec-2006: Use specific Drift for MB1W1 (non fluxed chamber)
00119   float vd=vDrift;
00120   // if (wireId.wheel()==1 && wireId.station()==1) {
00121   //   vd=vDriftMB1W1;
00122   //   //cout << "Using Vd " << vd<< endl;
00123   // }
00124 
00125   float drift = driftTime * vd;
00126 
00127   // Get Wire position
00128   if(!layer->specificTopology().isWireValid(wireId.wire())) return false;
00129   LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
00130   //Build the two possible points and the error on the position
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 // Interface to the method which does the actual work suited for 2nd and 3rd steps 
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     // Set the position and the error of the rechit which is being updated
00170     switch(newHit1D.lrSide()) {
00171         
00172     case DTEnums::Left:
00173         {
00174           // Keep the original y position of newHit1D: for step==3, it's the
00175           // position along the wire. Needed for rotation alignment
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           // as above: 3d position
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 //float DTLinearDriftAlgo::vDriftMB1W1;
00206 
00207   
00208 float DTLinearDriftAlgo::hitResolution;
00209 
00210   
00211 float DTLinearDriftAlgo::minTime;
00212 
00213   
00214 float DTLinearDriftAlgo::maxTime;
00215 
00216   
00217 bool DTLinearDriftAlgo::debug;