13 #include "CLHEP/Random/RandFlat.h"
15 #define CBOLTZ (1.38E-23)
16 #define e_SI (1.6E-19)
19 conf_(conf),rndEngine(eng){
43 LogDebug(
"StripDigiInfo")<<
"APVs running in peak mode (poor time resolution)";
46 LogDebug(
"StripDigiInfo")<<
"APVs running in deconvolution mode (good time resolution)";
75 const std::vector<std::pair<const PSimHit*, int > > &
input,
93 std::vector<bool> badChannels;
95 badChannels.insert(badChannels.begin(),
numStrips,
false);
98 fs=deadChannelHandle->decode(*it);
114 std::vector<std::pair<const PSimHit*, int > >::const_iterator simHitIter =
input.begin();
115 std::vector<std::pair<const PSimHit*, int > >::const_iterator simHitIterEnd =
input.end();
117 for (;simHitIter != simHitIterEnd; ++simHitIter) {
121 if ( std::fabs( ((*simHitIter).first)->tof() -
cosmicShift - det->
surface().
toGlobal(((*simHitIter).first)->localPosition()).
mag()/30.) <
tofCut && ((*simHitIter).first)->energyLoss()>0) {
131 int pdg_id = ((*simHitIter).first)->particleType();
135 bool isHadron =
particle->isHadron();
136 if(charge!=0 && isHadron){
140 std::cout <<
"-------------------HIP--------------" << std::endl;
141 std::cout <<
"Killing APVs " << FirstAPV <<
" - " <<LastAPV <<
" " << detID <<std::endl;
176 int RefStrip = int(numStrips/2.);
177 while(RefStrip<numStrips&&badChannels[RefStrip]){
180 if(RefStrip<numStrips){
181 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange);
182 float gainValue = gainHandle->getStripGain(RefStrip, detGainRange);
219 std::vector<float> noiseRMSv;
221 noiseRMSv.insert(noiseRMSv.begin(),
numStrips,0.);
225 if(!badChannels[strip]) noiseRMSv[
strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC;
230 while(RefStrip<numStrips&&badChannels[RefStrip]){
233 if(RefStrip<numStrips){
234 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC;
236 if(!badChannels[strip]) noiseRMSv[
strip] = noiseRMS;
267 std::vector<float> vPeds;
269 vPeds.insert(vPeds.begin(),
numStrips,0.);
300 const std::vector<double>& afterNoise,
301 unsigned int detID) {
303 for ( DigitalVecType::const_iterator
i=digis.begin();
i!=digis.end();
i++) {
306 HitToDigisMapType::const_iterator mi(htd.find(
i->strip()));
307 if (mi == htd.end())
continue;
308 HitCounterToDigisMapType::const_iterator cmi(hctd.find(
i->strip()));
309 std::map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
310 for (std::vector < std::pair < const PSimHit*, Amplitude > >::const_iterator simul =
311 (*mi).second.begin() ; simul != (*mi).second.end(); simul ++){
312 totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
316 double totalAmplitude1 = afterNoise[(*mi).first];
320 for (std::map<const PSimHit *, Amplitude>::const_iterator iter = totalAmplitudePerSimHit.begin();
321 iter != totalAmplitudePerSimHit.end(); iter++){
323 float fraction = (*iter).second/totalAmplitude1;
324 if ( fraction >= threshold) {
326 if(fraction > 1.) fraction = 1.;
327 for (std::vector < std::pair < const PSimHit*, int > >::const_iterator
328 simcount = (*cmi).second.begin() ; simcount != (*cmi).second.end(); simcount ++){
329 if((*iter).first == (*simcount).first) sim_counter = (*simcount).second;
332 ((*iter).first)->trackId(),
334 ((*iter).first)->eventId(),
344 const std::vector<double>& afterNoise,
345 unsigned int detID) {
348 for ( DigitalRawVecType::const_iterator
i=digis.begin();
i!=digis.end();
i++) {
352 HitToDigisMapType::const_iterator mi(htd.find(nstrip));
353 HitCounterToDigisMapType::const_iterator cmi(hctd.find(nstrip));
354 if (mi == htd.end())
continue;
355 std::map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
356 for (std::vector < std::pair < const PSimHit*, Amplitude > >::const_iterator simul =
357 (*mi).second.begin() ; simul != (*mi).second.end(); simul ++){
358 totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
362 double totalAmplitude1 = afterNoise[(*mi).first];
365 int sim_counter_raw=0;
366 for (std::map<const PSimHit *, Amplitude>::const_iterator iter = totalAmplitudePerSimHit.begin();
367 iter != totalAmplitudePerSimHit.end(); iter++){
369 float fraction = (*iter).second/totalAmplitude1;
370 if (fraction >= threshold) {
372 if(fraction >1.) fraction = 1.;
374 for (std::vector < std::pair < const PSimHit*, int > >::const_iterator
375 simcount = (*cmi).second.begin() ; simcount != (*cmi).second.end(); simcount ++){
376 if((*iter).first == (*simcount).first) sim_counter_raw = (*simcount).second;
379 ((*iter).first)->trackId(),
381 ((*iter).first)->eventId(),
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > locAmpl
DigitalVecType convert(const std::vector< double > &, edm::ESHandle< SiStripGain > &, unsigned int detid)
void addCMNoise(std::vector< double > &, float, std::vector< bool > &)
const HitCounterToDigisMapType & dumpCounterLink() const
SiDigitalConverter::DigitalRawVecType DigitalRawVecType
SiDigitalConverter::DigitalVecType DigitalVecType
CLHEP::HepRandomEngine & rndEngine
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
SiHitDigitizer * theSiHitDigitizer
std::vector< unsigned int >::const_iterator ContainerIterator
std::pair< ContainerIterator, ContainerIterator > Range
void addBaselineShift(std::vector< double > &, std::vector< bool > &)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
void addNoiseVR(std::vector< double > &, std::vector< float > &)
void push_link_raw(const DigitalRawVecType &, const HitToDigisMapType &, const HitCounterToDigisMapType &, const std::vector< double > &, unsigned int)
std::vector< double > detAmpl
uint32_t rawId() const
get the raw id
void push_link(const DigitalVecType &, const HitToDigisMapType &, const HitCounterToDigisMapType &, const std::vector< double > &, unsigned int)
DigitalRawVecType rawdigis
SiStripDigitizerAlgorithm(const edm::ParameterSet &conf, CLHEP::HepRandomEngine &)
SiPileUpSignals::HitToDigisMapType HitToDigisMapType
SiPileUpSignals * theSiPileUpSignals
SiPileUpSignals::HitCounterToDigisMapType HitCounterToDigisMapType
void suppress(const std::vector< SiStripDigi > &, std::vector< SiStripDigi > &, const uint32_t &, edm::ESHandle< SiStripNoises > &, edm::ESHandle< SiStripThreshold > &)
std::pair< ContainerIterator, ContainerIterator > Range
DetId geographicalId() const
The label of this GeomDet.
size_t lastChannelWithSignal
std::map< int, std::vector< std::pair< const PSimHit *, int > >, std::less< int > > HitCounterToDigisMapType
std::map< int, std::vector< std::pair< const PSimHit *, Amplitude > >, std::less< int > > HitToDigisMapType
void processHit(const PSimHit *, const StripGeomDetUnit &, GlobalVector, float, std::vector< double > &, size_t &, size_t &)
double theTOFCutForDeconvolution
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned short firstStrip
SiTrivialDigitalConverter * theSiDigitalConverter
bool APVSaturationFromHIP
void addNoise(std::vector< double > &, size_t &, size_t &, int, float)
const BoundPlane & surface() const
The nominal surface of the GeomDet.
std::pair< ContainerIterator, ContainerIterator > Range
SiStripFedZeroSuppression * theSiZeroSuppress
SiGaussianTailNoiseAdder * theSiNoiseAdder
void run(edm::DetSet< SiStripDigi > &, edm::DetSet< SiStripRawDigi > &, const std::vector< std::pair< const PSimHit *, int > > &, StripGeomDetUnit *, GlobalVector, float, edm::ESHandle< SiStripGain > &, edm::ESHandle< SiStripThreshold > &, edm::ESHandle< SiStripNoises > &, edm::ESHandle< SiStripPedestals > &, edm::ESHandle< SiStripBadStrip > &)
virtual void add(const std::vector< double > &locAmpl, const size_t &firstChannelWithSignal, const size_t &lastChannelWithSignal, const PSimHit *hit, const int &counter)
std::pair< ContainerIterator, ContainerIterator > Range
size_t firstChannelWithSignal
DigitalRawVecType convertRaw(const std::vector< double > &, edm::ESHandle< SiStripGain > &, unsigned int detid)
std::vector< StripDigiSimLink > link_coll
const ParticleData * particle
void addPedestals(std::vector< double > &, std::vector< float > &)
const ParticleDataTable * pdt
const HitToDigisMapType & dumpLink() const
CLHEP::RandFlat * theFlatDistribution
~SiStripDigitizerAlgorithm()