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")),
59 theFlatDistribution(new CLHEP::RandFlat(eng, 0., 1.)) {
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,
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);
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);
226 std::vector<float> detAmpl(numStrips, 0.);
228 for(
const auto& amp : *theSignal) {
229 detAmpl[amp.first] = amp.second;
235 for(
int strip =0; strip < numStrips; ++strip)
if(badChannels[strip]) detAmpl[strip] = 0.;
249 int RefStrip = int(numStrips/2.);
250 while(RefStrip<numStrips&&badChannels[RefStrip]){
253 if(RefStrip<numStrips){
254 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange);
255 float gainValue = gainHandle->getStripGain(RefStrip, detGainRange);
264 for(
const auto& iDigi : digis ) {
265 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
266 const std::vector<AssociationInfo>& associationInfo=associationInfoByChannel[iDigi.channel()];
271 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
273 for(
const auto& iAssociationInfo : associationInfo ) {
276 outLink.
push_back(
StripDigiSimLink( iDigi.channel(), iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex+1, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
280 outdigi.
data = digis;
310 std::vector<float> noiseRMSv;
312 noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
315 for(
int strip=0; strip< numStrips; ++strip){
316 if(!badChannels[strip]) noiseRMSv[strip] = (noiseHandle->getNoise(strip,detNoiseRange))*
theElectronPerADC;
321 while(RefStrip<numStrips&&badChannels[RefStrip]){
324 if(RefStrip<numStrips){
325 float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *
theElectronPerADC;
326 for(
int strip=0; strip< numStrips; ++strip){
327 if(!badChannels[strip]) noiseRMSv[strip] = noiseRMS;
358 std::vector<float> vPeds;
360 vPeds.insert(vPeds.begin(),numStrips,0.);
363 for(
int strip=0; strip< numStrips; ++strip){
367 for(
int strip=0; strip< numStrips; ++strip){
387 for(
size_t channel=0; channel<rawdigis.size(); ++channel ) {
388 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
389 const auto iAssociationInfo=associationInfoByChannel.find(channel);
390 if( iAssociationInfo==associationInfoByChannel.end() )
continue;
391 const std::vector<AssociationInfo>& associationInfo=iAssociationInfo->second;
396 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
398 for(
const auto& iAssociationInfo : associationInfo ) {
401 outLink.
push_back(
StripDigiSimLink( channel, iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex+1, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
406 outrawdigi.
data = rawdigis;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const std::unique_ptr< CLHEP::RandFlat > theFlatDistribution
const std::unique_ptr< SiPileUpSignals > theSiPileUpSignals
edm::ESHandle< SiStripLorentzAngle > lorentzAngleHandle
void push_back(const T &t)
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 > &)
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
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)
const std::unique_ptr< SiTrivialDigitalConverter > theSiDigitalConverter
const bool zeroSuppression
SiStripDigitizerAlgorithm(const edm::ParameterSet &conf, CLHEP::HepRandomEngine &)
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
std::pair< ContainerIterator, ContainerIterator > Range
std::map< unsigned int, size_t > lastChannelsWithSignal
std::pair< ContainerIterator, ContainerIterator > Range
const bool SingleStripNoise
void initializeDetUnit(StripGeomDetUnit *det, const edm::EventSetup &iSetup)
const ParticleData * particle
const bool APVSaturationFromHIP
const ParticleDataTable * pdt
const bool CommonModeNoise
~SiStripDigitizerAlgorithm()