From 0b1ca8b159c641db4ef658ed0c564d4a2d7528bc Mon Sep 17 00:00:00 2001 From: Suchandra Date: Tue, 7 Jul 2020 18:25:18 +0200 Subject: [PATCH 1/5] Software Design update and integration of Pixel3DDigitizerAlgorithm in the framework. Phase2Digitizer configuraion updated to to have a common PSet for Pixel and individual IT-pixel algotithms can clone it and make necessary modifications. A bug fix has been made in the dual slope correction to avoid a shift of 0.5 ToT bin --- .../plugins/DigitizerUtility.h | 4 - .../plugins/PSPDigitizerAlgorithm.cc | 44 +---- .../plugins/PSPDigitizerAlgorithm.h | 12 +- .../plugins/PSSDigitizerAlgorithm.cc | 44 +---- .../plugins/PSSDigitizerAlgorithm.h | 12 +- .../Phase2TrackerDigitizerAlgorithm.cc | 110 +++++++---- .../plugins/Phase2TrackerDigitizerAlgorithm.h | 43 ++--- .../plugins/Pixel3DDigitizerAlgorithm.cc | 66 ++----- .../plugins/Pixel3DDigitizerAlgorithm.h | 32 ++-- .../plugins/PixelDigitizerAlgorithm.cc | 44 +---- .../plugins/PixelDigitizerAlgorithm.h | 12 +- .../plugins/SSDigitizerAlgorithm.cc | 75 ++------ .../plugins/SSDigitizerAlgorithm.h | 23 +-- .../python/phase2TrackerDigitizer_cfi.py | 172 +++++++----------- 14 files changed, 231 insertions(+), 462 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/DigitizerUtility.h b/SimTracker/SiPhase2Digitizer/plugins/DigitizerUtility.h index 3b06ce92939a0..c473e93a732a9 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/DigitizerUtility.h +++ b/SimTracker/SiPhase2Digitizer/plugins/DigitizerUtility.h @@ -60,10 +60,6 @@ namespace DigitizerUtility { void set(const float amplitude) { // Used to reset the amplitude _amp = amplitude; } - // void setind (const float indamplitude) { // Used to reset the amplitude - // _frac = idamplitude; - // } - private: float _amp; std::vector > > _simInfoList; diff --git a/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.cc index 99b0d4e2d8cc5..aa51d09f4ad6a 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.cc @@ -27,56 +27,16 @@ PSPDigitizerAlgorithm::PSPDigitizerAlgorithm(const edm::ParameterSet& conf) << tMax_ << " pix-inefficiency " << addPixelInefficiency_; } PSPDigitizerAlgorithm::~PSPDigitizerAlgorithm() { LogDebug("PSPDigitizerAlgorithm") << "Algorithm deleted"; } -void PSPDigitizerAlgorithm::accumulateSimHits(std::vector::const_iterator inputBegin, - std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) { - // produce SignalPoint's for all SimHit's in detector - // Loop over hits - uint32_t detId = pixdet->geographicalId().rawId(); - size_t simHitGlobalIndex = inputBeginGlobalIndex; // This needs to be stored to create the digi-sim link later - - // find the relevant hits - std::vector matchedSimHits; - std::copy_if(inputBegin, inputEnd, std::back_inserter(matchedSimHits), [detId](auto const& hit) -> bool { - return hit.detUnitId() == detId; - }); - // loop over a much reduced set of SimHits - for (auto const& hit : matchedSimHits) { - LogDebug("PSPDigitizerAlgorithm") << hit.particleType() << " " << hit.pabs() << " " << hit.energyLoss() << " " - << hit.tof() << " " << hit.trackId() << " " << hit.processType() << " " - << hit.detUnitId() << hit.entryPoint() << " " << hit.exitPoint(); - - std::vector ionization_points; - std::vector collection_points; - - double signalScale = 1.0; - // fill collection_points for this SimHit, indpendent of topology - if (select_hit(hit, (pixdet->surface().toGlobal(hit.localPosition()).mag() * c_inv), signalScale)) { - primary_ionization(hit, ionization_points); // fills ionization_points - - // transforms ionization_points -> collection_points - drift(hit, pixdet, bfield, ionization_points, collection_points); - - // compute induced signal on readout elements and add to _signal - // hit needed only for SimHit<-->Digi link - induce_signal(hit, simHitGlobalIndex, tofBin, pixdet, collection_points); - } - ++simHitGlobalIndex; - } -} // // -- Select the Hit for Digitization (sigScale will be implemented in future) // -bool PSPDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) { +bool PSPDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) const { double toa = hit.tof() - tCorr; return (toa > theTofLowerCut_ && toa < theTofUpperCut_); } // // -- Compare Signal with Threshold // -bool PSPDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) { +bool PSPDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const { return (charge >= thr); } diff --git a/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.h index 3c412d1a95eb3..47938039f092b 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.h @@ -11,15 +11,7 @@ class PSPDigitizerAlgorithm : public Phase2TrackerDigitizerAlgorithm { // initialization that cannot be done in the constructor void init(const edm::EventSetup& es) override; - // void initializeEvent(); - // run the algorithm to digitize a single det - void accumulateSimHits(const std::vector::const_iterator inputBegin, - const std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) override; - bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) override; - bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) override; + bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) const override; + bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const override; }; #endif diff --git a/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.cc index 63a3d84f0ecfa..4c9670f1e7e13 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.cc @@ -27,50 +27,10 @@ PSSDigitizerAlgorithm::PSSDigitizerAlgorithm(const edm::ParameterSet& conf) << tMax_ << " pix-inefficiency " << addPixelInefficiency_; } PSSDigitizerAlgorithm::~PSSDigitizerAlgorithm() { LogDebug("PSSDigitizerAlgorithm") << "Algorithm deleted"; } -void PSSDigitizerAlgorithm::accumulateSimHits(std::vector::const_iterator inputBegin, - std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) { - // produce SignalPoint's for all SimHit's in detector - // Loop over hits - uint32_t detId = pixdet->geographicalId().rawId(); - size_t simHitGlobalIndex = inputBeginGlobalIndex; // This needs to be stored to create the digi-sim link later - - // find the relevant hits - std::vector matchedSimHits; - std::copy_if(inputBegin, inputEnd, std::back_inserter(matchedSimHits), [detId](auto const& hit) -> bool { - return hit.detUnitId() == detId; - }); - // loop over a much reduced set of SimHits - for (auto const& hit : matchedSimHits) { - LogDebug("PSSDigitizerAlgorithm") << hit.particleType() << " " << hit.pabs() << " " << hit.energyLoss() << " " - << hit.tof() << " " << hit.trackId() << " " << hit.processType() << " " - << hit.detUnitId() << hit.entryPoint() << " " << hit.exitPoint(); - - std::vector ionization_points; - std::vector collection_points; - - double signalScale = 1.0; - // fill collection_points for this SimHit, indpendent of topology - if (select_hit(hit, (pixdet->surface().toGlobal(hit.localPosition()).mag() * c_inv), signalScale)) { - primary_ionization(hit, ionization_points); // fills ionization_points - - // transforms ionization_points -> collection_points - drift(hit, pixdet, bfield, ionization_points, collection_points); - - // compute induced signal on readout elements and add to _signal - // hit needed only for SimHit<-->Digi link - induce_signal(hit, simHitGlobalIndex, tofBin, pixdet, collection_points); - } - ++simHitGlobalIndex; - } -} // // -- Select the Hit for Digitization (sigScale will be implemented in future) // -bool PSSDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) { +bool PSSDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) const { double toa = hit.tof() - tCorr; return (toa > theTofLowerCut_ && toa < theTofUpperCut_); } @@ -79,6 +39,6 @@ bool PSSDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& // bool PSSDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* const hisInfo, float charge, - float thr) { + float thr) const { return (charge >= thr); } diff --git a/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.h index 38c88ce6a4ed4..af14ce990d9dd 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.h @@ -11,15 +11,7 @@ class PSSDigitizerAlgorithm : public Phase2TrackerDigitizerAlgorithm { // initialization that cannot be done in the constructor void init(const edm::EventSetup& es) override; - // void initializeEvent(); - // run the algorithm to digitize a single det - void accumulateSimHits(const std::vector::const_iterator inputBegin, - const std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) override; - bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) override; - bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) override; + bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) const override; + bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const override; }; #endif diff --git a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc index 4e448969c9236..d7d70af06bfc6 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc @@ -43,8 +43,14 @@ namespace { constexpr double m_electron = 0.511; constexpr double m_muon = 105.658; constexpr double m_proton = 938.272; + double calcQ(float x); } // namespace - +namespace { + double calcQ(float x) { + auto xx = std::min(0.5f * x * x, 12.5f); + return 0.5 * (1.0 - std::copysign(std::sqrt(1.f - unsafe_expf<4>(-xx * (1.f + 0.2733f / (1.f + 0.147f * xx)))), x)); + } +} Phase2TrackerDigitizerAlgorithm::Phase2TrackerDigitizerAlgorithm(const edm::ParameterSet& conf_common, const edm::ParameterSet& conf_specific) : _signal(), @@ -174,14 +180,49 @@ Phase2TrackerDigitizerAlgorithm::SubdetEfficiencies::SubdetEfficiencies(const ed barrel_efficiencies = conf.getParameter >("EfficiencyFactors_Barrel"); endcap_efficiencies = conf.getParameter >("EfficiencyFactors_Endcap"); } +void Phase2TrackerDigitizerAlgorithm::accumulateSimHits(std::vector::const_iterator inputBegin, + std::vector::const_iterator inputEnd, + const size_t inputBeginGlobalIndex, + const uint32_t tofBin, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield) { + // produce SignalPoint's for all SimHit's in detector + // Loop over hits + uint32_t detId = pixdet->geographicalId().rawId(); + size_t simHitGlobalIndex = inputBeginGlobalIndex; // This needs to be stored to create the digi-sim link later + + // find the relevant hits + std::vector matchedSimHits; + std::copy_if(inputBegin, inputEnd, std::back_inserter(matchedSimHits), [detId](auto const& hit) -> bool { + return hit.detUnitId() == detId; + }); + // loop over a much reduced set of SimHits + for (auto const& hit : matchedSimHits) { + LogDebug("Phase2DigitizerAlgorithm") << hit.particleType() << " " << hit.pabs() << " " << hit.energyLoss() << " " + << hit.tof() << " " << hit.trackId() << " " << hit.processType() << " " + << hit.detUnitId() << hit.entryPoint() << " " << hit.exitPoint(); + double signalScale = 1.0; + // fill collection_points for this SimHit, indpendent of topology + if (select_hit(hit, (pixdet->surface().toGlobal(hit.localPosition()).mag() * c_inv), signalScale)) { + const auto ionization_points = primary_ionization(hit); // fills ionization_points + + // transforms ionization_points -> collection_points + const auto collection_points = drift(hit, pixdet, bfield, ionization_points); + + // compute induced signal on readout elements and add to _signal + // hit needed only for SimHit<-->Digi link + induce_signal(hit, simHitGlobalIndex, tofBin, pixdet, collection_points); + } + ++simHitGlobalIndex; + } +} // ================================================================= // // Generate primary ionization along the track segment. // Divide the track into small sub-segments // // ================================================================= -void Phase2TrackerDigitizerAlgorithm::primary_ionization( - const PSimHit& hit, std::vector& ionization_points) const { +std::vector Phase2TrackerDigitizerAlgorithm::primary_ionization(const PSimHit& hit) const { // Straight line approximation for trajectory inside active media constexpr float SegmentLength = 0.0010; // in cm (10 microns) // Get the 3D segment direction vector @@ -198,26 +239,31 @@ void Phase2TrackerDigitizerAlgorithm::primary_ionization( << " " << hit.exitPoint().y() - hit.entryPoint().y() << " " << hit.exitPoint().z() - hit.entryPoint().z() << " " << hit.particleType() << " " << hit.pabs(); - std::vector elossVector; // Eloss vector + std::vector elossVector; elossVector.reserve(NumberOfSegments); if (fluctuateCharge_) { // Generate fluctuated charge points - fluctuateEloss(hit.particleType(), hit.pabs(), eLoss, length, NumberOfSegments, elossVector); + elossVector = fluctuateEloss(hit.particleType(), hit.pabs(), eLoss, length, NumberOfSegments); + } + else { + float averageEloss = eLoss / NumberOfSegments; + std::fill(std::begin(elossVector), std::end(elossVector), averageEloss); } - ionization_points.reserve(NumberOfSegments); // set size + std::vector ionization_points; + ionization_points.reserve(NumberOfSegments); // set size // loop over segments for (size_t i = 0; i < elossVector.size(); ++i) { // Divide the segment into equal length subsegments Local3DPoint point = hit.entryPoint() + ((i + 0.5) / NumberOfSegments) * direction; - float energy = fluctuateCharge_ ? elossVector[i] / GeVperElectron_ // Convert charge to elec. - : eLoss / GeVperElectron_ / NumberOfSegments; + float energy = elossVector[i] / GeVperElectron_; // Convert charge to elec. DigitizerUtility::EnergyDepositUnit edu(energy, point); // define position,energy point ionization_points.push_back(edu); // save LogDebug("Phase2TrackerDigitizerAlgorithm") << i << " " << edu.x() << " " << edu.y() << " " << edu.z() << " " << edu.energy(); } + return ionization_points; } //============================================================================== // @@ -225,17 +271,11 @@ void Phase2TrackerDigitizerAlgorithm::primary_ionization( // Use the G4 routine. For mip pions for the moment. // //============================================================================== -void Phase2TrackerDigitizerAlgorithm::fluctuateEloss(int pid, - float particleMomentum, - float eloss, - float length, - int NumberOfSegs, - std::vector& elossVector) const { - // Get dedx for this track - //float dedx; - //if( length > 0.) dedx = eloss/length; - //else dedx = eloss; - +std::vector Phase2TrackerDigitizerAlgorithm::fluctuateEloss(int pid, + float particleMomentum, + float eloss, + float length, + int NumberOfSegs) const { double particleMass = ::m_pion; // Mass in MeV, assume pion pid = std::abs(pid); if (pid != 211) { // Mass in MeV @@ -254,9 +294,11 @@ void Phase2TrackerDigitizerAlgorithm::fluctuateEloss(int pid, // Generate charge fluctuations. float sum = 0.; double segmentEloss = (1000. * eloss) / NumberOfSegs; //eloss in MeV + std::vector elossVector; + elossVector.reserve(NumberOfSegs); for (int i = 0; i < NumberOfSegs; ++i) { - // material,*, momentum,energy,*, *, mass - //myglandz_(14.,segmentLength,2.,2.,dedx,de,0.14); + // material,*, momentum,energy,*, *, mass + // myglandz_(14.,segmentLength,2.,2.,dedx,de,0.14); // The G4 routine needs momentum in MeV, mass in Mev, delta-cut in MeV, // track segment length in mm, segment eloss in MeV // Returns fluctuated eloss in MeV @@ -282,6 +324,7 @@ void Phase2TrackerDigitizerAlgorithm::fluctuateEloss(int pid, float averageEloss = eloss / NumberOfSegs; std::fill(std::begin(elossVector), std::end(elossVector), averageEloss); } + return elossVector; } // ====================================================================== @@ -290,18 +333,19 @@ void Phase2TrackerDigitizerAlgorithm::fluctuateEloss(int pid, // Include the effect of E-field and B-field // // ===================================================================== -void Phase2TrackerDigitizerAlgorithm::drift(const PSimHit& hit, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield, - const std::vector& ionization_points, - std::vector& collection_points) const { +std::vector +Phase2TrackerDigitizerAlgorithm::drift(const PSimHit& hit, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield, + const std::vector& ionization_points) const { LogDebug("Phase2TrackerDigitizerAlgorithm") << "enter drift "; + std::vector collection_points; collection_points.reserve(ionization_points.size()); // set size LocalVector driftDir = DriftDirection(pixdet, bfield, hit.detUnitId()); // get the charge drift direction if (driftDir.z() == 0.) { LogWarning("Phase2TrackerDigitizerAlgorithm") << " pxlx: drift in z is zero "; - return; + return collection_points; } float TanLorenzAngleX = driftDir.x(); // tangent of Lorentz angle @@ -381,6 +425,7 @@ void Phase2TrackerDigitizerAlgorithm::drift(const PSimHit& hit, // Load the Charge distribution parameters collection_points.push_back(sp); } + return collection_points; } // ==================================================================== @@ -467,7 +512,7 @@ void Phase2TrackerDigitizerAlgorithm::induce_signal( } else { mp = MeasurementPoint(ix, 0.0); xLB = topol->localPosition(mp).x(); - LowerBound = 1 - calcQ((xLB - CloudCenterX) / SigmaX); + LowerBound = 1 - ::calcQ((xLB - CloudCenterX) / SigmaX); } float xUB, UpperBound; @@ -476,7 +521,7 @@ void Phase2TrackerDigitizerAlgorithm::induce_signal( } else { mp = MeasurementPoint(ix + 1, 0.0); xUB = topol->localPosition(mp).x(); - UpperBound = 1. - calcQ((xUB - CloudCenterX) / SigmaX); + UpperBound = 1. - ::calcQ((xUB - CloudCenterX) / SigmaX); } float TotalIntegrationRange = UpperBound - LowerBound; // get strip x.emplace(ix, TotalIntegrationRange); // save strip integral @@ -491,7 +536,7 @@ void Phase2TrackerDigitizerAlgorithm::induce_signal( } else { mp = MeasurementPoint(0.0, iy); yLB = topol->localPosition(mp).y(); - LowerBound = 1. - calcQ((yLB - CloudCenterY) / SigmaY); + LowerBound = 1. - ::calcQ((yLB - CloudCenterY) / SigmaY); } float yUB, UpperBound; @@ -500,7 +545,7 @@ void Phase2TrackerDigitizerAlgorithm::induce_signal( } else { mp = MeasurementPoint(0.0, iy + 1); yUB = topol->localPosition(mp).y(); - UpperBound = 1. - calcQ((yUB - CloudCenterY) / SigmaY); + UpperBound = 1. - ::calcQ((yUB - CloudCenterY) / SigmaY); } float TotalIntegrationRange = UpperBound - LowerBound; @@ -978,7 +1023,8 @@ int Phase2TrackerDigitizerAlgorithm::convertSignalToAdc(uint32_t detID, float si // calculate the kink point and the slope int dualslope_param = std::min(std::abs(thePhase2ReadoutMode_), max_limit); int kink_point = static_cast(theAdcFullScale_ / 2) + 1; - temp_signal = std::floor((signal_in_elec - threshold) / theElectronPerADC_) + 1; + // C-ROC: first valid ToT code above threshold is 0b0000 + temp_signal = std::floor((signal_in_elec - threshold) / theElectronPerADC_); if (temp_signal > kink_point) temp_signal = std::floor((temp_signal - kink_point) / (pow(2, dualslope_param - 1))) + kink_point; } diff --git a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h index 9159423a3d4d5..7beb79532e03d 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h @@ -70,12 +70,12 @@ class Phase2TrackerDigitizerAlgorithm { const size_t inputBeginGlobalIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) = 0; + const GlobalVector& bfield); virtual void digitize(const Phase2TrackerGeomDetUnit* pixdet, std::map& digi_map, const TrackerTopology* tTopo); - virtual bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) { return true; } - virtual bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) { return true; } + virtual bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) const { return true; } + virtual bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const { return true; } // For premixing void loadAccumulator(uint32_t detId, const std::map& accumulator); @@ -181,24 +181,21 @@ class Phase2TrackerDigitizerAlgorithm { //-- additional member functions // Private methods - void primary_ionization(const PSimHit& hit, - std::vector& ionization_points) const; - void drift(const PSimHit& hit, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield, - const std::vector& ionization_points, - std::vector& collection_points) const; - void induce_signal(const PSimHit& hit, - const size_t hitIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const std::vector& collection_points); - void fluctuateEloss(int particleId, - float momentum, - float eloss, - float length, - int NumberOfSegments, - std::vector& elossVector) const; + virtual std::vector primary_ionization(const PSimHit& hit) const; + virtual std::vector drift(const PSimHit& hit, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield, + const std::vector& ionization_points) const; + virtual void induce_signal(const PSimHit& hit, + const size_t hitIndex, + const uint32_t tofBin, + const Phase2TrackerGeomDetUnit* pixdet, + const std::vector& collection_points); + virtual std::vector fluctuateEloss(int particleId, + float momentum, + float eloss, + float length, + int NumberOfSegments) const; virtual void add_noise(const Phase2TrackerGeomDetUnit* pixdet); virtual void add_cross_talk(const Phase2TrackerGeomDetUnit* pixdet); virtual void add_noisy_cells(const Phase2TrackerGeomDetUnit* pixdet, float thePixelThreshold); @@ -234,10 +231,6 @@ class Phase2TrackerDigitizerAlgorithm { // convert signal in electrons to ADC counts int convertSignalToAdc(uint32_t detID, float signal_in_elec, float threshold); - double calcQ(float x) const { - auto xx = std::min(0.5f * x * x, 12.5f); - return 0.5 * (1.0 - std::copysign(std::sqrt(1.f - unsafe_expf<4>(-xx * (1.f + 0.2733f / (1.f + 0.147f * xx)))), x)); - } bool pixelFlag_; }; #endif diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index eae013c74aeb4..fc31f3a577b6c 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -72,51 +72,12 @@ Pixel3DDigitizerAlgorithm::Pixel3DDigitizerAlgorithm(const edm::ParameterSet& co Pixel3DDigitizerAlgorithm::~Pixel3DDigitizerAlgorithm() {} -void Pixel3DDigitizerAlgorithm::accumulateSimHits(std::vector::const_iterator inputBegin, - std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const unsigned int tofBin, - const Phase2TrackerGeomDetUnit* pix3Ddet, - const GlobalVector& bfield) { - // produce SignalPoint's for all SimHit's in detector - - const uint32_t detId = pix3Ddet->geographicalId().rawId(); - // This needs to be stored to create the digi-sim link later - size_t simHitGlobalIndex = inputBeginGlobalIndex; - - // Loop over hits - for (auto it = inputBegin; it != inputEnd; ++it, ++simHitGlobalIndex) { - // skip hit: not in this detector. - if (it->detUnitId() != detId) { - continue; - } - - LogDebug("Pixel3DDigitizerAlgorithm:: Geant4 hit info: ") - << (*it).particleType() << " " << (*it).pabs() << " " << (*it).energyLoss() << " " << (*it).tof() << " " - << (*it).trackId() << " " << (*it).processType() << " " << (*it).detUnitId() << (*it).entryPoint() << " " - << (*it).exitPoint() << " Global index for PSimHit:" << simHitGlobalIndex; - - // Convert the simhit position into global to check if the simhit was - // produced within a given time-window - const auto global_hit_position = pix3Ddet->surface().toGlobal(it->localPosition()).mag(); - - // Only accept those sim hits produced inside a time window (same bunch-crossing) - if ((it->tof() - global_hit_position * c_inv >= theTofLowerCut_) && - (it->tof() - global_hit_position * c_inv <= theTofUpperCut_)) { - // XXX: this vectors are the output of the next methods, the methods should - // return them, instead of an input argument - std::vector ionization_points; - - // For each sim hit, super-charges (electron-holes) are created every 10um - primary_ionization(*it, ionization_points); - // Drift the super-charges (only electrons) to the collecting electrodes - const auto collection_points = drift(*it, pix3Ddet, bfield, ionization_points, true); - - // compute induced signal on readout elements and add to _signal - // *ihit needed only for SimHit<-->Digi link - induce_signal(*it, simHitGlobalIndex, tofBin, pix3Ddet, collection_points); - } - } +// +// -- Select the Hit for Digitization +// +bool Pixel3DDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) const { + double time = hit.tof() - tCorr; + return (time >= theTofLowerCut_ && time < theTofUpperCut_); } const bool Pixel3DDigitizerAlgorithm::_is_inside_n_column(const LocalPoint& p) const { @@ -146,7 +107,7 @@ std::vector Pixel3DDigitizerAlgorithm::diff const float& ncarriers, const std::function& u_drift, const std::pair hpitches, - const float& thickness) { + const float& thickness) const { // FIXME -- DM : Note that with a 0.3 will be enough (if using current sigma formulae) // With the current sigma, this value is dependent of the thickness, // Note that this formulae is coming from planar sensors, a similar @@ -250,13 +211,20 @@ std::vector Pixel3DDigitizerAlgorithm::diff // Include the effect of E-field and B-field // // ===================================================================== -// XXX: Signature to be checked +std::vector Pixel3DDigitizerAlgorithm::drift( + const PSimHit& hit, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield, + const std::vector& ionization_points) const +{ + return drift(hit, pixdet, bfield, ionization_points, true); +} std::vector Pixel3DDigitizerAlgorithm::drift( const PSimHit& hit, const Phase2TrackerGeomDetUnit* pixdet, const GlobalVector& bfield, const std::vector& ionization_points, - bool diffusion_activated) { + bool diffusion_activated) const { // -- Current reference system is placed in the center on the module // -- The natural reference frame should be discribed taking advantatge of // -- the cylindrical nature of the pixel geometry --> @@ -405,7 +373,7 @@ std::vector Pixel3DDigitizerAlgorithm::drift( // signal and linking it to the simulated energy deposit (hit) void Pixel3DDigitizerAlgorithm::induce_signal(const PSimHit& hit, const size_t hitIndex, - const unsigned int tofBin, + const uint32_t tofBin, const Phase2TrackerGeomDetUnit* pixdet, const std::vector& collection_points) { // X - Rows, Left-Right diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h index bfb124934aeef..8f6aae91e8158 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h @@ -27,34 +27,30 @@ class Pixel3DDigitizerAlgorithm : public Phase2TrackerDigitizerAlgorithm { // initialization that cannot be done in the constructor void init(const edm::EventSetup& es) override; + bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) const override; + std::vector drift(const PSimHit& hit, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield, + const std::vector& ionization_points) const override; + // overload drift + std::vector drift(const PSimHit& hit, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield, + const std::vector& ionization_points, + bool diffusion_activated) const; - // run the algorithm to digitize a single det - void accumulateSimHits(const std::vector::const_iterator inputBegin, - const std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const unsigned int tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) override; - - // overload the mother (drift3d maybe) - std::vector drift( - const PSimHit& hit, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield, - const std::vector& ionization_points, - bool diffusion_activated); // New diffusion function: check implementation std::vector diffusion(const LocalPoint& pos, const float& ncarriers, const std::function& u_drift, const std::pair pitches, - const float& thickness); + const float& thickness) const; // Specific for 3D-pixel void induce_signal(const PSimHit& hit, const size_t hitIndex, - const unsigned int tofBin, + const uint32_t tofBin, const Phase2TrackerGeomDetUnit* pixdet, - const std::vector& collection_points); + const std::vector& collection_points) override; private: // Raidus of Column np and ohmic diff --git a/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc index 2989a533a22b3..9eb89e3c02369 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc @@ -64,50 +64,10 @@ PixelDigitizerAlgorithm::PixelDigitizerAlgorithm(const edm::ParameterSet& conf) << addPixelInefficiency_; } PixelDigitizerAlgorithm::~PixelDigitizerAlgorithm() { LogDebug("PixelDigitizerAlgorithm") << "Algorithm deleted"; } -void PixelDigitizerAlgorithm::accumulateSimHits(std::vector::const_iterator inputBegin, - std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) { - // produce SignalPoint's for all SimHit's in detector - // Loop over hits - uint32_t detId = pixdet->geographicalId().rawId(); - size_t simHitGlobalIndex = inputBeginGlobalIndex; // This needs to be stored to create the digi-sim link later - - // find the relevant hits - std::vector matchedSimHits; - std::copy_if(inputBegin, inputEnd, std::back_inserter(matchedSimHits), [detId](auto const& hit) -> bool { - return hit.detUnitId() == detId; - }); - // loop over a much reduced set of SimHits - for (auto const& hit : matchedSimHits) { - LogDebug("PixelDigitizerAlgorithm") << hit.particleType() << " " << hit.pabs() << " " << hit.energyLoss() << " " - << hit.tof() << " " << hit.trackId() << " " << hit.processType() << " " - << hit.detUnitId() << hit.entryPoint() << " " << hit.exitPoint(); - - std::vector ionization_points; - std::vector collection_points; - - double signalScale = 1.0; - // fill collection_points for this SimHit, indpendent of topology - if (select_hit(hit, (pixdet->surface().toGlobal(hit.localPosition()).mag() * c_inv), signalScale)) { - primary_ionization(hit, ionization_points); // fills ionization_points - - // transforms ionization_points -> collection_points - drift(hit, pixdet, bfield, ionization_points, collection_points); - - // compute induced signal on readout elements and add to _signal - // hit needed only for SimHit<-->Digi link - induce_signal(hit, simHitGlobalIndex, tofBin, pixdet, collection_points); - } - ++simHitGlobalIndex; - } -} // // -- Select the Hit for Digitization // -bool PixelDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) { +bool PixelDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) const { double time = hit.tof() - tCorr; return (time >= theTofLowerCut_ && time < theTofUpperCut_); } @@ -267,7 +227,7 @@ std::size_t PixelDigitizerAlgorithm::TimewalkModel::find_closest_index(const std // // -- Compare Signal with Threshold // -bool PixelDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) { +bool PixelDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const { if (charge < thr) return false; if (apply_timewalk_ && hitInfo) { diff --git a/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.h index e025c93b496fc..10f3d651dfe83 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.h @@ -41,16 +41,8 @@ class PixelDigitizerAlgorithm : public Phase2TrackerDigitizerAlgorithm { // initialization that cannot be done in the constructor void init(const edm::EventSetup& es) override; - // void initializeEvent(); - // run the algorithm to digitize a single det - void accumulateSimHits(const std::vector::const_iterator inputBegin, - const std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) override; - bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) override; - bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) override; + bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) const override; + bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const override; void add_cross_talk(const Phase2TrackerGeomDetUnit* pixdet) override; // Addition four xtalk-related parameters to PixelDigitizerAlgorithm specific parameters initialized in Phase2TrackerDigitizerAlgorithm diff --git a/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.cc index 2842cfad0aa8a..e7b54a8f810d5 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.cc @@ -14,6 +14,17 @@ using namespace edm; +namespace { + double nFactorial(int n); + double aScalingConstant(int N, int i); +} +namespace { + double nFactorial(int n) { return std::tgamma(n + 1); } + double aScalingConstant(int N, int i) { + return std::pow(-1, (double)i) * nFactorial(N) * nFactorial(N + 2) / + (nFactorial(N - i) * nFactorial(N + 2 - i) * nFactorial(i)); + } +} void SSDigitizerAlgorithm::init(const edm::EventSetup& es) { es.get().get(geom_); } SSDigitizerAlgorithm::SSDigitizerAlgorithm(const edm::ParameterSet& conf) : Phase2TrackerDigitizerAlgorithm(conf.getParameter("AlgorithmCommon"), @@ -33,50 +44,10 @@ SSDigitizerAlgorithm::SSDigitizerAlgorithm(const edm::ParameterSet& conf) storeSignalShape(); } SSDigitizerAlgorithm::~SSDigitizerAlgorithm() { LogDebug("SSDigitizerAlgorithm") << "SSDigitizerAlgorithm deleted"; } -void SSDigitizerAlgorithm::accumulateSimHits(std::vector::const_iterator inputBegin, - std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) { - // produce SignalPoint's for all SimHit's in detector - // Loop over hits - uint32_t detId = pixdet->geographicalId().rawId(); - size_t simHitGlobalIndex = inputBeginGlobalIndex; // This needs to be stored to create the digi-sim link later - - // find the relevant hits - std::vector matchedSimHits; - std::copy_if(inputBegin, inputEnd, std::back_inserter(matchedSimHits), [detId](auto const& hit) -> bool { - return hit.detUnitId() == detId; - }); - // loop over a much reduced set of SimHits - for (auto const& hit : matchedSimHits) { - LogDebug("SSDigitizerAlgorithm") << hit.particleType() << " " << hit.pabs() << " " << hit.energyLoss() << " " - << hit.tof() << " " << hit.trackId() << " " << hit.processType() << " " - << hit.detUnitId() << hit.entryPoint() << " " << hit.exitPoint(); - - std::vector ionization_points; - std::vector collection_points; - - double signalScale = 1.0; - // fill collection_points for this SimHit, indpendent of topology - if (select_hit(hit, (pixdet->surface().toGlobal(hit.localPosition()).mag() * c_inv), signalScale)) { - primary_ionization(hit, ionization_points); // fills ionization_points - - // transforms ionization_points -> collection_points - drift(hit, pixdet, bfield, ionization_points, collection_points); - - // compute induced signal on readout elements and add to _signal - // hit needed only for SimHit<-->Digi link - induce_signal(hit, simHitGlobalIndex, tofBin, pixdet, collection_points); - } - ++simHitGlobalIndex; - } -} // // -- Select the Hit for Digitization // -bool SSDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) { +bool SSDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) const { bool result = false; if (hitDetectionMode_ == SSDigitizerAlgorithm::SampledMode) result = select_hit_sampledMode(hit, tCorr, sigScale); @@ -91,7 +62,7 @@ bool SSDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& // // -- Select Hits in Sampled Mode // -bool SSDigitizerAlgorithm::select_hit_sampledMode(const PSimHit& hit, double tCorr, double& sigScale) { +bool SSDigitizerAlgorithm::select_hit_sampledMode(const PSimHit& hit, double tCorr, double& sigScale) const { double toa = hit.tof() - tCorr; double sampling_time = bx_time; @@ -105,7 +76,7 @@ bool SSDigitizerAlgorithm::select_hit_sampledMode(const PSimHit& hit, double tCo // // -- Select Hits in Hit Detection Mode // -bool SSDigitizerAlgorithm::select_hit_latchedMode(const PSimHit& hit, double tCorr, double& sigScale) { +bool SSDigitizerAlgorithm::select_hit_latchedMode(const PSimHit& hit, double tCorr, double& sigScale) const { float toa = hit.tof() - tCorr; toa -= hit.eventId().bunchCrossing() * bx_time; @@ -128,13 +99,7 @@ bool SSDigitizerAlgorithm::select_hit_latchedMode(const PSimHit& hit, double tCo } return false; } - -double SSDigitizerAlgorithm::nFactorial(int n) { return std::tgamma(n + 1); } -double SSDigitizerAlgorithm::aScalingConstant(int N, int i) { - return std::pow(-1, (double)i) * nFactorial(N) * nFactorial(N + 2) / - (nFactorial(N - i) * nFactorial(N + 2 - i) * nFactorial(i)); -} -double SSDigitizerAlgorithm::cbc3PulsePolarExpansion(double x) { +double SSDigitizerAlgorithm::cbc3PulsePolarExpansion(double x) const { constexpr size_t max_par = 6; if (pulseShapeParameters_.size() < max_par) return -1; @@ -152,10 +117,10 @@ double SSDigitizerAlgorithm::cbc3PulsePolarExpansion(double x) { for (int i = 0; i < nTerms; i++) { double angularTerm = 0; double temporalTerm = 0; - double rTerm = std::pow(r, i) / (std::pow(tau, 2. * i) * nFactorial(i + 2)); + double rTerm = std::pow(r, i) / (std::pow(tau, 2. * i) * ::nFactorial(i + 2)); for (int j = 0; j <= i; j++) { angularTerm += std::pow(std::cos(theta), (double)(i - j)) * std::pow(std::sin(theta), (double)j); - temporalTerm += aScalingConstant(i, j) * std::pow(xx, (double)(i - j)) * std::pow(tau, (double)j); + temporalTerm += ::aScalingConstant(i, j) * std::pow(xx, (double)(i - j)) * std::pow(tau, (double)j); } double fi = rTerm * angularTerm * temporalTerm; @@ -163,7 +128,7 @@ double SSDigitizerAlgorithm::cbc3PulsePolarExpansion(double x) { } return fN; } -double SSDigitizerAlgorithm::signalShape(double x) { +double SSDigitizerAlgorithm::signalShape(double x) const { double xOffset = pulseShapeParameters_[0]; double tau = pulseShapeParameters_[1]; double maxCharge = pulseShapeParameters_[5]; @@ -178,7 +143,7 @@ void SSDigitizerAlgorithm::storeSignalShape() { pulseShapeVec_.push_back(signalShape(val)); } } -double SSDigitizerAlgorithm::getSignalScale(double xval) { +double SSDigitizerAlgorithm::getSignalScale(double xval) const { double res = 0.0; int len = pulseShapeVec_.size(); @@ -201,6 +166,6 @@ double SSDigitizerAlgorithm::getSignalScale(double xval) { // bool SSDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* const hisInfo, float charge, - float thr) { + float thr) const { return (charge >= thr); } diff --git a/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.h index c179eb3b8ca12..a0ebea3da3d9b 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.h @@ -11,26 +11,17 @@ class SSDigitizerAlgorithm : public Phase2TrackerDigitizerAlgorithm { // initialization that cannot be done in the constructor void init(const edm::EventSetup& es) override; - // run the algorithm to digitize a single det - void accumulateSimHits(const std::vector::const_iterator inputBegin, - const std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) override; - bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) override; - bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) override; + bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) const override; + bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const override; private: enum { SquareWindow, SampledMode, LatchedMode, SampledOrLachedMode, HIPFindingMode }; - double nFactorial(int n); - double aScalingConstant(int N, int i); - double cbc3PulsePolarExpansion(double x); - double signalShape(double x); - double getSignalScale(double xval); + double cbc3PulsePolarExpansion(double x) const; + double signalShape(double x) const; + double getSignalScale(double xval) const; void storeSignalShape(); - bool select_hit_sampledMode(const PSimHit& hit, double tCorr, double& sigScale); - bool select_hit_latchedMode(const PSimHit& hit, double tCorr, double& sigScale); + bool select_hit_sampledMode(const PSimHit& hit, double tCorr, double& sigScale) const; + bool select_hit_latchedMode(const PSimHit& hit, double tCorr, double& sigScale) const; int hitDetectionMode_; std::vector pulseShapeVec_; diff --git a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py index 2f9e122f0041e..608be21b50fb1 100644 --- a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py +++ b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py @@ -1,5 +1,68 @@ + import FWCore.ParameterSet.Config as cms +PixelDigitizerAlgorithmCommon = cms.PSet( + ElectronPerAdc = cms.double(600.0), + ReadoutNoiseInElec = cms.double(0.0), + ThresholdInElectrons_Barrel = cms.double(1200.0), + ThresholdInElectrons_Endcap = cms.double(1200.0), + AddThresholdSmearing = cms.bool(False), + ThresholdSmearing_Barrel = cms.double(0.0), + ThresholdSmearing_Endcap = cms.double(0.0), + HIPThresholdInElectrons_Barrel = cms.double(1.0e10), # very high value to avoid Over threshold bit + HIPThresholdInElectrons_Endcap = cms.double(1.0e10), # very high value to avoid Over threshold bit + NoiseInElectrons = cms.double(0.0), + Phase2ReadoutMode = cms.int32(-1), # Flag to decide Readout Mode :Digital(0) or Analog (linear TDR (-1), dual slope with slope parameters (+1,+2,+3,+4) with threshold subtraction + AdcFullScale = cms.int32(15), + TofUpperCut = cms.double(12.5), + TofLowerCut = cms.double(-12.5), + AddNoisyPixels = cms.bool(False), + Alpha2Order = cms.bool(True), #D.B.: second order effect, does not switch off magnetic field as described + AddNoise = cms.bool(False), + AddXTalk = cms.bool(False), #D.B. + InterstripCoupling = cms.double(0.0), #D.B. # No need to be used in PixelDigitizerAlgorithm + Odd_row_interchannelCoupling_next_row = cms.double(0.20), + Even_row_interchannelCoupling_next_row = cms.double(0.0), + Odd_column_interchannelCoupling_next_column = cms.double(0.0), + Even_column_interchannelCoupling_next_column = cms.double(0.0), + SigmaZero = cms.double(0.00037), #D.B.: 3.7um spread for 300um-thick sensor, renormalized in digitizerAlgo + SigmaCoeff = cms.double(0), #S.D: setting SigmaCoeff=0 for IT-pixel + ClusterWidth = cms.double(3), #D.B.: this is used as number of sigmas for charge collection (3=+-3sigmas) + LorentzAngle_DB = cms.bool(True), + TanLorentzAnglePerTesla_Endcap = cms.double(0.106), + TanLorentzAnglePerTesla_Barrel = cms.double(0.106), + KillModules = cms.bool(False), + DeadModules_DB = cms.bool(False), + DeadModules = cms.VPSet(), + AddInefficiency = cms.bool(False), + Inefficiency_DB = cms.bool(False), + EfficiencyFactors_Barrel = cms.vdouble(0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999 ), + EfficiencyFactors_Endcap = cms.vdouble(0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, + 0.999, 0.999 ),#Efficiencies kept as Side2Disk1,Side1Disk1 and so on + CellsToKill = cms.VPSet(), + ApplyTimewalk = cms.bool(False), + TimewalkModel = cms.PSet( + ThresholdValues = cms.vdouble(1000, 1200, 1500, 3000), + Curves = cms.VPSet( + cms.PSet( + charge = cms.vdouble(1000, 1025, 1050, 1100, 1200, 1500, 2000, 6000, 10000, 15000, 20000, 30000), + delay = cms.vdouble(26.8, 23.73, 21.92, 19.46, 16.52, 12.15, 8.88, 3.03, 1.69, 0.95, 0.56, 0.19) + ), + cms.PSet( + charge = cms.vdouble(1200, 1225, 1250, 1500, 2000, 6000, 10000, 15000, 20000, 30000), + delay = cms.vdouble(26.28, 23.5, 21.79, 14.92, 10.27, 3.33, 1.86, 1.07, 0.66, 0.27) + ), + cms.PSet( + charge = cms.vdouble(1500, 1525, 1550, 1600, 2000, 6000, 10000, 15000, 20000, 30000), + delay = cms.vdouble(25.36, 23.05, 21.6, 19.56, 12.94, 3.79, 2.14, 1.26, 0.81, 0.39) + ), + cms.PSet( + charge = cms.vdouble(3000, 3025, 3050, 3100, 3500, 6000, 10000, 15000, 20000, 30000), + delay = cms.vdouble(25.63, 23.63, 22.35, 20.65, 14.92, 6.7, 3.68, 2.29, 1.62, 1.02) + ) + ) + ) +) phase2TrackerDigitizer = cms.PSet( # For the Digitizer accumulatorType = cms.string("Phase2TrackerDigitizer"), @@ -19,109 +82,9 @@ ), # Specific parameters #Pixel Digitizer Algorithm - PixelDigitizerAlgorithm = cms.PSet( - ElectronPerAdc = cms.double(600.0), - ReadoutNoiseInElec = cms.double(0.0), - ThresholdInElectrons_Barrel = cms.double(1200.0), - ThresholdInElectrons_Endcap = cms.double(1200.0), - AddThresholdSmearing = cms.bool(False), - ThresholdSmearing_Barrel = cms.double(0.0), - ThresholdSmearing_Endcap = cms.double(0.0), - HIPThresholdInElectrons_Barrel = cms.double(1.0e10), # very high value to avoid Over threshold bit - HIPThresholdInElectrons_Endcap = cms.double(1.0e10), # very high value to avoid Over threshold bit - NoiseInElectrons = cms.double(0.0), - Phase2ReadoutMode = cms.int32(-1), # Flag to decide Readout Mode :Digital(0) or Analog (linear TDR (-1), dual slope with slope parameters (+1,+2,+3,+4) with threshold subtraction - AdcFullScale = cms.int32(15), - TofUpperCut = cms.double(12.5), - TofLowerCut = cms.double(-12.5), - AddNoisyPixels = cms.bool(False), - Alpha2Order = cms.bool(True), #D.B.: second order effect, does not switch off magnetic field as described - AddNoise = cms.bool(False), - AddXTalk = cms.bool(False), #D.B. - InterstripCoupling = cms.double(0.0), #D.B. # No need to be used in PixelDigitizerAlgorithm - Odd_row_interchannelCoupling_next_row = cms.double(0.20), - Even_row_interchannelCoupling_next_row = cms.double(0.0), - Odd_column_interchannelCoupling_next_column = cms.double(0.0), - Even_column_interchannelCoupling_next_column = cms.double(0.0), - SigmaZero = cms.double(0.00037), #D.B.: 3.7um spread for 300um-thick sensor, renormalized in digitizerAlgo - SigmaCoeff = cms.double(0), #S.D: setting SigmaCoeff=0 for IT-pixel - ClusterWidth = cms.double(3), #D.B.: this is used as number of sigmas for charge collection (3=+-3sigmas) - LorentzAngle_DB = cms.bool(True), - TanLorentzAnglePerTesla_Endcap = cms.double(0.106), - TanLorentzAnglePerTesla_Barrel = cms.double(0.106), - KillModules = cms.bool(False), - DeadModules_DB = cms.bool(False), - DeadModules = cms.VPSet(), - AddInefficiency = cms.bool(False), - Inefficiency_DB = cms.bool(False), - EfficiencyFactors_Barrel = cms.vdouble(0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999 ), - EfficiencyFactors_Endcap = cms.vdouble(0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, - 0.999, 0.999 ),#Efficiencies kept as Side2Disk1,Side1Disk1 and so on - CellsToKill = cms.VPSet(), - ApplyTimewalk = cms.bool(False), - TimewalkModel = cms.PSet( - ThresholdValues = cms.vdouble(1000, 1200, 1500, 3000), - Curves = cms.VPSet( - cms.PSet( - charge = cms.vdouble(1000, 1025, 1050, 1100, 1200, 1500, 2000, 6000, 10000, 15000, 20000, 30000), - delay = cms.vdouble(26.8, 23.73, 21.92, 19.46, 16.52, 12.15, 8.88, 3.03, 1.69, 0.95, 0.56, 0.19) - ), - cms.PSet( - charge = cms.vdouble(1200, 1225, 1250, 1500, 2000, 6000, 10000, 15000, 20000, 30000), - delay = cms.vdouble(26.28, 23.5, 21.79, 14.92, 10.27, 3.33, 1.86, 1.07, 0.66, 0.27) - ), - cms.PSet( - charge = cms.vdouble(1500, 1525, 1550, 1600, 2000, 6000, 10000, 15000, 20000, 30000), - delay = cms.vdouble(25.36, 23.05, 21.6, 19.56, 12.94, 3.79, 2.14, 1.26, 0.81, 0.39) - ), - cms.PSet( - charge = cms.vdouble(3000, 3025, 3050, 3100, 3500, 6000, 10000, 15000, 20000, 30000), - delay = cms.vdouble(25.63, 23.63, 22.35, 20.65, 14.92, 6.7, 3.68, 2.29, 1.62, 1.02) - ) - ) - ) - ), + PixelDigitizerAlgorithm = PixelDigitizerAlgorithmCommon.clone(), #Pixel-3D Digitizer Algorithm - Pixel3DDigitizerAlgorithm = cms.PSet( - ElectronPerAdc = cms.double(600.0), - ReadoutNoiseInElec = cms.double(0.0), - ThresholdInElectrons_Barrel = cms.double(1200.0), - ThresholdInElectrons_Endcap = cms.double(1200.0), - AddThresholdSmearing = cms.bool(False), - ThresholdSmearing_Barrel = cms.double(0.0), - ThresholdSmearing_Endcap = cms.double(0.0), - HIPThresholdInElectrons_Barrel = cms.double(1.0e10), # very high value to avoid Over threshold bit - HIPThresholdInElectrons_Endcap = cms.double(1.0e10), # very high value to avoid Over threshold bit - NoiseInElectrons = cms.double(0.0), - Phase2ReadoutMode = cms.int32(-1), # Flag to decide Readout Mode :Digital(0) or Analog (linear TDR (-1), dual slope with slope parameters (+1,+2,+3,+4) with threshold subtraction - AdcFullScale = cms.int32(15), - TofUpperCut = cms.double(12.5), - TofLowerCut = cms.double(-12.5), - AddNoisyPixels = cms.bool(False), - Alpha2Order = cms.bool(True), #D.B.: second order effect, does not switch off magnetic field as described - AddNoise = cms.bool(False), - AddXTalk = cms.bool(False), #D.B. - InterstripCoupling = cms.double(0.0), #D.B. # No need to be used in PixelDigitizerAlgorithm - Odd_row_interchannelCoupling_next_row = cms.double(0.20), - Even_row_interchannelCoupling_next_row = cms.double(0.0), - Odd_column_interchannelCoupling_next_column = cms.double(0.0), - Even_column_interchannelCoupling_next_column = cms.double(0.0), - SigmaZero = cms.double(0.00037), #D.B.: 3.7um spread for 300um-thick sensor, renormalized in digitizerAlgo - SigmaCoeff = cms.double(1.80), #D.B.: to be confirmed with simulations in CMSSW_6.X - ClusterWidth = cms.double(3), #D.B.: this is used as number of sigmas for charge collection (3=+-3sigmas) - LorentzAngle_DB = cms.bool(True), - TanLorentzAnglePerTesla_Endcap = cms.double(0.106), - TanLorentzAnglePerTesla_Barrel = cms.double(0.106), - KillModules = cms.bool(False), - DeadModules_DB = cms.bool(False), - DeadModules = cms.VPSet(), - AddInefficiency = cms.bool(False), - Inefficiency_DB = cms.bool(False), - EfficiencyFactors_Barrel = cms.vdouble(0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999 ), - EfficiencyFactors_Endcap = cms.vdouble(0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, - 0.999, 0.999 ),#Efficiencies kept as Side2Disk1,Side1Disk1 and so on - CellsToKill = cms.VPSet() - ), + Pixel3DDigitizerAlgorithm = PixelDigitizerAlgorithmCommon.clone(SigmaCoeff = cms.double(1.80)), #Pixel in PS Module PSPDigitizerAlgorithm = cms.PSet( ElectronPerAdc = cms.double(135.0), @@ -258,11 +221,6 @@ AddInefficiency = False, AddThresholdSmearing = False, ), - Pixel3DDigitizerAlgorithm = dict( - AddNoisyPixels = False, - AddInefficiency = False, - AddThresholdSmearing = False, - ), PSPDigitizerAlgorithm = dict( AddNoisyPixels = False, AddInefficiency = False, From 3e7b97d5cd171d7b1f9abb2eda225e47112707df Mon Sep 17 00:00:00 2001 From: Suchandra Date: Tue, 7 Jul 2020 18:36:49 +0200 Subject: [PATCH 2/5] after code-checks and code-format --- .../plugins/DigitizerUtility.h | 1 + .../plugins/PSPDigitizerAlgorithm.cc | 4 +- .../Phase2TrackerDigitizerAlgorithm.cc | 39 +++++++++---------- .../plugins/Phase2TrackerDigitizerAlgorithm.h | 28 ++++++------- .../plugins/Pixel3DDigitizerAlgorithm.cc | 3 +- .../plugins/Pixel3DDigitizerAlgorithm.h | 20 +++++----- .../plugins/PixelDigitizerAlgorithm.cc | 4 +- .../plugins/SSDigitizerAlgorithm.cc | 6 +-- 8 files changed, 54 insertions(+), 51 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/DigitizerUtility.h b/SimTracker/SiPhase2Digitizer/plugins/DigitizerUtility.h index c473e93a732a9..8a2d511e79778 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/DigitizerUtility.h +++ b/SimTracker/SiPhase2Digitizer/plugins/DigitizerUtility.h @@ -60,6 +60,7 @@ namespace DigitizerUtility { void set(const float amplitude) { // Used to reset the amplitude _amp = amplitude; } + private: float _amp; std::vector > > _simInfoList; diff --git a/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.cc index aa51d09f4ad6a..a7aabb87750c1 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.cc @@ -37,6 +37,8 @@ bool PSPDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& // // -- Compare Signal with Threshold // -bool PSPDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const { +bool PSPDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, + float charge, + float thr) const { return (charge >= thr); } diff --git a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc index d7d70af06bfc6..d4e8fe77a600f 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc @@ -50,7 +50,7 @@ namespace { auto xx = std::min(0.5f * x * x, 12.5f); return 0.5 * (1.0 - std::copysign(std::sqrt(1.f - unsafe_expf<4>(-xx * (1.f + 0.2733f / (1.f + 0.147f * xx)))), x)); } -} +} // namespace Phase2TrackerDigitizerAlgorithm::Phase2TrackerDigitizerAlgorithm(const edm::ParameterSet& conf_common, const edm::ParameterSet& conf_specific) : _signal(), @@ -181,11 +181,11 @@ Phase2TrackerDigitizerAlgorithm::SubdetEfficiencies::SubdetEfficiencies(const ed endcap_efficiencies = conf.getParameter >("EfficiencyFactors_Endcap"); } void Phase2TrackerDigitizerAlgorithm::accumulateSimHits(std::vector::const_iterator inputBegin, - std::vector::const_iterator inputEnd, - const size_t inputBeginGlobalIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield) { + std::vector::const_iterator inputEnd, + const size_t inputBeginGlobalIndex, + const uint32_t tofBin, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield) { // produce SignalPoint's for all SimHit's in detector // Loop over hits uint32_t detId = pixdet->geographicalId().rawId(); @@ -199,8 +199,8 @@ void Phase2TrackerDigitizerAlgorithm::accumulateSimHits(std::vector::co // loop over a much reduced set of SimHits for (auto const& hit : matchedSimHits) { LogDebug("Phase2DigitizerAlgorithm") << hit.particleType() << " " << hit.pabs() << " " << hit.energyLoss() << " " - << hit.tof() << " " << hit.trackId() << " " << hit.processType() << " " - << hit.detUnitId() << hit.entryPoint() << " " << hit.exitPoint(); + << hit.tof() << " " << hit.trackId() << " " << hit.processType() << " " + << hit.detUnitId() << hit.entryPoint() << " " << hit.exitPoint(); double signalScale = 1.0; // fill collection_points for this SimHit, indpendent of topology if (select_hit(hit, (pixdet->surface().toGlobal(hit.localPosition()).mag() * c_inv), signalScale)) { @@ -222,7 +222,8 @@ void Phase2TrackerDigitizerAlgorithm::accumulateSimHits(std::vector::co // Divide the track into small sub-segments // // ================================================================= -std::vector Phase2TrackerDigitizerAlgorithm::primary_ionization(const PSimHit& hit) const { +std::vector Phase2TrackerDigitizerAlgorithm::primary_ionization( + const PSimHit& hit) const { // Straight line approximation for trajectory inside active media constexpr float SegmentLength = 0.0010; // in cm (10 microns) // Get the 3D segment direction vector @@ -244,8 +245,7 @@ std::vector Phase2TrackerDigitizerAlgorithm if (fluctuateCharge_) { // Generate fluctuated charge points elossVector = fluctuateEloss(hit.particleType(), hit.pabs(), eLoss, length, NumberOfSegments); - } - else { + } else { float averageEloss = eLoss / NumberOfSegments; std::fill(std::begin(elossVector), std::end(elossVector), averageEloss); } @@ -271,11 +271,8 @@ std::vector Phase2TrackerDigitizerAlgorithm // Use the G4 routine. For mip pions for the moment. // //============================================================================== -std::vector Phase2TrackerDigitizerAlgorithm::fluctuateEloss(int pid, - float particleMomentum, - float eloss, - float length, - int NumberOfSegs) const { +std::vector Phase2TrackerDigitizerAlgorithm::fluctuateEloss( + int pid, float particleMomentum, float eloss, float length, int NumberOfSegs) const { double particleMass = ::m_pion; // Mass in MeV, assume pion pid = std::abs(pid); if (pid != 211) { // Mass in MeV @@ -333,11 +330,11 @@ std::vector Phase2TrackerDigitizerAlgorithm::fluctuateEloss(int pid, // Include the effect of E-field and B-field // // ===================================================================== -std::vector -Phase2TrackerDigitizerAlgorithm::drift(const PSimHit& hit, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield, - const std::vector& ionization_points) const { +std::vector Phase2TrackerDigitizerAlgorithm::drift( + const PSimHit& hit, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield, + const std::vector& ionization_points) const { LogDebug("Phase2TrackerDigitizerAlgorithm") << "enter drift "; std::vector collection_points; diff --git a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h index 7beb79532e03d..6168569d17c4f 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h @@ -75,7 +75,9 @@ class Phase2TrackerDigitizerAlgorithm { std::map& digi_map, const TrackerTopology* tTopo); virtual bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) const { return true; } - virtual bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const { return true; } + virtual bool isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const { + return true; + } // For premixing void loadAccumulator(uint32_t detId, const std::map& accumulator); @@ -182,20 +184,18 @@ class Phase2TrackerDigitizerAlgorithm { //-- additional member functions // Private methods virtual std::vector primary_ionization(const PSimHit& hit) const; - virtual std::vector drift(const PSimHit& hit, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield, - const std::vector& ionization_points) const; + virtual std::vector drift( + const PSimHit& hit, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield, + const std::vector& ionization_points) const; virtual void induce_signal(const PSimHit& hit, - const size_t hitIndex, - const uint32_t tofBin, - const Phase2TrackerGeomDetUnit* pixdet, - const std::vector& collection_points); - virtual std::vector fluctuateEloss(int particleId, - float momentum, - float eloss, - float length, - int NumberOfSegments) const; + const size_t hitIndex, + const uint32_t tofBin, + const Phase2TrackerGeomDetUnit* pixdet, + const std::vector& collection_points); + virtual std::vector fluctuateEloss( + int particleId, float momentum, float eloss, float length, int NumberOfSegments) const; virtual void add_noise(const Phase2TrackerGeomDetUnit* pixdet); virtual void add_cross_talk(const Phase2TrackerGeomDetUnit* pixdet); virtual void add_noisy_cells(const Phase2TrackerGeomDetUnit* pixdet, float thePixelThreshold); diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index fc31f3a577b6c..2640c7b118498 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -215,8 +215,7 @@ std::vector Pixel3DDigitizerAlgorithm::drift( const PSimHit& hit, const Phase2TrackerGeomDetUnit* pixdet, const GlobalVector& bfield, - const std::vector& ionization_points) const -{ + const std::vector& ionization_points) const { return drift(hit, pixdet, bfield, ionization_points, true); } std::vector Pixel3DDigitizerAlgorithm::drift( diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h index 8f6aae91e8158..98685ffd70b93 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h @@ -28,16 +28,18 @@ class Pixel3DDigitizerAlgorithm : public Phase2TrackerDigitizerAlgorithm { // initialization that cannot be done in the constructor void init(const edm::EventSetup& es) override; bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) const override; - std::vector drift(const PSimHit& hit, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield, - const std::vector& ionization_points) const override; + std::vector drift( + const PSimHit& hit, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield, + const std::vector& ionization_points) const override; // overload drift - std::vector drift(const PSimHit& hit, - const Phase2TrackerGeomDetUnit* pixdet, - const GlobalVector& bfield, - const std::vector& ionization_points, - bool diffusion_activated) const; + std::vector drift( + const PSimHit& hit, + const Phase2TrackerGeomDetUnit* pixdet, + const GlobalVector& bfield, + const std::vector& ionization_points, + bool diffusion_activated) const; // New diffusion function: check implementation std::vector diffusion(const LocalPoint& pos, diff --git a/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc index 9eb89e3c02369..1b4989ec2470d 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc @@ -227,7 +227,9 @@ std::size_t PixelDigitizerAlgorithm::TimewalkModel::find_closest_index(const std // // -- Compare Signal with Threshold // -bool PixelDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const { +bool PixelDigitizerAlgorithm::isAboveThreshold(const DigitizerUtility::SimHitInfo* hitInfo, + float charge, + float thr) const { if (charge < thr) return false; if (apply_timewalk_ && hitInfo) { diff --git a/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.cc index e7b54a8f810d5..05ba921db0df7 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/SSDigitizerAlgorithm.cc @@ -17,14 +17,14 @@ using namespace edm; namespace { double nFactorial(int n); double aScalingConstant(int N, int i); -} +} // namespace namespace { double nFactorial(int n) { return std::tgamma(n + 1); } double aScalingConstant(int N, int i) { return std::pow(-1, (double)i) * nFactorial(N) * nFactorial(N + 2) / - (nFactorial(N - i) * nFactorial(N + 2 - i) * nFactorial(i)); + (nFactorial(N - i) * nFactorial(N + 2 - i) * nFactorial(i)); } -} +} // namespace void SSDigitizerAlgorithm::init(const edm::EventSetup& es) { es.get().get(geom_); } SSDigitizerAlgorithm::SSDigitizerAlgorithm(const edm::ParameterSet& conf) : Phase2TrackerDigitizerAlgorithm(conf.getParameter("AlgorithmCommon"), From 1100288a1dbcdf80f1af4edf9bcc804c9e71594d Mon Sep 17 00:00:00 2001 From: Suchandra Date: Wed, 8 Jul 2020 07:21:24 +0200 Subject: [PATCH 3/5] Suggestions from experts incorporated --- .../Phase2TrackerDigitizerAlgorithm.cc | 20 ++++++++++--------- .../python/phase2TrackerDigitizer_cfi.py | 5 +++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc index d4e8fe77a600f..433d070c19bfe 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc @@ -45,10 +45,14 @@ namespace { constexpr double m_proton = 938.272; double calcQ(float x); } // namespace -namespace { +namespace { double calcQ(float x) { - auto xx = std::min(0.5f * x * x, 12.5f); - return 0.5 * (1.0 - std::copysign(std::sqrt(1.f - unsafe_expf<4>(-xx * (1.f + 0.2733f / (1.f + 0.147f * xx)))), x)); + constexpr float p1 = 12.5f; + constexpr float p2 = 0.2733f; + constexpr float p3 = 0.147f; + + auto xx = std::min(0.5f * x * x, p1); + return 0.5f * (1.f - std::copysign(std::sqrt(1.f - unsafe_expf<4>(-xx * (1.f + p2 / (1.f + p3 * xx)))), x)); } } // namespace Phase2TrackerDigitizerAlgorithm::Phase2TrackerDigitizerAlgorithm(const edm::ParameterSet& conf_common, @@ -204,10 +208,10 @@ void Phase2TrackerDigitizerAlgorithm::accumulateSimHits(std::vector::co double signalScale = 1.0; // fill collection_points for this SimHit, indpendent of topology if (select_hit(hit, (pixdet->surface().toGlobal(hit.localPosition()).mag() * c_inv), signalScale)) { - const auto ionization_points = primary_ionization(hit); // fills ionization_points + const auto& ionization_points = primary_ionization(hit); // fills ionization_points // transforms ionization_points -> collection_points - const auto collection_points = drift(hit, pixdet, bfield, ionization_points); + const auto& collection_points = drift(hit, pixdet, bfield, ionization_points); // compute induced signal on readout elements and add to _signal // hit needed only for SimHit<-->Digi link @@ -247,7 +251,7 @@ std::vector Phase2TrackerDigitizerAlgorithm elossVector = fluctuateEloss(hit.particleType(), hit.pabs(), eLoss, length, NumberOfSegments); } else { float averageEloss = eLoss / NumberOfSegments; - std::fill(std::begin(elossVector), std::end(elossVector), averageEloss); + elossVector.resize(NumberOfSegments, averageEloss); } std::vector ionization_points; @@ -294,8 +298,6 @@ std::vector Phase2TrackerDigitizerAlgorithm::fluctuateEloss( std::vector elossVector; elossVector.reserve(NumberOfSegs); for (int i = 0; i < NumberOfSegs; ++i) { - // material,*, momentum,energy,*, *, mass - // myglandz_(14.,segmentLength,2.,2.,dedx,de,0.14); // The G4 routine needs momentum in MeV, mass in Mev, delta-cut in MeV, // track segment length in mm, segment eloss in MeV // Returns fluctuated eloss in MeV @@ -319,7 +321,7 @@ std::vector Phase2TrackerDigitizerAlgorithm::fluctuateEloss( }); // use a simple lambda expression } else { // if fluctuations gives 0 eloss float averageEloss = eloss / NumberOfSegs; - std::fill(std::begin(elossVector), std::end(elossVector), averageEloss); + elossVector.resize(NumberOfSegs, averageEloss); } return elossVector; } diff --git a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py index 608be21b50fb1..feb9987c188d4 100644 --- a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py +++ b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py @@ -221,6 +221,11 @@ AddInefficiency = False, AddThresholdSmearing = False, ), + Pixel3DDigitizerAlgorithm = dict( + AddNoisyPixels = False, + AddInefficiency = False, + AddThresholdSmearing = False, + ), PSPDigitizerAlgorithm = dict( AddNoisyPixels = False, AddInefficiency = False, From 244d8830d032ddac466cee354363c6113aaeeb58 Mon Sep 17 00:00:00 2001 From: Suchandra Date: Wed, 8 Jul 2020 08:32:23 +0200 Subject: [PATCH 4/5] return type of Phase2TrackerDigitizerAlgorithm::calcQ changed from double to float --- .../plugins/Phase2TrackerDigitizerAlgorithm.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc index 433d070c19bfe..27082f9125c3c 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc @@ -43,10 +43,10 @@ namespace { constexpr double m_electron = 0.511; constexpr double m_muon = 105.658; constexpr double m_proton = 938.272; - double calcQ(float x); + float calcQ(float x); } // namespace namespace { - double calcQ(float x) { + float calcQ(float x) { constexpr float p1 = 12.5f; constexpr float p2 = 0.2733f; constexpr float p3 = 0.147f; From 3de577a441d73304b64fdb641c618c0cc68e15a0 Mon Sep 17 00:00:00 2001 From: Suchandra Date: Fri, 10 Jul 2020 20:04:30 +0200 Subject: [PATCH 5/5] applied code-format --- .../plugins/Phase2TrackerDigitizerAlgorithm.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc index 27082f9125c3c..0d302248815d8 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc @@ -45,11 +45,11 @@ namespace { constexpr double m_proton = 938.272; float calcQ(float x); } // namespace -namespace { +namespace { float calcQ(float x) { constexpr float p1 = 12.5f; - constexpr float p2 = 0.2733f; - constexpr float p3 = 0.147f; + constexpr float p2 = 0.2733f; + constexpr float p3 = 0.147f; auto xx = std::min(0.5f * x * x, p1); return 0.5f * (1.f - std::copysign(std::sqrt(1.f - unsafe_expf<4>(-xx * (1.f + p2 / (1.f + p3 * xx)))), x));