CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/SimMuon/CSCDigitizer/src/CSCWireHitSim.cc

Go to the documentation of this file.
00001 #include "SimMuon/CSCDigitizer/src/CSCWireHitSim.h"
00002 #include "SimMuon/CSCDigitizer/src/CSCDriftSim.h"
00003 #include "SimMuon/CSCDigitizer/src/CSCGasCollisions.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
00006 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
00007 
00008 
00009 CSCWireHitSim::CSCWireHitSim(CSCDriftSim* driftSim) 
00010 : theRandFlat(0),
00011   theDriftSim(driftSim),
00012   theGasIonizer( new CSCGasCollisions() ) ,
00013   theNewWireHits()
00014 {
00015 }
00016 
00017 
00018 CSCWireHitSim::~CSCWireHitSim() {
00019   delete theRandFlat;
00020   delete theGasIonizer;
00021 }
00022 
00023 
00024 std::vector<CSCDetectorHit> &
00025 CSCWireHitSim::simulate(const CSCLayer * layer, 
00026                         const edm::PSimHitContainer & simHits) 
00027 {
00028   const CSCLayerGeometry * geom = layer->geometry(); 
00029 
00030   theNewWireHits.clear();
00031   for (edm::PSimHitContainer::const_iterator hitItr = simHits.begin();
00032        hitItr != simHits.end();  ++hitItr)
00033   {
00034 
00035     std::vector<LocalPoint> ionClusters 
00036       = getIonizationClusters(*hitItr, layer);
00037 
00038     unsigned nClusters = ionClusters.size();
00039     theNewWireHits.reserve(theNewWireHits.size()+nClusters);
00040 
00041     for(unsigned icl = 0; icl < nClusters; ++icl) {
00042 
00043       // Drift the electrons in the cluster to the nearest wire...
00044       int nearestWire=geom->nearestWire(ionClusters[icl]);
00045 
00046       // The wire hit contains wire# and position measured _along the wire_
00047       // from where it intersects local y axis.
00048 
00049       theNewWireHits.push_back( 
00050           theDriftSim->getWireHit(ionClusters[icl], layer, nearestWire,
00051           *hitItr) );
00052 
00053     }
00054   } 
00055   return theNewWireHits;
00056 }
00057 
00058 std::vector<LocalPoint> 
00059 CSCWireHitSim::getIonizationClusters(const PSimHit & simHit, 
00060      const CSCLayer * layer) 
00061 {
00062   const LocalPoint & entryPoint = simHit.entryPoint();
00063   const LocalPoint & exitPoint  = simHit.exitPoint();
00064 
00065   LogTrace("CSCWireHitSim") << "CSCWireHitSim:" 
00066       << " type=" << simHit.particleType() 
00067       << " mom=" << simHit.pabs()
00068       << "\n Local entry " << entryPoint << " exit " << exitPoint;
00069 
00070   std::vector<LocalPoint> positions;
00071   std::vector<int> electrons;
00072   theGasIonizer->simulate( simHit, positions, electrons );
00073 
00074   std::vector<LocalPoint> results; // start empty
00075 
00076   int j = 0;
00077   for( std::vector<LocalPoint>::const_iterator pointItr = positions.begin(); 
00078                                          pointItr != positions.end(); ++pointItr ) 
00079   {
00080     ++j;
00081     // some verification
00082     if(layer->geometry()->inside(*pointItr) ) {
00083       // push the point for each electron at this point
00084       
00085       for( int ie = 1;  ie <= electrons[j-1]; ++ie ) {
00086         // probability of getting attached
00087         float f_att = 0.5;
00088         if(theRandFlat->fire() > f_att) {
00089           results.push_back(*pointItr);
00090         }
00091       }
00092     }
00093   }
00094   LogTrace("CSCWireHitSim") << "CSCWireHitSim: there are " << results.size()
00095      << " clusters identified with each electron.";
00096   return results;
00097 }
00098 
00099 
00100 void CSCWireHitSim::setParticleDataTable(const ParticleDataTable * pdt)
00101 {
00102   theGasIonizer->setParticleDataTable(pdt);
00103 }
00104 
00105 
00106 void CSCWireHitSim::setRandomEngine(CLHEP::HepRandomEngine& engine)
00107 {
00108   theRandFlat = new CLHEP::RandFlat(engine);
00109   theDriftSim->setRandomEngine(engine);
00110   theGasIonizer->setRandomEngine(engine);
00111 }
00112 
00113