CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCWireHitSim.cc
Go to the documentation of this file.
7 
8 
10 : theRandFlat(0),
11  theDriftSim(driftSim),
12  theGasIonizer( new CSCGasCollisions() ) ,
13  theNewWireHits()
14 {
15 }
16 
17 
19  delete theRandFlat;
20  delete theGasIonizer;
21 }
22 
23 
24 std::vector<CSCDetectorHit> &
27 {
28  const CSCLayerGeometry * geom = layer->geometry();
29 
30  theNewWireHits.clear();
31  for (edm::PSimHitContainer::const_iterator hitItr = simHits.begin();
32  hitItr != simHits.end(); ++hitItr)
33  {
34 
35  std::vector<LocalPoint> ionClusters
36  = getIonizationClusters(*hitItr, layer);
37 
38  unsigned nClusters = ionClusters.size();
39  theNewWireHits.reserve(theNewWireHits.size()+nClusters);
40 
41  for(unsigned icl = 0; icl < nClusters; ++icl) {
42 
43  // Drift the electrons in the cluster to the nearest wire...
44  int nearestWire=geom->nearestWire(ionClusters[icl]);
45 
46  // The wire hit contains wire# and position measured _along the wire_
47  // from where it intersects local y axis.
48 
49  theNewWireHits.push_back(
50  theDriftSim->getWireHit(ionClusters[icl], layer, nearestWire,
51  *hitItr) );
52 
53  }
54  }
55  return theNewWireHits;
56 }
57 
58 std::vector<LocalPoint>
60  const CSCLayer * layer)
61 {
62  const LocalPoint & entryPoint = simHit.entryPoint();
63  const LocalPoint & exitPoint = simHit.exitPoint();
64 
65  LogTrace("CSCWireHitSim") << "CSCWireHitSim:"
66  << " type=" << simHit.particleType()
67  << " mom=" << simHit.pabs()
68  << "\n Local entry " << entryPoint << " exit " << exitPoint;
69 
70  std::vector<LocalPoint> positions;
71  std::vector<int> electrons;
72  theGasIonizer->simulate( simHit, positions, electrons );
73 
74  std::vector<LocalPoint> results; // start empty
75 
76  int j = 0;
77  for( std::vector<LocalPoint>::const_iterator pointItr = positions.begin();
78  pointItr != positions.end(); ++pointItr )
79  {
80  ++j;
81  // some verification
82  if(layer->geometry()->inside(*pointItr) ) {
83  // push the point for each electron at this point
84 
85  for( int ie = 1; ie <= electrons[j-1]; ++ie ) {
86  // probability of getting attached
87  float f_att = 0.5;
88  if(theRandFlat->fire() > f_att) {
89  results.push_back(*pointItr);
90  }
91  }
92  }
93  }
94  LogTrace("CSCWireHitSim") << "CSCWireHitSim: there are " << results.size()
95  << " clusters identified with each electron.";
96  return results;
97 }
98 
99 
101 {
103 }
104 
105 
106 void CSCWireHitSim::setRandomEngine(CLHEP::HepRandomEngine& engine)
107 {
108  theRandFlat = new CLHEP::RandFlat(engine);
109  theDriftSim->setRandomEngine(engine);
111 }
112 
113 
int nearestWire(const LocalPoint &lp) const
void simulate(const PSimHit &, std::vector< LocalPoint > &clusters, std::vector< int > &electrons)
CLHEP::RandFlat * theRandFlat
Definition: CSCWireHitSim.h:45
std::vector< Local3DPoint > getIonizationClusters(const PSimHit &hit, const CSCLayer *)
HepPDT::ParticleDataTable ParticleDataTable
CSCDriftSim * theDriftSim
Definition: CSCWireHitSim.h:46
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:38
int j
Definition: DBlmapReader.cc:9
void setRandomEngine(CLHEP::HepRandomEngine &engine)
Definition: CSCDriftSim.cc:60
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
Definition: PSimHit.h:63
void setParticleDataTable(const ParticleDataTable *pdt)
#define LogTrace(id)
void setRandomEngine(CLHEP::HepRandomEngine &engine)
CSCWireHitSim(CSCDriftSim *driftSim)
Definition: CSCWireHitSim.cc:9
CSCGasCollisions * theGasIonizer
Definition: CSCWireHitSim.h:47
tuple simHits
Definition: trackerHits.py:16
std::vector< CSCDetectorHit > & simulate(const CSCLayer *layer, const edm::PSimHitContainer &simHits)
int particleType() const
Definition: PSimHit.h:85
CSCDetectorHit getWireHit(const Local3DPoint &ionClusterPosition, const CSCLayer *, int wire, const PSimHit &simHit)
Definition: CSCDriftSim.cc:68
bool inside(const Local3DPoint &, const LocalError &, float scale=1.f) const
std::vector< PSimHit > PSimHitContainer
std::vector< CSCDetectorHit > theNewWireHits
Definition: CSCWireHitSim.h:48
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
void setParticleDataTable(const ParticleDataTable *pdt)
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
void setRandomEngine(CLHEP::HepRandomEngine &engine)