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();
141 dbobject_den = SiPixel2DTemp_den.
product();
145 dbobject_num = SiPixel2DTemp_num.
product();
147 int numOfTemplates = dbobject_den->
numOfTempl()+dbobject_num->numOfTempl();
148 templateStores_.reserve(numOfTemplates);
161 makeDigiSimLinks_(conf.getUntrackedParameter<
bool>(
"makeDigiSimLinks",
true)),
162 use_ineff_from_db_(conf.getParameter<
bool>(
"useDB")),
163 use_module_killing_(conf.getParameter<
bool>(
"killModules")),
164 use_deadmodule_DB_(conf.getParameter<
bool>(
"DeadModules_DB")),
165 use_LorentzAngle_DB_(conf.getParameter<
bool>(
"LorentzAngle_DB")),
169 templ2D(templateStores_),
172 IDnum(conf.exists(
"TemplateIDnumerator")?conf.getParameter<
int>(
"TemplateIDnumerator"):0),
173 IDden(conf.exists(
"TemplateIDdenominator")?conf.getParameter<
int>(
"TemplateIDdenominator"):0),
177 GeVperElectron(3.61E-09),
180 alpha2Order(conf.getParameter<
bool>(
"Alpha2Order")),
186 NumberOfBarrelLayers(conf.exists(
"NumPixelBarrel")?conf.getParameter<
int>(
"NumPixelBarrel"):3),
187 NumberOfEndcapDisks(conf.exists(
"NumPixelEndcap")?conf.getParameter<
int>(
"NumPixelEndcap"):2),
194 theElectronPerADC(conf.getParameter<double>(
"ElectronPerAdc")),
198 theAdcFullScale(conf.getParameter<
int>(
"AdcFullScale")),
202 theNoiseInElectrons(conf.getParameter<double>(
"NoiseInElectrons")),
206 theReadoutNoise(conf.getParameter<double>(
"ReadoutNoiseInElec")),
211 theThresholdInE_FPix(conf.getParameter<double>(
"ThresholdInElectrons_FPix")),
212 theThresholdInE_BPix(conf.getParameter<double>(
"ThresholdInElectrons_BPix")),
213 theThresholdInE_BPix_L1(conf.exists(
"ThresholdInElectrons_BPix_L1")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L1"):theThresholdInE_BPix),
214 theThresholdInE_BPix_L2(conf.exists(
"ThresholdInElectrons_BPix_L2")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L2"):theThresholdInE_BPix),
217 theThresholdSmearing_FPix(conf.getParameter<double>(
"ThresholdSmearing_FPix")),
218 theThresholdSmearing_BPix(conf.getParameter<double>(
"ThresholdSmearing_BPix")),
219 theThresholdSmearing_BPix_L1(conf.exists(
"ThresholdSmearing_BPix_L1")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L1"):theThresholdSmearing_BPix),
220 theThresholdSmearing_BPix_L2(conf.exists(
"ThresholdSmearing_BPix_L2")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L2"):theThresholdSmearing_BPix),
223 electronsPerVCAL(conf.getParameter<double>(
"ElectronsPerVcal")),
224 electronsPerVCAL_Offset(conf.getParameter<double>(
"ElectronsPerVcal_Offset")),
225 electronsPerVCAL_L1(conf.exists(
"ElectronsPerVcal_L1")?conf.getParameter<double>(
"ElectronsPerVcal_L1"):electronsPerVCAL),
226 electronsPerVCAL_L1_Offset(conf.exists(
"ElectronsPerVcal_L1_Offset")?conf.getParameter<double>(
"ElectronsPerVcal_L1_Offset"):electronsPerVCAL_Offset),
230 theTofLowerCut(conf.getParameter<double>(
"TofLowerCut")),
231 theTofUpperCut(conf.getParameter<double>(
"TofUpperCut")),
234 tanLorentzAnglePerTesla_FPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_FPix")),
235 tanLorentzAnglePerTesla_BPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_BPix")),
238 FPix_p0(conf.getParameter<double>(
"FPix_SignalResponse_p0")),
239 FPix_p1(conf.getParameter<double>(
"FPix_SignalResponse_p1")),
240 FPix_p2(conf.getParameter<double>(
"FPix_SignalResponse_p2")),
241 FPix_p3(conf.getParameter<double>(
"FPix_SignalResponse_p3")),
243 BPix_p0(conf.getParameter<double>(
"BPix_SignalResponse_p0")),
244 BPix_p1(conf.getParameter<double>(
"BPix_SignalResponse_p1")),
245 BPix_p2(conf.getParameter<double>(
"BPix_SignalResponse_p2")),
246 BPix_p3(conf.getParameter<double>(
"BPix_SignalResponse_p3")),
249 addNoise(conf.getParameter<
bool>(
"AddNoise")),
253 addChargeVCALSmearing(conf.getParameter<
bool>(
"ChargeVCALSmearing")),
256 addNoisyPixels(conf.getParameter<
bool>(
"AddNoisyPixels")),
259 fluctuateCharge(conf.getUntrackedParameter<
bool>(
"FluctuateCharge",
true)),
266 addThresholdSmearing(conf.getParameter<
bool>(
"AddThresholdSmearing")),
269 doMissCalibrate(conf.getParameter<
bool>(
"MissCalibrate")),
270 theGainSmearing(conf.getParameter<double>(
"GainSmearing")),
271 theOffsetSmearing(conf.getParameter<double>(
"OffsetSmearing")),
274 AddPixelAging(conf.getParameter<
bool>(
"DoPixelAging")),
282 tMax(conf.getParameter<double>(
"deltaProductionCut")),
289 pixelAging_(conf,AddPixelAging,NumberOfBarrelLayers,NumberOfEndcapDisks)
291 LogInfo (
"PixelDigitizer ") <<
"SiPixelDigitizerAlgorithm constructed" 292 <<
"Configuration parameters:" 293 <<
"Threshold/Gain = " 294 <<
"threshold in electron FPix = " 296 <<
"threshold in electron BPix = " 298 <<
"threshold in electron BPix Layer1 = " 300 <<
"threshold in electron BPix Layer2 = " 303 <<
" The delta cut-off is set to " <<
tMax 308 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
315 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
calmap;
318 <<
" miss-calibrate the pixel amplitude ";
320 const bool ReadCalParameters =
false;
321 if(ReadCalParameters) {
324 char filename[80] =
"phCalibrationFit_C0.dat";
328 cout <<
" File not found " << endl;
331 cout <<
" file opened : " << filename << endl;
334 for (
int i = 0;
i < 3;
i++) {
335 in_file.getline(line, 500,
'\n');
339 cout <<
" test map" << endl;
345 for(
int i=0;
i<(52*80);
i++) {
346 in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid >> rowid;
348 cerr <<
"Cannot read data file" << endl;
351 if( in_file.eof() != 0 ) {
352 cerr << in_file.eof() <<
" " << in_file.gcount() <<
" " 353 << in_file.fail() <<
" " << in_file.good() <<
" end of file " 369 calmap.insert(std::pair<int,CalParameters>(chan,onePix));
373 if(rowid!=p.first)
cout<<
" wrong channel row "<<rowid<<
" "<<p.first<<endl;
374 if(colid!=p.second)
cout<<
" wrong channel col "<<colid<<
" "<<p.second<<endl;
378 cout <<
" map size " << calmap.size() <<
" max "<<calmap.max_size() <<
" " 379 <<calmap.empty()<< endl;
402 LogDebug (
"PixelDigitizer")<<
"SiPixelDigitizerAlgorithm deleted";
411 if (AddPixelInefficiency){
413 conf.
exists(
"thePixelColEfficiency_BPix1") && conf.
exists(
"thePixelColEfficiency_BPix2") && conf.
exists(
"thePixelColEfficiency_BPix3") &&
414 conf.
exists(
"thePixelColEfficiency_FPix1") && conf.
exists(
"thePixelColEfficiency_FPix2") &&
415 conf.
exists(
"thePixelEfficiency_BPix1") && conf.
exists(
"thePixelEfficiency_BPix2") && conf.
exists(
"thePixelEfficiency_BPix3") &&
416 conf.
exists(
"thePixelEfficiency_FPix1") && conf.
exists(
"thePixelEfficiency_FPix2") &&
417 conf.
exists(
"thePixelChipEfficiency_BPix1") && conf.
exists(
"thePixelChipEfficiency_BPix2") && conf.
exists(
"thePixelChipEfficiency_BPix3") &&
418 conf.
exists(
"thePixelChipEfficiency_FPix1") && conf.
exists(
"thePixelChipEfficiency_FPix2");
419 if (NumberOfBarrelLayers==3) FromConfig = FromConfig && conf.
exists(
"theLadderEfficiency_BPix1") && conf.
exists(
"theLadderEfficiency_BPix2") && conf.
exists(
"theLadderEfficiency_BPix3") &&
420 conf.
exists(
"theModuleEfficiency_BPix1") && conf.
exists(
"theModuleEfficiency_BPix2") && conf.
exists(
"theModuleEfficiency_BPix3") &&
421 conf.
exists(
"thePUEfficiency_BPix1") && conf.
exists(
"thePUEfficiency_BPix2") && conf.
exists(
"thePUEfficiency_BPix3") &&
422 conf.
exists(
"theInnerEfficiency_FPix1") && conf.
exists(
"theInnerEfficiency_FPix2") &&
423 conf.
exists(
"theOuterEfficiency_FPix1") && conf.
exists(
"theOuterEfficiency_FPix2") &&
424 conf.
exists(
"thePUEfficiency_FPix_Inner") && conf.
exists(
"thePUEfficiency_FPix_Outer") &&
425 conf.
exists(
"theInstLumiScaleFactor");
426 if (NumberOfBarrelLayers>=4) FromConfig = FromConfig && conf.
exists(
"thePixelColEfficiency_BPix4") &&
427 conf.
exists(
"thePixelEfficiency_BPix4") && conf.
exists(
"thePixelChipEfficiency_BPix4");
428 if (NumberOfEndcapDisks>=3) FromConfig = FromConfig && conf.
exists(
"thePixelColEfficiency_FPix4") &&
429 conf.
exists(
"thePixelEfficiency_FPix3") && conf.
exists(
"thePixelChipEfficiency_FPix3");
431 LogInfo (
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the config file.\n";
432 theInstLumiScaleFactor = conf.
getParameter<
double>(
"theInstLumiScaleFactor");
434 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix1");
435 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix2");
436 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix3");
437 if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix4");}
440 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix1");
441 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix2");
442 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix3");
443 if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix4");}
446 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix1");
447 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix2");
448 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix3");
449 if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix4");}
451 if (NumberOfBarrelLayers==3){
453 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix1");
454 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix2");
455 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix3");
456 if ( ((theLadderEfficiency_BPix[0].
size()!=20) || (theLadderEfficiency_BPix[1].
size()!=32) ||
457 (theLadderEfficiency_BPix[2].
size()!=44)) && (NumberOfBarrelLayers==3) )
458 throw cms::Exception(
"Configuration") <<
"Wrong ladder number in efficiency config!";
461 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix1");
462 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix2");
463 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix3");
464 if ( ((theModuleEfficiency_BPix[0].
size()!=4) || (theModuleEfficiency_BPix[1].
size()!=4) ||
465 (theModuleEfficiency_BPix[2].
size()!=4)) && (NumberOfBarrelLayers==3) )
466 throw cms::Exception(
"Configuration") <<
"Wrong module number in efficiency config!";
468 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix1"));
469 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix2"));
470 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix3"));
471 if ( ((thePUEfficiency[0].
empty()) || (thePUEfficiency[1].
empty()) ||
472 (thePUEfficiency[2].
empty())) && (NumberOfBarrelLayers==3) )
473 throw cms::Exception(
"Configuration") <<
"At least one PU efficiency (BPix) number is needed in efficiency config!";
476 if (NumberOfBarrelLayers>=5){
477 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
480 thePixelColEfficiency[j-1]=0.999;
481 thePixelEfficiency[j-1]=0.999;
482 thePixelChipEfficiency[j-1]=0.999;
487 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix1");
488 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix2");
489 if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix3");}
491 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix1");
492 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix2");
493 if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix3");}
495 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix1");
496 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix2");
497 if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix3");}
499 if (NumberOfEndcapDisks>=4){
500 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
503 thePixelColEfficiency[j-1]=0.999;
504 thePixelEfficiency[j-1]=0.999;
505 thePixelChipEfficiency[j-1]=0.999;
509 if (NumberOfBarrelLayers==3){
511 theInnerEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theInnerEfficiency_FPix1");
512 theInnerEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theInnerEfficiency_FPix2");
514 theOuterEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theOuterEfficiency_FPix1");
515 theOuterEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theOuterEfficiency_FPix2");
516 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Inner"));
517 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Outer"));
518 if ( ((thePUEfficiency[3].
empty()) || (thePUEfficiency[4].
empty())) && (NumberOfEndcapDisks==2) )
519 throw cms::Exception(
"Configuration") <<
"At least one (FPix) PU efficiency number is needed in efficiency config!";
520 pu_scale.resize(thePUEfficiency.size());
523 else LogInfo (
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the database.\n";
541 const std::map<uint32_t, double>& PixelGeomFactorsDBIn = SiPixelDynamicInefficiency->
getPixelGeomFactors();
542 const std::map<uint32_t, double>& ColGeomFactorsDB = SiPixelDynamicInefficiency->
getColGeomFactors();
543 const std::map<uint32_t, double>& ChipGeomFactorsDB = SiPixelDynamicInefficiency->
getChipGeomFactors();
544 const std::map<uint32_t, std::vector<double> >& PUFactors = SiPixelDynamicInefficiency->
getPUFactors();
545 std::vector<uint32_t > DetIdmasks = SiPixelDynamicInefficiency->
getDetIdmasks();
548 for(
const auto& it_module : geom->
detUnits()) {
549 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
550 const DetId detid = it_module->geographicalId();
551 uint32_t rawid = detid.
rawId();
552 PixelGeomFactors[rawid] = 1;
553 ColGeomFactors[rawid] = 1;
554 ChipGeomFactors[rawid] = 1;
555 PixelGeomFactorsROCStdPixels[rawid] = std::vector<double>(16,1);
556 PixelGeomFactorsROCBigPixels[rawid] = std::vector<double>(16,1);
560 std::map<uint32_t, double> PixelGeomFactorsDB;
564 for (
auto db_factor : PixelGeomFactorsDBIn){
567 unsigned int rocMask = rocIdMaskBits <<
shift;
568 unsigned int rocId = (((db_factor.first) & rocMask) >>
shift);
571 unsigned int rawid = db_factor.first & (~rocMask);
576 double factor = db_factor.second;
577 double badFraction = 1 - factor;
578 double bigPixelFraction =
static_cast<double> (nBigPixelsInROC)/nPixelsInROC;
579 double stdPixelFraction = 1. - bigPixelFraction;
581 double badFractionBig =
std::min(bigPixelFraction, badFraction);
582 double badFractionStd =
std::max(0., badFraction - badFractionBig);
583 double badFractionBigReNormalized = badFractionBig/bigPixelFraction;
584 double badFractionStdReNormalized = badFractionStd/stdPixelFraction;
585 PixelGeomFactorsROCStdPixels[rawid][rocId] *= (1. - badFractionStdReNormalized);
586 PixelGeomFactorsROCBigPixels[rawid][rocId] *= (1. - badFractionBigReNormalized);
589 PixelGeomFactorsDB[db_factor.first] = db_factor.second;
594 PixelGeomFactorsDB = PixelGeomFactorsDBIn;
598 for(
const auto& it_module : geom->
detUnits()) {
599 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
600 const DetId detid = it_module->geographicalId();
601 uint32_t rawid = detid.
rawId();
602 for (
auto db_factor : PixelGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) PixelGeomFactors[rawid] *= db_factor.second;
603 for (
auto db_factor : ColGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) ColGeomFactors[rawid] *= db_factor.second;
604 for (
auto db_factor : ChipGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) ChipGeomFactors[rawid] *= db_factor.second;
610 for (
auto factor : PUFactors) {
612 for(
const auto& it_module : geom->
detUnits()) {
613 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
614 const DetId detid = it_module->geographicalId();
615 if (!
matches(detid, db_id, DetIdmasks))
continue;
616 if (iPU.count(detid.
rawId())) {
617 throw cms::Exception(
"Database")<<
"Multiple db_ids match to same module in SiPixelDynamicInefficiency DB Object";
622 thePUEfficiency.push_back(factor.second);
625 pu_scale.resize(thePUEfficiency.size());
630 for (
size_t i=0;
i<DetIdmasks.size(); ++
i) {
647 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix1");
648 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix2");
649 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix3");
650 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix4");
653 if (NumberOfBarrelLayers>=5){
654 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
657 thePixelPseudoRadDamage[j-1]=0.;
662 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix1");
663 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix2");
664 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix3");
667 if (NumberOfEndcapDisks>=4){
668 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
671 thePixelPseudoRadDamage[j-1]=0.;
681 std::vector<PSimHit>::const_iterator inputEnd,
682 const size_t inputBeginGlobalIndex,
683 const unsigned int tofBin,
687 CLHEP::HepRandomEngine* engine) {
692 size_t simHitGlobalIndex=inputBeginGlobalIndex;
693 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
695 if((*ssbegin).detUnitId() != detId) {
701 << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" " 702 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" " 703 << (*ssbegin).trackId() <<
" " << (*ssbegin).processType() <<
" " 704 << (*ssbegin).detUnitId()
705 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint() ;
709 std::vector<EnergyDepositUnit> ionization_points;
710 std::vector<SignalPoint> collection_points;
717 drift(*ssbegin, pixdet, bfield, tTopo, ionization_points, collection_points);
719 induce_signal(inputBegin, inputEnd, *ssbegin, simHitGlobalIndex, tofBin, pixdet, collection_points);
735 std::vector<int>::const_iterator
pu;
736 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
738 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++
pu) {
745 if (pu0!=bunchCrossing.end()) {
748 double instlumi_pow=1.;
752 instlumi_pow*=instlumi;
767 for(
unsigned int i=0;
i<ps.size();
i++)
768 if (ps[
i].getBunchCrossing() == 0)
774 double instlumi_pow=1.;
778 instlumi_pow*=instlumi;
797 std::unique_ptr<PixelFEDChannelCollection> PixelFEDChannelCollection_ =
nullptr;
804 std::vector<int>::const_iterator
pu;
805 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
807 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++
pu) {
815 if (pu0!=bunchCrossing.end()) {
817 unsigned int PUBin = TrueInteractionList.at(
p);
819 std::vector<double> probabilities;
820 probabilities.reserve(theProbabilitiesPerScenario.size());
821 for (
auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++){
822 probabilities.push_back(it->second);
825 CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size());
826 double x = randGeneral.shoot();
827 unsigned int index = x * probabilities.size() - 1;
830 PixelFEDChannelCollection_ = std::make_unique<PixelFEDChannelCollection>(
quality_map->at(scenario));
834 return PixelFEDChannelCollection_;
839 for(
const auto& det: signalMap) {
840 auto& theSignal =
_signal[det.first];
841 for(
const auto&
chan: det.second) {
849 std::vector<PixelDigi>& digis,
850 std::vector<PixelDigiSimLink>& simlinks,
852 CLHEP::HepRandomEngine* engine) {
866 float thePixelThresholdInE = 0.;
870 int lay = tTopo->
layer(detID);
899 else {
throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;}
906 int numRows = topol->
nrows();
910 <<
" PixelDigitizer " 911 << numColumns <<
" " << numRows <<
" " << moduleThickness;
932 make_digis(thePixelThresholdInE, detID, pixdet, digis, simlinks, tTopo);
935 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
946 const float SegmentLength = 0.0010;
953 float length = direction.
mag();
955 int NumberOfSegments =
int ( length / SegmentLength);
956 if(NumberOfSegments < 1) NumberOfSegments = 1;
960 <<
" enter primary_ionzation " << NumberOfSegments
968 float* elossVector =
new float[NumberOfSegments];
975 float momentum = hit.
pabs();
978 elossVector, engine);
981 ionization_points.resize( NumberOfSegments);
984 for (
int i = 0;
i != NumberOfSegments;
i++) {
987 float((
i+0.5)/NumberOfSegments) * direction;
995 ionization_points[
i] = edu;
999 <<
i <<
" " << ionization_points[
i].x() <<
" " 1000 << ionization_points[
i].y() <<
" " 1001 << ionization_points[
i].z() <<
" " 1002 << ionization_points[
i].energy();
1007 delete[] elossVector;
1015 float eloss,
float length,
1016 int NumberOfSegs,
float elossVector[],
1017 CLHEP::HepRandomEngine* engine)
const {
1024 double particleMass = 139.6;
1027 if(pid==11) particleMass = 0.511;
1028 else if(pid==13) particleMass = 105.7;
1029 else if(pid==321) particleMass = 493.7;
1030 else if(pid==2212) particleMass = 938.3;
1033 float segmentLength = length/NumberOfSegs;
1038 double segmentEloss = (1000.*eloss)/NumberOfSegs;
1039 for (
int i=0;
i<NumberOfSegs;
i++) {
1045 double deltaCutoff =
tMax;
1046 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
1047 particleMass, deltaCutoff,
1048 double(segmentLength*10.),
1049 segmentEloss, engine )/1000.;
1056 float ratio = eloss/sum;
1058 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
1060 float averageEloss = eloss/NumberOfSegs;
1061 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
1073 const std::vector<EnergyDepositUnit>& ionization_points,
1074 std::vector<SignalPoint>& collection_points)
const {
1077 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
1080 collection_points.resize(ionization_points.size());
1083 if(driftDir.
z() ==0.) {
1084 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
1092 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
1095 TanLorenzAngleX = driftDir.
x();
1096 TanLorenzAngleY = driftDir.
y();
1097 dir_z = driftDir.
z();
1098 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
1099 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
1102 TanLorenzAngleX = driftDir.
x();
1103 TanLorenzAngleY = 0.;
1104 dir_z = driftDir.
z();
1105 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
1106 CosLorenzAngleY = 1.;
1112 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" " 1113 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" " 1114 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
1119 float DriftDistance;
1123 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
1125 float SegX, SegY, SegZ;
1126 SegX = ionization_points[
i].
x();
1127 SegY = ionization_points[
i].y();
1128 SegZ = ionization_points[
i].z();
1133 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
1143 if( DriftDistance < 0.) {
1145 }
else if( DriftDistance > moduleThickness )
1146 DriftDistance = moduleThickness;
1149 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
1150 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
1153 float CloudCenterX = SegX + XDriftDueToMagField;
1154 float CloudCenterY = SegY + YDriftDueToMagField;
1157 DriftLength =
sqrt( DriftDistance*DriftDistance +
1158 XDriftDueToMagField*XDriftDueToMagField +
1159 YDriftDueToMagField*YDriftDueToMagField );
1165 Sigma_x = Sigma / CosLorenzAngleX ;
1166 Sigma_y = Sigma / CosLorenzAngleY ;
1169 float energyOnCollector = ionization_points[
i].energy();
1174 energyOnCollector *=
exp( -1*kValue*DriftDistance/moduleThickness );
1179 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
1180 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
1183 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
1186 collection_points[
i] = (sp);
1195 std::vector<PSimHit>::const_iterator inputEnd,
1197 const size_t hitIndex,
1198 const unsigned int tofBin,
1200 const std::vector<SignalPoint>& collection_points) {
1211 <<
" enter induce_signal, " 1212 << topol->
pitch().first <<
" " << topol->
pitch().second;
1216 typedef std::map< int, float, std::less<int> > hit_map_type;
1217 hit_map_type hit_signal;
1220 std::map<int, float, std::less<int> >
x,
y;
1225 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
1226 i != collection_points.end(); ++
i) {
1228 float CloudCenterX =
i->position().x();
1229 float CloudCenterY =
i->position().y();
1232 float Charge =
i->amplitude();
1243 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" " 1244 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
1267 int IPixRightUpX =
int( floor( mp.
x()));
1268 int IPixRightUpY =
int( floor( mp.
y()));
1271 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" " 1272 << mp.
x() <<
" " << mp.
y() <<
" " 1273 << IPixRightUpX <<
" " << IPixRightUpY ;
1278 int IPixLeftDownX =
int( floor( mp.
x()));
1279 int IPixLeftDownY =
int( floor( mp.
y()));
1282 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" " 1283 << mp.
x() <<
" " << mp.
y() <<
" " 1284 << IPixLeftDownX <<
" " << IPixLeftDownY ;
1288 int numColumns = topol->
ncolumns();
1289 int numRows = topol->
nrows();
1291 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
1292 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
1293 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
1294 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
1301 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1302 float xUB, xLB, UpperBound, LowerBound;
1307 if(ix == 0 || SigmaX==0. )
1312 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
1315 if(ix == numRows-1 || SigmaX==0. )
1320 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
1323 float TotalIntegrationRange = UpperBound - LowerBound;
1324 x[ix] = TotalIntegrationRange;
1332 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1333 float yUB, yLB, UpperBound, LowerBound;
1335 if(iy == 0 || SigmaY==0.)
1340 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
1343 if(iy == numColumns-1 || SigmaY==0. )
1348 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
1351 float TotalIntegrationRange = UpperBound - LowerBound;
1352 y[iy] = TotalIntegrationRange;
1359 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1360 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1362 float ChargeFraction = Charge*x[ix]*y[iy];
1364 if( ChargeFraction > 0. ) {
1367 hit_signal[
chan] += ChargeFraction;
1375 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" " 1376 << chan <<
" " << ChargeFraction<<
" " 1377 << mp.
x() <<
" " << mp.
y() <<
" " 1378 << lp.
x() <<
" " << lp.
y() <<
" " 1390 bool reweighted =
false;
1400 for ( hit_map_type::const_iterator im = hit_signal.begin();
1401 im != hit_signal.end(); ++im) {
1402 int chan = (*im).first;
1403 theSignal[
chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1408 <<
" pixel " << ip.first <<
" " << ip.second <<
" " 1422 std::vector<PixelDigi>& digis,
1423 std::vector<PixelDigiSimLink>& simlinks,
1427 LogDebug (
"Pixel Digitizer") <<
" make digis "<<
" " 1432 <<
" List pixels passing threshold ";
1437 signalMaps::const_iterator it =
_signal.find(detID);
1446 std::map<TrackEventId, float> simi;
1450 float signalInElectrons = (*i).second ;
1457 if( signalInElectrons >= thePixelThresholdInE && signalInElectrons > 0.) {
1459 int chan = (*i).first;
1466 int col = ip.second;
1467 adc =
int(
missCalibrate(detID, tTopo, pixdet, col, row, signalInElectrons));
1474 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1475 <<
" " << adc << ip.first <<
" " << ip.second ;
1479 digis.emplace_back(ip.first, ip.second, adc);
1484 for(
const auto&
info: (*i).second.hitInfos()) {
1487 simi[std::make_pair(
info.trackId(),
info.eventId().rawId())] += (*i).second.individualampl()[il];
1492 for(
const auto&
info: (*i).second.hitInfos()) {
1494 auto found = simi.find(std::make_pair(
info.trackId(),
info.eventId().rawId()));
1495 if(
found == simi.end())
1498 float sum_samechannel =
found->second;
1499 float fraction=sum_samechannel/(*i).second;
1500 if(fraction>1.
f) fraction=1.f;
1516 float thePixelThreshold,
1517 CLHEP::HepRandomEngine* engine) {
1528 float theSmearedChargeRMS = 0.0;
1534 if((*i).second < 3000)
1536 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1537 }
else if((*i).second < 6000){
1538 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1540 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1544 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1548 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1549 (*i).second.set(0);}
1551 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1561 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1562 (*i).second.set(0);}
1574 int numColumns = topol->
ncolumns();
1575 int numRows = topol->
nrows();
1579 int numberOfPixels = (numRows * numColumns);
1580 std::map<int,float, std::less<int> > otherPixels;
1581 std::map<int,float, std::less<int> >::iterator mapI;
1591 <<
" Add noisy pixels " << numRows <<
" " 1594 << otherPixels.size() ;
1598 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1599 int iy = ((*mapI).first) / numRows;
1600 int ix = ((*mapI).first) - (iy*numRows);
1603 if( iy < 0 || iy > (numColumns-1) )
1604 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1605 if( ix < 0 || ix > (numRows-1) )
1606 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1612 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1613 <<
" " << ix <<
" " << iy <<
" " <<
chan ;
1616 if(theSignal[chan] == 0){
1618 int noise=
int( (*mapI).second );
1631 CLHEP::HepRandomEngine* engine) {
1636 int numColumns = topol->
ncolumns();
1637 int numRows = topol->
nrows();
1641 double pixelEfficiency = 1.0;
1642 double columnEfficiency = 1.0;
1643 double chipEfficiency = 1.0;
1644 std::vector<double> pixelEfficiencyROCStdPixels(16,1);
1645 std::vector<double> pixelEfficiencyROCBigPixels(16,1);
1647 auto pIndexConverter =
PixelIndices(numColumns,numRows);
1649 std::vector<int> badRocsFromFEDChannels(16,0);
1655 for(
const auto& ch: *it) {
1656 for (
unsigned int i_roc = ch.roc_first; i_roc <= ch.roc_last; ++i_roc){
1657 for(
const auto p : path){
1659 if( myroc->
idInDetUnit() ==
static_cast<unsigned int>(i_roc)) {
1662 int chipIndex(0), colROC(0), rowROC(0);
1663 pIndexConverter.transformToROC(global.
col,global.
row,chipIndex,colROC,rowROC);
1664 badRocsFromFEDChannels.at(chipIndex) = 1;
1677 int layerIndex=tTopo->
layer(detID);
1684 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1685 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1689 if (module<=4) module=5-module;
1699 unsigned int panelIndex=tTopo->
pxfPanel(detID);
1700 unsigned int moduleIndex=tTopo->
pxfModule(detID);
1710 if(numColumns>260 || numRows>160) {
1711 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1712 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1715 if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) {
1723 pixelEfficiency = 0.999;
1724 columnEfficiency = 0.999;
1725 chipEfficiency = 0.999;
1740 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" " 1741 << columnEfficiency <<
" " << chipEfficiency;
1750 std::map<int, int, std::less<int> >chips,
columns, pixelStd, pixelBig;
1751 std::map<int, int, std::less<int> >::iterator iter;
1757 int chan =
i->first;
1760 int col = ip.second;
1762 pIndexConverter.transformToROC(col,row,chipIndex,colROC,rowROC);
1763 int dColInChip = pIndexConverter.DColumn(colROC);
1765 int dColInDet = pIndexConverter.DColumnInModule(dColInChip,chipIndex);
1768 columns[dColInDet]++;
1771 pixelBig[chipIndex]++;
1773 pixelStd[chipIndex]++;
1778 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1780 float rand = CLHEP::RandFlat::shoot(engine);
1781 if( rand > chipEfficiency ) chips[iter->first]=0;
1785 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1787 float rand = CLHEP::RandFlat::shoot(engine);
1788 if( rand > columnEfficiency ) columns[iter->first]=0;
1793 for ( iter = pixelStd.begin(); iter != pixelStd.end() ; iter++ ) {
1794 float rand = CLHEP::RandFlat::shoot(engine);
1795 if( rand > pixelEfficiencyROCStdPixels[iter->first]) pixelStd[iter->first] = 0;
1798 for ( iter = pixelBig.begin(); iter != pixelBig.end() ; iter++ ) {
1799 float rand = CLHEP::RandFlat::shoot(engine);
1800 if( rand > pixelEfficiencyROCBigPixels[iter->first]) pixelBig[iter->first] = 0;
1811 int col = ip.second;
1813 pIndexConverter.transformToROC(col,row,chipIndex,colROC,rowROC);
1814 int dColInChip = pIndexConverter.DColumn(colROC);
1816 int dColInDet = pIndexConverter.DColumnInModule(dColInChip,chipIndex);
1819 float rand = CLHEP::RandFlat::shoot(engine);
1820 if( chips[chipIndex]==0 || columns[dColInDet]==0
1821 || rand>pixelEfficiency
1822 || (pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0)
1823 || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)) {
1828 if((pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0)
1829 || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)
1830 || (badRocsFromFEDChannels.at(chipIndex) == 1))
1855 float pseudoRadDamage = 0.0f;
1860 int layerIndex=tTopo->
layer(detID);
1878 pseudoRadDamage = 0.f;
1884 return pseudoRadDamage;
1886 LogDebug (
"Pixel Digitizer") <<
" enter pixel_aging " << pseudoRadDamage;
1901 const float signalInElectrons)
const {
1928 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1942 newAmp = p3 + p2 * tanh(p0*signal - p1);
1987 const DetId& detId)
const {
2024 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
2029 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
2032 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
2039 alpha2 = lorentzAngle * lorentzAngle;
2041 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
2042 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
2043 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
2050 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is " 2051 << theDriftDirection ;
2054 return theDriftDirection;
2069 int col = ip.second;
2086 Parameters::const_iterator itDeadModules=
DeadModules.begin();
2089 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
2090 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
2091 if(detid == Dead_detID){
2104 if(Module==
"whole"){
2113 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
2117 if( Module==
"tbmB" && ip.first<=79){
2132 for (
size_t id=0;
id<disabledModules.size();
id++)
2134 if(detID==disabledModules[
id].DetID){
2136 badmodule = disabledModules[
id];
2156 std::vector<GlobalPixel> badrocpositions (0);
2157 for(
unsigned int j = 0; j < 16; j++){
2161 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
2162 for (IT it = path.begin(); it != path.end(); ++it) {
2167 badrocpositions.push_back(global);
2178 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
2179 if(it->row >= 80 && ip.first >= 80 ){
2180 if((
std::abs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
2181 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
2182 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
2184 else if(it->row < 80 && ip.first < 80 ){
2185 if((
std::abs(ip.second - it->col) < 26) ){
i->second.set(0.);}
2186 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
2187 else if(it->row==39 && it->col-ip.second==26){
i->second.set(0.);}
2197 std::map<
int,
float, std::less<int> >& hit_signal,
2198 const size_t hitIndex,
2199 const unsigned int tofBin,
2203 unsigned short int processType){
2205 int irow_min = topol->
nrows();
2210 float chargeBefore = 0;
2211 float chargeAfter = 0;
2215 for (
std::map<
int,
float, std::less<int> >::const_iterator im = hit_signal.begin(); im != hit_signal.end(); ++im) {
2216 int chan = (*im).first;
2220 hitSignal[
chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
2221 chargeBefore += (*im).second;
2223 if(pixelWithCharge.first < irow_min)
2224 irow_min = pixelWithCharge.first;
2225 if(pixelWithCharge.first > irow_max)
2226 irow_max = pixelWithCharge.first;
2227 if(pixelWithCharge.second < icol_min)
2228 icol_min = pixelWithCharge.second;
2229 if(pixelWithCharge.second > icol_max)
2230 icol_max = pixelWithCharge.second;
2235 float trajectoryScaleToPosition = hitEntryPoint.
z()/direction.
z();
2237 if( (hitEntryPoint.
z() > 0 && direction.
z() < 0) || (hitEntryPoint.
z() < 0 && direction.
z() > 0) ){
2238 trajectoryScaleToPosition *= -1;
2241 LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction;
2244 std::pair<int,int> hitPixel = std::pair<int,int>(
int( floor(hitPositionPixel.
x() ) ),
int ( floor(hitPositionPixel.
y() ) ));
2251 std::pair<int,int> entryPixel = std::pair<int,int>(
int( floor(hitEntryPointPixel.
x() ) ),
int ( floor(hitEntryPointPixel.
y() ) ));
2252 std::pair<int,int> exitPixel = std::pair<int,int>(
int( floor(hitExitPointPixel.
x() ) ),
int ( floor(hitExitPointPixel.
y() ) ));
2254 int hitcol_min, hitcol_max, hitrow_min, hitrow_max;
2255 if(entryPixel.first>exitPixel.first){
2256 hitrow_min = exitPixel.first;
2257 hitrow_max = entryPixel.first;
2259 hitrow_min = entryPixel.first;
2260 hitrow_max = exitPixel.first;
2263 if(entryPixel.second>exitPixel.second){
2264 hitcol_min = exitPixel.second;
2265 hitcol_max = entryPixel.second;
2267 hitcol_min = entryPixel.second;
2268 hitcol_max = exitPixel.second;
2279 <<
"HitPosition:" <<
"\n" 2283 <<
"Pixel Pos - X: " << hitPositionPixel.
x() <<
" Y: " << hitPositionPixel.
y() <<
"\n" 2284 <<
"Cart.Cor. - X: " << CMSSWhitPosition.
x() <<
" Y: " << CMSSWhitPosition.
y() <<
"\n" 2285 <<
"Z=0 Pos - X: " << hitPosition.
x() <<
" Y: " << hitPosition.
y() <<
"\n" 2287 <<
"Origin of the template:" <<
"\n" 2288 <<
"Pixel Pos - X: " << originPixel.x() <<
" Y: " << originPixel.y() <<
"\n" 2289 <<
"Cart.Cor. - X: " << origin.
x() <<
" Y: " << origin.
y() <<
"\n" 2291 <<
"Entry/Exit:" <<
"\n" 2295 <<
"Entry - X Pixel: " << hitEntryPointPixel.
x() <<
" Y Pixel: " << hitEntryPointPixel.
y() <<
"\n" 2296 <<
"Exit - X Pixel: " << hitExitPointPixel.
x() <<
" Y Pixel: " << hitExitPointPixel.
y() <<
"\n" 2298 <<
"row min: " << irow_min <<
" col min: " << icol_min <<
"\n";
2301 if(!(irow_min<=hitrow_max && irow_max>=hitrow_min && icol_min<=hitcol_max && icol_max>=hitcol_min)){
2307 float cmToMicrons = 10000.f;
2309 track[0] = (hitPosition.
x() - origin.
x() )*cmToMicrons;
2310 track[1] = (hitPosition.
y() - origin.
y() )*cmToMicrons;
2312 track[3] = direction.x();
2313 track[4] = direction.y();
2314 track[5] = direction.z();
2318 for(
int row = 0; row <
TXSIZE; ++row) {
2320 pixrewgt[row][
col] = 0;
2324 for(
int row = 0; row <
TXSIZE; ++row) {
2332 for(
int row = 0; row <
TXSIZE; ++row) {
2341 std::cout <<
"Cluster before reweighting: " << std::endl;
2362 LogDebug (
"PixelDigitizer ") <<
"Cluster Charge Reweighting did not work properly.";
2368 std::cout <<
"Cluster after reweighting: " << std::endl;
2372 for(
int row = 0; row <
TXSIZE; ++row) {
2375 charge = pixrewgt[row][
col];
2376 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){
2383 if(chargeBefore!=0. && chargeAfter==0.){
2389 std::cout <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter << std::endl;
2390 std::cout <<
"Charge loss: " << (1 - chargeAfter/chargeBefore)*100 <<
" %" << std::endl << std::endl;
2409 int i, j,
k,
l, kclose;
2411 float xsize,
ysize, q50i, q100i, q50r, q10r, q100r, xhit2D, yhit2D, qclust, dist2, dmin2;
2414 int goodWeightsUsed, nearbyWeightsUsed, noWeightsUsed;
2415 float cotalpha, cotbeta;
2433 LogDebug (
"Pixel Digitizer") <<
"Reweighting angle is not good!" << std::endl;
2450 for(i=0; i<
BYM2; ++
i) {
2451 for(j=0; j<
BXM2; ++j) {
2453 xy_rewgt[j][
i] = 0.f;
2462 LogDebug(
"Pixel Digitizer") <<
"No matching template found" << std::endl;
2468 std::cout <<
"Template unirrad: " << std::endl;
2478 if(cluster.num_dimensions() != 2) {
2479 LogWarning (
"Pixel Digitizer") <<
"Cluster is not 2-dimensional. Return." << std::endl;
2482 nclusx = (
int)cluster.shape()[0];
2483 nclusy = (
int)cluster.shape()[1];
2485 LogWarning (
"Pixel Digitizer") <<
"Sizes in x do not match: nclusx=" << nclusx <<
" xdoubleSize=" <<
xdouble.size() <<
" TXSIZE=" <<
TXSIZE <<
". Return." << std::endl;
2489 LogWarning (
"Pixel Digitizer") <<
"Sizes in y do not match. Return." << std::endl;
2497 for(j=0; j<
TXSIZE; ++j) {
2498 xy_clust[j][
i] = 0.f;
2499 denx_clust[j][
i] = 0;
2500 deny_clust[j][
i] = 0;
2501 if(cluster[j][i] > q100i) {
2502 qclust += cluster[j][
i];
2512 std::cout <<
"Template irrad: " << std::endl;
2524 std::vector<int> ytclust;
2525 std::vector<int> xtclust;
2526 std::vector<int> ycclust;
2527 std::vector<int> xcclust;
2530 for(j=0; j<
TXSIZE; ++j) {
2531 if(xy_in[j+1][i+1] > q100i) {
2533 ytclust.push_back(i);
2534 xtclust.push_back(j);
2535 xy_clust[j][
i] = xy_rewgt[j+1][i+1]/xy_in[j+1][i+1];
2536 denx_clust[j][
i] = j;
2537 deny_clust[j][
i] =
i;
2545 for(j=0; j<
TXSIZE; ++j) {
2546 if(xy_rewgt[j+1][i+1] > q10r && xy_clust[j][i] == 0.
f && ntpix>0) {
2548 dmin2 = 10000.f; kclose = 0;
2549 for(k=0; k<ntpix; ++
k) {
2550 dist2=(i-ytclust[
k])*(i-ytclust[k])+0.44444f*(j-xtclust[
k])*(j-xtclust[k]);
2556 xy_clust[j][
i] = xy_rewgt[j+1][i+1]/xy_in[xtclust[kclose]+1][ytclust[kclose]+1];
2557 denx_clust[j][
i] = xtclust[kclose];
2558 deny_clust[j][
i] = ytclust[kclose];
2571 goodWeightsUsed = 0;
2572 nearbyWeightsUsed = 0;
2576 for(j=0; j<
TXSIZE; ++j) {
2577 if(xy_clust[j][i] > 0.
f) {
2578 cluster[j][
i] = xy_clust[j][
i]*clust[denx_clust[j][
i]][deny_clust[j][
i]];
2579 if(cluster[j][i] > q100r) {
2580 qclust += cluster[j][
i];
2582 if(cluster[j][i] > 0) {
2586 if(clust[j][i] > 0.
f) {
2588 ycclust.push_back(i);
2589 xcclust.push_back(j);
2598 for(l=0; l<ncpix; ++
l) {
2599 i=ycclust[
l]; j=xcclust[
l];
2600 dmin2 = 10000.f; kclose = 0;
2601 for(k=0; k<ntpix; ++
k) {
2602 dist2=(i-ytclust[
k])*(i-ytclust[k])+0.44444f*(j-xtclust[
k])*(j-xtclust[k]);
2609 nearbyWeightsUsed++;
2610 cluster[j][
i] *= xy_clust[xtclust[kclose]][ytclust[kclose]];
2611 if(cluster[j][i] > q100r) {
2612 qclust += cluster[j][
i];
2616 cluster[j][
i] = 0.f;
2627 for(
int row = 0; row <
TXSIZE; ++row) {
2639 for(
int row = 0; row <
BXM2; ++row) {
2651 for(
int row = 0; row <
TXSIZE; ++row) {
int adc(sample_type sample)
get the ADC sample (12 bits)
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
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.
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
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
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
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