CMS 3D CMS Logo

CSCWireHitSim.cc
Go to the documentation of this file.
7 
8 #include "CLHEP/Random/RandFlat.h"
9 
11  : theDriftSim(driftSim), theGasIonizer(new CSCGasCollisions(p)), theNewWireHits() {}
12 
14 
15 std::vector<CSCDetectorHit> &CSCWireHitSim::simulate(const CSCLayer *layer,
17  CLHEP::HepRandomEngine *engine) {
18  const CSCLayerGeometry *geom = layer->geometry();
19 
20  theNewWireHits.clear();
21  for (edm::PSimHitContainer::const_iterator hitItr = simHits.begin(); hitItr != simHits.end(); ++hitItr) {
22  std::vector<LocalPoint> ionClusters = getIonizationClusters(*hitItr, layer, engine);
23 
24  unsigned nClusters = ionClusters.size();
25  theNewWireHits.reserve(theNewWireHits.size() + nClusters);
26 
27  for (unsigned icl = 0; icl < nClusters; ++icl) {
28  // Drift the electrons in the cluster to the nearest wire...
29  int nearestWire = geom->nearestWire(ionClusters[icl]);
30 
31  // The wire hit contains wire# and position measured _along the wire_
32  // from where it intersects local y axis.
33 
34  theNewWireHits.push_back(theDriftSim->getWireHit(ionClusters[icl], layer, nearestWire, *hitItr, engine));
35  }
36  }
37  return theNewWireHits;
38 }
39 
40 std::vector<LocalPoint> CSCWireHitSim::getIonizationClusters(const PSimHit &simHit,
41  const CSCLayer *layer,
42  CLHEP::HepRandomEngine *engine) {
43  const LocalPoint &entryPoint = simHit.entryPoint();
44  const LocalPoint &exitPoint = simHit.exitPoint();
45 
46  LogTrace("CSCWireHitSim") << "CSCWireHitSim:"
47  << " type=" << simHit.particleType() << " mom=" << simHit.pabs() << "\n Local entry "
48  << entryPoint << " exit " << exitPoint;
49 
50  std::vector<LocalPoint> positions;
51  std::vector<int> electrons;
52  theGasIonizer->simulate(simHit, positions, electrons, engine);
53 
54  std::vector<LocalPoint> results; // start empty
55 
56  int j = 0;
57  for (std::vector<LocalPoint>::const_iterator pointItr = positions.begin(); pointItr != positions.end(); ++pointItr) {
58  ++j;
59  // some verification
60  if (layer->geometry()->inside(*pointItr)) {
61  // push the point for each electron at this point
62 
63  for (int ie = 1; ie <= electrons[j - 1]; ++ie) {
64  // probability of getting attached
65  float f_att = 0.5;
66  if (CLHEP::RandFlat::shoot(engine) > f_att) {
67  results.push_back(*pointItr);
68  }
69  }
70  }
71  }
72  LogTrace("CSCWireHitSim") << "CSCWireHitSim: there are " << results.size()
73  << " clusters identified with each electron.";
74  return results;
75 }
76 
CSCWireHitSim(CSCDriftSim *driftSim, const edm::ParameterSet &p)
void entryPoint(InputDataCPU const &, InputDataGPU &, OutputDataGPU &, ScratchDataGPU &, OutputDataCPU &, ConditionsProducts const &, cudaStream_t, uint32_t const, uint32_t const)
HepPDT::ParticleDataTable ParticleDataTable
std::vector< CSCDetectorHit > & simulate(const CSCLayer *layer, const edm::PSimHitContainer &simHits, CLHEP::HepRandomEngine *)
CSCDetectorHit getWireHit(const Local3DPoint &ionClusterPosition, const CSCLayer *, int wire, const PSimHit &simHit, CLHEP::HepRandomEngine *)
Definition: CSCDriftSim.cc:55
CSCDriftSim * theDriftSim
Definition: CSCWireHitSim.h:45
#define LogTrace(id)
void setParticleDataTable(const ParticleDataTable *pdt)
std::vector< Local3DPoint > getIonizationClusters(const PSimHit &hit, const CSCLayer *, CLHEP::HepRandomEngine *)
CSCGasCollisions * theGasIonizer
Definition: CSCWireHitSim.h:46
results
Definition: mysort.py:8
std::vector< PSimHit > PSimHitContainer
std::vector< CSCDetectorHit > theNewWireHits
Definition: CSCWireHitSim.h:47
void simulate(const PSimHit &, std::vector< LocalPoint > &clusters, std::vector< int > &electrons, CLHEP::HepRandomEngine *)
void setParticleDataTable(const ParticleDataTable *pdt)