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) {
119 if ( std::fabs( ((*simHitIter).first)->tof() -
cosmicShift - det->
surface().
toGlobal(((*simHitIter).first)->localPosition()).
mag()/30.) <
tofCut && ((*simHitIter).first)->energyLoss()>0) {
133 bool isHadron =
particle->isHadron();
134 if(charge!=0 && isHadron){
138 std::cout <<
"-------------------HIP--------------" << std::endl;
139 std::cout <<
"Killing APVs " << FirstAPV <<
" - " <<LastAPV <<
" " << detID <<std::endl;
175 while(RefStrip<numStrips&&badChannels[RefStrip]){
178 if(RefStrip<numStrips){
179 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange);
180 float gainValue = gainHandle->getStripGain(RefStrip, detGainRange);
217 std::vector<float> noiseRMSv;
219 noiseRMSv.insert(noiseRMSv.begin(),
numStrips,0.);
223 if(!badChannels[strip]) noiseRMSv[
strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC;
228 while(RefStrip<numStrips&&badChannels[RefStrip]){
231 if(RefStrip<numStrips){
232 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC;
234 if(!badChannels[strip]) noiseRMSv[
strip] = noiseRMS;
265 std::vector<float> vPeds;
267 vPeds.insert(vPeds.begin(),
numStrips,0.);
298 const std::vector<double>& afterNoise,
299 unsigned int detID) {
301 for ( DigitalVecType::const_iterator
i=digis.begin();
i!=digis.end();
i++) {
304 HitToDigisMapType::const_iterator mi(htd.find(
i->strip()));
305 if (mi == htd.end())
continue;
306 HitCounterToDigisMapType::const_iterator cmi(hctd.find(
i->strip()));
307 std::map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
308 for (std::vector < std::pair < const PSimHit*, Amplitude > >::const_iterator simul =
309 (*mi).second.begin() ; simul != (*mi).second.end(); simul ++){
310 totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
314 double totalAmplitude1 = afterNoise[(*mi).first];
318 for (std::map<const PSimHit *, Amplitude>::const_iterator iter = totalAmplitudePerSimHit.begin();
319 iter != totalAmplitudePerSimHit.end(); iter++){
321 float fraction = (*iter).second/totalAmplitude1;
322 if ( fraction >= threshold) {
324 if(fraction > 1.) fraction = 1.;
325 for (std::vector < std::pair < const PSimHit*, int > >::const_iterator
326 simcount = (*cmi).second.begin() ; simcount != (*cmi).second.end(); simcount ++){
327 if((*iter).first == (*simcount).first) sim_counter = (*simcount).second;
330 ((*iter).first)->trackId(),
332 ((*iter).first)->eventId(),
342 const std::vector<double>& afterNoise,
343 unsigned int detID) {
346 for ( DigitalRawVecType::const_iterator
i=digis.begin();
i!=digis.end();
i++) {
350 HitToDigisMapType::const_iterator mi(htd.find(nstrip));
351 HitCounterToDigisMapType::const_iterator cmi(hctd.find(nstrip));
352 if (mi == htd.end())
continue;
353 std::map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
354 for (std::vector < std::pair < const PSimHit*, Amplitude > >::const_iterator simul =
355 (*mi).second.begin() ; simul != (*mi).second.end(); simul ++){
356 totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
360 double totalAmplitude1 = afterNoise[(*mi).first];
363 int sim_counter_raw=0;
364 for (std::map<const PSimHit *, Amplitude>::const_iterator iter = totalAmplitudePerSimHit.begin();
365 iter != totalAmplitudePerSimHit.end(); iter++){
367 float fraction = (*iter).second/totalAmplitude1;
368 if (fraction >= threshold) {
370 if(fraction >1.) fraction = 1.;
372 for (std::vector < std::pair < const PSimHit*, int > >::const_iterator
373 simcount = (*cmi).second.begin() ; simcount != (*cmi).second.end(); simcount ++){
374 if((*iter).first == (*simcount).first) sim_counter_raw = (*simcount).second;
377 ((*iter).first)->trackId(),
379 ((*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
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 &)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
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)
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
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
const HitToDigisMapType & dumpLink() const
CLHEP::RandFlat * theFlatDistribution
~SiStripDigitizerAlgorithm()