14 #include "CLHEP/Random/RandFlat.h"
16 #define CBOLTZ (1.38E-23)
17 #define e_SI (1.6E-19)
20 conf_(conf),rndEngine(eng){
44 LogDebug(
"StripDigiInfo")<<
"APVs running in peak mode (poor time resolution)";
47 LogDebug(
"StripDigiInfo")<<
"APVs running in deconvolution mode (good time resolution)";
76 const std::vector<std::pair<const PSimHit*, int > > &
input,
94 std::vector<bool> badChannels;
96 badChannels.insert(badChannels.begin(),
numStrips,
false);
99 fs=deadChannelHandle->decode(*it);
115 std::vector<std::pair<const PSimHit*, int > >::const_iterator simHitIter =
input.begin();
116 std::vector<std::pair<const PSimHit*, int > >::const_iterator simHitIterEnd =
input.end();
118 for (;simHitIter != simHitIterEnd; ++simHitIter) {
122 if ( std::fabs( ((*simHitIter).first)->tof() -
cosmicShift - det->
surface().
toGlobal(((*simHitIter).first)->localPosition()).
mag()/30.) <
tofCut && ((*simHitIter).first)->energyLoss()>0) {
132 int pdg_id = ((*simHitIter).first)->particleType();
136 bool isHadron =
particle->isHadron();
137 if(charge!=0 && isHadron){
141 std::cout <<
"-------------------HIP--------------" << std::endl;
142 std::cout <<
"Killing APVs " << FirstAPV <<
" - " <<LastAPV <<
" " << detID <<std::endl;
177 int RefStrip = int(numStrips/2.);
178 while(RefStrip<numStrips&&badChannels[RefStrip]){
181 if(RefStrip<numStrips){
182 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange);
183 float gainValue = gainHandle->getStripGain(RefStrip, detGainRange);
220 std::vector<float> noiseRMSv;
222 noiseRMSv.insert(noiseRMSv.begin(),
numStrips,0.);
226 if(!badChannels[strip]) noiseRMSv[
strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC;
231 while(RefStrip<numStrips&&badChannels[RefStrip]){
234 if(RefStrip<numStrips){
235 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC;
237 if(!badChannels[strip]) noiseRMSv[
strip] = noiseRMS;
268 std::vector<float> vPeds;
270 vPeds.insert(vPeds.begin(),
numStrips,0.);
301 const std::vector<float>& afterNoise,
302 unsigned int detID) {
304 for ( DigitalVecType::const_iterator
i=digis.begin();
i!=digis.end();
i++) {
307 HitToDigisMapType::const_iterator mi(htd.find(
i->strip()));
308 if (mi == htd.end())
continue;
309 HitCounterToDigisMapType::const_iterator cmi(hctd.find(
i->strip()));
310 std::map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
311 for (std::vector < std::pair < const PSimHit*, Amplitude > >::const_iterator simul =
312 (*mi).second.begin() ; simul != (*mi).second.end(); simul ++){
313 totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
317 double totalAmplitude1 = afterNoise[(*mi).first];
321 for (std::map<const PSimHit *, Amplitude>::const_iterator iter = totalAmplitudePerSimHit.begin();
322 iter != totalAmplitudePerSimHit.end(); iter++){
324 float fraction = (*iter).second/totalAmplitude1;
325 if (fraction >= threshold) {
327 if(fraction > 1.) fraction = 1.;
328 for (std::vector<std::pair<const PSimHit*, int > >::const_iterator
329 simcount = (*cmi).second.begin() ; simcount != (*cmi).second.end(); ++simcount){
330 if((*iter).first == (*simcount).first) sim_counter = (*simcount).second;
333 ((*iter).first)->trackId(),
335 ((*iter).first)->eventId(),
345 const std::vector<float>& afterNoise,
346 unsigned int detID) {
349 for ( DigitalRawVecType::const_iterator
i=digis.begin();
i!=digis.end();
i++) {
353 HitToDigisMapType::const_iterator mi(htd.find(nstrip));
354 HitCounterToDigisMapType::const_iterator cmi(hctd.find(nstrip));
355 if (mi == htd.end())
continue;
356 std::map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
357 for (std::vector < std::pair < const PSimHit*, Amplitude > >::const_iterator simul =
358 (*mi).second.begin() ; simul != (*mi).second.end(); simul ++){
359 totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
363 double totalAmplitude1 = afterNoise[(*mi).first];
366 int sim_counter_raw=0;
367 for (std::map<const PSimHit *, Amplitude>::const_iterator iter = totalAmplitudePerSimHit.begin();
368 iter != totalAmplitudePerSimHit.end(); iter++){
370 float fraction = (*iter).second/totalAmplitude1;
371 if (fraction >= threshold) {
373 if(fraction >1.) fraction = 1.;
375 for (std::vector<std::pair<const PSimHit*, int > >::const_iterator
376 simcount = (*cmi).second.begin() ; simcount != (*cmi).second.end(); ++simcount){
377 if((*iter).first == (*simcount).first) sim_counter_raw = (*simcount).second;
380 ((*iter).first)->trackId(),
382 ((*iter).first)->eventId(),
DigiSimLinkAlgorithm(const edm::ParameterSet &conf, CLHEP::HepRandomEngine &)
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
void processHit(const PSimHit *, const StripGeomDetUnit &, GlobalVector, float, std::vector< float > &, size_t &, size_t &, const TrackerTopology *tTopo)
SiHitDigitizer * theSiHitDigitizer
CLHEP::HepRandomEngine & rndEngine
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
std::pair< ContainerIterator, ContainerIterator > Range
const ParticleDataTable * pdt
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
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
std::vector< StripDigiSimLink > link_coll
uint32_t rawId() const
get the raw id
void addPedestals(std::vector< float > &, std::vector< float > &) const
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)
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
void addNoiseVR(std::vector< float > &, std::vector< float > &) const
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 addBaselineShift(std::vector< float > &, std::vector< bool > &) const
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 > &, const TrackerTopology *tTopo)
const ParticleData * particle
unsigned short firstStrip
std::pair< ContainerIterator, ContainerIterator > Range
bool APVSaturationFromHIP
DigiSimLinkPileUpSignals::HitToDigisMapType HitToDigisMapType
DigiSimLinkPileUpSignals * theDigiSimLinkPileUpSignals
void addNoise(std::vector< float > &, size_t &, size_t &, int, float) const
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
CLHEP::RandFlat * theFlatDistribution
void addCMNoise(std::vector< float > &, float, std::vector< bool > &) const