34 #include "CLHEP/Random/RandFlat.h" 69 typedef std::pair<uint16_t, Amplitude>
RawDigi;
84 const SignalMapType*
getSignal(uint32_t detID)
const {
89 return &where->second;
95 typedef std::multimap< uint32_t, std::bitset<6> >
APVMap;
133 bool operator() (RawDigi
i,RawDigi j)
const {
return i.first < j.first;}
142 theThreshold(ps.getParameter<double>(
"NoiseSigmaThreshold")),
173 <<
"SiStripDigitizer requires the RandomNumberGeneratorService\n" 174 "which is not present in the psiguration file. You must add the service\n" 175 "in the configuration file or remove the modules that require it.";
187 unsigned int detId = (*iu)->geographicalId().rawId();
196 assert(stripdet !=
nullptr);
216 badChannels.insert(badChannels.begin(), numStrips,
false);
218 hipChannels.insert(hipChannels.begin(), numStrips,
false);
239 for (; DSViter!=input->end();DSViter++){
242 LogDebug(
"PreMixingSiStripWorker") <<
"Processing DetID " << DSViter->id;
246 LocalMap.
reserve((DSViter->data).size());
247 LocalMap.insert(LocalMap.end(),(DSViter->data).
begin(),(DSViter->data).
end());
280 const auto&
input = *inputHandle;
286 for (; DSViter!=
input.end();DSViter++){
289 LogDebug(
"PreMixingSiStripWorker") <<
"Pileups: Processing DetID " << DSViter->id;
294 SiGlobalIndex::const_iterator itest;
300 LocalMap = itest->second;
303 LocalMap.insert(LocalMap.end(),(DSViter->data).
begin(),(DSViter->data).
end());
311 LocalMap.reserve((DSViter->data).size());
312 LocalMap.insert(LocalMap.end(),(DSViter->data).
begin(),(DSViter->data).
end());
324 const auto &APVinput = inputAPVHandle;
326 std::vector<std::pair<int,std::bitset<6>> >::const_iterator
entry = APVinput->begin();
327 for( ; entry != APVinput->end(); entry++) {
353 std::map< int,std::bitset<6>> DeadAPVList;
377 for(SiGlobalIndex::const_iterator IDet =
SiHitStorage_.begin();
380 uint32_t detID = IDet->first;
388 OneDetectorMap::const_iterator iLocal = LocalMap.begin();
389 for(;iLocal != LocalMap.end(); ++iLocal) {
391 uint16_t currentStrip = iLocal->strip();
392 float signal =
float(iLocal->adc());
393 if(iLocal->adc() == 1022) signal = 1500.;
394 if(iLocal->adc() == 1023) signal = 3000.;
398 float ReSignal = signal*signal/9.0;
400 RawDigi NewRawDigi = std::make_pair(currentStrip,ReSignal);
402 LocalRawMap.push_back(NewRawDigi);
412 int NumberOfBxBetweenHIPandEvent=1
e3;
418 bool HasAtleastOneAffectedAPV=
false;
419 while(!HasAtleastOneAffectedAPV){
420 for(
int bx=floor(300.0/25.0);bx>0;bx--){
421 float temp=CLHEP::RandFlat::shoot(engine)<0.5?1:0;
422 if(temp==1 && bx<NumberOfBxBetweenHIPandEvent){
423 NumberOfBxBetweenHIPandEvent=bx;
424 HasAtleastOneAffectedAPV=
true;
429 APVMap::const_iterator iAPVchk;
430 uint32_t formerID = 0;
432 std::bitset<6> NewAPVBits;
437 currentID = iAPV->first;
439 if (currentID == formerID) {
440 for(
int ibit=0; ibit<6; ++ibit){
441 NewAPVBits[ibit] = NewAPVBits[ibit]||(iAPV->second)[ibit];
445 DeadAPVList[currentID]=NewAPVBits;
447 formerID = currentID;
448 NewAPVBits = iAPV->second;
453 DeadAPVList[currentID]=NewAPVBits;
463 std::vector< edm::DetSet<SiStripDigi> > vSiStripDigi;
472 for(SiGlobalRawIndex::const_iterator IDet =
SiRawDigis_.begin();
475 uint32_t detID = IDet->first;
483 int formerStrip = -1;
489 OneDetectorRawMap::const_iterator iLocalchk;
490 OneDetectorRawMap::const_iterator iLocal = LocalMap.begin();
491 for(;iLocal != LocalMap.end(); ++iLocal) {
493 currentStrip = iLocal->first;
495 if (currentStrip == formerStrip) {
497 ADCSum+=iLocal->second ;
501 Signals.insert( std::make_pair(formerStrip, ADCSum));
504 formerStrip = currentStrip;
505 ADCSum = iLocal->second;
509 if((++iLocalchk) == LocalMap.end()) {
510 Signals.insert( std::make_pair(formerStrip, ADCSum));
514 signals_.insert( std::make_pair( detID, Signals));
535 std::vector<float> detAmpl(numStrips, 0.);
537 for(
const auto& amp : *theSignal) {
538 detAmpl[amp.first] = amp.second;
550 std::bitset<6> & bs=DeadAPVList[detID];
555 float Shift=1-NumberOfBxBetweenHIPandEvent/floor(300.0/25.0);
556 float randomX=CLHEP::RandFlat::shoot(engine);
557 float scalingValue=(randomX-Shift)*10.0/7.0-3.0/7.0;
561 detAmpl[
strip] *=scalingValue>0?scalingValue:0.0;
590 size_t firstChannelWithSignal = 0;
591 size_t lastChannelWithSignal = numStrips;
594 std::vector<float> noiseRMSv;
596 noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
598 if(!badChannels[
strip]){
599 float gainValue = gainHandle->
getStripGain(strip, detGainRange);
605 int RefStrip =
int(numStrips/2.);
606 while(RefStrip<numStrips&&badChannels[RefStrip]){
609 if(RefStrip<numStrips){
610 float RefgainValue = gainHandle->
getStripGain(RefStrip, detGainRange);
613 theSiNoiseAdder->addNoise(detAmpl,firstChannelWithSignal,lastChannelWithSignal,numStrips,RefnoiseRMS, engine);
624 vSiStripDigi.push_back(SSD);
631 edm::LogInfo(
"PreMixingSiStripWorker") <<
"total # Merged strips: " << vSiStripDigi.size() ;
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
int bunchCrossing() const
std::map< unsigned int, std::vector< bool > > allBadChannels
T getParameter(std::string const &) const
void addSignals(edm::Event const &e, edm::EventSetup const &es) override
std::vector< SiStripDigi > DigitalVecType
std::map< unsigned int, std::vector< bool > > allHIPChannels
PreMixingSiStripWorker(const edm::ParameterSet &ps, edm::ProducerBase &producer, edm::ConsumesCollector &&iC)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::unique_ptr< SiTrivialDigitalConverter > theSiDigitalConverter
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
std::map< unsigned int, size_t > lastChannelsWithSignal
std::map< uint32_t, OneDetectorRawMap > SiGlobalRawIndex
std::vector< unsigned int >::const_iterator ContainerIterator
edm::ESHandle< TrackerGeometry > pDD
std::map< uint32_t, OneDetectorMap > SiGlobalIndex
EventID const & id() const
constexpr uint32_t rawId() const
get the raw id
void DMinitializeDetUnit(StripGeomDetUnit const *det, const edm::EventSetup &iSetup)
SiGlobalIndex SiHitStorage_
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
static std::string const input
edm::InputTag SistripLabelSig_
edm::EventPrincipal const & principal()
static float getNoise(uint16_t strip, const Range &range)
Container::value_type value_type
edm::InputTag SiStripPileInputTag_
static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range)
std::vector< SiStripDigi > OneDetectorMap
std::string SiStripDigiCollectionDM_
const uint16_t & strip() const
const SignalMapType * getSignal(uint32_t detID) const
std::unique_ptr< SiGaussianTailNoiseAdder > theSiNoiseAdder
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::pair< ContainerIterator, ContainerIterator > Range
DetId geographicalId() const
The label of this GeomDet.
bool APVSaturationFromHIP_
~PreMixingSiStripWorker() override=default
std::string SistripAPVListDM_
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
edm::InputTag SiStripAPVPileInputTag_
std::unique_ptr< SiStripFedZeroSuppression > theSiZeroSuppress
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void put(edm::Event &e, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bs) override
bool operator()(SiStripDigi i, SiStripDigi j) const
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
SiGlobalRawIndex SiRawDigis_
unsigned short firstStrip
APVMap theAffectedAPVmap_
std::pair< uint16_t, Amplitude > RawDigi
const Range getRange(const uint32_t detID) const
const Range getRange(const uint32_t detID) const
std::pair< ContainerIterator, ContainerIterator > Range
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
std::map< unsigned int, size_t > firstChannelsWithSignal
StreamID streamID() const
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &es) override
std::vector< RawDigi > OneDetectorRawMap
std::pair< ContainerIterator, ContainerIterator > Range
edm::InputTag SistripAPVLabelSig_
collection_type::const_iterator const_iterator
#define DEFINE_PREMIXING_WORKER(TYPE)
std::map< uint32_t, SignalMapType > signalMaps
std::map< int, Amplitude > SignalMapType
data decode(const unsigned int &value) const
std::multimap< uint32_t, std::bitset< 6 > > APVMap
const SiStripApvGain::Range getRange(uint32_t detID) const
SiDigitalConverter::DigitalVecType DigitalVecType