15 #include "CLHEP/Random/RandFlat.h"
17 #define CBOLTZ (1.38E-23)
18 #define e_SI (1.6E-19)
45 LogDebug(
"StripDigiInfo")<<
"APVs running in peak mode (poor time resolution)";
48 LogDebug(
"StripDigiInfo")<<
"APVs running in deconvolution mode (good time resolution)";
73 const std::vector<std::pair<const PSimHit*, int > > &
input,
82 CLHEP::HepRandomEngine* engine) {
92 std::vector<bool> badChannels;
94 badChannels.insert(badChannels.begin(),
numStrips,
false);
97 fs=deadChannelHandle->decode(*it);
113 std::vector<std::pair<const PSimHit*, int > >::const_iterator simHitIter =
input.begin();
114 std::vector<std::pair<const PSimHit*, int > >::const_iterator simHitIterEnd =
input.end();
116 for (;simHitIter != simHitIterEnd; ++simHitIter) {
120 if ( std::fabs( ((*simHitIter).first)->tof() -
cosmicShift - det->
surface().
toGlobal(((*simHitIter).first)->localPosition()).
mag()/30.) <
tofCut && ((*simHitIter).first)->energyLoss()>0) {
130 int pdg_id = ((*simHitIter).first)->particleType();
134 bool isHadron =
particle->isHadron();
135 if(charge!=0 && isHadron){
139 std::cout <<
"-------------------HIP--------------" << std::endl;
140 std::cout <<
"Killing APVs " << FirstAPV <<
" - " <<LastAPV <<
" " << detID <<std::endl;
175 int RefStrip = int(numStrips/2.);
176 while(RefStrip<numStrips&&badChannels[RefStrip]){
179 if(RefStrip<numStrips){
180 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange);
181 float gainValue = gainHandle->getStripGain(RefStrip, detGainRange);
218 std::vector<float> noiseRMSv;
220 noiseRMSv.insert(noiseRMSv.begin(),
numStrips,0.);
224 if(!badChannels[strip]) noiseRMSv[
strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC;
229 while(RefStrip<numStrips&&badChannels[RefStrip]){
232 if(RefStrip<numStrips){
233 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC;
235 if(!badChannels[strip]) noiseRMSv[
strip] = noiseRMS;
266 std::vector<float> vPeds;
268 vPeds.insert(vPeds.begin(),
numStrips,0.);
299 const std::vector<float>& afterNoise,
300 unsigned int detID) {
302 for ( DigitalVecType::const_iterator
i=digis.begin();
i!=digis.end();
i++) {
305 HitToDigisMapType::const_iterator mi(htd.find(
i->strip()));
306 if (mi == htd.end())
continue;
307 HitCounterToDigisMapType::const_iterator cmi(hctd.find(
i->strip()));
308 std::map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
309 for (std::vector < std::pair < const PSimHit*, Amplitude > >::const_iterator simul =
310 (*mi).second.begin() ; simul != (*mi).second.end(); simul ++){
311 totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
315 double totalAmplitude1 = afterNoise[(*mi).first];
319 for (std::map<const PSimHit *, Amplitude>::const_iterator
iter = totalAmplitudePerSimHit.begin();
320 iter != totalAmplitudePerSimHit.end();
iter++){
322 float fraction = (*iter).second/totalAmplitude1;
323 if (fraction >= threshold) {
325 if(fraction > 1.) fraction = 1.;
326 for (std::vector<std::pair<const PSimHit*, int > >::const_iterator
327 simcount = (*cmi).second.begin() ; simcount != (*cmi).second.end(); ++simcount){
328 if((*iter).first == (*simcount).first) sim_counter = (*simcount).second;
331 ((*iter).first)->trackId(),
333 ((*iter).first)->eventId(),
343 const std::vector<float>& afterNoise,
344 unsigned int detID) {
347 for ( DigitalRawVecType::const_iterator
i=digis.begin();
i!=digis.end();
i++) {
351 HitToDigisMapType::const_iterator mi(htd.find(nstrip));
352 HitCounterToDigisMapType::const_iterator cmi(hctd.find(nstrip));
353 if (mi == htd.end())
continue;
354 std::map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
355 for (std::vector < std::pair < const PSimHit*, Amplitude > >::const_iterator simul =
356 (*mi).second.begin() ; simul != (*mi).second.end(); simul ++){
357 totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
361 double totalAmplitude1 = afterNoise[(*mi).first];
364 int sim_counter_raw=0;
365 for (std::map<const PSimHit *, Amplitude>::const_iterator
iter = totalAmplitudePerSimHit.begin();
366 iter != totalAmplitudePerSimHit.end();
iter++){
368 float fraction = (*iter).second/totalAmplitude1;
369 if (fraction >= threshold) {
371 if(fraction >1.) fraction = 1.;
373 for (std::vector<std::pair<const PSimHit*, int > >::const_iterator
374 simcount = (*cmi).second.begin() ; simcount != (*cmi).second.end(); ++simcount){
375 if((*iter).first == (*simcount).first) sim_counter_raw = (*simcount).second;
378 ((*iter).first)->trackId(),
380 ((*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.
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