CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
RPLinearChargeDivider Class Reference

#include <RPLinearChargeDivider.h>

Public Member Functions

simromanpot::energy_path_distribution divide (const PSimHit &hit)
 
 RPLinearChargeDivider (const edm::ParameterSet &params, CLHEP::HepRandomEngine &eng, RPDetId det_id)
 
 ~RPLinearChargeDivider ()
 

Private Member Functions

void FluctuateEloss (int pid, double particleMomentum, double eloss, double length, int NumberOfSegs, simromanpot::energy_path_distribution &elossVector)
 

Private Attributes

int chargedivisionsPerStrip_
 
int chargedivisionsPerThickness_
 
double deltaCut_
 
RPDetId det_id_
 
std::unique_ptr< SiG4UniversalFluctuationfluctuate_
 
bool fluctuateCharge_
 
const edm::ParameterSetparams_
 
double pitch_
 
CLHEP::HepRandomEngine & rndEngine_
 
simromanpot::energy_path_distribution the_energy_path_distribution_
 
double thickness_
 
int verbosity_
 

Detailed Description

Definition at line 13 of file RPLinearChargeDivider.h.

Constructor & Destructor Documentation

RPLinearChargeDivider::RPLinearChargeDivider ( const edm::ParameterSet params,
CLHEP::HepRandomEngine &  eng,
RPDetId  det_id 
)

Definition at line 7 of file RPLinearChargeDivider.cc.

References chargedivisionsPerStrip_, chargedivisionsPerThickness_, deltaCut_, fluctuate_, fluctuateCharge_, edm::ParameterSet::getParameter(), pitch_, thickness_, and verbosity_.

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 }
T getParameter(std::string const &) const
std::unique_ptr< SiG4UniversalFluctuation > fluctuate_
Geometrical and topological information on RP silicon detector. Uses coordinate a frame with origin i...
Definition: RPTopology.h:29
const edm::ParameterSet & params_
CLHEP::HepRandomEngine & rndEngine_
RPLinearChargeDivider::~RPLinearChargeDivider ( )

Definition at line 37 of file RPLinearChargeDivider.cc.

37 {}

Member Function Documentation

simromanpot::energy_path_distribution RPLinearChargeDivider::divide ( const PSimHit hit)

Definition at line 39 of file RPLinearChargeDivider.cc.

References chargedivisionsPerStrip_, chargedivisionsPerThickness_, det_id_, simKBmtfDigis_cfi::eLoss, PSimHit::energyLoss(), PSimHit::entryPoint(), PSimHit::exitPoint(), fluctuateCharge_, FluctuateEloss(), mps_fire::i, createfilelist::int, PV3DBase< T, PVType, FrameType >::mag(), SiStripPI::max, PSimHit::pabs(), PSimHit::particleType(), pitch_, the_energy_path_distribution_, thickness_, verbosity_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

39  {
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 }
simromanpot::energy_path_distribution the_energy_path_distribution_
T y() const
Definition: PV3DBase.h:60
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:46
T mag() const
Definition: PV3DBase.h:64
T z() const
Definition: PV3DBase.h:61
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
Definition: PSimHit.h:67
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:79
int particleType() const
Definition: PSimHit.h:89
void FluctuateEloss(int pid, double particleMomentum, double eloss, double length, int NumberOfSegs, simromanpot::energy_path_distribution &elossVector)
T x() const
Definition: PV3DBase.h:59
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:43
void RPLinearChargeDivider::FluctuateEloss ( int  pid,
double  particleMomentum,
double  eloss,
double  length,
int  NumberOfSegs,
simromanpot::energy_path_distribution elossVector 
)
private

Definition at line 87 of file RPLinearChargeDivider.cc.

References funct::abs(), deltaCut_, EcalCondDBWriter_cfi::Energy, fluctuate_, mps_fire::i, cuy::ii, particleFlowDisplacedVertex_cfi::ratio, and rndEngine_.

Referenced by divide().

92  {
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 }
std::unique_ptr< SiG4UniversalFluctuation > fluctuate_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ii
Definition: cuy.py:590
CLHEP::HepRandomEngine & rndEngine_

Member Data Documentation

int RPLinearChargeDivider::chargedivisionsPerStrip_
private

Definition at line 25 of file RPLinearChargeDivider.h.

Referenced by divide(), and RPLinearChargeDivider().

int RPLinearChargeDivider::chargedivisionsPerThickness_
private

Definition at line 26 of file RPLinearChargeDivider.h.

Referenced by divide(), and RPLinearChargeDivider().

double RPLinearChargeDivider::deltaCut_
private

Definition at line 27 of file RPLinearChargeDivider.h.

Referenced by FluctuateEloss(), and RPLinearChargeDivider().

RPDetId RPLinearChargeDivider::det_id_
private

Definition at line 22 of file RPLinearChargeDivider.h.

Referenced by divide().

std::unique_ptr<SiG4UniversalFluctuation> RPLinearChargeDivider::fluctuate_
private

Definition at line 31 of file RPLinearChargeDivider.h.

Referenced by FluctuateEloss(), and RPLinearChargeDivider().

bool RPLinearChargeDivider::fluctuateCharge_
private

Definition at line 24 of file RPLinearChargeDivider.h.

Referenced by divide(), and RPLinearChargeDivider().

const edm::ParameterSet& RPLinearChargeDivider::params_
private

Definition at line 20 of file RPLinearChargeDivider.h.

double RPLinearChargeDivider::pitch_
private

Definition at line 28 of file RPLinearChargeDivider.h.

Referenced by divide(), and RPLinearChargeDivider().

CLHEP::HepRandomEngine& RPLinearChargeDivider::rndEngine_
private

Definition at line 21 of file RPLinearChargeDivider.h.

Referenced by FluctuateEloss().

simromanpot::energy_path_distribution RPLinearChargeDivider::the_energy_path_distribution_
private

Definition at line 30 of file RPLinearChargeDivider.h.

Referenced by divide().

double RPLinearChargeDivider::thickness_
private

Definition at line 29 of file RPLinearChargeDivider.h.

Referenced by divide(), and RPLinearChargeDivider().

int RPLinearChargeDivider::verbosity_
private

Definition at line 32 of file RPLinearChargeDivider.h.

Referenced by divide(), and RPLinearChargeDivider().