CMS 3D CMS Logo

RPLinearChargeDivider.cc
Go to the documentation of this file.
6 
8  CLHEP::HepRandomEngine& eng,
9  RPDetId det_id)
10  : params_(params), 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 }
Vector3DBase< float, LocalTag >
RPLinearChargeDivider::~RPLinearChargeDivider
~RPLinearChargeDivider()
Definition: RPLinearChargeDivider.cc:37
simromanpot::energy_path_distribution
std::vector< RPEnergyDepositUnit > energy_path_distribution
Definition: RPSimTypes.h:16
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
EcalCondDBWriter_cfi.Energy
Energy
Definition: EcalCondDBWriter_cfi.py:152
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
RPLinearChargeDivider::pitch_
double pitch_
Definition: RPLinearChargeDivider.h:28
RPLinearChargeDivider::fluctuate_
std::unique_ptr< SiG4UniversalFluctuation > fluctuate_
Definition: RPLinearChargeDivider.h:31
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
RPLinearChargeDivider::FluctuateEloss
void FluctuateEloss(int pid, double particleMomentum, double eloss, double length, int NumberOfSegs, simromanpot::energy_path_distribution &elossVector)
Definition: RPLinearChargeDivider.cc:87
simKBmtfDigis_cfi.eLoss
eLoss
Definition: simKBmtfDigis_cfi.py:9
RPLinearChargeDivider::the_energy_path_distribution_
simromanpot::energy_path_distribution the_energy_path_distribution_
Definition: RPLinearChargeDivider.h:30
RPLinearChargeDivider::chargedivisionsPerThickness_
int chargedivisionsPerThickness_
Definition: RPLinearChargeDivider.h:26
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
RPLinearChargeDivider::thickness_
double thickness_
Definition: RPLinearChargeDivider.h:29
RPLinearChargeDivider::RPLinearChargeDivider
RPLinearChargeDivider(const edm::ParameterSet &params, CLHEP::HepRandomEngine &eng, RPDetId det_id)
Definition: RPLinearChargeDivider.cc:7
particleFlowDisplacedVertex_cfi.ratio
ratio
Definition: particleFlowDisplacedVertex_cfi.py:93
RPLinearChargeDivider::rndEngine_
CLHEP::HepRandomEngine & rndEngine_
Definition: RPLinearChargeDivider.h:21
RPTopology
Geometrical and topological information on RP silicon detector. Uses coordinate a frame with origin i...
Definition: RPTopology.h:18
edm::ParameterSet
Definition: ParameterSet.h:47
RPLinearChargeDivider::divide
simromanpot::energy_path_distribution divide(const PSimHit &hit)
Definition: RPLinearChargeDivider.cc:39
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
createfilelist.int
int
Definition: createfilelist.py:10
RPLinearChargeDivider::det_id_
RPDetId det_id_
Definition: RPLinearChargeDivider.h:22
RPLinearChargeDivider::fluctuateCharge_
bool fluctuateCharge_
Definition: RPLinearChargeDivider.h:24
RPDetId
uint32_t RPDetId
Definition: RPSimTypes.h:11
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
LocalPoint.h
RPTopology.h
RPLinearChargeDivider::chargedivisionsPerStrip_
int chargedivisionsPerStrip_
Definition: RPLinearChargeDivider.h:25
RPLinearChargeDivider.h
RPLinearChargeDivider::deltaCut_
double deltaCut_
Definition: RPLinearChargeDivider.h:27
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PSimHit
Definition: PSimHit.h:15
LocalVector.h
cuy.ii
ii
Definition: cuy.py:589
RPLinearChargeDivider::verbosity_
int verbosity_
Definition: RPLinearChargeDivider.h:32
hit
Definition: SiStripHitEffFromCalibTree.cc:88