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 #include "CLHEP/Random/RandFlat.h"
9 
11 : theDriftSim(driftSim),
12  theGasIonizer( new CSCGasCollisions( p ) ) ,
13  theNewWireHits()
14 {
15 }
16 
17 
19  delete theGasIonizer;
20 }
21 
22 
23 std::vector<CSCDetectorHit> &
26  CLHEP::HepRandomEngine* engine)
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, engine);
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, engine) );
52 
53  }
54  }
55  return theNewWireHits;
56 }
57 
58 std::vector<LocalPoint>
60  const CSCLayer * layer,
61  CLHEP::HepRandomEngine* engine)
62 {
63  const LocalPoint & entryPoint = simHit.entryPoint();
64  const LocalPoint & exitPoint = simHit.exitPoint();
65 
66  LogTrace("CSCWireHitSim") << "CSCWireHitSim:"
67  << " type=" << simHit.particleType()
68  << " mom=" << simHit.pabs()
69  << "\n Local entry " << entryPoint << " exit " << exitPoint;
70 
71  std::vector<LocalPoint> positions;
72  std::vector<int> electrons;
73  theGasIonizer->simulate( simHit, positions, electrons, engine );
74 
75  std::vector<LocalPoint> results; // start empty
76 
77  int j = 0;
78  for( std::vector<LocalPoint>::const_iterator pointItr = positions.begin();
79  pointItr != positions.end(); ++pointItr )
80  {
81  ++j;
82  // some verification
83  if(layer->geometry()->inside(*pointItr) ) {
84  // push the point for each electron at this point
85 
86  for( int ie = 1; ie <= electrons[j-1]; ++ie ) {
87  // probability of getting attached
88  float f_att = 0.5;
89  if(CLHEP::RandFlat::shoot(engine) > f_att) {
90  results.push_back(*pointItr);
91  }
92  }
93  }
94  }
95  LogTrace("CSCWireHitSim") << "CSCWireHitSim: there are " << results.size()
96  << " clusters identified with each electron.";
97  return results;
98 }
99 
100 
102 {
104 }
int nearestWire(const LocalPoint &lp) const
CSCWireHitSim(CSCDriftSim *driftSim, const edm::ParameterSet &p)
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:61
CSCDriftSim * theDriftSim
Definition: CSCWireHitSim.h:48
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:38
int j
Definition: DBlmapReader.cc:9
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
Definition: PSimHit.h:63
void setParticleDataTable(const ParticleDataTable *pdt)
#define LogTrace(id)
std::vector< Local3DPoint > getIonizationClusters(const PSimHit &hit, const CSCLayer *, CLHEP::HepRandomEngine *)
CSCGasCollisions * theGasIonizer
Definition: CSCWireHitSim.h:49
tuple simHits
Definition: trackerHits.py:16
int particleType() const
Definition: PSimHit.h:85
bool inside(const Local3DPoint &, const LocalError &, float scale=1.f) const
std::vector< PSimHit > PSimHitContainer
std::vector< CSCDetectorHit > theNewWireHits
Definition: CSCWireHitSim.h:50
void simulate(const PSimHit &, std::vector< LocalPoint > &clusters, std::vector< int > &electrons, CLHEP::HepRandomEngine *)
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