52 #include <gsl/gsl_sf_erf.h>
54 #include "CLHEP/Random/RandGaussQ.h"
55 #include "CLHEP/Random/RandFlat.h"
102 using namespace sipixelobjects;
104 #define TP_DEBUG // protect all LogDebug with ifdef. Takes too much CPU
108 if(use_ineff_from_db_){
109 theSiPixelGainCalibrationService_->setESObjects( es );
111 if(use_deadmodule_DB_) {
114 if(use_LorentzAngle_DB_) {
128 makeDigiSimLinks_(conf.getUntrackedParameter<bool>(
"makeDigiSimLinks",
true)),
129 use_ineff_from_db_(conf.getParameter<bool>(
"useDB")),
130 use_module_killing_(conf.getParameter<bool>(
"killModules")),
131 use_deadmodule_DB_(conf.getParameter<bool>(
"DeadModules_DB")),
132 use_LorentzAngle_DB_(conf.getParameter<bool>(
"LorentzAngle_DB")),
138 GeVperElectron(3.61E-09),
141 alpha2Order(conf.getParameter<bool>(
"Alpha2Order")),
147 NumberOfBarrelLayers(conf.exists(
"NumPixelBarrel")?conf.getParameter<int>(
"NumPixelBarrel"):3),
148 NumberOfEndcapDisks(conf.exists(
"NumPixelEndcap")?conf.getParameter<int>(
"NumPixelEndcap"):2),
155 theElectronPerADC(conf.getParameter<double>(
"ElectronPerAdc")),
159 theAdcFullScale(conf.getParameter<int>(
"AdcFullScale")),
160 theAdcFullScaleStack(conf.exists(
"AdcFullScaleStack")?conf.getParameter<int>(
"AdcFullScaleStack"):255),
161 theFirstStackLayer(conf.exists(
"FirstStackLayer")?conf.getParameter<int>(
"FirstStackLayer"):5),
165 theNoiseInElectrons(conf.getParameter<double>(
"NoiseInElectrons")),
169 theReadoutNoise(conf.getParameter<double>(
"ReadoutNoiseInElec")),
174 theThresholdInE_FPix(conf.getParameter<double>(
"ThresholdInElectrons_FPix")),
175 theThresholdInE_BPix(conf.getParameter<double>(
"ThresholdInElectrons_BPix")),
176 theThresholdInE_BPix_L1(conf.exists(
"ThresholdInElectrons_BPix_L1")?conf.getParameter<double>(
"ThresholdInElectrons_BPix_L1"):theThresholdInE_BPix),
179 theThresholdSmearing_FPix(conf.getParameter<double>(
"ThresholdSmearing_FPix")),
180 theThresholdSmearing_BPix(conf.getParameter<double>(
"ThresholdSmearing_BPix")),
181 theThresholdSmearing_BPix_L1(conf.exists(
"ThresholdSmearing_BPix_L1")?conf.getParameter<double>(
"ThresholdSmearing_BPix_L1"):theThresholdSmearing_BPix),
184 electronsPerVCAL(conf.getParameter<double>(
"ElectronsPerVcal")),
185 electronsPerVCAL_Offset(conf.getParameter<double>(
"ElectronsPerVcal_Offset")),
189 theTofLowerCut(conf.getParameter<double>(
"TofLowerCut")),
190 theTofUpperCut(conf.getParameter<double>(
"TofUpperCut")),
193 tanLorentzAnglePerTesla_FPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_FPix")),
194 tanLorentzAnglePerTesla_BPix(use_LorentzAngle_DB_ ? 0.0 : conf.getParameter<double>(
"TanLorentzAnglePerTesla_BPix")),
197 FPix_p0(conf.getParameter<double>(
"FPix_SignalResponse_p0")),
198 FPix_p1(conf.getParameter<double>(
"FPix_SignalResponse_p1")),
199 FPix_p2(conf.getParameter<double>(
"FPix_SignalResponse_p2")),
200 FPix_p3(conf.getParameter<double>(
"FPix_SignalResponse_p3")),
202 BPix_p0(conf.getParameter<double>(
"BPix_SignalResponse_p0")),
203 BPix_p1(conf.getParameter<double>(
"BPix_SignalResponse_p1")),
204 BPix_p2(conf.getParameter<double>(
"BPix_SignalResponse_p2")),
205 BPix_p3(conf.getParameter<double>(
"BPix_SignalResponse_p3")),
208 addNoise(conf.getParameter<bool>(
"AddNoise")),
212 addChargeVCALSmearing(conf.getParameter<bool>(
"ChargeVCALSmearing")),
215 addNoisyPixels(conf.getParameter<bool>(
"AddNoisyPixels")),
218 fluctuateCharge(conf.getUntrackedParameter<bool>(
"FluctuateCharge",
true)),
221 AddPixelInefficiency(conf.getParameter<bool>(
"AddPixelInefficiencyFromPython")),
224 addThresholdSmearing(conf.getParameter<bool>(
"AddThresholdSmearing")),
227 doMissCalibrate(conf.getParameter<bool>(
"MissCalibrate")),
228 theGainSmearing(conf.getParameter<double>(
"GainSmearing")),
229 theOffsetSmearing(conf.getParameter<double>(
"OffsetSmearing")),
232 pseudoRadDamage(conf.exists(
"PseudoRadDamage")?conf.getParameter<double>(
"PseudoRadDamage"):double(0.0)),
233 pseudoRadDamageRadius(conf.exists(
"PseudoRadDamageRadius")?conf.getParameter<double>(
"PseudoRadDamageRadius"):double(0.0)),
238 tMax(conf.getParameter<double>(
"DeltaProductionCut")),
242 calmap(doMissCalibrate ? initCal() : std::
map<int,
CalParameters,std::less<int> >()),
244 pixelEfficiencies_(conf, AddPixelInefficiency,NumberOfBarrelLayers,NumberOfEndcapDisks),
245 flatDistribution_((addNoise || AddPixelInefficiency || fluctuateCharge || addThresholdSmearing) ? new CLHEP::RandFlat(eng, 0., 1.) : 0),
246 gaussDistribution_((addNoise || AddPixelInefficiency || fluctuateCharge || addThresholdSmearing) ? new CLHEP::RandGaussQ(eng, 0., theReadoutNoise) : 0),
247 gaussDistributionVCALNoise_((addNoise || AddPixelInefficiency || fluctuateCharge || addThresholdSmearing) ? new CLHEP::RandGaussQ(eng, 0., 1.) : 0),
249 smearedThreshold_FPix_(addThresholdSmearing ? new CLHEP::RandGaussQ(eng, theThresholdInE_FPix , theThresholdSmearing_FPix) : 0),
250 smearedThreshold_BPix_(addThresholdSmearing ? new CLHEP::RandGaussQ(eng, theThresholdInE_BPix , theThresholdSmearing_BPix) : 0),
251 smearedThreshold_BPix_L1_(addThresholdSmearing ? new CLHEP::RandGaussQ(eng, theThresholdInE_BPix_L1 , theThresholdSmearing_BPix_L1) : 0)
253 LogInfo (
"PixelDigitizer ") <<
"SiPixelDigitizerAlgorithm constructed"
254 <<
"Configuration parameters:"
255 <<
"Threshold/Gain = "
256 <<
"threshold in electron FPix = "
258 <<
"threshold in electron BPix = "
260 <<
"threshold in electron BPix Layer1 = "
263 <<
" The delta cut-off is set to " <<
tMax
268 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
275 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
calmap;
278 <<
" miss-calibrate the pixel amplitude ";
280 const bool ReadCalParameters =
false;
281 if(ReadCalParameters) {
284 char filename[80] =
"phCalibrationFit_C0.dat";
288 cout <<
" File not found " << endl;
291 cout <<
" file opened : " << filename << endl;
294 for (
int i = 0;
i < 3;
i++) {
295 in_file.getline(line, 500,
'\n');
299 cout <<
" test map" << endl;
301 float par0,par1,par2,par3;
305 for(
int i=0;
i<(52*80);
i++) {
306 in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid >> rowid;
308 cerr <<
"Cannot read data file" << endl;
311 if( in_file.eof() != 0 ) {
312 cerr << in_file.eof() <<
" " << in_file.gcount() <<
" "
313 << in_file.fail() <<
" " << in_file.good() <<
" end of file "
329 calmap.insert(std::pair<int,CalParameters>(chan,onePix));
333 if(rowid!=p.first)
cout<<
" wrong channel row "<<rowid<<
" "<<p.first<<endl;
334 if(colid!=p.second)
cout<<
" wrong channel col "<<colid<<
" "<<p.second<<endl;
338 cout <<
" map size " << calmap.size() <<
" max "<<calmap.max_size() <<
" "
339 <<calmap.empty()<< endl;
362 LogDebug (
"PixelDigitizer")<<
"SiPixelDigitizerAlgorithm deleted";
370 if (AddPixelInefficiency){
374 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix3");
375 if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_BPix4");}
380 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix3");
381 if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_BPix4");}
386 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix3");
387 if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_BPix4");}
389 if (NumberOfBarrelLayers>=5){
390 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
393 thePixelColEfficiency[
j-1]=0.999;
394 thePixelEfficiency[
j-1]=0.999;
395 thePixelChipEfficiency[
j-1]=0.999;
400 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix1");
401 thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix2");
402 if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.
getParameter<
double>(
"thePixelColEfficiency_FPix3");}
404 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix1");
405 thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix2");
406 if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.
getParameter<
double>(
"thePixelEfficiency_FPix3");}
408 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix1");
409 thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix2");
410 if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.
getParameter<
double>(
"thePixelChipEfficiency_FPix3");}
412 if (NumberOfEndcapDisks>=4){
413 if (NumberOfTotLayers>20){
throw cms::Exception(
"Configuration") <<
"SiPixelDigitizer was given more layers than it can handle";}
416 thePixelColEfficiency[
j-1]=0.999;
417 thePixelEfficiency[
j-1]=0.999;
418 thePixelChipEfficiency[
j-1]=0.999;
424 if(!AddPixelInefficiency) {
425 for (
int i=0;
i<NumberOfTotLayers;
i++) {
435 std::vector<PSimHit>::const_iterator inputEnd,
442 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin) {
444 if((*ssbegin).detUnitId() != detId) {
450 << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" "
451 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" "
452 << (*ssbegin).trackId() <<
" " << (*ssbegin).processType() <<
" "
453 << (*ssbegin).detUnitId()
454 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint() ;
458 std::vector<EnergyDepositUnit> ionization_points;
459 std::vector<SignalPoint> collection_points;
466 drift(*ssbegin, pixdet, bfield, ionization_points, collection_points);
476 std::vector<PixelDigi>& digis,
477 std::vector<PixelDigiSimLink>& simlinks,
const TrackerTopology *tTopo) {
488 int numRows = topol->
nrows();
496 float thePixelThresholdInE = 0.;
528 <<
" PixelDigitizer "
529 << numColumns <<
" " << numRows <<
" " << moduleThickness;
550 make_digis(thePixelThresholdInE, detID, digis, simlinks, tTopo);
553 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
564 const float SegmentLength = 0.0010;
571 float length = direction.
mag();
573 int NumberOfSegments = int ( length / SegmentLength);
574 if(NumberOfSegments < 1) NumberOfSegments = 1;
578 <<
" enter primary_ionzation " << NumberOfSegments
586 float* elossVector =
new float[NumberOfSegments];
593 float momentum = hit.
pabs();
599 ionization_points.resize( NumberOfSegments);
602 for (
int i = 0;
i != NumberOfSegments;
i++) {
605 float((
i+0.5)/NumberOfSegments) * direction;
613 ionization_points[
i] = edu;
617 <<
i <<
" " << ionization_points[
i].x() <<
" "
618 << ionization_points[
i].y() <<
" "
619 << ionization_points[
i].z() <<
" "
620 << ionization_points[
i].energy();
625 delete[] elossVector;
633 float eloss,
float length,
634 int NumberOfSegs,
float elossVector[])
const {
641 double particleMass = 139.6;
644 if(pid==11) particleMass = 0.511;
645 else if(pid==13) particleMass = 105.7;
646 else if(pid==321) particleMass = 493.7;
647 else if(pid==2212) particleMass = 938.3;
650 float segmentLength = length/NumberOfSegs;
655 double segmentEloss = (1000.*eloss)/NumberOfSegs;
656 for (
int i=0;
i<NumberOfSegs;
i++) {
662 double deltaCutoff =
tMax;
663 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
664 particleMass, deltaCutoff,
665 double(segmentLength*10.),
666 segmentEloss )/1000.;
674 float ratio = eloss/sum;
676 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
678 float averageEloss = eloss/NumberOfSegs;
679 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
690 const std::vector<EnergyDepositUnit>& ionization_points,
691 std::vector<SignalPoint>& collection_points)
const {
694 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
697 collection_points.resize(ionization_points.size());
700 if(driftDir.
z() ==0.) {
701 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
709 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
713 TanLorenzAngleX = driftDir.
x();
714 TanLorenzAngleY = driftDir.
y();
715 dir_z = driftDir.
z();
716 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
717 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
721 TanLorenzAngleX = driftDir.
x();
722 TanLorenzAngleY = 0.;
723 dir_z = driftDir.
z();
724 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
725 CosLorenzAngleY = 1.;
731 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" "
732 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" "
733 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
743 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
745 float SegX, SegY, SegZ;
746 SegX = ionization_points[
i].
x();
747 SegY = ionization_points[
i].y();
748 SegZ = ionization_points[
i].z();
753 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
763 if( DriftDistance < 0.) {
765 }
else if( DriftDistance > moduleThickness )
766 DriftDistance = moduleThickness;
769 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
770 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
773 float CloudCenterX = SegX + XDriftDueToMagField;
774 float CloudCenterY = SegY + YDriftDueToMagField;
777 DriftLength =
sqrt( DriftDistance*DriftDistance +
778 XDriftDueToMagField*XDriftDueToMagField +
779 YDriftDueToMagField*YDriftDueToMagField );
785 Sigma_x = Sigma / CosLorenzAngleX ;
786 Sigma_y = Sigma / CosLorenzAngleY ;
789 float energyOnCollector = ionization_points[
i].energy();
797 energyOnCollector = energyOnCollector *
exp( -1*kValue*DriftDistance/moduleThickness );
802 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
803 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
806 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
809 collection_points[
i] = (sp);
819 const std::vector<SignalPoint>& collection_points) {
830 <<
" enter induce_signal, "
831 << topol->
pitch().first <<
" " << topol->
pitch().second;
835 typedef std::map< int, float, std::less<int> > hit_map_type;
836 hit_map_type hit_signal;
839 std::map<int, float, std::less<int> >
x,
y;
844 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
845 i != collection_points.end(); ++
i) {
847 float CloudCenterX =
i->position().x();
848 float CloudCenterY =
i->position().y();
849 float SigmaX =
i->sigma_x();
850 float SigmaY =
i->sigma_y();
851 float Charge =
i->amplitude();
862 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" "
863 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
886 int IPixRightUpX = int( floor( mp.
x()));
887 int IPixRightUpY = int( floor( mp.
y()));
890 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" "
891 << mp.
x() <<
" " << mp.
y() <<
" "
892 << IPixRightUpX <<
" " << IPixRightUpY ;
897 int IPixLeftDownX = int( floor( mp.
x()));
898 int IPixLeftDownY = int( floor( mp.
y()));
901 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" "
902 << mp.
x() <<
" " << mp.
y() <<
" "
903 << IPixLeftDownX <<
" " << IPixLeftDownY ;
908 int numRows = topol->
nrows();
910 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
911 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
912 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
913 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
920 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
921 float xUB, xLB, UpperBound, LowerBound;
926 if(ix == 0 || SigmaX==0. )
931 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
934 if(ix == numRows-1 || SigmaX==0. )
939 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
942 float TotalIntegrationRange = UpperBound - LowerBound;
943 x[ix] = TotalIntegrationRange;
951 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
952 float yUB, yLB, UpperBound, LowerBound;
954 if(iy == 0 || SigmaY==0.)
959 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
962 if(iy == numColumns-1 || SigmaY==0. )
967 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
970 float TotalIntegrationRange = UpperBound - LowerBound;
971 y[iy] = TotalIntegrationRange;
978 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
979 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
981 float ChargeFraction = Charge*x[ix]*y[iy];
983 if( ChargeFraction > 0. ) {
986 hit_signal[chan] += ChargeFraction;
996 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" "
997 << chan <<
" " << ChargeFraction<<
" "
998 << mp.
x() <<
" " << mp.
y() <<
" "
999 << lp.
x() <<
" " << lp.
y() <<
" "
1029 for ( hit_map_type::const_iterator im = hit_signal.begin();
1030 im != hit_signal.end(); ++im) {
1031 int chan = (*im).first;
1032 theSignal[chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1037 <<
" pixel " << ip.first <<
" " << ip.second <<
" "
1049 std::vector<PixelDigi>& digis,
1050 std::vector<PixelDigiSimLink>& simlinks,
1054 LogDebug (
"Pixel Digitizer") <<
" make digis "<<
" "
1058 <<
" List pixels passing threshold ";
1063 signalMaps::const_iterator it =
_signal.find(detID);
1072 float signalInElectrons = (*i).second ;
1079 if( signalInElectrons >= thePixelThresholdInE) {
1081 int chan = (*i).first;
1088 int col = ip.second;
1089 adc = int(
missCalibrate(detID, col, row, signalInElectrons));
1109 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1110 <<
" " << adc << ip.first <<
" " << ip.second ;
1114 digis.emplace_back(ip.first, ip.second, adc);
1118 if((*i).second.trackIds().size()>0){
1121 for( std::vector<unsigned int>::const_iterator itid = (*i).second.trackIds().begin();
1122 itid != (*i).second.trackIds().end(); ++itid) {
1123 simi[*itid].push_back((*i).second.individualampl()[il]);
1128 for( simlink_map::iterator simiiter=simi.begin();
1129 simiiter!=simi.end();
1132 float sum_samechannel=0;
1133 for (
unsigned int iii=0;iii<(*simiiter).second.size();iii++){
1134 sum_samechannel+=(*simiiter).second[iii];
1136 float fraction=sum_samechannel/(*i).second;
1137 if(fraction>1.) fraction=1.;
1138 simlinks.emplace_back((*i).first, (*simiiter).first, (*i).second.eventId(), fraction);
1150 float thePixelThreshold) {
1161 float theSmearedChargeRMS = 0.0;
1167 if((*i).second < 3000)
1169 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1170 }
else if((*i).second < 6000){
1171 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1173 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1181 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1182 (*i).second.set(0);}
1184 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1194 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1195 (*i).second.set(0);}
1207 int numColumns = topol->
ncolumns();
1208 int numRows = topol->
nrows();
1212 int numberOfPixels = (numRows * numColumns);
1213 std::map<int,float, std::less<int> > otherPixels;
1214 std::map<int,float, std::less<int> >::iterator mapI;
1223 <<
" Add noisy pixels " << numRows <<
" "
1226 << otherPixels.size() ;
1230 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1231 int iy = ((*mapI).first) / numRows;
1232 int ix = ((*mapI).first) - (iy*numRows);
1235 if( iy < 0 || iy > (numColumns-1) )
1236 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1237 if( ix < 0 || ix > (numRows-1) )
1238 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1244 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1245 <<
" " << ix <<
" " << iy <<
" " << chan ;
1248 if(theSignal[chan] == 0){
1250 int noise=int( (*mapI).second );
1251 theSignal[chan] =
Amplitude (noise, -1.);
1269 int numColumns = topol->
ncolumns();
1270 int numRows = topol->
nrows();
1273 float pixelEfficiency = 1.0;
1274 float columnEfficiency = 1.0;
1275 float chipEfficiency = 1.0;
1280 int layerIndex=tTopo->
pxbLayer(detID);
1287 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1288 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1301 if(numColumns>260 || numRows>160) {
1302 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1303 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1310 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" "
1311 << columnEfficiency <<
" " << chipEfficiency;
1316 std::auto_ptr<PixelIndices> pIndexConverter(
new PixelIndices(numColumns,numRows));
1321 std::map<int, int, std::less<int> >chips, columns;
1322 std::map<int, int, std::less<int> >::iterator iter;
1328 int chan =
i->first;
1331 int col = ip.second;
1333 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1334 int dColInChip = pIndexConverter->DColumn(colROC);
1336 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1339 columns[dColInDet]++;
1343 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1346 if( rand > chipEfficiency ) chips[iter->first]=0;
1350 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1353 if( rand > columnEfficiency ) columns[iter->first]=0;
1363 int col = ip.second;
1365 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1366 int dColInChip = pIndexConverter->DColumn(colROC);
1368 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1373 if( chips[chipIndex]==0 || columns[dColInDet]==0
1374 || rand>pixelEfficiency ) {
1392 const float signalInElectrons)
const {
1430 newAmp = p3 + p2 * tanh(p0*signal - p1);
1475 const DetId& detId)
const {
1513 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1514 scale = (1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1519 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1520 scale = (1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1527 alpha2 = lorentzAngle * lorentzAngle;
1529 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1530 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1531 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1532 scale = (1 + alpha2 * Bfield.z()*Bfield.z() );
1538 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is "
1539 << theDriftDirection ;
1542 return theDriftDirection;
1559 int col = ip.second;
1578 Parameters::const_iterator itDeadModules=
DeadModules.begin();
1581 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
1582 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
1583 if(detid == Dead_detID){
1596 if(Module==
"whole"){
1605 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
1609 if( Module==
"tbmB" && ip.first<=79){
1622 std::vector<SiPixelQuality::disabledModuleType>disabledModules =
SiPixelBadModule_->getBadComponentList();
1626 for (
size_t id=0;
id<disabledModules.size();
id++)
1628 if(detID==disabledModules[
id].DetID){
1630 badmodule = disabledModules[id];
1650 std::vector<GlobalPixel> badrocpositions (0);
1651 for(
unsigned int j = 0;
j < 16;
j++){
1654 std::vector<CablingPathToDetUnit>
path =
map_.
product()->pathToDetUnit(detID);
1655 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
1656 for (IT it = path.begin(); it != path.end(); ++it) {
1661 badrocpositions.push_back(global);
1672 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
1673 if(it->row >= 80 && ip.first >= 80 ){
1674 if((fabs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
1675 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
1676 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
1678 else if(it->row < 80 && ip.first < 80 ){
1679 if((fabs(ip.second - it->col) < 26) ){
i->second.set(0.);}
1680 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
1681 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
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_
GlobalPixel toGlobal(const LocalPixel &loc) const
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
virtual int ncolumns() const =0
void fluctuateEloss(int particleId, float momentum, float eloss, float length, int NumberOfSegments, float elossVector[]) 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::unique_ptr< CLHEP::RandGaussQ > smearedThreshold_BPix_
unsigned int pxfDisk(const DetId &id) const
const std::unique_ptr< CLHEP::RandGaussQ > gaussDistribution_
float missCalibrate(uint32_t detID, int col, int row, float amp) const
virtual int nrows() const =0
const std::unique_ptr< CLHEP::RandGaussQ > smearedThreshold_BPix_L1_
const float theThresholdInE_FPix
const Bounds & bounds() const
const std::unique_ptr< CLHEP::RandFlat > flatDistribution_
const bool addThresholdSmearing
void module_killing_conf(uint32_t detID)
const bool fluctuateCharge
~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
const double pseudoRadDamage
const bool use_LorentzAngle_DB_
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
void induce_signal(const PSimHit &hit, const PixelGeomDetUnit *pixdet, const std::vector< SignalPoint > &collection_points)
Local3DPoint exitPoint() const
Exit point in the local Det frame.
const std::map< int, CalParameters, std::less< int > > calmap
const Parameters DeadModules
void drift(const PSimHit &hit, const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const std::vector< EnergyDepositUnit > &ionization_points, std::vector< SignalPoint > &collection_points) const
const float theTofUpperCut
const bool use_module_killing_
void module_killing_DB(uint32_t detID)
static int pixelToChannelROC(const int rowROC, const int colROC)
void accumulateSimHits(const std::vector< PSimHit >::const_iterator inputBegin, const std::vector< PSimHit >::const_iterator inputEnd, const PixelGeomDetUnit *pixdet, const GlobalVector &bfield)
static std::pair< int, int > channelToPixelROC(const int chan)
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Abs< T >::type abs(const T &t)
const float theThresholdInE_BPix
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
void add_noise(const PixelGeomDetUnit *pixdet, float thePixelThreshold)
std::vector< LinkConnSpec >::const_iterator IT
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
const double pseudoRadDamageRadius
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_
virtual std::pair< float, float > pitch() const =0
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_
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 int theAdcFullScaleStack
row and collumn in ROC representation
void digitize(const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelDigiSimLink > &simlinks, const TrackerTopology *tTopo)
const float tanLorentzAnglePerTesla_BPix
float thePixelChipEfficiency[20]
float thePixelColEfficiency[20]
std::vector< edm::ParameterSet > Parameters
const std::unique_ptr< CLHEP::RandGaussQ > gaussDistributionVCALNoise_
float energyLoss() const
The energy deposit in the PSimHit, in ???.
const std::unique_ptr< CLHEP::RandGaussQ > smearedThreshold_FPix_
const double electronsPerVCAL
void primary_ionization(const PSimHit &hit, std::vector< EnergyDepositUnit > &ionization_points) const
const RotationType & rotation() const
float thePixelEfficiency[20]
const float theTofLowerCut
SiPixelDigitizerAlgorithm(const edm::ParameterSet &conf, CLHEP::HepRandomEngine &)
const bool addNoisyPixels
const PositionType & position() const
const float theElectronPerADC
Local3DPoint entryPoint() const
Entry point in the local Det frame.
const bool makeDigiSimLinks_
void pixel_inefficiency(const PixelEfficiencies &eff, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo)
*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