CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
 SiTrivialInduceChargeOnStrips (const edm::ParameterSet &conf, double g)
 
virtual ~SiTrivialInduceChargeOnStrips ()
 
- 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 84 of file SiTrivialInduceChargeOnStrips.cc.

85  : signalCoupling(fillSignalCoupling(conf, Ntypes, type)), Nsigma(3.), geVperElectron(g) {
86 }
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
virtual SiTrivialInduceChargeOnStrips::~SiTrivialInduceChargeOnStrips ( )
inlinevirtual

Definition at line 12 of file SiTrivialInduceChargeOnStrips.h.

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
virtual

Implements SiInduceChargeOnStrips.

Definition at line 90 of file SiTrivialInduceChargeOnStrips.cc.

References induceVector().

95  {
96 
97 
98  induceVector(collection_points, det, localAmplitudes, recordMinAffectedStrip, recordMaxAffectedStrip, tTopo);
99 
100  /*
101  auto ominA=recordMinAffectedStrip, omaxA=recordMaxAffectedStrip;
102  std::vector<float> oampl(localAmplitudes);
103  induceOriginal(collection_points, det, oampl, ominA, omaxA, tTopo);
104 
105  // std::cout << "orig " << ominA << " " << omaxA << " ";
106  //for (auto a : oampl) std::cout << a << ",";
107  //std::cout << std::endl;
108 
109  auto minA=recordMinAffectedStrip, maxA=recordMaxAffectedStrip;
110  std::vector<float> ampl(localAmplitudes);
111  induceVector(collection_points, det, ampl, minA, maxA, tTopo);
112 
113  // std::cout << "vect " << minA << " " << maxA << " ";
114  //for (auto a : ampl) std::cout << a << ",";
115  //std::cout << std::endl;
116 
117  float diff=0;
118  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);}
119  if (diff> 1.e-4) {
120  std::cout << diff << std::endl;
121  std::cout << "orig " << ominA << " " << omaxA << " ";
122 // for (auto a : oampl) std::cout << a << ",";
123  std::cout << std::endl;
124  std::cout << "vect " << minA << " " << maxA << " ";
125 // for (auto a : ampl) std::cout << a << ",";
126  std::cout << std::endl;
127  }
128 
129  localAmplitudes.swap(ampl);
130  recordMinAffectedStrip=minA;
131  recordMaxAffectedStrip=maxA;
132  */
133 
134 }
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 255 of file SiTrivialInduceChargeOnStrips.cc.

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

260  {
261 
262 
263  auto const & coupling = signalCoupling[typeOf(det,tTopo)];
264  const StripTopology& topology = dynamic_cast<const StripTopology&>(det.specificTopology());
265  size_t Nstrips = topology.nstrips();
266 
267  if (!collection_points.empty()) count.dep(collection_points.size());
268 
269  for (auto signalpoint = collection_points.begin(); signalpoint != collection_points.end(); signalpoint++ ) {
270 
271  //In strip coordinates:
272  double chargePosition = topology.strip(signalpoint->position());
273  double chargeSpread = signalpoint->sigma() / topology.localPitch(signalpoint->position());
274 
275  size_t fromStrip = size_t(std::max( 0, int(std::floor( chargePosition - Nsigma*chargeSpread))));
276  size_t untilStrip = size_t(std::min( Nstrips, size_t(std::ceil( chargePosition + Nsigma*chargeSpread) )));
277 
278  count.str(std::max(0,int(untilStrip)-int(fromStrip)));
279  for (size_t strip = fromStrip; strip < untilStrip; strip++) {
280 
281  double chargeDepositedOnStrip = chargeDeposited( strip, Nstrips, signalpoint->amplitude() / geVperElectron, chargeSpread, chargePosition);
282 
283  size_t affectedFromStrip = size_t(std::max( 0, int(strip - coupling.size() + 1)));
284  size_t affectedUntilStrip = size_t(std::min( Nstrips, strip + coupling.size()) );
285  for (size_t affectedStrip = affectedFromStrip; affectedStrip < affectedUntilStrip; affectedStrip++) {
286  localAmplitudes.at( affectedStrip ) += chargeDepositedOnStrip * coupling.at(abs( affectedStrip - strip )) ;
287  }
288 
289  if( affectedFromStrip < recordMinAffectedStrip ) recordMinAffectedStrip = affectedFromStrip;
290  if( affectedUntilStrip > recordMaxAffectedStrip ) recordMaxAffectedStrip = affectedUntilStrip;
291  }
292  }
293 
294 }
virtual int nstrips() const =0
CaloTopology const * topology(0)
const std::vector< std::vector< float > > signalCoupling
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
virtual float strip(const LocalPoint &) const =0
virtual float localPitch(const LocalPoint &) const =0
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
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 138 of file SiTrivialInduceChargeOnStrips.cc.

References funct::abs(), approx_erf(), assert(), RecoTauCleanerPlugins::charge, constexpr, prof2calltree::count, delta, f, geVperElectron, i, j, relval_steps::k, GetRecoTauVFromDQM_MC_cff::kk, StripTopology::localPitch(), bookConverter::max, HLT_25ns14e33_v1_cff::MaxN, min(), N, Nsigma, StripTopology::nstrips(), position, StripGeomDetUnit::specificTopology(), mathSSE::sqrt(), StripTopology::strip(), ecaldqm::topology(), and relativeConstraints::value.

Referenced by induce().

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