55 #include <gsl/gsl_sf_erf.h> 57 #include "CLHEP/Random/RandGaussQ.h" 58 #include "CLHEP/Random/RandFlat.h" 59 #include "CLHEP/Random/RandGeneral.h" 108 if (use_ineff_from_db_) {
109 theSiPixelGainCalibrationService_->setESObjects(es);
111 if (use_deadmodule_DB_) {
112 SiPixelBadModule_ = &es.
getData(SiPixelBadModuleToken_);
114 if (use_LorentzAngle_DB_) {
116 SiPixelLorentzAngle_ = &es.
getData(SiPixelLorentzAngleToken_);
120 geom_ = &es.
getData(geomToken_);
123 scenarioProbability_ = &es.
getData(scenarioProbabilityToken_);
124 quality_map = &es.
getData(PixelFEDChannelCollectionMapToken_);
127 std::vector<std::string> allScenarios;
131 std::back_inserter(allScenarios),
134 std::vector<std::string> allScenariosInProb;
136 for (
auto it = m_probabilities.begin(); it != m_probabilities.end(); ++it) {
138 for (
const auto&
entry : it->second) {
140 auto probability =
entry.second;
141 if (probability != 0) {
142 if (
std::find(allScenariosInProb.begin(), allScenariosInProb.end(),
scenario) == allScenariosInProb.end()) {
143 allScenariosInProb.push_back(
scenario);
150 std::copy_if(allScenariosInProb.begin(),
151 allScenariosInProb.end(),
154 return (
std::find(allScenarios.begin(), allScenarios.end(),
arg) == allScenarios.end());
159 LogError(
"SiPixelFEDChannelContainer")
160 <<
"The requested scenario: " <<
entry <<
" is not found in the map!! \n";
163 <<
" missing scenario(s) in SiPixelStatusScenariosRcd while " 164 "present in SiPixelStatusScenarioProbabilityRcd \n";
167 LogInfo(
"PixelDigitizer ") <<
" PixelDigitizerAlgorithm init \n";
168 LogInfo(
"PixelDigitizer ") <<
" PixelDigitizerAlgorithm --> UseReweighting " <<
UseReweighting <<
"\n";
169 LogInfo(
"PixelDigitizer ") <<
" PixelDigitizerAlgorithm --> store_SimHitEntryExitPoints_ " 170 << store_SimHitEntryExitPoints_ <<
"\n";
171 LogInfo(
"PixelDigitizer ") <<
" PixelDigitizerAlgorithm --> makeDigiSimLinks_ " << makeDigiSimLinks_ <<
"\n";
173 TheNewSiPixelChargeReweightingAlgorithmClass->init(es);
175 int collectionIndex = 0;
177 for (
int i1 = 1;
i1 < 3;
i1++) {
178 for (
int i2 = 0;
i2 < 2;
i2++) {
185 SimHitCollMap[theSubDetTofBin] = collectionIndex;
198 makeDigiSimLinks_(conf.getUntrackedParameter<
bool>(
"makeDigiSimLinks",
true)),
199 store_SimHitEntryExitPoints_(
200 conf.exists(
"store_SimHitEntryExitPoints") ? conf.getParameter<
bool>(
"store_SimHitEntryExitPoints") :
false),
201 use_ineff_from_db_(conf.getParameter<
bool>(
"useDB")),
202 use_module_killing_(conf.getParameter<
bool>(
"killModules")),
203 use_deadmodule_DB_(conf.getParameter<
bool>(
"DeadModules_DB")),
204 use_LorentzAngle_DB_(conf.getParameter<
bool>(
"LorentzAngle_DB")),
207 : conf.getParameter<
Parameters>(
"DeadModules")),
209 TheNewSiPixelChargeReweightingAlgorithmClass(),
213 GeVperElectron(3.61E-09),
216 alpha2Order(conf.getParameter<
bool>(
"Alpha2Order")),
222 NumberOfBarrelLayers(conf.exists(
"NumPixelBarrel") ? conf.getParameter<
int>(
"NumPixelBarrel") : 3),
230 theElectronPerADC(conf.getParameter<double>(
"ElectronPerAdc")),
234 theAdcFullScale(conf.getParameter<
int>(
"AdcFullScale")),
235 theAdcFullScLateCR(conf.getParameter<
int>(
"AdcFullScLateCR")),
239 theNoiseInElectrons(conf.getParameter<double>(
"NoiseInElectrons")),
243 theReadoutNoise(conf.getParameter<double>(
"ReadoutNoiseInElec")),
248 theThresholdInE_FPix(conf.getParameter<double>(
"ThresholdInElectrons_FPix")),
249 theThresholdInE_BPix(conf.getParameter<double>(
"ThresholdInElectrons_BPix")),
250 theThresholdInE_BPix_L1(conf.exists(
"ThresholdInElectrons_BPix_L1")
251 ? conf.getParameter<double>(
"ThresholdInElectrons_BPix_L1")
252 : theThresholdInE_BPix),
253 theThresholdInE_BPix_L2(conf.exists(
"ThresholdInElectrons_BPix_L2")
254 ? conf.getParameter<double>(
"ThresholdInElectrons_BPix_L2")
255 : theThresholdInE_BPix),
258 theThresholdSmearing_FPix(conf.getParameter<double>(
"ThresholdSmearing_FPix")),
259 theThresholdSmearing_BPix(conf.getParameter<double>(
"ThresholdSmearing_BPix")),
260 theThresholdSmearing_BPix_L1(conf.exists(
"ThresholdSmearing_BPix_L1")
261 ? conf.getParameter<double>(
"ThresholdSmearing_BPix_L1")
262 : theThresholdSmearing_BPix),
263 theThresholdSmearing_BPix_L2(conf.exists(
"ThresholdSmearing_BPix_L2")
264 ? conf.getParameter<double>(
"ThresholdSmearing_BPix_L2")
265 : theThresholdSmearing_BPix),
268 electronsPerVCAL(conf.getParameter<double>(
"ElectronsPerVcal")),
269 electronsPerVCAL_Offset(conf.getParameter<double>(
"ElectronsPerVcal_Offset")),
270 electronsPerVCAL_L1(conf.exists(
"ElectronsPerVcal_L1") ? conf.getParameter<double>(
"ElectronsPerVcal_L1")
272 electronsPerVCAL_L1_Offset(conf.exists(
"ElectronsPerVcal_L1_Offset")
273 ? conf.getParameter<double>(
"ElectronsPerVcal_L1_Offset")
274 : electronsPerVCAL_Offset),
278 theTofLowerCut(conf.getParameter<double>(
"TofLowerCut")),
279 theTofUpperCut(conf.getParameter<double>(
"TofUpperCut")),
282 tanLorentzAnglePerTesla_FPix(use_LorentzAngle_DB_ ? 0.0
283 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_FPix")),
284 tanLorentzAnglePerTesla_BPix(use_LorentzAngle_DB_ ? 0.0
285 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_BPix")),
288 FPix_p0(conf.getParameter<double>(
"FPix_SignalResponse_p0")),
289 FPix_p1(conf.getParameter<double>(
"FPix_SignalResponse_p1")),
290 FPix_p2(conf.getParameter<double>(
"FPix_SignalResponse_p2")),
291 FPix_p3(conf.getParameter<double>(
"FPix_SignalResponse_p3")),
293 BPix_p0(conf.getParameter<double>(
"BPix_SignalResponse_p0")),
294 BPix_p1(conf.getParameter<double>(
"BPix_SignalResponse_p1")),
295 BPix_p2(conf.getParameter<double>(
"BPix_SignalResponse_p2")),
296 BPix_p3(conf.getParameter<double>(
"BPix_SignalResponse_p3")),
299 addNoise(conf.getParameter<
bool>(
"AddNoise")),
303 addChargeVCALSmearing(conf.getParameter<
bool>(
"ChargeVCALSmearing")),
306 addNoisyPixels(conf.getParameter<
bool>(
"AddNoisyPixels")),
309 fluctuateCharge(conf.getUntrackedParameter<
bool>(
"FluctuateCharge",
true)),
316 addThresholdSmearing(conf.getParameter<
bool>(
"AddThresholdSmearing")),
319 doMissCalibrate(conf.getParameter<
bool>(
"MissCalibrate")),
320 doMissCalInLateCR(conf.getParameter<
bool>(
"MissCalInLateCR")),
321 theGainSmearing(conf.getParameter<double>(
"GainSmearing")),
322 theOffsetSmearing(conf.getParameter<double>(
"OffsetSmearing")),
325 AddPixelAging(conf.getParameter<
bool>(
"DoPixelAging")),
331 tMax(conf.getParameter<double>(
"deltaProductionCut")),
362 LogInfo(
"PixelDigitizer ") <<
"SiPixelDigitizerAlgorithm constructed" 363 <<
"Configuration parameters:" 364 <<
"Threshold/Gain = " 372 LogInfo(
"PixelDigitizer ") <<
" SiPixelDigitizerAlgorithm constructed with UseReweighting " <<
UseReweighting 379 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
calmap;
381 LogDebug(
"PixelDigitizer ") <<
" miss-calibrate the pixel amplitude \n";
383 const bool ReadCalParameters =
false;
384 if (ReadCalParameters) {
387 char filename[80] =
"phCalibrationFit_C0.dat";
391 LogInfo(
"PixelDigitizer ") <<
" File not found \n ";
397 for (
int i = 0;
i < 3;
i++) {
402 LogInfo(
"PixelDigitizer ") <<
" test map" 409 for (
int i = 0;
i < (52 * 80);
i++) {
412 LogError(
"PixelDigitizer") <<
"Cannot read data file for calmap" 418 <<
" " <<
in_file.good() <<
" end of file " 424 << colid <<
" " << rowid <<
"\n";
434 calmap.insert(std::pair<int, CalParameters>(
chan, onePix));
438 if (rowid !=
p.first)
439 LogInfo(
"PixelDigitizer ") <<
" wrong channel row " << rowid <<
" " <<
p.first <<
"\n";
440 if (colid !=
p.second)
441 LogInfo(
"PixelDigitizer ") <<
" wrong channel col " << colid <<
" " <<
p.second <<
"\n";
445 LogInfo(
"PixelDigitizer ") <<
" map size " <<
calmap.size() <<
" max " <<
calmap.max_size() <<
" " 446 <<
calmap.empty() <<
"\n";
469 LogDebug(
"PixelDigitizer") <<
"SiPixelDigitizerAlgorithm deleted";
475 int NumberOfBarrelLayers,
483 conf.
exists(
"thePixelColEfficiency_BPix3") && conf.
exists(
"thePixelColEfficiency_FPix1") &&
484 conf.
exists(
"thePixelColEfficiency_FPix2") && conf.
exists(
"thePixelEfficiency_BPix1") &&
485 conf.
exists(
"thePixelEfficiency_BPix2") && conf.
exists(
"thePixelEfficiency_BPix3") &&
486 conf.
exists(
"thePixelEfficiency_FPix1") && conf.
exists(
"thePixelEfficiency_FPix2") &&
487 conf.
exists(
"thePixelChipEfficiency_BPix1") && conf.
exists(
"thePixelChipEfficiency_BPix2") &&
488 conf.
exists(
"thePixelChipEfficiency_BPix3") && conf.
exists(
"thePixelChipEfficiency_FPix1") &&
489 conf.
exists(
"thePixelChipEfficiency_FPix2");
492 conf.
exists(
"theLadderEfficiency_BPix3") && conf.
exists(
"theModuleEfficiency_BPix1") &&
493 conf.
exists(
"theModuleEfficiency_BPix2") && conf.
exists(
"theModuleEfficiency_BPix3") &&
494 conf.
exists(
"thePUEfficiency_BPix1") && conf.
exists(
"thePUEfficiency_BPix2") &&
495 conf.
exists(
"thePUEfficiency_BPix3") && conf.
exists(
"theInnerEfficiency_FPix1") &&
496 conf.
exists(
"theInnerEfficiency_FPix2") && conf.
exists(
"theOuterEfficiency_FPix1") &&
497 conf.
exists(
"theOuterEfficiency_FPix2") && conf.
exists(
"thePUEfficiency_FPix_Inner") &&
498 conf.
exists(
"thePUEfficiency_FPix_Outer") && conf.
exists(
"theInstLumiScaleFactor");
501 conf.
exists(
"thePixelEfficiency_BPix4") && conf.
exists(
"thePixelChipEfficiency_BPix4");
504 conf.
exists(
"thePixelEfficiency_FPix3") && conf.
exists(
"thePixelChipEfficiency_FPix3");
506 LogInfo(
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the config file.\n";
540 throw cms::Exception(
"Configuration") <<
"Wrong ladder number in efficiency config!";
549 throw cms::Exception(
"Configuration") <<
"Wrong module number in efficiency config!";
557 <<
"At least one PU efficiency (BPix) number is needed in efficiency config!";
561 if (NumberOfTotLayers > 20) {
562 throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";
592 if (NumberOfTotLayers > 20) {
593 throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";
614 <<
"At least one (FPix) PU efficiency number is needed in efficiency config!";
618 LogInfo(
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the database.\n";
644 for (
const auto& it_module :
geom->detUnits()) {
645 if (dynamic_cast<PixelGeomDetUnit const*>(it_module) ==
nullptr)
647 const DetId detid = it_module->geographicalId();
648 uint32_t rawid = detid.
rawId();
649 PixelGeomFactors[rawid] = 1;
650 ColGeomFactors[rawid] = 1;
651 ChipGeomFactors[rawid] = 1;
652 PixelGeomFactorsROCStdPixels[rawid] = std::vector<double>(16, 1);
653 PixelGeomFactorsROCBigPixels[rawid] = std::vector<double>(16, 1);
657 std::map<uint32_t, double> PixelGeomFactorsDB;
659 LogDebug(
"PixelDigitizer ") <<
" Check PixelEfficiencies -- PixelGeomFactorsDBIn " 662 for (
auto db_factor : PixelGeomFactorsDBIn) {
663 LogDebug(
"PixelDigitizer ") <<
" db_factor " << db_factor.first <<
" " << db_factor.second <<
"\n";
667 unsigned int rocMask = rocIdMaskBits <<
shift;
668 unsigned int rocId = (((db_factor.first) & rocMask) >>
shift);
671 unsigned int rawid = db_factor.first & (~rocMask);
676 double factor = db_factor.second;
677 double badFraction = 1 -
factor;
678 double bigPixelFraction =
static_cast<double>(nBigPixelsInROC) / nPixelsInROC;
679 double stdPixelFraction = 1. - bigPixelFraction;
681 double badFractionBig =
std::min(bigPixelFraction, badFraction);
682 double badFractionStd =
std::max(0., badFraction - badFractionBig);
683 double badFractionBigReNormalized = badFractionBig / bigPixelFraction;
684 double badFractionStdReNormalized = badFractionStd / stdPixelFraction;
685 PixelGeomFactorsROCStdPixels[rawid][rocId] *= (1. - badFractionStdReNormalized);
686 PixelGeomFactorsROCBigPixels[rawid][rocId] *= (1. - badFractionBigReNormalized);
688 PixelGeomFactorsDB[db_factor.first] = db_factor.second;
693 PixelGeomFactorsDB = PixelGeomFactorsDBIn;
697 <<
" Check PixelEfficiencies -- Loop on all modules and store module level geometrical scale factors " 700 for (
const auto& it_module :
geom->detUnits()) {
701 if (dynamic_cast<PixelGeomDetUnit const*>(it_module) ==
nullptr)
703 const DetId detid = it_module->geographicalId();
704 uint32_t rawid = detid.
rawId();
705 for (
auto db_factor : PixelGeomFactorsDB) {
706 LogDebug(
"PixelDigitizer ") <<
" db_factor PixelGeomFactorsDB " << db_factor.first <<
" " 707 << db_factor.second <<
"\n";
709 PixelGeomFactors[rawid] *= db_factor.second;
711 for (
auto db_factor : ColGeomFactorsDB) {
712 LogDebug(
"PixelDigitizer ") <<
" db_factor ColGeomFactorsDB " << db_factor.first <<
" " << db_factor.second
715 ColGeomFactors[rawid] *= db_factor.second;
717 for (
auto db_factor : ChipGeomFactorsDB) {
718 LogDebug(
"PixelDigitizer ") <<
" db_factor ChipGeomFactorsDB " << db_factor.first <<
" " 719 << db_factor.second <<
"\n";
721 ChipGeomFactors[rawid] *= db_factor.second;
728 LogDebug(
"PixelDigitizer ") <<
" Check PixelEfficiencies -- PUFactors " 730 for (
const auto&
factor : PUFactors) {
732 LogDebug(
"PixelDigitizer ") <<
" factor " <<
factor.first <<
" " <<
factor.second.size() <<
"\n";
733 for (
size_t i = 0,
n =
factor.second.size();
i <
n;
i++) {
734 LogDebug(
"PixelDigitizer ") <<
" print factor.second for " <<
i <<
" " <<
factor.second[
i] <<
"\n";
738 for (
const auto& it_module :
geom->detUnits()) {
739 if (dynamic_cast<PixelGeomDetUnit const*>(it_module) ==
nullptr)
741 const DetId detid = it_module->geographicalId();
742 if (!
matches(detid, db_id, DetIdmasks))
744 if (iPU.count(detid.
rawId())) {
746 <<
"Multiple db_ids match to same module in SiPixelDynamicInefficiency DB Object";
751 thePUEfficiency.push_back(
factor.second);
754 pu_scale.resize(thePUEfficiency.size());
759 const std::vector<uint32_t>& DetIdmasks) {
762 for (
size_t i = 0;
i < DetIdmasks.size(); ++
i) {
784 thePixelPseudoRadDamage[
i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix1");
785 thePixelPseudoRadDamage[
i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix2");
786 thePixelPseudoRadDamage[
i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix3");
787 thePixelPseudoRadDamage[
i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix4");
791 if (NumberOfTotLayers > 20) {
792 throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";
796 thePixelPseudoRadDamage[
j - 1] = 0.;
801 thePixelPseudoRadDamage[
i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix1");
802 thePixelPseudoRadDamage[
i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix2");
803 thePixelPseudoRadDamage[
i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix3");
807 if (NumberOfTotLayers > 20) {
808 throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";
812 thePixelPseudoRadDamage[
j - 1] = 0.;
822 std::vector<PSimHit>::const_iterator inputEnd,
823 const size_t inputBeginGlobalIndex,
824 const unsigned int tofBin,
828 CLHEP::HepRandomEngine* engine) {
833 size_t simHitGlobalIndex = inputBeginGlobalIndex;
834 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
836 if ((*ssbegin).detUnitId() != detId) {
841 LogDebug(
"Pixel Digitizer") << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" " 842 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" " << (*ssbegin).trackId()
843 <<
" " << (*ssbegin).processType() <<
" " << (*ssbegin).detUnitId()
844 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint();
847 std::vector<EnergyDepositUnit> ionization_points;
848 std::vector<SignalPoint> collection_points;
866 inputBeginGlobalIndex,
884 std::vector<int>::const_iterator
pu;
885 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
887 for (
pu = bunchCrossing.begin();
pu != bunchCrossing.end(); ++
pu) {
894 if (pu0 != bunchCrossing.end()) {
897 double instlumi_pow = 1.;
901 instlumi_pow *= instlumi;
915 for (
unsigned int i = 0;
i < ps.size();
i++)
916 if (ps[
i].getBunchCrossing() == 0)
922 double instlumi_pow = 1.;
926 instlumi_pow *= instlumi;
941 const std::vector<PileupSummaryInfo>& ps, CLHEP::HepRandomEngine* engine) {
942 std::unique_ptr<PixelFEDChannelCollection> PixelFEDChannelCollection_ =
nullptr;
945 std::vector<int> bunchCrossing;
946 std::vector<float> TrueInteractionList;
948 for (
unsigned int i = 0;
i < ps.size();
i++) {
949 bunchCrossing.push_back(ps[
i].getBunchCrossing());
950 TrueInteractionList.push_back(ps[
i].getTrueNumInteractions());
954 std::vector<int>::const_iterator
pu;
955 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
957 for (
pu = bunchCrossing.begin();
pu != bunchCrossing.end(); ++
pu) {
965 if (pu0 != bunchCrossing.end()) {
966 unsigned int PUBin = TrueInteractionList.at(
p);
968 std::vector<double> probabilities;
969 probabilities.reserve(theProbabilitiesPerScenario.size());
970 for (
auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++) {
971 probabilities.push_back(it->second);
974 CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size());
975 double x = randGeneral.shoot();
976 unsigned int index =
x * probabilities.size() - 1;
979 PixelFEDChannelCollection_ = std::make_unique<PixelFEDChannelCollection>(
quality_map->at(
scenario));
984 return PixelFEDChannelCollection_;
988 CLHEP::HepRandomEngine* engine) {
991 std::unique_ptr<PixelFEDChannelCollection> PixelFEDChannelCollection_ =
nullptr;
998 std::vector<int>::const_iterator
pu;
999 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
1001 for (
pu = bunchCrossing.begin();
pu != bunchCrossing.end(); ++
pu) {
1009 if (pu0 != bunchCrossing.end()) {
1010 unsigned int PUBin = TrueInteractionList.at(
p);
1012 std::vector<double> probabilities;
1013 probabilities.reserve(theProbabilitiesPerScenario.size());
1014 for (
auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++) {
1015 probabilities.push_back(it->second);
1018 CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size());
1019 double x = randGeneral.shoot();
1020 unsigned int index =
x * probabilities.size() - 1;
1023 PixelFEDChannelCollection_ = std::make_unique<PixelFEDChannelCollection>(
quality_map->at(
scenario));
1028 return PixelFEDChannelCollection_;
1033 for (
const auto& det : signalMap) {
1034 auto& theSignal =
_signal[det.first];
1035 for (
const auto&
chan : det.second) {
1036 theSignal[
chan.first].set(
chan.second *
1044 std::vector<PixelDigi>& digis,
1045 std::vector<PixelDigiSimLink>& simlinks,
1046 std::vector<PixelDigiAddTempInfo>& newClass_Digi_extra,
1048 CLHEP::HepRandomEngine* engine) {
1060 float thePixelThresholdInE = 0.;
1064 int lay = tTopo->
layer(detID);
1069 thePixelThresholdInE = CLHEP::RandGaussQ::shoot(
1071 }
else if (lay == 2) {
1072 thePixelThresholdInE = CLHEP::RandGaussQ::shoot(
1075 thePixelThresholdInE =
1084 }
else if (lay == 2) {
1093 thePixelThresholdInE =
1099 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1105 int numColumns = topol->
ncolumns();
1106 int numRows = topol->
nrows();
1109 LogDebug(
"PixelDigitizer") <<
" PixelDigitizer " << numColumns <<
" " << numRows <<
" " << moduleThickness;
1131 make_digis(thePixelThresholdInE, detID, pixdet, digis, simlinks, newClass_Digi_extra, tTopo);
1134 LogDebug(
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" 1143 std::vector<EnergyDepositUnit>& ionization_points,
1144 CLHEP::HepRandomEngine* engine)
const {
1147 const float SegmentLength = 0.0010;
1154 float length = direction.
mag();
1156 int NumberOfSegments =
int(length / SegmentLength);
1157 if (NumberOfSegments < 1)
1158 NumberOfSegments = 1;
1161 LogDebug(
"Pixel Digitizer") <<
" enter primary_ionzation " << NumberOfSegments
1162 <<
" shift = " << (
hit.exitPoint().
x() -
hit.entryPoint().
x()) <<
" " 1163 << (
hit.exitPoint().
y() -
hit.entryPoint().
y()) <<
" " 1164 << (
hit.exitPoint().
z() -
hit.entryPoint().
z()) <<
" " <<
hit.particleType() <<
" " 1168 float* elossVector =
new float[NumberOfSegments];
1172 int pid =
hit.particleType();
1175 float momentum =
hit.pabs();
1180 ionization_points.resize(NumberOfSegments);
1183 for (
int i = 0;
i != NumberOfSegments;
i++) {
1193 ionization_points[
i] = edu;
1196 LogDebug(
"Pixel Digitizer") <<
i <<
" " << ionization_points[
i].x() <<
" " << ionization_points[
i].y() <<
" " 1197 << ionization_points[
i].z() <<
" " << ionization_points[
i].energy();
1202 delete[] elossVector;
1209 float particleMomentum,
1213 float elossVector[],
1214 CLHEP::HepRandomEngine* engine)
const {
1220 double particleMass = 139.6;
1224 particleMass = 0.511;
1226 particleMass = 105.7;
1227 else if (pid == 321)
1228 particleMass = 493.7;
1229 else if (pid == 2212)
1230 particleMass = 938.3;
1233 float segmentLength = length / NumberOfSegs;
1238 double segmentEloss = (1000. * eloss) / NumberOfSegs;
1239 for (
int i = 0;
i < NumberOfSegs;
i++) {
1245 double deltaCutoff =
tMax;
1246 de =
fluctuate->SampleFluctuations(
double(particleMomentum * 1000.),
1249 double(segmentLength * 10.),
1253 elossVector[
i] = de;
1259 float ratio = eloss / sum;
1261 for (
int ii = 0;
ii < NumberOfSegs;
ii++)
1262 elossVector[
ii] =
ratio * elossVector[
ii];
1264 float averageEloss = eloss / NumberOfSegs;
1265 for (
int ii = 0;
ii < NumberOfSegs;
ii++)
1266 elossVector[
ii] = averageEloss;
1278 const std::vector<EnergyDepositUnit>& ionization_points,
1279 std::vector<SignalPoint>& collection_points)
const {
1281 LogDebug(
"Pixel Digitizer") <<
" enter drift ";
1284 collection_points.resize(ionization_points.size());
1287 if (driftDir.
z() == 0.) {
1288 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
1296 float TanLorenzAngleX, TanLorenzAngleY, dir_z, CosLorenzAngleX, CosLorenzAngleY;
1298 TanLorenzAngleX = driftDir.
x();
1299 TanLorenzAngleY = driftDir.
y();
1300 dir_z = driftDir.
z();
1301 CosLorenzAngleX = 1. /
sqrt(1. + TanLorenzAngleX * TanLorenzAngleX);
1302 CosLorenzAngleY = 1. /
sqrt(1. + TanLorenzAngleY * TanLorenzAngleY);
1305 TanLorenzAngleX = driftDir.
x();
1306 TanLorenzAngleY = 0.;
1307 dir_z = driftDir.
z();
1308 CosLorenzAngleX = 1. /
sqrt(1. + TanLorenzAngleX * TanLorenzAngleX);
1309 CosLorenzAngleY = 1.;
1314 LogDebug(
"Pixel Digitizer") <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" " << CosLorenzAngleX
1315 <<
" " << CosLorenzAngleY <<
" " << moduleThickness * TanLorenzAngleX <<
" " << driftDir;
1320 float DriftDistance;
1324 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
1325 float SegX, SegY, SegZ;
1326 SegX = ionization_points[
i].
x();
1327 SegY = ionization_points[
i].y();
1328 SegZ = ionization_points[
i].z();
1333 DriftDistance = moduleThickness / 2. - (dir_z * SegZ);
1335 if (DriftDistance <= 0.)
1336 LogDebug(
"PixelDigitizer ") <<
" <=0 " << DriftDistance <<
" " <<
i <<
" " << SegZ <<
" " << dir_z <<
" " << SegX
1337 <<
" " << SegY <<
" " << (moduleThickness / 2) <<
" " << ionization_points[
i].
energy()
1338 <<
" " <<
hit.particleType() <<
" " <<
hit.pabs() <<
" " <<
hit.energyLoss() <<
" " 1339 <<
hit.entryPoint() <<
" " <<
hit.exitPoint() <<
"\n";
1341 if (DriftDistance < 0.) {
1343 }
else if (DriftDistance > moduleThickness)
1344 DriftDistance = moduleThickness;
1347 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
1348 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
1351 float CloudCenterX = SegX + XDriftDueToMagField;
1352 float CloudCenterY = SegY + YDriftDueToMagField;
1355 DriftLength =
sqrt(DriftDistance * DriftDistance + XDriftDueToMagField * XDriftDueToMagField +
1356 YDriftDueToMagField * YDriftDueToMagField);
1362 Sigma_x = Sigma / CosLorenzAngleX;
1363 Sigma_y = Sigma / CosLorenzAngleY;
1366 float energyOnCollector = ionization_points[
i].energy();
1371 energyOnCollector *=
exp(-1 * kValue * DriftDistance / moduleThickness);
1375 LogDebug(
"Pixel Digitizer") <<
" Dift DistanceZ= " << DriftDistance <<
" module thickness= " << moduleThickness
1376 <<
" Start Energy= " << ionization_points[
i].energy()
1377 <<
" Energy after loss= " << energyOnCollector;
1379 SignalPoint sp(CloudCenterX, CloudCenterY, Sigma_x, Sigma_y,
hit.tof(), energyOnCollector);
1382 collection_points[
i] = (sp);
1391 std::vector<PSimHit>::const_iterator inputEnd,
1393 const size_t hitIndex,
1394 const size_t FirstHitIndex,
1395 const unsigned int tofBin,
1397 const std::vector<SignalPoint>& collection_points) {
1406 LogDebug(
"Pixel Digitizer") <<
" enter induce_signal, " << topol->
pitch().first <<
" " << topol->
pitch().second;
1410 typedef std::map<int, float, std::less<int> > hit_map_type;
1411 hit_map_type hit_signal;
1414 std::map<int, float, std::less<int> >
x,
y;
1419 for (std::vector<SignalPoint>::const_iterator
i = collection_points.begin();
i != collection_points.end(); ++
i) {
1420 float CloudCenterX =
i->position().x();
1421 float CloudCenterY =
i->position().y();
1424 float Charge =
i->amplitude();
1428 <<
i->position().y() <<
" " <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " 1429 <<
i->amplitude() <<
"\n";
1433 LogDebug(
"Pixel Digitizer") <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" " <<
i->sigma_x()
1434 <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
1457 int IPixRightUpX =
int(floor(mp.
x()));
1458 int IPixRightUpY =
int(floor(mp.
y()));
1461 LogDebug(
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" " << mp.
x() <<
" " << mp.
y() <<
" " << IPixRightUpX
1462 <<
" " << IPixRightUpY;
1467 int IPixLeftDownX =
int(floor(mp.
x()));
1468 int IPixLeftDownY =
int(floor(mp.
y()));
1471 emd::LogDebug(
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" " << mp.
x() <<
" " << mp.
y() <<
" " 1472 << IPixLeftDownX <<
" " << IPixLeftDownY;
1476 int numColumns = topol->
ncolumns();
1477 int numRows = topol->
nrows();
1479 IPixRightUpX = numRows > IPixRightUpX ? IPixRightUpX : numRows - 1;
1480 IPixRightUpY = numColumns > IPixRightUpY ? IPixRightUpY : numColumns - 1;
1481 IPixLeftDownX = 0 < IPixLeftDownX ? IPixLeftDownX : 0;
1482 IPixLeftDownY = 0 < IPixLeftDownY ? IPixLeftDownY : 0;
1489 for (ix = IPixLeftDownX; ix <= IPixRightUpX; ix++) {
1490 float xUB, xLB, UpperBound, LowerBound;
1495 if (ix == 0 ||
SigmaX == 0.)
1500 LowerBound = 1 -
calcQ((xLB - CloudCenterX) /
SigmaX);
1503 if (ix == numRows - 1 ||
SigmaX == 0.)
1508 UpperBound = 1. -
calcQ((xUB - CloudCenterX) /
SigmaX);
1511 float TotalIntegrationRange = UpperBound - LowerBound;
1512 x[ix] = TotalIntegrationRange;
1514 LogDebug(
"Pixel Digitizer") << TotalIntegrationRange <<
" " << ix <<
"\n";
1519 for (iy = IPixLeftDownY; iy <= IPixRightUpY; iy++) {
1520 float yUB, yLB, UpperBound, LowerBound;
1522 if (iy == 0 ||
SigmaY == 0.)
1527 LowerBound = 1. -
calcQ((yLB - CloudCenterY) /
SigmaY);
1530 if (iy == numColumns - 1 ||
SigmaY == 0.)
1535 UpperBound = 1. -
calcQ((yUB - CloudCenterY) /
SigmaY);
1538 float TotalIntegrationRange = UpperBound - LowerBound;
1539 y[iy] = TotalIntegrationRange;
1541 LogDebug(
"Pixel Digitizer") << TotalIntegrationRange <<
" " << iy <<
"\n";
1546 for (ix = IPixLeftDownX; ix <= IPixRightUpX; ix++) {
1547 for (iy = IPixLeftDownY; iy <= IPixRightUpY; iy++) {
1549 float ChargeFraction =
Charge *
x[ix] *
y[iy];
1551 if (ChargeFraction > 0.) {
1554 hit_signal[
chan] += ChargeFraction;
1561 LogDebug(
"Pixel Digitizer") <<
" pixel " << ix <<
" " << iy <<
" - " 1562 <<
" " <<
chan <<
" " << ChargeFraction <<
" " << mp.
x() <<
" " << mp.
y() <<
" " 1563 << lp.
x() <<
" " << lp.
y() <<
" " 1574 bool reweighted =
false;
1577 size_t ReferenceIndex4CR = 0;
1579 if (
hit.processType() == 0) {
1580 ReferenceIndex4CR = hitIndex;
1582 hit, hit_signal, hitIndex, ReferenceIndex4CR, tofBin, topol, detID, theSignal,
hit.processType(), makeDSLinks);
1584 std::vector<PSimHit>::const_iterator crSimHit = inputBegin;
1585 ReferenceIndex4CR = FirstHitIndex;
1587 if ((*inputBegin).trackId() !=
hit.trackId()) {
1590 size_t localIndex = FirstHitIndex;
1591 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; localIndex < hitIndex;
1592 ++ssbegin, ++localIndex) {
1593 if ((*ssbegin).detUnitId() != detId) {
1596 if ((*ssbegin).trackId() ==
hit.trackId() && (*ssbegin).processType() == 0) {
1598 ReferenceIndex4CR = localIndex;
1617 for (hit_map_type::const_iterator im = hit_signal.begin(); im != hit_signal.end(); ++im) {
1618 int chan = (*im).first;
1619 if (ReferenceIndex4CR == 0) {
1622 if (
hit.processType() == 0)
1623 ReferenceIndex4CR = hitIndex;
1625 ReferenceIndex4CR = FirstHitIndex;
1627 if ((*inputBegin).trackId() !=
hit.trackId()) {
1630 size_t localIndex = FirstHitIndex;
1631 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; localIndex < hitIndex;
1632 ++ssbegin, ++localIndex) {
1633 if ((*ssbegin).detUnitId() != detId) {
1636 if ((*ssbegin).trackId() ==
hit.trackId() && (*ssbegin).processType() == 0) {
1637 ReferenceIndex4CR = localIndex;
1644 theSignal[
chan] += (makeDSLinks ?
Amplitude((*im).second, &
hit, hitIndex, ReferenceIndex4CR, tofBin, (*im).second)
1645 :
Amplitude((*im).second, (*im).second));
1649 LogDebug(
"Pixel Digitizer") <<
" pixel " << ip.first <<
" " << ip.second <<
" " << theSignal[
chan];
1661 for (std::vector<PSimHit>::const_iterator it =
simHits.begin(), itEnd =
simHits.end(); it != itEnd;
1663 unsigned int detID = (*it).detUnitId();
1678 std::vector<PixelDigi>& digis,
1679 std::vector<PixelDigiSimLink>& simlinks,
1680 std::vector<PixelDigiAddTempInfo>& newClass_Digi_extra,
1683 LogDebug(
"Pixel Digitizer") <<
" make digis " 1689 <<
" List pixels passing threshold ";
1694 signalMaps::const_iterator it =
_signal.find(detID);
1703 std::map<TrackEventId, float> simi;
1706 float signalInElectrons = (*i).second;
1713 if (signalInElectrons >= thePixelThresholdInE &&
1714 signalInElectrons > 0.) {
1716 int chan = (*i).first;
1723 int col = ip.second;
1730 LogDebug(
"Pixel Digitizer") << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons <<
" " <<
adc 1731 << ip.first <<
" " << ip.second;
1735 digis.emplace_back(ip.first, ip.second,
adc);
1739 unsigned int il = 0;
1740 for (
const auto&
info : (*i).second.hitInfos()) {
1743 simi[std::make_pair(
info.trackId(),
info.eventId().rawId())] += (*i).second.individualampl()[il];
1748 for (
const auto&
info : (*i).second.hitInfos()) {
1750 auto found = simi.find(std::make_pair(
info.trackId(),
info.eventId().rawId()));
1751 if (
found == simi.end())
1754 float sum_samechannel =
found->second;
1755 float fraction = sum_samechannel / (*i).second;
1768 for (
const auto&
info : (*i).second.hitInfos()) {
1769 unsigned int CFPostoBeUsed =
info.hitIndex4ChargeRew();
1772 std::vector<PixelDigiAddTempInfo>::iterator loopNewClass;
1773 bool already_present =
false;
1774 for (loopNewClass = newClass_Digi_extra.begin(); loopNewClass != newClass_Digi_extra.end(); ++loopNewClass) {
1775 if (
chan == (
int)loopNewClass->channel() && CFPostoBeUsed == loopNewClass->hitIndex()) {
1776 already_present =
true;
1777 loopNewClass->addCharge(
info.getAmpl());
1780 if (!already_present) {
1781 unsigned int tofBin =
info.tofBin();
1786 auto it2 =
SimHitMap.find((it->second));
1789 const PSimHit& theSimHit = (it2->second)[CFPostoBeUsed];
1790 newClass_Digi_extra.emplace_back(
chan,
1791 info.hitIndex4ChargeRew(),
1811 float thePixelThreshold,
1812 CLHEP::HepRandomEngine* engine) {
1821 float theSmearedChargeRMS = 0.0;
1825 if ((*i).second < 3000) {
1826 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1827 }
else if ((*i).second < 6000) {
1828 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1830 theSmearedChargeRMS = -432.4 + (*i).second * 0.123;
1834 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1838 if (((*i).second +
Amplitude(
noise + noise_ChargeVCALSmearing, -1.)) < 0.) {
1862 int numColumns = topol->
ncolumns();
1863 int numRows = topol->
nrows();
1867 int numberOfPixels = (numRows * numColumns);
1868 std::map<int, float, std::less<int> > otherPixels;
1869 std::map<int, float, std::less<int> >::iterator mapI;
1880 << otherPixels.size();
1884 for (mapI = otherPixels.begin(); mapI != otherPixels.end(); mapI++) {
1885 int iy = ((*mapI).first) / numRows;
1886 int ix = ((*mapI).first) - (iy * numRows);
1889 if (iy < 0 || iy > (numColumns - 1))
1890 LogWarning(
"Pixel Geometry") <<
" error in iy " << iy;
1891 if (ix < 0 || ix > (numRows - 1))
1892 LogWarning(
"Pixel Geometry") <<
" error in ix " << ix;
1897 LogDebug(
"Pixel Digitizer") <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second <<
" " << ix <<
" " 1898 << iy <<
" " <<
chan;
1901 if (theSignal[
chan] == 0) {
1916 CLHEP::HepRandomEngine* engine) {
1920 int numColumns = topol->
ncolumns();
1921 int numRows = topol->
nrows();
1925 double pixelEfficiency = 1.0;
1926 double columnEfficiency = 1.0;
1927 double chipEfficiency = 1.0;
1928 std::vector<double> pixelEfficiencyROCStdPixels(16, 1);
1929 std::vector<double> pixelEfficiencyROCBigPixels(16, 1);
1931 auto pIndexConverter =
PixelIndices(numColumns, numRows);
1933 std::vector<int> badRocsFromFEDChannels(16, 0);
1939 for (
const auto& ch : *it) {
1940 for (
unsigned int i_roc = ch.roc_first; i_roc <= ch.roc_last; ++i_roc) {
1941 for (
const auto p :
path) {
1943 if (myroc->
idInDetUnit() ==
static_cast<unsigned int>(i_roc)) {
1946 int chipIndex(0), colROC(0), rowROC(0);
1947 pIndexConverter.transformToROC(global.
col, global.
row, chipIndex, colROC, rowROC);
1948 badRocsFromFEDChannels.at(chipIndex) = 1;
1960 int layerIndex = tTopo->
layer(detID);
1964 LogDebug(
"Pixel Digitizer") <<
"Using BPix columnEfficiency = " << columnEfficiency
1965 <<
" for layer = " << layerIndex <<
"\n";
1968 if (numColumns > 416)
1969 LogWarning(
"Pixel Geometry") <<
" wrong columns in barrel " << numColumns;
1971 LogWarning(
"Pixel Geometry") <<
" wrong rows in barrel " << numRows;
1987 unsigned int diskIndex =
1989 unsigned int panelIndex = tTopo->
pxfPanel(detID);
1990 unsigned int moduleIndex = tTopo->
pxfModule(detID);
1996 LogDebug(
"Pixel Digitizer") <<
"Using FPix columnEfficiency = " << columnEfficiency
1997 <<
" for Disk = " << tTopo->
pxfDisk(detID) <<
"\n";
2002 if (numColumns > 260 || numRows > 160) {
2003 if (numColumns > 260)
2004 LogWarning(
"Pixel Geometry") <<
" wrong columns in endcaps " << numColumns;
2006 LogWarning(
"Pixel Geometry") <<
" wrong rows in endcaps " << numRows;
2009 if ((panelIndex == 1 && (moduleIndex == 1 || moduleIndex == 2)) ||
2010 (panelIndex == 2 && moduleIndex == 1)) {
2019 pixelEfficiency = 0.999;
2020 columnEfficiency = 0.999;
2021 chipEfficiency = 0.999;
2036 LogDebug(
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" " << columnEfficiency <<
" " 2046 std::map<int, int, std::less<int> > chips,
columns, pixelStd, pixelBig;
2047 std::map<int, int, std::less<int> >::iterator iter;
2052 int chan =
i->first;
2055 int col = ip.second;
2057 pIndexConverter.transformToROC(
col, row, chipIndex, colROC, rowROC);
2058 int dColInChip = pIndexConverter.DColumn(colROC);
2060 int dColInDet = pIndexConverter.DColumnInModule(dColInChip, chipIndex);
2066 pixelBig[chipIndex]++;
2068 pixelStd[chipIndex]++;
2073 for (iter = chips.begin(); iter != chips.end(); iter++) {
2075 float rand = CLHEP::RandFlat::shoot(engine);
2076 if (rand > chipEfficiency)
2077 chips[iter->first] = 0;
2083 float rand = CLHEP::RandFlat::shoot(engine);
2084 if (rand > columnEfficiency)
2090 for (iter = pixelStd.begin(); iter != pixelStd.end(); iter++) {
2091 float rand = CLHEP::RandFlat::shoot(engine);
2092 if (rand > pixelEfficiencyROCStdPixels[iter->first])
2093 pixelStd[iter->first] = 0;
2096 for (iter = pixelBig.begin(); iter != pixelBig.end(); iter++) {
2097 float rand = CLHEP::RandFlat::shoot(engine);
2098 if (rand > pixelEfficiencyROCBigPixels[iter->first])
2099 pixelBig[iter->first] = 0;
2109 int col = ip.second;
2111 pIndexConverter.transformToROC(
col, row, chipIndex, colROC, rowROC);
2112 int dColInChip = pIndexConverter.DColumn(colROC);
2114 int dColInDet = pIndexConverter.DColumnInModule(dColInChip, chipIndex);
2117 float rand = CLHEP::RandFlat::shoot(engine);
2118 if (chips[chipIndex] == 0 ||
columns[dColInDet] == 0 || rand > pixelEfficiency ||
2119 (pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0) ||
2120 (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)) {
2125 if ((pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0) ||
2126 (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0) || (badRocsFromFEDChannels.at(chipIndex) == 1)) {
2148 float pseudoRadDamage = 0.0f;
2153 int layerIndex = tTopo->
layer(detID);
2155 pseudoRadDamage =
aging.thePixelPseudoRadDamage[layerIndex - 1];
2157 LogDebug(
"Pixel Digitizer") <<
"pixel_aging: " 2159 LogDebug(
"Pixel Digitizer") <<
"Subid " << pixdet->
subDetector() <<
" layerIndex " << layerIndex <<
" ladder " 2165 unsigned int diskIndex =
2168 pseudoRadDamage =
aging.thePixelPseudoRadDamage[diskIndex - 1];
2170 LogDebug(
"Pixel Digitizer") <<
"pixel_aging: " 2172 LogDebug(
"Pixel Digitizer") <<
"Subid " << pixdet->
subDetector() <<
" diskIndex " << diskIndex <<
"\n";
2176 pseudoRadDamage = 0.f;
2179 LogDebug(
"Pixel Digitizer") <<
" pseudoRadDamage " << pseudoRadDamage <<
"\n";
2180 LogDebug(
"Pixel Digitizer") <<
" end pixel_aging " 2183 return pseudoRadDamage;
2185 LogDebug(
"Pixel Digitizer") <<
" enter pixel_aging " << pseudoRadDamage;
2203 const float signalInElectrons)
const {
2230 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
2274 LogDebug(
"Pixel Digitizer") <<
" misscalibrate " <<
col <<
" " << row
2277 << signalInElectrons <<
" " << signal <<
" " << newAmp <<
" " 2292 const DetId& detId)
const {
2335 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
2342 alpha2 = lorentzAngle * lorentzAngle;
2352 LogDebug(
"Pixel Digitizer") <<
" The drift direction in local coordinate is " << theDriftDirection;
2355 return theDriftDirection;
2368 int col = ip.second;
2371 LogDebug(
"Pixel Digitizer") <<
"now in isdead check, row " << detID <<
" " <<
col <<
"," << row <<
"\n";
2383 Parameters::const_iterator itDeadModules =
DeadModules.begin();
2386 for (; itDeadModules !=
DeadModules.end(); ++itDeadModules) {
2387 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
2388 if (detid == Dead_detID) {
2410 if (
Module ==
"tbmA" && ip.first >= 80 && ip.first <= 159) {
2414 if (
Module ==
"tbmB" && ip.first <= 79) {
2429 for (
size_t id = 0;
id < disabledModules.size();
id++) {
2430 if (detID == disabledModules[
id].DetID) {
2432 badmodule = disabledModules[
id];
2442 LogDebug(
"Pixel Digitizer") <<
"Hit in: " << detID <<
" errorType " << badmodule.
errorType <<
" BadRocs=" << std::hex
2453 std::vector<GlobalPixel> badrocpositions(0);
2454 for (
unsigned int j = 0;
j < 16;
j++) {
2457 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
2458 for (
IT it =
path.begin(); it !=
path.end(); ++it) {
2463 badrocpositions.push_back(global);
2473 for (std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it) {
2474 if (it->row >= 80 && ip.first >= 80) {
2475 if ((
std::abs(ip.second - it->col) < 26)) {
2477 }
else if (it->row == 120 && ip.second - it->col == 26) {
2479 }
else if (it->row == 119 && it->col - ip.second == 26) {
2482 }
else if (it->row < 80 && ip.first < 80) {
2483 if ((
std::abs(ip.second - it->col) < 26)) {
2485 }
else if (it->row == 40 && ip.second - it->col == 26) {
2487 }
else if (it->row == 39 && it->col - ip.second == 26) {
2499 std::vector<PixelDigi>& digis,
2500 std::vector<PixelSimHitExtraInfo>& newClass_Sim_extra,
2502 CLHEP::HepRandomEngine* engine) {
2505 std::vector<PixelDigi> New_digis;
2509 LogError(
"PixelDigitizer ") <<
" ******************************** \n";
2510 LogError(
"PixelDigitizer ") <<
" ******************************** \n";
2511 LogError(
"PixelDigitizer ") <<
" ***** INCONSISTENCY !!! ***** \n";
2513 <<
" applyLateReweighting_ and UseReweighting can not be true at the same time for PU ! \n";
2514 LogError(
"PixelDigitizer ") <<
" ---> DO NOT APPLY CHARGE REWEIGHTING TWICE !!! \n";
2515 LogError(
"PixelDigitizer ") <<
" ******************************** \n";
2516 LogError(
"PixelDigitizer ") <<
" ******************************** \n";
2520 float thePixelThresholdInE = 0.;
2523 int lay = tTopo->
layer(detID);
2528 thePixelThresholdInE = CLHEP::RandGaussQ::shoot(
2530 }
else if (lay == 2) {
2531 thePixelThresholdInE = CLHEP::RandGaussQ::shoot(
2534 thePixelThresholdInE =
2543 }
else if (lay == 2) {
2554 thePixelThresholdInE =
2561 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
2567 bool reweighted =
false;
2568 std::vector<PixelSimHitExtraInfo>::iterator loopTempSH;
2569 for (loopTempSH = newClass_Sim_extra.begin(); loopTempSH != newClass_Sim_extra.end(); ++loopTempSH) {
2573 pixdet, digis, TheNewInfo, theDigiSignal, tTopo, engine);
2576 std::vector<PixelDigi>::const_iterator loopDigi;
2577 for (loopDigi = digis.begin(); loopDigi != digis.end(); ++loopDigi) {
2578 unsigned int chan = loopDigi->channel();
2580 if (loopTempSH->isInTheList(
chan)) {
2581 float corresponding_charge = loopDigi->adc();
2582 theDigiSignal[
chan] +=
Amplitude(corresponding_charge, corresponding_charge);
2590 float signalInADC = (*i).second;
2591 if (signalInADC > 0.) {
2592 if (signalInADC >= Thresh_inADC) {
2593 int chan = (*i).first;
2595 int adc =
int(signalInADC);
2599 int col = ip.second;
2608 LogDebug(
"Pixel Digitizer") << (*i).first <<
" " << (*i).second <<
" " << signalInADC <<
" " <<
adc 2609 << ip.first <<
" " << ip.second;
2613 New_digis.emplace_back(ip.first, ip.second,
adc);
2617 theDigiSignal.clear();
void init(const edm::EventSetup &es)
static std::pair< int, int > channelToPixelROC(const int chan)
void fillSimHitMaps(std::vector< PSimHit > simHits, const unsigned int tofBin)
const float theThresholdInE_BPix_L2
double theOuterEfficiency_FPix[20]
T getParameter(std::string const &) const
void pixel_inefficiency_db(uint32_t detID)
unsigned int pxbLayer(const DetId &id) const
signal_map_type::const_iterator signal_map_const_iterator
Local3DVector LocalVector
const bool use_deadmodule_DB_
const float electronsPerVCAL
const double theThresholdSmearing_FPix
Point3DBase< Scalar, LocalTag > LocalPoint
std::map< unsigned int, probabilityVec > probabilityMap
void tanh(data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
const std::unique_ptr< SiPixelGainCalibrationOfflineSimService > theSiPixelGainCalibrationService_
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
static std::pair< int, int > channelToPixel(int ch)
const std::map< unsigned int, double > & getPixelGeomFactors() const
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
virtual int ncolumns() const =0
const float tanLorentzAnglePerTesla_FPix
PixelEfficiencies pixelEfficiencies_
const std::unique_ptr< SiG4UniversalFluctuation > fluctuate
const int theAdcFullScale
PixelEfficiencies(const edm::ParameterSet &conf, bool AddPixelInefficiency, int NumberOfBarrelLayers, int NumberOfEndcapDisks)
unsigned int pxfModule(const DetId &id) const
const GeomDetType & type() const override
virtual int rowsperroc() const =0
bool exists(std::string const ¶meterName) const
checks if a parameter exists
const double theThresholdSmearing_BPix_L1
const std::map< unsigned int, double > & getColGeomFactors() const
virtual int nrows() const =0
edm::ESGetToken< SiPixelQualityProbabilities, SiPixelStatusScenarioProbabilityRcd > scenarioProbabilityToken_
Local3DPoint exitPoint() const
Exit point in the local Det frame.
const float theThresholdInE_FPix
std::unique_ptr< PixelFEDChannelCollection > PixelFEDChannelCollection_
const double theThresholdSmearing_BPix
std::vector< std::vector< double > > thePUEfficiency
std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const final
const std::vector< int > & getMix_bunchCrossing() const
const float electronsPerVCAL_Offset
void make_digis(float thePixelThresholdInE, uint32_t detID, const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelDigiSimLink > &simlinks, std::vector< PixelDigiAddTempInfo > &newClass_Digi_extra, const TrackerTopology *tTopo) const
const bool addThresholdSmearing
float pixel_aging(const PixelAging &aging, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo) const
void module_killing_conf(uint32_t detID)
const bool fluctuateCharge
unsigned int pxbLadder(const DetId &id) const
Log< level::Error, false > LogError
std::map< uint32_t, size_t > iPU
void drift(const PSimHit &hit, const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const TrackerTopology *tTopo, const std::vector< EnergyDepositUnit > &ionization_points, std::vector< SignalPoint > &collection_points) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
~SiPixelDigitizerAlgorithm()
constexpr Detector det() const
get the detector field from this detid
const float GeVperElectron
const double theThresholdSmearing_BPix_L2
identify pixel inside single ROC
const bool doMissCalInLateCR
const SiPixelDynamicInefficiency * SiPixelDynamicInefficiency_
unsigned int layer(const DetId &id) const
std::unique_ptr< SiPixelChargeReweightingAlgorithm > TheNewSiPixelChargeReweightingAlgorithmClass
bool isTrackerPixel() const
const bool use_ineff_from_db_
constexpr std::array< uint8_t, layerIndexSize > layer
static int pixelToChannel(int row, int col)
global coordinates (row and column in DetUnit, as in PixelDigi)
virtual float thickness() const =0
void induce_signal(std::vector< PSimHit >::const_iterator inputBegin, std::vector< PSimHit >::const_iterator inputEnd, const PSimHit &hit, const size_t hitIndex, const size_t FirstHitIndex, const unsigned int tofBin, const PixelGeomDetUnit *pixdet, const std::vector< SignalPoint > &collection_points)
const bool use_LorentzAngle_DB_
const std::map< unsigned int, std::vector< double > > & getPUFactors() const
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
Container::value_type value_type
LocalVector DriftDirection(const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const DetId &detId) const
edm::ESGetToken< SiPixelQuality, SiPixelQualityRcd > SiPixelBadModuleToken_
const std::vector< disabledModuleType > getBadComponentList() const
SiPixelDigitizerAlgorithm(const edm::ParameterSet &conf, edm::ConsumesCollector iC)
const PixelFEDChannelCollectionMap * quality_map
const bool store_SimHitEntryExitPoints_
const std::vector< uint32_t > getDetIdmasks() const
std::pair< unsigned int, unsigned int > subDetTofBin
void digitize(const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelDigiSimLink > &simlinks, std::vector< PixelDigiAddTempInfo > &newClass_Digi_extra, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
double theInstLumiScaleFactor
const Parameters DeadModules
std::map< uint32_t, std::vector< double > > PixelGeomFactorsROCBigPixels
virtual bool isItBigPixelInX(int ixbin) const =0
double thePixelChipEfficiency[20]
virtual int colsperroc() const =0
const float theTofUpperCut
void primary_ionization(const PSimHit &hit, std::vector< EnergyDepositUnit > &ionization_points, CLHEP::HepRandomEngine *) const
const bool use_module_killing_
GlobalPixel toGlobal(const LocalPixel &loc) const
std::vector< double > pu_scale
void module_killing_DB(uint32_t detID)
probabilityVec getProbabilities(const unsigned int puBin) const
static int pixelToChannelROC(const int rowROC, const int colROC)
virtual bool isItBigPixelInY(int iybin) const =0
unsigned short processType() const
const std::map< unsigned int, double > & getChipGeomFactors() const
unsigned int pxfDisk(const DetId &id) const
const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const final
Abs< T >::type abs(const T &t)
double calcQ(float x) const
const float theThresholdInE_BPix
double theInnerEfficiency_FPix[20]
const SiPixelLorentzAngle * SiPixelLorentzAngle_
Local3DPoint entryPoint() const
Entry point in the local Det frame.
virtual int channel(const LocalPoint &p) const =0
const int NumberOfEndcapDisks
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
std::vector< double > theModuleEfficiency_BPix[20]
bool getData(T &iHolder) const
float missCalibrate(uint32_t detID, const TrackerTopology *tTopo, const PixelGeomDetUnit *pixdet, int col, int row, float amp) const
unsigned int trackId() const
std::vector< LinkConnSpec >::const_iterator IT
void init_from_db(const TrackerGeometry *, const SiPixelDynamicInefficiency *)
edm::ESGetToken< SiPixelLorentzAngle, SiPixelLorentzAngleSimRcd > SiPixelLorentzAngleToken_
signal_map_type::iterator signal_map_iterator
void init_DynIneffDB(const edm::EventSetup &)
DetId geographicalId() const
The label of this GeomDet.
std::unique_ptr< PixelFEDChannelCollection > chooseScenario(PileupMixingContent *puInfo, CLHEP::HepRandomEngine *)
const float theThresholdInE_BPix_L1
const float electronsPerVCAL_L1_Offset
void setSimAccumulator(const std::map< uint32_t, std::map< int, int > > &signalMap)
const bool UseReweighting
edm::ESGetToken< PixelFEDChannelCollectionMap, SiPixelFEDChannelContainerESProducerRcd > PixelFEDChannelCollectionMapToken_
const std::map< int, CalParameters, std::less< int > > calmap
const bool doMissCalibrate
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const bool AddPixelInefficiency
unsigned int pxfPanel(const DetId &id) const
const bool addChargeVCALSmearing
const int theAdcFullScLateCR
Log< level::Info, false > LogInfo
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const std::unique_ptr< GaussianTailNoiseGenerator > theNoiser
const float theNoiseInElectrons
std::map< int, Amplitude, std::less< int > > signal_map_type
const SiPixelQuality * SiPixelBadModule_
const SiPixelFedCablingMap * map_
const Plane & surface() const
The nominal surface of the GeomDet.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const float electronsPerVCAL_L1
const PositionType & position() const
std::map< uint32_t, std::vector< double > > PixelGeomFactorsROCStdPixels
double thePixelColEfficiency[20]
const std::vector< float > & getMix_TrueInteractions() const
constexpr uint32_t rawId() const
get the raw id
void calculateInstlumiFactor(PileupMixingContent *puInfo)
void accumulateSimHits(const std::vector< PSimHit >::const_iterator inputBegin, const std::vector< PSimHit >::const_iterator inputEnd, const size_t inputBeginGlobalIndex, const unsigned int tofBin, const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
row and collumn in ROC representation
virtual SubDetector subDetector() const
Which subdetector.
static const GlobalPoint notFound(0, 0, 0)
const float tanLorentzAnglePerTesla_BPix
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
const SiPixelQualityProbabilities * scenarioProbability_
void fluctuateEloss(int particleId, float momentum, float eloss, float length, int NumberOfSegments, float elossVector[], CLHEP::HepRandomEngine *) const
bool matches(const DetId &, const DetId &, const std::vector< uint32_t > &)
void lateSignalReweight(const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelSimHitExtraInfo > &newClass_Sim_extra, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *engine)
std::vector< edm::ParameterSet > Parameters
const bool KillBadFEDChannels
std::vector< double > theLadderEfficiency_BPix[20]
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
const float theReadoutNoise
EcalLogicID subdetID(EcalSubdetector)
const TrackerGeometry * geom_
short getBadRocs(const uint32_t &detid) const
static unsigned int const shift
edm::ESGetToken< SiPixelDynamicInefficiency, SiPixelDynamicInefficiencyRcd > SiPixelDynamicInefficiencyToken_
std::map< uint32_t, double > ColGeomFactors
const RotationType & rotation() const
std::map< int, CalParameters, std::less< int > > initCal() const
double thePixelEfficiency[20]
virtual std::pair< float, float > pitch() const =0
simhit_collectionMap SimHitCollMap
PixelAging(const edm::ParameterSet &conf, bool AddPixelAging, int NumberOfBarrelLayers, int NumberOfEndcapDisks)
const float theTofLowerCut
unsigned int pxbModule(const DetId &id) const
Log< level::Warning, false > LogWarning
bool killBadFEDChannels() const
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
std::map< uint32_t, double > PixelGeomFactors
std::map< uint32_t, double > ChipGeomFactors
const bool addNoisyPixels
const PixelAging pixelAging_
float getLorentzAngle(const uint32_t &) const
const float theElectronPerADC
const bool makeDigiSimLinks_
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
const int NumberOfBarrelLayers
double gettheInstLumiScaleFactor() const
uint16_t *__restrict__ uint16_t const *__restrict__ adc
void add_noise(const PixelGeomDetUnit *pixdet, float thePixelThreshold, CLHEP::HepRandomEngine *)
void pixel_inefficiency(const PixelEfficiencies &eff, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
const Bounds & bounds() const