CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiTrivialInduceChargeOnStrips.cc
Go to the documentation of this file.
2 
6 #include <Math/ProbFuncMathCore.h>
12 
13 #include <algorithm>
14 #include <iostream>
15 
16 const int
18 Ntypes = 14;
19 
20 const std::string
22 type[Ntypes] = { "IB1", "IB2","OB1","OB2","W1a","W2a","W3a","W1b","W2b","W3b","W4","W5","W6","W7"};
23 
24 inline unsigned int
26 indexOf(const std::string& t) { return std::find( type, type + Ntypes, t) - type;}
27 
28 inline unsigned int
30 typeOf(const StripGeomDetUnit& det) {
31  DetId id = det.geographicalId();
32  switch (det.specificType().subDetector()) {
33  case GeomDetEnumerators::TIB: {return (TIBDetId(id).layer() < 3) ? indexOf("IB1") : indexOf("IB2");}
34  case GeomDetEnumerators::TOB: {return (TOBDetId(id).layer() > 4) ? indexOf("OB1") : indexOf("OB2");}
35  case GeomDetEnumerators::TID: {return indexOf("W1a") -1 + TIDDetId(id).ring();} //fragile: relies on ordering of 'type'
36  case GeomDetEnumerators::TEC: {return indexOf("W1b") -1 + TECDetId(id).ring();} //fragile: relies on ordering of 'type'
37  default: throw cms::Exception("Invalid subdetector") << id();
38  }
39 }
40 
43  : Nsigma(3.), geVperElectron(g) {
44  std::string mode = conf.getParameter<bool>("APVpeakmode") ? "Peak" : "Dec";
45  for(int i=0; i<Ntypes; i++)
46  signalCoupling.push_back(conf.getParameter<std::vector<double> >("CouplingConstant"+mode+type[i]));
47 }
48 
49 void
52  const StripGeomDetUnit& det,
53  std::vector<double>& localAmplitudes,
54  size_t& recordMinAffectedStrip,
55  size_t& recordMaxAffectedStrip) {
56 
57  std::vector<double>& coupling = signalCoupling.at(typeOf(det));
58  const StripTopology& topology = dynamic_cast<const StripTopology&>(det.specificTopology());
59  size_t Nstrips = topology.nstrips();
60 
61  for (SiChargeCollectionDrifter::collection_type::const_iterator
62  signalpoint = collection_points.begin(); signalpoint != collection_points.end(); signalpoint++ ) {
63 
64  //In strip coordinates:
65  double chargePosition = topology.strip(signalpoint->position());
66  double chargeSpread = signalpoint->sigma() / topology.localPitch(signalpoint->position());
67 
68  size_t fromStrip = size_t(std::max( 0, int(std::floor( chargePosition - Nsigma*chargeSpread))));
69  size_t untilStrip = size_t(std::min( Nstrips, size_t(std::ceil( chargePosition + Nsigma*chargeSpread) )));
70  for (size_t strip = fromStrip; strip < untilStrip; strip++) {
71 
72  double chargeDepositedOnStrip = chargeDeposited( strip, Nstrips, signalpoint->amplitude(), chargeSpread, chargePosition);
73 
74  size_t affectedFromStrip = size_t(std::max( 0, int(strip - coupling.size() + 1)));
75  size_t affectedUntilStrip = size_t(std::min( Nstrips, strip + coupling.size()) );
76  for (size_t affectedStrip = affectedFromStrip; affectedStrip < affectedUntilStrip; affectedStrip++) {
77  localAmplitudes.at( affectedStrip ) += chargeDepositedOnStrip * coupling.at(abs( affectedStrip - strip )) ;
78  }
79 
80  if( affectedFromStrip < recordMinAffectedStrip ) recordMinAffectedStrip = affectedFromStrip;
81  if( affectedUntilStrip > recordMaxAffectedStrip ) recordMaxAffectedStrip = affectedUntilStrip;
82  }
83  }
84  return;
85 }
86 
87 inline double
89 chargeDeposited(size_t strip, size_t Nstrips, double amplitude, double chargeSpread, double chargePosition) const {
90  double integralUpToStrip = (strip == 0) ? 0. : ( ROOT::Math::normal_cdf( strip, chargeSpread, chargePosition) );
91  double integralUpToNext = (strip+1 == Nstrips) ? 1. : ( ROOT::Math::normal_cdf( strip+1, chargeSpread, chargePosition) );
92  double percentOfSignal = integralUpToNext - integralUpToStrip;
93 
94  return percentOfSignal * amplitude / geVperElectron;
95 }
type
Definition: HCALResponse.h:22
T getParameter(std::string const &) const
virtual int nstrips() const =0
int i
Definition: DBlmapReader.cc:9
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
static unsigned int indexOf(const std::string &)
double chargeDeposited(size_t strip, size_t Nstrips, double amplitude, double chargeSpread, double chargePosition) const
std::vector< std::vector< double > > signalCoupling
#define abs(x)
Definition: mlp_lapack.h:159
std::vector< SignalPoint > collection_type
#define min(a, b)
Definition: mlp_lapack.h:161
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
virtual float strip(const LocalPoint &) const =0
virtual float localPitch(const LocalPoint &) const =0
const T & max(const T &a, const T &b)
unsigned int ring() const
ring id
Definition: TIDDetId.h:55
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
static unsigned int typeOf(const StripGeomDetUnit &)
virtual StripGeomDetType & specificType() const
tuple conf
Definition: dbtoconf.py:185
Definition: DetId.h:20
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
unsigned int ring() const
ring id
Definition: TECDetId.h:71
void induce(SiChargeCollectionDrifter::collection_type collection_points, const StripGeomDetUnit &det, std::vector< double > &localAmplitudes, size_t &recordMinAffectedStrip, size_t &recordMaxAffectedStrip)
SiTrivialInduceChargeOnStrips(const edm::ParameterSet &conf, double g)
SubDetector subDetector() const
Definition: GeomDetType.h:22