CMS 3D CMS Logo

DTNoDriftAlgo.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2007/04/19 11:08:17 $
00005  *  $Revision: 1.1 $
00006  *  \author Martijn Mulders - CERN (martijn.mulders@cern.ch)
00007  *  based on DTLinearDriftAlgo
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"); // Set to size of (half)cell 
00030     // Set verbose output
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   //  theSync->setES(setup);
00043 }
00044 
00045 
00046 
00047 
00048 // Build all hits in the range associated to the layerId, at the 1st step.
00049 OwnVector<DTRecHit1DPair> DTNoDriftAlgo::reconstruct(const DTLayer* layer,
00050                                                         const DTLayerId& layerId,
00051                                                         const DTDigiCollection::Range& digiRange) {
00052   OwnVector<DTRecHit1DPair> result; 
00053 
00054   // Loop over all digis in the given range
00055   for (DTDigiCollection::const_iterator digi = digiRange.first;
00056        digi != digiRange.second;
00057        digi++) {
00058     // Get the wireId
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         //      std::cout << " Reject this hit with time " << (*digi).time() << std::endl; 
00068         break;
00069       }
00070     }
00071     
00072     if (isDouble) continue;
00073 
00074     LocalError tmpErr;
00075     LocalPoint lpoint, rpoint;
00076     // Call the compute method
00077     bool OK = compute(layer, *digi, lpoint, rpoint, tmpErr);
00078 
00079     if (!OK) continue;
00080 
00081     // Build a new pair of 1D rechit    
00082     DTRecHit1DPair*  recHitPair = new DTRecHit1DPair(wireId, *digi);
00083 
00084     // Set the position and the error of the 1D rechits
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 // First Step
00098 bool DTNoDriftAlgo::compute(const DTLayer* layer,
00099                                 const DTDigi& digi,
00100                                 LocalPoint& leftPoint,
00101                                 LocalPoint& rightPoint,
00102                                 LocalError& error) const {
00103   // Get the wireId
00104   DTLayerId layerId = layer->id();
00105   const DTWireId wireId(layerId, digi.wire());
00106 
00107   // Get Wire position
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 // Second step: the same as 1st step
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 // Third step.
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 // Do the actual work.
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   // Small negative times interpreted as hits close to the wire.
00150   //if (driftTime<0.) driftTime=0;
00151 
00152 
00153   // check for out-of-time
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) { //FIXME: protection against failure at 2nd and 3rd steps, must be checked!!!
00159       // Hits are interpreted as coming from out-of-time pile-up and recHit
00160       // is ignored.
00161       return false;
00162     }
00163   }
00164 
00165 
00166   // Compute the drift distance
00167   float drift = fixedDrift;
00168 
00169   // Get Wire position
00170   LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
00171   //Build the two possible points and the error on the position
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       //         << "       Drift time:     " << driftTime << endl
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 // Interface to the method which does the actual work suited for 2nd and 3rd steps 
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     // Set the position and the error of the rechit which is being updated
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;

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