27 #include "CLHEP/Random/RandFlat.h"
30 lorentzAngleName(conf.getParameter<std::
string>(
"LorentzAngle")),
31 theThreshold(conf.getParameter<double>(
"NoiseSigmaThreshold")),
32 cmnRMStib(conf.getParameter<double>(
"cmnRMStib")),
33 cmnRMStob(conf.getParameter<double>(
"cmnRMStob")),
34 cmnRMStid(conf.getParameter<double>(
"cmnRMStid")),
35 cmnRMStec(conf.getParameter<double>(
"cmnRMStec")),
36 APVSaturationProb(conf.getParameter<double>(
"APVSaturationProb")),
37 makeDigiSimLinks_(conf.getUntrackedParameter<bool>(
"makeDigiSimLinks",
false)),
38 peakMode(conf.getParameter<bool>(
"APVpeakmode")),
39 noise(conf.getParameter<bool>(
"Noise")),
40 RealPedestals(conf.getParameter<bool>(
"RealPedestals")),
41 SingleStripNoise(conf.getParameter<bool>(
"SingleStripNoise")),
42 CommonModeNoise(conf.getParameter<bool>(
"CommonModeNoise")),
43 BaselineShift(conf.getParameter<bool>(
"BaselineShift")),
44 APVSaturationFromHIP(conf.getParameter<bool>(
"APVSaturationFromHIP")),
45 theFedAlgo(conf.getParameter<int>(
"FedAlgorithm")),
46 zeroSuppression(conf.getParameter<bool>(
"ZeroSuppression")),
47 theElectronPerADC(conf.getParameter<double>( peakMode ?
"electronPerAdcPeak" :
"electronPerAdcDec" )),
48 theTOFCutForPeak(conf.getParameter<double>(
"TOFCutForPeak")),
49 theTOFCutForDeconvolution(conf.getParameter<double>(
"TOFCutForDeconvolution")),
50 tofCut(peakMode ? theTOFCutForPeak : theTOFCutForDeconvolution),
51 cosmicShift(conf.getUntrackedParameter<double>(
"CosmicDelayShift")),
52 inefficiency(conf.getParameter<double>(
"Inefficiency")),
53 pedOffset((unsigned int)conf.getParameter<double>(
"PedestalsOffset")),
54 PreMixing_(conf.getParameter<bool>(
"PreMixingMode")),
62 LogDebug(
"StripDigiInfo")<<
"APVs running in peak mode (poor time resolution)";
64 LogDebug(
"StripDigiInfo")<<
"APVs running in deconvolution mode (good time resolution)";
83 badChannels.insert(badChannels.begin(), numStrips,
false);
110 std::vector<PSimHit>::const_iterator inputEnd,
111 size_t inputBeginGlobalIndex,
116 CLHEP::HepRandomEngine* engine) {
122 size_t thisFirstChannelWithSignal = numStrips;
123 size_t thisLastChannelWithSignal = 0;
127 std::vector<float> locAmpl(numStrips, 0.);
136 std::vector<float> previousLocalAmplitude;
138 size_t simHitGlobalIndex=inputBeginGlobalIndex;
139 for (std::vector<PSimHit>::const_iterator simHitIter = inputBegin; simHitIter != inputEnd; ++simHitIter, ++simHitGlobalIndex ) {
141 if((*simHitIter).detUnitId() != detId) {
147 size_t localFirstChannel = numStrips;
148 size_t localLastChannel = 0;
150 theSiHitDigitizer->processHit(&*simHitIter, *det, bfield, langle, locAmpl, localFirstChannel, localLastChannel, tTopo, engine);
156 int pdg_id = simHitIter->particleType();
160 bool isHadron =
particle->isHadron();
161 if(charge!=0 && isHadron){
163 int FirstAPV = localFirstChannel/128;
164 int LastAPV = localLastChannel/128;
165 std::cout <<
"-------------------HIP--------------" << std::endl;
166 std::cout <<
"Killing APVs " << FirstAPV <<
" - " <<LastAPV <<
" " << detID <<std::endl;
167 for(
int strip = FirstAPV*128; strip < LastAPV*128 +128; ++strip) {
168 badChannels[strip] =
true;
179 if(thisFirstChannelWithSignal > localFirstChannel) thisFirstChannelWithSignal = localFirstChannel;
180 if(thisLastChannelWithSignal < localLastChannel) thisLastChannelWithSignal = localLastChannel;
183 for(
size_t stripIndex=0; stripIndex<locAmpl.size(); ++stripIndex ) {
185 float signalFromThisSimHit=locAmpl[stripIndex]-previousLocalAmplitude[stripIndex];
186 if( signalFromThisSimHit!=0 ) {
187 auto& associationVector=(*pDetIDAssociationInfo)[stripIndex];
188 bool addNewEntry=
true;
191 for(
auto& associationInfo : associationVector ) {
192 if( associationInfo.trackID==simHitIter->trackId() && associationInfo.eventID==simHitIter->eventId() ) {
194 associationInfo.contributionToADC+=signalFromThisSimHit;
200 if( addNewEntry ) associationVector.push_back(
AssociationInfo{ simHitIter->trackId(), simHitIter->eventId(), signalFromThisSimHit, simHitGlobalIndex, tofBin } );
207 theSiPileUpSignals->add(detID, locAmpl, thisFirstChannelWithSignal, thisLastChannelWithSignal);
223 CLHEP::HepRandomEngine* engine) {
229 std::vector<float> detAmpl(numStrips, 0.);
231 for(
const auto& amp : *theSignal) {
232 detAmpl[amp.first] = amp.second;
238 for(
int strip =0; strip < numStrips; ++strip)
if(badChannels[strip]) detAmpl[strip] = 0.;
252 int RefStrip = int(numStrips/2.);
253 while(RefStrip<numStrips&&badChannels[RefStrip]){
256 if(RefStrip<numStrips){
257 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange);
258 float gainValue = gainHandle->getStripGain(RefStrip, detGainRange);
267 for(
const auto& iDigi : digis ) {
268 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
269 const std::vector<AssociationInfo>& associationInfo=associationInfoByChannel[iDigi.channel()];
274 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
276 for(
const auto& iAssociationInfo : associationInfo ) {
279 outLink.
push_back(
StripDigiSimLink( iDigi.channel(), iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
283 outdigi.
data = digis;
313 std::vector<float> noiseRMSv;
315 noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
318 for(
int strip=0; strip< numStrips; ++strip){
319 if(!badChannels[strip]) noiseRMSv[strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC;
324 while(RefStrip<numStrips&&badChannels[RefStrip]){
327 if(RefStrip<numStrips){
328 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC;
329 for(
int strip=0; strip< numStrips; ++strip){
330 if(!badChannels[strip]) noiseRMSv[strip] = noiseRMS;
361 std::vector<float> vPeds;
363 vPeds.insert(vPeds.begin(),numStrips,0.);
366 for(
int strip=0; strip< numStrips; ++strip){
370 for(
int strip=0; strip< numStrips; ++strip){
390 for(
size_t channel=0; channel<rawdigis.size(); ++channel ) {
391 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
392 const auto iAssociationInfo=associationInfoByChannel.find(channel);
393 if( iAssociationInfo==associationInfoByChannel.end() )
continue;
394 const std::vector<AssociationInfo>& associationInfo=iAssociationInfo->second;
399 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
401 for(
const auto& iAssociationInfo : associationInfo ) {
404 outLink.
push_back(
StripDigiSimLink( channel, iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
409 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()