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"
105 using namespace sipixelobjects;
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(),
152 std::back_inserter(notFound),
154 return (
std::find(allScenarios.begin(), allScenarios.end(),
arg) == allScenarios.end());
157 if (!notFound.empty()) {
158 for (
const auto&
entry : notFound) {
159 LogError(
"SiPixelFEDChannelContainer")
160 <<
"The requested scenario: " <<
entry <<
" is not found in the map!! \n";
162 throw cms::Exception(
"SiPixelDigitizerAlgorithm") <<
"Found: " << notFound.size()
163 <<
" missing scenario(s) in SiPixelStatusScenariosRcd while "
164 "present in SiPixelStatusScenarioProbabilityRcd \n";
168 TheNewSiPixelChargeReweightingAlgorithmClass->init(es);
178 makeDigiSimLinks_(conf.getUntrackedParameter<bool>(
"makeDigiSimLinks",
true)),
179 use_ineff_from_db_(conf.getParameter<bool>(
"useDB")),
180 use_module_killing_(conf.getParameter<bool>(
"killModules")),
181 use_deadmodule_DB_(conf.getParameter<bool>(
"DeadModules_DB")),
182 use_LorentzAngle_DB_(conf.getParameter<bool>(
"LorentzAngle_DB")),
185 : conf.getParameter<
Parameters>(
"DeadModules")),
187 TheNewSiPixelChargeReweightingAlgorithmClass(),
191 GeVperElectron(3.61E-09),
194 alpha2Order(conf.getParameter<bool>(
"Alpha2Order")),
200 NumberOfBarrelLayers(conf.exists(
"NumPixelBarrel") ? conf.getParameter<int>(
"NumPixelBarrel") : 3),
201 NumberOfEndcapDisks(conf.exists(
"NumPixelEndcap") ? conf.getParameter<int>(
"NumPixelEndcap") : 2),
208 theElectronPerADC(conf.getParameter<double>(
"ElectronPerAdc")),
212 theAdcFullScale(conf.getParameter<int>(
"AdcFullScale")),
216 theNoiseInElectrons(conf.getParameter<double>(
"NoiseInElectrons")),
220 theReadoutNoise(conf.getParameter<double>(
"ReadoutNoiseInElec")),
225 theThresholdInE_FPix(conf.getParameter<double>(
"ThresholdInElectrons_FPix")),
226 theThresholdInE_BPix(conf.getParameter<double>(
"ThresholdInElectrons_BPix")),
227 theThresholdInE_BPix_L1(conf.exists(
"ThresholdInElectrons_BPix_L1")
228 ? conf.getParameter<double>(
"ThresholdInElectrons_BPix_L1")
229 : theThresholdInE_BPix),
230 theThresholdInE_BPix_L2(conf.exists(
"ThresholdInElectrons_BPix_L2")
231 ? conf.getParameter<double>(
"ThresholdInElectrons_BPix_L2")
232 : theThresholdInE_BPix),
235 theThresholdSmearing_FPix(conf.getParameter<double>(
"ThresholdSmearing_FPix")),
236 theThresholdSmearing_BPix(conf.getParameter<double>(
"ThresholdSmearing_BPix")),
237 theThresholdSmearing_BPix_L1(conf.exists(
"ThresholdSmearing_BPix_L1")
238 ? conf.getParameter<double>(
"ThresholdSmearing_BPix_L1")
239 : theThresholdSmearing_BPix),
240 theThresholdSmearing_BPix_L2(conf.exists(
"ThresholdSmearing_BPix_L2")
241 ? conf.getParameter<double>(
"ThresholdSmearing_BPix_L2")
242 : theThresholdSmearing_BPix),
245 electronsPerVCAL(conf.getParameter<double>(
"ElectronsPerVcal")),
246 electronsPerVCAL_Offset(conf.getParameter<double>(
"ElectronsPerVcal_Offset")),
247 electronsPerVCAL_L1(conf.exists(
"ElectronsPerVcal_L1") ? conf.getParameter<double>(
"ElectronsPerVcal_L1")
249 electronsPerVCAL_L1_Offset(conf.exists(
"ElectronsPerVcal_L1_Offset")
250 ? conf.getParameter<double>(
"ElectronsPerVcal_L1_Offset")
251 : electronsPerVCAL_Offset),
255 theTofLowerCut(conf.getParameter<double>(
"TofLowerCut")),
256 theTofUpperCut(conf.getParameter<double>(
"TofUpperCut")),
259 tanLorentzAnglePerTesla_FPix(use_LorentzAngle_DB_ ? 0.0
260 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_FPix")),
261 tanLorentzAnglePerTesla_BPix(use_LorentzAngle_DB_ ? 0.0
262 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_BPix")),
265 FPix_p0(conf.getParameter<double>(
"FPix_SignalResponse_p0")),
266 FPix_p1(conf.getParameter<double>(
"FPix_SignalResponse_p1")),
267 FPix_p2(conf.getParameter<double>(
"FPix_SignalResponse_p2")),
268 FPix_p3(conf.getParameter<double>(
"FPix_SignalResponse_p3")),
270 BPix_p0(conf.getParameter<double>(
"BPix_SignalResponse_p0")),
271 BPix_p1(conf.getParameter<double>(
"BPix_SignalResponse_p1")),
272 BPix_p2(conf.getParameter<double>(
"BPix_SignalResponse_p2")),
273 BPix_p3(conf.getParameter<double>(
"BPix_SignalResponse_p3")),
276 addNoise(conf.getParameter<bool>(
"AddNoise")),
280 addChargeVCALSmearing(conf.getParameter<bool>(
"ChargeVCALSmearing")),
283 addNoisyPixels(conf.getParameter<bool>(
"AddNoisyPixels")),
286 fluctuateCharge(conf.getUntrackedParameter<bool>(
"FluctuateCharge",
true)),
293 addThresholdSmearing(conf.getParameter<bool>(
"AddThresholdSmearing")),
296 doMissCalibrate(conf.getParameter<bool>(
"MissCalibrate")),
297 theGainSmearing(conf.getParameter<double>(
"GainSmearing")),
298 theOffsetSmearing(conf.getParameter<double>(
"OffsetSmearing")),
301 AddPixelAging(conf.getParameter<bool>(
"DoPixelAging")),
302 UseReweighting(conf.getParameter<bool>(
"UseReweighting")),
307 tMax(conf.getParameter<double>(
"deltaProductionCut")),
311 calmap(doMissCalibrate ? initCal() : std::map<int,
CalParameters, std::less<int> >()),
315 pixelAging_(conf, AddPixelAging, NumberOfBarrelLayers, NumberOfEndcapDisks) {
338 LogInfo(
"PixelDigitizer ") <<
"SiPixelDigitizerAlgorithm constructed"
339 <<
"Configuration parameters:"
340 <<
"Threshold/Gain = "
352 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
calmap;
354 LogDebug(
"PixelDigitizer ") <<
" miss-calibrate the pixel amplitude \n";
356 const bool ReadCalParameters =
false;
357 if (ReadCalParameters) {
359 std::ifstream in_file;
360 char filename[80] =
"phCalibrationFit_C0.dat";
364 LogInfo(
"PixelDigitizer ") <<
" File not found \n ";
367 LogInfo(
"PixelDigitizer ") <<
" file opened : " << filename <<
"\n";
370 for (
int i = 0;
i < 3;
i++) {
371 in_file.getline(line, 500,
'\n');
372 LogInfo(
"PixelDigitizer ") << line <<
"\n";
375 LogInfo(
"PixelDigitizer ") <<
" test map"
378 float par0, par1, par2, par3;
382 for (
int i = 0;
i < (52 * 80);
i++) {
383 in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid >> rowid;
385 LogError(
"PixelDigitizer") <<
"Cannot read data file for calmap"
389 if (in_file.eof() != 0) {
390 LogError(
"PixelDigitizer") <<
"calmap " << in_file.eof() <<
" " << in_file.gcount() <<
" " << in_file.fail()
391 <<
" " << in_file.good() <<
" end of file "
396 LogDebug(
"PixelDigitizer ") <<
" line " <<
i <<
" " << par0 <<
" " << par1 <<
" " << par2 <<
" " << par3 <<
" "
397 << colid <<
" " << rowid <<
"\n";
407 calmap.insert(std::pair<int, CalParameters>(chan, onePix));
411 if (rowid != p.first)
412 LogInfo(
"PixelDigitizer ") <<
" wrong channel row " << rowid <<
" " << p.first <<
"\n";
413 if (colid != p.second)
414 LogInfo(
"PixelDigitizer ") <<
" wrong channel col " << colid <<
" " << p.second <<
"\n";
418 LogInfo(
"PixelDigitizer ") <<
" map size " << calmap.size() <<
" max " << calmap.max_size() <<
" "
419 << calmap.empty() <<
"\n";
442 LogDebug(
"PixelDigitizer") <<
"SiPixelDigitizerAlgorithm deleted";
448 int NumberOfBarrelLayers,
449 int NumberOfEndcapDisks) {
454 if (AddPixelInefficiency) {
456 conf.
exists(
"thePixelColEfficiency_BPix3") && conf.
exists(
"thePixelColEfficiency_FPix1") &&
457 conf.
exists(
"thePixelColEfficiency_FPix2") && conf.
exists(
"thePixelEfficiency_BPix1") &&
458 conf.
exists(
"thePixelEfficiency_BPix2") && conf.
exists(
"thePixelEfficiency_BPix3") &&
459 conf.
exists(
"thePixelEfficiency_FPix1") && conf.
exists(
"thePixelEfficiency_FPix2") &&
460 conf.
exists(
"thePixelChipEfficiency_BPix1") && conf.
exists(
"thePixelChipEfficiency_BPix2") &&
461 conf.
exists(
"thePixelChipEfficiency_BPix3") && conf.
exists(
"thePixelChipEfficiency_FPix1") &&
462 conf.
exists(
"thePixelChipEfficiency_FPix2");
463 if (NumberOfBarrelLayers == 3)
465 conf.
exists(
"theLadderEfficiency_BPix3") && conf.
exists(
"theModuleEfficiency_BPix1") &&
466 conf.
exists(
"theModuleEfficiency_BPix2") && conf.
exists(
"theModuleEfficiency_BPix3") &&
467 conf.
exists(
"thePUEfficiency_BPix1") && conf.
exists(
"thePUEfficiency_BPix2") &&
468 conf.
exists(
"thePUEfficiency_BPix3") && conf.
exists(
"theInnerEfficiency_FPix1") &&
469 conf.
exists(
"theInnerEfficiency_FPix2") && conf.
exists(
"theOuterEfficiency_FPix1") &&
470 conf.
exists(
"theOuterEfficiency_FPix2") && conf.
exists(
"thePUEfficiency_FPix_Inner") &&
471 conf.
exists(
"thePUEfficiency_FPix_Outer") && conf.
exists(
"theInstLumiScaleFactor");
472 if (NumberOfBarrelLayers >= 4)
474 conf.
exists(
"thePixelEfficiency_BPix4") && conf.
exists(
"thePixelChipEfficiency_BPix4");
475 if (NumberOfEndcapDisks >= 3)
477 conf.
exists(
"thePixelEfficiency_FPix3") && conf.
exists(
"thePixelChipEfficiency_FPix3");
479 LogInfo(
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the config file.\n";
484 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix3");
485 if (NumberOfBarrelLayers >= 4) {
486 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix4");
492 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix3");
493 if (NumberOfBarrelLayers >= 4) {
494 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix4");
500 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix3");
501 if (NumberOfBarrelLayers >= 4) {
502 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix4");
505 if (NumberOfBarrelLayers == 3) {
509 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix3");
510 if (((theLadderEfficiency_BPix[0].
size() != 20) || (theLadderEfficiency_BPix[1].
size() != 32) ||
511 (theLadderEfficiency_BPix[2].
size() != 44)) &&
512 (NumberOfBarrelLayers == 3))
513 throw cms::Exception(
"Configuration") <<
"Wrong ladder number in efficiency config!";
518 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix3");
519 if (((theModuleEfficiency_BPix[0].
size() != 4) || (theModuleEfficiency_BPix[1].
size() != 4) ||
520 (theModuleEfficiency_BPix[2].
size() != 4)) &&
521 (NumberOfBarrelLayers == 3))
522 throw cms::Exception(
"Configuration") <<
"Wrong module number in efficiency config!";
528 (NumberOfBarrelLayers == 3))
530 <<
"At least one PU efficiency (BPix) number is needed in efficiency config!";
533 if (NumberOfBarrelLayers >= 5) {
534 if (NumberOfTotLayers > 20) {
535 throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";
539 thePixelColEfficiency[
j - 1] = 0.999;
540 thePixelEfficiency[
j - 1] = 0.999;
541 thePixelChipEfficiency[
j - 1] = 0.999;
546 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix1");
547 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix2");
548 if (NumberOfEndcapDisks >= 3) {
549 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix3");
552 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix1");
553 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix2");
554 if (NumberOfEndcapDisks >= 3) {
555 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix3");
558 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix1");
559 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix2");
560 if (NumberOfEndcapDisks >= 3) {
561 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix3");
564 if (NumberOfEndcapDisks >= 4) {
565 if (NumberOfTotLayers > 20) {
566 throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";
570 thePixelColEfficiency[
j - 1] = 0.999;
571 thePixelEfficiency[
j - 1] = 0.999;
572 thePixelChipEfficiency[
j - 1] = 0.999;
576 if (NumberOfBarrelLayers == 3) {
587 <<
"At least one (FPix) PU efficiency number is needed in efficiency config!";
591 LogInfo(
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the database.\n";
610 const std::map<uint32_t, double>& PixelGeomFactorsDBIn = SiPixelDynamicInefficiency->
getPixelGeomFactors();
611 const std::map<uint32_t, double>& ColGeomFactorsDB = SiPixelDynamicInefficiency->
getColGeomFactors();
612 const std::map<uint32_t, double>& ChipGeomFactorsDB = SiPixelDynamicInefficiency->
getChipGeomFactors();
613 const std::map<uint32_t, std::vector<double> >& PUFactors = SiPixelDynamicInefficiency->
getPUFactors();
614 std::vector<uint32_t> DetIdmasks = SiPixelDynamicInefficiency->
getDetIdmasks();
617 for (
const auto& it_module : geom->
detUnits()) {
618 if (dynamic_cast<PixelGeomDetUnit const*>(it_module) ==
nullptr)
620 const DetId detid = it_module->geographicalId();
621 uint32_t rawid = detid.
rawId();
622 PixelGeomFactors[rawid] = 1;
623 ColGeomFactors[rawid] = 1;
624 ChipGeomFactors[rawid] = 1;
625 PixelGeomFactorsROCStdPixels[rawid] = std::vector<double>(16, 1);
626 PixelGeomFactorsROCBigPixels[rawid] = std::vector<double>(16, 1);
630 std::map<uint32_t, double> PixelGeomFactorsDB;
632 LogDebug(
"PixelDigitizer ") <<
" Check PixelEfficiencies -- PixelGeomFactorsDBIn "
635 for (
auto db_factor : PixelGeomFactorsDBIn) {
636 LogDebug(
"PixelDigitizer ") <<
" db_factor " << db_factor.first <<
" " << db_factor.second <<
"\n";
640 unsigned int rocMask = rocIdMaskBits <<
shift;
641 unsigned int rocId = (((db_factor.first) & rocMask) >>
shift);
644 unsigned int rawid = db_factor.first & (~rocMask);
649 double factor = db_factor.second;
650 double badFraction = 1 - factor;
651 double bigPixelFraction =
static_cast<double>(nBigPixelsInROC) / nPixelsInROC;
652 double stdPixelFraction = 1. - bigPixelFraction;
654 double badFractionBig =
std::min(bigPixelFraction, badFraction);
655 double badFractionStd =
std::max(0., badFraction - badFractionBig);
656 double badFractionBigReNormalized = badFractionBig / bigPixelFraction;
657 double badFractionStdReNormalized = badFractionStd / stdPixelFraction;
658 PixelGeomFactorsROCStdPixels[rawid][rocId] *= (1. - badFractionStdReNormalized);
659 PixelGeomFactorsROCBigPixels[rawid][rocId] *= (1. - badFractionBigReNormalized);
661 PixelGeomFactorsDB[db_factor.first] = db_factor.second;
666 PixelGeomFactorsDB = PixelGeomFactorsDBIn;
670 <<
" Check PixelEfficiencies -- Loop on all modules and store module level geometrical scale factors "
673 for (
const auto& it_module : geom->
detUnits()) {
674 if (dynamic_cast<PixelGeomDetUnit const*>(it_module) ==
nullptr)
676 const DetId detid = it_module->geographicalId();
677 uint32_t rawid = detid.
rawId();
678 for (
auto db_factor : PixelGeomFactorsDB) {
679 LogDebug(
"PixelDigitizer ") <<
" db_factor PixelGeomFactorsDB " << db_factor.first <<
" "
680 << db_factor.second <<
"\n";
681 if (matches(detid,
DetId(db_factor.first), DetIdmasks))
682 PixelGeomFactors[rawid] *= db_factor.second;
684 for (
auto db_factor : ColGeomFactorsDB) {
685 LogDebug(
"PixelDigitizer ") <<
" db_factor ColGeomFactorsDB " << db_factor.first <<
" " << db_factor.second
687 if (matches(detid,
DetId(db_factor.first), DetIdmasks))
688 ColGeomFactors[rawid] *= db_factor.second;
690 for (
auto db_factor : ChipGeomFactorsDB) {
691 LogDebug(
"PixelDigitizer ") <<
" db_factor ChipGeomFactorsDB " << db_factor.first <<
" "
692 << db_factor.second <<
"\n";
693 if (matches(detid,
DetId(db_factor.first), DetIdmasks))
694 ChipGeomFactors[rawid] *= db_factor.second;
701 LogDebug(
"PixelDigitizer ") <<
" Check PixelEfficiencies -- PUFactors "
703 for (
const auto& factor : PUFactors) {
705 LogDebug(
"PixelDigitizer ") <<
" factor " << factor.first <<
" " << factor.second.size() <<
"\n";
706 for (
size_t i = 0,
n = factor.second.size(); i <
n; i++) {
707 LogDebug(
"PixelDigitizer ") <<
" print factor.second for " << i <<
" " << factor.second[
i] <<
"\n";
711 for (
const auto& it_module : geom->
detUnits()) {
712 if (dynamic_cast<PixelGeomDetUnit const*>(it_module) ==
nullptr)
714 const DetId detid = it_module->geographicalId();
715 if (!matches(detid, db_id, DetIdmasks))
717 if (iPU.count(detid.
rawId())) {
719 <<
"Multiple db_ids match to same module in SiPixelDynamicInefficiency DB Object";
724 thePUEfficiency.push_back(factor.second);
727 pu_scale.resize(thePUEfficiency.size());
732 const std::vector<uint32_t>& DetIdmasks) {
735 for (
size_t i = 0;
i < DetIdmasks.size(); ++
i) {
757 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix1");
758 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix2");
759 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix3");
760 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix4");
763 if (NumberOfBarrelLayers >= 5) {
764 if (NumberOfTotLayers > 20) {
765 throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";
769 thePixelPseudoRadDamage[
j - 1] = 0.;
774 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix1");
775 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix2");
776 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix3");
779 if (NumberOfEndcapDisks >= 4) {
780 if (NumberOfTotLayers > 20) {
781 throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";
785 thePixelPseudoRadDamage[
j - 1] = 0.;
795 std::vector<PSimHit>::const_iterator inputEnd,
796 const size_t inputBeginGlobalIndex,
797 const unsigned int tofBin,
801 CLHEP::HepRandomEngine* engine) {
806 size_t simHitGlobalIndex = inputBeginGlobalIndex;
807 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
809 if ((*ssbegin).detUnitId() != detId) {
814 LogDebug(
"Pixel Digitizer") << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" "
815 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" " << (*ssbegin).trackId()
816 <<
" " << (*ssbegin).processType() <<
" " << (*ssbegin).detUnitId()
817 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint();
820 std::vector<EnergyDepositUnit> ionization_points;
821 std::vector<SignalPoint> collection_points;
839 inputBeginGlobalIndex,
857 std::vector<int>::const_iterator pu;
858 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
860 for (pu = bunchCrossing.begin(); pu != bunchCrossing.end(); ++pu) {
867 if (pu0 != bunchCrossing.end()) {
870 double instlumi_pow = 1.;
874 instlumi_pow *= instlumi;
888 for (
unsigned int i = 0;
i < ps.size();
i++)
889 if (ps[
i].getBunchCrossing() == 0)
895 double instlumi_pow = 1.;
899 instlumi_pow *= instlumi;
914 const std::vector<PileupSummaryInfo>& ps, CLHEP::HepRandomEngine* engine) {
915 std::unique_ptr<PixelFEDChannelCollection> PixelFEDChannelCollection_ =
nullptr;
918 std::vector<int> bunchCrossing;
919 std::vector<float> TrueInteractionList;
921 for (
unsigned int i = 0;
i < ps.size();
i++) {
922 bunchCrossing.push_back(ps[
i].getBunchCrossing());
923 TrueInteractionList.push_back(ps[
i].getTrueNumInteractions());
927 std::vector<int>::const_iterator pu;
928 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
930 for (pu = bunchCrossing.begin(); pu != bunchCrossing.end(); ++pu) {
938 if (pu0 != bunchCrossing.end()) {
939 unsigned int PUBin = TrueInteractionList.at(
p);
941 std::vector<double> probabilities;
942 probabilities.reserve(theProbabilitiesPerScenario.size());
943 for (
auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++) {
944 probabilities.push_back(it->second);
947 CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size());
948 double x = randGeneral.shoot();
949 unsigned int index = x * probabilities.size() - 1;
952 PixelFEDChannelCollection_ = std::make_unique<PixelFEDChannelCollection>(
quality_map->at(scenario));
954 std::make_unique<PixelFEDChannelCollection>(
quality_map->at(scenario));
957 return PixelFEDChannelCollection_;
961 CLHEP::HepRandomEngine* engine) {
964 std::unique_ptr<PixelFEDChannelCollection> PixelFEDChannelCollection_ =
nullptr;
971 std::vector<int>::const_iterator pu;
972 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
974 for (pu = bunchCrossing.begin(); pu != bunchCrossing.end(); ++pu) {
982 if (pu0 != bunchCrossing.end()) {
983 unsigned int PUBin = TrueInteractionList.at(
p);
985 std::vector<double> probabilities;
986 probabilities.reserve(theProbabilitiesPerScenario.size());
987 for (
auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++) {
988 probabilities.push_back(it->second);
991 CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size());
992 double x = randGeneral.shoot();
993 unsigned int index = x * probabilities.size() - 1;
996 PixelFEDChannelCollection_ = std::make_unique<PixelFEDChannelCollection>(
quality_map->at(scenario));
998 std::make_unique<PixelFEDChannelCollection>(
quality_map->at(scenario));
1001 return PixelFEDChannelCollection_;
1006 for (
const auto& det : signalMap) {
1007 auto& theSignal =
_signal[det.first];
1008 for (
const auto&
chan : det.second) {
1009 theSignal[
chan.first].set(
chan.second *
1017 std::vector<PixelDigi>& digis,
1018 std::vector<PixelDigiSimLink>& simlinks,
1020 CLHEP::HepRandomEngine* engine) {
1032 float thePixelThresholdInE = 0.;
1036 int lay = tTopo->
layer(detID);
1041 thePixelThresholdInE = CLHEP::RandGaussQ::shoot(
1043 }
else if (lay == 2) {
1044 thePixelThresholdInE = CLHEP::RandGaussQ::shoot(
1047 thePixelThresholdInE =
1056 }
else if (lay == 2) {
1065 thePixelThresholdInE =
1071 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1077 int numColumns = topol->
ncolumns();
1078 int numRows = topol->
nrows();
1081 LogDebug(
"PixelDigitizer") <<
" PixelDigitizer " << numColumns <<
" " << numRows <<
" " << moduleThickness;
1103 make_digis(thePixelThresholdInE, detID, pixdet, digis, simlinks, tTopo);
1106 LogDebug(
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit"
1115 std::vector<EnergyDepositUnit>& ionization_points,
1116 CLHEP::HepRandomEngine* engine)
const {
1119 const float SegmentLength = 0.0010;
1126 float length = direction.
mag();
1128 int NumberOfSegments = int(length / SegmentLength);
1129 if (NumberOfSegments < 1)
1130 NumberOfSegments = 1;
1133 LogDebug(
"Pixel Digitizer") <<
" enter primary_ionzation " << NumberOfSegments
1140 float* elossVector =
new float[NumberOfSegments];
1147 float momentum = hit.
pabs();
1149 fluctuateEloss(pid, momentum, eLoss, length, NumberOfSegments, elossVector, engine);
1152 ionization_points.resize(NumberOfSegments);
1155 for (
int i = 0;
i != NumberOfSegments;
i++) {
1165 ionization_points[
i] = edu;
1168 LogDebug(
"Pixel Digitizer") <<
i <<
" " << ionization_points[
i].x() <<
" " << ionization_points[
i].y() <<
" "
1169 << ionization_points[
i].z() <<
" " << ionization_points[
i].energy();
1174 delete[] elossVector;
1181 float particleMomentum,
1185 float elossVector[],
1186 CLHEP::HepRandomEngine* engine)
const {
1192 double particleMass = 139.6;
1196 particleMass = 0.511;
1198 particleMass = 105.7;
1199 else if (pid == 321)
1200 particleMass = 493.7;
1201 else if (pid == 2212)
1202 particleMass = 938.3;
1205 float segmentLength = length / NumberOfSegs;
1210 double segmentEloss = (1000. * eloss) / NumberOfSegs;
1211 for (
int i = 0;
i < NumberOfSegs;
i++) {
1217 double deltaCutoff =
tMax;
1218 de =
fluctuate->SampleFluctuations(
double(particleMomentum * 1000.),
1221 double(segmentLength * 10.),
1225 elossVector[
i] = de;
1231 float ratio = eloss / sum;
1233 for (
int ii = 0;
ii < NumberOfSegs;
ii++)
1234 elossVector[
ii] = ratio * elossVector[
ii];
1236 float averageEloss = eloss / NumberOfSegs;
1237 for (
int ii = 0;
ii < NumberOfSegs;
ii++)
1238 elossVector[
ii] = averageEloss;
1250 const std::vector<EnergyDepositUnit>& ionization_points,
1251 std::vector<SignalPoint>& collection_points)
const {
1253 LogDebug(
"Pixel Digitizer") <<
" enter drift ";
1256 collection_points.resize(ionization_points.size());
1259 if (driftDir.
z() == 0.) {
1260 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
1268 float TanLorenzAngleX, TanLorenzAngleY, dir_z, CosLorenzAngleX, CosLorenzAngleY;
1270 TanLorenzAngleX = driftDir.
x();
1271 TanLorenzAngleY = driftDir.
y();
1272 dir_z = driftDir.
z();
1273 CosLorenzAngleX = 1. /
sqrt(1. + TanLorenzAngleX * TanLorenzAngleX);
1274 CosLorenzAngleY = 1. /
sqrt(1. + TanLorenzAngleY * TanLorenzAngleY);
1277 TanLorenzAngleX = driftDir.
x();
1278 TanLorenzAngleY = 0.;
1279 dir_z = driftDir.
z();
1280 CosLorenzAngleX = 1. /
sqrt(1. + TanLorenzAngleX * TanLorenzAngleX);
1281 CosLorenzAngleY = 1.;
1286 LogDebug(
"Pixel Digitizer") <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" " << CosLorenzAngleX
1287 <<
" " << CosLorenzAngleY <<
" " << moduleThickness * TanLorenzAngleX <<
" " << driftDir;
1292 float DriftDistance;
1296 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
1297 float SegX, SegY, SegZ;
1298 SegX = ionization_points[
i].
x();
1299 SegY = ionization_points[
i].y();
1300 SegZ = ionization_points[
i].z();
1305 DriftDistance = moduleThickness / 2. - (dir_z * SegZ);
1307 if (DriftDistance <= 0.)
1308 LogDebug(
"PixelDigitizer ") <<
" <=0 " << DriftDistance <<
" " <<
i <<
" " << SegZ <<
" " << dir_z <<
" " << SegX
1309 <<
" " << SegY <<
" " << (moduleThickness / 2) <<
" " << ionization_points[
i].
energy()
1313 if (DriftDistance < 0.) {
1315 }
else if (DriftDistance > moduleThickness)
1316 DriftDistance = moduleThickness;
1319 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
1320 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
1323 float CloudCenterX = SegX + XDriftDueToMagField;
1324 float CloudCenterY = SegY + YDriftDueToMagField;
1327 DriftLength =
sqrt(DriftDistance * DriftDistance + XDriftDueToMagField * XDriftDueToMagField +
1328 YDriftDueToMagField * YDriftDueToMagField);
1334 Sigma_x = Sigma / CosLorenzAngleX;
1335 Sigma_y = Sigma / CosLorenzAngleY;
1338 float energyOnCollector = ionization_points[
i].energy();
1343 energyOnCollector *=
exp(-1 * kValue * DriftDistance / moduleThickness);
1347 LogDebug(
"Pixel Digitizer") <<
" Dift DistanceZ= " << DriftDistance <<
" module thickness= " << moduleThickness
1348 <<
" Start Energy= " << ionization_points[
i].energy()
1349 <<
" Energy after loss= " << energyOnCollector;
1351 SignalPoint sp(CloudCenterX, CloudCenterY, Sigma_x, Sigma_y, hit.
tof(), energyOnCollector);
1354 collection_points[
i] = (sp);
1363 std::vector<PSimHit>::const_iterator inputEnd,
1365 const size_t hitIndex,
1366 const size_t FirstHitIndex,
1367 const unsigned int tofBin,
1369 const std::vector<SignalPoint>& collection_points) {
1378 LogDebug(
"Pixel Digitizer") <<
" enter induce_signal, " << topol->
pitch().first <<
" " << topol->
pitch().second;
1382 typedef std::map<int, float, std::less<int> > hit_map_type;
1383 hit_map_type hit_signal;
1386 std::map<int, float, std::less<int> >
x,
y;
1391 for (std::vector<SignalPoint>::const_iterator
i = collection_points.begin();
i != collection_points.end(); ++
i) {
1392 float CloudCenterX =
i->position().x();
1393 float CloudCenterY =
i->position().y();
1394 float SigmaX =
i->sigma_x();
1395 float SigmaY =
i->sigma_y();
1396 float Charge =
i->amplitude();
1398 if (SigmaX == 0 || SigmaY == 0) {
1399 LogDebug(
"Pixel Digitizer") << SigmaX <<
" " << SigmaY <<
" cloud " <<
i->position().x() <<
" "
1400 <<
i->position().y() <<
" " <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" "
1401 <<
i->amplitude() <<
"\n";
1405 LogDebug(
"Pixel Digitizer") <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" " <<
i->sigma_x()
1406 <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
1410 float CloudRight = CloudCenterX +
ClusterWidth * SigmaX;
1411 float CloudLeft = CloudCenterX -
ClusterWidth * SigmaX;
1413 float CloudDown = CloudCenterY -
ClusterWidth * SigmaY;
1429 int IPixRightUpX = int(floor(mp.
x()));
1430 int IPixRightUpY = int(floor(mp.
y()));
1433 LogDebug(
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" " << mp.
x() <<
" " << mp.
y() <<
" " << IPixRightUpX
1434 <<
" " << IPixRightUpY;
1439 int IPixLeftDownX = int(floor(mp.
x()));
1440 int IPixLeftDownY = int(floor(mp.
y()));
1443 emd::LogDebug(
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" " << mp.
x() <<
" " << mp.
y() <<
" "
1444 << IPixLeftDownX <<
" " << IPixLeftDownY;
1448 int numColumns = topol->
ncolumns();
1449 int numRows = topol->
nrows();
1451 IPixRightUpX = numRows > IPixRightUpX ? IPixRightUpX : numRows - 1;
1452 IPixRightUpY = numColumns > IPixRightUpY ? IPixRightUpY : numColumns - 1;
1453 IPixLeftDownX = 0 < IPixLeftDownX ? IPixLeftDownX : 0;
1454 IPixLeftDownY = 0 < IPixLeftDownY ? IPixLeftDownY : 0;
1461 for (ix = IPixLeftDownX; ix <= IPixRightUpX; ix++) {
1462 float xUB, xLB, UpperBound, LowerBound;
1467 if (ix == 0 || SigmaX == 0.)
1472 LowerBound = 1 -
calcQ((xLB - CloudCenterX) / SigmaX);
1475 if (ix == numRows - 1 || SigmaX == 0.)
1480 UpperBound = 1. -
calcQ((xUB - CloudCenterX) / SigmaX);
1483 float TotalIntegrationRange = UpperBound - LowerBound;
1484 x[ix] = TotalIntegrationRange;
1485 if (SigmaX == 0 || SigmaY == 0)
1486 LogDebug(
"Pixel Digitizer") << TotalIntegrationRange <<
" " << ix <<
"\n";
1491 for (iy = IPixLeftDownY; iy <= IPixRightUpY; iy++) {
1492 float yUB, yLB, UpperBound, LowerBound;
1494 if (iy == 0 || SigmaY == 0.)
1499 LowerBound = 1. -
calcQ((yLB - CloudCenterY) / SigmaY);
1502 if (iy == numColumns - 1 || SigmaY == 0.)
1507 UpperBound = 1. -
calcQ((yUB - CloudCenterY) / SigmaY);
1510 float TotalIntegrationRange = UpperBound - LowerBound;
1511 y[iy] = TotalIntegrationRange;
1512 if (SigmaX == 0 || SigmaY == 0)
1513 LogDebug(
"Pixel Digitizer") << TotalIntegrationRange <<
" " << iy <<
"\n";
1518 for (ix = IPixLeftDownX; ix <= IPixRightUpX; ix++) {
1519 for (iy = IPixLeftDownY; iy <= IPixRightUpY; iy++) {
1521 float ChargeFraction = Charge * x[ix] * y[iy];
1523 if (ChargeFraction > 0.) {
1526 hit_signal[
chan] += ChargeFraction;
1533 LogDebug(
"Pixel Digitizer") <<
" pixel " << ix <<
" " << iy <<
" - "
1534 <<
" " << chan <<
" " << ChargeFraction <<
" " << mp.
x() <<
" " << mp.
y() <<
" "
1535 << lp.
x() <<
" " << lp.
y() <<
" "
1546 bool reweighted =
false;
1554 std::vector<PSimHit>::const_iterator crSimHit = inputBegin;
1557 if ((*inputBegin).trackId() != hit.
trackId()) {
1560 size_t localIndex = FirstHitIndex;
1561 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; localIndex < hitIndex;
1562 ++ssbegin, ++localIndex) {
1563 if ((*ssbegin).detUnitId() != detId) {
1566 if ((*ssbegin).trackId() == hit.
trackId() && (*ssbegin).processType() == 0) {
1579 for (hit_map_type::const_iterator im = hit_signal.begin(); im != hit_signal.end(); ++im) {
1580 int chan = (*im).first;
1582 : Amplitude((*im).second, (*im).second));
1586 LogDebug(
"Pixel Digitizer") <<
" pixel " << ip.first <<
" " << ip.second <<
" " << theSignal[
chan];
1599 std::vector<PixelDigi>& digis,
1600 std::vector<PixelDigiSimLink>& simlinks,
1603 LogDebug(
"Pixel Digitizer") <<
" make digis "
1609 <<
" List pixels passing threshold ";
1614 signalMaps::const_iterator it =
_signal.find(detID);
1623 std::map<TrackEventId, float> simi;
1626 float signalInElectrons = (*i).second;
1633 if (signalInElectrons >= thePixelThresholdInE &&
1634 signalInElectrons > 0.) {
1636 int chan = (*i).first;
1643 int col = ip.second;
1644 adc = int(
missCalibrate(detID, tTopo, pixdet, col, row, signalInElectrons));
1650 LogDebug(
"Pixel Digitizer") << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons <<
" " << adc
1651 << ip.first <<
" " << ip.second;
1655 digis.emplace_back(ip.first, ip.second, adc);
1659 unsigned int il = 0;
1660 for (
const auto&
info : (*i).second.hitInfos()) {
1663 simi[std::make_pair(
info.trackId(),
info.eventId().rawId())] += (*i).second.individualampl()[il];
1668 for (
const auto&
info : (*i).second.hitInfos()) {
1670 auto found = simi.find(std::make_pair(
info.trackId(),
info.eventId().rawId()));
1671 if (
found == simi.end())
1674 float sum_samechannel =
found->second;
1675 float fraction = sum_samechannel / (*i).second;
1693 float thePixelThreshold,
1694 CLHEP::HepRandomEngine* engine) {
1703 float theSmearedChargeRMS = 0.0;
1707 if ((*i).second < 3000) {
1708 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1709 }
else if ((*i).second < 6000) {
1710 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1712 theSmearedChargeRMS = -432.4 + (*i).second * 0.123;
1716 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1720 if (((*i).second +
Amplitude(noise + noise_ChargeVCALSmearing, -1.)) < 0.) {
1723 (*i).second +=
Amplitude(noise + noise_ChargeVCALSmearing, -1.);
1732 if (((*i).second +
Amplitude(noise, -1.)) < 0.) {
1744 int numColumns = topol->
ncolumns();
1745 int numRows = topol->
nrows();
1749 int numberOfPixels = (numRows * numColumns);
1750 std::map<int, float, std::less<int> > otherPixels;
1751 std::map<int, float, std::less<int> >::iterator mapI;
1762 << otherPixels.size();
1766 for (mapI = otherPixels.begin(); mapI != otherPixels.end(); mapI++) {
1767 int iy = ((*mapI).first) / numRows;
1768 int ix = ((*mapI).first) - (iy * numRows);
1771 if (iy < 0 || iy > (numColumns - 1))
1772 LogWarning(
"Pixel Geometry") <<
" error in iy " << iy;
1773 if (ix < 0 || ix > (numRows - 1))
1774 LogWarning(
"Pixel Geometry") <<
" error in ix " << ix;
1779 LogDebug(
"Pixel Digitizer") <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second <<
" " << ix <<
" "
1780 << iy <<
" " <<
chan;
1783 if (theSignal[chan] == 0) {
1785 int noise = int((*mapI).second);
1798 CLHEP::HepRandomEngine* engine) {
1802 int numColumns = topol->
ncolumns();
1803 int numRows = topol->
nrows();
1807 double pixelEfficiency = 1.0;
1808 double columnEfficiency = 1.0;
1809 double chipEfficiency = 1.0;
1810 std::vector<double> pixelEfficiencyROCStdPixels(16, 1);
1811 std::vector<double> pixelEfficiencyROCBigPixels(16, 1);
1813 auto pIndexConverter =
PixelIndices(numColumns, numRows);
1815 std::vector<int> badRocsFromFEDChannels(16, 0);
1821 for (
const auto& ch : *it) {
1822 for (
unsigned int i_roc = ch.roc_first; i_roc <= ch.roc_last; ++i_roc) {
1823 for (
const auto p : path) {
1825 if (myroc->
idInDetUnit() ==
static_cast<unsigned int>(i_roc)) {
1828 int chipIndex(0), colROC(0), rowROC(0);
1829 pIndexConverter.transformToROC(global.
col, global.
row, chipIndex, colROC, rowROC);
1830 badRocsFromFEDChannels.at(chipIndex) = 1;
1842 int layerIndex = tTopo->
layer(detID);
1846 LogDebug(
"Pixel Digitizer") <<
"Using BPix columnEfficiency = " << columnEfficiency
1847 <<
" for layer = " << layerIndex <<
"\n";
1850 if (numColumns > 416)
1851 LogWarning(
"Pixel Geometry") <<
" wrong columns in barrel " << numColumns;
1853 LogWarning(
"Pixel Geometry") <<
" wrong rows in barrel " << numRows;
1869 unsigned int diskIndex =
1871 unsigned int panelIndex = tTopo->
pxfPanel(detID);
1872 unsigned int moduleIndex = tTopo->
pxfModule(detID);
1878 LogDebug(
"Pixel Digitizer") <<
"Using FPix columnEfficiency = " << columnEfficiency
1879 <<
" for Disk = " << tTopo->
pxfDisk(detID) <<
"\n";
1884 if (numColumns > 260 || numRows > 160) {
1885 if (numColumns > 260)
1886 LogWarning(
"Pixel Geometry") <<
" wrong columns in endcaps " << numColumns;
1888 LogWarning(
"Pixel Geometry") <<
" wrong rows in endcaps " << numRows;
1891 if ((panelIndex == 1 && (moduleIndex == 1 || moduleIndex == 2)) ||
1892 (panelIndex == 2 && moduleIndex == 1)) {
1901 pixelEfficiency = 0.999;
1902 columnEfficiency = 0.999;
1903 chipEfficiency = 0.999;
1918 LogDebug(
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" " << columnEfficiency <<
" "
1928 std::map<int, int, std::less<int> > chips,
columns, pixelStd, pixelBig;
1929 std::map<int, int, std::less<int> >::iterator iter;
1934 int chan =
i->first;
1937 int col = ip.second;
1939 pIndexConverter.transformToROC(col, row, chipIndex, colROC, rowROC);
1940 int dColInChip = pIndexConverter.DColumn(colROC);
1942 int dColInDet = pIndexConverter.DColumnInModule(dColInChip, chipIndex);
1945 columns[dColInDet]++;
1948 pixelBig[chipIndex]++;
1950 pixelStd[chipIndex]++;
1955 for (iter = chips.begin(); iter != chips.end(); iter++) {
1957 float rand = CLHEP::RandFlat::shoot(engine);
1958 if (rand > chipEfficiency)
1959 chips[iter->first] = 0;
1963 for (iter = columns.begin(); iter != columns.end(); iter++) {
1965 float rand = CLHEP::RandFlat::shoot(engine);
1966 if (rand > columnEfficiency)
1967 columns[iter->first] = 0;
1972 for (iter = pixelStd.begin(); iter != pixelStd.end(); iter++) {
1973 float rand = CLHEP::RandFlat::shoot(engine);
1974 if (rand > pixelEfficiencyROCStdPixels[iter->first])
1975 pixelStd[iter->first] = 0;
1978 for (iter = pixelBig.begin(); iter != pixelBig.end(); iter++) {
1979 float rand = CLHEP::RandFlat::shoot(engine);
1980 if (rand > pixelEfficiencyROCBigPixels[iter->first])
1981 pixelBig[iter->first] = 0;
1991 int col = ip.second;
1993 pIndexConverter.transformToROC(col, row, chipIndex, colROC, rowROC);
1994 int dColInChip = pIndexConverter.DColumn(colROC);
1996 int dColInDet = pIndexConverter.DColumnInModule(dColInChip, chipIndex);
1999 float rand = CLHEP::RandFlat::shoot(engine);
2000 if (chips[chipIndex] == 0 || columns[dColInDet] == 0 || rand > pixelEfficiency ||
2001 (pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0) ||
2002 (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)) {
2007 if ((pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0) ||
2008 (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0) || (badRocsFromFEDChannels.at(chipIndex) == 1)) {
2030 float pseudoRadDamage = 0.0f;
2035 int layerIndex = tTopo->
layer(detID);
2039 LogDebug(
"Pixel Digitizer") <<
"pixel_aging: "
2041 LogDebug(
"Pixel Digitizer") <<
"Subid " << pixdet->
subDetector() <<
" layerIndex " << layerIndex <<
" ladder "
2047 unsigned int diskIndex =
2052 LogDebug(
"Pixel Digitizer") <<
"pixel_aging: "
2054 LogDebug(
"Pixel Digitizer") <<
"Subid " << pixdet->
subDetector() <<
" diskIndex " << diskIndex <<
"\n";
2058 pseudoRadDamage = 0.f;
2061 LogDebug(
"Pixel Digitizer") <<
" pseudoRadDamage " << pseudoRadDamage <<
"\n";
2062 LogDebug(
"Pixel Digitizer") <<
" end pixel_aging "
2065 return pseudoRadDamage;
2067 LogDebug(
"Pixel Digitizer") <<
" enter pixel_aging " << pseudoRadDamage;
2085 const float signalInElectrons)
const {
2112 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
2128 newAmp = p3 + p2 * tanh(p0 * signal - p1);
2156 LogDebug(
"Pixel Digitizer") <<
" misscalibrate " << col <<
" " << row
2159 << signalInElectrons <<
" " << signal <<
" " << newAmp <<
" "
2174 const DetId& detId)
const {
2209 dir_z = -(1 + alpha2_BPix * Bfield.z() * Bfield.z());
2214 dir_z = -(1 + alpha2_FPix * Bfield.z() * Bfield.z());
2217 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
2224 alpha2 = lorentzAngle * lorentzAngle;
2225 dir_x = -(lorentzAngle * Bfield.y() + alpha2 * Bfield.z() * Bfield.x());
2226 dir_y = +(lorentzAngle * Bfield.x() - alpha2 * Bfield.z() * Bfield.y());
2227 dir_z = -(1 + alpha2 * Bfield.z() * Bfield.z());
2234 LogDebug(
"Pixel Digitizer") <<
" The drift direction in local coordinate is " << theDriftDirection;
2237 return theDriftDirection;
2250 int col = ip.second;
2253 LogDebug(
"Pixel Digitizer") <<
"now in isdead check, row " << detID <<
" " << col <<
"," << row <<
"\n";
2265 Parameters::const_iterator itDeadModules =
DeadModules.begin();
2268 for (; itDeadModules !=
DeadModules.end(); ++itDeadModules) {
2269 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
2270 if (detid == Dead_detID) {
2283 if (Module ==
"whole") {
2292 if (Module ==
"tbmA" && ip.first >= 80 && ip.first <= 159) {
2296 if (Module ==
"tbmB" && ip.first <= 79) {
2311 for (
size_t id = 0;
id < disabledModules.size();
id++) {
2312 if (detID == disabledModules[
id].DetID) {
2314 badmodule = disabledModules[
id];
2324 LogDebug(
"Pixel Digitizer") <<
"Hit in: " << detID <<
" errorType " << badmodule.
errorType <<
" BadRocs=" << std::hex
2335 std::vector<GlobalPixel> badrocpositions(0);
2336 for (
unsigned int j = 0;
j < 16;
j++) {
2339 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
2340 for (IT it = path.begin(); it != path.end(); ++it) {
2345 badrocpositions.push_back(global);
2355 for (std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it) {
2356 if (it->row >= 80 && ip.first >= 80) {
2357 if ((
std::abs(ip.second - it->col) < 26)) {
2359 }
else if (it->row == 120 && ip.second - it->col == 26) {
2361 }
else if (it->row == 119 && it->col - ip.second == 26) {
2364 }
else if (it->row < 80 && ip.first < 80) {
2365 if ((
std::abs(ip.second - it->col) < 26)) {
2367 }
else if (it->row == 40 && ip.second - it->col == 26) {
2369 }
else if (it->row == 39 && it->col - ip.second == 26) {
void init(const edm::EventSetup &es)
static std::pair< int, int > channelToPixelROC(const int chan)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const float theThresholdInE_BPix_L2
double theOuterEfficiency_FPix[20]
void pixel_inefficiency_db(uint32_t detID)
signal_map_type::const_iterator signal_map_const_iterator
Local3DVector LocalVector
float tof() const
deprecated name for timeOfFlight()
const bool use_deadmodule_DB_
const float electronsPerVCAL
const double theThresholdSmearing_FPix
Point3DBase< Scalar, LocalTag > LocalPoint
const std::map< unsigned int, double > & getPixelGeomFactors() const
std::map< unsigned int, probabilityVec > probabilityMap
std::map< int, CalParameters, std::less< int > > initCal() const
const std::unique_ptr< SiPixelGainCalibrationOfflineSimService > theSiPixelGainCalibrationService_
static std::pair< int, int > channelToPixel(int ch)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
LocalVector DriftDirection(const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const DetId &detId) const
uint16_t *__restrict__ id
virtual int ncolumns() const =0
const std::vector< float > & getMix_TrueInteractions() const
probabilityVec getProbabilities(const unsigned int puBin) const
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)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
unsigned int pxfDisk(const DetId &id) const
const std::vector< int > & getMix_bunchCrossing() const
tuple chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
const GeomDetType & type() const override
virtual int rowsperroc() const =0
const double theThresholdSmearing_BPix_L1
unsigned int pxbLadder(const DetId &id) const
constexpr uint32_t rawId() const
get the raw id
bool exists(std::string const ¶meterName) const
checks if a parameter exists
virtual int nrows() const =0
edm::ESGetToken< SiPixelQualityProbabilities, SiPixelStatusScenarioProbabilityRcd > scenarioProbabilityToken_
bool killBadFEDChannels() const
const float theThresholdInE_FPix
std::unique_ptr< PixelFEDChannelCollection > PixelFEDChannelCollection_
const double theThresholdSmearing_BPix
const Bounds & bounds() const
std::vector< std::vector< double > > thePUEfficiency
std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const final
unsigned int pxbModule(const DetId &id) const
const float electronsPerVCAL_Offset
const bool addThresholdSmearing
void module_killing_conf(uint32_t detID)
Exp< T >::type exp(const T &t)
const std::map< unsigned int, std::vector< double > > & getPUFactors() const
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
const bool fluctuateCharge
Log< level::Error, false > LogError
std::map< uint32_t, size_t > iPU
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
float thePixelPseudoRadDamage[20]
~SiPixelDigitizerAlgorithm()
double calcQ(float x) const
const Plane & surface() const
The nominal surface of the GeomDet.
const float GeVperElectron
const double theThresholdSmearing_BPix_L2
identify pixel inside single ROC
const SiPixelDynamicInefficiency * SiPixelDynamicInefficiency_
std::unique_ptr< SiPixelChargeReweightingAlgorithm > TheNewSiPixelChargeReweightingAlgorithmClass
const bool use_ineff_from_db_
constexpr std::array< uint8_t, layerIndexSize > layer
void make_digis(float thePixelThresholdInE, uint32_t detID, const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelDigiSimLink > &simlinks, const TrackerTopology *tTopo) const
static int pixelToChannel(int row, int col)
global coordinates (row and column in DetUnit, as in PixelDigi)
bool isThere(GeomDetEnumerators::SubDetector subdet) const
virtual float thickness() const =0
bool getData(T &iHolder) const
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::vector< uint32_t > getDetIdmasks() const
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Container::value_type value_type
edm::ESGetToken< SiPixelQuality, SiPixelQualityRcd > SiPixelBadModuleToken_
SiPixelDigitizerAlgorithm(const edm::ParameterSet &conf, edm::ConsumesCollector iC)
const PixelFEDChannelCollectionMap * quality_map
double theInstLumiScaleFactor
const Parameters DeadModules
const std::map< unsigned int, double > & getColGeomFactors() const
float pixel_aging(const PixelAging &aging, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo) const
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
const bool use_module_killing_
std::vector< double > pu_scale
void module_killing_DB(uint32_t detID)
static int pixelToChannelROC(const int rowROC, const int colROC)
virtual bool isItBigPixelInY(int iybin) const =0
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void digitize(const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelDigiSimLink > &simlinks, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const final
Abs< T >::type abs(const T &t)
const float theThresholdInE_BPix
double theInnerEfficiency_FPix[20]
const SiPixelLorentzAngle * SiPixelLorentzAngle_
virtual int channel(const LocalPoint &p) const =0
DetId geographicalId() const
The label of this GeomDet.
const int NumberOfEndcapDisks
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
std::vector< double > theModuleEfficiency_BPix[20]
const std::vector< disabledModuleType > getBadComponentList() const
std::vector< LinkConnSpec >::const_iterator IT
void init_from_db(const TrackerGeometry *, const SiPixelDynamicInefficiency *)
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
edm::ESGetToken< SiPixelLorentzAngle, SiPixelLorentzAngleSimRcd > SiPixelLorentzAngleToken_
bool isTrackerPixel() const
signal_map_type::iterator signal_map_iterator
void init_DynIneffDB(const edm::EventSetup &)
std::unique_ptr< PixelFEDChannelCollection > chooseScenario(PileupMixingContent *puInfo, CLHEP::HepRandomEngine *)
const float theThresholdInE_BPix_L1
const TrackerGeomDet * idToDet(DetId) const override
const float electronsPerVCAL_L1_Offset
unsigned int pxfModule(const DetId &id) const
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
void fluctuateEloss(int particleId, float momentum, float eloss, float length, int NumberOfSegments, float elossVector[], CLHEP::HepRandomEngine *) const
const bool doMissCalibrate
unsigned int pxbLayer(const DetId &id) const
const bool AddPixelInefficiency
const bool addChargeVCALSmearing
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 float electronsPerVCAL_L1
std::map< uint32_t, std::vector< double > > PixelGeomFactorsROCStdPixels
void primary_ionization(const PSimHit &hit, std::vector< EnergyDepositUnit > &ionization_points, CLHEP::HepRandomEngine *) const
double thePixelColEfficiency[20]
void calculateInstlumiFactor(PileupMixingContent *puInfo)
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
T getParameter(std::string const &) const
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
const std::map< unsigned int, double > & getChipGeomFactors() const
static const GlobalPoint notFound(0, 0, 0)
const float tanLorentzAnglePerTesla_BPix
short getBadRocs(const uint32_t &detid) const
unsigned short processType() const
const SiPixelQualityProbabilities * scenarioProbability_
unsigned int layer(const DetId &id) const
float missCalibrate(uint32_t detID, const TrackerTopology *tTopo, const PixelGeomDetUnit *pixdet, int col, int row, float amp) const
bool matches(const DetId &, const DetId &, const std::vector< uint32_t > &)
std::vector< edm::ParameterSet > Parameters
const bool KillBadFEDChannels
std::vector< double > theLadderEfficiency_BPix[20]
double gettheInstLumiScaleFactor() const
float energyLoss() const
The energy deposit in the PSimHit, in ???.
const float theReadoutNoise
unsigned int trackId() const
const TrackerGeometry * geom_
static unsigned int const shift
float getLorentzAngle(const uint32_t &) const
edm::ESGetToken< SiPixelDynamicInefficiency, SiPixelDynamicInefficiencyRcd > SiPixelDynamicInefficiencyToken_
std::map< uint32_t, double > ColGeomFactors
const RotationType & rotation() const
double thePixelEfficiency[20]
virtual std::pair< float, float > pitch() const =0
PixelAging(const edm::ParameterSet &conf, bool AddPixelAging, int NumberOfBarrelLayers, int NumberOfEndcapDisks)
const float theTofLowerCut
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
Log< level::Warning, false > LogWarning
std::map< uint32_t, double > PixelGeomFactors
std::map< uint32_t, double > ChipGeomFactors
virtual SubDetector subDetector() const
Which subdetector.
const bool addNoisyPixels
const PixelAging pixelAging_
const PositionType & position() const
const float theElectronPerADC
Local3DPoint entryPoint() const
Entry point in the local Det frame.
tuple size
Write out results.
unsigned int pxfPanel(const DetId &id) const
const bool makeDigiSimLinks_
*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
unsigned int detUnitId() const
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
const int NumberOfBarrelLayers
uint16_t *__restrict__ uint16_t const *__restrict__ adc
GlobalPixel toGlobal(const LocalPixel &loc) const
void add_noise(const PixelGeomDetUnit *pixdet, float thePixelThreshold, CLHEP::HepRandomEngine *)
void pixel_inefficiency(const PixelEfficiencies &eff, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
constexpr Detector det() const
get the detector field from this detid