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),
166 theNoiseInElectrons(conf.getParameter<double>(
"NoiseInElectrons")),
170 theReadoutNoise(conf.getParameter<double>(
"ReadoutNoiseInElec")),
175 theThresholdInE_FPix(conf.getParameter<double>(
"ThresholdInElectrons_FPix")),
176 theThresholdInE_BPix(conf.getParameter<double>(
"ThresholdInElectrons_BPix")),
177 theThresholdInE_BPix_L1(conf.exists(
"ThresholdInElectrons_BPix_L1")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L1"):theThresholdInE_BPix),
180 theThresholdSmearing_FPix(conf.getParameter<double>(
"ThresholdSmearing_FPix")),
181 theThresholdSmearing_BPix(conf.getParameter<double>(
"ThresholdSmearing_BPix")),
182 theThresholdSmearing_BPix_L1(conf.exists(
"ThresholdSmearing_BPix_L1")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L1"):theThresholdSmearing_BPix),
185 electronsPerVCAL(conf.getParameter<double>(
"ElectronsPerVcal")),
186 electronsPerVCAL_Offset(conf.getParameter<double>(
"ElectronsPerVcal_Offset")),
190 theTofLowerCut(conf.getParameter<double>(
"TofLowerCut")),
191 theTofUpperCut(conf.getParameter<double>(
"TofUpperCut")),
194 tanLorentzAnglePerTesla_FPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_FPix")),
195 tanLorentzAnglePerTesla_BPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_BPix")),
198 FPix_p0(conf.getParameter<double>(
"FPix_SignalResponse_p0")),
199 FPix_p1(conf.getParameter<double>(
"FPix_SignalResponse_p1")),
200 FPix_p2(conf.getParameter<double>(
"FPix_SignalResponse_p2")),
201 FPix_p3(conf.getParameter<double>(
"FPix_SignalResponse_p3")),
203 BPix_p0(conf.getParameter<double>(
"BPix_SignalResponse_p0")),
204 BPix_p1(conf.getParameter<double>(
"BPix_SignalResponse_p1")),
205 BPix_p2(conf.getParameter<double>(
"BPix_SignalResponse_p2")),
206 BPix_p3(conf.getParameter<double>(
"BPix_SignalResponse_p3")),
209 addNoise(conf.getParameter<bool>(
"AddNoise")),
213 addChargeVCALSmearing(conf.getParameter<bool>(
"ChargeVCALSmearing")),
216 addNoisyPixels(conf.getParameter<bool>(
"AddNoisyPixels")),
219 fluctuateCharge(conf.getUntrackedParameter<bool>(
"FluctuateCharge",
true)),
222 AddPixelInefficiency(conf.getParameter<bool>(
"AddPixelInefficiencyFromPython")),
225 addThresholdSmearing(conf.getParameter<bool>(
"AddThresholdSmearing")),
228 doMissCalibrate(conf.getParameter<bool>(
"MissCalibrate")),
229 theGainSmearing(conf.getParameter<double>(
"GainSmearing")),
230 theOffsetSmearing(conf.getParameter<double>(
"OffsetSmearing")),
233 AddPixelAging(conf.getParameter<bool>(
"DoPixelAging")),
238 tMax(conf.getParameter<double>(
"deltaProductionCut")),
242 calmap(doMissCalibrate ? initCal() : std::
map<int,
CalParameters,std::less<int> >()),
244 pixelEfficiencies_(conf, AddPixelInefficiency,NumberOfBarrelLayers,NumberOfEndcapDisks),
245 pixelAging_(conf,AddPixelAging,NumberOfBarrelLayers,NumberOfEndcapDisks)
247 LogInfo (
"PixelDigitizer ") <<
"SiPixelDigitizerAlgorithm constructed"
248 <<
"Configuration parameters:"
249 <<
"Threshold/Gain = "
250 <<
"threshold in electron FPix = "
252 <<
"threshold in electron BPix = "
254 <<
"threshold in electron BPix Layer1 = "
257 <<
" The delta cut-off is set to " <<
tMax
262 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
269 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
calmap;
272 <<
" miss-calibrate the pixel amplitude ";
274 const bool ReadCalParameters =
false;
275 if(ReadCalParameters) {
278 char filename[80] =
"phCalibrationFit_C0.dat";
282 cout <<
" File not found " << endl;
285 cout <<
" file opened : " << filename << endl;
288 for (
int i = 0;
i < 3;
i++) {
289 in_file.getline(line, 500,
'\n');
293 cout <<
" test map" << endl;
295 float par0,par1,par2,par3;
299 for(
int i=0;
i<(52*80);
i++) {
300 in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid >> rowid;
302 cerr <<
"Cannot read data file" << endl;
305 if( in_file.eof() != 0 ) {
306 cerr << in_file.eof() <<
" " << in_file.gcount() <<
" "
307 << in_file.fail() <<
" " << in_file.good() <<
" end of file "
323 calmap.insert(std::pair<int,CalParameters>(chan,onePix));
327 if(rowid!=p.first)
cout<<
" wrong channel row "<<rowid<<
" "<<p.first<<endl;
328 if(colid!=p.second)
cout<<
" wrong channel col "<<colid<<
" "<<p.second<<endl;
332 cout <<
" map size " << calmap.size() <<
" max "<<calmap.max_size() <<
" "
333 <<calmap.empty()<< endl;
356 LogDebug (
"PixelDigitizer")<<
"SiPixelDigitizerAlgorithm deleted";
364 if (AddPixelInefficiency){
368 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix3");
369 if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix4");}
374 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix3");
375 if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix4");}
380 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix3");
381 if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix4");}
386 theLadderEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theLadderEfficiency_BPix3");
387 if ( ((theLadderEfficiency_BPix[0].
size()!=20) || (theLadderEfficiency_BPix[1].
size()!=32) ||
388 (theLadderEfficiency_BPix[2].
size()!=44)) && (NumberOfBarrelLayers==3) )
389 throw cms::Exception(
"Configuration") <<
"Wrong ladder number in efficiency config!";
394 theModuleEfficiency_BPix[i++] = conf.
getParameter<std::vector<double> >(
"theModuleEfficiency_BPix3");
395 if ( ((theModuleEfficiency_BPix[0].
size()!=4) || (theModuleEfficiency_BPix[1].
size()!=4) ||
396 (theModuleEfficiency_BPix[2].
size()!=4)) && (NumberOfBarrelLayers==3) )
397 throw cms::Exception(
"Configuration") <<
"Wrong module number in efficiency config!";
402 thePUEfficiency[i++] = conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix3");
403 if ( ((thePUEfficiency[0].
size()==0) || (thePUEfficiency[1].
size()==0) ||
404 (thePUEfficiency[2].
size()==0)) && (NumberOfBarrelLayers==3) )
405 throw cms::Exception(
"Configuration") <<
"At least one PU efficiency (BPix) number is needed in efficiency config!";
407 if (NumberOfBarrelLayers>=5){
408 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
411 thePixelColEfficiency[
j-1]=0.999;
412 thePixelEfficiency[
j-1]=0.999;
413 thePixelChipEfficiency[
j-1]=0.999;
418 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix1");
419 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix2");
420 if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix3");}
422 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix1");
423 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix2");
424 if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix3");}
426 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix1");
427 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix2");
428 if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix3");}
430 if (NumberOfEndcapDisks>=4){
431 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
434 thePixelColEfficiency[
j-1]=0.999;
435 thePixelEfficiency[
j-1]=0.999;
436 thePixelChipEfficiency[
j-1]=0.999;
447 thePUEfficiency[i++] = conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Inner");
448 thePUEfficiency[i++] = conf.
getParameter<std::vector<double> >(
"thePUEfficiency_FPix_Outer");
449 if ( ((thePUEfficiency[3].
size()==0) || (thePUEfficiency[4].
size()==0)) && (NumberOfEndcapDisks==2) )
450 throw cms::Exception(
"Configuration") <<
"At least one (FPix) PU efficiency number is needed in efficiency config!";
464 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix1");
465 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix2");
466 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix3");
467 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_BPix4");
470 if (NumberOfBarrelLayers>=5){
471 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
474 thePixelPseudoRadDamage[
j-1]=0.;
479 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix1");
480 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix2");
481 thePixelPseudoRadDamage[i++] = conf.
getParameter<
double>(
"thePixelPseudoRadDamage_FPix3");
484 if (NumberOfEndcapDisks>=4){
485 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
488 thePixelPseudoRadDamage[
j-1]=0.;
498 std::vector<PSimHit>::const_iterator inputEnd,
499 const size_t inputBeginGlobalIndex,
500 const unsigned int tofBin,
504 CLHEP::HepRandomEngine* engine) {
509 size_t simHitGlobalIndex=inputBeginGlobalIndex;
510 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
512 if((*ssbegin).detUnitId() != detId) {
518 << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" "
519 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" "
520 << (*ssbegin).trackId() <<
" " << (*ssbegin).processType() <<
" "
521 << (*ssbegin).detUnitId()
522 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint() ;
526 std::vector<EnergyDepositUnit> ionization_points;
527 std::vector<SignalPoint> collection_points;
534 drift(*ssbegin, pixdet, bfield, tTopo, ionization_points, collection_points);
536 induce_signal(*ssbegin, simHitGlobalIndex, tofBin, pixdet, collection_points);
550 double bunchScale=1.0;
555 std::vector<int>::const_iterator pu;
556 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
558 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++pu) {
566 if (pu0!=bunchCrossing.end()) {
567 for (
size_t i=0;
i<5;
i++) {
569 double instlumi_pow=1.;
573 instlumi_pow*=instlumi;
579 for (
int i=0;
i<5;
i++) {
587 std::vector<PixelDigi>& digis,
588 std::vector<PixelDigiSimLink>& simlinks,
590 CLHEP::HepRandomEngine* engine) {
601 int numRows = topol->
nrows();
608 float thePixelThresholdInE = 0.;
612 int lay = tTopo->
layer(detID);
633 else {
throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;}
641 <<
" PixelDigitizer "
642 << numColumns <<
" " << numRows <<
" " << moduleThickness;
663 make_digis(thePixelThresholdInE, detID, pixdet, digis, simlinks, tTopo);
666 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
677 const float SegmentLength = 0.0010;
684 float length = direction.
mag();
686 int NumberOfSegments = int ( length / SegmentLength);
687 if(NumberOfSegments < 1) NumberOfSegments = 1;
691 <<
" enter primary_ionzation " << NumberOfSegments
699 float* elossVector =
new float[NumberOfSegments];
706 float momentum = hit.
pabs();
709 elossVector, engine);
712 ionization_points.resize( NumberOfSegments);
715 for (
int i = 0;
i != NumberOfSegments;
i++) {
718 float((
i+0.5)/NumberOfSegments) * direction;
726 ionization_points[
i] = edu;
730 <<
i <<
" " << ionization_points[
i].x() <<
" "
731 << ionization_points[
i].y() <<
" "
732 << ionization_points[
i].z() <<
" "
733 << ionization_points[
i].energy();
738 delete[] elossVector;
746 float eloss,
float length,
747 int NumberOfSegs,
float elossVector[],
748 CLHEP::HepRandomEngine* engine)
const {
755 double particleMass = 139.6;
758 if(pid==11) particleMass = 0.511;
759 else if(pid==13) particleMass = 105.7;
760 else if(pid==321) particleMass = 493.7;
761 else if(pid==2212) particleMass = 938.3;
764 float segmentLength = length/NumberOfSegs;
769 double segmentEloss = (1000.*eloss)/NumberOfSegs;
770 for (
int i=0;
i<NumberOfSegs;
i++) {
776 double deltaCutoff =
tMax;
777 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
778 particleMass, deltaCutoff,
779 double(segmentLength*10.),
780 segmentEloss, engine )/1000.;
787 float ratio = eloss/sum;
789 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
791 float averageEloss = eloss/NumberOfSegs;
792 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
804 const std::vector<EnergyDepositUnit>& ionization_points,
805 std::vector<SignalPoint>& collection_points)
const {
808 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
811 collection_points.resize(ionization_points.size());
814 if(driftDir.
z() ==0.) {
815 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
823 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
826 TanLorenzAngleX = driftDir.
x();
827 TanLorenzAngleY = driftDir.
y();
828 dir_z = driftDir.
z();
829 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
830 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
833 TanLorenzAngleX = driftDir.
x();
834 TanLorenzAngleY = 0.;
835 dir_z = driftDir.
z();
836 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
837 CosLorenzAngleY = 1.;
843 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" "
844 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" "
845 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
854 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
856 float SegX, SegY, SegZ;
857 SegX = ionization_points[
i].
x();
858 SegY = ionization_points[
i].y();
859 SegZ = ionization_points[
i].z();
864 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
874 if( DriftDistance < 0.) {
876 }
else if( DriftDistance > moduleThickness )
877 DriftDistance = moduleThickness;
880 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
881 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
884 float CloudCenterX = SegX + XDriftDueToMagField;
885 float CloudCenterY = SegY + YDriftDueToMagField;
888 DriftLength =
sqrt( DriftDistance*DriftDistance +
889 XDriftDueToMagField*XDriftDueToMagField +
890 YDriftDueToMagField*YDriftDueToMagField );
896 Sigma_x = Sigma / CosLorenzAngleX ;
897 Sigma_y = Sigma / CosLorenzAngleY ;
900 float energyOnCollector = ionization_points[
i].energy();
905 energyOnCollector *=
exp( -1*kValue*DriftDistance/moduleThickness );
910 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
911 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
914 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
917 collection_points[
i] = (sp);
926 const size_t hitIndex,
927 const unsigned int tofBin,
929 const std::vector<SignalPoint>& collection_points) {
940 <<
" enter induce_signal, "
941 << topol->
pitch().first <<
" " << topol->
pitch().second;
945 typedef std::map< int, float, std::less<int> > hit_map_type;
946 hit_map_type hit_signal;
949 std::map<int, float, std::less<int> >
x,
y;
954 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
955 i != collection_points.end(); ++
i) {
957 float CloudCenterX =
i->position().x();
958 float CloudCenterY =
i->position().y();
959 float SigmaX =
i->sigma_x();
960 float SigmaY =
i->sigma_y();
961 float Charge =
i->amplitude();
972 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" "
973 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
996 int IPixRightUpX = int( floor( mp.
x()));
997 int IPixRightUpY = int( floor( mp.
y()));
1000 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" "
1001 << mp.
x() <<
" " << mp.
y() <<
" "
1002 << IPixRightUpX <<
" " << IPixRightUpY ;
1007 int IPixLeftDownX = int( floor( mp.
x()));
1008 int IPixLeftDownY = int( floor( mp.
y()));
1011 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" "
1012 << mp.
x() <<
" " << mp.
y() <<
" "
1013 << IPixLeftDownX <<
" " << IPixLeftDownY ;
1017 int numColumns = topol->
ncolumns();
1018 int numRows = topol->
nrows();
1020 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
1021 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
1022 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
1023 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
1030 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1031 float xUB, xLB, UpperBound, LowerBound;
1036 if(ix == 0 || SigmaX==0. )
1041 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
1044 if(ix == numRows-1 || SigmaX==0. )
1049 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
1052 float TotalIntegrationRange = UpperBound - LowerBound;
1053 x[ix] = TotalIntegrationRange;
1061 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1062 float yUB, yLB, UpperBound, LowerBound;
1064 if(iy == 0 || SigmaY==0.)
1069 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
1072 if(iy == numColumns-1 || SigmaY==0. )
1077 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
1080 float TotalIntegrationRange = UpperBound - LowerBound;
1081 y[iy] = TotalIntegrationRange;
1088 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1089 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1091 float ChargeFraction = Charge*x[ix]*y[iy];
1093 if( ChargeFraction > 0. ) {
1096 hit_signal[chan] += ChargeFraction;
1106 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" "
1107 << chan <<
" " << ChargeFraction<<
" "
1108 << mp.
x() <<
" " << mp.
y() <<
" "
1109 << lp.
x() <<
" " << lp.
y() <<
" "
1139 for ( hit_map_type::const_iterator im = hit_signal.begin();
1140 im != hit_signal.end(); ++im) {
1141 int chan = (*im).first;
1142 theSignal[chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1147 <<
" 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, pixdet, col, row, signalInElectrons));
1216 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1217 <<
" " << adc << ip.first <<
" " << ip.second ;
1221 digis.emplace_back(ip.first, ip.second, adc);
1225 if((*i).second.trackIds().size()>0){
1228 for( std::vector<unsigned int>::const_iterator itid = (*i).second.trackIds().begin();
1229 itid != (*i).second.trackIds().end(); ++itid) {
1230 simi[*itid].push_back((*i).second.individualampl()[il]);
1235 for( simlink_map::iterator simiiter=simi.begin();
1236 simiiter!=simi.end();
1239 float sum_samechannel=0;
1240 for (
unsigned int iii=0;iii<(*simiiter).second.size();iii++){
1241 sum_samechannel+=(*simiiter).second[iii];
1243 float fraction=sum_samechannel/(*i).second;
1244 if(fraction>1.) fraction=1.;
1245 simlinks.emplace_back((*i).first, (*simiiter).first, (*i).second.hitIndex(), (*i).second.tofBin(), (*i).second.eventId(),
fraction);
1257 float thePixelThreshold,
1258 CLHEP::HepRandomEngine* engine) {
1269 float theSmearedChargeRMS = 0.0;
1275 if((*i).second < 3000)
1277 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1278 }
else if((*i).second < 6000){
1279 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1281 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1285 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1289 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1290 (*i).second.set(0);}
1292 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1302 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1303 (*i).second.set(0);}
1315 int numColumns = topol->
ncolumns();
1316 int numRows = topol->
nrows();
1320 int numberOfPixels = (numRows * numColumns);
1321 std::map<int,float, std::less<int> > otherPixels;
1322 std::map<int,float, std::less<int> >::iterator mapI;
1332 <<
" Add noisy pixels " << numRows <<
" "
1335 << otherPixels.size() ;
1339 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1340 int iy = ((*mapI).first) / numRows;
1341 int ix = ((*mapI).first) - (iy*numRows);
1344 if( iy < 0 || iy > (numColumns-1) )
1345 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1346 if( ix < 0 || ix > (numRows-1) )
1347 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1353 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1354 <<
" " << ix <<
" " << iy <<
" " << chan ;
1357 if(theSignal[chan] == 0){
1359 int noise=int( (*mapI).second );
1360 theSignal[chan] =
Amplitude (noise, -1.);
1372 CLHEP::HepRandomEngine* engine) {
1377 int numColumns = topol->
ncolumns();
1378 int numRows = topol->
nrows();
1381 double pixelEfficiency = 1.0;
1382 double columnEfficiency = 1.0;
1383 double chipEfficiency = 1.0;
1388 int layerIndex=tTopo->
layer(detID);
1395 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1396 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1400 if (module<=4) module=5-
module;
1410 unsigned int panelIndex=tTopo->
pxfPanel(detID);
1411 unsigned int moduleIndex=tTopo->
pxfModule(detID);
1421 if(numColumns>260 || numRows>160) {
1422 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1423 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1426 if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) {
1434 pixelEfficiency = 0.999;
1435 columnEfficiency = 0.999;
1436 chipEfficiency = 0.999;
1440 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" "
1441 << columnEfficiency <<
" " << chipEfficiency;
1446 std::auto_ptr<PixelIndices> pIndexConverter(
new PixelIndices(numColumns,numRows));
1451 std::map<int, int, std::less<int> >chips, columns;
1452 std::map<int, int, std::less<int> >::iterator
iter;
1458 int chan =
i->first;
1461 int col = ip.second;
1463 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1464 int dColInChip = pIndexConverter->DColumn(colROC);
1466 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1469 columns[dColInDet]++;
1473 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1475 float rand = CLHEP::RandFlat::shoot(engine);
1476 if( rand > chipEfficiency ) chips[iter->first]=0;
1480 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1482 float rand = CLHEP::RandFlat::shoot(engine);
1483 if( rand > columnEfficiency ) columns[iter->first]=0;
1493 int col = ip.second;
1495 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1496 int dColInChip = pIndexConverter->DColumn(colROC);
1498 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1501 float rand = CLHEP::RandFlat::shoot(engine);
1502 if( chips[chipIndex]==0 || columns[dColInDet]==0
1503 || rand>pixelEfficiency ) {
1523 float pseudoRadDamage = 0.0;
1528 int layerIndex=tTopo->
layer(detID);
1546 pseudoRadDamage = 0.;
1552 return pseudoRadDamage;
1554 LogDebug (
"Pixel Digitizer") <<
" enter pixel_aging " << pseudoRadDamage;
1569 const float signalInElectrons)
const {
1596 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1607 newAmp = p3 + p2 * tanh(p0*signal - p1);
1652 const DetId& detId)
const {
1689 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1694 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1697 throw cms::Exception(
"NotAPixelGeomDetUnit") <<
"Not a pixel geomdet unit" << detID;
1704 alpha2 = lorentzAngle * lorentzAngle;
1706 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1707 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1708 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1715 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is "
1716 << theDriftDirection ;
1719 return theDriftDirection;
1734 int col = ip.second;
1751 Parameters::const_iterator itDeadModules=
DeadModules.begin();
1754 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
1755 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
1756 if(detid == Dead_detID){
1769 if(Module==
"whole"){
1778 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
1782 if( Module==
"tbmB" && ip.first<=79){
1793 std::vector<SiPixelQuality::disabledModuleType>disabledModules =
SiPixelBadModule_->getBadComponentList();
1797 for (
size_t id=0;
id<disabledModules.size();
id++)
1799 if(detID==disabledModules[
id].DetID){
1801 badmodule = disabledModules[id];
1821 std::vector<GlobalPixel> badrocpositions (0);
1822 for(
unsigned int j = 0;
j < 16;
j++){
1825 std::vector<CablingPathToDetUnit>
path =
map_.
product()->pathToDetUnit(detID);
1826 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
1827 for (IT it = path.begin(); it != path.end(); ++it) {
1832 badrocpositions.push_back(global);
1843 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
1844 if(it->row >= 80 && ip.first >= 80 ){
1845 if((fabs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
1846 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
1847 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
1849 else if(it->row < 80 && ip.first < 80 ){
1850 if((fabs(ip.second - it->col) < 26) ){
i->second.set(0.);}
1851 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
1852 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())
const std::vector< int > & getMix_bunchCrossing() const
virtual const GeomDetType & type() const override
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_
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)
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.
float missCalibrate(uint32_t detID, const PixelGeomDetUnit *pixdet, int col, int row, float amp) const
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
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()
bool isTrackerPixel() const
signal_map_type::iterator signal_map_iterator
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
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 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
unsigned int layer(const DetId &id) const
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
virtual SubDetector subDetector() const
Which subdetector.
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 *)