CMS 3D CMS Logo

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

#include <SiTrivialInduceChargeOnStrips.h>

Inheritance diagram for SiTrivialInduceChargeOnStrips:
SiInduceChargeOnStrips

Public Member Functions

void induce (const SiChargeCollectionDrifter::collection_type &collection_points, const StripGeomDetUnit &det, std::vector< float > &localAmplitudes, size_t &recordMinAffectedStrip, size_t &recordMaxAffectedStrip, const TrackerTopology *tTopo) const override
 
 SiTrivialInduceChargeOnStrips (const edm::ParameterSet &conf, double g)
 
 ~SiTrivialInduceChargeOnStrips () override
 
- Public Member Functions inherited from SiInduceChargeOnStrips
virtual ~SiInduceChargeOnStrips ()
 

Private Member Functions

void induceOriginal (const SiChargeCollectionDrifter::collection_type &collection_points, const StripGeomDetUnit &det, std::vector< float > &localAmplitudes, size_t &recordMinAffectedStrip, size_t &recordMaxAffectedStrip, const TrackerTopology *tTopo) const
 
void induceVector (const SiChargeCollectionDrifter::collection_type &collection_points, const StripGeomDetUnit &det, std::vector< float > &localAmplitudes, size_t &recordMinAffectedStrip, size_t &recordMaxAffectedStrip, const TrackerTopology *tTopo) const
 

Private Attributes

const float geVperElectron
 
const float Nsigma
 
const std::vector< std::vector< float > > signalCoupling
 

Detailed Description

Definition at line 9 of file SiTrivialInduceChargeOnStrips.h.

Constructor & Destructor Documentation

SiTrivialInduceChargeOnStrips::SiTrivialInduceChargeOnStrips ( const edm::ParameterSet conf,
double  g 
)

Definition at line 100 of file SiTrivialInduceChargeOnStrips.cc.

References induce().

101  : signalCoupling(fillSignalCoupling(conf, Ntypes, type)), Nsigma(3.), geVperElectron(g) {
102 }
type
Definition: HCALResponse.h:21
const std::vector< std::vector< float > > signalCoupling
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
SiTrivialInduceChargeOnStrips::~SiTrivialInduceChargeOnStrips ( )
inlineoverride

Definition at line 12 of file SiTrivialInduceChargeOnStrips.h.

References induce(), induceOriginal(), and induceVector().

12 {}

Member Function Documentation

void SiTrivialInduceChargeOnStrips::induce ( const SiChargeCollectionDrifter::collection_type collection_points,
const StripGeomDetUnit det,
std::vector< float > &  localAmplitudes,
size_t &  recordMinAffectedStrip,
size_t &  recordMaxAffectedStrip,
const TrackerTopology tTopo 
) const
overridevirtual

Implements SiInduceChargeOnStrips.

Definition at line 106 of file SiTrivialInduceChargeOnStrips.cc.

References induceVector().

Referenced by SiTrivialInduceChargeOnStrips(), and ~SiTrivialInduceChargeOnStrips().

111  {
112 
113 
114  induceVector(collection_points, det, localAmplitudes, recordMinAffectedStrip, recordMaxAffectedStrip, tTopo);
115 
116  /*
117  auto ominA=recordMinAffectedStrip, omaxA=recordMaxAffectedStrip;
118  std::vector<float> oampl(localAmplitudes);
119  induceOriginal(collection_points, det, oampl, ominA, omaxA, tTopo);
120 
121  // std::cout << "orig " << ominA << " " << omaxA << " ";
122  //for (auto a : oampl) std::cout << a << ",";
123  //std::cout << std::endl;
124 
125  auto minA=recordMinAffectedStrip, maxA=recordMaxAffectedStrip;
126  std::vector<float> ampl(localAmplitudes);
127  induceVector(collection_points, det, ampl, minA, maxA, tTopo);
128 
129  // std::cout << "vect " << minA << " " << maxA << " ";
130  //for (auto a : ampl) std::cout << a << ",";
131  //std::cout << std::endl;
132 
133  float diff=0;
134  for (size_t i=0; i!=ampl.size(); ++i) { diff = std::max(diff,ampl[i]>0 ? std::abs(ampl[i]-oampl[i])/ampl[i] : 0);}
135  if (diff> 1.e-4) {
136  std::cout << diff << std::endl;
137  std::cout << "orig " << ominA << " " << omaxA << " ";
138 // for (auto a : oampl) std::cout << a << ",";
139  std::cout << std::endl;
140  std::cout << "vect " << minA << " " << maxA << " ";
141 // for (auto a : ampl) std::cout << a << ",";
142  std::cout << std::endl;
143  }
144 
145  localAmplitudes.swap(ampl);
146  recordMinAffectedStrip=minA;
147  recordMaxAffectedStrip=maxA;
148  */
149 
150 }
void induceVector(const SiChargeCollectionDrifter::collection_type &collection_points, const StripGeomDetUnit &det, std::vector< float > &localAmplitudes, size_t &recordMinAffectedStrip, size_t &recordMaxAffectedStrip, const TrackerTopology *tTopo) const
void SiTrivialInduceChargeOnStrips::induceOriginal ( const SiChargeCollectionDrifter::collection_type collection_points,
const StripGeomDetUnit det,
std::vector< float > &  localAmplitudes,
size_t &  recordMinAffectedStrip,
size_t &  recordMaxAffectedStrip,
const TrackerTopology tTopo 
) const
private

Definition at line 271 of file SiTrivialInduceChargeOnStrips.cc.

References funct::abs(), geVperElectron, StripTopology::localPitch(), SiStripPI::max, min(), Nsigma, StripTopology::nstrips(), StripGeomDetUnit::specificTopology(), StripTopology::strip(), and ecaldqm::topology().

Referenced by induceVector(), and ~SiTrivialInduceChargeOnStrips().

276  {
277 
278 
279  auto const & coupling = signalCoupling[typeOf(det,tTopo)];
280  const StripTopology& topology = dynamic_cast<const StripTopology&>(det.specificTopology());
281  size_t Nstrips = topology.nstrips();
282 
283  if (!collection_points.empty()) count.dep(collection_points.size());
284 
285  for (auto signalpoint = collection_points.begin(); signalpoint != collection_points.end(); signalpoint++ ) {
286 
287  //In strip coordinates:
288  double chargePosition = topology.strip(signalpoint->position());
289  double chargeSpread = signalpoint->sigma() / topology.localPitch(signalpoint->position());
290 
291  size_t fromStrip = size_t(std::max( 0, int(std::floor( chargePosition - Nsigma*chargeSpread))));
292  size_t untilStrip = size_t(std::min( Nstrips, size_t(std::ceil( chargePosition + Nsigma*chargeSpread) )));
293 
294  count.str(std::max(0,int(untilStrip)-int(fromStrip)));
295  for (size_t strip = fromStrip; strip < untilStrip; strip++) {
296 
297  double chargeDepositedOnStrip = chargeDeposited( strip, Nstrips, signalpoint->amplitude() / geVperElectron, chargeSpread, chargePosition);
298 
299  size_t affectedFromStrip = size_t(std::max( 0, int(strip - coupling.size() + 1)));
300  size_t affectedUntilStrip = size_t(std::min( Nstrips, strip + coupling.size()) );
301  for (size_t affectedStrip = affectedFromStrip; affectedStrip < affectedUntilStrip; affectedStrip++) {
302  localAmplitudes.at( affectedStrip ) += chargeDepositedOnStrip * coupling.at((size_t)std::abs( (int)affectedStrip - (int)strip )) ;
303  }
304 
305  if( affectedFromStrip < recordMinAffectedStrip ) recordMinAffectedStrip = affectedFromStrip;
306  if( affectedUntilStrip > recordMaxAffectedStrip ) recordMaxAffectedStrip = affectedUntilStrip;
307  }
308  }
309 
310 }
CaloTopology const * topology(0)
virtual float strip(const LocalPoint &) const =0
const std::vector< std::vector< float > > signalCoupling
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
virtual int nstrips() const =0
virtual float localPitch(const LocalPoint &) const =0
void SiTrivialInduceChargeOnStrips::induceVector ( const SiChargeCollectionDrifter::collection_type collection_points,
const StripGeomDetUnit det,
std::vector< float > &  localAmplitudes,
size_t &  recordMinAffectedStrip,
size_t &  recordMaxAffectedStrip,
const TrackerTopology tTopo 
) const
private

include last strip

do crosstalk... (can be done better, most probably not worth)

Definition at line 154 of file SiTrivialInduceChargeOnStrips.cc.

References funct::abs(), CustomPhysics_cfi::amplitude, approx_erf(), ALCARECOTkAlJpsiMuMu_cff::charge, constexpr, delta, f, objects.autophobj::float, geVperElectron, mps_fire::i, induceOriginal(), gen::k, GetRecoTauVFromDQM_MC_cff::kk, StripTopology::localPitch(), SiStripPI::max, PFRecoTauDiscriminationByNProngs_cfi::MaxN, min(), N, Nsigma, StripTopology::nstrips(), position, SimDataFormats::CaloAnalysis::sc, StripGeomDetUnit::specificTopology(), mathSSE::sqrt(), StripTopology::strip(), and ecaldqm::topology().

Referenced by induce(), and ~SiTrivialInduceChargeOnStrips().

159  {
160 
161 
162  auto const & coupling = signalCoupling[typeOf(det,tTopo)];
163  const StripTopology& topology = dynamic_cast<const StripTopology&>(det.specificTopology());
164  const int Nstrips = topology.nstrips();
165 
166  if (Nstrips == 0) return;
167 
168  const int NP = collection_points.size();
169  if(0==NP) return;
170 
171  constexpr int MaxN = 512;
172  // if NP too large split...
173 
174  for (int ip=0; ip<NP; ip+=MaxN) {
175  auto N = std::min(NP-ip,MaxN);
176 
177  count.dep(N);
178  float amplitude[N];
179  float chargePosition[N];
180  float chargeSpread[N];
181  int fromStrip[N];
182  int nStrip[N];
183 
184  // load not vectorize
185  //In strip coordinates:
186  for (int i=0; i!=N;++i) {
187  auto j = ip+i;
188  if (0==collection_points[j].amplitude()) count.zero();
189  chargePosition[i]=topology.strip(collection_points[j].position());
190  chargeSpread[i]= collection_points[j].sigma() / topology.localPitch(collection_points[j].position());
191  amplitude[i]=0.5f*collection_points[j].amplitude() / geVperElectron;
192  }
193 
194  // this vectorize
195  for (int i=0; i!=N;++i) {
196  fromStrip[i] = std::max( 0, int(std::floor( chargePosition[i] - Nsigma*chargeSpread[i])) );
197  nStrip[i] = std::min( Nstrips, int(std::ceil( chargePosition[i] + Nsigma*chargeSpread[i])) ) - fromStrip[i];
198  }
199  int tot=0;
200  for (int i=0; i!=N;++i) tot += nStrip[i];
201  tot+=N; // add last strip
202  count.val(tot);
203  float value[tot];
204 
205  // assign relative position (lower bound of strip) in value;
206  int kk=0;
207  for (int i=0; i!=N;++i) {
208  auto delta = 1.f/(std::sqrt(2.f)*chargeSpread[i]);
209  auto pos = delta*(float(fromStrip[i])-chargePosition[i]);
210 
211  // VI: before value[0] was not defined and value[tot] was filled
212  // to fix this the loop below was changed
213  for (int j=0;j<=nStrip[i]; ++j) {
214  value[kk] = pos+float(j)*delta;
215  ++kk;
216  }
217  }
218  assert(kk==tot);
219 
220  // main loop fully vectorized
221  for (int k=0;k!=tot; ++k)
222  value[k] = approx_erf(value[k]);
223 
224  // saturate 0 & NStrips strip to 0 and 1???
225  kk=0;
226  for (int i=0; i!=N;++i) {
227  if (0 == fromStrip[i]) value[kk]=0;
228  kk+=nStrip[i];
229  if (Nstrips == fromStrip[i]+nStrip[i]) value[kk]=1.f;
230  ++kk;
231  }
232  assert(kk==tot);
233 
234  // compute integral over strip (lower bound becomes the value)
235  for (int k=0;k!=tot-1; ++k)
236  value[k]-=value[k+1]; // this is negative!
237 
238 
239  float charge[Nstrips]; for (int i=0;i!=Nstrips; ++i) charge[i]=0;
240  kk=0;
241  for (int i=0; i!=N;++i){
242  for (int j=0;j!=nStrip[i]; ++j)
243  charge[fromStrip[i]+j]-= amplitude[i]*value[kk++];
244  ++kk; // skip last "strip"
245  }
246  assert(kk==tot);
247 
248 
250  int minA=recordMinAffectedStrip, maxA=recordMaxAffectedStrip;
251  int sc = coupling.size();
252  for (int i=0;i!=Nstrips; ++i) {
253  int strip = i;
254  if (0==charge[i]) continue;
255  auto affectedFromStrip = std::max( 0, strip - sc + 1);
256  auto affectedUntilStrip = std::min(Nstrips, strip + sc);
257  for (auto affectedStrip=affectedFromStrip; affectedStrip < affectedUntilStrip; ++affectedStrip)
258  localAmplitudes[affectedStrip] += charge[i] * coupling[std::abs(affectedStrip - strip)] ;
259 
260  if( affectedFromStrip < minA ) minA = affectedFromStrip;
261  if( affectedUntilStrip > maxA ) maxA = affectedUntilStrip;
262  }
263  recordMinAffectedStrip=minA;
264  recordMaxAffectedStrip=maxA;
265  } // end loop ip
266 
267 }
dbl * delta
Definition: mlp_gen.cc:36
CaloTopology const * topology(0)
virtual float strip(const LocalPoint &) const =0
const std::vector< std::vector< float > > signalCoupling
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
#define constexpr
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
Definition: value.py:1
T min(T a, T b)
Definition: MathUtil.h:58
int k[5][pyjets_maxn]
#define N
Definition: blowfish.cc:9
virtual int nstrips() const =0
constexpr float approx_erf(float x)
Definition: approx_erf.h:6
virtual float localPitch(const LocalPoint &) const =0
static int position[264][3]
Definition: ReadPGInfo.cc:509

Member Data Documentation

const float SiTrivialInduceChargeOnStrips::geVperElectron
private

Definition at line 41 of file SiTrivialInduceChargeOnStrips.h.

Referenced by induceOriginal(), and induceVector().

const float SiTrivialInduceChargeOnStrips::Nsigma
private

Definition at line 40 of file SiTrivialInduceChargeOnStrips.h.

Referenced by induceOriginal(), and induceVector().

const std::vector<std::vector<float> > SiTrivialInduceChargeOnStrips::signalCoupling
private

Definition at line 38 of file SiTrivialInduceChargeOnStrips.h.