diff --git a/SimTracker/Common/interface/SiPixelChargeReweightingAlgorithm.h b/SimTracker/Common/interface/SiPixelChargeReweightingAlgorithm.h index 1676e8a4220b9..612107da76d9f 100644 --- a/SimTracker/Common/interface/SiPixelChargeReweightingAlgorithm.h +++ b/SimTracker/Common/interface/SiPixelChargeReweightingAlgorithm.h @@ -3,8 +3,8 @@ // Original Author Caroline Collard // September 2020 : Extraction of the code for cluster charge reweighting from SiPixelDigitizerAlgorithm to a new class +// Jan 2023: Generalize so it can be used for Phase-2 IT as well (M. Musich, T.A. Vami) -// forward declarations #include #include #include @@ -56,10 +56,8 @@ class SiPixelChargeReweightingAlgorithm { // initialization that cannot be done in the constructor void init(const edm::EventSetup& es); - typedef std::map > signal_map_type; // from Digi.Skel. - typedef signal_map_type::iterator signal_map_iterator; // from Digi.Skel. - typedef signal_map_type::const_iterator signal_map_const_iterator; // from Digi.Skel. - + // template this so it can be used for Phase-2 as well + template bool hitSignalReweight(const PSimHit& hit, std::map >& hit_signal, const size_t hitIndex, @@ -67,20 +65,20 @@ class SiPixelChargeReweightingAlgorithm { const unsigned int tofBin, const PixelTopology* topol, uint32_t detID, - signal_map_type& theSignal, + SignalType& theSignal, unsigned short int processType, const bool& boolmakeDigiSimLinks); + template bool lateSignalReweight(const PixelGeomDetUnit* pixdet, std::vector& digis, PixelSimHitExtraInfo& loopTempSH, - signal_map_type& theNewDigiSignal, + SignalType& theNewDigiSignal, const TrackerTopology* tTopo, CLHEP::HepRandomEngine* engine); private: // Internal typedef - typedef std::map signalMaps; typedef GloballyPositioned Frame; typedef std::vector Parameters; typedef boost::multi_array array_2d; @@ -125,6 +123,7 @@ inline void SiPixelChargeReweightingAlgorithm::init(const edm::EventSetup& es) { SiPixelTemplate2D::pushfile(*dbobject_num, templateStores_); track.resize(6); + LogDebug("SiPixelChargeReweightingAlgorithm") << "Init SiPixelChargeReweightingAlgorithm"; } } @@ -143,34 +142,34 @@ inline SiPixelChargeReweightingAlgorithm::SiPixelChargeReweightingAlgorithm(cons UseReweighting(conf.getParameter("UseReweighting")), applyLateReweighting_(conf.exists("applyLateReweighting") ? conf.getParameter("applyLateReweighting") : false), - PrintClusters(conf.getParameter("PrintClusters")), - PrintTemplates(conf.getParameter("PrintTemplates")) { + PrintClusters(conf.exists("PrintClusters") ? conf.getParameter("PrintClusters") : false), + PrintTemplates(conf.exists("PrintTemplates") ? conf.getParameter("PrintTemplates") : false) { if (UseReweighting || applyLateReweighting_) { SiPixel2DTemp_den_token_ = iC.esConsumes(edm::ESInputTag("", "denominator")); SiPixel2DTemp_num_token_ = iC.esConsumes(edm::ESInputTag("", "numerator")); } - edm::LogVerbatim("PixelDigitizer ") << "SiPixelChargeReweightingAlgorithm constructed" - << " with UseReweighting = " << UseReweighting - << " and applyLateReweighting_ = " << applyLateReweighting_; + LogDebug("SiPixelChargeReweightingAlgorithm") + << "SiPixelChargeReweightingAlgorithm constructed" + << " with UseReweighting = " << UseReweighting << " and applyLateReweighting_ = " << applyLateReweighting_; } //========================================================================= inline SiPixelChargeReweightingAlgorithm::~SiPixelChargeReweightingAlgorithm() { - LogDebug("PixelDigitizer") << "SiPixelChargeReweightingAlgorithm deleted"; + LogDebug("SiPixelChargeReweightingAlgorithm") << "SiPixelChargeReweightingAlgorithm deleted"; } //============================================================================ - -inline bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& hit, - std::map >& hit_signal, - const size_t hitIndex, - const size_t hitIndex4CR, - const unsigned int tofBin, - const PixelTopology* topol, - uint32_t detID, - signal_map_type& theSignal, - unsigned short int processType, - const bool& boolmakeDigiSimLinks) { +template +bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& hit, + std::map >& hit_signal, + const size_t hitIndex, + const size_t hitIndex4CR, + const unsigned int tofBin, + const PixelTopology* topol, + uint32_t detID, + SignalType& theSignal, + unsigned short int processType, + const bool& boolmakeDigiSimLinks) { int irow_min = topol->nrows(); int irow_max = 0; int icol_min = topol->ncolumns(); @@ -178,16 +177,19 @@ inline bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& float chargeBefore = 0; float chargeAfter = 0; - signal_map_type hitSignal; + SignalType hitSignal; LocalVector direction = hit.exitPoint() - hit.entryPoint(); for (std::map >::const_iterator im = hit_signal.begin(); im != hit_signal.end(); ++im) { int chan = (*im).first; std::pair pixelWithCharge = PixelDigi::channelToPixel(chan); - - hitSignal[chan] += (boolmakeDigiSimLinks ? digitizerUtility::Amplitude( - (*im).second, &hit, hitIndex, hitIndex4CR, tofBin, (*im).second) - : digitizerUtility::Amplitude((*im).second, (*im).second)); + if constexpr (std::is_same_v) { + hitSignal[chan] += AmplitudeType((*im).second, &hit, (*im).second, 0., hitIndex, tofBin); + } else { + hitSignal[chan] += + (boolmakeDigiSimLinks ? AmplitudeType((*im).second, &hit, hitIndex, hitIndex4CR, tofBin, (*im).second) + : AmplitudeType((*im).second, (*im).second)); + } chargeBefore += (*im).second; if (pixelWithCharge.first < irow_min) @@ -237,45 +239,40 @@ inline bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& hitcol_max = exitPixel.second; } -#ifdef TP_DEBUG LocalPoint CMSSWhitPosition = hit.localPosition(); - - LogDebug("Pixel Digitizer") << "\n" - << "Particle ID is: " << hit.particleType() << "\n" - << "Process type: " << hit.processType() << "\n" - << "HitPosition:" - << "\n" - << "Hit entry x/y/z: " << hit.entryPoint().x() << " " << hit.entryPoint().y() << " " - << hit.entryPoint().z() << " " - << "Hit exit x/y/z: " << hit.exitPoint().x() << " " << hit.exitPoint().y() << " " - << hit.exitPoint().z() << " " - - << "Pixel Pos - X: " << hitPositionPixel.x() << " Y: " << hitPositionPixel.y() << "\n" - << "Cart.Cor. - X: " << CMSSWhitPosition.x() << " Y: " << CMSSWhitPosition.y() << "\n" - << "Z=0 Pos - X: " << hitPosition.x() << " Y: " << hitPosition.y() << "\n" - - << "Origin of the template:" - << "\n" - << "Pixel Pos - X: " << originPixel.x() << " Y: " << originPixel.y() << "\n" - << "Cart.Cor. - X: " << origin.x() << " Y: " << origin.y() << "\n" - << "\n" - << "Entry/Exit:" - << "\n" - << "Entry - X: " << hit.entryPoint().x() << " Y: " << hit.entryPoint().y() - << " Z: " << hit.entryPoint().z() << "\n" - << "Exit - X: " << hit.exitPoint().x() << " Y: " << hit.exitPoint().y() - << " Z: " << hit.exitPoint().z() << "\n" - - << "Entry - X Pixel: " << hitEntryPointPixel.x() << " Y Pixel: " << hitEntryPointPixel.y() - << "\n" - << "Exit - X Pixel: " << hitExitPointPixel.x() << " Y Pixel: " << hitExitPointPixel.y() - << "\n" - - << "row min: " << irow_min << " col min: " << icol_min << "\n"; -#endif + LogDebug("SiPixelChargeReweightingAlgorithm") + << "\n" + << "Particle ID is: " << hit.particleType() << "\n" + << "Process type: " << hit.processType() << "\n" + << "HitPosition:" + << "\n" + << "Hit entry x/y/z: " << hit.entryPoint().x() << " " << hit.entryPoint().y() << " " << hit.entryPoint().z() + << " " + << "Hit exit x/y/z: " << hit.exitPoint().x() << " " << hit.exitPoint().y() << " " << hit.exitPoint().z() << " " + + << "Pixel Pos - X: " << hitPositionPixel.x() << " Y: " << hitPositionPixel.y() << "\n" + << "Cart.Cor. - X: " << CMSSWhitPosition.x() << " Y: " << CMSSWhitPosition.y() << "\n" + << "Z=0 Pos - X: " << hitPosition.x() << " Y: " << hitPosition.y() << "\n" + + << "Origin of the template:" + << "\n" + << "Pixel Pos - X: " << originPixel.x() << " Y: " << originPixel.y() << "\n" + << "Cart.Cor. - X: " << origin.x() << " Y: " << origin.y() << "\n" + << "\n" + << "Entry/Exit:" + << "\n" + << "Entry - X: " << hit.entryPoint().x() << " Y: " << hit.entryPoint().y() << " Z: " << hit.entryPoint().z() + << "\n" + << "Exit - X: " << hit.exitPoint().x() << " Y: " << hit.exitPoint().y() << " Z: " << hit.exitPoint().z() << "\n" + + << "Entry - X Pixel: " << hitEntryPointPixel.x() << " Y Pixel: " << hitEntryPointPixel.y() << "\n" + << "Exit - X Pixel: " << hitExitPointPixel.x() << " Y Pixel: " << hitExitPointPixel.y() << "\n" + + << "row min: " << irow_min << " col min: " << icol_min << "\n"; 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 + LogDebug("SiPixelChargeReweightingAlgorithm") << "Outside the row/col boundary, exit charge reweighting"; return false; } @@ -286,6 +283,7 @@ inline bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& track[4] = direction.y(); track[5] = direction.z(); + LogDebug("SiPixelChargeReweightingAlgorithm") << "Init array of size x = " << TXSIZE << " and y = " << TYSIZE; array_2d pixrewgt(boost::extents[TXSIZE][TYSIZE]); for (int row = 0; row < TXSIZE; ++row) { @@ -318,7 +316,7 @@ inline bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& } if (PrintClusters) { - LogDebug("PixelDigitizer ") << "Cluster before reweighting: "; + LogDebug("SiPixelChargeReweightingAlgorithm ") << "Cluster before reweighting: "; printCluster(pixrewgt); } @@ -337,14 +335,12 @@ inline bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& ierr = PixelTempRewgt2D(IDden, IDden, pixrewgt); } if (ierr != 0) { -#ifdef TP_DEBUG - LogDebug("PixelDigitizer ") << "Cluster Charge Reweighting did not work properly."; -#endif + LogDebug("SiPixelChargeReweightingAlgorithm ") << "Cluster Charge Reweighting did not work properly."; return false; } if (PrintClusters) { - LogDebug("PixelDigitizer ") << "Cluster after reweighting: "; + LogDebug("SiPixelChargeReweightingAlgorithm ") << "Cluster after reweighting: "; printCluster(pixrewgt); } @@ -353,9 +349,14 @@ inline bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& float charge = pixrewgt[row][col]; if (charge > 0) { chargeAfter += charge; - theSignal[PixelDigi::pixelToChannel(hitPixel.first + row - THX, hitPixel.second + col - THY)] += - (boolmakeDigiSimLinks ? digitizerUtility::Amplitude(charge, &hit, hitIndex, hitIndex4CR, tofBin, charge) - : digitizerUtility::Amplitude(charge, charge)); + if constexpr (std::is_same_v) { + theSignal[PixelDigi::pixelToChannel(hitPixel.first + row - THX, hitPixel.second + col - THY)] += + AmplitudeType(charge, &hit, charge, 0., hitIndex, tofBin); + } else { + theSignal[PixelDigi::pixelToChannel(hitPixel.first + row - THX, hitPixel.second + col - THY)] += + (boolmakeDigiSimLinks ? AmplitudeType(charge, &hit, hitIndex, hitIndex4CR, tofBin, charge) + : AmplitudeType(charge, charge)); + } } } } @@ -365,8 +366,10 @@ inline bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& } if (PrintClusters) { - LogDebug("PixelDigitizer ") << "Charges (before->after): " << chargeBefore << " -> " << chargeAfter; - LogDebug("PixelDigitizer ") << "Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 << " % \n"; + LogDebug("SiPixelChargeReweightingAlgorithm ") + << "Charges (before->after): " << chargeBefore << " -> " << chargeAfter; + LogDebug("SiPixelChargeReweightingAlgorithm ") + << "Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 << " % \n"; } return true; @@ -407,7 +410,7 @@ inline int SiPixelChargeReweightingAlgorithm::PixelTempRewgt2D(int id_in, int id cotalpha = track[3] / track[5]; //if track[5] (direction in z) is 0 the hit is not processed by re-weighting cotbeta = track[4] / track[5]; } else { - LogDebug("Pixel Digitizer") << "Reweighting angle is not good! \n"; + LogDebug("SiPixelChargeReweightingAlgorithm") << "Reweighting angle is not good! \n"; return 9; //returned value here indicates that no reweighting was done in this case } @@ -437,14 +440,12 @@ inline int SiPixelChargeReweightingAlgorithm::PixelTempRewgt2D(int id_in, int id success = 1; } if (success != 0) { -#ifdef TP_DEBUG - LogDebug("Pixel Digitizer") << "No matching template found \n"; -#endif + LogDebug("SiPixelChargeReweightingAlgorithm") << "No matching template found \n"; return 2; } if (PrintTemplates) { - LogDebug("Pixel Digitizer") << "Template unirrad: \n"; + LogDebug("SiPixelChargeReweightingAlgorithm") << "Template unirrad: \n"; printCluster(xy_in); } @@ -455,18 +456,19 @@ inline int SiPixelChargeReweightingAlgorithm::PixelTempRewgt2D(int id_in, int id // Check that the cluster container is a 13x21 matrix if (cluster.num_dimensions() != 2) { - edm::LogWarning("Pixel Digitizer") << "Cluster is not 2-dimensional. Return. \n"; + edm::LogWarning("SiPixelChargeReweightingAlgorithm") << "Cluster is not 2-dimensional. Return. \n"; return 3; } nclusx = (int)cluster.shape()[0]; nclusy = (int)cluster.shape()[1]; if (nclusx != TXSIZE || xdouble.size() != TXSIZE) { - edm::LogWarning("Pixel Digitizer") << "Sizes in x do not match: nclusx=" << nclusx - << " xdoubleSize=" << xdouble.size() << " TXSIZE=" << TXSIZE << ". Return. \n"; + edm::LogWarning("SiPixelChargeReweightingAlgorithm") + << "Sizes in x do not match: nclusx=" << nclusx << " xdoubleSize=" << xdouble.size() << " TXSIZE=" << TXSIZE + << ". Return. \n"; return 4; } if (nclusy != TYSIZE || ydouble.size() != TYSIZE) { - edm::LogWarning("Pixel Digitizer") << "Sizes in y do not match. Return. \n"; + edm::LogWarning("SiPixelChargeReweightingAlgorithm") << "Sizes in y do not match. Return. \n"; return 5; } @@ -491,7 +493,7 @@ inline int SiPixelChargeReweightingAlgorithm::PixelTempRewgt2D(int id_in, int id } if (PrintTemplates) { - LogDebug("Pixel Digitizer") << "Template irrad: \n"; + LogDebug("SiPixelChargeReweightingAlgorithm") << "Template irrad: \n"; printCluster(xy_rewgt); } @@ -544,7 +546,7 @@ inline int SiPixelChargeReweightingAlgorithm::PixelTempRewgt2D(int id_in, int id } if (PrintTemplates) { - LogDebug("Pixel Digitizer") << "Weights: \n"; + LogDebug("SiPixelChargeReweightingAlgorithm") << "Weights: \n"; printCluster(xy_clust); } @@ -607,53 +609,54 @@ inline int SiPixelChargeReweightingAlgorithm::PixelTempRewgt2D(int id_in, int id inline void SiPixelChargeReweightingAlgorithm::printCluster(array_2d& cluster) { for (int col = 0; col < TYSIZE; ++col) { for (int row = 0; row < TXSIZE; ++row) { - LogDebug("Pixel Digitizer") << cluster[row][col]; + LogDebug("SiPixelChargeReweightingAlgorithm") << cluster[row][col]; } - LogDebug("Pixel Digitizer") << "\n"; + LogDebug("SiPixelChargeReweightingAlgorithm") << "\n"; } } inline void SiPixelChargeReweightingAlgorithm::printCluster(float arr[BXM2][BYM2]) { for (int col = 0; col < BYM2; ++col) { for (int row = 0; row < BXM2; ++row) { - LogDebug("Pixel Digitizer") << arr[row][col]; + LogDebug("SiPixelChargeReweightingAlgorithm") << arr[row][col]; } - LogDebug("Pixel Digitizer") << "\n"; + LogDebug("SiPixelChargeReweightingAlgorithm") << "\n"; } } inline void SiPixelChargeReweightingAlgorithm::printCluster(float arr[TXSIZE][TYSIZE]) { for (int col = 0; col < TYSIZE; ++col) { for (int row = 0; row < TXSIZE; ++row) { - LogDebug("Pixel Digitizer") << arr[row][col]; + LogDebug("SiPixelChargeReweightingAlgorithm") << arr[row][col]; } - LogDebug("Pixel Digitizer") << "\n"; + LogDebug("SiPixelChargeReweightingAlgorithm") << "\n"; } } -inline bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeomDetUnit* pixdet, - std::vector& digis, - PixelSimHitExtraInfo& loopTempSH, - signal_map_type& theNewDigiSignal, - const TrackerTopology* tTopo, - CLHEP::HepRandomEngine* engine) { +template +bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeomDetUnit* pixdet, + std::vector& digis, + PixelSimHitExtraInfo& loopTempSH, + SignalType& theNewDigiSignal, + const TrackerTopology* tTopo, + CLHEP::HepRandomEngine* engine) { uint32_t detID = pixdet->geographicalId().rawId(); const PixelTopology* topol = &pixdet->specificTopology(); if (UseReweighting) { - edm::LogError("Pixel Digitizer") << " ******************************** \n"; - edm::LogError("Pixel Digitizer") << " ******************************** \n"; - edm::LogError("Pixel Digitizer") << " ******************************** \n"; - edm::LogError("Pixel Digitizer") << " ***** INCONSISTENCY !!! ***** \n"; - edm::LogError("Pixel Digitizer") + 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("Pixel Digitizer") << " ---> DO NOT APPLY CHARGE REWEIGHTING TWICE !!! \n"; - edm::LogError("Pixel Digitizer") << " ******************************** \n"; - edm::LogError("Pixel Digitizer") << " ******************************** \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ---> DO NOT APPLY CHARGE REWEIGHTING TWICE !!! \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ******************************** \n"; + edm::LogError("SiPixelChargeReweightingAlgorithm") << " ******************************** \n"; return false; } - signal_map_type theDigiSignal; + SignalType theDigiSignal; int irow_min = topol->nrows(); int irow_max = 0; @@ -669,7 +672,13 @@ inline bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeo unsigned int chan = loopDigi->channel(); if (loopTempSH.isInTheList(chan)) { float corresponding_charge = loopDigi->adc(); - theDigiSignal[chan] += digitizerUtility::Amplitude(corresponding_charge, corresponding_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 { + theDigiSignal[chan] += AmplitudeType(corresponding_charge, corresponding_charge); + } chargeBefore += corresponding_charge; if (loopDigi->row() < irow_min) irow_min = loopDigi->row(); @@ -761,7 +770,7 @@ inline bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeo } if (PrintClusters) { - LogDebug("Pixel Digitizer") << " Cluster before reweighting: "; + LogDebug("SiPixelChargeReweightingAlgorithm") << " Cluster before reweighting: "; printCluster(pixrewgt); } @@ -772,18 +781,16 @@ inline bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeo int ID0 = dbobject_den->getTemplateID(detID); if (ID0 == ID1) { - LogDebug("Pixel Digitizer") << " same template for num and den "; + LogDebug("SiPixelChargeReweightingAlgorithm") << " same template for num and den "; return false; } ierr = PixelTempRewgt2D(ID0, ID1, pixrewgt); if (ierr != 0) { -#ifdef TP_DEBUG - LogDebug("PixelDigitizer ") << "Cluster Charge Reweighting did not work properly."; -#endif + edm::LogError("SiPixelChargeReweightingAlgorithm") << "Cluster Charge Reweighting did not work properly."; return false; } if (PrintClusters) { - LogDebug("Pixel Digitizer") << " Cluster after reweighting: "; + LogDebug("SiPixelChargeReweightingAlgorithm") << " Cluster after reweighting: "; printCluster(pixrewgt); } @@ -794,8 +801,14 @@ inline bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeo 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; - theNewDigiSignal[PixelDigi::pixelToChannel(hitPixel.first + row - THX, hitPixel.second + col - THY)] += - digitizerUtility::Amplitude(charge, 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); + } } } } @@ -805,14 +818,15 @@ inline bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeo } if (PrintClusters) { - LogDebug("Pixel Digitizer") << "Charges (before->after): " << chargeBefore << " -> " << chargeAfter; - LogDebug("Pixel Digitizer") << "Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 << " %"; + 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 (signal_map_const_iterator i = theDigiSignal.begin(); i != theDigiSignal.end(); ++i) { + for (auto& i : theDigiSignal) { // check if in the 21x13 box - int chanDigi = (*i).first; + int chanDigi = i.first; std::pair ip = PixelDigi::channelToPixel(chanDigi); int row_digi = ip.first; int col_digi = ip.second; @@ -820,8 +834,14 @@ inline bool SiPixelChargeReweightingAlgorithm::lateSignalReweight(const PixelGeo 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) { - theNewDigiSignal[chanDigi] += digitizerUtility::Amplitude((*i).second, (*i).second); + 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); + } } } } diff --git a/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.h index ab93663b6cd53..62e93ea9fef1a 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/PSPDigitizerAlgorithm.h @@ -1,5 +1,5 @@ -#ifndef _SimTracker_SiPhase2Digitizer_PSPDigitizerAlgorithm_h -#define _SimTracker_SiPhase2Digitizer_PSPDigitizerAlgorithm_h +#ifndef SimTracker_SiPhase2Digitizer_PSPDigitizerAlgorithm_h +#define SimTracker_SiPhase2Digitizer_PSPDigitizerAlgorithm_h #include "CondFormats/DataRecord/interface/SiPhase2OuterTrackerLorentzAngleRcd.h" #include "FWCore/Utilities/interface/ESGetToken.h" diff --git a/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.h index 4f50f78d4e1d2..9c4ba5f4caf8f 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.h @@ -1,5 +1,5 @@ -#ifndef _SimTracker_SiPhase2Digitizer_PSSDigitizerAlgorithm_h -#define _SimTracker_SiPhase2Digitizer_PSSDigitizerAlgorithm_h +#ifndef SimTracker_SiPhase2Digitizer_PSSDigitizerAlgorithm_h +#define SimTracker_SiPhase2Digitizer_PSSDigitizerAlgorithm_h #include "CondFormats/DataRecord/interface/SiPhase2OuterTrackerLorentzAngleRcd.h" #include "FWCore/Utilities/interface/ESGetToken.h" diff --git a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc index b5faea5938cdc..14ce0b25a2a37 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.cc @@ -1,35 +1,28 @@ -#include -#include #include - -#include "SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h" - -#include "SimGeneral/NoiseGenerators/interface/GaussianTailNoiseGenerator.h" -#include "SimTracker/Common/interface/SiG4UniversalFluctuation.h" +#include +#include #include "CLHEP/Random/RandGaussQ.h" - +#include "CalibTracker/SiPixelESProducers/interface/SiPixelGainCalibrationOfflineSimService.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/SiPhase2OuterTrackerLorentzAngle.h" +#include "CondFormats/SiPixelObjects/interface/GlobalPixel.h" +#include "CondFormats/SiPixelObjects/interface/LocalPixel.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelLorentzAngle.h" +#include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" - #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/Exception.h" -#include "CalibTracker/SiPixelESProducers/interface/SiPixelGainCalibrationOfflineSimService.h" - -#include "DataFormats/DetId/interface/DetId.h" -#include "CondFormats/SiPixelObjects/interface/GlobalPixel.h" -#include "CondFormats/SiPixelObjects/interface/SiPixelLorentzAngle.h" -#include "CondFormats/SiPixelObjects/interface/LocalPixel.h" -#include "CondFormats/SiPhase2TrackerObjects/interface/SiPhase2OuterTrackerLorentzAngle.h" - -// Geometry -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" -#include "Geometry/CommonTopologies/interface/PixelTopology.h" #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonTopologies/interface/PixelTopology.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "SimGeneral/NoiseGenerators/interface/GaussianTailNoiseGenerator.h" +#include "SimTracker/Common/interface/SiG4UniversalFluctuation.h" +#include "SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h" using namespace edm; @@ -41,6 +34,7 @@ namespace ph2tkdigialgo { constexpr double m_muon = 105.658; constexpr double m_proton = 938.272; } // namespace ph2tkdigialgo + Phase2TrackerDigitizerAlgorithm::Phase2TrackerDigitizerAlgorithm(const edm::ParameterSet& conf_common, const edm::ParameterSet& conf_specific, edm::ConsumesCollector iC) @@ -140,6 +134,10 @@ Phase2TrackerDigitizerAlgorithm::Phase2TrackerDigitizerAlgorithm(const edm::Para pseudoRadDamageRadius_(conf_specific.exists("PseudoRadDamageRadius") ? conf_specific.getParameter("PseudoRadDamageRadius") : double(0.0)), + // Add pixel radiation damage + useChargeReweighting_(conf_specific.getParameter("UseReweighting")), + theSiPixelChargeReweightingAlgorithm_( + useChargeReweighting_ ? std::make_unique(conf_specific, iC) : nullptr), // delta cutoff in MeV, has to be same as in OSCAR(0.030/cmsim=1.0 MeV // tMax(0.030), // In MeV. @@ -171,6 +169,7 @@ 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, @@ -202,7 +201,8 @@ void Phase2TrackerDigitizerAlgorithm::accumulateSimHits(std::vector::co // 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); + induce_signal(inputBegin, hit, simHitGlobalIndex, inputBeginGlobalIndex, tofBin, pixdet, collection_points); + LogDebug("Phase2DigitizerAlgorithm") << "Induced signal was computed"; } ++simHitGlobalIndex; } @@ -252,7 +252,8 @@ std::vector Phase2TrackerDigitizerAlgorithm 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(); + << "For index = " << i << " EnergyDepositUnit-x = " << edu.x() << " EnergyDepositUnit-y = " << edu.y() + << " EnergyDepositUnit-z = " << edu.z() << " EnergyDepositUnit-energy = " << edu.energy(); } return ionization_points; } @@ -324,11 +325,11 @@ std::vector Phase2TrackerDigitizerAlgorithm::drif const Phase2TrackerGeomDetUnit* pixdet, const GlobalVector& bfield, const std::vector& ionization_points) const { - LogDebug("Phase2TrackerDigitizerAlgorithm") << "enter drift "; + 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 + 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 collection_points; @@ -348,8 +349,9 @@ std::vector Phase2TrackerDigitizerAlgorithm::drif float stripPitch = pixdet->specificTopology().pitch().first; LogDebug("Phase2TrackerDigitizerAlgorithm") - << " Lorentz Tan " << TanLorenzAngleX << " " << TanLorenzAngleY << " " << CosLorenzAngleX << " " - << CosLorenzAngleY << " " << moduleThickness * TanLorenzAngleX << " " << driftDir; + << " Lorentz Tan-X " << TanLorenzAngleX << " Lorentz Tan-Y " << TanLorenzAngleY << " Lorentz Cos-X " + << CosLorenzAngleX << " Lorentz Cos-Y " << CosLorenzAngleY + << " ticknes * Lorentz Tan-X = " << moduleThickness * TanLorenzAngleX << " drift direction " << driftDir; for (auto const& val : ionization_points) { // position @@ -418,8 +420,10 @@ std::vector Phase2TrackerDigitizerAlgorithm::drif // // Induce the signal on the collection plane of the active sensor area. void Phase2TrackerDigitizerAlgorithm::induce_signal( + std::vector::const_iterator inputBegin, const PSimHit& hit, const size_t hitIndex, + const size_t firstHitIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit* pixdet, const std::vector& collection_points) { @@ -430,7 +434,7 @@ void Phase2TrackerDigitizerAlgorithm::induce_signal( signal_map_type& theSignal = _signal[detID]; LogDebug("Phase2TrackerDigitizerAlgorithm") - << " enter induce_signal, " << topol->pitch().first << " " << topol->pitch().second; + << "Enter induce_signal, Pitch size is " << topol->pitch().first << " cm vs " << topol->pitch().second << " cm"; // local map to store pixels hit by 1 Hit. using hit_map_type = std::map >; @@ -563,14 +567,51 @@ void Phase2TrackerDigitizerAlgorithm::induce_signal( } } // Fill the global map with all hit pixels from this event + bool reweighted = false; + size_t referenceIndex4CR = 0; + + if (useChargeReweighting_) { + if (hit.processType() == 0) { + referenceIndex4CR = hitIndex; + reweighted = + theSiPixelChargeReweightingAlgorithm_->hitSignalReweight(hit, + hit_signal, + hitIndex, + referenceIndex4CR, + tofBin, + topol, + detID, + theSignal, + hit.processType(), + makeDigiSimLinks_); + } else { + // If it's not the primary particle, use the first hit in the collection as SimHit, which should be the corresponding primary. + referenceIndex4CR = firstHitIndex; + reweighted = + theSiPixelChargeReweightingAlgorithm_->hitSignalReweight((*inputBegin), + hit_signal, + hitIndex, + referenceIndex4CR, + tofBin, + topol, + detID, + theSignal, + hit.processType(), + makeDigiSimLinks_); + } + } + float corr_time = hit.tof() - pixdet->surface().toGlobal(hit.localPosition()).mag() * c_inv; - for (auto const& hit_s : hit_signal) { - int chan = hit_s.first; - theSignal[chan] += (makeDigiSimLinks_ ? digitizerUtility::Ph2Amplitude( - hit_s.second, &hit, hit_s.second, corr_time, hitIndex, tofBin) - : digitizerUtility::Ph2Amplitude(hit_s.second, nullptr, hit_s.second)); + if (!reweighted) { + for (auto const& hit_s : hit_signal) { + int chan = hit_s.first; + theSignal[chan] += (makeDigiSimLinks_ ? digitizerUtility::Ph2Amplitude( + hit_s.second, &hit, hit_s.second, corr_time, hitIndex, tofBin) + : digitizerUtility::Ph2Amplitude(hit_s.second, nullptr, hit_s.second)); + } } -} +} // end of induce_signal function + // ====================================================================== // // Add electronic noise to pixel charge @@ -587,6 +628,7 @@ void Phase2TrackerDigitizerAlgorithm::add_noise(const Phase2TrackerGeomDetUnit* s.second += noise; } } + // ====================================================================== // // Add Cross-talk contribution @@ -719,6 +761,7 @@ void Phase2TrackerDigitizerAlgorithm::pixel_inefficiency(const SubdetEfficiencie } } } + void Phase2TrackerDigitizerAlgorithm::initializeEvent(CLHEP::HepRandomEngine& eng) { if (addNoise_ || addPixelInefficiency_ || fluctuateCharge_ || addThresholdSmearing_) { gaussDistribution_ = std::make_unique(eng, 0., theNoiseInElectrons_); @@ -742,7 +785,7 @@ void Phase2TrackerDigitizerAlgorithm::initializeEvent(CLHEP::HepRandomEngine& en // Configurations for barrel and foward pixels possess different tanLorentzAngleperTesla // parameter value -LocalVector Phase2TrackerDigitizerAlgorithm::DriftDirection(const Phase2TrackerGeomDetUnit* pixdet, +LocalVector Phase2TrackerDigitizerAlgorithm::driftDirection(const Phase2TrackerGeomDetUnit* pixdet, const GlobalVector& bfield, const DetId& detId) const { Frame detFrame(pixdet->surface().position(), pixdet->surface().rotation()); @@ -759,6 +802,11 @@ LocalVector Phase2TrackerDigitizerAlgorithm::DriftDirection(const Phase2TrackerG // Read Lorentz angle from DB: if (use_LorentzAngle_DB_) { bool isPixel = (Sub_detid == PixelSubdetector::PixelBarrel || Sub_detid == PixelSubdetector::PixelEndcap); + if (isPixel) { + LogDebug("Phase2TrackerDigitizerAlgorithm") << "Read Lorentz angle from DB for Phase-2 IT"; + } else { + LogDebug("Phase2TrackerDigitizerAlgorithm") << "Read Lorentz angle from DB for Phase-2 OT"; + } float lorentzAngle = isPixel ? siPixelLorentzAngle_->getLorentzAngle(detId) : siPhase2OTLorentzAngle_->getLorentzAngle(detId); @@ -770,6 +818,7 @@ LocalVector Phase2TrackerDigitizerAlgorithm::DriftDirection(const Phase2TrackerG scale = (1 + alpha2 * std::pow(Bfield.z(), 2)); } else { // Read Lorentz angle from cfg file: + LogDebug("Phase2TrackerDigitizerAlgorithm") << "Read Lorentz angle from cfg file"; float alpha2_Endcap = 0.0; float alpha2_Barrel = 0.0; if (alpha2Order_) { @@ -967,6 +1016,7 @@ int Phase2TrackerDigitizerAlgorithm::convertSignalToAdc(uint32_t detID, float si } return signal_in_adc; } + float Phase2TrackerDigitizerAlgorithm::calcQ(float x) { constexpr float p1 = 12.5f; constexpr float p2 = 0.2733f; diff --git a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h index 6f42ac95ef8e3..343e6dc261848 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerAlgorithm.h @@ -1,5 +1,5 @@ -#ifndef __SimTracker_SiPhase2Digitizer_Phase2TrackerDigitizerAlgorithm_h -#define __SimTracker_SiPhase2Digitizer_Phase2TrackerDigitizerAlgorithm_h +#ifndef SimTracker_SiPhase2Digitizer_Phase2TrackerDigitizerAlgorithm_h +#define SimTracker_SiPhase2Digitizer_Phase2TrackerDigitizerAlgorithm_h #include #include @@ -14,6 +14,7 @@ #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" #include "SimTracker/Common/interface/DigitizerUtility.h" +#include "SimTracker/Common/interface/SiPixelChargeReweightingAlgorithm.h" #include "SimTracker/SiPhase2Digitizer/plugins/Phase2TrackerDigitizerFwd.h" // Units and Constants @@ -39,6 +40,7 @@ class SiPixelQuality; class SiPhase2OuterTrackerLorentzAngle; class TrackerGeometry; class TrackerTopology; +class SiPixelChargeReweightingAlgorithm; // REMEMBER CMS conventions: // -- Energy: GeV @@ -168,6 +170,11 @@ class Phase2TrackerDigitizerAlgorithm { const double pseudoRadDamage_; // Decrease the amount off freed charge that reaches the collector const double pseudoRadDamageRadius_; // Only apply pseudoRadDamage to pixels with radius<=pseudoRadDamageRadius + // charge reweighting + const bool useChargeReweighting_; + // access 2D templates from DB. Only gets initialized if useChargeReweighting_ is set to true + const std::unique_ptr theSiPixelChargeReweightingAlgorithm_; + // The PDTable // HepPDTable *particleTable; // ParticleDataTable *particleTable; @@ -190,8 +197,10 @@ class Phase2TrackerDigitizerAlgorithm { const Phase2TrackerGeomDetUnit* pixdet, const GlobalVector& bfield, const std::vector& ionization_points) const; - virtual void induce_signal(const PSimHit& hit, + virtual void induce_signal(std::vector::const_iterator inputBegin, + const PSimHit& hit, const size_t hitIndex, + const size_t firstHitIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit* pixdet, const std::vector& collection_points); @@ -208,7 +217,8 @@ class Phase2TrackerDigitizerAlgorithm { // access to the gain calibration payloads in the db. Only gets initialized if check_dead_pixels_ is set to true. const std::unique_ptr theSiPixelGainCalibrationService_; - LocalVector DriftDirection(const Phase2TrackerGeomDetUnit* pixdet, + + LocalVector driftDirection(const Phase2TrackerGeomDetUnit* pixdet, const GlobalVector& bfield, const DetId& detId) const; diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index 806f2567e36d7..01ad7b674803e 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -1,20 +1,13 @@ -#include "SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h" +#include +#include +#include -// Framework infrastructure +#include "CalibTracker/SiPixelESProducers/interface/SiPixelGainCalibrationOfflineSimService.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" - -// Calibration & Conditions -#include "CalibTracker/SiPixelESProducers/interface/SiPixelGainCalibrationOfflineSimService.h" - -// Geometry #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" - -//#include -#include -#include -#include +#include "SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h" using namespace sipixelobjects; @@ -343,8 +336,10 @@ std::vector Pixel3DDigitizerAlgorithm::drift( // Signal is already "induced" (actually electrons transported to the // n-column) at the electrode. Just collecting and adding-up all pixel // signal and linking it to the simulated energy deposit (hit) -void Pixel3DDigitizerAlgorithm::induce_signal(const PSimHit& hit, +void Pixel3DDigitizerAlgorithm::induce_signal(std::vector::const_iterator inputBegin, + const PSimHit& hit, const size_t hitIndex, + const size_t firstHitIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit* pixdet, const std::vector& collection_points) { @@ -372,7 +367,7 @@ void Pixel3DDigitizerAlgorithm::induce_signal(const PSimHit& hit, the_signal[channel] += digitizerUtility::Ph2Amplitude(pt.amplitude(), nullptr, pt.amplitude()); } - LogDebug("Pixel3DDigitizerAlgorithm::induce_signal") + LogDebug("Pixel3DDigitizerAlgorithm") << " Induce charge at row,col:" << pt.position() << " N_electrons:" << pt.amplitude() << " [Channel:" << channel << "]\n [Accumulated signal in this channel:" << the_signal[channel].ampl() << "] " << " Global index linked PSimHit:" << hitIndex; diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h index ff117af60b61e..a7f6868e927a5 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h @@ -1,5 +1,5 @@ -#ifndef _SimTracker_SiPhase2Digitizer_Pixel3DDigitizerAlgorithm_h -#define _SimTracker_SiPhase2Digitizer_Pixel3DDigitizerAlgorithm_h +#ifndef SimTracker_SiPhase2Digitizer_Pixel3DDigitizerAlgorithm_h +#define SimTracker_SiPhase2Digitizer_Pixel3DDigitizerAlgorithm_h //------------------------------------------------------------- // class Pixel3DDigitizerAlgorithm @@ -52,8 +52,10 @@ class Pixel3DDigitizerAlgorithm : public PixelDigitizerAlgorithm { const std::pair pitches, const float& thickness) const; // Specific for 3D-pixel - void induce_signal(const PSimHit& hit, + void induce_signal(std::vector::const_iterator inputBegin, + const PSimHit& hit, const size_t hitIndex, + const size_t firstHitIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit* pixdet, const std::vector& collection_points) override; diff --git a/SimTracker/SiPhase2Digitizer/plugins/PixelBrickedDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/PixelBrickedDigitizerAlgorithm.cc index 4b2dc723c55d5..612923cfc282f 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PixelBrickedDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/PixelBrickedDigitizerAlgorithm.cc @@ -50,8 +50,10 @@ PixelBrickedDigitizerAlgorithm::PixelBrickedDigitizerAlgorithm(const edm::Parame PixelBrickedDigitizerAlgorithm::~PixelBrickedDigitizerAlgorithm() { LogDebug("PixelBrickedDigitizerAlgorithm") << "Algorithm deleted"; } -void PixelBrickedDigitizerAlgorithm::induce_signal(const PSimHit& hit, +void PixelBrickedDigitizerAlgorithm::induce_signal(std::vector::const_iterator inputBegin, + const PSimHit& hit, const size_t hitIndex, + const size_t firstHitIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit* pixdet, const std::vector& collection_points) { diff --git a/SimTracker/SiPhase2Digitizer/plugins/PixelBrickedDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/PixelBrickedDigitizerAlgorithm.h index 77ffe47e38e27..7446eb4d8e665 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PixelBrickedDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/PixelBrickedDigitizerAlgorithm.h @@ -17,8 +17,10 @@ class PixelBrickedDigitizerAlgorithm : public PixelDigitizerAlgorithm { ~PixelBrickedDigitizerAlgorithm() override; // Specific for bricked pixel - void induce_signal(const PSimHit& hit, + void induce_signal(std::vector::const_iterator inputBegin, + const PSimHit& hit, const size_t hitIndex, + const size_t firstHitIndex, const unsigned int tofBin, const Phase2TrackerGeomDetUnit* pixdet, const std::vector& collection_points) override; diff --git a/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc index 69f4018f3afd4..08d490748d7d1 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/PixelDigitizerAlgorithm.cc @@ -35,6 +35,9 @@ void PixelDigitizerAlgorithm::init(const edm::EventSetup& es) { // gets the map and geometry from the DB (to kill ROCs) fedCablingMap_ = &es.getData(fedCablingMapToken_); geom_ = &es.getData(geomToken_); + if (useChargeReweighting_) { + theSiPixelChargeReweightingAlgorithm_->init(es); + } } PixelDigitizerAlgorithm::PixelDigitizerAlgorithm(const edm::ParameterSet& conf, edm::ConsumesCollector iC) @@ -70,7 +73,9 @@ PixelDigitizerAlgorithm::PixelDigitizerAlgorithm(const edm::ParameterSet& conf, << " The delta cut-off is set to " << tMax_ << " pix-inefficiency " << addPixelInefficiency_; } + PixelDigitizerAlgorithm::~PixelDigitizerAlgorithm() { LogDebug("PixelDigitizerAlgorithm") << "Algorithm deleted"; } + // // -- Select the Hit for Digitization // diff --git a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py index 569d0d46ab3f2..8768b3e707ed1 100644 --- a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py +++ b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py @@ -35,6 +35,7 @@ DeadModules = cms.VPSet(), AddInefficiency = cms.bool(False), Inefficiency_DB = cms.bool(False), + UseReweighting = 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 @@ -81,13 +82,16 @@ ), # Specific parameters #Pixel Digitizer Algorithm - PixelDigitizerAlgorithm = PixelDigitizerAlgorithmCommon.clone(), + PixelDigitizerAlgorithm = PixelDigitizerAlgorithmCommon.clone( + UseReweighting = cms.bool(False), # will be True for realistic simulations + ), #Pixel-3D Digitizer Algorithm Pixel3DDigitizerAlgorithm = PixelDigitizerAlgorithmCommon.clone( SigmaCoeff = cms.double(1.80), NPColumnRadius = cms.double(4.0), OhmicColumnRadius = cms.double(4.0), - NPColumnGap = cms.double(46.0) + NPColumnGap = cms.double(46.0), + UseReweighting = cms.bool(False), # will be True for realistic simulations ), #Pixel-Bricked Digitizer Algorithm PixelBrickedDigitizerAlgorithm = PixelDigitizerAlgorithmCommon.clone(), @@ -103,7 +107,7 @@ 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(200), # 30% of the readout noise (should be changed in future) - Phase2ReadoutMode = cms.int32(0), # Flag to decide Readout Mode :Digital(0) or Analog (linear TDR (-1), dual slope with slope parameters (+1,+2,+3,+4) with threshold subtraction + Phase2ReadoutMode = cms.int32(0), # 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(255), TofUpperCut = cms.double(12.5), TofLowerCut = cms.double(-12.5), @@ -127,7 +131,8 @@ 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(), - BiasRailInefficiencyFlag = cms.int32(1) # Flag to decide BiasRail inefficiency : no inefficency(0) : inefficiency with optimistic(AND) scenario(1) : inefficiency with pessimistic(OR) scenario(2) + BiasRailInefficiencyFlag = cms.int32(1), # Flag to decide BiasRail inefficiency : no inefficency(0) : inefficiency with optimistic(AND) scenario(1) : inefficiency with pessimistic(OR) scenario(2) + UseReweighting = cms.bool(False), ), #Strip in PS module PSSDigitizerAlgorithm = cms.PSet( @@ -142,7 +147,7 @@ HIPThresholdInElectrons_Barrel = cms.double(21000.), # 1.4 MIP considered as HIP HIPThresholdInElectrons_Endcap = cms.double(21000.), # 1.4 MIP considered as HIP NoiseInElectrons = cms.double(1010), # threshold = 4800e, noise=4800e/4.75=1010 (4.75 sigma=>occupancy =1e-6) - Phase2ReadoutMode = cms.int32(0), # Flag to decide Readout Mode :Digital(0) or Analog (linear TDR (-1), dual slope with slope parameters (+1,+2,+3,+4) with threshold subtraction + Phase2ReadoutMode = cms.int32(0), # 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(255), TofUpperCut = cms.double(12.5), TofLowerCut = cms.double(-12.5), @@ -165,7 +170,8 @@ 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() + CellsToKill = cms.VPSet(), + UseReweighting = cms.bool(False), ), #Two Strip Module SSDigitizerAlgorithm = cms.PSet( @@ -180,7 +186,7 @@ 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(1263), # threshold = 6000e, noise=6000e/4.75=1263e (4.75 sigma=>occupancy =1e-6) - Phase2ReadoutMode = cms.int32(0), # Flag to decide Readout Mode :Digital(0) or Analog (linear TDR (-1), dual slope with slope parameters (+1,+2,+3,+4) with threshold subtraction + Phase2ReadoutMode = cms.int32(0), # 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(255), TofUpperCut = cms.double(12.5), TofLowerCut = cms.double(-12.5), @@ -206,7 +212,8 @@ CellsToKill = cms.VPSet(), HitDetectionMode = cms.int32(0), # (0/1/2/3/4 => SquareWindow/SampledMode/LatchedMode/SampledOrLachedMode/HIPFindingMode) PulseShapeParameters = cms.vdouble(-3.0, 16.043703, 99.999857, 40.571650, 2.0, 1.2459094), - CBCDeadTime = cms.double(0.0) # (2.7 ns deadtime in latched mode) + CBCDeadTime = cms.double(0.0), # (2.7 ns deadtime in latched mode) + UseReweighting = cms.bool(False), ) ) @@ -242,7 +249,7 @@ AddNoisyPixels = False, AddInefficiency = False, AddThresholdSmearing = False, - Phase2ReadoutMode = -1 + Phase2ReadoutMode = -1, ), SSDigitizerAlgorithm = dict( AddNoisyPixels = False, diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index 6c7b362dd8385..e65d123b4ac42 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -1454,8 +1454,8 @@ void SiPixelDigitizerAlgorithm::induce_signal(std::vector::const_iterat int IPixLeftDownY = int(floor(mp.y())); #ifdef TP_DEBUG - emd::LogDebug("Pixel Digitizer") << " left-down " << PointLeftDown << " " << mp.x() << " " << mp.y() << " " - << IPixLeftDownX << " " << IPixLeftDownY; + LogDebug("Pixel Digitizer") << " left-down " << PointLeftDown << " " << mp.x() << " " << mp.y() << " " + << IPixLeftDownX << " " << IPixLeftDownY; #endif // Check detector limits to correct for pixels outside range. @@ -1564,7 +1564,7 @@ void SiPixelDigitizerAlgorithm::induce_signal(std::vector::const_iterat if (UseReweighting) { if (hit.processType() == 0) { ReferenceIndex4CR = hitIndex; - reweighted = TheNewSiPixelChargeReweightingAlgorithmClass->hitSignalReweight( + reweighted = TheNewSiPixelChargeReweightingAlgorithmClass->hitSignalReweight( hit, hit_signal, hitIndex, ReferenceIndex4CR, tofBin, topol, detID, theSignal, hit.processType(), makeDSLinks); } else { std::vector::const_iterator crSimHit = inputBegin; @@ -1587,16 +1587,17 @@ void SiPixelDigitizerAlgorithm::induce_signal(std::vector::const_iterat } } - reweighted = TheNewSiPixelChargeReweightingAlgorithmClass->hitSignalReweight((*crSimHit), - hit_signal, - hitIndex, - ReferenceIndex4CR, - tofBin, - topol, - detID, - theSignal, - hit.processType(), - makeDSLinks); + reweighted = TheNewSiPixelChargeReweightingAlgorithmClass->hitSignalReweight( + (*crSimHit), + hit_signal, + hitIndex, + ReferenceIndex4CR, + tofBin, + topol, + detID, + theSignal, + hit.processType(), + makeDSLinks); } } if (!reweighted) { @@ -2556,7 +2557,7 @@ void SiPixelDigitizerAlgorithm::lateSignalReweight(const PixelGeomDetUnit* pixde for (loopTempSH = newClass_Sim_extra.begin(); loopTempSH != newClass_Sim_extra.end(); ++loopTempSH) { signal_map_type theDigiSignal; PixelSimHitExtraInfo TheNewInfo = *loopTempSH; - reweighted = TheNewSiPixelChargeReweightingAlgorithmClass->lateSignalReweight( + reweighted = TheNewSiPixelChargeReweightingAlgorithmClass->lateSignalReweight( pixdet, digis, TheNewInfo, theDigiSignal, tTopo, engine); if (!reweighted) { // loop on the non-reweighthed digis associated to the considered SimHit