diff --git a/Configuration/ProcessModifiers/python/runDependentForPixelVal_cff.py b/Configuration/ProcessModifiers/python/runDependentForPixelVal_cff.py new file mode 100644 index 0000000000000..abf9267ccdebf --- /dev/null +++ b/Configuration/ProcessModifiers/python/runDependentForPixelVal_cff.py @@ -0,0 +1,2 @@ +import FWCore.ParameterSet.Config as cms +runDependentForPixelVal = cms.Modifier() diff --git a/Configuration/PyReleaseValidation/python/relval_premix.py b/Configuration/PyReleaseValidation/python/relval_premix.py index 5ae88673b74a9..1d2704ba0b736 100644 --- a/Configuration/PyReleaseValidation/python/relval_premix.py +++ b/Configuration/PyReleaseValidation/python/relval_premix.py @@ -49,7 +49,9 @@ workflows[250202.181]=['TTbar13TeVPUppmx2018',['TTbar_13UP18','PREMIXUP18_PU25','DIGIPRMXLOCALUP18_PU25','RECOPRMXUP18_PU25','HARVESTUP18_PU25']] workflows[250202.182]=['',['TTbar_13UP18_RD','DIGIPRMXUP18_PU25_RD','RECOPRMXUP18_PU25_RD','HARVESTUP18_PU25_RD']] workflows[250202.183]=['',['TTbar_13UP18_RD_IB','DIGIPRMXUP18_PU25_RD_IB','RECOPRMXUP18_PU25_RD','HARVESTUP18_PU25_RD']] -workflows[250202.184]=['',['TTbar_13UP18','PREMIXUP18_PU25_RDPix','DIGIPRMXLOCALUP18_PU25_RDPix','RECOPRMXUP18_PU25','HARVESTUP18_PU25']] +#workflows[250202.184]=['',['TTbar_13UP18','PREMIXUP18_PU25_RDPix','DIGIPRMXLOCALUP18_PU25_RDPix','RECOPRMXUP18_PU25','HARVESTUP18_PU25']] +workflows[250202.184]=['',['TTbar_13UP18','PREMIXUP18_PU25_RDPixLite','DIGIPRMXLOCALUP18_PU25_RDPix','RECOPRMXUP18_PU25','HARVESTUP18_PU25']] +workflows[250202.185]=['',['TTbar_13UP18','PREMIXUP18_PU25_RDPixLite','DIGIPRMXLOCALUP18_PU25_RDPixLite','RECOPRMXUP18_PU25','HARVESTUP18_PU25']] workflows[250203.18]=['',['H125GGgluonfusion_13UP18','DIGIPRMXUP18_PU25','RECOPRMXUP18_PU25','HARVESTUP18_PU25']] workflows[250204.18]=['',['QQH1352T_13UP18','DIGIPRMXUP18_PU25','RECOPRMXUP18_PU25','HARVESTUP18_PU25']] workflows[250205.18]=['',['ZTT_13UP18','DIGIPRMXUP18_PU25','RECOPRMXUP18_PU25','HARVESTUP18_PU25']] diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 455bcb17a0976..3de09f77a20c6 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -2089,12 +2089,17 @@ def lhegensim2018ml(fragment,howMuch): {'--era':'Run2_2018'}, {'--procModifiers':'premix_stage1,runDependentForPixel'}, premixUp2015Defaults]) +premixUp2018_RDPixLite = merge([{'--conditions':'auto:phase1_2018_realistic_rd'}, + {'--era':'Run2_2018'}, + {'--procModifiers':'premix_stage1,runDependentForPixelVal'}, + premixUp2015Defaults]) steps['PREMIXUP15_PU25']=merge([PU25,Kby(100,100),premixUp2015Defaults]) steps['PREMIXUP15_PU50']=merge([PU50,Kby(100,100),premixUp2015Defaults50ns]) steps['PREMIXUP17_PU25']=merge([PU25UP17,Kby(100,100),premixUp2017Defaults]) steps['PREMIXUP18_PU25']=merge([PU25UP18,Kby(100,100),premixUp2018Defaults]) steps['PREMIXUP18_PU25_RDPix']=merge([PU25UP18,Kby(100,100),premixUp2018_RDPix]) +steps['PREMIXUP18_PU25_RDPixLite']=merge([PU25UP18,Kby(100,100),premixUp2018_RDPixLite]) digiPremixUp2015Defaults25ns = { '--conditions' : 'auto:run2_mc', @@ -2169,6 +2174,8 @@ def lhegensim2018ml(fragment,howMuch): steps['DIGIPRMXLOCALUP18_PU25_RDPix']=merge([{'--conditions':'auto:phase1_2018_realistic_rd', '--procModifiers':'premix_stage2,runDependentForPixel'}, digiPremixLocalPileupUp2018Defaults25ns]) +steps['DIGIPRMXLOCALUP18_PU25_RDPixLite']=merge([{'--conditions':'auto:phase1_2018_realistic_rd', '--procModifiers':'premix_stage2,runDependentForPixelVal'}, digiPremixLocalPileupUp2018Defaults25ns]) + premixProd25ns = {'-s' : 'DIGI,DATAMIX,L1,DIGI2RAW,HLT:@relval2016', '--eventcontent' : 'PREMIXRAW', '--datatier' : 'PREMIXRAW'} diff --git a/SimDataFormats/TrackerDigiSimLink/interface/PixelSimHitExtraInfoLite.h b/SimDataFormats/TrackerDigiSimLink/interface/PixelSimHitExtraInfoLite.h new file mode 100644 index 0000000000000..c0ab9671e03ac --- /dev/null +++ b/SimDataFormats/TrackerDigiSimLink/interface/PixelSimHitExtraInfoLite.h @@ -0,0 +1,74 @@ +#ifndef PixelSimHitExtraInfoLite_h +#define PixelSimHitExtraInfoLite_h + +#include "DataFormats/GeometryVector/interface/LocalPoint.h" +#include "DataFormats/Math/interface/libminifloat.h" +#include +#include + +class PixelSimHitExtraInfoLite { +public: + PixelSimHitExtraInfoLite(size_t Hindex, const Local3DPoint& entryP, const Local3DPoint& exitP, unsigned int ch) { + index_ = Hindex; + // theEntryPoint_ = entryP; + // theExitPoint_ = exitP; + theEntryPointX_ = MiniFloatConverter::float32to16(entryP.x()); + theEntryPointY_ = MiniFloatConverter::float32to16(entryP.y()); + theEntryPointZ_ = MiniFloatConverter::float32to16(entryP.z()); + theExitPointX_ = MiniFloatConverter::float32to16(exitP.x()); + theExitPointY_ = MiniFloatConverter::float32to16(exitP.y()); + theExitPointZ_ = MiniFloatConverter::float32to16(exitP.z()); + chan_.push_back(ch); + }; + PixelSimHitExtraInfoLite() = default; + ~PixelSimHitExtraInfoLite() = default; + size_t hitIndex() const { return index_; }; + const uint16_t& entryPointX() const { return theEntryPointX_; } + const uint16_t& entryPointY() const { return theEntryPointY_; } + const uint16_t& entryPointZ() const { return theEntryPointZ_; } + const uint16_t& exitPointX() const { return theExitPointX_; } + const uint16_t& exitPointY() const { return theExitPointY_; } + const uint16_t& exitPointZ() const { return theExitPointZ_; } + + Local3DPoint& entryPoint() { + UncompressedEntryPoint_ = Local3DPoint(MiniFloatConverter::float16to32(theEntryPointX_), + MiniFloatConverter::float16to32(theEntryPointY_), + MiniFloatConverter::float16to32(theEntryPointZ_)); + return UncompressedEntryPoint_; + } + Local3DPoint& exitPoint() { + UncompressedExitPoint_ = Local3DPoint(MiniFloatConverter::float16to32(theExitPointX_), + MiniFloatConverter::float16to32(theExitPointY_), + MiniFloatConverter::float16to32(theExitPointZ_)); + return UncompressedExitPoint_; + } + + const std::vector& channel() const { return chan_; }; + + inline bool operator<(const PixelSimHitExtraInfoLite& other) const { return hitIndex() < other.hitIndex(); } + + void addDigiInfo(unsigned int theDigiChannel) { chan_.push_back(theDigiChannel); } + bool isInTheList(unsigned int channelToCheck) { + bool result_in_the_list = false; + for (unsigned int icheck = 0; icheck < chan_.size(); icheck++) { + if (channelToCheck == chan_[icheck]) { + result_in_the_list = true; + break; + } + } + return result_in_the_list; + } + +private: + size_t index_; + uint16_t theEntryPointX_; + uint16_t theEntryPointY_; + uint16_t theEntryPointZ_; + uint16_t theExitPointX_; + uint16_t theExitPointY_; + uint16_t theExitPointZ_; + Local3DPoint UncompressedEntryPoint_; + Local3DPoint UncompressedExitPoint_; + std::vector chan_; +}; +#endif diff --git a/SimDataFormats/TrackerDigiSimLink/src/classes.h b/SimDataFormats/TrackerDigiSimLink/src/classes.h index 5a3c3c7c6fd94..7000c8f98d420 100644 --- a/SimDataFormats/TrackerDigiSimLink/src/classes.h +++ b/SimDataFormats/TrackerDigiSimLink/src/classes.h @@ -9,5 +9,6 @@ #include "SimDataFormats/TrackerDigiSimLink/interface/StripDigiSimLink.h" #include "SimDataFormats/TrackerDigiSimLink/interface/StripCompactDigiSimLinks.h" #include "SimDataFormats/TrackerDigiSimLink/interface/PixelSimHitExtraInfo.h" +#include "SimDataFormats/TrackerDigiSimLink/interface/PixelSimHitExtraInfoLite.h" #endif // TRACKERDIGISIMLINK_CLASSES_H diff --git a/SimDataFormats/TrackerDigiSimLink/src/classes_def.xml b/SimDataFormats/TrackerDigiSimLink/src/classes_def.xml index 72a2d145112f5..a828c2065380a 100644 --- a/SimDataFormats/TrackerDigiSimLink/src/classes_def.xml +++ b/SimDataFormats/TrackerDigiSimLink/src/classes_def.xml @@ -47,4 +47,19 @@ + + + + + + + + + + + + + + + diff --git a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py index 57a495a894255..c668619c702c7 100644 --- a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py +++ b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py @@ -50,7 +50,9 @@ def _modifyPixelDigitizerForRun3( digitizer ): KillBadFEDChannels = cms.bool(False), UseReweighting = cms.bool(False), applyLateReweighting = cms.bool(False), + usePixelExtraLiteFormat = cms.bool(False), store_SimHitEntryExitPoints = cms.bool(False), + store_SimHitEntryExitPointsLite = cms.bool(False), PrintClusters = cms.bool(False), PrintTemplates = cms.bool(False), DoPixelAging = cms.bool(False), diff --git a/SimGeneral/MixingModule/python/aliases_cfi.py b/SimGeneral/MixingModule/python/aliases_cfi.py index 3c7d89e67444c..9ef571596b797 100644 --- a/SimGeneral/MixingModule/python/aliases_cfi.py +++ b/SimGeneral/MixingModule/python/aliases_cfi.py @@ -98,12 +98,16 @@ from Configuration.ProcessModifiers.runDependentForPixel_cff import runDependentForPixel (runDependentForPixel).toModify(simSiPixelDigis, mix = _pixelCommon + [cms.PSet(type = cms.string('PixelSimHitExtraInfoedmDetSetVector'))]) +from Configuration.ProcessModifiers.runDependentForPixelVal_cff import runDependentForPixelVal +(runDependentForPixelVal).toModify(simSiPixelDigis, mix = _pixelCommon + [cms.PSet(type = cms.string('PixelSimHitExtraInfoedmDetSetVector'))] + [cms.PSet(type = cms.string('PixelSimHitExtraInfoLiteedmDetSetVector'))]) + from Configuration.Eras.Modifier_phase2_hfnose_cff import phase2_hfnose (~phase2_hfnose).toModify(simHFNoseUnsuppressedDigis, mix = None) from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel phase1Pixel.toModify(simSiPixelDigis, mix = _pixelCommon + [cms.PSet(type = cms.string('PixelFEDChanneledmNewDetSetVector'))]) (phase1Pixel & runDependentForPixel).toModify(simSiPixelDigis, mix = _pixelCommon + [cms.PSet(type = cms.string('PixelSimHitExtraInfoedmDetSetVector'))] + [cms.PSet(type = cms.string('PixelFEDChanneledmNewDetSetVector'))]) +(phase1Pixel & runDependentForPixelVal).toModify(simSiPixelDigis, mix = _pixelCommon + [cms.PSet(type = cms.string('PixelSimHitExtraInfoedmDetSetVector'))] + [cms.PSet(type = cms.string('PixelSimHitExtraInfoLiteedmDetSetVector'))] + [cms.PSet(type = cms.string('PixelFEDChanneledmNewDetSetVector'))]) from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker phase2_tracker.toModify(simSiStripDigis, mix = None) diff --git a/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py b/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py index febe320e19777..7dbb0ab4b9e14 100644 --- a/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py +++ b/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py @@ -40,7 +40,19 @@ (runDependentForPixel & premix_stage1).toModify(pixelDigitizer, UseReweighting = False, applyLateReweighting = False, + usePixelExtraLiteFormat = False, store_SimHitEntryExitPoints = True, + store_SimHitEntryExitPointsLite = False, + AdcFullScale = 1023, + MissCalibrate = False +) +from Configuration.ProcessModifiers.runDependentForPixelVal_cff import runDependentForPixelVal +(runDependentForPixelVal & premix_stage1).toModify(pixelDigitizer, + UseReweighting = False, + applyLateReweighting = False, + usePixelExtraLiteFormat = False, + store_SimHitEntryExitPoints = True, + store_SimHitEntryExitPointsLite = True, AdcFullScale = 1023, MissCalibrate = False ) diff --git a/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py b/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py index b4ac1f578367a..241fde39bb22a 100644 --- a/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py +++ b/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py @@ -57,6 +57,7 @@ pixeldigiCollectionSig = cms.InputTag("simSiPixelDigis"), pixeldigiCollectionPile = cms.InputTag("simSiPixelDigis"), pixeldigiExtraCollectionPile = cms.InputTag("simSiPixelDigis"), + pixeldigiExtraLiteCollectionPile = cms.InputTag("simSiPixelDigis"), PixelDigiCollectionDM = cms.string('siPixelDigisDM'), ), strip = cms.PSet( @@ -158,7 +159,18 @@ (runDependentForPixel & premix_stage2).toModify(mixData.workers.pixel, UseReweighting=False, applyLateReweighting=True, - store_SimHitEntryExitPoints=False + usePixelExtraLiteFormat = False, + store_SimHitEntryExitPoints=False, + store_SimHitEntryExitPointsLite = False +) + +from Configuration.ProcessModifiers.runDependentForPixelVal_cff import runDependentForPixelVal +(runDependentForPixelVal & premix_stage2).toModify(mixData.workers.pixel, + UseReweighting=False, + applyLateReweighting=True, + usePixelExtraLiteFormat = True, + store_SimHitEntryExitPoints=False, + store_SimHitEntryExitPointsLite = False ) from Configuration.Eras.Modifier_fastSim_cff import fastSim diff --git a/SimTracker/Common/interface/SiPixelChargeReweightingAlgorithm.h b/SimTracker/Common/interface/SiPixelChargeReweightingAlgorithm.h index bd965f6e90923..ec09ed76e6603 100644 --- a/SimTracker/Common/interface/SiPixelChargeReweightingAlgorithm.h +++ b/SimTracker/Common/interface/SiPixelChargeReweightingAlgorithm.h @@ -77,6 +77,13 @@ class SiPixelChargeReweightingAlgorithm { const TrackerTopology* tTopo, CLHEP::HepRandomEngine* engine); + template + bool lateSignalReweight(const PixelGeomDetUnit* pixdet, + std::vector& digis, + PixelSimHitExtraInfoLite& loopTempSH, + SignalType& theNewDigiSignal, + const TrackerTopology* tTopo, + CLHEP::HepRandomEngine* engine); // could be templated in future ? private: // Internal typedef typedef GloballyPositioned Frame; @@ -778,7 +785,7 @@ bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeomDetUni } ierr = PixelTempRewgt2D(ID0, ID1, pixrewgt); if (ierr != 0) { - edm::LogError("SiPixelChargeReweightingAlgorithm") << "Cluster Charge Reweighting did not work properly."; + LogDebug("SiPixelChargeReweightingAlgorithm ") << "Cluster Charge Reweighting did not work properly."; return false; } if (PrintClusters) { @@ -816,7 +823,7 @@ bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeomDetUni } // need to store the digi out of the 21x13 box. - for (auto& i : theDigiSignal) { + for (const auto& i : theDigiSignal) { // check if in the 21x13 box int chanDigi = i.first; std::pair ip = PixelDigi::channelToPixel(chanDigi); @@ -841,4 +848,219 @@ bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeomDetUni return true; } +template +bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeomDetUnit* pixdet, + std::vector& digis, + PixelSimHitExtraInfoLite& loopTempSH, + SignalType& theNewDigiSignal, + const TrackerTopology* tTopo, + CLHEP::HepRandomEngine* engine) { + uint32_t detID = pixdet->geographicalId().rawId(); + const PixelTopology* topol = &pixdet->specificTopology(); + + if (UseReweighting) { + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ******************************** \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ******************************** \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ******************************** \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ***** INCONSISTENCY !!! ***** \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") + << " applyLateReweighting_ and UseReweighting can not be true at the same time for PU ! \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ---> DO NOT APPLY CHARGE REWEIGHTING TWICE !!! \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ******************************** \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ******************************** \n"; + return false; + } + + SignalType theDigiSignal; + + int irow_min = topol->nrows(); + int irow_max = 0; + int icol_min = topol->ncolumns(); + int icol_max = 0; + + float chargeBefore = 0; + float chargeAfter = 0; + + //loop on digis + std::vector::const_iterator loopDigi; + for (loopDigi = digis.begin(); loopDigi != digis.end(); ++loopDigi) { + unsigned int chan = loopDigi->channel(); + if (loopTempSH.isInTheList(chan)) { + float corresponding_charge = loopDigi->adc(); + if constexpr (std::is_same_v) { + edm::LogError("SiPixelChargeReweightingAlgorithm") + << "Phase-2 late charge reweighting not supported (not sure we need it at all)"; + return false; + } else { + theDigiSignal[chan] += AmplitudeType(corresponding_charge, corresponding_charge); + } + chargeBefore += corresponding_charge; + if (loopDigi->row() < irow_min) + irow_min = loopDigi->row(); + if (loopDigi->row() > irow_max) + irow_max = loopDigi->row(); + if (loopDigi->column() < icol_min) + icol_min = loopDigi->column(); + if (loopDigi->column() > icol_max) + icol_max = loopDigi->column(); + } + } + // end loop on digis + + LocalVector direction = loopTempSH.exitPoint() - loopTempSH.entryPoint(); + LocalPoint hitEntryPoint = loopTempSH.entryPoint(); + float trajectoryScaleToPosition = std::abs(hitEntryPoint.z() / direction.z()); + LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction; + + // addition as now the hit himself is not available + // https://github.com/cms-sw/cmssw/blob/master/SimDataFormats/TrackingHit/interface/PSimHit.h#L52 + LocalPoint hitLocalPosition = hitEntryPoint + 0.5 * direction; + MeasurementPoint hitPositionPixel = topol->measurementPosition(hitLocalPosition); + std::pair hitPixel = + std::pair(int(floor(hitPositionPixel.x())), int(floor(hitPositionPixel.y()))); + + MeasurementPoint originPixel = MeasurementPoint(hitPixel.first - THX + 0.5, hitPixel.second - THY + 0.5); + LocalPoint origin = topol->localPosition(originPixel); + + MeasurementPoint hitEntryPointPixel = topol->measurementPosition(loopTempSH.entryPoint()); + MeasurementPoint hitExitPointPixel = topol->measurementPosition(loopTempSH.exitPoint()); + std::pair entryPixel = + std::pair(int(floor(hitEntryPointPixel.x())), int(floor(hitEntryPointPixel.y()))); + std::pair exitPixel = + std::pair(int(floor(hitExitPointPixel.x())), int(floor(hitExitPointPixel.y()))); + + int hitcol_min, hitcol_max, hitrow_min, hitrow_max; + if (entryPixel.first > exitPixel.first) { + hitrow_min = exitPixel.first; + hitrow_max = entryPixel.first; + } else { + hitrow_min = entryPixel.first; + hitrow_max = exitPixel.first; + } + + if (entryPixel.second > exitPixel.second) { + hitcol_min = exitPixel.second; + hitcol_max = entryPixel.second; + } else { + hitcol_min = entryPixel.second; + hitcol_max = exitPixel.second; + } + + if (!(irow_min <= hitrow_max && irow_max >= hitrow_min && icol_min <= hitcol_max && icol_max >= hitcol_min)) { + // The clusters do not have an overlap, hence the hit is NOT reweighted + return false; + } + + track[0] = (hitPosition.x() - origin.x()) * cmToMicrons; + track[1] = (hitPosition.y() - origin.y()) * cmToMicrons; + track[2] = 0.0f; //Middle of sensor is origin for Z-axis + track[3] = direction.x(); + track[4] = direction.y(); + track[5] = direction.z(); + + array_2d pixrewgt(boost::extents[TXSIZE][TYSIZE]); + + /* + for (int row = 0; row < TXSIZE; ++row) { + for (int col = 0; col < TYSIZE; ++col) { + pixrewgt[row][col] = 0; + } + } +*/ + + for (int row = 0; row < TXSIZE; ++row) { + xdouble[row] = topol->isItBigPixelInX(hitPixel.first + row - THX); + } + + for (int col = 0; col < TYSIZE; ++col) { + ydouble[col] = topol->isItBigPixelInY(hitPixel.second + col - THY); + } + + for (int row = 0; row < TXSIZE; ++row) { + for (int col = 0; col < TYSIZE; ++col) { + //Fill charges into 21x13 Pixel Array with hitPixel in centre + pixrewgt[row][col] = + theDigiSignal[PixelDigi::pixelToChannel(hitPixel.first + row - THX, hitPixel.second + col - THY)]; + } + } + + if (PrintClusters) { + LogDebug("SiPixelChargeReweightingAlgorithm") << " Cluster before reweighting: "; + printCluster(pixrewgt); + } + + int ierr; + // for unirradiated: 2nd argument is IDden + // for irradiated: 2nd argument is IDnum + int ID1 = dbobject_num->getTemplateID(detID); + int ID0 = dbobject_den->getTemplateID(detID); + + if (ID0 == ID1) { + LogDebug("SiPixelChargeReweightingAlgorithm") << " same template for num and den "; + return false; + } + ierr = PixelTempRewgt2D(ID0, ID1, pixrewgt); + if (ierr != 0) { + LogDebug("SiPixelChargeReweightingAlgorithm") << "Cluster Charge Reweighting did not work properly."; + return false; + } + if (PrintClusters) { + LogDebug("SiPixelChargeReweightingAlgorithm") << " Cluster after reweighting: "; + printCluster(pixrewgt); + } + + for (int row = 0; row < TXSIZE; ++row) { + for (int col = 0; col < TYSIZE; ++col) { + float charge = 0; + charge = pixrewgt[row][col]; + if ((hitPixel.first + row - THX) >= 0 && (hitPixel.first + row - THX) < topol->nrows() && + (hitPixel.second + col - THY) >= 0 && (hitPixel.second + col - THY) < topol->ncolumns() && charge > 0) { + chargeAfter += charge; + if constexpr (std::is_same_v) { + edm::LogError("SiPixelChargeReweightingAlgorithm") + << "Phase-2 late charge reweighting not supported (not sure we need it at all)"; + return false; + } else { + theNewDigiSignal[PixelDigi::pixelToChannel(hitPixel.first + row - THX, hitPixel.second + col - THY)] += + AmplitudeType(charge, charge); + } + } + } + } + + if (chargeBefore != 0. && chargeAfter == 0.) { + return false; + } + + if (PrintClusters) { + LogDebug("SiPixelChargeReweightingAlgorithm") + << "Charges (before->after): " << chargeBefore << " -> " << chargeAfter; + LogDebug("SiPixelChargeReweightingAlgorithm") << "Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 << " %"; + } + + // need to store the digi out of the 21x13 box. + for (const auto& i : theDigiSignal) { + // check if in the 21x13 box + int chanDigi = i.first; + std::pair ip = PixelDigi::channelToPixel(chanDigi); + int row_digi = ip.first; + int col_digi = ip.second; + int i_transformed_row = row_digi - hitPixel.first + THX; + int i_transformed_col = col_digi - hitPixel.second + THY; + if (i_transformed_row < 0 || i_transformed_row > TXSIZE || i_transformed_col < 0 || i_transformed_col > TYSIZE) { + // not in the box + if (chanDigi >= 0 && i.second > 0) { + if constexpr (std::is_same_v) { + edm::LogError("SiPixelChargeReweightingAlgorithm") + << "Phase-2 late charge reweighting not supported (not sure we need it at all)"; + return false; + } else { + theNewDigiSignal[chanDigi] += AmplitudeType(i.second, i.second); + } + } + } + } + + return true; +} #endif diff --git a/SimTracker/SiPixelDigitizer/plugins/PreMixingSiPixelWorker.cc b/SimTracker/SiPixelDigitizer/plugins/PreMixingSiPixelWorker.cc index ca333da2f368b..c67d3110c8f0c 100644 --- a/SimTracker/SiPixelDigitizer/plugins/PreMixingSiPixelWorker.cc +++ b/SimTracker/SiPixelDigitizer/plugins/PreMixingSiPixelWorker.cc @@ -51,11 +51,13 @@ class PreMixingSiPixelWorker : public PreMixingWorker { edm::InputTag pixeldigi_collectionSig_; // secondary name given to collection of SiPixel digis edm::InputTag pixeldigi_collectionPile_; // secondary name given to collection of SiPixel digis edm::InputTag pixeldigi_extraInfo_; // secondary name given to collection of SiPixel digis + edm::InputTag pixeldigi_extraInfoLite_; // secondary name given to collection of SiPixel digis std::string PixelDigiCollectionDM_; // secondary name to be given to new SiPixel digis edm::EDGetTokenT> PixelDigiToken_; // Token to retrieve information edm::EDGetTokenT> PixelDigiPToken_; // Token to retrieve information edm::EDGetTokenT> PixelDigiPExtraToken_; + edm::EDGetTokenT> PixelDigiPExtraLiteToken_; // Lite version const edm::ESGetToken tTopoToken_; const edm::ESGetToken pDDToken_; @@ -73,13 +75,17 @@ class PreMixingSiPixelWorker : public PreMixingWorker { typedef std::map SiGlobalIndex; // map to all data for each detector ID typedef std::multimap OneExtraInfoMap; typedef std::map SiPixelExtraInfo; + typedef std::multimap OneExtraInfoLiteMap; // Lite version + typedef std::map SiPixelExtraInfoLite; // Lite version SiGlobalIndex SiHitStorage_; SiPixelExtraInfo SiHitExtraStorage_; + SiPixelExtraInfoLite SiHitExtraLiteStorage_; // Lite version bool firstInitializeEvent_ = true; bool firstFinalizeEvent_ = true; bool applyLateReweighting_; + bool usePixelExtraLiteFormat_; }; // Constructor @@ -94,13 +100,21 @@ PreMixingSiPixelWorker::PreMixingSiPixelWorker(const edm::ParameterSet& ps, pixeldigi_collectionSig_ = ps.getParameter("pixeldigiCollectionSig"); pixeldigi_collectionPile_ = ps.getParameter("pixeldigiCollectionPile"); pixeldigi_extraInfo_ = ps.getParameter("pixeldigiExtraCollectionPile"); + pixeldigi_extraInfoLite_ = ps.getParameter("pixeldigiExtraLiteCollectionPile"); // Lite version PixelDigiCollectionDM_ = ps.getParameter("PixelDigiCollectionDM"); applyLateReweighting_ = ps.getParameter("applyLateReweighting"); + usePixelExtraLiteFormat_ = ps.getParameter("usePixelExtraLiteFormat"); LogDebug("PreMixingSiPixelWorker") << "applyLateReweighting_ in PreMixingSiPixelWorker " << applyLateReweighting_; + LogDebug("PreMixingSiPixelWorker") << " applyLateReweighting_ in PreMixingSiPixelWorker " << applyLateReweighting_; + LogDebug("PreMixingSiPixelWorker") << " usePixelExtraLiteFormat_ in PreMixingSiPixelWorker " + << usePixelExtraLiteFormat_; + PixelDigiToken_ = iC.consumes>(pixeldigi_collectionSig_); PixelDigiPToken_ = iC.consumes>(pixeldigi_collectionPile_); PixelDigiPExtraToken_ = iC.consumes>(pixeldigi_extraInfo_); + PixelDigiPExtraLiteToken_ = + iC.consumes>(pixeldigi_extraInfoLite_); // Lite version producesCollector.produces>(PixelDigiCollectionDM_); producesCollector.produces(PixelDigiCollectionDM_); @@ -108,6 +122,7 @@ PreMixingSiPixelWorker::PreMixingSiPixelWorker(const edm::ParameterSet& ps, // clear local storage for this event SiHitStorage_.clear(); SiHitExtraStorage_.clear(); + SiHitExtraLiteStorage_.clear(); } // Need an event initialization @@ -163,6 +178,8 @@ void PreMixingSiPixelWorker::addPileups(PileUpEventPrincipal const& pep, edm::Ev // added for the Late CR edm::Handle> pixelAddInfo; pep.getByLabel(pixeldigi_extraInfo_, pixelAddInfo); + edm::Handle> pixelAddInfoLite; // Lite version + pep.getByLabel(pixeldigi_extraInfoLite_, pixelAddInfoLite); // Lite version const TrackerTopology* tTopo = &es.getData(tTopoToken_); auto const& pDD = es.getData(pDDToken_); edm::Service rng; @@ -173,27 +190,52 @@ void PreMixingSiPixelWorker::addPileups(PileUpEventPrincipal const& pep, edm::Ev bool loadExtraInformation = false; - if (pixelAddInfo.isValid() && applyLateReweighting_) { - // access the extra information - loadExtraInformation = true; - // Iterate on detector units - edm::DetSetVector::const_iterator detIdIter; - for (detIdIter = pixelAddInfo->begin(); detIdIter != pixelAddInfo->end(); detIdIter++) { - uint32_t detid = detIdIter->id; // = rawid - OneExtraInfoMap LocalExtraMap; - edm::DetSet::const_iterator di; - for (di = detIdIter->data.begin(); di != detIdIter->data.end(); di++) { - LocalExtraMap.insert(OneExtraInfoMap::value_type((di->hitIndex()), *di)); - } - SiHitExtraStorage_.insert(SiPixelExtraInfo::value_type(detid, LocalExtraMap)); - } // end loop on detIdIter - } // end if applyLateReweighting_ - else if (!pixelAddInfo.isValid() && applyLateReweighting_) { - edm::LogError("PreMixingSiPixelWorker") << " Problem in accessing the Extra Pixel SimHit Collection !!!! "; - edm::LogError("PreMixingSiPixelWorker") << " The Late Charge Reweighting can not be applied "; - throw cms::Exception("PreMixingSiPixelWorker") - << " Problem in accessing the Extra Pixel SimHit Collection for Late Charge Reweighting \n"; - } + if (!usePixelExtraLiteFormat_) { + if (pixelAddInfo.isValid() && applyLateReweighting_) { + // access the extra information + loadExtraInformation = true; + // Iterate on detector units + edm::DetSetVector::const_iterator detIdIter; + for (detIdIter = pixelAddInfo->begin(); detIdIter != pixelAddInfo->end(); detIdIter++) { + uint32_t detid = detIdIter->id; // = rawid + OneExtraInfoMap LocalExtraMap; + edm::DetSet::const_iterator di; + for (di = detIdIter->data.begin(); di != detIdIter->data.end(); di++) { + LocalExtraMap.insert(OneExtraInfoMap::value_type((di->hitIndex()), *di)); + } + SiHitExtraStorage_.insert(SiPixelExtraInfo::value_type(detid, LocalExtraMap)); + } // end loop on detIdIter + } // end if applyLateReweighting_ + else if (!pixelAddInfo.isValid() && applyLateReweighting_) { + edm::LogError("PreMixingSiPixelWorker") << " Problem in accessing the Extra Pixel SimHit Collection !!!! "; + edm::LogError("PreMixingSiPixelWorker") << " The Late Charge Reweighting can not be applied "; + throw cms::Exception("PreMixingSiPixelWorker") + << " Problem in accessing the Extra Pixel SimHit Collection for Late Charge Reweighting \n"; + } + } else { // Lite version + if (pixelAddInfoLite.isValid() && applyLateReweighting_) { + // access the extra information + loadExtraInformation = true; + // Iterate on detector units + edm::DetSetVector::const_iterator detIdIter; + for (detIdIter = pixelAddInfoLite->begin(); detIdIter != pixelAddInfoLite->end(); detIdIter++) { + uint32_t detid = detIdIter->id; // = rawid + OneExtraInfoLiteMap LocalExtraMap; + edm::DetSet::const_iterator di; + for (di = detIdIter->data.begin(); di != detIdIter->data.end(); di++) { + LocalExtraMap.insert(OneExtraInfoLiteMap::value_type((di->hitIndex()), *di)); + } + SiHitExtraLiteStorage_.insert(SiPixelExtraInfoLite::value_type(detid, LocalExtraMap)); + } // end loop on detIdIter + } // end if applyLateReweighting_ + else if (!pixelAddInfoLite.isValid() && applyLateReweighting_) { + edm::LogError("PreMixingSiPixelWorker") + << " Problem in accessing the Extra Pixel SimHit Lite Collection !!!! "; + edm::LogError("PreMixingSiPixelWorker") << " The Late Charge Reweighting can not be applied "; + throw cms::Exception("PreMixingSiPixelWorker") + << " Problem in accessing the Extra Pixel SimHit Lite Collection for Late Charge Reweighting \n"; + } + } // end if !usePixelExtraLiteFormat_ //loop on all detsets (detectorIDs) inside the input collection edm::DetSetVector::const_iterator DSViter = input.begin(); @@ -219,24 +261,45 @@ void PreMixingSiPixelWorker::addPileups(PileUpEventPrincipal const& pep, edm::Ev } if (loadExtraInformation) { // apply the Late Charge Reweighthing on Pile-up digi - SiPixelExtraInfo::const_iterator jtest; - jtest = SiHitExtraStorage_.find(detID); - OneExtraInfoMap LocalSimHitExtraMap = jtest->second; - std::vector TempSimExtra; - for (auto& iLocal : LocalSimHitExtraMap) { - TempSimExtra.push_back(iLocal.second); - } + if (!usePixelExtraLiteFormat_) { + SiPixelExtraInfo::const_iterator jtest; + jtest = SiHitExtraStorage_.find(detID); + OneExtraInfoMap LocalSimHitExtraMap = jtest->second; + std::vector TempSimExtra; + for (const auto& iLocal : LocalSimHitExtraMap) { + TempSimExtra.push_back(iLocal.second); + } - for (const auto& iu : pDD.detUnits()) { - if (iu->type().isTrackerPixel()) { - uint32_t detIDinLoop = iu->geographicalId().rawId(); - if (detIDinLoop == detID) { - digitizer_.lateSignalReweight( - dynamic_cast(iu), TempDigis, TempSimExtra, tTopo, engine); - break; + for (const auto& iu : pDD.detUnits()) { + if (iu->type().isTrackerPixel()) { + uint32_t detIDinLoop = iu->geographicalId().rawId(); + if (detIDinLoop == detID) { + digitizer_.lateSignalReweight( + dynamic_cast(iu), TempDigis, TempSimExtra, tTopo, engine); + break; + } } } - } + } else { // Lite version + SiPixelExtraInfoLite::const_iterator jtest; + jtest = SiHitExtraLiteStorage_.find(detID); + OneExtraInfoLiteMap LocalSimHitExtraMap = jtest->second; + std::vector TempSimExtra; + for (const auto& iLocal : LocalSimHitExtraMap) { + TempSimExtra.push_back(iLocal.second); + } + + for (const auto& iu : pDD.detUnits()) { + if (iu->type().isTrackerPixel()) { + uint32_t detIDinLoop = iu->geographicalId().rawId(); + if (detIDinLoop == detID) { + digitizer_.lateSignalReweight( + dynamic_cast(iu), TempDigis, TempSimExtra, tTopo, engine); + break; + } + } + } + } // end if !usePixelExtraLiteFormat_ } if (itest != SiHitStorage_.end()) { // this detID already has hits, add to existing map @@ -375,6 +438,7 @@ void PreMixingSiPixelWorker::put(edm::Event& e, // clear local storage for this event SiHitStorage_.clear(); SiHitExtraStorage_.clear(); + SiHitExtraLiteStorage_.clear(); } DEFINE_PREMIXING_WORKER(PreMixingSiPixelWorker); diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc index 4010b36ffa555..bfdc121c6e957 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc @@ -24,6 +24,7 @@ // user include files #include "SiPixelDigitizer.h" #include "SimDataFormats/TrackerDigiSimLink/interface/PixelSimHitExtraInfo.h" +#include "SimDataFormats/TrackerDigiSimLink/interface/PixelSimHitExtraInfoLite.h" #include "PixelDigiAddTempInfo.h" #include "SiPixelDigitizerAlgorithm.h" @@ -86,9 +87,14 @@ namespace cms { firstFinalizeEvent_(true), applyLateReweighting_( iConfig.exists("applyLateReweighting") ? iConfig.getParameter("applyLateReweighting") : false), + usePixelExtraLiteFormat_( + iConfig.exists("usePixelExtraLiteFormat") ? iConfig.getParameter("usePixelExtraLiteFormat") : false), store_SimHitEntryExitPoints_(iConfig.exists("store_SimHitEntryExitPoints") ? iConfig.getParameter("store_SimHitEntryExitPoints") : false), + store_SimHitEntryExitPointsLite_(iConfig.exists("store_SimHitEntryExitPointsLite") + ? iConfig.getParameter("store_SimHitEntryExitPointsLite") + : false), _pixeldigialgo(), hitsProducer(iConfig.getParameter("hitsProducer")), trackerContainers(iConfig.getParameter >("RoutList")), @@ -108,6 +114,9 @@ namespace cms { if (store_SimHitEntryExitPoints_) producesCollector.produces >().setBranchAlias(alias + "siPixelExtraSimHit"); + if (store_SimHitEntryExitPointsLite_) + producesCollector.produces >().setBranchAlias( + alias + "siPixelExtraSimHitLite"); for (auto const& trackerContainer : trackerContainers) { edm::InputTag tag(hitsProducer, trackerContainer); @@ -261,6 +270,7 @@ namespace cms { std::vector > theDigiVector; std::vector > theDigiLinkVector; std::vector > theExtraSimHitInfoVector; + std::vector > theExtraSimHitInfoLiteVector; if (firstFinalizeEvent_) { _pixeldigialgo->init_DynIneffDB(iSetup); @@ -285,6 +295,7 @@ namespace cms { edm::DetSet linkcollector(iu->geographicalId().rawId()); std::vector tempcollector; edm::DetSet tempSHcollector(iu->geographicalId().rawId()); + edm::DetSet tempSHLitecollector(iu->geographicalId().rawId()); _pixeldigialgo->digitize(dynamic_cast(iu), collector.data, @@ -318,6 +329,7 @@ namespace cms { } bool checkInTheList = false; + // To fill the PixelSimHitExtraInfo temporary collector if (!checkTwoSimHits) { std::vector::iterator loopTempSH; for (loopTempSH = tempSHcollector.begin(); loopTempSH != tempSHcollector.end(); ++loopTempSH) { @@ -334,13 +346,41 @@ namespace cms { tempSHcollector.push_back(newSHEntry); } } + bool checkInTheListLite = false; + // To fill the PixelSimHitExtraInfoLite temporary collector + if (!checkTwoSimHits) { + std::vector::iterator loopTempSHLite; + for (loopTempSHLite = tempSHLitecollector.begin(); loopTempSHLite != tempSHLitecollector.end(); + ++loopTempSHLite) { + if (loopNewClass->hitIndex() == loopTempSHLite->hitIndex()) { + checkInTheListLite = true; + loopTempSHLite->addDigiInfo(loopNewClass->channel()); + } + } + if (!checkInTheListLite) { + PixelSimHitExtraInfoLite newSHLiteEntry(loopNewClass->hitIndex(), + loopNewClass->entryPoint(), + loopNewClass->exitPoint(), + loopNewClass->channel()); + tempSHLitecollector.push_back(newSHLiteEntry); + } + } } } if (applyLateReweighting_) { - // if applyLateReweighting_ is true, the charge reweighting has to be applied on top of the digis - _pixeldigialgo->lateSignalReweight( - dynamic_cast(iu), collector.data, tempSHcollector.data, tTopo, randomEngine_); + if (!usePixelExtraLiteFormat_) { + // if applyLateReweighting_ is true, the charge reweighting has to be applied on top of the digis + _pixeldigialgo->lateSignalReweight( + dynamic_cast(iu), collector.data, tempSHcollector.data, tTopo, randomEngine_); + } else { + // if applyLateReweighting_ is true, the charge reweighting has to be applied on top of the digis + _pixeldigialgo->lateSignalReweight(dynamic_cast(iu), + collector.data, + tempSHLitecollector.data, + tTopo, + randomEngine_); + } } if (!collector.data.empty()) { @@ -352,6 +392,9 @@ namespace cms { if (!tempSHcollector.data.empty()) { theExtraSimHitInfoVector.push_back(std::move(tempSHcollector)); } + if (!tempSHLitecollector.data.empty()) { + theExtraSimHitInfoLiteVector.push_back(std::move(tempSHLitecollector)); + } } } _pixeldigialgo->resetSimHitMaps(); @@ -362,12 +405,16 @@ namespace cms { new edm::DetSetVector(theDigiLinkVector)); std::unique_ptr > outputExtraSim( new edm::DetSetVector(theExtraSimHitInfoVector)); + std::unique_ptr > outputExtraSimLite( + new edm::DetSetVector(theExtraSimHitInfoLiteVector)); // Step D: write output to file iEvent.put(std::move(output)); iEvent.put(std::move(outputlink)); if (store_SimHitEntryExitPoints_) iEvent.put(std::move(outputExtraSim)); + if (store_SimHitEntryExitPointsLite_) + iEvent.put(std::move(outputExtraSimLite)); randomEngine_ = nullptr; // to prevent access outside event } diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.h b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.h index 66995282e9a30..7efb0ae3608dd 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.h +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.h @@ -74,7 +74,9 @@ namespace cms { bool firstInitializeEvent_; bool firstFinalizeEvent_; bool applyLateReweighting_; + bool usePixelExtraLiteFormat_; const bool store_SimHitEntryExitPoints_; + const bool store_SimHitEntryExitPointsLite_; bool makeDigiSimLinks_; std::unique_ptr _pixeldigialgo; /** @brief Offset to add to the index of each sim hit to account for which crossing it's in. diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index c61513f5cee6c..99814c01b5749 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -184,6 +184,9 @@ SiPixelDigitizerAlgorithm::SiPixelDigitizerAlgorithm(const edm::ParameterSet& co makeDigiSimLinks_(conf.getUntrackedParameter("makeDigiSimLinks", true)), store_SimHitEntryExitPoints_( conf.exists("store_SimHitEntryExitPoints") ? conf.getParameter("store_SimHitEntryExitPoints") : false), + store_SimHitEntryExitPointsLite_(conf.exists("store_SimHitEntryExitPointsLite") + ? conf.getParameter("store_SimHitEntryExitPointsLite") + : false), use_ineff_from_db_(conf.getParameter("useDB")), use_module_killing_(conf.getParameter("killModules")), // boolean to kill or not modules use_deadmodule_DB_(conf.getParameter("DeadModules_DB")), // boolean to access dead modules from DB @@ -2607,3 +2610,130 @@ void SiPixelDigitizerAlgorithm::lateSignalReweight(const PixelGeomDetUnit* pixde digis.clear(); digis = New_digis; } + +/******************************************************************/ + +void SiPixelDigitizerAlgorithm::lateSignalReweight(const PixelGeomDetUnit* pixdet, + std::vector& digis, + std::vector& newClass_Sim_extra, + const TrackerTopology* tTopo, + CLHEP::HepRandomEngine* engine) { + // Function to apply the Charge Reweighting on top of digi in case of PU from mixing library + // for time dependent MC + std::vector New_digis; + uint32_t detID = pixdet->geographicalId().rawId(); + + if (UseReweighting) { + LogError("PixelDigitizer ") << " ******************************** \n"; + LogError("PixelDigitizer ") << " ******************************** \n"; + LogError("PixelDigitizer ") << " ***** INCONSISTENCY !!! ***** \n"; + LogError("PixelDigitizer ") + << " applyLateReweighting_ and UseReweighting can not be true at the same time for PU ! \n"; + LogError("PixelDigitizer ") << " ---> DO NOT APPLY CHARGE REWEIGHTING TWICE !!! \n"; + LogError("PixelDigitizer ") << " ******************************** \n"; + LogError("PixelDigitizer ") << " ******************************** \n"; + return; + } + + float thePixelThresholdInE = 0.; + if (theNoiseInElectrons > 0.) { + if (pixdet->type().isTrackerPixel() && pixdet->type().isBarrel()) { // Barrel modules + int lay = tTopo->layer(detID); + if (addThresholdSmearing) { + if (pixdet->subDetector() == GeomDetEnumerators::SubDetector::PixelBarrel || + pixdet->subDetector() == GeomDetEnumerators::SubDetector::P1PXB) { + if (lay == 1) { + thePixelThresholdInE = CLHEP::RandGaussQ::shoot( + engine, theThresholdInE_BPix_L1, theThresholdSmearing_BPix_L1); // gaussian smearing + } else if (lay == 2) { + thePixelThresholdInE = CLHEP::RandGaussQ::shoot( + engine, theThresholdInE_BPix_L2, theThresholdSmearing_BPix_L2); // gaussian smearing + } else { + thePixelThresholdInE = + CLHEP::RandGaussQ::shoot(engine, theThresholdInE_BPix, theThresholdSmearing_BPix); // gaussian smearing + } + } + } else { + if (pixdet->subDetector() == GeomDetEnumerators::SubDetector::PixelBarrel || + pixdet->subDetector() == GeomDetEnumerators::SubDetector::P1PXB) { + if (lay == 1) { + thePixelThresholdInE = theThresholdInE_BPix_L1; + } else if (lay == 2) { + thePixelThresholdInE = theThresholdInE_BPix_L2; + } else { + thePixelThresholdInE = theThresholdInE_BPix; // no smearing + } + } + } + + } else if (pixdet->type().isTrackerPixel()) { // Forward disks modules + + if (addThresholdSmearing) { + thePixelThresholdInE = + CLHEP::RandGaussQ::shoot(engine, theThresholdInE_FPix, theThresholdSmearing_FPix); // gaussian smearing + } else { + thePixelThresholdInE = theThresholdInE_FPix; // no smearing + } + + } else { + throw cms::Exception("NotAPixelGeomDetUnit") << "Not a pixel geomdet unit" << detID; + } + } + + // loop on the SimHit extra info class + // apply the reweighting for that SimHit on a cluster way + bool reweighted = false; + std::vector::iterator loopTempSH; + for (loopTempSH = newClass_Sim_extra.begin(); loopTempSH != newClass_Sim_extra.end(); ++loopTempSH) { + signal_map_type theDigiSignal; + PixelSimHitExtraInfoLite TheNewInfo = *loopTempSH; + reweighted = TheNewSiPixelChargeReweightingAlgorithmClass->lateSignalReweight( + pixdet, digis, TheNewInfo, theDigiSignal, tTopo, engine); + if (!reweighted) { + // loop on the non-reweighthed digis associated to the considered SimHit + std::vector::const_iterator loopDigi; + for (loopDigi = digis.begin(); loopDigi != digis.end(); ++loopDigi) { + unsigned int chan = loopDigi->channel(); + // check if that digi is related to the SimHit + if (loopTempSH->isInTheList(chan)) { + float corresponding_charge = loopDigi->adc(); + theDigiSignal[chan] += digitizerUtility::Amplitude(corresponding_charge, corresponding_charge); + } + } + } + + // transform theDigiSignal into digis + int Thresh_inADC = int(thePixelThresholdInE / theElectronPerADC); + for (signal_map_const_iterator i = theDigiSignal.begin(); i != theDigiSignal.end(); ++i) { + float signalInADC = (*i).second; // signal in ADC + if (signalInADC > 0.) { + if (signalInADC >= Thresh_inADC) { + int chan = (*i).first; // channel number + std::pair ip = PixelDigi::channelToPixel(chan); + int adc = int(signalInADC); + // add MissCalibration + if (doMissCalInLateCR) { + int row = ip.first; + int col = ip.second; + adc = + int(missCalibrate(detID, tTopo, pixdet, col, row, signalInADC * theElectronPerADC)); //full misscalib. + } + + if (adc > theAdcFullScLateCR) + adc = theAdcFullScLateCR; // Check maximum value + +#ifdef TP_DEBUG + LogDebug("Pixel Digitizer") << (*i).first << " " << (*i).second << " " << signalInADC << " " << adc + << ip.first << " " << ip.second; +#endif + + // Load digis + New_digis.emplace_back(ip.first, ip.second, adc); + } + } + } // end loop on theDigiSignal + theDigiSignal.clear(); + } + digis.clear(); + digis = New_digis; +} diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h index 6b479641903af..42eba2e3c6f3d 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h @@ -12,6 +12,7 @@ #include "SimTracker/Common/interface/DigitizerUtility.h" #include "SimTracker/SiPixelDigitizer/plugins/PixelDigiAddTempInfo.h" #include "SimDataFormats/TrackerDigiSimLink/interface/PixelSimHitExtraInfo.h" +#include "SimDataFormats/TrackerDigiSimLink/interface/PixelSimHitExtraInfoLite.h" #include "DataFormats/Math/interface/approx_exp.h" #include "SimDataFormats/PileupSummaryInfo/interface/PileupMixingContent.h" #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" @@ -91,6 +92,11 @@ class SiPixelDigitizerAlgorithm { std::vector& newClass_Sim_extra, const TrackerTopology* tTopo, CLHEP::HepRandomEngine* engine); + void lateSignalReweight(const PixelGeomDetUnit* pixdet, + std::vector& digis, + std::vector& newClass_Sim_extra, + const TrackerTopology* tTopo, + CLHEP::HepRandomEngine* engine); // for premixing void calculateInstlumiFactor(const std::vector& ps, @@ -277,6 +283,7 @@ class SiPixelDigitizerAlgorithm { const bool makeDigiSimLinks_; const bool store_SimHitEntryExitPoints_; + const bool store_SimHitEntryExitPointsLite_; const bool use_ineff_from_db_; const bool use_module_killing_; // remove or not the dead pixel modules