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")),
192 theAdcFullScaleStack(conf.exists(
"AdcFullScaleStack")?conf.getParameter<
int>(
"AdcFullScaleStack"):255),
196 theNoiseInElectrons(conf.getParameter<double>(
"NoiseInElectrons")),
200 theReadoutNoise(conf.getParameter<double>(
"ReadoutNoiseInElec")),
205 theThresholdInE_FPix(conf.getParameter<double>(
"ThresholdInElectrons_FPix")),
206 theThresholdInE_BPix(conf.getParameter<double>(
"ThresholdInElectrons_BPix")),
207 theThresholdInE_BPix_L1(conf.exists(
"ThresholdInElectrons_BPix_L1")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L1"):theThresholdInE_BPix),
208 theThresholdInE_BPix_L2(conf.exists(
"ThresholdInElectrons_BPix_L2")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L2"):theThresholdInE_BPix),
211 theThresholdSmearing_FPix(conf.getParameter<double>(
"ThresholdSmearing_FPix")),
212 theThresholdSmearing_BPix(conf.getParameter<double>(
"ThresholdSmearing_BPix")),
213 theThresholdSmearing_BPix_L1(conf.exists(
"ThresholdSmearing_BPix_L1")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L1"):theThresholdSmearing_BPix),
214 theThresholdSmearing_BPix_L2(conf.exists(
"ThresholdSmearing_BPix_L2")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L2"):theThresholdSmearing_BPix),
217 electronsPerVCAL(conf.getParameter<double>(
"ElectronsPerVcal")),
218 electronsPerVCAL_Offset(conf.getParameter<double>(
"ElectronsPerVcal_Offset")),
219 electronsPerVCAL_L1(conf.exists(
"ElectronsPerVcal_L1")?conf.getParameter<double>(
"ElectronsPerVcal_L1"):electronsPerVCAL),
220 electronsPerVCAL_L1_Offset(conf.exists(
"ElectronsPerVcal_L1_Offset")?conf.getParameter<double>(
"ElectronsPerVcal_L1_Offset"):electronsPerVCAL_Offset),
224 theTofLowerCut(conf.getParameter<double>(
"TofLowerCut")),
225 theTofUpperCut(conf.getParameter<double>(
"TofUpperCut")),
228 tanLorentzAnglePerTesla_FPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_FPix")),
229 tanLorentzAnglePerTesla_BPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_BPix")),
232 FPix_p0(conf.getParameter<double>(
"FPix_SignalResponse_p0")),
233 FPix_p1(conf.getParameter<double>(
"FPix_SignalResponse_p1")),
234 FPix_p2(conf.getParameter<double>(
"FPix_SignalResponse_p2")),
235 FPix_p3(conf.getParameter<double>(
"FPix_SignalResponse_p3")),
237 BPix_p0(conf.getParameter<double>(
"BPix_SignalResponse_p0")),
238 BPix_p1(conf.getParameter<double>(
"BPix_SignalResponse_p1")),
239 BPix_p2(conf.getParameter<double>(
"BPix_SignalResponse_p2")),
240 BPix_p3(conf.getParameter<double>(
"BPix_SignalResponse_p3")),
243 addNoise(conf.getParameter<
bool>(
"AddNoise")),
247 addChargeVCALSmearing(conf.getParameter<
bool>(
"ChargeVCALSmearing")),
250 addNoisyPixels(conf.getParameter<
bool>(
"AddNoisyPixels")),
253 fluctuateCharge(conf.getUntrackedParameter<
bool>(
"FluctuateCharge",
true)),
259 addThresholdSmearing(conf.getParameter<
bool>(
"AddThresholdSmearing")),
262 doMissCalibrate(conf.getParameter<
bool>(
"MissCalibrate")),
263 theGainSmearing(conf.getParameter<double>(
"GainSmearing")),
264 theOffsetSmearing(conf.getParameter<double>(
"OffsetSmearing")),
267 AddPixelAging(conf.getParameter<
bool>(
"DoPixelAging")),
275 tMax(conf.getParameter<double>(
"deltaProductionCut")),
282 pixelAging_(conf,AddPixelAging,NumberOfBarrelLayers,NumberOfEndcapDisks)
284 LogInfo (
"PixelDigitizer ") <<
"SiPixelDigitizerAlgorithm constructed" 285 <<
"Configuration parameters:" 286 <<
"Threshold/Gain = " 287 <<
"threshold in electron FPix = " 289 <<
"threshold in electron BPix = " 291 <<
"threshold in electron BPix Layer1 = " 293 <<
"threshold in electron BPix Layer2 = " 296 <<
" The delta cut-off is set to " <<
tMax 301 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
308 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
calmap;
311 <<
" miss-calibrate the pixel amplitude ";
313 const bool ReadCalParameters =
false;
314 if(ReadCalParameters) {
317 char filename[80] =
"phCalibrationFit_C0.dat";
321 cout <<
" File not found " << endl;
324 cout <<
" file opened : " << filename << endl;
327 for (
int i = 0;
i < 3;
i++) {
328 in_file.getline(line, 500,
'\n');
332 cout <<
" test map" << endl;
338 for(
int i=0;
i<(52*80);
i++) {
339 in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid >> rowid;
341 cerr <<
"Cannot read data file" << endl;
344 if( in_file.eof() != 0 ) {
345 cerr << in_file.eof() <<
" " << in_file.gcount() <<
" " 346 << in_file.fail() <<
" " << in_file.good() <<
" end of file " 362 calmap.insert(std::pair<int,CalParameters>(chan,onePix));
366 if(rowid!=p.first)
cout<<
" wrong channel row "<<rowid<<
" "<<p.first<<endl;
367 if(colid!=p.second)
cout<<
" wrong channel col "<<colid<<
" "<<p.second<<endl;
371 cout <<
" map size " << calmap.size() <<
" max "<<calmap.max_size() <<
" " 372 <<calmap.empty()<< endl;
395 LogDebug (
"PixelDigitizer")<<
"SiPixelDigitizerAlgorithm deleted";
404 if (AddPixelInefficiency){
406 conf.
exists(
"thePixelColEfficiency_BPix1") && conf.
exists(
"thePixelColEfficiency_BPix2") && conf.
exists(
"thePixelColEfficiency_BPix3") &&
407 conf.
exists(
"thePixelColEfficiency_FPix1") && conf.
exists(
"thePixelColEfficiency_FPix2") &&
408 conf.
exists(
"thePixelEfficiency_BPix1") && conf.
exists(
"thePixelEfficiency_BPix2") && conf.
exists(
"thePixelEfficiency_BPix3") &&
409 conf.
exists(
"thePixelEfficiency_FPix1") && conf.
exists(
"thePixelEfficiency_FPix2") &&
410 conf.
exists(
"thePixelChipEfficiency_BPix1") && conf.
exists(
"thePixelChipEfficiency_BPix2") && conf.
exists(
"thePixelChipEfficiency_BPix3") &&
411 conf.
exists(
"thePixelChipEfficiency_FPix1") && conf.
exists(
"thePixelChipEfficiency_FPix2");
412 if (NumberOfBarrelLayers==3) FromConfig = FromConfig && conf.
exists(
"theLadderEfficiency_BPix1") && conf.
exists(
"theLadderEfficiency_BPix2") && conf.
exists(
"theLadderEfficiency_BPix3") &&
413 conf.
exists(
"theModuleEfficiency_BPix1") && conf.
exists(
"theModuleEfficiency_BPix2") && conf.
exists(
"theModuleEfficiency_BPix3") &&
414 conf.
exists(
"thePUEfficiency_BPix1") && conf.
exists(
"thePUEfficiency_BPix2") && conf.
exists(
"thePUEfficiency_BPix3") &&
415 conf.
exists(
"theInnerEfficiency_FPix1") && conf.
exists(
"theInnerEfficiency_FPix2") &&
416 conf.
exists(
"theOuterEfficiency_FPix1") && conf.
exists(
"theOuterEfficiency_FPix2") &&
417 conf.
exists(
"thePUEfficiency_FPix_Inner") && conf.
exists(
"thePUEfficiency_FPix_Outer") &&
418 conf.
exists(
"theInstLumiScaleFactor");
419 if (NumberOfBarrelLayers>=4) FromConfig = FromConfig && conf.
exists(
"thePixelColEfficiency_BPix4") &&
420 conf.
exists(
"thePixelEfficiency_BPix4") && conf.
exists(
"thePixelChipEfficiency_BPix4");
421 if (NumberOfEndcapDisks>=3) FromConfig = FromConfig && conf.
exists(
"thePixelColEfficiency_FPix4") &&
422 conf.
exists(
"thePixelEfficiency_FPix3") && conf.
exists(
"thePixelChipEfficiency_FPix3");
424 LogInfo (
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the config file.\n";
425 theInstLumiScaleFactor = conf.
getParameter<
double>(
"theInstLumiScaleFactor");
427 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix1");
428 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix2");
429 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix3");
430 if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix4");}
433 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix1");
434 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix2");
435 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix3");
436 if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix4");}
439 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix1");
440 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix2");
441 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix3");
442 if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix4");}
444 if (NumberOfBarrelLayers==3){
446 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix1");
447 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix2");
448 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix3");
449 if ( ((theLadderEfficiency_BPix[0].
size()!=20) || (theLadderEfficiency_BPix[1].
size()!=32) ||
450 (theLadderEfficiency_BPix[2].
size()!=44)) && (NumberOfBarrelLayers==3) )
451 throw cms::Exception(
"Configuration") <<
"Wrong ladder number in efficiency config!";
454 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix1");
455 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix2");
456 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix3");
457 if ( ((theModuleEfficiency_BPix[0].
size()!=4) || (theModuleEfficiency_BPix[1].
size()!=4) ||
458 (theModuleEfficiency_BPix[2].
size()!=4)) && (NumberOfBarrelLayers==3) )
459 throw cms::Exception(
"Configuration") <<
"Wrong module number in efficiency config!";
461 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix1"));
462 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix2"));
463 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix3"));
464 if ( ((thePUEfficiency[0].
empty()) || (thePUEfficiency[1].
empty()) ||
465 (thePUEfficiency[2].
empty())) && (NumberOfBarrelLayers==3) )
466 throw cms::Exception(
"Configuration") <<
"At least one PU efficiency (BPix) number is needed in efficiency config!";
469 if (NumberOfBarrelLayers>=5){
470 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
473 thePixelColEfficiency[j-1]=0.999;
474 thePixelEfficiency[j-1]=0.999;
475 thePixelChipEfficiency[j-1]=0.999;
480 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix1");
481 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix2");
482 if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix3");}
484 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix1");
485 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix2");
486 if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix3");}
488 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix1");
489 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix2");
490 if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix3");}
492 if (NumberOfEndcapDisks>=4){
493 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
496 thePixelColEfficiency[j-1]=0.999;
497 thePixelEfficiency[j-1]=0.999;
498 thePixelChipEfficiency[j-1]=0.999;
502 if (NumberOfBarrelLayers==3){
504 theInnerEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theInnerEfficiency_FPix1");
505 theInnerEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theInnerEfficiency_FPix2");
507 theOuterEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theOuterEfficiency_FPix1");
508 theOuterEfficiency_FPix[i++] = conf.
getParameter<
double>(
"theOuterEfficiency_FPix2");
509 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Inner"));
510 thePUEfficiency.push_back(conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Outer"));
511 if ( ((thePUEfficiency[3].
empty()) || (thePUEfficiency[4].
empty())) && (NumberOfEndcapDisks==2) )
512 throw cms::Exception(
"Configuration") <<
"At least one (FPix) PU efficiency number is needed in efficiency config!";
513 pu_scale.resize(thePUEfficiency.size());
516 else LogInfo (
"PixelDigitizer ") <<
"The PixelDigitizer inefficiency configuration is read from the database.\n";
534 const std::map<uint32_t, double>& PixelGeomFactorsDBIn = SiPixelDynamicInefficiency->
getPixelGeomFactors();
535 const std::map<uint32_t, double>& ColGeomFactorsDB = SiPixelDynamicInefficiency->
getColGeomFactors();
536 const std::map<uint32_t, double>& ChipGeomFactorsDB = SiPixelDynamicInefficiency->
getChipGeomFactors();
537 const std::map<uint32_t, std::vector<double> >& PUFactors = SiPixelDynamicInefficiency->
getPUFactors();
538 std::vector<uint32_t > DetIdmasks = SiPixelDynamicInefficiency->
getDetIdmasks();
541 for(
const auto& it_module : geom->
detUnits()) {
542 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
543 const DetId detid = it_module->geographicalId();
544 uint32_t rawid = detid.
rawId();
545 PixelGeomFactors[rawid] = 1;
546 ColGeomFactors[rawid] = 1;
547 ChipGeomFactors[rawid] = 1;
548 PixelGeomFactorsROCStdPixels[rawid] = std::vector<double>(16,1);
549 PixelGeomFactorsROCBigPixels[rawid] = std::vector<double>(16,1);
553 std::map<uint32_t, double> PixelGeomFactorsDB;
557 for (
auto db_factor : PixelGeomFactorsDBIn){
560 unsigned int rocMask = rocIdMaskBits <<
shift;
561 unsigned int rocId = (((db_factor.first) & rocMask) >>
shift);
564 unsigned int rawid = db_factor.first & (~rocMask);
569 double factor = db_factor.second;
570 double badFraction = 1 - factor;
571 double bigPixelFraction =
static_cast<double> (nBigPixelsInROC)/nPixelsInROC;
572 double stdPixelFraction = 1. - bigPixelFraction;
574 double badFractionBig =
std::min(bigPixelFraction, badFraction);
575 double badFractionStd =
std::max(0., badFraction - badFractionBig);
576 double badFractionBigReNormalized = badFractionBig/bigPixelFraction;
577 double badFractionStdReNormalized = badFractionStd/stdPixelFraction;
578 PixelGeomFactorsROCStdPixels[rawid][rocId] *= (1. - badFractionStdReNormalized);
579 PixelGeomFactorsROCBigPixels[rawid][rocId] *= (1. - badFractionBigReNormalized);
582 PixelGeomFactorsDB[db_factor.first] = db_factor.second;
587 PixelGeomFactorsDB = PixelGeomFactorsDBIn;
591 for(
const auto& it_module : geom->
detUnits()) {
592 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
593 const DetId detid = it_module->geographicalId();
594 uint32_t rawid = detid.
rawId();
595 for (
auto db_factor : PixelGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) PixelGeomFactors[rawid] *= db_factor.second;
596 for (
auto db_factor : ColGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) ColGeomFactors[rawid] *= db_factor.second;
597 for (
auto db_factor : ChipGeomFactorsDB)
if (
matches(detid,
DetId(db_factor.first), DetIdmasks)) ChipGeomFactors[rawid] *= db_factor.second;
603 for (
auto factor : PUFactors) {
605 for(
const auto& it_module : geom->
detUnits()) {
606 if( dynamic_cast<PixelGeomDetUnit const*>(it_module)==
nullptr)
continue;
607 const DetId detid = it_module->geographicalId();
608 if (!
matches(detid, db_id, DetIdmasks))
continue;
609 if (iPU.count(detid.
rawId())) {
610 throw cms::Exception(
"Database")<<
"Multiple db_ids match to same module in SiPixelDynamicInefficiency DB Object";
615 thePUEfficiency.push_back(factor.second);
618 pu_scale.resize(thePUEfficiency.size());
623 for (
size_t i=0;
i<DetIdmasks.size(); ++
i) {
640 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix1");
641 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix2");
642 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix3");
643 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix4");
646 if (NumberOfBarrelLayers>=5){
647 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
650 thePixelPseudoRadDamage[j-1]=0.;
655 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix1");
656 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix2");
657 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix3");
660 if (NumberOfEndcapDisks>=4){
661 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
664 thePixelPseudoRadDamage[j-1]=0.;
674 std::vector<PSimHit>::const_iterator inputEnd,
675 const size_t inputBeginGlobalIndex,
676 const unsigned int tofBin,
680 CLHEP::HepRandomEngine* engine) {
685 size_t simHitGlobalIndex=inputBeginGlobalIndex;
686 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
688 if((*ssbegin).detUnitId() != detId) {
694 << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" " 695 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" " 696 << (*ssbegin).trackId() <<
" " << (*ssbegin).processType() <<
" " 697 << (*ssbegin).detUnitId()
698 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint() ;
702 std::vector<EnergyDepositUnit> ionization_points;
703 std::vector<SignalPoint> collection_points;
710 drift(*ssbegin, pixdet, bfield, tTopo, ionization_points, collection_points);
712 induce_signal(inputBegin, inputEnd, *ssbegin, simHitGlobalIndex, tofBin, pixdet, collection_points);
728 std::vector<int>::const_iterator
pu;
729 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
731 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++
pu) {
738 if (pu0!=bunchCrossing.end()) {
741 double instlumi_pow=1.;
745 instlumi_pow*=instlumi;
760 for(
unsigned int i=0;
i<ps.size();
i++)
761 if (ps[
i].getBunchCrossing() == 0)
767 double instlumi_pow=1.;
771 instlumi_pow*=instlumi;
784 for(
const auto& det: signalMap) {
785 auto& theSignal =
_signal[det.first];
786 for(
const auto&
chan: det.second) {
794 std::vector<PixelDigi>& digis,
795 std::vector<PixelDigiSimLink>& simlinks,
797 CLHEP::HepRandomEngine* engine) {
811 float thePixelThresholdInE = 0.;
815 int lay = tTopo->
layer(detID);
844 else {
throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;}
851 int numRows = topol->
nrows();
855 <<
" PixelDigitizer " 856 << numColumns <<
" " << numRows <<
" " << moduleThickness;
877 make_digis(thePixelThresholdInE, detID, pixdet, digis, simlinks, tTopo);
880 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
891 const float SegmentLength = 0.0010;
898 float length = direction.
mag();
900 int NumberOfSegments =
int ( length / SegmentLength);
901 if(NumberOfSegments < 1) NumberOfSegments = 1;
905 <<
" enter primary_ionzation " << NumberOfSegments
913 float* elossVector =
new float[NumberOfSegments];
920 float momentum = hit.
pabs();
923 elossVector, engine);
926 ionization_points.resize( NumberOfSegments);
929 for (
int i = 0;
i != NumberOfSegments;
i++) {
932 float((
i+0.5)/NumberOfSegments) * direction;
940 ionization_points[
i] = edu;
944 <<
i <<
" " << ionization_points[
i].x() <<
" " 945 << ionization_points[
i].y() <<
" " 946 << ionization_points[
i].z() <<
" " 947 << ionization_points[
i].energy();
952 delete[] elossVector;
960 float eloss,
float length,
961 int NumberOfSegs,
float elossVector[],
962 CLHEP::HepRandomEngine* engine)
const {
969 double particleMass = 139.6;
972 if(pid==11) particleMass = 0.511;
973 else if(pid==13) particleMass = 105.7;
974 else if(pid==321) particleMass = 493.7;
975 else if(pid==2212) particleMass = 938.3;
978 float segmentLength = length/NumberOfSegs;
983 double segmentEloss = (1000.*eloss)/NumberOfSegs;
984 for (
int i=0;
i<NumberOfSegs;
i++) {
990 double deltaCutoff =
tMax;
991 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
992 particleMass, deltaCutoff,
993 double(segmentLength*10.),
994 segmentEloss, engine )/1000.;
1001 float ratio = eloss/sum;
1003 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
1005 float averageEloss = eloss/NumberOfSegs;
1006 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
1018 const std::vector<EnergyDepositUnit>& ionization_points,
1019 std::vector<SignalPoint>& collection_points)
const {
1022 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
1025 collection_points.resize(ionization_points.size());
1028 if(driftDir.
z() ==0.) {
1029 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
1037 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
1040 TanLorenzAngleX = driftDir.
x();
1041 TanLorenzAngleY = driftDir.
y();
1042 dir_z = driftDir.
z();
1043 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
1044 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
1047 TanLorenzAngleX = driftDir.
x();
1048 TanLorenzAngleY = 0.;
1049 dir_z = driftDir.
z();
1050 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
1051 CosLorenzAngleY = 1.;
1057 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" " 1058 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" " 1059 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
1064 float DriftDistance;
1068 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
1070 float SegX, SegY, SegZ;
1071 SegX = ionization_points[
i].
x();
1072 SegY = ionization_points[
i].y();
1073 SegZ = ionization_points[
i].z();
1078 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
1088 if( DriftDistance < 0.) {
1090 }
else if( DriftDistance > moduleThickness )
1091 DriftDistance = moduleThickness;
1094 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
1095 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
1098 float CloudCenterX = SegX + XDriftDueToMagField;
1099 float CloudCenterY = SegY + YDriftDueToMagField;
1102 DriftLength =
sqrt( DriftDistance*DriftDistance +
1103 XDriftDueToMagField*XDriftDueToMagField +
1104 YDriftDueToMagField*YDriftDueToMagField );
1110 Sigma_x = Sigma / CosLorenzAngleX ;
1111 Sigma_y = Sigma / CosLorenzAngleY ;
1114 float energyOnCollector = ionization_points[
i].energy();
1119 energyOnCollector *=
exp( -1*kValue*DriftDistance/moduleThickness );
1124 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
1125 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
1128 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
1131 collection_points[
i] = (sp);
1140 std::vector<PSimHit>::const_iterator inputEnd,
1142 const size_t hitIndex,
1143 const unsigned int tofBin,
1145 const std::vector<SignalPoint>& collection_points) {
1156 <<
" enter induce_signal, " 1157 << topol->
pitch().first <<
" " << topol->
pitch().second;
1161 typedef std::map< int, float, std::less<int> > hit_map_type;
1162 hit_map_type hit_signal;
1165 std::map<int, float, std::less<int> >
x,
y;
1170 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
1171 i != collection_points.end(); ++
i) {
1173 float CloudCenterX =
i->position().x();
1174 float CloudCenterY =
i->position().y();
1177 float Charge =
i->amplitude();
1188 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" " 1189 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
1212 int IPixRightUpX =
int( floor( mp.
x()));
1213 int IPixRightUpY =
int( floor( mp.
y()));
1216 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" " 1217 << mp.
x() <<
" " << mp.
y() <<
" " 1218 << IPixRightUpX <<
" " << IPixRightUpY ;
1223 int IPixLeftDownX =
int( floor( mp.
x()));
1224 int IPixLeftDownY =
int( floor( mp.
y()));
1227 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" " 1228 << mp.
x() <<
" " << mp.
y() <<
" " 1229 << IPixLeftDownX <<
" " << IPixLeftDownY ;
1233 int numColumns = topol->
ncolumns();
1234 int numRows = topol->
nrows();
1236 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
1237 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
1238 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
1239 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
1246 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1247 float xUB, xLB, UpperBound, LowerBound;
1252 if(ix == 0 || SigmaX==0. )
1257 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
1260 if(ix == numRows-1 || SigmaX==0. )
1265 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
1268 float TotalIntegrationRange = UpperBound - LowerBound;
1269 x[ix] = TotalIntegrationRange;
1277 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1278 float yUB, yLB, UpperBound, LowerBound;
1280 if(iy == 0 || SigmaY==0.)
1285 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
1288 if(iy == numColumns-1 || SigmaY==0. )
1293 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
1296 float TotalIntegrationRange = UpperBound - LowerBound;
1297 y[iy] = TotalIntegrationRange;
1304 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1305 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1307 float ChargeFraction = Charge*x[ix]*y[iy];
1309 if( ChargeFraction > 0. ) {
1312 hit_signal[
chan] += ChargeFraction;
1322 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" " 1323 << chan <<
" " << ChargeFraction<<
" " 1324 << mp.
x() <<
" " << mp.
y() <<
" " 1325 << lp.
x() <<
" " << lp.
y() <<
" " 1337 bool reweighted =
false;
1347 for ( hit_map_type::const_iterator im = hit_signal.begin();
1348 im != hit_signal.end(); ++im) {
1349 int chan = (*im).first;
1350 theSignal[
chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1355 <<
" pixel " << ip.first <<
" " << ip.second <<
" " 1369 std::vector<PixelDigi>& digis,
1370 std::vector<PixelDigiSimLink>& simlinks,
1374 LogDebug (
"Pixel Digitizer") <<
" make digis "<<
" " 1379 <<
" List pixels passing threshold ";
1384 signalMaps::const_iterator it =
_signal.find(detID);
1393 std::map<TrackEventId, float> simi;
1397 float signalInElectrons = (*i).second ;
1404 if( signalInElectrons >= thePixelThresholdInE && signalInElectrons > 0.) {
1406 int chan = (*i).first;
1413 int col = ip.second;
1414 adc =
int(
missCalibrate(detID, tTopo, pixdet, col, row, signalInElectrons));
1430 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1431 <<
" " << adc << ip.first <<
" " << ip.second ;
1435 digis.emplace_back(ip.first, ip.second, adc);
1440 for(
const auto&
info: (*i).second.hitInfos()) {
1443 simi[std::make_pair(
info.trackId(),
info.eventId().rawId())] += (*i).second.individualampl()[il];
1448 for(
const auto&
info: (*i).second.hitInfos()) {
1450 auto found = simi.find(std::make_pair(
info.trackId(),
info.eventId().rawId()));
1451 if(
found == simi.end())
1454 float sum_samechannel =
found->second;
1455 float fraction=sum_samechannel/(*i).second;
1456 if(fraction>1.
f) fraction=1.f;
1472 float thePixelThreshold,
1473 CLHEP::HepRandomEngine* engine) {
1484 float theSmearedChargeRMS = 0.0;
1490 if((*i).second < 3000)
1492 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1493 }
else if((*i).second < 6000){
1494 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1496 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1500 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1504 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1505 (*i).second.set(0);}
1507 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1517 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1518 (*i).second.set(0);}
1530 int numColumns = topol->
ncolumns();
1531 int numRows = topol->
nrows();
1535 int numberOfPixels = (numRows * numColumns);
1536 std::map<int,float, std::less<int> > otherPixels;
1537 std::map<int,float, std::less<int> >::iterator mapI;
1547 <<
" Add noisy pixels " << numRows <<
" " 1550 << otherPixels.size() ;
1554 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1555 int iy = ((*mapI).first) / numRows;
1556 int ix = ((*mapI).first) - (iy*numRows);
1559 if( iy < 0 || iy > (numColumns-1) )
1560 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1561 if( ix < 0 || ix > (numRows-1) )
1562 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1568 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1569 <<
" " << ix <<
" " << iy <<
" " <<
chan ;
1572 if(theSignal[chan] == 0){
1574 int noise=
int( (*mapI).second );
1587 CLHEP::HepRandomEngine* engine) {
1592 int numColumns = topol->
ncolumns();
1593 int numRows = topol->
nrows();
1597 double pixelEfficiency = 1.0;
1598 double columnEfficiency = 1.0;
1599 double chipEfficiency = 1.0;
1600 std::vector<double> pixelEfficiencyROCStdPixels(16,1);
1601 std::vector<double> pixelEfficiencyROCBigPixels(16,1);
1607 int layerIndex=tTopo->
layer(detID);
1614 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1615 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1619 if (module<=4) module=5-module;
1629 unsigned int panelIndex=tTopo->
pxfPanel(detID);
1630 unsigned int moduleIndex=tTopo->
pxfModule(detID);
1640 if(numColumns>260 || numRows>160) {
1641 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1642 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1645 if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) {
1653 pixelEfficiency = 0.999;
1654 columnEfficiency = 0.999;
1655 chipEfficiency = 0.999;
1670 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" " 1671 << columnEfficiency <<
" " << chipEfficiency;
1676 std::unique_ptr<PixelIndices> pIndexConverter(
new PixelIndices(numColumns,numRows));
1681 std::map<int, int, std::less<int> >chips,
columns, pixelStd, pixelBig;
1682 std::map<int, int, std::less<int> >::iterator iter;
1688 int chan =
i->first;
1691 int col = ip.second;
1693 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1694 int dColInChip = pIndexConverter->DColumn(colROC);
1696 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1699 columns[dColInDet]++;
1702 pixelBig[chipIndex]++;
1704 pixelStd[chipIndex]++;
1709 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1711 float rand = CLHEP::RandFlat::shoot(engine);
1712 if( rand > chipEfficiency ) chips[iter->first]=0;
1716 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1718 float rand = CLHEP::RandFlat::shoot(engine);
1719 if( rand > columnEfficiency ) columns[iter->first]=0;
1724 for ( iter = pixelStd.begin(); iter != pixelStd.end() ; iter++ ) {
1725 float rand = CLHEP::RandFlat::shoot(engine);
1726 if( rand > pixelEfficiencyROCStdPixels[iter->first]) pixelStd[iter->first] = 0;
1729 for ( iter = pixelBig.begin(); iter != pixelBig.end() ; iter++ ) {
1730 float rand = CLHEP::RandFlat::shoot(engine);
1731 if( rand > pixelEfficiencyROCBigPixels[iter->first]) pixelBig[iter->first] = 0;
1742 int col = ip.second;
1744 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1745 int dColInChip = pIndexConverter->DColumn(colROC);
1747 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1750 float rand = CLHEP::RandFlat::shoot(engine);
1751 if( chips[chipIndex]==0 || columns[dColInDet]==0
1752 || rand>pixelEfficiency
1753 || (pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0)
1754 || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)) {
1759 if((pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0)
1760 || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)) {
1780 float pseudoRadDamage = 0.0f;
1785 int layerIndex=tTopo->
layer(detID);
1803 pseudoRadDamage = 0.f;
1809 return pseudoRadDamage;
1811 LogDebug (
"Pixel Digitizer") <<
" enter pixel_aging " << pseudoRadDamage;
1826 const float signalInElectrons)
const {
1853 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1867 newAmp = p3 + p2 * tanh(p0*signal - p1);
1912 const DetId& detId)
const {
1949 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1954 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1957 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1964 alpha2 = lorentzAngle * lorentzAngle;
1966 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1967 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1968 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1975 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is " 1976 << theDriftDirection ;
1979 return theDriftDirection;
1994 int col = ip.second;
2011 Parameters::const_iterator itDeadModules=
DeadModules.begin();
2014 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
2015 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
2016 if(detid == Dead_detID){
2029 if(Module==
"whole"){
2038 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
2042 if( Module==
"tbmB" && ip.first<=79){
2057 for (
size_t id=0;
id<disabledModules.size();
id++)
2059 if(detID==disabledModules[
id].DetID){
2061 badmodule = disabledModules[
id];
2081 std::vector<GlobalPixel> badrocpositions (0);
2082 for(
unsigned int j = 0; j < 16; j++){
2086 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
2087 for (IT it = path.begin(); it != path.end(); ++it) {
2092 badrocpositions.push_back(global);
2103 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
2104 if(it->row >= 80 && ip.first >= 80 ){
2105 if((
std::abs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
2106 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
2107 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
2109 else if(it->row < 80 && ip.first < 80 ){
2110 if((
std::abs(ip.second - it->col) < 26) ){
i->second.set(0.);}
2111 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
2112 else if(it->row==39 && it->col-ip.second==26){
i->second.set(0.);}
2122 std::map<
int,
float, std::less<int> >& hit_signal,
2123 const size_t hitIndex,
2124 const unsigned int tofBin,
2128 unsigned short int processType){
2130 int irow_min = topol->
nrows();
2135 float chargeBefore = 0;
2136 float chargeAfter = 0;
2140 for (
std::map<
int,
float, std::less<int> >::const_iterator im = hit_signal.begin(); im != hit_signal.end(); ++im) {
2141 int chan = (*im).first;
2145 hitSignal[
chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
2146 chargeBefore += (*im).second;
2148 if(pixelWithCharge.first < irow_min)
2149 irow_min = pixelWithCharge.first;
2150 if(pixelWithCharge.first > irow_max)
2151 irow_max = pixelWithCharge.first;
2152 if(pixelWithCharge.second < icol_min)
2153 icol_min = pixelWithCharge.second;
2154 if(pixelWithCharge.second > icol_max)
2155 icol_max = pixelWithCharge.second;
2160 float trajectoryScaleToPosition = hitEntryPoint.
z()/direction.
z();
2162 if( (hitEntryPoint.
z() > 0 && direction.
z() < 0) || (hitEntryPoint.
z() < 0 && direction.
z() > 0) ){
2163 trajectoryScaleToPosition *= -1;
2166 LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction;
2169 std::pair<int,int> hitPixel = std::pair<int,int>(
int( floor(hitPositionPixel.
x() ) ),
int ( floor(hitPositionPixel.
y() ) ));
2176 std::pair<int,int> entryPixel = std::pair<int,int>(
int( floor(hitEntryPointPixel.
x() ) ),
int ( floor(hitEntryPointPixel.
y() ) ));
2177 std::pair<int,int> exitPixel = std::pair<int,int>(
int( floor(hitExitPointPixel.
x() ) ),
int ( floor(hitExitPointPixel.
y() ) ));
2179 int hitcol_min, hitcol_max, hitrow_min, hitrow_max;
2180 if(entryPixel.first>exitPixel.first){
2181 hitrow_min = exitPixel.first;
2182 hitrow_max = entryPixel.first;
2184 hitrow_min = entryPixel.first;
2185 hitrow_max = exitPixel.first;
2188 if(entryPixel.second>exitPixel.second){
2189 hitcol_min = exitPixel.second;
2190 hitcol_max = entryPixel.second;
2192 hitcol_min = entryPixel.second;
2193 hitcol_max = exitPixel.second;
2204 <<
"HitPosition:" <<
"\n" 2208 <<
"Pixel Pos - X: " << hitPositionPixel.
x() <<
" Y: " << hitPositionPixel.
y() <<
"\n" 2209 <<
"Cart.Cor. - X: " << CMSSWhitPosition.
x() <<
" Y: " << CMSSWhitPosition.
y() <<
"\n" 2210 <<
"Z=0 Pos - X: " << hitPosition.
x() <<
" Y: " << hitPosition.
y() <<
"\n" 2212 <<
"Origin of the template:" <<
"\n" 2213 <<
"Pixel Pos - X: " << originPixel.x() <<
" Y: " << originPixel.y() <<
"\n" 2214 <<
"Cart.Cor. - X: " << origin.
x() <<
" Y: " << origin.
y() <<
"\n" 2216 <<
"Entry/Exit:" <<
"\n" 2220 <<
"Entry - X Pixel: " << hitEntryPointPixel.
x() <<
" Y Pixel: " << hitEntryPointPixel.
y() <<
"\n" 2221 <<
"Exit - X Pixel: " << hitExitPointPixel.
x() <<
" Y Pixel: " << hitExitPointPixel.
y() <<
"\n" 2223 <<
"row min: " << irow_min <<
" col min: " << icol_min <<
"\n";
2226 if(!(irow_min<=hitrow_max && irow_max>=hitrow_min && icol_min<=hitcol_max && icol_max>=hitcol_min)){
2232 float cmToMicrons = 10000.f;
2234 track[0] = (hitPosition.
x() - origin.
x() )*cmToMicrons;
2235 track[1] = (hitPosition.
y() - origin.
y() )*cmToMicrons;
2237 track[3] = direction.x();
2238 track[4] = direction.y();
2239 track[5] = direction.z();
2243 for(
int row = 0; row <
TXSIZE; ++row) {
2245 pixrewgt[row][
col] = 0;
2249 for(
int row = 0; row <
TXSIZE; ++row) {
2257 for(
int row = 0; row <
TXSIZE; ++row) {
2266 std::cout <<
"Cluster before reweighting: " << std::endl;
2287 LogDebug (
"PixelDigitizer ") <<
"Cluster Charge Reweighting did not work properly.";
2293 std::cout <<
"Cluster after reweighting: " << std::endl;
2297 for(
int row = 0; row <
TXSIZE; ++row) {
2300 charge = pixrewgt[row][
col];
2301 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){
2308 if(chargeBefore!=0. && chargeAfter==0.){
2314 std::cout <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter << std::endl;
2315 std::cout <<
"Charge loss: " << (1 - chargeAfter/chargeBefore)*100 <<
" %" << std::endl << std::endl;
2334 int i, j,
k,
l, kclose;
2336 float xsize,
ysize, q50i, q100i, q50r, q10r, q100r, xhit2D, yhit2D, qclust, dist2, dmin2;
2339 int goodWeightsUsed, nearbyWeightsUsed, noWeightsUsed;
2340 float cotalpha, cotbeta;
2357 LogDebug (
"Pixel Digitizer") <<
"Reweighting angle is not good!" << std::endl;
2374 for(i=0; i<
BYM2; ++
i) {
2375 for(j=0; j<
BXM2; ++j) {
2377 xy_rewgt[j][
i] = 0.f;
2386 LogDebug(
"Pixel Digitizer") <<
"No matching template found" << std::endl;
2392 std::cout <<
"Template unirrad: " << std::endl;
2402 if(cluster.num_dimensions() != 2) {
2403 LogWarning (
"Pixel Digitizer") <<
"Cluster is not 2-dimensional. Return." << std::endl;
2406 nclusx = (
int)cluster.shape()[0];
2407 nclusy = (
int)cluster.shape()[1];
2409 LogWarning (
"Pixel Digitizer") <<
"Sizes in x do not match: nclusx=" << nclusx <<
" xdoubleSize=" <<
xdouble.size() <<
" TXSIZE=" <<
TXSIZE <<
". Return." << std::endl;
2413 LogWarning (
"Pixel Digitizer") <<
"Sizes in y do not match. Return." << std::endl;
2421 for(j=0; j<
TXSIZE; ++j) {
2422 xy_clust[j][
i] = 0.f;
2423 denx_clust[j][
i] = 0;
2424 deny_clust[j][
i] = 0;
2425 if(cluster[j][i] > q100i) {
2426 qclust += cluster[j][
i];
2436 std::cout <<
"Template irrad: " << std::endl;
2448 std::vector<int> ytclust;
2449 std::vector<int> xtclust;
2450 std::vector<int> ycclust;
2451 std::vector<int> xcclust;
2454 for(j=0; j<
TXSIZE; ++j) {
2455 if(xy_in[j+1][i+1] > q100i) {
2457 ytclust.push_back(i);
2458 xtclust.push_back(j);
2459 xy_clust[j][
i] = xy_rewgt[j+1][i+1]/xy_in[j+1][i+1];
2460 denx_clust[j][
i] = j;
2461 deny_clust[j][
i] =
i;
2469 for(j=0; j<
TXSIZE; ++j) {
2470 if(xy_rewgt[j+1][i+1] > q10r && xy_clust[j][i] == 0.
f && ntpix>0) {
2472 dmin2 = 10000.f; kclose = 0;
2473 for(k=0; k<ntpix; ++
k) {
2474 dist2=(i-ytclust[
k])*(i-ytclust[k])+0.44444f*(j-xtclust[
k])*(j-xtclust[k]);
2480 xy_clust[j][
i] = xy_rewgt[j+1][i+1]/xy_in[xtclust[kclose]+1][ytclust[kclose]+1];
2481 denx_clust[j][
i] = xtclust[kclose];
2482 deny_clust[j][
i] = ytclust[kclose];
2495 goodWeightsUsed = 0;
2496 nearbyWeightsUsed = 0;
2500 for(j=0; j<
TXSIZE; ++j) {
2501 if(xy_clust[j][i] > 0.
f) {
2502 cluster[j][
i] = xy_clust[j][
i]*clust[denx_clust[j][
i]][deny_clust[j][
i]];
2503 if(cluster[j][i] > q100r) {
2504 qclust += cluster[j][
i];
2506 if(cluster[j][i] > 0) {
2510 if(clust[j][i] > 0.
f) {
2512 ycclust.push_back(i);
2513 xcclust.push_back(j);
2522 for(l=0; l<ncpix; ++
l) {
2523 i=ycclust[
l]; j=xcclust[
l];
2524 dmin2 = 10000.f; kclose = 0;
2525 for(k=0; k<ntpix; ++
k) {
2526 dist2=(i-ytclust[
k])*(i-ytclust[k])+0.44444f*(j-xtclust[
k])*(j-xtclust[k]);
2533 nearbyWeightsUsed++;
2534 cluster[j][
i] *= xy_clust[xtclust[kclose]][ytclust[kclose]];
2535 if(cluster[j][i] > q100r) {
2536 qclust += cluster[j][
i];
2540 cluster[j][
i] = 0.f;
2551 for(
int row = 0; row <
TXSIZE; ++row) {
2563 for(
int row = 0; row <
BXM2; ++row) {
2575 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 *)
const int theAdcFullScaleStack
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