15 #include "CLHEP/Random/RandFlat.h"
17 #define CBOLTZ (1.38E-23)
18 #define e_SI (1.6E-19)
46 LogDebug(
"StripDigiInfo")<<
"APVs running in peak mode (poor time resolution)";
49 LogDebug(
"StripDigiInfo")<<
"APVs running in deconvolution mode (good time resolution)";
74 const std::vector<std::pair<const PSimHit*, int > > &
input,
83 CLHEP::HepRandomEngine* engine) {
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) {
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<float>& 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<float>& 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(),
void push_link(const DigitalVecType &, const HitToDigisMapType &, const HitCounterToDigisMapType &, const std::vector< float > &, unsigned int)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
SiHitDigitizer * theSiHitDigitizer
DigitalVecType convert(const std::vector< float > &, edm::ESHandle< SiStripGain > &, unsigned int detid)
DigitalRawVecType rawdigis
SiStripFedZeroSuppression * theSiZeroSuppress
size_t firstChannelWithSignal
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
std::vector< unsigned int >::const_iterator ContainerIterator
void addBaselineShift(std::vector< float > &, std::vector< bool > &) const override
std::pair< ContainerIterator, ContainerIterator > Range
const ParticleDataTable * pdt
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
bool isHadron(const P &p)
void addNoise(std::vector< float > &, size_t &, size_t &, int, float, CLHEP::HepRandomEngine *) const override
const Plane & surface() const
The nominal surface of the GeomDet.
void push_link_raw(const DigitalRawVecType &, const HitToDigisMapType &, const HitCounterToDigisMapType &, const std::vector< float > &, unsigned int)
SiDigitalConverter::DigitalRawVecType DigitalRawVecType
SiDigitalConverter::DigitalVecType DigitalVecType
static std::string const input
std::vector< StripDigiSimLink > link_coll
uint32_t rawId() const
get the raw id
SiTrivialDigitalConverter * theSiDigitalConverter
DigitalRawVecType convertRaw(const std::vector< float > &, edm::ESHandle< SiStripGain > &, unsigned int detid)
virtual void add(const std::vector< float > &locAmpl, const size_t &firstChannelWithSignal, const size_t &lastChannelWithSignal, const PSimHit *hit, const int &counter)
void run(edm::DetSet< SiStripDigi > &, edm::DetSet< SiStripRawDigi > &, const std::vector< std::pair< const PSimHit *, int > > &, StripGeomDetUnit const *, GlobalVector, float, edm::ESHandle< SiStripGain > &, edm::ESHandle< SiStripThreshold > &, edm::ESHandle< SiStripNoises > &, edm::ESHandle< SiStripPedestals > &, edm::ESHandle< SiStripBadStrip > &, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
std::vector< float > detAmpl
SiGaussianTailNoiseAdder * theSiNoiseAdder
const HitToDigisMapType & dumpLink() const
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
const HitCounterToDigisMapType & dumpCounterLink() const
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
DigiSimLinkPileUpSignals::HitCounterToDigisMapType HitCounterToDigisMapType
void processHit(const PSimHit *, const StripGeomDetUnit &, GlobalVector, float, std::vector< float > &, size_t &, size_t &, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
DigiSimLinkAlgorithm(const edm::ParameterSet &conf)
const ParticleData * particle
unsigned short firstStrip
void addPedestals(std::vector< float > &, std::vector< float > &) const override
std::pair< ContainerIterator, ContainerIterator > Range
void addCMNoise(std::vector< float > &, float, std::vector< bool > &, CLHEP::HepRandomEngine *) const override
bool APVSaturationFromHIP
DigiSimLinkPileUpSignals::HitToDigisMapType HitToDigisMapType
DigiSimLinkPileUpSignals * theDigiSimLinkPileUpSignals
double theTOFCutForDeconvolution
std::map< int, std::vector< std::pair< const PSimHit *, Amplitude > >, std::less< int > > HitToDigisMapType
std::map< int, std::vector< std::pair< const PSimHit *, int > >, std::less< int > > HitCounterToDigisMapType
std::vector< float > locAmpl
std::pair< ContainerIterator, ContainerIterator > Range
void addNoiseVR(std::vector< float > &, std::vector< float > &, CLHEP::HepRandomEngine *) const override