54 #include <gsl/gsl_sf_erf.h> 56 #include "CLHEP/Random/RandGaussQ.h" 57 #include "CLHEP/Random/RandFlat.h" 116 if(use_ineff_from_db_){
117 theSiPixelGainCalibrationService_->setESObjects( es );
119 if(use_deadmodule_DB_) {
122 if(use_LorentzAngle_DB_) {
134 dbobject_den = SiPixel2DTemp_den.
product();
138 dbobject_num = SiPixel2DTemp_num.
product();
140 int numOfTemplates = dbobject_den->
numOfTempl()+dbobject_num->numOfTempl();
141 templateStores_.reserve(numOfTemplates);
154 makeDigiSimLinks_(conf.getUntrackedParameter<
bool>(
"makeDigiSimLinks",
true)),
155 use_ineff_from_db_(conf.getParameter<
bool>(
"useDB")),
156 use_module_killing_(conf.getParameter<
bool>(
"killModules")),
157 use_deadmodule_DB_(conf.getParameter<
bool>(
"DeadModules_DB")),
158 use_LorentzAngle_DB_(conf.getParameter<
bool>(
"LorentzAngle_DB")),
162 templ2D(templateStores_),
165 IDnum(conf.exists(
"TemplateIDnumerator")?conf.getParameter<
int>(
"TemplateIDnumerator"):0),
166 IDden(conf.exists(
"TemplateIDdenominator")?conf.getParameter<
int>(
"TemplateIDdenominator"):0),
170 GeVperElectron(3.61E-09),
173 alpha2Order(conf.getParameter<
bool>(
"Alpha2Order")),
179 NumberOfBarrelLayers(conf.exists(
"NumPixelBarrel")?conf.getParameter<
int>(
"NumPixelBarrel"):3),
180 NumberOfEndcapDisks(conf.exists(
"NumPixelEndcap")?conf.getParameter<
int>(
"NumPixelEndcap"):2),
187 theElectronPerADC(conf.getParameter<double>(
"ElectronPerAdc")),
191 theAdcFullScale(conf.getParameter<
int>(
"AdcFullScale")),
195 theNoiseInElectrons(conf.getParameter<double>(
"NoiseInElectrons")),
199 theReadoutNoise(conf.getParameter<double>(
"ReadoutNoiseInElec")),
204 theThresholdInE_FPix(conf.getParameter<double>(
"ThresholdInElectrons_FPix")),
205 theThresholdInE_BPix(conf.getParameter<double>(
"ThresholdInElectrons_BPix")),
206 theThresholdInE_BPix_L1(conf.exists(
"ThresholdInElectrons_BPix_L1")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L1"):theThresholdInE_BPix),
207 theThresholdInE_BPix_L2(conf.exists(
"ThresholdInElectrons_BPix_L2")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L2"):theThresholdInE_BPix),
210 theThresholdSmearing_FPix(conf.getParameter<double>(
"ThresholdSmearing_FPix")),
211 theThresholdSmearing_BPix(conf.getParameter<double>(
"ThresholdSmearing_BPix")),
212 theThresholdSmearing_BPix_L1(conf.exists(
"ThresholdSmearing_BPix_L1")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L1"):theThresholdSmearing_BPix),
213 theThresholdSmearing_BPix_L2(conf.exists(
"ThresholdSmearing_BPix_L2")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L2"):theThresholdSmearing_BPix),
216 electronsPerVCAL(conf.getParameter<double>(
"ElectronsPerVcal")),
217 electronsPerVCAL_Offset(conf.getParameter<double>(
"ElectronsPerVcal_Offset")),
218 electronsPerVCAL_L1(conf.exists(
"ElectronsPerVcal_L1")?conf.getParameter<double>(
"ElectronsPerVcal_L1"):electronsPerVCAL),
219 electronsPerVCAL_L1_Offset(conf.exists(
"ElectronsPerVcal_L1_Offset")?conf.getParameter<double>(
"ElectronsPerVcal_L1_Offset"):electronsPerVCAL_Offset),
223 theTofLowerCut(conf.getParameter<double>(
"TofLowerCut")),
224 theTofUpperCut(conf.getParameter<double>(
"TofUpperCut")),
227 tanLorentzAnglePerTesla_FPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_FPix")),
228 tanLorentzAnglePerTesla_BPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_BPix")),
231 FPix_p0(conf.getParameter<double>(
"FPix_SignalResponse_p0")),
232 FPix_p1(conf.getParameter<double>(
"FPix_SignalResponse_p1")),
233 FPix_p2(conf.getParameter<double>(
"FPix_SignalResponse_p2")),
234 FPix_p3(conf.getParameter<double>(
"FPix_SignalResponse_p3")),
236 BPix_p0(conf.getParameter<double>(
"BPix_SignalResponse_p0")),
237 BPix_p1(conf.getParameter<double>(
"BPix_SignalResponse_p1")),
238 BPix_p2(conf.getParameter<double>(
"BPix_SignalResponse_p2")),
239 BPix_p3(conf.getParameter<double>(
"BPix_SignalResponse_p3")),
242 addNoise(conf.getParameter<
bool>(
"AddNoise")),
246 addChargeVCALSmearing(conf.getParameter<
bool>(
"ChargeVCALSmearing")),
249 addNoisyPixels(conf.getParameter<
bool>(
"AddNoisyPixels")),
252 fluctuateCharge(conf.getUntrackedParameter<
bool>(
"FluctuateCharge",
true)),
258 addThresholdSmearing(conf.getParameter<
bool>(
"AddThresholdSmearing")),
261 doMissCalibrate(conf.getParameter<
bool>(
"MissCalibrate")),
262 theGainSmearing(conf.getParameter<double>(
"GainSmearing")),
263 theOffsetSmearing(conf.getParameter<double>(
"OffsetSmearing")),
266 AddPixelAging(conf.getParameter<
bool>(
"DoPixelAging")),
274 tMax(conf.getParameter<double>(
"deltaProductionCut")),
281 pixelAging_(conf,AddPixelAging,NumberOfBarrelLayers,NumberOfEndcapDisks)
283 LogInfo (
"PixelDigitizer ") <<
"SiPixelDigitizerAlgorithm constructed" 284 <<
"Configuration parameters:" 285 <<
"Threshold/Gain = " 286 <<
"threshold in electron FPix = " 288 <<
"threshold in electron BPix = " 290 <<
"threshold in electron BPix Layer1 = " 292 <<
"threshold in electron BPix Layer2 = " 295 <<
" The delta cut-off is set to " <<
tMax 300 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
307 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
calmap;
310 <<
" miss-calibrate the pixel amplitude ";
312 const bool ReadCalParameters =
false;
313 if(ReadCalParameters) {
316 char filename[80] =
"phCalibrationFit_C0.dat";
320 cout <<
" File not found " << endl;
323 cout <<
" file opened : " << filename << endl;
326 for (
int i = 0;
i < 3;
i++) {
327 in_file.getline(line, 500,
'\n');
331 cout <<
" test map" << endl;
337 for(
int i=0;
i<(52*80);
i++) {
338 in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid >> rowid;
340 cerr <<
"Cannot read data file" << endl;
343 if( in_file.eof() != 0 ) {
344 cerr << in_file.eof() <<
" " << in_file.gcount() <<
" " 345 << in_file.fail() <<
" " << in_file.good() <<
" end of file " 361 calmap.insert(std::pair<int,CalParameters>(chan,onePix));
365 if(rowid!=p.first)
cout<<
" wrong channel row "<<rowid<<
" "<<p.first<<endl;
366 if(colid!=p.second)
cout<<
" wrong channel col "<<colid<<
" "<<p.second<<endl;
370 cout <<
" map size " << calmap.size() <<
" max "<<calmap.max_size() <<
" " 371 <<calmap.empty()<< endl;
394 LogDebug (
"PixelDigitizer")<<
"SiPixelDigitizerAlgorithm deleted";
403 if (AddPixelInefficiency){
405 conf.
exists(
"thePixelColEfficiency_BPix1") && conf.
exists(
"thePixelColEfficiency_BPix2") && conf.
exists(
"thePixelColEfficiency_BPix3") &&
406 conf.
exists(
"thePixelColEfficiency_FPix1") && conf.
exists(
"thePixelColEfficiency_FPix2") &&
407 conf.
exists(
"thePixelEfficiency_BPix1") && conf.
exists(
"thePixelEfficiency_BPix2") && conf.
exists(
"thePixelEfficiency_BPix3") &&
408 conf.
exists(
"thePixelEfficiency_FPix1") && conf.
exists(
"thePixelEfficiency_FPix2") &&
409 conf.
exists(
"thePixelChipEfficiency_BPix1") && conf.
exists(
"thePixelChipEfficiency_BPix2") && conf.
exists(
"thePixelChipEfficiency_BPix3") &&
410 conf.
exists(
"thePixelChipEfficiency_FPix1") && conf.
exists(
"thePixelChipEfficiency_FPix2");
411 if (NumberOfBarrelLayers==3) FromConfig = FromConfig && conf.
exists(
"theLadderEfficiency_BPix1") && conf.
exists(
"theLadderEfficiency_BPix2") && conf.
exists(
"theLadderEfficiency_BPix3") &&
412 conf.
exists(
"theModuleEfficiency_BPix1") && conf.
exists(
"theModuleEfficiency_BPix2") && conf.
exists(
"theModuleEfficiency_BPix3") &&
413 conf.
exists(
"thePUEfficiency_BPix1") && conf.
exists(
"thePUEfficiency_BPix2") && conf.
exists(
"thePUEfficiency_BPix3") &&
414 conf.
exists(
"theInnerEfficiency_FPix1") && conf.
exists(
"theInnerEfficiency_FPix2") &&
415 conf.
exists(
"theOuterEfficiency_FPix1") && conf.
exists(
"theOuterEfficiency_FPix2") &&
416 conf.
exists(
"thePUEfficiency_FPix_Inner") && conf.
exists(
"thePUEfficiency_FPix_Outer") &&
417 conf.
exists(
"theInstLumiScaleFactor");
418 if (NumberOfBarrelLayers>=4) FromConfig = FromConfig && conf.
exists(
"thePixelColEfficiency_BPix4") &&
419 conf.
exists(
"thePixelEfficiency_BPix4") && conf.
exists(
"thePixelChipEfficiency_BPix4");
420 if (NumberOfEndcapDisks>=3) FromConfig = FromConfig && conf.
exists(
"thePixelColEfficiency_FPix4") &&
421 conf.
exists(
"thePixelEfficiency_FPix3") && conf.
exists(
"thePixelChipEfficiency_FPix3");
423 LogInfo (
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the config file.\n";
424 theInstLumiScaleFactor = conf.
getParameter<
double>(
"theInstLumiScaleFactor");
426 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix1");
427 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix2");
428 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix3");
429 if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix4");}
432 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix1");
433 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix2");
434 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix3");
435 if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix4");}
438 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix1");
439 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix2");
440 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix3");
441 if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix4");}
443 if (NumberOfBarrelLayers==3){
445 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix1");
446 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix2");
447 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix3");
448 if ( ((theLadderEfficiency_BPix[0].
size()!=20) || (theLadderEfficiency_BPix[1].
size()!=32) ||
449 (theLadderEfficiency_BPix[2].
size()!=44)) && (NumberOfBarrelLayers==3) )
450 throw cms::Exception(
"Configuration") <<
"Wrong ladder number in efficiency config!";
453 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix1");
454 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix2");
455 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix3");
456 if ( ((theModuleEfficiency_BPix[0].
size()!=4) || (theModuleEfficiency_BPix[1].
size()!=4) ||
457 (theModuleEfficiency_BPix[2].
size()!=4)) && (NumberOfBarrelLayers==3) )
458 throw cms::Exception(
"Configuration") <<
"Wrong module number in efficiency config!";
460 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix1"));
461 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix2"));
462 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix3"));
463 if ( ((thePUEfficiency[0].
empty()) || (thePUEfficiency[1].
empty()) ||
464 (thePUEfficiency[2].
empty())) && (NumberOfBarrelLayers==3) )
465 throw cms::Exception(
"Configuration") <<
"At least one PU efficiency (BPix) number is needed in efficiency config!";
468 if (NumberOfBarrelLayers>=5){
469 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
472 thePixelColEfficiency[j-1]=0.999;
473 thePixelEfficiency[j-1]=0.999;
474 thePixelChipEfficiency[j-1]=0.999;
479 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix1");
480 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix2");
481 if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix3");}
483 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix1");
484 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix2");
485 if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix3");}
487 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix1");
488 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix2");
489 if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix3");}
491 if (NumberOfEndcapDisks>=4){
492 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
495 thePixelColEfficiency[j-1]=0.999;
496 thePixelEfficiency[j-1]=0.999;
497 thePixelChipEfficiency[j-1]=0.999;
501 if (NumberOfBarrelLayers==3){
503 theInnerEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theInnerEfficiency_FPix1");
504 theInnerEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theInnerEfficiency_FPix2");
506 theOuterEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theOuterEfficiency_FPix1");
507 theOuterEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theOuterEfficiency_FPix2");
508 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Inner"));
509 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Outer"));
510 if ( ((thePUEfficiency[3].
empty()) || (thePUEfficiency[4].
empty())) && (NumberOfEndcapDisks==2) )
511 throw cms::Exception(
"Configuration") <<
"At least one (FPix) PU efficiency number is needed in efficiency config!";
512 pu_scale.resize(thePUEfficiency.size());
515 else LogInfo (
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the database.\n";
533 const std::map<uint32_t, double>& PixelGeomFactorsDBIn = SiPixelDynamicInefficiency->
getPixelGeomFactors();
534 const std::map<uint32_t, double>& ColGeomFactorsDB = SiPixelDynamicInefficiency->
getColGeomFactors();
535 const std::map<uint32_t, double>& ChipGeomFactorsDB = SiPixelDynamicInefficiency->
getChipGeomFactors();
536 const std::map<uint32_t, std::vector<double> >& PUFactors = SiPixelDynamicInefficiency->
getPUFactors();
537 std::vector<uint32_t > DetIdmasks = SiPixelDynamicInefficiency->
getDetIdmasks();
540 for(
const auto& it_module : geom->
detUnits()) {
541 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
542 const DetId detid = it_module->geographicalId();
543 uint32_t rawid = detid.
rawId();
544 PixelGeomFactors[rawid] = 1;
545 ColGeomFactors[rawid] = 1;
546 ChipGeomFactors[rawid] = 1;
547 PixelGeomFactorsROCStdPixels[rawid] = std::vector<double>(16,1);
548 PixelGeomFactorsROCBigPixels[rawid] = std::vector<double>(16,1);
552 std::map<uint32_t, double> PixelGeomFactorsDB;
556 for (
auto db_factor : PixelGeomFactorsDBIn){
559 unsigned int rocMask = rocIdMaskBits <<
shift;
560 unsigned int rocId = (((db_factor.first) & rocMask) >>
shift);
563 unsigned int rawid = db_factor.first & (~rocMask);
568 double factor = db_factor.second;
569 double badFraction = 1 - factor;
570 double bigPixelFraction =
static_cast<double> (nBigPixelsInROC)/nPixelsInROC;
571 double stdPixelFraction = 1. - bigPixelFraction;
573 double badFractionBig =
std::min(bigPixelFraction, badFraction);
574 double badFractionStd =
std::max(0., badFraction - badFractionBig);
575 double badFractionBigReNormalized = badFractionBig/bigPixelFraction;
576 double badFractionStdReNormalized = badFractionStd/stdPixelFraction;
577 PixelGeomFactorsROCStdPixels[rawid][rocId] *= (1. - badFractionStdReNormalized);
578 PixelGeomFactorsROCBigPixels[rawid][rocId] *= (1. - badFractionBigReNormalized);
581 PixelGeomFactorsDB[db_factor.first] = db_factor.second;
586 PixelGeomFactorsDB = PixelGeomFactorsDBIn;
590 for(
const auto& it_module : geom->
detUnits()) {
591 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
592 const DetId detid = it_module->geographicalId();
593 uint32_t rawid = detid.
rawId();
594 for (
auto db_factor : PixelGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) PixelGeomFactors[rawid] *= db_factor.second;
595 for (
auto db_factor : ColGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) ColGeomFactors[rawid] *= db_factor.second;
596 for (
auto db_factor : ChipGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) ChipGeomFactors[rawid] *= db_factor.second;
602 for (
auto factor : PUFactors) {
604 for(
const auto& it_module : geom->
detUnits()) {
605 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
606 const DetId detid = it_module->geographicalId();
607 if (!
matches(detid, db_id, DetIdmasks))
continue;
608 if (iPU.count(detid.
rawId())) {
609 throw cms::Exception(
"Database")<<
"Multiple db_ids match to same module in SiPixelDynamicInefficiency DB Object";
614 thePUEfficiency.push_back(factor.second);
617 pu_scale.resize(thePUEfficiency.size());
622 for (
size_t i=0;
i<DetIdmasks.size(); ++
i) {
639 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix1");
640 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix2");
641 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix3");
642 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix4");
645 if (NumberOfBarrelLayers>=5){
646 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
649 thePixelPseudoRadDamage[j-1]=0.;
654 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix1");
655 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix2");
656 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix3");
659 if (NumberOfEndcapDisks>=4){
660 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
663 thePixelPseudoRadDamage[j-1]=0.;
673 std::vector<PSimHit>::const_iterator inputEnd,
674 const size_t inputBeginGlobalIndex,
675 const unsigned int tofBin,
679 CLHEP::HepRandomEngine* engine) {
684 size_t simHitGlobalIndex=inputBeginGlobalIndex;
685 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
687 if((*ssbegin).detUnitId() != detId) {
693 << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" " 694 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" " 695 << (*ssbegin).trackId() <<
" " << (*ssbegin).processType() <<
" " 696 << (*ssbegin).detUnitId()
697 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint() ;
701 std::vector<EnergyDepositUnit> ionization_points;
702 std::vector<SignalPoint> collection_points;
709 drift(*ssbegin, pixdet, bfield, tTopo, ionization_points, collection_points);
711 induce_signal(inputBegin, inputEnd, *ssbegin, simHitGlobalIndex, tofBin, pixdet, collection_points);
727 std::vector<int>::const_iterator
pu;
728 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
730 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++
pu) {
737 if (pu0!=bunchCrossing.end()) {
740 double instlumi_pow=1.;
744 instlumi_pow*=instlumi;
759 for(
unsigned int i=0;
i<ps.size();
i++)
760 if (ps[
i].getBunchCrossing() == 0)
766 double instlumi_pow=1.;
770 instlumi_pow*=instlumi;
783 for(
const auto& det: signalMap) {
784 auto& theSignal =
_signal[det.first];
785 for(
const auto&
chan: det.second) {
793 std::vector<PixelDigi>& digis,
794 std::vector<PixelDigiSimLink>& simlinks,
796 CLHEP::HepRandomEngine* engine) {
810 float thePixelThresholdInE = 0.;
814 int lay = tTopo->
layer(detID);
843 else {
throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;}
850 int numRows = topol->
nrows();
854 <<
" PixelDigitizer " 855 << numColumns <<
" " << numRows <<
" " << moduleThickness;
876 make_digis(thePixelThresholdInE, detID, pixdet, digis, simlinks, tTopo);
879 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
890 const float SegmentLength = 0.0010;
897 float length = direction.
mag();
899 int NumberOfSegments =
int ( length / SegmentLength);
900 if(NumberOfSegments < 1) NumberOfSegments = 1;
904 <<
" enter primary_ionzation " << NumberOfSegments
912 float* elossVector =
new float[NumberOfSegments];
919 float momentum = hit.
pabs();
922 elossVector, engine);
925 ionization_points.resize( NumberOfSegments);
928 for (
int i = 0;
i != NumberOfSegments;
i++) {
931 float((
i+0.5)/NumberOfSegments) * direction;
939 ionization_points[
i] = edu;
943 <<
i <<
" " << ionization_points[
i].x() <<
" " 944 << ionization_points[
i].y() <<
" " 945 << ionization_points[
i].z() <<
" " 946 << ionization_points[
i].energy();
951 delete[] elossVector;
959 float eloss,
float length,
960 int NumberOfSegs,
float elossVector[],
961 CLHEP::HepRandomEngine* engine)
const {
968 double particleMass = 139.6;
971 if(pid==11) particleMass = 0.511;
972 else if(pid==13) particleMass = 105.7;
973 else if(pid==321) particleMass = 493.7;
974 else if(pid==2212) particleMass = 938.3;
977 float segmentLength = length/NumberOfSegs;
982 double segmentEloss = (1000.*eloss)/NumberOfSegs;
983 for (
int i=0;
i<NumberOfSegs;
i++) {
989 double deltaCutoff =
tMax;
990 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
991 particleMass, deltaCutoff,
992 double(segmentLength*10.),
993 segmentEloss, engine )/1000.;
1000 float ratio = eloss/sum;
1002 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
1004 float averageEloss = eloss/NumberOfSegs;
1005 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
1017 const std::vector<EnergyDepositUnit>& ionization_points,
1018 std::vector<SignalPoint>& collection_points)
const {
1021 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
1024 collection_points.resize(ionization_points.size());
1027 if(driftDir.
z() ==0.) {
1028 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
1036 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
1039 TanLorenzAngleX = driftDir.
x();
1040 TanLorenzAngleY = driftDir.
y();
1041 dir_z = driftDir.
z();
1042 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
1043 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
1046 TanLorenzAngleX = driftDir.
x();
1047 TanLorenzAngleY = 0.;
1048 dir_z = driftDir.
z();
1049 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
1050 CosLorenzAngleY = 1.;
1056 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" " 1057 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" " 1058 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
1063 float DriftDistance;
1067 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
1069 float SegX, SegY, SegZ;
1070 SegX = ionization_points[
i].
x();
1071 SegY = ionization_points[
i].y();
1072 SegZ = ionization_points[
i].z();
1077 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
1087 if( DriftDistance < 0.) {
1089 }
else if( DriftDistance > moduleThickness )
1090 DriftDistance = moduleThickness;
1093 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
1094 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
1097 float CloudCenterX = SegX + XDriftDueToMagField;
1098 float CloudCenterY = SegY + YDriftDueToMagField;
1101 DriftLength =
sqrt( DriftDistance*DriftDistance +
1102 XDriftDueToMagField*XDriftDueToMagField +
1103 YDriftDueToMagField*YDriftDueToMagField );
1109 Sigma_x = Sigma / CosLorenzAngleX ;
1110 Sigma_y = Sigma / CosLorenzAngleY ;
1113 float energyOnCollector = ionization_points[
i].energy();
1118 energyOnCollector *=
exp( -1*kValue*DriftDistance/moduleThickness );
1123 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
1124 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
1127 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
1130 collection_points[
i] = (sp);
1139 std::vector<PSimHit>::const_iterator inputEnd,
1141 const size_t hitIndex,
1142 const unsigned int tofBin,
1144 const std::vector<SignalPoint>& collection_points) {
1155 <<
" enter induce_signal, " 1156 << topol->
pitch().first <<
" " << topol->
pitch().second;
1160 typedef std::map< int, float, std::less<int> > hit_map_type;
1161 hit_map_type hit_signal;
1164 std::map<int, float, std::less<int> >
x,
y;
1169 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
1170 i != collection_points.end(); ++
i) {
1172 float CloudCenterX =
i->position().x();
1173 float CloudCenterY =
i->position().y();
1176 float Charge =
i->amplitude();
1187 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" " 1188 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
1211 int IPixRightUpX =
int( floor( mp.
x()));
1212 int IPixRightUpY =
int( floor( mp.
y()));
1215 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" " 1216 << mp.
x() <<
" " << mp.
y() <<
" " 1217 << IPixRightUpX <<
" " << IPixRightUpY ;
1222 int IPixLeftDownX =
int( floor( mp.
x()));
1223 int IPixLeftDownY =
int( floor( mp.
y()));
1226 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" " 1227 << mp.
x() <<
" " << mp.
y() <<
" " 1228 << IPixLeftDownX <<
" " << IPixLeftDownY ;
1232 int numColumns = topol->
ncolumns();
1233 int numRows = topol->
nrows();
1235 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
1236 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
1237 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
1238 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
1245 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1246 float xUB, xLB, UpperBound, LowerBound;
1251 if(ix == 0 || SigmaX==0. )
1256 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
1259 if(ix == numRows-1 || SigmaX==0. )
1264 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
1267 float TotalIntegrationRange = UpperBound - LowerBound;
1268 x[ix] = TotalIntegrationRange;
1276 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1277 float yUB, yLB, UpperBound, LowerBound;
1279 if(iy == 0 || SigmaY==0.)
1284 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
1287 if(iy == numColumns-1 || SigmaY==0. )
1292 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
1295 float TotalIntegrationRange = UpperBound - LowerBound;
1296 y[iy] = TotalIntegrationRange;
1303 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1304 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1306 float ChargeFraction = Charge*x[ix]*y[iy];
1308 if( ChargeFraction > 0. ) {
1311 hit_signal[
chan] += ChargeFraction;
1319 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" " 1320 << chan <<
" " << ChargeFraction<<
" " 1321 << mp.
x() <<
" " << mp.
y() <<
" " 1322 << lp.
x() <<
" " << lp.
y() <<
" " 1334 bool reweighted =
false;
1344 for ( hit_map_type::const_iterator im = hit_signal.begin();
1345 im != hit_signal.end(); ++im) {
1346 int chan = (*im).first;
1347 theSignal[
chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1352 <<
" pixel " << ip.first <<
" " << ip.second <<
" " 1366 std::vector<PixelDigi>& digis,
1367 std::vector<PixelDigiSimLink>& simlinks,
1371 LogDebug (
"Pixel Digitizer") <<
" make digis "<<
" " 1376 <<
" List pixels passing threshold ";
1381 signalMaps::const_iterator it =
_signal.find(detID);
1390 std::map<TrackEventId, float> simi;
1394 float signalInElectrons = (*i).second ;
1401 if( signalInElectrons >= thePixelThresholdInE && signalInElectrons > 0.) {
1403 int chan = (*i).first;
1410 int col = ip.second;
1411 adc =
int(
missCalibrate(detID, tTopo, pixdet, col, row, signalInElectrons));
1418 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1419 <<
" " << adc << ip.first <<
" " << ip.second ;
1423 digis.emplace_back(ip.first, ip.second, adc);
1428 for(
const auto&
info: (*i).second.hitInfos()) {
1431 simi[std::make_pair(
info.trackId(),
info.eventId().rawId())] += (*i).second.individualampl()[il];
1436 for(
const auto&
info: (*i).second.hitInfos()) {
1438 auto found = simi.find(std::make_pair(
info.trackId(),
info.eventId().rawId()));
1439 if(
found == simi.end())
1442 float sum_samechannel =
found->second;
1443 float fraction=sum_samechannel/(*i).second;
1444 if(fraction>1.
f) fraction=1.f;
1460 float thePixelThreshold,
1461 CLHEP::HepRandomEngine* engine) {
1472 float theSmearedChargeRMS = 0.0;
1478 if((*i).second < 3000)
1480 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1481 }
else if((*i).second < 6000){
1482 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1484 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1488 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1492 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1493 (*i).second.set(0);}
1495 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1505 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1506 (*i).second.set(0);}
1518 int numColumns = topol->
ncolumns();
1519 int numRows = topol->
nrows();
1523 int numberOfPixels = (numRows * numColumns);
1524 std::map<int,float, std::less<int> > otherPixels;
1525 std::map<int,float, std::less<int> >::iterator mapI;
1535 <<
" Add noisy pixels " << numRows <<
" " 1538 << otherPixels.size() ;
1542 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1543 int iy = ((*mapI).first) / numRows;
1544 int ix = ((*mapI).first) - (iy*numRows);
1547 if( iy < 0 || iy > (numColumns-1) )
1548 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1549 if( ix < 0 || ix > (numRows-1) )
1550 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1556 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1557 <<
" " << ix <<
" " << iy <<
" " <<
chan ;
1560 if(theSignal[chan] == 0){
1562 int noise=
int( (*mapI).second );
1575 CLHEP::HepRandomEngine* engine) {
1580 int numColumns = topol->
ncolumns();
1581 int numRows = topol->
nrows();
1585 double pixelEfficiency = 1.0;
1586 double columnEfficiency = 1.0;
1587 double chipEfficiency = 1.0;
1588 std::vector<double> pixelEfficiencyROCStdPixels(16,1);
1589 std::vector<double> pixelEfficiencyROCBigPixels(16,1);
1595 int layerIndex=tTopo->
layer(detID);
1602 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1603 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1607 if (module<=4) module=5-module;
1617 unsigned int panelIndex=tTopo->
pxfPanel(detID);
1618 unsigned int moduleIndex=tTopo->
pxfModule(detID);
1628 if(numColumns>260 || numRows>160) {
1629 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1630 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1633 if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) {
1641 pixelEfficiency = 0.999;
1642 columnEfficiency = 0.999;
1643 chipEfficiency = 0.999;
1658 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" " 1659 << columnEfficiency <<
" " << chipEfficiency;
1664 std::unique_ptr<PixelIndices> pIndexConverter(
new PixelIndices(numColumns,numRows));
1669 std::map<int, int, std::less<int> >chips,
columns, pixelStd, pixelBig;
1670 std::map<int, int, std::less<int> >::iterator iter;
1676 int chan =
i->first;
1679 int col = ip.second;
1681 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1682 int dColInChip = pIndexConverter->DColumn(colROC);
1684 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1687 columns[dColInDet]++;
1690 pixelBig[chipIndex]++;
1692 pixelStd[chipIndex]++;
1697 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1699 float rand = CLHEP::RandFlat::shoot(engine);
1700 if( rand > chipEfficiency ) chips[iter->first]=0;
1704 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1706 float rand = CLHEP::RandFlat::shoot(engine);
1707 if( rand > columnEfficiency ) columns[iter->first]=0;
1712 for ( iter = pixelStd.begin(); iter != pixelStd.end() ; iter++ ) {
1713 float rand = CLHEP::RandFlat::shoot(engine);
1714 if( rand > pixelEfficiencyROCStdPixels[iter->first]) pixelStd[iter->first] = 0;
1717 for ( iter = pixelBig.begin(); iter != pixelBig.end() ; iter++ ) {
1718 float rand = CLHEP::RandFlat::shoot(engine);
1719 if( rand > pixelEfficiencyROCBigPixels[iter->first]) pixelBig[iter->first] = 0;
1730 int col = ip.second;
1732 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1733 int dColInChip = pIndexConverter->DColumn(colROC);
1735 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1738 float rand = CLHEP::RandFlat::shoot(engine);
1739 if( chips[chipIndex]==0 || columns[dColInDet]==0
1740 || rand>pixelEfficiency
1741 || (pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0)
1742 || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)) {
1747 if((pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0)
1748 || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)) {
1768 float pseudoRadDamage = 0.0f;
1773 int layerIndex=tTopo->
layer(detID);
1791 pseudoRadDamage = 0.f;
1797 return pseudoRadDamage;
1799 LogDebug (
"Pixel Digitizer") <<
" enter pixel_aging " << pseudoRadDamage;
1814 const float signalInElectrons)
const {
1841 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1855 newAmp = p3 + p2 * tanh(p0*signal - p1);
1900 const DetId& detId)
const {
1937 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1942 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1945 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1952 alpha2 = lorentzAngle * lorentzAngle;
1954 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1955 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1956 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1963 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is " 1964 << theDriftDirection ;
1967 return theDriftDirection;
1982 int col = ip.second;
1999 Parameters::const_iterator itDeadModules=
DeadModules.begin();
2002 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
2003 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
2004 if(detid == Dead_detID){
2017 if(Module==
"whole"){
2026 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
2030 if( Module==
"tbmB" && ip.first<=79){
2045 for (
size_t id=0;
id<disabledModules.size();
id++)
2047 if(detID==disabledModules[
id].DetID){
2049 badmodule = disabledModules[
id];
2069 std::vector<GlobalPixel> badrocpositions (0);
2070 for(
unsigned int j = 0; j < 16; j++){
2074 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
2075 for (IT it = path.begin(); it != path.end(); ++it) {
2080 badrocpositions.push_back(global);
2091 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
2092 if(it->row >= 80 && ip.first >= 80 ){
2093 if((
std::abs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
2094 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
2095 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
2097 else if(it->row < 80 && ip.first < 80 ){
2098 if((
std::abs(ip.second - it->col) < 26) ){
i->second.set(0.);}
2099 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
2100 else if(it->row==39 && it->col-ip.second==26){
i->second.set(0.);}
2110 std::map<
int,
float, std::less<int> >& hit_signal,
2111 const size_t hitIndex,
2112 const unsigned int tofBin,
2116 unsigned short int processType){
2118 int irow_min = topol->
nrows();
2123 float chargeBefore = 0;
2124 float chargeAfter = 0;
2128 for (
std::map<
int,
float, std::less<int> >::const_iterator im = hit_signal.begin(); im != hit_signal.end(); ++im) {
2129 int chan = (*im).first;
2133 hitSignal[
chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
2134 chargeBefore += (*im).second;
2136 if(pixelWithCharge.first < irow_min)
2137 irow_min = pixelWithCharge.first;
2138 if(pixelWithCharge.first > irow_max)
2139 irow_max = pixelWithCharge.first;
2140 if(pixelWithCharge.second < icol_min)
2141 icol_min = pixelWithCharge.second;
2142 if(pixelWithCharge.second > icol_max)
2143 icol_max = pixelWithCharge.second;
2148 float trajectoryScaleToPosition = hitEntryPoint.
z()/direction.
z();
2150 if( (hitEntryPoint.
z() > 0 && direction.
z() < 0) || (hitEntryPoint.
z() < 0 && direction.
z() > 0) ){
2151 trajectoryScaleToPosition *= -1;
2154 LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction;
2157 std::pair<int,int> hitPixel = std::pair<int,int>(
int( floor(hitPositionPixel.
x() ) ),
int ( floor(hitPositionPixel.
y() ) ));
2164 std::pair<int,int> entryPixel = std::pair<int,int>(
int( floor(hitEntryPointPixel.
x() ) ),
int ( floor(hitEntryPointPixel.
y() ) ));
2165 std::pair<int,int> exitPixel = std::pair<int,int>(
int( floor(hitExitPointPixel.
x() ) ),
int ( floor(hitExitPointPixel.
y() ) ));
2167 int hitcol_min, hitcol_max, hitrow_min, hitrow_max;
2168 if(entryPixel.first>exitPixel.first){
2169 hitrow_min = exitPixel.first;
2170 hitrow_max = entryPixel.first;
2172 hitrow_min = entryPixel.first;
2173 hitrow_max = exitPixel.first;
2176 if(entryPixel.second>exitPixel.second){
2177 hitcol_min = exitPixel.second;
2178 hitcol_max = entryPixel.second;
2180 hitcol_min = entryPixel.second;
2181 hitcol_max = exitPixel.second;
2192 <<
"HitPosition:" <<
"\n" 2196 <<
"Pixel Pos - X: " << hitPositionPixel.
x() <<
" Y: " << hitPositionPixel.
y() <<
"\n" 2197 <<
"Cart.Cor. - X: " << CMSSWhitPosition.
x() <<
" Y: " << CMSSWhitPosition.
y() <<
"\n" 2198 <<
"Z=0 Pos - X: " << hitPosition.
x() <<
" Y: " << hitPosition.
y() <<
"\n" 2200 <<
"Origin of the template:" <<
"\n" 2201 <<
"Pixel Pos - X: " << originPixel.x() <<
" Y: " << originPixel.y() <<
"\n" 2202 <<
"Cart.Cor. - X: " << origin.
x() <<
" Y: " << origin.
y() <<
"\n" 2204 <<
"Entry/Exit:" <<
"\n" 2208 <<
"Entry - X Pixel: " << hitEntryPointPixel.
x() <<
" Y Pixel: " << hitEntryPointPixel.
y() <<
"\n" 2209 <<
"Exit - X Pixel: " << hitExitPointPixel.
x() <<
" Y Pixel: " << hitExitPointPixel.
y() <<
"\n" 2211 <<
"row min: " << irow_min <<
" col min: " << icol_min <<
"\n";
2214 if(!(irow_min<=hitrow_max && irow_max>=hitrow_min && icol_min<=hitcol_max && icol_max>=hitcol_min)){
2220 float cmToMicrons = 10000.f;
2222 track[0] = (hitPosition.
x() - origin.
x() )*cmToMicrons;
2223 track[1] = (hitPosition.
y() - origin.
y() )*cmToMicrons;
2225 track[3] = direction.x();
2226 track[4] = direction.y();
2227 track[5] = direction.z();
2231 for(
int row = 0; row <
TXSIZE; ++row) {
2233 pixrewgt[row][
col] = 0;
2237 for(
int row = 0; row <
TXSIZE; ++row) {
2245 for(
int row = 0; row <
TXSIZE; ++row) {
2254 std::cout <<
"Cluster before reweighting: " << std::endl;
2275 LogDebug (
"PixelDigitizer ") <<
"Cluster Charge Reweighting did not work properly.";
2281 std::cout <<
"Cluster after reweighting: " << std::endl;
2285 for(
int row = 0; row <
TXSIZE; ++row) {
2288 charge = pixrewgt[row][
col];
2289 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){
2296 if(chargeBefore!=0. && chargeAfter==0.){
2302 std::cout <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter << std::endl;
2303 std::cout <<
"Charge loss: " << (1 - chargeAfter/chargeBefore)*100 <<
" %" << std::endl << std::endl;
2322 int i, j,
k,
l, kclose;
2324 float xsize,
ysize, q50i, q100i, q50r, q10r, q100r, xhit2D, yhit2D, qclust, dist2, dmin2;
2327 int goodWeightsUsed, nearbyWeightsUsed, noWeightsUsed;
2328 float cotalpha, cotbeta;
2346 LogDebug (
"Pixel Digitizer") <<
"Reweighting angle is not good!" << std::endl;
2363 for(i=0; i<
BYM2; ++
i) {
2364 for(j=0; j<
BXM2; ++j) {
2366 xy_rewgt[j][
i] = 0.f;
2375 LogDebug(
"Pixel Digitizer") <<
"No matching template found" << std::endl;
2381 std::cout <<
"Template unirrad: " << std::endl;
2391 if(cluster.num_dimensions() != 2) {
2392 LogWarning (
"Pixel Digitizer") <<
"Cluster is not 2-dimensional. Return." << std::endl;
2395 nclusx = (
int)cluster.shape()[0];
2396 nclusy = (
int)cluster.shape()[1];
2398 LogWarning (
"Pixel Digitizer") <<
"Sizes in x do not match: nclusx=" << nclusx <<
" xdoubleSize=" <<
xdouble.size() <<
" TXSIZE=" <<
TXSIZE <<
". Return." << std::endl;
2402 LogWarning (
"Pixel Digitizer") <<
"Sizes in y do not match. Return." << std::endl;
2410 for(j=0; j<
TXSIZE; ++j) {
2411 xy_clust[j][
i] = 0.f;
2412 denx_clust[j][
i] = 0;
2413 deny_clust[j][
i] = 0;
2414 if(cluster[j][i] > q100i) {
2415 qclust += cluster[j][
i];
2425 std::cout <<
"Template irrad: " << std::endl;
2437 std::vector<int> ytclust;
2438 std::vector<int> xtclust;
2439 std::vector<int> ycclust;
2440 std::vector<int> xcclust;
2443 for(j=0; j<
TXSIZE; ++j) {
2444 if(xy_in[j+1][i+1] > q100i) {
2446 ytclust.push_back(i);
2447 xtclust.push_back(j);
2448 xy_clust[j][
i] = xy_rewgt[j+1][i+1]/xy_in[j+1][i+1];
2449 denx_clust[j][
i] = j;
2450 deny_clust[j][
i] =
i;
2458 for(j=0; j<
TXSIZE; ++j) {
2459 if(xy_rewgt[j+1][i+1] > q10r && xy_clust[j][i] == 0.
f && ntpix>0) {
2461 dmin2 = 10000.f; kclose = 0;
2462 for(k=0; k<ntpix; ++
k) {
2463 dist2=(i-ytclust[
k])*(i-ytclust[k])+0.44444f*(j-xtclust[
k])*(j-xtclust[k]);
2469 xy_clust[j][
i] = xy_rewgt[j+1][i+1]/xy_in[xtclust[kclose]+1][ytclust[kclose]+1];
2470 denx_clust[j][
i] = xtclust[kclose];
2471 deny_clust[j][
i] = ytclust[kclose];
2484 goodWeightsUsed = 0;
2485 nearbyWeightsUsed = 0;
2489 for(j=0; j<
TXSIZE; ++j) {
2490 if(xy_clust[j][i] > 0.
f) {
2491 cluster[j][
i] = xy_clust[j][
i]*clust[denx_clust[j][
i]][deny_clust[j][
i]];
2492 if(cluster[j][i] > q100r) {
2493 qclust += cluster[j][
i];
2495 if(cluster[j][i] > 0) {
2499 if(clust[j][i] > 0.
f) {
2501 ycclust.push_back(i);
2502 xcclust.push_back(j);
2511 for(l=0; l<ncpix; ++
l) {
2512 i=ycclust[
l]; j=xcclust[
l];
2513 dmin2 = 10000.f; kclose = 0;
2514 for(k=0; k<ntpix; ++
k) {
2515 dist2=(i-ytclust[
k])*(i-ytclust[k])+0.44444f*(j-xtclust[
k])*(j-xtclust[k]);
2522 nearbyWeightsUsed++;
2523 cluster[j][
i] *= xy_clust[xtclust[kclose]][ytclust[kclose]];
2524 if(cluster[j][i] > q100r) {
2525 qclust += cluster[j][
i];
2529 cluster[j][
i] = 0.f;
2540 for(
int row = 0; row <
TXSIZE; ++row) {
2552 for(
int row = 0; row <
BXM2; ++row) {
2564 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)
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
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())
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
const float theThresholdInE_FPix
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 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
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
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