54 #include <gsl/gsl_sf_erf.h> 56 #include "CLHEP/Random/RandGaussQ.h" 57 #include "CLHEP/Random/RandFlat.h" 58 #include "CLHEP/Random/RandGeneral.h" 117 if(use_ineff_from_db_){
118 theSiPixelGainCalibrationService_->setESObjects( es );
120 if(use_deadmodule_DB_) {
123 if(use_LorentzAngle_DB_) {
134 quality_map = PixelFEDChannelCollectionMapHandle.product();
137 std::vector<std::string> allScenarios;
141 std::back_inserter(allScenarios),
144 std::vector<std::string> allScenariosInProb;
146 for(
auto it = m_probabilities.begin(); it != m_probabilities.end() ; ++it){
148 for (
const auto &
entry : it->second){
150 auto probability =
entry.second;
152 if(
std::find(allScenariosInProb.begin(), allScenariosInProb.end(),
scenario) == allScenariosInProb.end()) {
153 allScenariosInProb.push_back(
scenario);
160 std::copy_if(allScenariosInProb.begin(), allScenariosInProb.end(), std::back_inserter(notFound),
162 {
return (
std::find(allScenarios.begin(),allScenarios.end(),
arg) == allScenarios.end());});
164 if(!notFound.empty()){
165 for(
const auto &
entry : notFound){
166 edm::LogError(
"SiPixelFEDChannelContainer") <<
"The requested scenario: " <<
entry <<
" is not found in the map!!"<<std::endl;
168 throw cms::Exception(
"SiPixelDigitizerAlgorithm")<<
"Found: " << notFound.size()<<
" missing scenario(s) in SiPixelStatusScenariosRcd while present in SiPixelStatusScenarioProbabilityRcd \n";
176 dbobject_den = SiPixel2DTemp_den.
product();
180 dbobject_num = SiPixel2DTemp_num.
product();
182 int numOfTemplates = dbobject_den->
numOfTempl()+dbobject_num->numOfTempl();
183 templateStores_.reserve(numOfTemplates);
197 makeDigiSimLinks_(conf.getUntrackedParameter<
bool>(
"makeDigiSimLinks",
true)),
198 use_ineff_from_db_(conf.getParameter<
bool>(
"useDB")),
199 use_module_killing_(conf.getParameter<
bool>(
"killModules")),
200 use_deadmodule_DB_(conf.getParameter<
bool>(
"DeadModules_DB")),
201 use_LorentzAngle_DB_(conf.getParameter<
bool>(
"LorentzAngle_DB")),
205 templ2D(templateStores_),
208 IDnum(conf.exists(
"TemplateIDnumerator")?conf.getParameter<
int>(
"TemplateIDnumerator"):0),
209 IDden(conf.exists(
"TemplateIDdenominator")?conf.getParameter<
int>(
"TemplateIDdenominator"):0),
213 GeVperElectron(3.61E-09),
216 alpha2Order(conf.getParameter<
bool>(
"Alpha2Order")),
222 NumberOfBarrelLayers(conf.exists(
"NumPixelBarrel")?conf.getParameter<
int>(
"NumPixelBarrel"):3),
223 NumberOfEndcapDisks(conf.exists(
"NumPixelEndcap")?conf.getParameter<
int>(
"NumPixelEndcap"):2),
230 theElectronPerADC(conf.getParameter<double>(
"ElectronPerAdc")),
234 theAdcFullScale(conf.getParameter<
int>(
"AdcFullScale")),
238 theNoiseInElectrons(conf.getParameter<double>(
"NoiseInElectrons")),
242 theReadoutNoise(conf.getParameter<double>(
"ReadoutNoiseInElec")),
247 theThresholdInE_FPix(conf.getParameter<double>(
"ThresholdInElectrons_FPix")),
248 theThresholdInE_BPix(conf.getParameter<double>(
"ThresholdInElectrons_BPix")),
249 theThresholdInE_BPix_L1(conf.exists(
"ThresholdInElectrons_BPix_L1")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L1"):theThresholdInE_BPix),
250 theThresholdInE_BPix_L2(conf.exists(
"ThresholdInElectrons_BPix_L2")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L2"):theThresholdInE_BPix),
253 theThresholdSmearing_FPix(conf.getParameter<double>(
"ThresholdSmearing_FPix")),
254 theThresholdSmearing_BPix(conf.getParameter<double>(
"ThresholdSmearing_BPix")),
255 theThresholdSmearing_BPix_L1(conf.exists(
"ThresholdSmearing_BPix_L1")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L1"):theThresholdSmearing_BPix),
256 theThresholdSmearing_BPix_L2(conf.exists(
"ThresholdSmearing_BPix_L2")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L2"):theThresholdSmearing_BPix),
259 electronsPerVCAL(conf.getParameter<double>(
"ElectronsPerVcal")),
260 electronsPerVCAL_Offset(conf.getParameter<double>(
"ElectronsPerVcal_Offset")),
261 electronsPerVCAL_L1(conf.exists(
"ElectronsPerVcal_L1")?conf.getParameter<double>(
"ElectronsPerVcal_L1"):electronsPerVCAL),
262 electronsPerVCAL_L1_Offset(conf.exists(
"ElectronsPerVcal_L1_Offset")?conf.getParameter<double>(
"ElectronsPerVcal_L1_Offset"):electronsPerVCAL_Offset),
266 theTofLowerCut(conf.getParameter<double>(
"TofLowerCut")),
267 theTofUpperCut(conf.getParameter<double>(
"TofUpperCut")),
270 tanLorentzAnglePerTesla_FPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_FPix")),
271 tanLorentzAnglePerTesla_BPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_BPix")),
274 FPix_p0(conf.getParameter<double>(
"FPix_SignalResponse_p0")),
275 FPix_p1(conf.getParameter<double>(
"FPix_SignalResponse_p1")),
276 FPix_p2(conf.getParameter<double>(
"FPix_SignalResponse_p2")),
277 FPix_p3(conf.getParameter<double>(
"FPix_SignalResponse_p3")),
279 BPix_p0(conf.getParameter<double>(
"BPix_SignalResponse_p0")),
280 BPix_p1(conf.getParameter<double>(
"BPix_SignalResponse_p1")),
281 BPix_p2(conf.getParameter<double>(
"BPix_SignalResponse_p2")),
282 BPix_p3(conf.getParameter<double>(
"BPix_SignalResponse_p3")),
285 addNoise(conf.getParameter<
bool>(
"AddNoise")),
289 addChargeVCALSmearing(conf.getParameter<
bool>(
"ChargeVCALSmearing")),
292 addNoisyPixels(conf.getParameter<
bool>(
"AddNoisyPixels")),
295 fluctuateCharge(conf.getUntrackedParameter<
bool>(
"FluctuateCharge",
true)),
302 addThresholdSmearing(conf.getParameter<
bool>(
"AddThresholdSmearing")),
305 doMissCalibrate(conf.getParameter<
bool>(
"MissCalibrate")),
306 theGainSmearing(conf.getParameter<double>(
"GainSmearing")),
307 theOffsetSmearing(conf.getParameter<double>(
"OffsetSmearing")),
310 AddPixelAging(conf.getParameter<
bool>(
"DoPixelAging")),
318 tMax(conf.getParameter<double>(
"deltaProductionCut")),
325 pixelAging_(conf,AddPixelAging,NumberOfBarrelLayers,NumberOfEndcapDisks)
327 LogInfo (
"PixelDigitizer ") <<
"SiPixelDigitizerAlgorithm constructed" 328 <<
"Configuration parameters:" 329 <<
"Threshold/Gain = " 330 <<
"threshold in electron FPix = " 332 <<
"threshold in electron BPix = " 334 <<
"threshold in electron BPix Layer1 = " 336 <<
"threshold in electron BPix Layer2 = " 339 <<
" The delta cut-off is set to " <<
tMax 344 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
351 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
calmap;
354 <<
" miss-calibrate the pixel amplitude ";
356 const bool ReadCalParameters =
false;
357 if(ReadCalParameters) {
360 char filename[80] =
"phCalibrationFit_C0.dat";
364 cout <<
" File not found " << endl;
367 cout <<
" file opened : " << filename << endl;
370 for (
int i = 0;
i < 3;
i++) {
371 in_file.getline(line, 500,
'\n');
375 cout <<
" test map" << endl;
381 for(
int i=0;
i<(52*80);
i++) {
382 in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid >> rowid;
384 cerr <<
"Cannot read data file" << endl;
387 if( in_file.eof() != 0 ) {
388 cerr << in_file.eof() <<
" " << in_file.gcount() <<
" " 389 << in_file.fail() <<
" " << in_file.good() <<
" end of file " 405 calmap.insert(std::pair<int,CalParameters>(chan,onePix));
409 if(rowid!=p.first)
cout<<
" wrong channel row "<<rowid<<
" "<<p.first<<endl;
410 if(colid!=p.second)
cout<<
" wrong channel col "<<colid<<
" "<<p.second<<endl;
414 cout <<
" map size " << calmap.size() <<
" max "<<calmap.max_size() <<
" " 415 <<calmap.empty()<< endl;
438 LogDebug (
"PixelDigitizer")<<
"SiPixelDigitizerAlgorithm deleted";
447 if (AddPixelInefficiency){
449 conf.
exists(
"thePixelColEfficiency_BPix1") && conf.
exists(
"thePixelColEfficiency_BPix2") && conf.
exists(
"thePixelColEfficiency_BPix3") &&
450 conf.
exists(
"thePixelColEfficiency_FPix1") && conf.
exists(
"thePixelColEfficiency_FPix2") &&
451 conf.
exists(
"thePixelEfficiency_BPix1") && conf.
exists(
"thePixelEfficiency_BPix2") && conf.
exists(
"thePixelEfficiency_BPix3") &&
452 conf.
exists(
"thePixelEfficiency_FPix1") && conf.
exists(
"thePixelEfficiency_FPix2") &&
453 conf.
exists(
"thePixelChipEfficiency_BPix1") && conf.
exists(
"thePixelChipEfficiency_BPix2") && conf.
exists(
"thePixelChipEfficiency_BPix3") &&
454 conf.
exists(
"thePixelChipEfficiency_FPix1") && conf.
exists(
"thePixelChipEfficiency_FPix2");
455 if (NumberOfBarrelLayers==3) FromConfig = FromConfig && conf.
exists(
"theLadderEfficiency_BPix1") && conf.
exists(
"theLadderEfficiency_BPix2") && conf.
exists(
"theLadderEfficiency_BPix3") &&
456 conf.
exists(
"theModuleEfficiency_BPix1") && conf.
exists(
"theModuleEfficiency_BPix2") && conf.
exists(
"theModuleEfficiency_BPix3") &&
457 conf.
exists(
"thePUEfficiency_BPix1") && conf.
exists(
"thePUEfficiency_BPix2") && conf.
exists(
"thePUEfficiency_BPix3") &&
458 conf.
exists(
"theInnerEfficiency_FPix1") && conf.
exists(
"theInnerEfficiency_FPix2") &&
459 conf.
exists(
"theOuterEfficiency_FPix1") && conf.
exists(
"theOuterEfficiency_FPix2") &&
460 conf.
exists(
"thePUEfficiency_FPix_Inner") && conf.
exists(
"thePUEfficiency_FPix_Outer") &&
461 conf.
exists(
"theInstLumiScaleFactor");
462 if (NumberOfBarrelLayers>=4) FromConfig = FromConfig && conf.
exists(
"thePixelColEfficiency_BPix4") &&
463 conf.
exists(
"thePixelEfficiency_BPix4") && conf.
exists(
"thePixelChipEfficiency_BPix4");
464 if (NumberOfEndcapDisks>=3) FromConfig = FromConfig && conf.
exists(
"thePixelColEfficiency_FPix4") &&
465 conf.
exists(
"thePixelEfficiency_FPix3") && conf.
exists(
"thePixelChipEfficiency_FPix3");
467 LogInfo (
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the config file.\n";
468 theInstLumiScaleFactor = conf.
getParameter<
double>(
"theInstLumiScaleFactor");
470 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix1");
471 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix2");
472 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix3");
473 if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix4");}
476 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix1");
477 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix2");
478 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix3");
479 if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix4");}
482 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix1");
483 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix2");
484 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix3");
485 if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix4");}
487 if (NumberOfBarrelLayers==3){
489 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix1");
490 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix2");
491 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix3");
492 if ( ((theLadderEfficiency_BPix[0].
size()!=20) || (theLadderEfficiency_BPix[1].
size()!=32) ||
493 (theLadderEfficiency_BPix[2].
size()!=44)) && (NumberOfBarrelLayers==3) )
494 throw cms::Exception(
"Configuration") <<
"Wrong ladder number in efficiency config!";
497 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix1");
498 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix2");
499 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix3");
500 if ( ((theModuleEfficiency_BPix[0].
size()!=4) || (theModuleEfficiency_BPix[1].
size()!=4) ||
501 (theModuleEfficiency_BPix[2].
size()!=4)) && (NumberOfBarrelLayers==3) )
502 throw cms::Exception(
"Configuration") <<
"Wrong module number in efficiency config!";
504 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix1"));
505 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix2"));
506 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix3"));
507 if ( ((thePUEfficiency[0].
empty()) || (thePUEfficiency[1].
empty()) ||
508 (thePUEfficiency[2].
empty())) && (NumberOfBarrelLayers==3) )
509 throw cms::Exception(
"Configuration") <<
"At least one PU efficiency (BPix) number is needed in efficiency config!";
512 if (NumberOfBarrelLayers>=5){
513 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
516 thePixelColEfficiency[j-1]=0.999;
517 thePixelEfficiency[j-1]=0.999;
518 thePixelChipEfficiency[j-1]=0.999;
523 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix1");
524 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix2");
525 if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix3");}
527 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix1");
528 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix2");
529 if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix3");}
531 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix1");
532 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix2");
533 if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix3");}
535 if (NumberOfEndcapDisks>=4){
536 if (NumberOfTotLayers>20){
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;
545 if (NumberOfBarrelLayers==3){
547 theInnerEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theInnerEfficiency_FPix1");
548 theInnerEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theInnerEfficiency_FPix2");
550 theOuterEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theOuterEfficiency_FPix1");
551 theOuterEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theOuterEfficiency_FPix2");
552 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Inner"));
553 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Outer"));
554 if ( ((thePUEfficiency[3].
empty()) || (thePUEfficiency[4].
empty())) && (NumberOfEndcapDisks==2) )
555 throw cms::Exception(
"Configuration") <<
"At least one (FPix) PU efficiency number is needed in efficiency config!";
556 pu_scale.resize(thePUEfficiency.size());
559 else LogInfo (
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the database.\n";
577 const std::map<uint32_t, double>& PixelGeomFactorsDBIn = SiPixelDynamicInefficiency->
getPixelGeomFactors();
578 const std::map<uint32_t, double>& ColGeomFactorsDB = SiPixelDynamicInefficiency->
getColGeomFactors();
579 const std::map<uint32_t, double>& ChipGeomFactorsDB = SiPixelDynamicInefficiency->
getChipGeomFactors();
580 const std::map<uint32_t, std::vector<double> >& PUFactors = SiPixelDynamicInefficiency->
getPUFactors();
581 std::vector<uint32_t > DetIdmasks = SiPixelDynamicInefficiency->
getDetIdmasks();
584 for(
const auto& it_module : geom->
detUnits()) {
585 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
586 const DetId detid = it_module->geographicalId();
587 uint32_t rawid = detid.
rawId();
588 PixelGeomFactors[rawid] = 1;
589 ColGeomFactors[rawid] = 1;
590 ChipGeomFactors[rawid] = 1;
591 PixelGeomFactorsROCStdPixels[rawid] = std::vector<double>(16,1);
592 PixelGeomFactorsROCBigPixels[rawid] = std::vector<double>(16,1);
596 std::map<uint32_t, double> PixelGeomFactorsDB;
600 for (
auto db_factor : PixelGeomFactorsDBIn){
603 unsigned int rocMask = rocIdMaskBits <<
shift;
604 unsigned int rocId = (((db_factor.first) & rocMask) >>
shift);
607 unsigned int rawid = db_factor.first & (~rocMask);
612 double factor = db_factor.second;
613 double badFraction = 1 - factor;
614 double bigPixelFraction =
static_cast<double> (nBigPixelsInROC)/nPixelsInROC;
615 double stdPixelFraction = 1. - bigPixelFraction;
617 double badFractionBig =
std::min(bigPixelFraction, badFraction);
618 double badFractionStd =
std::max(0., badFraction - badFractionBig);
619 double badFractionBigReNormalized = badFractionBig/bigPixelFraction;
620 double badFractionStdReNormalized = badFractionStd/stdPixelFraction;
621 PixelGeomFactorsROCStdPixels[rawid][rocId] *= (1. - badFractionStdReNormalized);
622 PixelGeomFactorsROCBigPixels[rawid][rocId] *= (1. - badFractionBigReNormalized);
625 PixelGeomFactorsDB[db_factor.first] = db_factor.second;
630 PixelGeomFactorsDB = PixelGeomFactorsDBIn;
634 for(
const auto& it_module : geom->
detUnits()) {
635 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
636 const DetId detid = it_module->geographicalId();
637 uint32_t rawid = detid.
rawId();
638 for (
auto db_factor : PixelGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) PixelGeomFactors[rawid] *= db_factor.second;
639 for (
auto db_factor : ColGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) ColGeomFactors[rawid] *= db_factor.second;
640 for (
auto db_factor : ChipGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) ChipGeomFactors[rawid] *= db_factor.second;
646 for (
auto factor : PUFactors) {
648 for(
const auto& it_module : geom->
detUnits()) {
649 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
650 const DetId detid = it_module->geographicalId();
651 if (!
matches(detid, db_id, DetIdmasks))
continue;
652 if (iPU.count(detid.
rawId())) {
653 throw cms::Exception(
"Database")<<
"Multiple db_ids match to same module in SiPixelDynamicInefficiency DB Object";
658 thePUEfficiency.push_back(factor.second);
661 pu_scale.resize(thePUEfficiency.size());
666 for (
size_t i=0;
i<DetIdmasks.size(); ++
i) {
683 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix1");
684 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix2");
685 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix3");
686 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix4");
689 if (NumberOfBarrelLayers>=5){
690 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
693 thePixelPseudoRadDamage[j-1]=0.;
698 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix1");
699 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix2");
700 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix3");
703 if (NumberOfEndcapDisks>=4){
704 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
707 thePixelPseudoRadDamage[j-1]=0.;
717 std::vector<PSimHit>::const_iterator inputEnd,
718 const size_t inputBeginGlobalIndex,
719 const unsigned int tofBin,
723 CLHEP::HepRandomEngine* engine) {
728 size_t simHitGlobalIndex=inputBeginGlobalIndex;
729 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
731 if((*ssbegin).detUnitId() != detId) {
737 << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" " 738 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" " 739 << (*ssbegin).trackId() <<
" " << (*ssbegin).processType() <<
" " 740 << (*ssbegin).detUnitId()
741 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint() ;
745 std::vector<EnergyDepositUnit> ionization_points;
746 std::vector<SignalPoint> collection_points;
753 drift(*ssbegin, pixdet, bfield, tTopo, ionization_points, collection_points);
755 induce_signal(inputBegin, inputEnd, *ssbegin, simHitGlobalIndex, tofBin, pixdet, collection_points);
771 std::vector<int>::const_iterator
pu;
772 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
774 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++
pu) {
781 if (pu0!=bunchCrossing.end()) {
784 double instlumi_pow=1.;
788 instlumi_pow*=instlumi;
803 for(
unsigned int i=0;
i<ps.size();
i++)
804 if (ps[
i].getBunchCrossing() == 0)
810 double instlumi_pow=1.;
814 instlumi_pow*=instlumi;
833 std::unique_ptr<PixelFEDChannelCollection> PixelFEDChannelCollection_ =
nullptr;
840 std::vector<int>::const_iterator
pu;
841 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
843 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++
pu) {
851 if (pu0!=bunchCrossing.end()) {
853 unsigned int PUBin = TrueInteractionList.at(
p);
855 std::vector<double> probabilities;
856 probabilities.reserve(theProbabilitiesPerScenario.size());
857 for (
auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++){
858 probabilities.push_back(it->second);
861 CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size());
862 double x = randGeneral.shoot();
863 unsigned int index = x * probabilities.size() - 1;
866 PixelFEDChannelCollection_ = std::make_unique<PixelFEDChannelCollection>(
quality_map->at(scenario));
870 return PixelFEDChannelCollection_;
875 for(
const auto& det: signalMap) {
876 auto& theSignal =
_signal[det.first];
877 for(
const auto&
chan: det.second) {
885 std::vector<PixelDigi>& digis,
886 std::vector<PixelDigiSimLink>& simlinks,
888 CLHEP::HepRandomEngine* engine) {
902 float thePixelThresholdInE = 0.;
906 int lay = tTopo->
layer(detID);
935 else {
throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;}
942 int numRows = topol->
nrows();
946 <<
" PixelDigitizer " 947 << numColumns <<
" " << numRows <<
" " << moduleThickness;
968 make_digis(thePixelThresholdInE, detID, pixdet, digis, simlinks, tTopo);
971 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
982 const float SegmentLength = 0.0010;
989 float length = direction.
mag();
991 int NumberOfSegments =
int ( length / SegmentLength);
992 if(NumberOfSegments < 1) NumberOfSegments = 1;
996 <<
" enter primary_ionzation " << NumberOfSegments
1004 float* elossVector =
new float[NumberOfSegments];
1011 float momentum = hit.
pabs();
1014 elossVector, engine);
1017 ionization_points.resize( NumberOfSegments);
1020 for (
int i = 0;
i != NumberOfSegments;
i++) {
1023 float((
i+0.5)/NumberOfSegments) * direction;
1031 ionization_points[
i] = edu;
1035 <<
i <<
" " << ionization_points[
i].x() <<
" " 1036 << ionization_points[
i].y() <<
" " 1037 << ionization_points[
i].z() <<
" " 1038 << ionization_points[
i].energy();
1043 delete[] elossVector;
1051 float eloss,
float length,
1052 int NumberOfSegs,
float elossVector[],
1053 CLHEP::HepRandomEngine* engine)
const {
1060 double particleMass = 139.6;
1063 if(pid==11) particleMass = 0.511;
1064 else if(pid==13) particleMass = 105.7;
1065 else if(pid==321) particleMass = 493.7;
1066 else if(pid==2212) particleMass = 938.3;
1069 float segmentLength = length/NumberOfSegs;
1074 double segmentEloss = (1000.*eloss)/NumberOfSegs;
1075 for (
int i=0;
i<NumberOfSegs;
i++) {
1081 double deltaCutoff =
tMax;
1082 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
1083 particleMass, deltaCutoff,
1084 double(segmentLength*10.),
1085 segmentEloss, engine )/1000.;
1092 float ratio = eloss/sum;
1094 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
1096 float averageEloss = eloss/NumberOfSegs;
1097 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
1109 const std::vector<EnergyDepositUnit>& ionization_points,
1110 std::vector<SignalPoint>& collection_points)
const {
1113 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
1116 collection_points.resize(ionization_points.size());
1119 if(driftDir.
z() ==0.) {
1120 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
1128 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
1131 TanLorenzAngleX = driftDir.
x();
1132 TanLorenzAngleY = driftDir.
y();
1133 dir_z = driftDir.
z();
1134 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
1135 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
1138 TanLorenzAngleX = driftDir.
x();
1139 TanLorenzAngleY = 0.;
1140 dir_z = driftDir.
z();
1141 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
1142 CosLorenzAngleY = 1.;
1148 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" " 1149 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" " 1150 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
1155 float DriftDistance;
1159 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
1161 float SegX, SegY, SegZ;
1162 SegX = ionization_points[
i].
x();
1163 SegY = ionization_points[
i].y();
1164 SegZ = ionization_points[
i].z();
1169 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
1179 if( DriftDistance < 0.) {
1181 }
else if( DriftDistance > moduleThickness )
1182 DriftDistance = moduleThickness;
1185 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
1186 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
1189 float CloudCenterX = SegX + XDriftDueToMagField;
1190 float CloudCenterY = SegY + YDriftDueToMagField;
1193 DriftLength =
sqrt( DriftDistance*DriftDistance +
1194 XDriftDueToMagField*XDriftDueToMagField +
1195 YDriftDueToMagField*YDriftDueToMagField );
1201 Sigma_x = Sigma / CosLorenzAngleX ;
1202 Sigma_y = Sigma / CosLorenzAngleY ;
1205 float energyOnCollector = ionization_points[
i].energy();
1210 energyOnCollector *=
exp( -1*kValue*DriftDistance/moduleThickness );
1215 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
1216 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
1219 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
1222 collection_points[
i] = (sp);
1231 std::vector<PSimHit>::const_iterator inputEnd,
1233 const size_t hitIndex,
1234 const unsigned int tofBin,
1236 const std::vector<SignalPoint>& collection_points) {
1247 <<
" enter induce_signal, " 1248 << topol->
pitch().first <<
" " << topol->
pitch().second;
1252 typedef std::map< int, float, std::less<int> > hit_map_type;
1253 hit_map_type hit_signal;
1256 std::map<int, float, std::less<int> >
x,
y;
1261 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
1262 i != collection_points.end(); ++
i) {
1264 float CloudCenterX =
i->position().x();
1265 float CloudCenterY =
i->position().y();
1268 float Charge =
i->amplitude();
1279 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" " 1280 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
1303 int IPixRightUpX =
int( floor( mp.
x()));
1304 int IPixRightUpY =
int( floor( mp.
y()));
1307 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" " 1308 << mp.
x() <<
" " << mp.
y() <<
" " 1309 << IPixRightUpX <<
" " << IPixRightUpY ;
1314 int IPixLeftDownX =
int( floor( mp.
x()));
1315 int IPixLeftDownY =
int( floor( mp.
y()));
1318 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" " 1319 << mp.
x() <<
" " << mp.
y() <<
" " 1320 << IPixLeftDownX <<
" " << IPixLeftDownY ;
1324 int numColumns = topol->
ncolumns();
1325 int numRows = topol->
nrows();
1327 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
1328 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
1329 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
1330 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
1337 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1338 float xUB, xLB, UpperBound, LowerBound;
1343 if(ix == 0 || SigmaX==0. )
1348 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
1351 if(ix == numRows-1 || SigmaX==0. )
1356 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
1359 float TotalIntegrationRange = UpperBound - LowerBound;
1360 x[ix] = TotalIntegrationRange;
1368 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1369 float yUB, yLB, UpperBound, LowerBound;
1371 if(iy == 0 || SigmaY==0.)
1376 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
1379 if(iy == numColumns-1 || SigmaY==0. )
1384 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
1387 float TotalIntegrationRange = UpperBound - LowerBound;
1388 y[iy] = TotalIntegrationRange;
1395 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1396 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1398 float ChargeFraction = Charge*x[ix]*y[iy];
1400 if( ChargeFraction > 0. ) {
1403 hit_signal[
chan] += ChargeFraction;
1411 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" " 1412 << chan <<
" " << ChargeFraction<<
" " 1413 << mp.
x() <<
" " << mp.
y() <<
" " 1414 << lp.
x() <<
" " << lp.
y() <<
" " 1426 bool reweighted =
false;
1436 for ( hit_map_type::const_iterator im = hit_signal.begin();
1437 im != hit_signal.end(); ++im) {
1438 int chan = (*im).first;
1439 theSignal[
chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1444 <<
" pixel " << ip.first <<
" " << ip.second <<
" " 1458 std::vector<PixelDigi>& digis,
1459 std::vector<PixelDigiSimLink>& simlinks,
1463 LogDebug (
"Pixel Digitizer") <<
" make digis "<<
" " 1468 <<
" List pixels passing threshold ";
1473 signalMaps::const_iterator it =
_signal.find(detID);
1482 std::map<TrackEventId, float> simi;
1486 float signalInElectrons = (*i).second ;
1493 if( signalInElectrons >= thePixelThresholdInE && signalInElectrons > 0.) {
1495 int chan = (*i).first;
1502 int col = ip.second;
1503 adc =
int(
missCalibrate(detID, tTopo, pixdet, col, row, signalInElectrons));
1510 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1511 <<
" " << adc << ip.first <<
" " << ip.second ;
1515 digis.emplace_back(ip.first, ip.second, adc);
1520 for(
const auto&
info: (*i).second.hitInfos()) {
1523 simi[std::make_pair(
info.trackId(),
info.eventId().rawId())] += (*i).second.individualampl()[il];
1528 for(
const auto&
info: (*i).second.hitInfos()) {
1530 auto found = simi.find(std::make_pair(
info.trackId(),
info.eventId().rawId()));
1531 if(
found == simi.end())
1534 float sum_samechannel =
found->second;
1535 float fraction=sum_samechannel/(*i).second;
1536 if(fraction>1.
f) fraction=1.f;
1552 float thePixelThreshold,
1553 CLHEP::HepRandomEngine* engine) {
1564 float theSmearedChargeRMS = 0.0;
1570 if((*i).second < 3000)
1572 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1573 }
else if((*i).second < 6000){
1574 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1576 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1580 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1584 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1585 (*i).second.set(0);}
1587 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1597 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1598 (*i).second.set(0);}
1610 int numColumns = topol->
ncolumns();
1611 int numRows = topol->
nrows();
1615 int numberOfPixels = (numRows * numColumns);
1616 std::map<int,float, std::less<int> > otherPixels;
1617 std::map<int,float, std::less<int> >::iterator mapI;
1627 <<
" Add noisy pixels " << numRows <<
" " 1630 << otherPixels.size() ;
1634 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1635 int iy = ((*mapI).first) / numRows;
1636 int ix = ((*mapI).first) - (iy*numRows);
1639 if( iy < 0 || iy > (numColumns-1) )
1640 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1641 if( ix < 0 || ix > (numRows-1) )
1642 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1648 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1649 <<
" " << ix <<
" " << iy <<
" " <<
chan ;
1652 if(theSignal[chan] == 0){
1654 int noise=
int( (*mapI).second );
1667 CLHEP::HepRandomEngine* engine) {
1672 int numColumns = topol->
ncolumns();
1673 int numRows = topol->
nrows();
1677 double pixelEfficiency = 1.0;
1678 double columnEfficiency = 1.0;
1679 double chipEfficiency = 1.0;
1680 std::vector<double> pixelEfficiencyROCStdPixels(16,1);
1681 std::vector<double> pixelEfficiencyROCBigPixels(16,1);
1683 auto pIndexConverter =
PixelIndices(numColumns,numRows);
1685 std::vector<int> badRocsFromFEDChannels(16,0);
1691 for(
const auto& ch: *it) {
1692 for (
unsigned int i_roc = ch.roc_first; i_roc <= ch.roc_last; ++i_roc){
1693 for(
const auto p : path){
1695 if( myroc->
idInDetUnit() ==
static_cast<unsigned int>(i_roc)) {
1698 int chipIndex(0), colROC(0), rowROC(0);
1699 pIndexConverter.transformToROC(global.
col,global.
row,chipIndex,colROC,rowROC);
1700 badRocsFromFEDChannels.at(chipIndex) = 1;
1713 int layerIndex=tTopo->
layer(detID);
1720 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1721 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1725 if (module<=4) module=5-module;
1735 unsigned int panelIndex=tTopo->
pxfPanel(detID);
1736 unsigned int moduleIndex=tTopo->
pxfModule(detID);
1746 if(numColumns>260 || numRows>160) {
1747 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1748 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1751 if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) {
1759 pixelEfficiency = 0.999;
1760 columnEfficiency = 0.999;
1761 chipEfficiency = 0.999;
1776 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" " 1777 << columnEfficiency <<
" " << chipEfficiency;
1786 std::map<int, int, std::less<int> >chips,
columns, pixelStd, pixelBig;
1787 std::map<int, int, std::less<int> >::iterator iter;
1793 int chan =
i->first;
1796 int col = ip.second;
1798 pIndexConverter.transformToROC(col,row,chipIndex,colROC,rowROC);
1799 int dColInChip = pIndexConverter.DColumn(colROC);
1801 int dColInDet = pIndexConverter.DColumnInModule(dColInChip,chipIndex);
1804 columns[dColInDet]++;
1807 pixelBig[chipIndex]++;
1809 pixelStd[chipIndex]++;
1814 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1816 float rand = CLHEP::RandFlat::shoot(engine);
1817 if( rand > chipEfficiency ) chips[iter->first]=0;
1821 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1823 float rand = CLHEP::RandFlat::shoot(engine);
1824 if( rand > columnEfficiency ) columns[iter->first]=0;
1829 for ( iter = pixelStd.begin(); iter != pixelStd.end() ; iter++ ) {
1830 float rand = CLHEP::RandFlat::shoot(engine);
1831 if( rand > pixelEfficiencyROCStdPixels[iter->first]) pixelStd[iter->first] = 0;
1834 for ( iter = pixelBig.begin(); iter != pixelBig.end() ; iter++ ) {
1835 float rand = CLHEP::RandFlat::shoot(engine);
1836 if( rand > pixelEfficiencyROCBigPixels[iter->first]) pixelBig[iter->first] = 0;
1847 int col = ip.second;
1849 pIndexConverter.transformToROC(col,row,chipIndex,colROC,rowROC);
1850 int dColInChip = pIndexConverter.DColumn(colROC);
1852 int dColInDet = pIndexConverter.DColumnInModule(dColInChip,chipIndex);
1855 float rand = CLHEP::RandFlat::shoot(engine);
1856 if( chips[chipIndex]==0 || columns[dColInDet]==0
1857 || rand>pixelEfficiency
1858 || (pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0)
1859 || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)) {
1864 if((pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0)
1865 || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)
1866 || (badRocsFromFEDChannels.at(chipIndex) == 1))
1891 float pseudoRadDamage = 0.0f;
1896 int layerIndex=tTopo->
layer(detID);
1914 pseudoRadDamage = 0.f;
1920 return pseudoRadDamage;
1922 LogDebug (
"Pixel Digitizer") <<
" enter pixel_aging " << pseudoRadDamage;
1937 const float signalInElectrons)
const {
1964 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1978 newAmp = p3 + p2 * tanh(p0*signal - p1);
2023 const DetId& detId)
const {
2060 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
2065 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
2068 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
2075 alpha2 = lorentzAngle * lorentzAngle;
2077 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
2078 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
2079 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
2086 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is " 2087 << theDriftDirection ;
2090 return theDriftDirection;
2105 int col = ip.second;
2122 Parameters::const_iterator itDeadModules=
DeadModules.begin();
2125 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
2126 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
2127 if(detid == Dead_detID){
2140 if(Module==
"whole"){
2149 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
2153 if( Module==
"tbmB" && ip.first<=79){
2168 for (
size_t id=0;
id<disabledModules.size();
id++)
2170 if(detID==disabledModules[
id].DetID){
2172 badmodule = disabledModules[
id];
2192 std::vector<GlobalPixel> badrocpositions (0);
2193 for(
unsigned int j = 0; j < 16; j++){
2197 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
2198 for (IT it = path.begin(); it != path.end(); ++it) {
2203 badrocpositions.push_back(global);
2214 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
2215 if(it->row >= 80 && ip.first >= 80 ){
2216 if((
std::abs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
2217 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
2218 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
2220 else if(it->row < 80 && ip.first < 80 ){
2221 if((
std::abs(ip.second - it->col) < 26) ){
i->second.set(0.);}
2222 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
2223 else if(it->row==39 && it->col-ip.second==26){
i->second.set(0.);}
2233 std::map<
int,
float, std::less<int> >& hit_signal,
2234 const size_t hitIndex,
2235 const unsigned int tofBin,
2239 unsigned short int processType){
2241 int irow_min = topol->
nrows();
2246 float chargeBefore = 0;
2247 float chargeAfter = 0;
2251 for (
std::map<
int,
float, std::less<int> >::const_iterator im = hit_signal.begin(); im != hit_signal.end(); ++im) {
2252 int chan = (*im).first;
2256 hitSignal[
chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
2257 chargeBefore += (*im).second;
2259 if(pixelWithCharge.first < irow_min)
2260 irow_min = pixelWithCharge.first;
2261 if(pixelWithCharge.first > irow_max)
2262 irow_max = pixelWithCharge.first;
2263 if(pixelWithCharge.second < icol_min)
2264 icol_min = pixelWithCharge.second;
2265 if(pixelWithCharge.second > icol_max)
2266 icol_max = pixelWithCharge.second;
2271 float trajectoryScaleToPosition = hitEntryPoint.
z()/direction.
z();
2273 if( (hitEntryPoint.
z() > 0 && direction.
z() < 0) || (hitEntryPoint.
z() < 0 && direction.
z() > 0) ){
2274 trajectoryScaleToPosition *= -1;
2277 LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction;
2280 std::pair<int,int> hitPixel = std::pair<int,int>(
int( floor(hitPositionPixel.
x() ) ),
int ( floor(hitPositionPixel.
y() ) ));
2287 std::pair<int,int> entryPixel = std::pair<int,int>(
int( floor(hitEntryPointPixel.
x() ) ),
int ( floor(hitEntryPointPixel.
y() ) ));
2288 std::pair<int,int> exitPixel = std::pair<int,int>(
int( floor(hitExitPointPixel.
x() ) ),
int ( floor(hitExitPointPixel.
y() ) ));
2290 int hitcol_min, hitcol_max, hitrow_min, hitrow_max;
2291 if(entryPixel.first>exitPixel.first){
2292 hitrow_min = exitPixel.first;
2293 hitrow_max = entryPixel.first;
2295 hitrow_min = entryPixel.first;
2296 hitrow_max = exitPixel.first;
2299 if(entryPixel.second>exitPixel.second){
2300 hitcol_min = exitPixel.second;
2301 hitcol_max = entryPixel.second;
2303 hitcol_min = entryPixel.second;
2304 hitcol_max = exitPixel.second;
2315 <<
"HitPosition:" <<
"\n" 2319 <<
"Pixel Pos - X: " << hitPositionPixel.
x() <<
" Y: " << hitPositionPixel.
y() <<
"\n" 2320 <<
"Cart.Cor. - X: " << CMSSWhitPosition.
x() <<
" Y: " << CMSSWhitPosition.
y() <<
"\n" 2321 <<
"Z=0 Pos - X: " << hitPosition.
x() <<
" Y: " << hitPosition.
y() <<
"\n" 2323 <<
"Origin of the template:" <<
"\n" 2324 <<
"Pixel Pos - X: " << originPixel.x() <<
" Y: " << originPixel.y() <<
"\n" 2325 <<
"Cart.Cor. - X: " << origin.
x() <<
" Y: " << origin.
y() <<
"\n" 2327 <<
"Entry/Exit:" <<
"\n" 2331 <<
"Entry - X Pixel: " << hitEntryPointPixel.
x() <<
" Y Pixel: " << hitEntryPointPixel.
y() <<
"\n" 2332 <<
"Exit - X Pixel: " << hitExitPointPixel.
x() <<
" Y Pixel: " << hitExitPointPixel.
y() <<
"\n" 2334 <<
"row min: " << irow_min <<
" col min: " << icol_min <<
"\n";
2337 if(!(irow_min<=hitrow_max && irow_max>=hitrow_min && icol_min<=hitcol_max && icol_max>=hitcol_min)){
2343 float cmToMicrons = 10000.f;
2345 track[0] = (hitPosition.
x() - origin.
x() )*cmToMicrons;
2346 track[1] = (hitPosition.
y() - origin.
y() )*cmToMicrons;
2348 track[3] = direction.x();
2349 track[4] = direction.y();
2350 track[5] = direction.z();
2354 for(
int row = 0; row <
TXSIZE; ++row) {
2356 pixrewgt[row][
col] = 0;
2360 for(
int row = 0; row <
TXSIZE; ++row) {
2368 for(
int row = 0; row <
TXSIZE; ++row) {
2377 std::cout <<
"Cluster before reweighting: " << std::endl;
2398 LogDebug (
"PixelDigitizer ") <<
"Cluster Charge Reweighting did not work properly.";
2404 std::cout <<
"Cluster after reweighting: " << std::endl;
2408 for(
int row = 0; row <
TXSIZE; ++row) {
2411 charge = pixrewgt[row][
col];
2412 if( (hitPixel.first + row -
THX) >= 0 && (hitPixel.first + row -
THX) < topol->
nrows() && (hitPixel.second +
col -
THY) >= 0 && (hitPixel.second +
col -
THY) < topol->
ncolumns() && charge > 0){
2419 if(chargeBefore!=0. && chargeAfter==0.){
2425 std::cout <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter << std::endl;
2426 std::cout <<
"Charge loss: " << (1 - chargeAfter/chargeBefore)*100 <<
" %" << std::endl << std::endl;
2445 int i, j,
k,
l, kclose;
2447 float xsize,
ysize, q50i, q100i, q50r, q10r, q100r, xhit2D, yhit2D, qclust, dist2, dmin2;
2450 int goodWeightsUsed, nearbyWeightsUsed, noWeightsUsed;
2451 float cotalpha, cotbeta;
2469 LogDebug (
"Pixel Digitizer") <<
"Reweighting angle is not good!" << std::endl;
2486 for(i=0; i<
BYM2; ++
i) {
2487 for(j=0; j<
BXM2; ++j) {
2489 xy_rewgt[j][
i] = 0.f;
2498 LogDebug(
"Pixel Digitizer") <<
"No matching template found" << std::endl;
2504 std::cout <<
"Template unirrad: " << std::endl;
2514 if(cluster.num_dimensions() != 2) {
2515 LogWarning (
"Pixel Digitizer") <<
"Cluster is not 2-dimensional. Return." << std::endl;
2518 nclusx = (
int)cluster.shape()[0];
2519 nclusy = (
int)cluster.shape()[1];
2521 LogWarning (
"Pixel Digitizer") <<
"Sizes in x do not match: nclusx=" << nclusx <<
" xdoubleSize=" <<
xdouble.size() <<
" TXSIZE=" <<
TXSIZE <<
". Return." << std::endl;
2525 LogWarning (
"Pixel Digitizer") <<
"Sizes in y do not match. Return." << std::endl;
2533 for(j=0; j<
TXSIZE; ++j) {
2534 xy_clust[j][
i] = 0.f;
2535 denx_clust[j][
i] = 0;
2536 deny_clust[j][
i] = 0;
2537 if(cluster[j][i] > q100i) {
2538 qclust += cluster[j][
i];
2548 std::cout <<
"Template irrad: " << std::endl;
2560 std::vector<int> ytclust;
2561 std::vector<int> xtclust;
2562 std::vector<int> ycclust;
2563 std::vector<int> xcclust;
2566 for(j=0; j<
TXSIZE; ++j) {
2567 if(xy_in[j+1][i+1] > q100i) {
2569 ytclust.push_back(i);
2570 xtclust.push_back(j);
2571 xy_clust[j][
i] = xy_rewgt[j+1][i+1]/xy_in[j+1][i+1];
2572 denx_clust[j][
i] = j;
2573 deny_clust[j][
i] =
i;
2581 for(j=0; j<
TXSIZE; ++j) {
2582 if(xy_rewgt[j+1][i+1] > q10r && xy_clust[j][i] == 0.
f && ntpix>0) {
2584 dmin2 = 10000.f; kclose = 0;
2585 for(k=0; k<ntpix; ++
k) {
2586 dist2=(i-ytclust[
k])*(i-ytclust[k])+0.44444f*(j-xtclust[
k])*(j-xtclust[k]);
2592 xy_clust[j][
i] = xy_rewgt[j+1][i+1]/xy_in[xtclust[kclose]+1][ytclust[kclose]+1];
2593 denx_clust[j][
i] = xtclust[kclose];
2594 deny_clust[j][
i] = ytclust[kclose];
2607 goodWeightsUsed = 0;
2608 nearbyWeightsUsed = 0;
2612 for(j=0; j<
TXSIZE; ++j) {
2613 if(xy_clust[j][i] > 0.
f) {
2614 cluster[j][
i] = xy_clust[j][
i]*clust[denx_clust[j][
i]][deny_clust[j][
i]];
2615 if(cluster[j][i] > q100r) {
2616 qclust += cluster[j][
i];
2618 if(cluster[j][i] > 0) {
2622 if(clust[j][i] > 0.
f) {
2624 ycclust.push_back(i);
2625 xcclust.push_back(j);
2634 for(l=0; l<ncpix; ++
l) {
2635 i=ycclust[
l]; j=xcclust[
l];
2636 dmin2 = 10000.f; kclose = 0;
2637 for(k=0; k<ntpix; ++
k) {
2638 dist2=(i-ytclust[
k])*(i-ytclust[k])+0.44444f*(j-xtclust[
k])*(j-xtclust[k]);
2645 nearbyWeightsUsed++;
2646 cluster[j][
i] *= xy_clust[xtclust[kclose]][ytclust[kclose]];
2647 if(cluster[j][i] > q100r) {
2648 qclust += cluster[j][
i];
2652 cluster[j][
i] = 0.f;
2663 for(
int row = 0; row <
TXSIZE; ++row) {
2675 for(
int row = 0; row <
BXM2; ++row) {
2687 for(
int row = 0; row <
TXSIZE; ++row) {
void init(const edm::EventSetup &es)
const SiPixel2DTemplateDBObject * dbobject_den
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
const float theThresholdInE_BPix_L2
virtual int nrows() const =0
const GeomDetType & type() const override
double theOuterEfficiency_FPix[20]
void pixel_inefficiency_db(uint32_t detID)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
signal_map_type::const_iterator signal_map_const_iterator
Local3DVector LocalVector
float tof() const
deprecated name for timeOfFlight()
const bool use_deadmodule_DB_
float xsize()
pixel x-size (microns)
edm::ESHandle< SiPixelFedCablingMap > map_
void init_DynIneffDB(const edm::EventSetup &, const unsigned int &)
const float electronsPerVCAL
const double theThresholdSmearing_FPix
virtual int rowsperroc() const =0
Point3DBase< Scalar, LocalTag > LocalPoint
std::map< int, CalParameters, std::less< int > > initCal() const
const std::unique_ptr< SiPixelGainCalibrationOfflineSimService > theSiPixelGainCalibrationService_
bool xytemp(float xhit, float yhit, bool ydouble[21+2], bool xdouble[13+2], float template2d[13+2][21+2], bool dervatives, float dpdx2d[2][13+2][21+2], float &QTemplate)
std::vector< float > track
LocalVector DriftDirection(const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const DetId &detId) const
void induce_signal(std::vector< PSimHit >::const_iterator inputBegin, std::vector< PSimHit >::const_iterator inputEnd, const PSimHit &hit, const size_t hitIndex, const unsigned int tofBin, const PixelGeomDetUnit *pixdet, const std::vector< SignalPoint > &collection_points)
SiPixelDigitizerAlgorithm(const edm::ParameterSet &conf)
CaloTopology const * topology(0)
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
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())
edm::ESHandle< SiPixelQualityProbabilities > scenarioProbabilityHandle
const std::vector< int > & getMix_bunchCrossing() const
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 std::pair< float, float > pitch() const =0
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
unsigned int pxbModule(const DetId &id) const
const float electronsPerVCAL_Offset
const bool addThresholdSmearing
void module_killing_conf(uint32_t detID)
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
const bool fluctuateCharge
virtual bool isItBigPixelInX(int ixbin) const =0
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
float thePixelPseudoRadDamage[20]
edm::ESHandle< TrackerGeometry > geom_
~SiPixelDigitizerAlgorithm()
double calcQ(float x) const
const Plane & surface() const
The nominal surface of the GeomDet.
const float GeVperElectron
float s50()
1/2 of the pixel threshold signal in adc units
const double theThresholdSmearing_BPix_L2
identify pixel inside single ROC
const bool use_ineff_from_db_
const SiPixel2DTemplateDBObject * dbobject_num
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
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
bunchspace
in terms of 25 ns
const PixelFEDChannelCollectionMap * quality_map
const std::map< int, CalParameters, std::less< int > > calmap
virtual int colsperroc() const =0
double theInstLumiScaleFactor
const Parameters DeadModules
boost::multi_array< float, 2 > array_2d
Local3DPoint localPosition() const
float pixel_aging(const PixelAging &aging, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo) const
std::map< uint32_t, std::vector< double > > PixelGeomFactorsROCBigPixels
double thePixelChipEfficiency[20]
const float theTofUpperCut
SiPixelTemplate2D templ2D
const bool use_module_killing_
std::vector< double > pu_scale
void printCluster(array_2d &cluster)
void module_killing_DB(uint32_t detID)
static int pixelToChannelROC(const int rowROC, const int colROC)
const bool PrintTemplates
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
static std::pair< int, int > channelToPixelROC(const int chan)
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) ...
virtual bool isItBigPixelInY(int iybin) const =0
void digitize(const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelDigiSimLink > &simlinks, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
Abs< T >::type abs(const T &t)
const float theThresholdInE_BPix
double theInnerEfficiency_FPix[20]
DetId geographicalId() const
The label of this GeomDet.
const int NumberOfEndcapDisks
virtual int channel(const LocalPoint &p) const =0
std::vector< double > theModuleEfficiency_BPix[20]
const std::vector< disabledModuleType > getBadComponentList() const
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
std::vector< LinkConnSpec >::const_iterator IT
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
bool isTrackerPixel() const
signal_map_type::iterator signal_map_iterator
std::unique_ptr< PixelFEDChannelCollection > chooseScenario(PileupMixingContent *puInfo, CLHEP::HepRandomEngine *)
const float theThresholdInE_BPix_L1
std::map< unsigned int, probabilityVec > probabilityMap
edm::ESHandle< SiPixelLorentzAngle > SiPixelLorentzAngle_
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
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
const std::unique_ptr< GaussianTailNoiseGenerator > theNoiser
const float theNoiseInElectrons
std::map< int, Amplitude, std::less< int > > signal_map_type
const float electronsPerVCAL_L1
edm::ESHandle< SiPixelQuality > SiPixelBadModule_
short getTemplateID(const uint32_t &detid) const
std::map< uint32_t, std::vector< double > > PixelGeomFactorsROCStdPixels
virtual float thickness() const =0
void primary_ionization(const PSimHit &hit, std::vector< EnergyDepositUnit > &ionization_points, CLHEP::HepRandomEngine *) const
void init_from_db(const edm::ESHandle< TrackerGeometry > &, const edm::ESHandle< SiPixelDynamicInefficiency > &)
double thePixelColEfficiency[20]
void calculateInstlumiFactor(PileupMixingContent *puInfo)
std::vector< bool > ydouble
static std::pair< int, int > channelToPixel(int ch)
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
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
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &pixelTemp, std::string dir="")
const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const final
static const GlobalPoint notFound(0, 0, 0)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
const float tanLorentzAnglePerTesla_BPix
edm::ESHandle< SiPixelDynamicInefficiency > SiPixelDynamicInefficiency_
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
unsigned short processType() const
float ysize()
pixel y-size (microns)
unsigned int layer(const DetId &id) const
std::vector< bool > xdouble
std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const final
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 ???.
virtual int ncolumns() const =0
const float theReadoutNoise
const TrackerGeomDet * idToDet(DetId) const override
static unsigned int const shift
float getLorentzAngle(const uint32_t &) const
std::map< uint32_t, double > ColGeomFactors
const std::map< unsigned int, std::vector< double > > & getPUFactors() const
const RotationType & rotation() const
double thePixelEfficiency[20]
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
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
int PixelTempRewgt2D(int id_gen, int id_rewgt, array_2d &cluster)
std::map< uint32_t, size_t > iPU
T const * product() const
const float theElectronPerADC
Local3DPoint entryPoint() const
Entry point in the local Det frame.
unsigned int pxfPanel(const DetId &id) const
const bool makeDigiSimLinks_
const std::map< unsigned int, double > & getColGeomFactors() const
bool hitSignalReweight(const PSimHit &hit, std::map< int, float, std::less< int > > &hit_signal, const size_t hitIndex, const unsigned int tofBin, const PixelTopology *topol, uint32_t detID, signal_map_type &theSignal, unsigned short int processType)
*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 std::map< unsigned int, double > & getPixelGeomFactors() const
const int NumberOfBarrelLayers
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
const std::map< unsigned int, double > & getChipGeomFactors() const