CMS 3D CMS Logo

DTLinearDriftAlgo.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2007/06/20 14:23:41 $
00005  *  $Revision: 1.2 $
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   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 // Second step: the same as 1st step
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 // Third step.
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 // Do the actual work.
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   // Subtract the offset to the digi time accordingly to the DTTTrigBaseSync concrete instance
00099   float driftTime = digiTime - theSync->offset(layer, wireId, globPos); 
00100   
00101   // check for out-of-time
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) { //FIXME: protection against failure at 2nd and 3rd steps, must be checked!!!
00107       // Hits are interpreted as coming from out-of-time pile-up and recHit
00108       // is ignored.
00109       return false;
00110     }
00111   }
00112 
00113   // Small negative times interpreted as hits close to the wire.
00114   if (driftTime<0.) driftTime=0;
00115 
00116   // Compute the drift distance
00117   // SL 21-Dec-2006: Use specific Drift for MB1W1 (non fluxed chamber)
00118   float vd=vDrift;
00119   // if (wireId.wheel()==1 && wireId.station()==1) {
00120   //   vd=vDriftMB1W1;
00121   //   //cout << "Using Vd " << vd<< endl;
00122   // }
00123 
00124   float drift = driftTime * vd;
00125 
00126   // Get Wire position
00127   LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
00128   //Build the two possible points and the error on the position
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 // Interface to the method which does the actual work suited for 2nd and 3rd steps 
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     // Set the position and the error of the rechit which is being updated
00168     switch(newHit1D.lrSide()) {
00169         
00170     case DTEnums::Left:
00171         {
00172           // Keep the original y position of newHit1D: for step==3, it's the
00173           // position along the wire. Needed for rotation alignment
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           // as above: 3d position
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 //float DTLinearDriftAlgo::vDriftMB1W1;
00204 
00205   
00206 float DTLinearDriftAlgo::hitResolution;
00207 
00208   
00209 float DTLinearDriftAlgo::minTime;
00210 
00211   
00212 float DTLinearDriftAlgo::maxTime;
00213 
00214   
00215 bool DTLinearDriftAlgo::debug;

Generated on Tue Jun 9 17:43:53 2009 for CMSSW by  doxygen 1.5.4