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 : theDriftSim(driftSim),
00011 theGasIonizer( new CSCGasCollisions() ) ,
00012 theNewWireHits()
00013 {
00014 }
00015
00016
00017 CSCWireHitSim::~CSCWireHitSim() {
00018 delete theGasIonizer;
00019 }
00020
00021
00022 std::vector<CSCDetectorHit> &
00023 CSCWireHitSim::simulate(const CSCLayer * layer,
00024 const edm::PSimHitContainer & simHits)
00025 {
00026 const CSCLayerGeometry * geom = layer->geometry();
00027
00028 theNewWireHits.clear();
00029 for (edm::PSimHitContainer::const_iterator hitItr = simHits.begin();
00030 hitItr != simHits.end(); ++hitItr)
00031 {
00032
00033 std::vector<LocalPoint> ionClusters
00034 = getIonizationClusters(*hitItr, layer);
00035
00036 unsigned nClusters = ionClusters.size();
00037 theNewWireHits.reserve(theNewWireHits.size()+nClusters);
00038
00039 for(unsigned icl = 0; icl < nClusters; ++icl) {
00040
00041
00042 int nearestWire=geom->nearestWire(ionClusters[icl]);
00043
00044
00045
00046
00047 theNewWireHits.push_back(
00048 theDriftSim->getWireHit(ionClusters[icl], layer, nearestWire,
00049 *hitItr) );
00050
00051 }
00052 }
00053 return theNewWireHits;
00054 }
00055
00056 std::vector<LocalPoint>
00057 CSCWireHitSim::getIonizationClusters(const PSimHit & simHit,
00058 const CSCLayer * layer)
00059 {
00060 const LocalPoint & entryPoint = simHit.entryPoint();
00061 const LocalPoint & exitPoint = simHit.exitPoint();
00062
00063 LogTrace("CSCWireHitSim") << "CSCWireHitSim:"
00064 << " type=" << simHit.particleType()
00065 << " mom=" << simHit.pabs()
00066 << "\n Local entry " << entryPoint << " exit " << exitPoint;
00067
00068 std::vector<LocalPoint> positions;
00069 std::vector<int> electrons;
00070 theGasIonizer->simulate( simHit, layer, positions, electrons );
00071
00072 std::vector<LocalPoint> results;
00073
00074 int j = 0;
00075 for( std::vector<LocalPoint>::const_iterator pointItr = positions.begin();
00076 pointItr != positions.end(); ++pointItr )
00077 {
00078 ++j;
00079
00080 if(layer->geometry()->inside(*pointItr) ) {
00081
00082
00083 for( int ie = 1; ie <= electrons[j-1]; ++ie ) {
00084 results.push_back(*pointItr);
00085 }
00086 }
00087 }
00088 LogTrace("CSCWireHitSim") << "CSCWireHitSim: there are " << results.size()
00089 << " clusters identified with each electron.";
00090 return results;
00091 }
00092
00093
00094 void CSCWireHitSim::setParticleDataTable(const ParticleDataTable * pdt)
00095 {
00096 theGasIonizer->setParticleDataTable(pdt);
00097 }
00098
00099
00100 void CSCWireHitSim::setRandomEngine(CLHEP::HepRandomEngine& engine)
00101 {
00102 theDriftSim->setRandomEngine(engine);
00103 theGasIonizer->setRandomEngine(engine);
00104 }
00105
00106