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")),
61 LogDebug(
"StripDigiInfo")<<
"APVs running in peak mode (poor time resolution)";
63 LogDebug(
"StripDigiInfo")<<
"APVs running in deconvolution mode (good time resolution)";
82 badChannels.insert(badChannels.begin(), numStrips,
false);
109 std::vector<PSimHit>::const_iterator inputEnd,
110 size_t inputBeginGlobalIndex,
115 CLHEP::HepRandomEngine* engine) {
121 size_t thisFirstChannelWithSignal = numStrips;
122 size_t thisLastChannelWithSignal = 0;
126 std::vector<float> locAmpl(numStrips, 0.);
135 std::vector<float> previousLocalAmplitude;
137 size_t simHitGlobalIndex=inputBeginGlobalIndex;
138 for (std::vector<PSimHit>::const_iterator simHitIter = inputBegin; simHitIter != inputEnd; ++simHitIter, ++simHitGlobalIndex ) {
140 if((*simHitIter).detUnitId() != detId) {
146 size_t localFirstChannel = numStrips;
147 size_t localLastChannel = 0;
149 theSiHitDigitizer->processHit(&*simHitIter, *det, bfield, langle, locAmpl, localFirstChannel, localLastChannel, tTopo, engine);
155 int pdg_id = simHitIter->particleType();
159 bool isHadron =
particle->isHadron();
160 if(charge!=0 && isHadron){
162 int FirstAPV = localFirstChannel/128;
163 int LastAPV = localLastChannel/128;
164 std::cout <<
"-------------------HIP--------------" << std::endl;
165 std::cout <<
"Killing APVs " << FirstAPV <<
" - " <<LastAPV <<
" " << detID <<std::endl;
166 for(
int strip = FirstAPV*128; strip < LastAPV*128 +128; ++strip) {
167 badChannels[strip] =
true;
178 if(thisFirstChannelWithSignal > localFirstChannel) thisFirstChannelWithSignal = localFirstChannel;
179 if(thisLastChannelWithSignal < localLastChannel) thisLastChannelWithSignal = localLastChannel;
182 for(
size_t stripIndex=0; stripIndex<locAmpl.size(); ++stripIndex ) {
184 float signalFromThisSimHit=locAmpl[stripIndex]-previousLocalAmplitude[stripIndex];
185 if( signalFromThisSimHit!=0 ) {
186 auto& associationVector=(*pDetIDAssociationInfo)[stripIndex];
187 bool addNewEntry=
true;
190 for(
auto& associationInfo : associationVector ) {
191 if( associationInfo.trackID==simHitIter->trackId() && associationInfo.eventID==simHitIter->eventId() ) {
193 associationInfo.contributionToADC+=signalFromThisSimHit;
199 if( addNewEntry ) associationVector.push_back(
AssociationInfo{ simHitIter->trackId(), simHitIter->eventId(), signalFromThisSimHit, simHitGlobalIndex, tofBin } );
206 theSiPileUpSignals->add(detID, locAmpl, thisFirstChannelWithSignal, thisLastChannelWithSignal);
222 CLHEP::HepRandomEngine* engine) {
228 std::vector<float> detAmpl(numStrips, 0.);
230 for(
const auto& amp : *theSignal) {
231 detAmpl[amp.first] = amp.second;
237 for(
int strip =0; strip < numStrips; ++strip)
if(badChannels[strip]) detAmpl[strip] = 0.;
251 int RefStrip = int(numStrips/2.);
252 while(RefStrip<numStrips&&badChannels[RefStrip]){
255 if(RefStrip<numStrips){
256 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange);
257 float gainValue = gainHandle->getStripGain(RefStrip, detGainRange);
266 for(
const auto& iDigi : digis ) {
267 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
268 const std::vector<AssociationInfo>& associationInfo=associationInfoByChannel[iDigi.channel()];
273 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
275 for(
const auto& iAssociationInfo : associationInfo ) {
278 outLink.
push_back(
StripDigiSimLink( iDigi.channel(), iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
282 outdigi.
data = digis;
312 std::vector<float> noiseRMSv;
314 noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
317 for(
int strip=0; strip< numStrips; ++strip){
318 if(!badChannels[strip]) noiseRMSv[strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC;
323 while(RefStrip<numStrips&&badChannels[RefStrip]){
326 if(RefStrip<numStrips){
327 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC;
328 for(
int strip=0; strip< numStrips; ++strip){
329 if(!badChannels[strip]) noiseRMSv[strip] = noiseRMS;
360 std::vector<float> vPeds;
362 vPeds.insert(vPeds.begin(),numStrips,0.);
365 for(
int strip=0; strip< numStrips; ++strip){
369 for(
int strip=0; strip< numStrips; ++strip){
389 for(
size_t channel=0; channel<rawdigis.size(); ++channel ) {
390 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
391 const auto iAssociationInfo=associationInfoByChannel.find(channel);
392 if( iAssociationInfo==associationInfoByChannel.end() )
continue;
393 const std::vector<AssociationInfo>& associationInfo=iAssociationInfo->second;
398 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
400 for(
const auto& iAssociationInfo : associationInfo ) {
403 outLink.
push_back(
StripDigiSimLink( channel, iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
408 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()