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,
114 CLHEP::HepRandomEngine* engine) {
120 size_t thisFirstChannelWithSignal = numStrips;
121 size_t thisLastChannelWithSignal = numStrips;
125 std::vector<float> locAmpl(numStrips, 0.);
134 std::vector<float> previousLocalAmplitude;
136 size_t simHitGlobalIndex=inputBeginGlobalIndex;
137 for (std::vector<PSimHit>::const_iterator simHitIter = inputBegin; simHitIter != inputEnd; ++simHitIter, ++simHitGlobalIndex ) {
139 if((*simHitIter).detUnitId() != detId) {
145 size_t localFirstChannel = numStrips;
146 size_t localLastChannel = 0;
148 theSiHitDigitizer->processHit(&*simHitIter, *det, bfield, langle, locAmpl, localFirstChannel, localLastChannel, tTopo, engine);
154 int pdg_id = simHitIter->particleType();
158 bool isHadron =
particle->isHadron();
159 if(charge!=0 && isHadron){
161 int FirstAPV = localFirstChannel/128;
162 int LastAPV = localLastChannel/128;
163 std::cout <<
"-------------------HIP--------------" << std::endl;
164 std::cout <<
"Killing APVs " << FirstAPV <<
" - " <<LastAPV <<
" " << detID <<std::endl;
165 for(
int strip = FirstAPV*128; strip < LastAPV*128 +128; ++strip) {
166 badChannels[strip] =
true;
177 if(thisFirstChannelWithSignal > localFirstChannel) thisFirstChannelWithSignal = localFirstChannel;
178 if(thisLastChannelWithSignal < localLastChannel) thisLastChannelWithSignal = localLastChannel;
181 for(
size_t stripIndex=0; stripIndex<locAmpl.size(); ++stripIndex ) {
183 float signalFromThisSimHit=locAmpl[stripIndex]-previousLocalAmplitude[stripIndex];
184 if( signalFromThisSimHit!=0 ) {
185 auto& associationVector=(*pDetIDAssociationInfo)[stripIndex];
186 bool addNewEntry=
true;
189 for(
auto& associationInfo : associationVector ) {
190 if( associationInfo.trackID==simHitIter->trackId() && associationInfo.eventID==simHitIter->eventId() ) {
192 associationInfo.contributionToADC+=signalFromThisSimHit;
198 if( addNewEntry ) associationVector.push_back(
AssociationInfo{ simHitIter->trackId(), simHitIter->eventId(), signalFromThisSimHit, simHitGlobalIndex } );
205 theSiPileUpSignals->add(detID, locAmpl, thisFirstChannelWithSignal, thisLastChannelWithSignal);
221 CLHEP::HepRandomEngine* engine) {
227 std::vector<float> detAmpl(numStrips, 0.);
229 for(
const auto& amp : *theSignal) {
230 detAmpl[amp.first] = amp.second;
236 for(
int strip =0; strip < numStrips; ++strip)
if(badChannels[strip]) detAmpl[strip] = 0.;
250 int RefStrip = int(numStrips/2.);
251 while(RefStrip<numStrips&&badChannels[RefStrip]){
254 if(RefStrip<numStrips){
255 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange);
256 float gainValue = gainHandle->getStripGain(RefStrip, detGainRange);
265 for(
const auto& iDigi : digis ) {
266 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
267 const std::vector<AssociationInfo>& associationInfo=associationInfoByChannel[iDigi.channel()];
272 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
274 for(
const auto& iAssociationInfo : associationInfo ) {
277 outLink.
push_back(
StripDigiSimLink( iDigi.channel(), iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex+1, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
281 outdigi.
data = digis;
311 std::vector<float> noiseRMSv;
313 noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
316 for(
int strip=0; strip< numStrips; ++strip){
317 if(!badChannels[strip]) noiseRMSv[strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC;
322 while(RefStrip<numStrips&&badChannels[RefStrip]){
325 if(RefStrip<numStrips){
326 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC;
327 for(
int strip=0; strip< numStrips; ++strip){
328 if(!badChannels[strip]) noiseRMSv[strip] = noiseRMS;
359 std::vector<float> vPeds;
361 vPeds.insert(vPeds.begin(),numStrips,0.);
364 for(
int strip=0; strip< numStrips; ++strip){
368 for(
int strip=0; strip< numStrips; ++strip){
388 for(
size_t channel=0; channel<rawdigis.size(); ++channel ) {
389 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
390 const auto iAssociationInfo=associationInfoByChannel.find(channel);
391 if( iAssociationInfo==associationInfoByChannel.end() )
continue;
392 const std::vector<AssociationInfo>& associationInfo=iAssociationInfo->second;
397 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
399 for(
const auto& iAssociationInfo : associationInfo ) {
402 outLink.
push_back(
StripDigiSimLink( channel, iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex+1, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
407 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
void accumulateSimHits(const std::vector< PSimHit >::const_iterator inputBegin, const std::vector< PSimHit >::const_iterator inputEnd, size_t inputBeginGlobalIndex, const StripGeomDetUnit *stripdet, const GlobalVector &bfield, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
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
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()