52 #include <gsl/gsl_sf_erf.h>
54 #include "CLHEP/Random/RandGaussQ.h"
55 #include "CLHEP/Random/RandFlat.h"
101 using namespace sipixelobjects;
103 #define TP_DEBUG // protect all LogDebug with ifdef. Takes too much CPU
107 if(use_ineff_from_db_){
108 theSiPixelGainCalibrationService_->setESObjects( es );
110 if(use_deadmodule_DB_) {
113 if(use_LorentzAngle_DB_) {
127 makeDigiSimLinks_(conf.getUntrackedParameter<bool>(
"makeDigiSimLinks",
true)),
128 use_ineff_from_db_(conf.getParameter<bool>(
"useDB")),
129 use_module_killing_(conf.getParameter<bool>(
"killModules")),
130 use_deadmodule_DB_(conf.getParameter<bool>(
"DeadModules_DB")),
131 use_LorentzAngle_DB_(conf.getParameter<bool>(
"LorentzAngle_DB")),
137 GeVperElectron(3.61E-09),
140 alpha2Order(conf.getParameter<bool>(
"Alpha2Order")),
146 NumberOfBarrelLayers(conf.exists(
"NumPixelBarrel")?conf.getParameter<int>(
"NumPixelBarrel"):3),
147 NumberOfEndcapDisks(conf.exists(
"NumPixelEndcap")?conf.getParameter<int>(
"NumPixelEndcap"):2),
149 theInstLumiScaleFactor(conf.getParameter<double>(
"theInstLumiScaleFactor")),
150 bunchScaleAt25(conf.getParameter<double>(
"bunchScaleAt25")),
157 theElectronPerADC(conf.getParameter<double>(
"ElectronPerAdc")),
161 theAdcFullScale(conf.getParameter<int>(
"AdcFullScale")),
162 theAdcFullScaleStack(conf.exists(
"AdcFullScaleStack")?conf.getParameter<int>(
"AdcFullScaleStack"):255),
163 theFirstStackLayer(conf.exists(
"FirstStackLayer")?conf.getParameter<int>(
"FirstStackLayer"):5),
167 theNoiseInElectrons(conf.getParameter<double>(
"NoiseInElectrons")),
171 theReadoutNoise(conf.getParameter<double>(
"ReadoutNoiseInElec")),
176 theThresholdInE_FPix(conf.getParameter<double>(
"ThresholdInElectrons_FPix")),
177 theThresholdInE_BPix(conf.getParameter<double>(
"ThresholdInElectrons_BPix")),
178 theThresholdInE_BPix_L1(conf.exists(
"ThresholdInElectrons_BPix_L1")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L1"):theThresholdInE_BPix),
181 theThresholdSmearing_FPix(conf.getParameter<double>(
"ThresholdSmearing_FPix")),
182 theThresholdSmearing_BPix(conf.getParameter<double>(
"ThresholdSmearing_BPix")),
183 theThresholdSmearing_BPix_L1(conf.exists(
"ThresholdSmearing_BPix_L1")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L1"):theThresholdSmearing_BPix),
186 electronsPerVCAL(conf.getParameter<double>(
"ElectronsPerVcal")),
187 electronsPerVCAL_Offset(conf.getParameter<double>(
"ElectronsPerVcal_Offset")),
191 theTofLowerCut(conf.getParameter<double>(
"TofLowerCut")),
192 theTofUpperCut(conf.getParameter<double>(
"TofUpperCut")),
195 tanLorentzAnglePerTesla_FPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_FPix")),
196 tanLorentzAnglePerTesla_BPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_BPix")),
199 FPix_p0(conf.getParameter<double>(
"FPix_SignalResponse_p0")),
200 FPix_p1(conf.getParameter<double>(
"FPix_SignalResponse_p1")),
201 FPix_p2(conf.getParameter<double>(
"FPix_SignalResponse_p2")),
202 FPix_p3(conf.getParameter<double>(
"FPix_SignalResponse_p3")),
204 BPix_p0(conf.getParameter<double>(
"BPix_SignalResponse_p0")),
205 BPix_p1(conf.getParameter<double>(
"BPix_SignalResponse_p1")),
206 BPix_p2(conf.getParameter<double>(
"BPix_SignalResponse_p2")),
207 BPix_p3(conf.getParameter<double>(
"BPix_SignalResponse_p3")),
210 addNoise(conf.getParameter<bool>(
"AddNoise")),
214 addChargeVCALSmearing(conf.getParameter<bool>(
"ChargeVCALSmearing")),
217 addNoisyPixels(conf.getParameter<bool>(
"AddNoisyPixels")),
220 fluctuateCharge(conf.getUntrackedParameter<bool>(
"FluctuateCharge",
true)),
223 AddPixelInefficiency(conf.getParameter<bool>(
"AddPixelInefficiencyFromPython")),
226 addThresholdSmearing(conf.getParameter<bool>(
"AddThresholdSmearing")),
229 doMissCalibrate(conf.getParameter<bool>(
"MissCalibrate")),
230 theGainSmearing(conf.getParameter<double>(
"GainSmearing")),
231 theOffsetSmearing(conf.getParameter<double>(
"OffsetSmearing")),
234 AddPixelAging(conf.getParameter<bool>(
"DoPixelAging")),
239 tMax(conf.getParameter<double>(
"DeltaProductionCut")),
243 calmap(doMissCalibrate ? initCal() : std::
map<int,
CalParameters,std::less<int> >()),
245 pixelEfficiencies_(conf, AddPixelInefficiency,NumberOfBarrelLayers,NumberOfEndcapDisks),
246 pixelAging_(conf,AddPixelAging,NumberOfBarrelLayers,NumberOfEndcapDisks)
248 LogInfo (
"PixelDigitizer ") <<
"SiPixelDigitizerAlgorithm constructed"
249 <<
"Configuration parameters:"
250 <<
"Threshold/Gain = "
251 <<
"threshold in electron FPix = "
253 <<
"threshold in electron BPix = "
255 <<
"threshold in electron BPix Layer1 = "
258 <<
" The delta cut-off is set to " <<
tMax
263 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
270 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
calmap;
273 <<
" miss-calibrate the pixel amplitude ";
275 const bool ReadCalParameters =
false;
276 if(ReadCalParameters) {
279 char filename[80] =
"phCalibrationFit_C0.dat";
283 cout <<
" File not found " << endl;
286 cout <<
" file opened : " << filename << endl;
289 for (
int i = 0;
i < 3;
i++) {
290 in_file.getline(line, 500,
'\n');
294 cout <<
" test map" << endl;
296 float par0,par1,par2,par3;
300 for(
int i=0;
i<(52*80);
i++) {
301 in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid >> rowid;
303 cerr <<
"Cannot read data file" << endl;
306 if( in_file.eof() != 0 ) {
307 cerr << in_file.eof() <<
" " << in_file.gcount() <<
" "
308 << in_file.fail() <<
" " << in_file.good() <<
" end of file "
324 calmap.insert(std::pair<int,CalParameters>(chan,onePix));
328 if(rowid!=p.first)
cout<<
" wrong channel row "<<rowid<<
" "<<p.first<<endl;
329 if(colid!=p.second)
cout<<
" wrong channel col "<<colid<<
" "<<p.second<<endl;
333 cout <<
" map size " << calmap.size() <<
" max "<<calmap.max_size() <<
" "
334 <<calmap.empty()<< endl;
357 LogDebug (
"PixelDigitizer")<<
"SiPixelDigitizerAlgorithm deleted";
365 if (AddPixelInefficiency){
369 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix3");
370 if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix4");}
375 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix3");
376 if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix4");}
381 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix3");
382 if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix4");}
387 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix3");
388 if ( ((theLadderEfficiency_BPix[0].
size()!=20) || (theLadderEfficiency_BPix[1].
size()!=32) ||
389 (theLadderEfficiency_BPix[2].
size()!=44)) && (NumberOfBarrelLayers==3) )
390 throw cms::Exception(
"Configuration") <<
"Wrong ladder number in efficiency config!";
395 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix3");
396 if ( ((theModuleEfficiency_BPix[0].
size()!=4) || (theModuleEfficiency_BPix[1].
size()!=4) ||
397 (theModuleEfficiency_BPix[2].
size()!=4)) && (NumberOfBarrelLayers==3) )
398 throw cms::Exception(
"Configuration") <<
"Wrong module number in efficiency config!";
403 thePUEfficiency[i++] = conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix3");
404 if ( ((thePUEfficiency[0].
size()==0) || (thePUEfficiency[1].
size()==0) ||
405 (thePUEfficiency[2].
size()==0)) && (NumberOfBarrelLayers==3) )
406 throw cms::Exception(
"Configuration") <<
"At least one PU efficiency (BPix) number is needed in efficiency config!";
408 if (NumberOfBarrelLayers>=5){
409 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
412 thePixelColEfficiency[
j-1]=0.999;
413 thePixelEfficiency[
j-1]=0.999;
414 thePixelChipEfficiency[
j-1]=0.999;
419 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix1");
420 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix2");
421 if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix3");}
423 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix1");
424 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix2");
425 if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix3");}
427 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix1");
428 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix2");
429 if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix3");}
431 if (NumberOfEndcapDisks>=4){
432 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
435 thePixelColEfficiency[
j-1]=0.999;
436 thePixelEfficiency[
j-1]=0.999;
437 thePixelChipEfficiency[
j-1]=0.999;
448 thePUEfficiency[i++] = conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Inner");
449 thePUEfficiency[i++] = conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Outer");
450 if ( ((thePUEfficiency[3].
size()==0) || (thePUEfficiency[4].
size()==0)) && (NumberOfEndcapDisks==2) )
451 throw cms::Exception(
"Configuration") <<
"At least one (FPix) PU efficiency number is needed in efficiency config!";
465 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix1");
466 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix2");
467 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix3");
468 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix4");
471 if (NumberOfBarrelLayers>=5){
472 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
475 thePixelPseudoRadDamage[
j-1]=0.;
480 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix1");
481 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix2");
482 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix3");
485 if (NumberOfEndcapDisks>=4){
486 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
489 thePixelPseudoRadDamage[
j-1]=0.;
499 std::vector<PSimHit>::const_iterator inputEnd,
500 const size_t inputBeginGlobalIndex,
501 const unsigned int tofBin,
505 CLHEP::HepRandomEngine* engine) {
510 size_t simHitGlobalIndex=inputBeginGlobalIndex;
511 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
513 if((*ssbegin).detUnitId() != detId) {
519 << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" "
520 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" "
521 << (*ssbegin).trackId() <<
" " << (*ssbegin).processType() <<
" "
522 << (*ssbegin).detUnitId()
523 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint() ;
527 std::vector<EnergyDepositUnit> ionization_points;
528 std::vector<SignalPoint> collection_points;
535 drift(*ssbegin, pixdet, bfield, tTopo, ionization_points, collection_points);
537 induce_signal(*ssbegin, simHitGlobalIndex, tofBin, pixdet, collection_points);
552 double bunchScale=1.0;
557 std::vector<int>::const_iterator pu;
558 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
560 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++pu) {
568 if (pu0!=bunchCrossing.end()) {
569 for (
size_t i=0;
i<5;
i++) {
571 double instlumi_pow=1.;
575 instlumi_pow*=instlumi;
581 for (
int i=0;
i<5;
i++) {
589 std::vector<PixelDigi>& digis,
590 std::vector<PixelDigiSimLink>& simlinks,
592 CLHEP::HepRandomEngine* engine) {
603 int numRows = topol->
nrows();
611 float thePixelThresholdInE = 0.;
643 <<
" PixelDigitizer "
644 << numColumns <<
" " << numRows <<
" " << moduleThickness;
665 make_digis(thePixelThresholdInE, detID, digis, simlinks, tTopo);
668 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
679 const float SegmentLength = 0.0010;
686 float length = direction.
mag();
688 int NumberOfSegments = int ( length / SegmentLength);
689 if(NumberOfSegments < 1) NumberOfSegments = 1;
693 <<
" enter primary_ionzation " << NumberOfSegments
701 float* elossVector =
new float[NumberOfSegments];
708 float momentum = hit.
pabs();
711 elossVector, engine);
714 ionization_points.resize( NumberOfSegments);
717 for (
int i = 0;
i != NumberOfSegments;
i++) {
720 float((
i+0.5)/NumberOfSegments) * direction;
728 ionization_points[
i] = edu;
732 <<
i <<
" " << ionization_points[
i].x() <<
" "
733 << ionization_points[
i].y() <<
" "
734 << ionization_points[
i].z() <<
" "
735 << ionization_points[
i].energy();
740 delete[] elossVector;
748 float eloss,
float length,
749 int NumberOfSegs,
float elossVector[],
750 CLHEP::HepRandomEngine* engine)
const {
757 double particleMass = 139.6;
760 if(pid==11) particleMass = 0.511;
761 else if(pid==13) particleMass = 105.7;
762 else if(pid==321) particleMass = 493.7;
763 else if(pid==2212) particleMass = 938.3;
766 float segmentLength = length/NumberOfSegs;
771 double segmentEloss = (1000.*eloss)/NumberOfSegs;
772 for (
int i=0;
i<NumberOfSegs;
i++) {
778 double deltaCutoff =
tMax;
779 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
780 particleMass, deltaCutoff,
781 double(segmentLength*10.),
782 segmentEloss, engine )/1000.;
789 float ratio = eloss/sum;
791 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
793 float averageEloss = eloss/NumberOfSegs;
794 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
806 const std::vector<EnergyDepositUnit>& ionization_points,
807 std::vector<SignalPoint>& collection_points)
const {
810 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
813 collection_points.resize(ionization_points.size());
816 if(driftDir.
z() ==0.) {
817 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
825 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
828 TanLorenzAngleX = driftDir.
x();
829 TanLorenzAngleY = driftDir.
y();
830 dir_z = driftDir.
z();
831 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
832 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
835 TanLorenzAngleX = driftDir.
x();
836 TanLorenzAngleY = 0.;
837 dir_z = driftDir.
z();
838 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
839 CosLorenzAngleY = 1.;
845 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" "
846 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" "
847 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
856 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
858 float SegX, SegY, SegZ;
859 SegX = ionization_points[
i].
x();
860 SegY = ionization_points[
i].y();
861 SegZ = ionization_points[
i].z();
866 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
876 if( DriftDistance < 0.) {
878 }
else if( DriftDistance > moduleThickness )
879 DriftDistance = moduleThickness;
882 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
883 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
886 float CloudCenterX = SegX + XDriftDueToMagField;
887 float CloudCenterY = SegY + YDriftDueToMagField;
890 DriftLength =
sqrt( DriftDistance*DriftDistance +
891 XDriftDueToMagField*XDriftDueToMagField +
892 YDriftDueToMagField*YDriftDueToMagField );
898 Sigma_x = Sigma / CosLorenzAngleX ;
899 Sigma_y = Sigma / CosLorenzAngleY ;
902 float energyOnCollector = ionization_points[
i].energy();
907 energyOnCollector *=
exp( -1*kValue*DriftDistance/moduleThickness );
912 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
913 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
916 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
919 collection_points[
i] = (sp);
928 const size_t hitIndex,
929 const unsigned int tofBin,
931 const std::vector<SignalPoint>& collection_points) {
942 <<
" enter induce_signal, "
943 << topol->
pitch().first <<
" " << topol->
pitch().second;
947 typedef std::map< int, float, std::less<int> > hit_map_type;
948 hit_map_type hit_signal;
951 std::map<int, float, std::less<int> >
x,
y;
956 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
957 i != collection_points.end(); ++
i) {
959 float CloudCenterX =
i->position().x();
960 float CloudCenterY =
i->position().y();
961 float SigmaX =
i->sigma_x();
962 float SigmaY =
i->sigma_y();
963 float Charge =
i->amplitude();
974 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" "
975 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
998 int IPixRightUpX = int( floor( mp.
x()));
999 int IPixRightUpY = int( floor( mp.
y()));
1002 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" "
1003 << mp.
x() <<
" " << mp.
y() <<
" "
1004 << IPixRightUpX <<
" " << IPixRightUpY ;
1009 int IPixLeftDownX = int( floor( mp.
x()));
1010 int IPixLeftDownY = int( floor( mp.
y()));
1013 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" "
1014 << mp.
x() <<
" " << mp.
y() <<
" "
1015 << IPixLeftDownX <<
" " << IPixLeftDownY ;
1019 int numColumns = topol->
ncolumns();
1020 int numRows = topol->
nrows();
1022 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
1023 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
1024 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
1025 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
1032 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1033 float xUB, xLB, UpperBound, LowerBound;
1038 if(ix == 0 || SigmaX==0. )
1043 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
1046 if(ix == numRows-1 || SigmaX==0. )
1051 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
1054 float TotalIntegrationRange = UpperBound - LowerBound;
1055 x[ix] = TotalIntegrationRange;
1063 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1064 float yUB, yLB, UpperBound, LowerBound;
1066 if(iy == 0 || SigmaY==0.)
1071 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
1074 if(iy == numColumns-1 || SigmaY==0. )
1079 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
1082 float TotalIntegrationRange = UpperBound - LowerBound;
1083 y[iy] = TotalIntegrationRange;
1090 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1091 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1093 float ChargeFraction = Charge*x[ix]*y[iy];
1095 if( ChargeFraction > 0. ) {
1098 hit_signal[chan] += ChargeFraction;
1108 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" "
1109 << chan <<
" " << ChargeFraction<<
" "
1110 << mp.
x() <<
" " << mp.
y() <<
" "
1111 << lp.
x() <<
" " << lp.
y() <<
" "
1141 for ( hit_map_type::const_iterator im = hit_signal.begin();
1142 im != hit_signal.end(); ++im) {
1143 int chan = (*im).first;
1144 theSignal[chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1149 <<
" pixel " << ip.first <<
" " << ip.second <<
" "
1161 std::vector<PixelDigi>& digis,
1162 std::vector<PixelDigiSimLink>& simlinks,
1166 LogDebug (
"Pixel Digitizer") <<
" make digis "<<
" "
1170 <<
" List pixels passing threshold ";
1175 signalMaps::const_iterator it =
_signal.find(detID);
1184 float signalInElectrons = (*i).second ;
1191 if( signalInElectrons >= thePixelThresholdInE) {
1193 int chan = (*i).first;
1200 int col = ip.second;
1201 adc = int(
missCalibrate(detID, col, row, signalInElectrons));
1221 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1222 <<
" " << adc << ip.first <<
" " << ip.second ;
1226 digis.emplace_back(ip.first, ip.second, adc);
1230 if((*i).second.trackIds().size()>0){
1233 for( std::vector<unsigned int>::const_iterator itid = (*i).second.trackIds().begin();
1234 itid != (*i).second.trackIds().end(); ++itid) {
1235 simi[*itid].push_back((*i).second.individualampl()[il]);
1240 for( simlink_map::iterator simiiter=simi.begin();
1241 simiiter!=simi.end();
1244 float sum_samechannel=0;
1245 for (
unsigned int iii=0;iii<(*simiiter).second.size();iii++){
1246 sum_samechannel+=(*simiiter).second[iii];
1248 float fraction=sum_samechannel/(*i).second;
1249 if(fraction>1.) fraction=1.;
1250 simlinks.emplace_back((*i).first, (*simiiter).first, (*i).second.hitIndex(), (*i).second.tofBin(), (*i).second.eventId(), fraction);
1262 float thePixelThreshold,
1263 CLHEP::HepRandomEngine* engine) {
1274 float theSmearedChargeRMS = 0.0;
1280 if((*i).second < 3000)
1282 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1283 }
else if((*i).second < 6000){
1284 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1286 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1290 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1294 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1295 (*i).second.set(0);}
1297 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1307 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1308 (*i).second.set(0);}
1320 int numColumns = topol->
ncolumns();
1321 int numRows = topol->
nrows();
1325 int numberOfPixels = (numRows * numColumns);
1326 std::map<int,float, std::less<int> > otherPixels;
1327 std::map<int,float, std::less<int> >::iterator mapI;
1337 <<
" Add noisy pixels " << numRows <<
" "
1340 << otherPixels.size() ;
1344 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1345 int iy = ((*mapI).first) / numRows;
1346 int ix = ((*mapI).first) - (iy*numRows);
1349 if( iy < 0 || iy > (numColumns-1) )
1350 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1351 if( ix < 0 || ix > (numRows-1) )
1352 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1358 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1359 <<
" " << ix <<
" " << iy <<
" " << chan ;
1362 if(theSignal[chan] == 0){
1364 int noise=int( (*mapI).second );
1365 theSignal[chan] =
Amplitude (noise, -1.);
1377 CLHEP::HepRandomEngine* engine) {
1382 int numColumns = topol->
ncolumns();
1383 int numRows = topol->
nrows();
1386 double pixelEfficiency = 1.0;
1387 double columnEfficiency = 1.0;
1388 double chipEfficiency = 1.0;
1393 int layerIndex=tTopo->
pxbLayer(detID);
1400 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1401 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1405 if (module<=4) module=5-
module;
1412 unsigned int panelIndex=tTopo->
pxfPanel(detID);
1413 unsigned int moduleIndex=tTopo->
pxfModule(detID);
1423 if(numColumns>260 || numRows>160) {
1424 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1425 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1428 if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) {
1437 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" "
1438 << columnEfficiency <<
" " << chipEfficiency;
1443 std::auto_ptr<PixelIndices> pIndexConverter(
new PixelIndices(numColumns,numRows));
1448 std::map<int, int, std::less<int> >chips, columns;
1449 std::map<int, int, std::less<int> >::iterator
iter;
1455 int chan =
i->first;
1458 int col = ip.second;
1460 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1461 int dColInChip = pIndexConverter->DColumn(colROC);
1463 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1466 columns[dColInDet]++;
1470 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1472 float rand = CLHEP::RandFlat::shoot(engine);
1473 if( rand > chipEfficiency ) chips[iter->first]=0;
1477 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1479 float rand = CLHEP::RandFlat::shoot(engine);
1480 if( rand > columnEfficiency ) columns[iter->first]=0;
1490 int col = ip.second;
1492 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1493 int dColInChip = pIndexConverter->DColumn(colROC);
1495 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1498 float rand = CLHEP::RandFlat::shoot(engine);
1499 if( chips[chipIndex]==0 || columns[dColInDet]==0
1500 || rand>pixelEfficiency ) {
1520 float pseudoRadDamage = 0.0;
1525 int layerIndex=tTopo->
pxbLayer(detID);
1545 return pseudoRadDamage;
1547 LogDebug (
"Pixel Digitizer") <<
" enter pixel_aging " << pseudoRadDamage;
1562 const float signalInElectrons)
const {
1600 newAmp = p3 + p2 * tanh(p0*signal - p1);
1645 const DetId& detId)
const {
1683 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1688 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1696 alpha2 = lorentzAngle * lorentzAngle;
1698 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1699 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1700 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1707 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is "
1708 << theDriftDirection ;
1711 return theDriftDirection;
1726 int col = ip.second;
1743 Parameters::const_iterator itDeadModules=
DeadModules.begin();
1746 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
1747 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
1748 if(detid == Dead_detID){
1761 if(Module==
"whole"){
1770 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
1774 if( Module==
"tbmB" && ip.first<=79){
1785 std::vector<SiPixelQuality::disabledModuleType>disabledModules =
SiPixelBadModule_->getBadComponentList();
1789 for (
size_t id=0;
id<disabledModules.size();
id++)
1791 if(detID==disabledModules[
id].DetID){
1793 badmodule = disabledModules[id];
1813 std::vector<GlobalPixel> badrocpositions (0);
1814 for(
unsigned int j = 0;
j < 16;
j++){
1817 std::vector<CablingPathToDetUnit>
path =
map_.
product()->pathToDetUnit(detID);
1818 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
1819 for (IT it = path.begin(); it != path.end(); ++it) {
1824 badrocpositions.push_back(global);
1835 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
1836 if(it->row >= 80 && ip.first >= 80 ){
1837 if((fabs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
1838 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
1839 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
1841 else if(it->row < 80 && ip.first < 80 ){
1842 if((fabs(ip.second - it->col) < 26) ){
i->second.set(0.);}
1843 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
1844 else if(it->row==39 && it->col-ip.second==26){
i->second.set(0.);}
int adc(sample_type sample)
get the ADC sample (12 bits)
void init(const edm::EventSetup &es)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
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_
edm::ESHandle< SiPixelFedCablingMap > map_
const double theThresholdSmearing_FPix
std::map< int, CalParameters, std::less< int > > initCal() const
std::map< unsigned int, std::vector< float >, std::less< unsigned int > > simlink_map
const std::unique_ptr< SiPixelGainCalibrationOfflineSimService > theSiPixelGainCalibrationService_
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
LocalVector DriftDirection(const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const DetId &detId) const
SiPixelDigitizerAlgorithm(const edm::ParameterSet &conf)
virtual int ncolumns() const =0
const std::vector< float > & getMix_TrueInteractions() const
const float tanLorentzAnglePerTesla_FPix
const std::unique_ptr< SiG4UniversalFluctuation > fluctuate
const int theAdcFullScale
PixelEfficiencies(const edm::ParameterSet &conf, bool AddPixelInefficiency, int NumberOfBarrelLayers, int NumberOfEndcapDisks)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
unsigned int pxfDisk(const DetId &id) const
const std::vector< int > & getMix_bunchCrossing() const
float missCalibrate(uint32_t detID, int col, int row, float amp) const
const double theThresholdSmearing_BPix_L1
unsigned int pxbLadder(const DetId &id) const
virtual int nrows() const =0
const float theThresholdInE_FPix
const double theThresholdSmearing_BPix
const Bounds & bounds() const
unsigned int pxbModule(const DetId &id) const
const bool addThresholdSmearing
void module_killing_conf(uint32_t detID)
std::vector< double > thePUEfficiency[20]
const bool fluctuateCharge
float thePixelPseudoRadDamage[20]
~SiPixelDigitizerAlgorithm()
double calcQ(float x) const
const Plane & surface() const
The nominal surface of the GeomDet.
const float GeVperElectron
identify pixel inside single ROC
const bool use_ineff_from_db_
static int pixelToChannel(int row, int col)
global coordinates (row and column in DetUnit, as in PixelDigi)
uint32_t rawId() const
get the raw id
virtual float thickness() const =0
void induce_signal(const PSimHit &hit, const size_t hitIndex, const unsigned int tofBin, const PixelGeomDetUnit *pixdet, const std::vector< SignalPoint > &collection_points)
const bool use_LorentzAngle_DB_
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
Local3DPoint exitPoint() const
Exit point in the local Det frame.
tuple path
else: Piece not in the list, fine.
const std::map< int, CalParameters, std::less< int > > calmap
const Parameters DeadModules
float pixel_aging(const PixelAging &aging, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo) const
double thePixelChipEfficiency[20]
const float theTofUpperCut
const bool use_module_killing_
void module_killing_DB(uint32_t detID)
static int pixelToChannelROC(const int rowROC, const int colROC)
static std::pair< int, int > channelToPixelROC(const int chan)
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
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]
virtual int channel(const LocalPoint &p) const =0
DetId geographicalId() const
The label of this GeomDet.
const int NumberOfEndcapDisks
const int theFirstStackLayer
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
std::vector< double > theModuleEfficiency_BPix[20]
std::vector< LinkConnSpec >::const_iterator IT
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
signal_map_type::iterator signal_map_iterator
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const float theThresholdInE_BPix_L1
edm::ESHandle< SiPixelLorentzAngle > SiPixelLorentzAngle_
unsigned int pxfModule(const DetId &id) const
virtual std::pair< float, float > pitch() const =0
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
void make_digis(float thePixelThresholdInE, uint32_t detID, std::vector< PixelDigi > &digis, std::vector< PixelDigiSimLink > &simlinks, const TrackerTopology *tTopo) const
const PixelEfficiencies pixelEfficiencies_
const double electronsPerVCAL_Offset
edm::ESHandle< SiPixelQuality > SiPixelBadModule_
const double theInstLumiScaleFactor
void primary_ionization(const PSimHit &hit, std::vector< EnergyDepositUnit > &ionization_points, CLHEP::HepRandomEngine *) const
double thePixelColEfficiency[20]
void calculateInstlumiFactor(PileupMixingContent *puInfo)
static std::pair< int, int > channelToPixel(int ch)
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
T const * product() const
const double bunchScaleAt25
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
const float tanLorentzAnglePerTesla_BPix
std::vector< edm::ParameterSet > Parameters
std::vector< double > theLadderEfficiency_BPix[20]
float energyLoss() const
The energy deposit in the PSimHit, in ???.
const float theReadoutNoise
const double electronsPerVCAL
const int & getMix_bunchSpacing() 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
const bool addNoisyPixels
const PixelAging pixelAging_
const PositionType & position() const
const float theElectronPerADC
Local3DPoint entryPoint() const
Entry point in the local Det frame.
tuple size
Write out results.
unsigned int pxfPanel(const DetId &id) const
const bool makeDigiSimLinks_
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
unsigned int detUnitId() const
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
const int NumberOfBarrelLayers
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 *)