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);
551 double bunchScale=1.0;
556 std::vector<int>::const_iterator pu;
557 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
559 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++pu) {
567 if (pu0!=bunchCrossing.end()) {
568 for (
size_t i=0;
i<5;
i++) {
570 double instlumi_pow=1.;
574 instlumi_pow*=instlumi;
580 for (
int i=0;
i<5;
i++) {
588 std::vector<PixelDigi>& digis,
589 std::vector<PixelDigiSimLink>& simlinks,
591 CLHEP::HepRandomEngine* engine) {
602 int numRows = topol->
nrows();
610 float thePixelThresholdInE = 0.;
642 <<
" PixelDigitizer "
643 << numColumns <<
" " << numRows <<
" " << moduleThickness;
664 make_digis(thePixelThresholdInE, detID, digis, simlinks, tTopo);
667 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
678 const float SegmentLength = 0.0010;
685 float length = direction.
mag();
687 int NumberOfSegments = int ( length / SegmentLength);
688 if(NumberOfSegments < 1) NumberOfSegments = 1;
692 <<
" enter primary_ionzation " << NumberOfSegments
700 float* elossVector =
new float[NumberOfSegments];
707 float momentum = hit.
pabs();
710 elossVector, engine);
713 ionization_points.resize( NumberOfSegments);
716 for (
int i = 0;
i != NumberOfSegments;
i++) {
719 float((
i+0.5)/NumberOfSegments) * direction;
727 ionization_points[
i] = edu;
731 <<
i <<
" " << ionization_points[
i].x() <<
" "
732 << ionization_points[
i].y() <<
" "
733 << ionization_points[
i].z() <<
" "
734 << ionization_points[
i].energy();
739 delete[] elossVector;
747 float eloss,
float length,
748 int NumberOfSegs,
float elossVector[],
749 CLHEP::HepRandomEngine* engine)
const {
756 double particleMass = 139.6;
759 if(pid==11) particleMass = 0.511;
760 else if(pid==13) particleMass = 105.7;
761 else if(pid==321) particleMass = 493.7;
762 else if(pid==2212) particleMass = 938.3;
765 float segmentLength = length/NumberOfSegs;
770 double segmentEloss = (1000.*eloss)/NumberOfSegs;
771 for (
int i=0;
i<NumberOfSegs;
i++) {
777 double deltaCutoff =
tMax;
778 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
779 particleMass, deltaCutoff,
780 double(segmentLength*10.),
781 segmentEloss, engine )/1000.;
788 float ratio = eloss/sum;
790 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
792 float averageEloss = eloss/NumberOfSegs;
793 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
805 const std::vector<EnergyDepositUnit>& ionization_points,
806 std::vector<SignalPoint>& collection_points)
const {
809 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
812 collection_points.resize(ionization_points.size());
815 if(driftDir.
z() ==0.) {
816 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
824 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
827 TanLorenzAngleX = driftDir.
x();
828 TanLorenzAngleY = driftDir.
y();
829 dir_z = driftDir.
z();
830 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
831 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
834 TanLorenzAngleX = driftDir.
x();
835 TanLorenzAngleY = 0.;
836 dir_z = driftDir.
z();
837 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
838 CosLorenzAngleY = 1.;
844 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" "
845 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" "
846 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
855 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
857 float SegX, SegY, SegZ;
858 SegX = ionization_points[
i].
x();
859 SegY = ionization_points[
i].y();
860 SegZ = ionization_points[
i].z();
865 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
875 if( DriftDistance < 0.) {
877 }
else if( DriftDistance > moduleThickness )
878 DriftDistance = moduleThickness;
881 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
882 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
885 float CloudCenterX = SegX + XDriftDueToMagField;
886 float CloudCenterY = SegY + YDriftDueToMagField;
889 DriftLength =
sqrt( DriftDistance*DriftDistance +
890 XDriftDueToMagField*XDriftDueToMagField +
891 YDriftDueToMagField*YDriftDueToMagField );
897 Sigma_x = Sigma / CosLorenzAngleX ;
898 Sigma_y = Sigma / CosLorenzAngleY ;
901 float energyOnCollector = ionization_points[
i].energy();
906 energyOnCollector *=
exp( -1*kValue*DriftDistance/moduleThickness );
911 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
912 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
915 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
918 collection_points[
i] = (sp);
927 const size_t hitIndex,
928 const unsigned int tofBin,
930 const std::vector<SignalPoint>& collection_points) {
941 <<
" enter induce_signal, "
942 << topol->
pitch().first <<
" " << topol->
pitch().second;
946 typedef std::map< int, float, std::less<int> > hit_map_type;
947 hit_map_type hit_signal;
950 std::map<int, float, std::less<int> >
x,
y;
955 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
956 i != collection_points.end(); ++
i) {
958 float CloudCenterX =
i->position().x();
959 float CloudCenterY =
i->position().y();
960 float SigmaX =
i->sigma_x();
961 float SigmaY =
i->sigma_y();
962 float Charge =
i->amplitude();
973 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" "
974 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
997 int IPixRightUpX = int( floor( mp.
x()));
998 int IPixRightUpY = int( floor( mp.
y()));
1001 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" "
1002 << mp.
x() <<
" " << mp.
y() <<
" "
1003 << IPixRightUpX <<
" " << IPixRightUpY ;
1008 int IPixLeftDownX = int( floor( mp.
x()));
1009 int IPixLeftDownY = int( floor( mp.
y()));
1012 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" "
1013 << mp.
x() <<
" " << mp.
y() <<
" "
1014 << IPixLeftDownX <<
" " << IPixLeftDownY ;
1018 int numColumns = topol->
ncolumns();
1019 int numRows = topol->
nrows();
1021 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
1022 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
1023 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
1024 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
1031 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1032 float xUB, xLB, UpperBound, LowerBound;
1037 if(ix == 0 || SigmaX==0. )
1042 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
1045 if(ix == numRows-1 || SigmaX==0. )
1050 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
1053 float TotalIntegrationRange = UpperBound - LowerBound;
1054 x[ix] = TotalIntegrationRange;
1062 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1063 float yUB, yLB, UpperBound, LowerBound;
1065 if(iy == 0 || SigmaY==0.)
1070 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
1073 if(iy == numColumns-1 || SigmaY==0. )
1078 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
1081 float TotalIntegrationRange = UpperBound - LowerBound;
1082 y[iy] = TotalIntegrationRange;
1089 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1090 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1092 float ChargeFraction = Charge*x[ix]*y[iy];
1094 if( ChargeFraction > 0. ) {
1097 hit_signal[chan] += ChargeFraction;
1107 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" "
1108 << chan <<
" " << ChargeFraction<<
" "
1109 << mp.
x() <<
" " << mp.
y() <<
" "
1110 << lp.
x() <<
" " << lp.
y() <<
" "
1140 for ( hit_map_type::const_iterator im = hit_signal.begin();
1141 im != hit_signal.end(); ++im) {
1142 int chan = (*im).first;
1143 theSignal[chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1148 <<
" pixel " << ip.first <<
" " << ip.second <<
" "
1160 std::vector<PixelDigi>& digis,
1161 std::vector<PixelDigiSimLink>& simlinks,
1165 LogDebug (
"Pixel Digitizer") <<
" make digis "<<
" "
1169 <<
" List pixels passing threshold ";
1174 signalMaps::const_iterator it =
_signal.find(detID);
1183 float signalInElectrons = (*i).second ;
1190 if( signalInElectrons >= thePixelThresholdInE) {
1192 int chan = (*i).first;
1199 int col = ip.second;
1200 adc = int(
missCalibrate(detID, col, row, signalInElectrons));
1220 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1221 <<
" " << adc << ip.first <<
" " << ip.second ;
1225 digis.emplace_back(ip.first, ip.second, adc);
1229 if((*i).second.trackIds().size()>0){
1232 for( std::vector<unsigned int>::const_iterator itid = (*i).second.trackIds().begin();
1233 itid != (*i).second.trackIds().end(); ++itid) {
1234 simi[*itid].push_back((*i).second.individualampl()[il]);
1239 for( simlink_map::iterator simiiter=simi.begin();
1240 simiiter!=simi.end();
1243 float sum_samechannel=0;
1244 for (
unsigned int iii=0;iii<(*simiiter).second.size();iii++){
1245 sum_samechannel+=(*simiiter).second[iii];
1247 float fraction=sum_samechannel/(*i).second;
1248 if(fraction>1.) fraction=1.;
1249 simlinks.emplace_back((*i).first, (*simiiter).first, (*i).second.hitIndex(), (*i).second.tofBin(), (*i).second.eventId(), fraction);
1261 float thePixelThreshold,
1262 CLHEP::HepRandomEngine* engine) {
1273 float theSmearedChargeRMS = 0.0;
1279 if((*i).second < 3000)
1281 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1282 }
else if((*i).second < 6000){
1283 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1285 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1289 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1293 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1294 (*i).second.set(0);}
1296 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1306 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1307 (*i).second.set(0);}
1319 int numColumns = topol->
ncolumns();
1320 int numRows = topol->
nrows();
1324 int numberOfPixels = (numRows * numColumns);
1325 std::map<int,float, std::less<int> > otherPixels;
1326 std::map<int,float, std::less<int> >::iterator mapI;
1336 <<
" Add noisy pixels " << numRows <<
" "
1339 << otherPixels.size() ;
1343 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1344 int iy = ((*mapI).first) / numRows;
1345 int ix = ((*mapI).first) - (iy*numRows);
1348 if( iy < 0 || iy > (numColumns-1) )
1349 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1350 if( ix < 0 || ix > (numRows-1) )
1351 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1357 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1358 <<
" " << ix <<
" " << iy <<
" " << chan ;
1361 if(theSignal[chan] == 0){
1363 int noise=int( (*mapI).second );
1364 theSignal[chan] =
Amplitude (noise, -1.);
1376 CLHEP::HepRandomEngine* engine) {
1381 int numColumns = topol->
ncolumns();
1382 int numRows = topol->
nrows();
1385 double pixelEfficiency = 1.0;
1386 double columnEfficiency = 1.0;
1387 double chipEfficiency = 1.0;
1392 int layerIndex=tTopo->
pxbLayer(detID);
1399 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1400 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1404 if (module<=4) module=5-
module;
1411 unsigned int panelIndex=tTopo->
pxfPanel(detID);
1412 unsigned int moduleIndex=tTopo->
pxfModule(detID);
1422 if(numColumns>260 || numRows>160) {
1423 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1424 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1427 if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) {
1436 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" "
1437 << columnEfficiency <<
" " << chipEfficiency;
1442 std::auto_ptr<PixelIndices> pIndexConverter(
new PixelIndices(numColumns,numRows));
1447 std::map<int, int, std::less<int> >chips, columns;
1448 std::map<int, int, std::less<int> >::iterator
iter;
1454 int chan =
i->first;
1457 int col = ip.second;
1459 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1460 int dColInChip = pIndexConverter->DColumn(colROC);
1462 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1465 columns[dColInDet]++;
1469 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1471 float rand = CLHEP::RandFlat::shoot(engine);
1472 if( rand > chipEfficiency ) chips[iter->first]=0;
1476 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1478 float rand = CLHEP::RandFlat::shoot(engine);
1479 if( rand > columnEfficiency ) columns[iter->first]=0;
1489 int col = ip.second;
1491 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1492 int dColInChip = pIndexConverter->DColumn(colROC);
1494 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1497 float rand = CLHEP::RandFlat::shoot(engine);
1498 if( chips[chipIndex]==0 || columns[dColInDet]==0
1499 || rand>pixelEfficiency ) {
1519 float pseudoRadDamage = 0.0;
1524 int layerIndex=tTopo->
pxbLayer(detID);
1544 return pseudoRadDamage;
1546 LogDebug (
"Pixel Digitizer") <<
" enter pixel_aging " << pseudoRadDamage;
1561 const float signalInElectrons)
const {
1599 newAmp = p3 + p2 * tanh(p0*signal - p1);
1644 const DetId& detId)
const {
1682 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1687 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1695 alpha2 = lorentzAngle * lorentzAngle;
1697 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1698 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1699 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1706 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is "
1707 << theDriftDirection ;
1710 return theDriftDirection;
1725 int col = ip.second;
1742 Parameters::const_iterator itDeadModules=
DeadModules.begin();
1745 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
1746 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
1747 if(detid == Dead_detID){
1760 if(Module==
"whole"){
1769 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
1773 if( Module==
"tbmB" && ip.first<=79){
1784 std::vector<SiPixelQuality::disabledModuleType>disabledModules =
SiPixelBadModule_->getBadComponentList();
1788 for (
size_t id=0;
id<disabledModules.size();
id++)
1790 if(detID==disabledModules[
id].DetID){
1792 badmodule = disabledModules[id];
1812 std::vector<GlobalPixel> badrocpositions (0);
1813 for(
unsigned int j = 0;
j < 16;
j++){
1816 std::vector<CablingPathToDetUnit>
path =
map_.
product()->pathToDetUnit(detID);
1817 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
1818 for (IT it = path.begin(); it != path.end(); ++it) {
1823 badrocpositions.push_back(global);
1834 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
1835 if(it->row >= 80 && ip.first >= 80 ){
1836 if((fabs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
1837 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
1838 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
1840 else if(it->row < 80 && ip.first < 80 ){
1841 if((fabs(ip.second - it->col) < 26) ){
i->second.set(0.);}
1842 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
1843 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 *)