CMS 3D CMS Logo

RPLinearChargeDivider.cc
Go to the documentation of this file.
6 
8  CLHEP::HepRandomEngine& eng,
9  RPDetId det_id)
10  : rndEngine_(eng), det_id_(det_id) {
11  verbosity_ = params.getParameter<int>("RPVerbosity");
12 
13  fluctuate_ = std::make_unique<SiG4UniversalFluctuation>();
14 
15  // To Run APV in peak instead of deconvolution mode, which degrades the time resolution.
16  //use: SimpleConfigurable<bool> SiLinearChargeDivider::peakMode(false,"SiStripDigitizer:APVpeakmode");
17 
18  // To Enable interstrip Landau fluctuations within a cluster.
19  //use: SimpleConfigurable<bool> SiLinearChargeDivider::fluctuateCharge(true,"SiStripDigitizer:LandauFluctuations");
20  fluctuateCharge_ = params.getParameter<bool>("RPLandauFluctuations");
21 
22  // Number of segments per strip into which charge is divided during
23  // simulation. If large, precision of simulation improves.
24  //to do so: SimpleConfigurable<int> SiLinearChargeDivider::chargeDivisionsPerStrip(10,"SiStripDigitizer:chargeDivisionsPerStrip");
25  chargedivisionsPerStrip_ = params.getParameter<int>("RPChargeDivisionsPerStrip");
26  chargedivisionsPerThickness_ = params.getParameter<int>("RPChargeDivisionsPerThickness");
27 
28  // delta cutoff in MeV, has to be same as in OSCAR (0.120425 MeV corresponding // to 100um range for electrons)
29  // SimpleConfigurable<double> SiLinearChargeDivider::deltaCut(0.120425,
30  deltaCut_ = params.getParameter<double>("RPDeltaProductionCut");
31 
32  RPTopology rp_det_topol;
33  pitch_ = rp_det_topol.DetPitch();
34  thickness_ = rp_det_topol.DetThickness();
35 }
36 
38 
40  LocalVector direction = hit.exitPoint() - hit.entryPoint();
41  if (direction.z() > 10 || direction.x() > 200 || direction.y() > 200) {
44  }
45 
46  int NumberOfSegmentation_y = (int)(1 + chargedivisionsPerStrip_ * fabs(direction.y()) / pitch_);
47  int NumberOfSegmentation_z = (int)(1 + chargedivisionsPerThickness_ * fabs(direction.z()) / thickness_);
48  int NumberOfSegmentation = std::max(NumberOfSegmentation_y, NumberOfSegmentation_z);
49 
50  double eLoss = hit.energyLoss(); // Eloss in GeV
51 
52  the_energy_path_distribution_.resize(NumberOfSegmentation);
53 
54  if (fluctuateCharge_) {
55  int pid = hit.particleType();
56  double momentum = hit.pabs();
57  double length = direction.mag(); // Track length in Silicon
58  FluctuateEloss(pid, momentum, eLoss, length, NumberOfSegmentation, the_energy_path_distribution_);
59  for (int i = 0; i < NumberOfSegmentation; i++) {
60  the_energy_path_distribution_[i].setPosition(hit.entryPoint() +
61  double((i + 0.5) / NumberOfSegmentation) * direction);
62  }
63  } else {
64  for (int i = 0; i < NumberOfSegmentation; i++) {
65  the_energy_path_distribution_[i].setPosition(hit.entryPoint() +
66  double((i + 0.5) / NumberOfSegmentation) * direction);
67  the_energy_path_distribution_[i].setEnergy(eLoss / (double)NumberOfSegmentation);
68  }
69  }
70 
71  if (verbosity_) {
72  edm::LogInfo("RPLinearChargeDivider") << det_id_ << " charge along the track:\n";
73  double sum = 0;
74  for (unsigned int i = 0; i < the_energy_path_distribution_.size(); i++) {
75  edm::LogInfo("RPLinearChargeDivider")
76  << the_energy_path_distribution_[i].Position().x() << " " << the_energy_path_distribution_[i].Position().y()
77  << " " << the_energy_path_distribution_[i].Position().z() << " " << the_energy_path_distribution_[i].Energy()
78  << "\n";
79  sum += the_energy_path_distribution_[i].Energy();
80  }
81  edm::LogInfo("RPLinearChargeDivider") << "energy dep. sum=" << sum << "\n";
82  }
83 
85 }
86 
88  double particleMomentum,
89  double eloss,
90  double length,
91  int NumberOfSegs,
93  double particleMass = 139.6; // Mass in MeV, Assume pion
94  pid = std::abs(pid);
95  if (pid != 211) { // Mass in MeV
96  if (pid == 11)
97  particleMass = 0.511;
98  else if (pid == 13)
99  particleMass = 105.7;
100  else if (pid == 321)
101  particleMass = 493.7;
102  else if (pid == 2212)
103  particleMass = 938.3;
104  }
105 
106  double segmentLength = length / NumberOfSegs;
107 
108  // Generate charge fluctuations.
109  double de = 0.;
110  double sum = 0.;
111  double segmentEloss = (eloss * 1000) / NumberOfSegs; //eloss in MeV
112  for (int i = 0; i < NumberOfSegs; i++) {
113  // The G4 routine needs momentum in MeV, mass in Mev, delta-cut in MeV,
114  // track segment length in mm, segment eloss in MeV
115  // Returns fluctuated eloss in MeV
116  double deltaCutoff = deltaCut_;
117  de = fluctuate_->SampleFluctuations(
118  particleMomentum * 1000, particleMass, deltaCutoff, segmentLength, segmentEloss, &(rndEngine_)) /
119  1000; //convert to GeV
120  elossVector[i].setEnergy(de);
121  sum += de;
122  }
123 
124  if (sum > 0.) { // If fluctuations give eloss>0.
125  // Rescale to the same total eloss
126  double ratio = eloss / sum;
127  for (int ii = 0; ii < NumberOfSegs; ii++)
128  elossVector[ii].setEnergy(ratio * elossVector[ii].Energy());
129  } else { // If fluctuations gives 0 eloss
130  double averageEloss = eloss / NumberOfSegs;
131  for (int ii = 0; ii < NumberOfSegs; ii++)
132  elossVector[ii].setEnergy(averageEloss);
133  }
134  return;
135 }
T z() const
Definition: PV3DBase.h:61
simromanpot::energy_path_distribution the_energy_path_distribution_
std::unique_ptr< SiG4UniversalFluctuation > fluctuate_
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T mag() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
uint32_t RPDetId
Definition: RPSimTypes.h:12
ii
Definition: cuy.py:589
simromanpot::energy_path_distribution divide(const PSimHit &hit)
Log< level::Info, false > LogInfo
Geometrical and topological information on RP silicon detector. Uses coordinate a frame with origin i...
Definition: RPTopology.h:19
RPLinearChargeDivider(const edm::ParameterSet &params, CLHEP::HepRandomEngine &eng, RPDetId det_id)
void FluctuateEloss(int pid, double particleMomentum, double eloss, double length, int NumberOfSegs, simromanpot::energy_path_distribution &elossVector)
std::vector< RPEnergyDepositUnit > energy_path_distribution
Definition: RPSimTypes.h:17
CLHEP::HepRandomEngine & rndEngine_