31 #include "CLHEP/Random/RandFlat.h"
34 lorentzAngleName(conf.getParameter<std::
string>(
"LorentzAngle")),
35 theThreshold(conf.getParameter<double>(
"NoiseSigmaThreshold")),
36 cmnRMStib(conf.getParameter<double>(
"cmnRMStib")),
37 cmnRMStob(conf.getParameter<double>(
"cmnRMStob")),
38 cmnRMStid(conf.getParameter<double>(
"cmnRMStid")),
39 cmnRMStec(conf.getParameter<double>(
"cmnRMStec")),
40 APVSaturationProb(conf.getParameter<double>(
"APVSaturationProb")),
41 makeDigiSimLinks_(conf.getUntrackedParameter<bool>(
"makeDigiSimLinks",
false)),
42 peakMode(conf.getParameter<bool>(
"APVpeakmode")),
43 noise(conf.getParameter<bool>(
"Noise")),
44 RealPedestals(conf.getParameter<bool>(
"RealPedestals")),
45 SingleStripNoise(conf.getParameter<bool>(
"SingleStripNoise")),
46 CommonModeNoise(conf.getParameter<bool>(
"CommonModeNoise")),
47 BaselineShift(conf.getParameter<bool>(
"BaselineShift")),
48 APVSaturationFromHIP(conf.getParameter<bool>(
"APVSaturationFromHIP")),
49 theFedAlgo(conf.getParameter<int>(
"FedAlgorithm")),
50 zeroSuppression(conf.getParameter<bool>(
"ZeroSuppression")),
51 theElectronPerADC(conf.getParameter<double>( peakMode ?
"electronPerAdcPeak" :
"electronPerAdcDec" )),
52 theTOFCutForPeak(conf.getParameter<double>(
"TOFCutForPeak")),
53 theTOFCutForDeconvolution(conf.getParameter<double>(
"TOFCutForDeconvolution")),
54 tofCut(peakMode ? theTOFCutForPeak : theTOFCutForDeconvolution),
55 cosmicShift(conf.getUntrackedParameter<double>(
"CosmicDelayShift")),
56 inefficiency(conf.getParameter<double>(
"Inefficiency")),
57 pedOffset((unsigned int)conf.getParameter<double>(
"PedestalsOffset")),
58 PreMixing_(conf.getParameter<bool>(
"PreMixingMode")),
66 LogDebug(
"StripDigiInfo")<<
"APVs running in peak mode (poor time resolution)";
68 LogDebug(
"StripDigiInfo")<<
"APVs running in deconvolution mode (good time resolution)";
71 else LogDebug(
"SiStripDigitizerAlgorithm")<<
" SingleStripNoise: OFF";
73 else LogDebug(
"SiStripDigitizerAlgorithm")<<
" CommonModeNoise: OFF";
91 badChannels.insert(badChannels.begin(), numStrips,
false);
118 std::vector<PSimHit>::const_iterator inputEnd,
119 size_t inputBeginGlobalIndex,
124 CLHEP::HepRandomEngine* engine) {
130 size_t thisFirstChannelWithSignal = numStrips;
131 size_t thisLastChannelWithSignal = 0;
135 std::vector<float> locAmpl(numStrips, 0.);
144 std::vector<float> previousLocalAmplitude;
146 size_t simHitGlobalIndex=inputBeginGlobalIndex;
147 for (std::vector<PSimHit>::const_iterator simHitIter = inputBegin; simHitIter != inputEnd; ++simHitIter, ++simHitGlobalIndex ) {
149 if((*simHitIter).detUnitId() != detId) {
155 size_t localFirstChannel = numStrips;
156 size_t localLastChannel = 0;
158 theSiHitDigitizer->processHit(&*simHitIter, *det, bfield, langle, locAmpl, localFirstChannel, localLastChannel, tTopo, engine);
164 int pdg_id = simHitIter->particleType();
168 bool isHadron =
particle->isHadron();
169 if(charge!=0 && isHadron){
171 int FirstAPV = localFirstChannel/128;
172 int LastAPV = localLastChannel/128;
175 for(
int strip = FirstAPV*128; strip < LastAPV*128 +128; ++strip) {
176 badChannels[strip] =
true;
187 if(thisFirstChannelWithSignal > localFirstChannel) thisFirstChannelWithSignal = localFirstChannel;
188 if(thisLastChannelWithSignal < localLastChannel) thisLastChannelWithSignal = localLastChannel;
191 for(
size_t stripIndex=0; stripIndex<locAmpl.size(); ++stripIndex ) {
193 float signalFromThisSimHit=locAmpl[stripIndex]-previousLocalAmplitude[stripIndex];
194 if( signalFromThisSimHit!=0 ) {
195 auto& associationVector=(*pDetIDAssociationInfo)[stripIndex];
196 bool addNewEntry=
true;
199 for(
auto& associationInfo : associationVector ) {
200 if( associationInfo.trackID==simHitIter->trackId() && associationInfo.eventID==simHitIter->eventId() ) {
202 associationInfo.contributionToADC+=signalFromThisSimHit;
208 if( addNewEntry ) associationVector.push_back(
AssociationInfo{ simHitIter->trackId(), simHitIter->eventId(), signalFromThisSimHit, simHitGlobalIndex, tofBin } );
215 theSiPileUpSignals->add(detID, locAmpl, thisFirstChannelWithSignal, thisLastChannelWithSignal);
231 CLHEP::HepRandomEngine* engine) {
237 std::vector<float> detAmpl(numStrips, 0.);
239 for(
const auto& amp : *theSignal) {
240 detAmpl[amp.first] = amp.second;
246 for(
int strip =0; strip < numStrips; ++strip)
if(badChannels[strip]) detAmpl[strip] = 0.;
265 std::vector<float> noiseRMSv;
267 noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
268 for(
int strip=0; strip< numStrips; ++strip){
269 if(!badChannels[strip]){
270 float gainValue = gainHandle->getStripGain(strip, detGainRange);
271 noiseRMSv[strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC/gainValue;
277 int RefStrip = int(numStrips/2.);
278 while(RefStrip<numStrips&&badChannels[RefStrip]){
281 if(RefStrip<numStrips){
282 float RefgainValue = gainHandle->getStripGain(RefStrip, detGainRange);
283 float RefnoiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC/RefgainValue;
285 theSiNoiseAdder->addNoise(detAmpl,firstChannelWithSignal,lastChannelWithSignal,numStrips,RefnoiseRMS, engine);
296 for(
const auto& iDigi : digis ) {
297 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
298 const std::vector<AssociationInfo>& associationInfo=associationInfoByChannel[iDigi.channel()];
303 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
305 for(
const auto& iAssociationInfo : associationInfo ) {
308 outLink.
push_back(
StripDigiSimLink( iDigi.channel(), iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
312 outdigi.
data = digis;
341 std::vector<float> noiseRMSv;
343 noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
346 for(
int strip=0; strip< numStrips; ++strip){
347 if(!badChannels[strip]) noiseRMSv[strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC;
352 while(RefStrip<numStrips&&badChannels[RefStrip]){
355 if(RefStrip<numStrips){
356 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC;
357 for(
int strip=0; strip< numStrips; ++strip){
358 if(!badChannels[strip]) noiseRMSv[strip] = noiseRMS;
389 std::vector<float> vPeds;
391 vPeds.insert(vPeds.begin(),numStrips,0.);
394 for(
int strip=0; strip< numStrips; ++strip){
398 for(
int strip=0; strip< numStrips; ++strip){
418 for(
size_t channel=0; channel<rawdigis.size(); ++channel ) {
419 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
420 const auto iAssociationInfo=associationInfoByChannel.find(channel);
421 if( iAssociationInfo==associationInfoByChannel.end() )
continue;
422 const std::vector<AssociationInfo>& associationInfo=iAssociationInfo->second;
427 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
429 for(
const auto& iAssociationInfo : associationInfo ) {
432 outLink.
push_back(
StripDigiSimLink( channel, iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
437 outrawdigi.
data = rawdigis;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const std::unique_ptr< SiPileUpSignals > theSiPileUpSignals
edm::ESHandle< SiStripLorentzAngle > lorentzAngleHandle
void push_back(const T &t)
AssociationInfoForDetId associationInfoForDetId_
Structure that holds the information on the SimTrack contributions. Only filled if makeDigiSimLinks_ ...
SiDigitalConverter::DigitalRawVecType DigitalRawVecType
SiDigitalConverter::DigitalVecType DigitalVecType
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
std::vector< unsigned int >::const_iterator ContainerIterator
void initializeEvent(const edm::EventSetup &iSetup)
const double theElectronPerADC
const bool makeDigiSimLinks_
std::pair< ContainerIterator, ContainerIterator > Range
void initializeDetUnit(StripGeomDetUnit const *det, const edm::EventSetup &iSetup)
void digitize(edm::DetSet< SiStripDigi > &outDigis, edm::DetSet< SiStripRawDigi > &outRawDigis, edm::DetSet< StripDigiSimLink > &outLink, const StripGeomDetUnit *stripdet, edm::ESHandle< SiStripGain > &, edm::ESHandle< SiStripThreshold > &, edm::ESHandle< SiStripNoises > &, edm::ESHandle< SiStripPedestals > &, CLHEP::HepRandomEngine *)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
const std::unique_ptr< const SiGaussianTailNoiseAdder > theSiNoiseAdder
const std::unique_ptr< SiHitDigitizer > theSiHitDigitizer
void getData(T &iHolder) const
std::map< unsigned int, size_t > firstChannelsWithSignal
std::map< int, Amplitude > SignalMapType
uint32_t rawId() const
get the raw id
const std::unique_ptr< SiTrivialDigitalConverter > theSiDigitalConverter
const bool zeroSuppression
const std::unique_ptr< SiStripFedZeroSuppression > theSiZeroSuppress
std::pair< ContainerIterator, ContainerIterator > Range
DetId geographicalId() const
The label of this GeomDet.
const std::string lorentzAngleName
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::map< unsigned int, std::vector< bool > > allBadChannels
const double APVSaturationProb
void setParticleDataTable(const ParticleDataTable *pardt)
unsigned short firstStrip
std::map< int, std::vector< AssociationInfo > > AssociationInfoForChannel
const double inefficiency
SiStripDigitizerAlgorithm(const edm::ParameterSet &conf)
std::pair< ContainerIterator, ContainerIterator > Range
std::map< unsigned int, size_t > lastChannelsWithSignal
void accumulateSimHits(const std::vector< PSimHit >::const_iterator inputBegin, const std::vector< PSimHit >::const_iterator inputEnd, size_t inputBeginGlobalIndex, unsigned int tofBin, const StripGeomDetUnit *stripdet, const GlobalVector &bfield, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
volatile std::atomic< bool > shutdown_flag false
std::pair< ContainerIterator, ContainerIterator > Range
const bool SingleStripNoise
const ParticleData * particle
const bool APVSaturationFromHIP
const ParticleDataTable * pdt
const bool CommonModeNoise
~SiStripDigitizerAlgorithm()