31 #include "CLHEP/Random/RandFlat.h" 36 #include <boost/algorithm/string.hpp> 39 lorentzAngleName(conf.getParameter<
std::
string>(
"LorentzAngle")),
40 theThreshold(conf.getParameter<double>(
"NoiseSigmaThreshold")),
41 cmnRMStib(conf.getParameter<double>(
"cmnRMStib")),
42 cmnRMStob(conf.getParameter<double>(
"cmnRMStob")),
43 cmnRMStid(conf.getParameter<double>(
"cmnRMStid")),
44 cmnRMStec(conf.getParameter<double>(
"cmnRMStec")),
45 APVSaturationProbScaling_(conf.getParameter<double>(
"APVSaturationProbScaling")),
46 makeDigiSimLinks_(conf.getUntrackedParameter<bool>(
"makeDigiSimLinks",
false)),
47 peakMode(conf.getParameter<bool>(
"APVpeakmode")),
48 noise(conf.getParameter<bool>(
"Noise")),
54 theFedAlgo(conf.getParameter<
int>(
"FedAlgorithm")),
55 zeroSuppression(conf.getParameter<bool>(
"ZeroSuppression")),
56 theElectronPerADC(conf.getParameter<double>( peakMode ?
"electronPerAdcPeak" :
"electronPerAdcDec" )),
57 theTOFCutForPeak(conf.getParameter<double>(
"TOFCutForPeak")),
58 theTOFCutForDeconvolution(conf.getParameter<double>(
"TOFCutForDeconvolution")),
59 tofCut(peakMode ? theTOFCutForPeak : theTOFCutForDeconvolution),
60 cosmicShift(conf.getUntrackedParameter<double>(
"CosmicDelayShift")),
61 inefficiency(conf.getParameter<double>(
"Inefficiency")),
62 pedOffset((unsigned
int)conf.getParameter<double>(
"PedestalsOffset")),
63 PreMixing_(conf.getParameter<bool>(
"PreMixingMode")),
72 LogDebug(
"StripDigiInfo")<<
"APVs running in peak mode (poor time resolution)";
74 LogDebug(
"StripDigiInfo")<<
"APVs running in deconvolution mode (good time resolution)";
77 else LogDebug(
"SiStripDigitizerAlgorithm")<<
" SingleStripNoise: OFF";
79 else LogDebug(
"SiStripDigitizerAlgorithm")<<
" CommonModeNoise: OFF";
86 std::vector<std::string> strs;
94 <<
"It seems that the APV probability list is missing\n";
113 badChannels.insert(badChannels.begin(), numStrips,
false);
117 badChannels[
strip] =
true;
152 std::vector<PSimHit>::const_iterator inputEnd,
153 size_t inputBeginGlobalIndex,
158 CLHEP::HepRandomEngine* engine) {
163 size_t thisFirstChannelWithSignal = numStrips;
164 size_t thisLastChannelWithSignal = 0;
168 std::vector<float> locAmpl(numStrips, 0.);
177 std::vector<float> previousLocalAmplitude;
179 size_t simHitGlobalIndex=inputBeginGlobalIndex;
180 for (std::vector<PSimHit>::const_iterator simHitIter = inputBegin; simHitIter != inputEnd; ++simHitIter, ++simHitGlobalIndex ) {
182 if((*simHitIter).detUnitId() != detId) {
188 size_t localFirstChannel = numStrips;
189 size_t localLastChannel = 0;
191 theSiHitDigitizer->processHit(&*simHitIter, *det, bfield, langle, locAmpl, localFirstChannel, localLastChannel, tTopo, engine);
193 if(thisFirstChannelWithSignal > localFirstChannel) thisFirstChannelWithSignal = localFirstChannel;
194 if(thisLastChannelWithSignal < localLastChannel) thisLastChannelWithSignal = localLastChannel;
197 for(
size_t stripIndex=0; stripIndex<locAmpl.size(); ++stripIndex ) {
199 float signalFromThisSimHit=locAmpl[stripIndex]-previousLocalAmplitude[stripIndex];
200 if( signalFromThisSimHit!=0 ) {
201 auto& associationVector=(*pDetIDAssociationInfo)[stripIndex];
202 bool addNewEntry=
true;
205 for(
auto& associationInfo : associationVector ) {
206 if( associationInfo.trackID==simHitIter->trackId() && associationInfo.eventID==simHitIter->eventId() ) {
208 associationInfo.contributionToADC+=signalFromThisSimHit;
214 if( addNewEntry ) associationVector.push_back(
AssociationInfo{ simHitIter->trackId(), simHitIter->eventId(), signalFromThisSimHit, simHitGlobalIndex, tofBin } );
221 theSiPileUpSignals->add(detID, locAmpl, thisFirstChannelWithSignal, thisLastChannelWithSignal);
237 double RevFreq = 11245.;
238 double minBXsec = 70.0E-27;
239 double Bunch = 2100.;
240 if (bunchSpacing == 50) Bunch = Bunch/2.;
243 std::vector<int>::const_iterator
pu;
244 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
246 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++
pu) {
253 if (pu0!=bunchCrossing.end()) {
254 double Tintr = TrueInteractionList.at(
p);
255 double instLumi = Bunch*Tintr*RevFreq/minBXsec;
275 std::vector<std::pair<
int,std::bitset<6>>> & theAffectedAPVvector,
276 CLHEP::HepRandomEngine* engine) {
282 std::vector<float> detAmpl(numStrips, 0.);
284 for(
const auto& amp : *theSignal) {
285 detAmpl[amp.first] = amp.second;
306 for(
int Napv=0;Napv<6;Napv++){
307 float cursor=CLHEP::RandFlat::shoot(engine);
314 bool HasAtleastOneAffectedAPV=
false;
315 while(!HasAtleastOneAffectedAPV){
316 for(
int bx=floor(300.0/25.0);bx>0;bx--){
317 float temp=CLHEP::RandFlat::shoot(engine)<0.5?1:0;
320 HasAtleastOneAffectedAPV=
true;
332 theAffectedAPVvector.push_back(std::make_pair(detID,bs));
339 float randomX=CLHEP::RandFlat::shoot(engine);
340 float scalingValue=(randomX-Shift)*10.0/7.0-3.0/7.0;
344 detAmpl[
strip] *=scalingValue>0?scalingValue:0.0;
370 std::vector<float> noiseRMSv;
372 noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
374 if(!badChannels[
strip]){
375 float gainValue = gainHandle->
getStripGain(strip, detGainRange);
382 int RefStrip =
int(numStrips/2.);
383 while(RefStrip<numStrips&&badChannels[RefStrip]){
386 if(RefStrip<numStrips){
387 float RefgainValue = gainHandle->
getStripGain(RefStrip, detGainRange);
390 theSiNoiseAdder->addNoise(detAmpl,firstChannelWithSignal,lastChannelWithSignal,numStrips,RefnoiseRMS, engine);
401 for(
const auto& iDigi : digis ) {
402 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
403 const std::vector<AssociationInfo>& associationInfo=associationInfoByChannel[iDigi.channel()];
408 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
410 for(
const auto& iAssociationInfo : associationInfo ) {
413 outLink.
push_back(
StripDigiSimLink( iDigi.channel(), iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
417 outdigi.
data = digis;
446 std::vector<float> noiseRMSv;
448 noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
457 while(RefStrip<numStrips&&badChannels[RefStrip]){
460 if(RefStrip<numStrips){
463 if(!badChannels[
strip]) noiseRMSv[
strip] = noiseRMS;
494 std::vector<float> vPeds;
496 vPeds.insert(vPeds.begin(),numStrips,0.);
523 for(
size_t channel=0; channel<rawdigis.size(); ++channel ) {
524 auto& associationInfoByChannel=iAssociationInfoByChannel->second;
525 const auto iAssociationInfo=associationInfoByChannel.find(channel);
526 if( iAssociationInfo==associationInfoByChannel.end() )
continue;
527 const std::vector<AssociationInfo>& associationInfo=iAssociationInfo->second;
532 for(
const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
534 for(
const auto& iAssociationInfo : associationInfo ) {
537 outLink.
push_back(
StripDigiSimLink( channel, iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
542 outrawdigi.
data = rawdigis;
std::map< int, float > mapOfAPVprobabilities
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const std::unique_ptr< SiPileUpSignals > theSiPileUpSignals
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 > &, std::vector< std::pair< int, std::bitset< 6 >>> &theAffectedAPVvector, CLHEP::HepRandomEngine *)
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_ ...
const std::vector< float > & getMix_TrueInteractions() const
std::map< int, std::bitset< 6 > > SiStripTrackerAffectedAPVMap
SiDigitalConverter::DigitalRawVecType DigitalRawVecType
SiDigitalConverter::DigitalVecType DigitalVecType
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const std::vector< int > & getMix_bunchCrossing() const
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)
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
float getPed(const uint16_t &strip, const Range &range) const
std::map< int, Amplitude > SignalMapType
uint32_t rawId() const
get the raw id
static float getNoise(uint16_t strip, const Range &range)
float getLorentzAngle(const uint32_t &) const
const std::unique_ptr< SiTrivialDigitalConverter > theSiDigitalConverter
const bool zeroSuppression
const std::unique_ptr< SiStripFedZeroSuppression > theSiZeroSuppress
static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range)
edm::FileInPath APVProbabilityFile
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) ...
void calculateInstlumiScale(PileupMixingContent *puInfo)
std::map< unsigned int, std::vector< bool > > allBadChannels
void setParticleDataTable(const ParticleDataTable *pardt)
const double APVSaturationProbScaling_
unsigned short firstStrip
std::map< int, std::vector< AssociationInfo > > AssociationInfoForChannel
const double inefficiency
RealPedestals
NOTE : turning Noise ON/OFF will make a big change Parameters valid only if Noise = True and ZeroSupp...
SiStripDigitizerAlgorithm(const edm::ParameterSet &conf)
const Range getRange(const uint32_t detID) const
const Range getRange(const uint32_t detID) const
std::pair< ContainerIterator, ContainerIterator > Range
std::map< unsigned int, size_t > lastChannelsWithSignal
std::ifstream APVProbaFile
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 *)
const int & getMix_bunchSpacing() const
std::string fullPath() const
int NumberOfBxBetweenHIPandEvent
const Range getRange(const uint32_t &detID) const
std::pair< ContainerIterator, ContainerIterator > Range
const bool SingleStripNoise
const bool APVSaturationFromHIP
const ParticleDataTable * pdt
data decode(const unsigned int &value) const
const bool CommonModeNoise
~SiStripDigitizerAlgorithm()
const SiStripApvGain::Range getRange(uint32_t detID) const
double APVSaturationProb_