52 #include <gsl/gsl_sf_erf.h>
54 #include "CLHEP/Random/RandGaussQ.h"
55 #include "CLHEP/Random/RandFlat.h"
103 using namespace sipixelobjects;
105 #define TP_DEBUG // protect all LogDebug with ifdef. Takes too much CPU
109 if(use_ineff_from_db_){
110 theSiPixelGainCalibrationService_->setESObjects( es );
112 if(use_deadmodule_DB_) {
115 if(use_LorentzAngle_DB_) {
129 makeDigiSimLinks_(conf.getUntrackedParameter<bool>(
"makeDigiSimLinks",
true)),
130 use_ineff_from_db_(conf.getParameter<bool>(
"useDB")),
131 use_module_killing_(conf.getParameter<bool>(
"killModules")),
132 use_deadmodule_DB_(conf.getParameter<bool>(
"DeadModules_DB")),
133 use_LorentzAngle_DB_(conf.getParameter<bool>(
"LorentzAngle_DB")),
139 GeVperElectron(3.61E-09),
142 alpha2Order(conf.getParameter<bool>(
"Alpha2Order")),
148 NumberOfBarrelLayers(conf.exists(
"NumPixelBarrel")?conf.getParameter<int>(
"NumPixelBarrel"):3),
149 NumberOfEndcapDisks(conf.exists(
"NumPixelEndcap")?conf.getParameter<int>(
"NumPixelEndcap"):2),
156 theElectronPerADC(conf.getParameter<double>(
"ElectronPerAdc")),
160 theAdcFullScale(conf.getParameter<int>(
"AdcFullScale")),
161 theAdcFullScaleStack(conf.exists(
"AdcFullScaleStack")?conf.getParameter<int>(
"AdcFullScaleStack"):255),
162 theFirstStackLayer(conf.exists(
"FirstStackLayer")?conf.getParameter<int>(
"FirstStackLayer"):5),
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 pseudoRadDamage(conf.exists(
"PseudoRadDamage")?conf.getParameter<double>(
"PseudoRadDamage"):double(0.0)),
234 pseudoRadDamageRadius(conf.exists(
"PseudoRadDamageRadius")?conf.getParameter<double>(
"PseudoRadDamageRadius"):double(0.0)),
239 tMax(conf.getParameter<double>(
"DeltaProductionCut")),
243 calmap(doMissCalibrate ? initCal() : std::
map<int,
CalParameters,std::less<int> >()),
245 pixelEfficiencies_(conf, AddPixelInefficiency,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_BPix[i++] = conf.
getParameter<std::vector<double> >(
"thePUEfficiency_BPix3");
403 if ( ((thePUEfficiency_BPix[0].
size()==0) || (thePUEfficiency_BPix[1].
size()==0) ||
404 (thePUEfficiency_BPix[2].
size()==0)) && (NumberOfBarrelLayers==3) )
405 throw cms::Exception(
"Configuration") <<
"At least one PU efficiency 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;
442 if(!AddPixelInefficiency) {
443 for (
int i=0;
i<NumberOfTotLayers;
i++) {
453 std::vector<PSimHit>::const_iterator inputEnd,
454 const size_t inputBeginGlobalIndex,
455 const unsigned int tofBin,
458 CLHEP::HepRandomEngine* engine) {
463 size_t simHitGlobalIndex=inputBeginGlobalIndex;
464 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
466 if((*ssbegin).detUnitId() != detId) {
472 << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" "
473 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" "
474 << (*ssbegin).trackId() <<
" " << (*ssbegin).processType() <<
" "
475 << (*ssbegin).detUnitId()
476 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint() ;
480 std::vector<EnergyDepositUnit> ionization_points;
481 std::vector<SignalPoint> collection_points;
488 drift(*ssbegin, pixdet, bfield, ionization_points, collection_points);
490 induce_signal(*ssbegin, simHitGlobalIndex, tofBin, pixdet, collection_points);
506 std::vector<int>::const_iterator pu;
507 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
509 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++pu) {
517 if (pu0!=bunchCrossing.end()) {
518 for (
size_t i=0;
i<3;
i++) {
519 double instlumi = TrueInteractionList.at(
p)*221.95;
520 double instlumi_pow=1.;
524 instlumi_pow*=instlumi;
530 for (
int i=0;
i<3;
i++) {
538 std::vector<PixelDigi>& digis,
539 std::vector<PixelDigiSimLink>& simlinks,
541 CLHEP::HepRandomEngine* engine) {
552 int numRows = topol->
nrows();
560 float thePixelThresholdInE = 0.;
592 <<
" PixelDigitizer "
593 << numColumns <<
" " << numRows <<
" " << moduleThickness;
614 make_digis(thePixelThresholdInE, detID, digis, simlinks, tTopo);
617 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
628 const float SegmentLength = 0.0010;
635 float length = direction.
mag();
637 int NumberOfSegments = int ( length / SegmentLength);
638 if(NumberOfSegments < 1) NumberOfSegments = 1;
642 <<
" enter primary_ionzation " << NumberOfSegments
650 float* elossVector =
new float[NumberOfSegments];
657 float momentum = hit.
pabs();
660 elossVector, engine);
663 ionization_points.resize( NumberOfSegments);
666 for (
int i = 0;
i != NumberOfSegments;
i++) {
669 float((
i+0.5)/NumberOfSegments) * direction;
677 ionization_points[
i] = edu;
681 <<
i <<
" " << ionization_points[
i].x() <<
" "
682 << ionization_points[
i].y() <<
" "
683 << ionization_points[
i].z() <<
" "
684 << ionization_points[
i].energy();
689 delete[] elossVector;
697 float eloss,
float length,
698 int NumberOfSegs,
float elossVector[],
699 CLHEP::HepRandomEngine* engine)
const {
706 double particleMass = 139.6;
709 if(pid==11) particleMass = 0.511;
710 else if(pid==13) particleMass = 105.7;
711 else if(pid==321) particleMass = 493.7;
712 else if(pid==2212) particleMass = 938.3;
715 float segmentLength = length/NumberOfSegs;
720 double segmentEloss = (1000.*eloss)/NumberOfSegs;
721 for (
int i=0;
i<NumberOfSegs;
i++) {
727 double deltaCutoff =
tMax;
728 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
729 particleMass, deltaCutoff,
730 double(segmentLength*10.),
731 segmentEloss, engine )/1000.;
739 float ratio = eloss/sum;
741 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
743 float averageEloss = eloss/NumberOfSegs;
744 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
755 const std::vector<EnergyDepositUnit>& ionization_points,
756 std::vector<SignalPoint>& collection_points)
const {
759 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
762 collection_points.resize(ionization_points.size());
765 if(driftDir.
z() ==0.) {
766 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
774 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
778 TanLorenzAngleX = driftDir.
x();
779 TanLorenzAngleY = driftDir.
y();
780 dir_z = driftDir.
z();
781 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
782 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
786 TanLorenzAngleX = driftDir.
x();
787 TanLorenzAngleY = 0.;
788 dir_z = driftDir.
z();
789 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
790 CosLorenzAngleY = 1.;
796 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" "
797 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" "
798 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
808 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
810 float SegX, SegY, SegZ;
811 SegX = ionization_points[
i].
x();
812 SegY = ionization_points[
i].y();
813 SegZ = ionization_points[
i].z();
818 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
828 if( DriftDistance < 0.) {
830 }
else if( DriftDistance > moduleThickness )
831 DriftDistance = moduleThickness;
834 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
835 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
838 float CloudCenterX = SegX + XDriftDueToMagField;
839 float CloudCenterY = SegY + YDriftDueToMagField;
842 DriftLength =
sqrt( DriftDistance*DriftDistance +
843 XDriftDueToMagField*XDriftDueToMagField +
844 YDriftDueToMagField*YDriftDueToMagField );
850 Sigma_x = Sigma / CosLorenzAngleX ;
851 Sigma_y = Sigma / CosLorenzAngleY ;
854 float energyOnCollector = ionization_points[
i].energy();
862 energyOnCollector = energyOnCollector *
exp( -1*kValue*DriftDistance/moduleThickness );
867 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
868 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
871 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
874 collection_points[
i] = (sp);
883 const size_t hitIndex,
884 const unsigned int tofBin,
886 const std::vector<SignalPoint>& collection_points) {
897 <<
" enter induce_signal, "
898 << topol->
pitch().first <<
" " << topol->
pitch().second;
902 typedef std::map< int, float, std::less<int> > hit_map_type;
903 hit_map_type hit_signal;
906 std::map<int, float, std::less<int> >
x,
y;
911 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
912 i != collection_points.end(); ++
i) {
914 float CloudCenterX =
i->position().x();
915 float CloudCenterY =
i->position().y();
916 float SigmaX =
i->sigma_x();
917 float SigmaY =
i->sigma_y();
918 float Charge =
i->amplitude();
929 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" "
930 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
953 int IPixRightUpX = int( floor( mp.
x()));
954 int IPixRightUpY = int( floor( mp.
y()));
957 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" "
958 << mp.
x() <<
" " << mp.
y() <<
" "
959 << IPixRightUpX <<
" " << IPixRightUpY ;
964 int IPixLeftDownX = int( floor( mp.
x()));
965 int IPixLeftDownY = int( floor( mp.
y()));
968 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" "
969 << mp.
x() <<
" " << mp.
y() <<
" "
970 << IPixLeftDownX <<
" " << IPixLeftDownY ;
975 int numRows = topol->
nrows();
977 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
978 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
979 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
980 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
987 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
988 float xUB, xLB, UpperBound, LowerBound;
993 if(ix == 0 || SigmaX==0. )
998 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
1001 if(ix == numRows-1 || SigmaX==0. )
1006 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
1009 float TotalIntegrationRange = UpperBound - LowerBound;
1010 x[ix] = TotalIntegrationRange;
1018 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1019 float yUB, yLB, UpperBound, LowerBound;
1021 if(iy == 0 || SigmaY==0.)
1026 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
1029 if(iy == numColumns-1 || SigmaY==0. )
1034 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
1037 float TotalIntegrationRange = UpperBound - LowerBound;
1038 y[iy] = TotalIntegrationRange;
1045 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1046 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1048 float ChargeFraction = Charge*x[ix]*y[iy];
1050 if( ChargeFraction > 0. ) {
1053 hit_signal[chan] += ChargeFraction;
1063 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" "
1064 << chan <<
" " << ChargeFraction<<
" "
1065 << mp.
x() <<
" " << mp.
y() <<
" "
1066 << lp.
x() <<
" " << lp.
y() <<
" "
1096 for ( hit_map_type::const_iterator im = hit_signal.begin();
1097 im != hit_signal.end(); ++im) {
1098 int chan = (*im).first;
1099 theSignal[chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1104 <<
" pixel " << ip.first <<
" " << ip.second <<
" "
1116 std::vector<PixelDigi>& digis,
1117 std::vector<PixelDigiSimLink>& simlinks,
1121 LogDebug (
"Pixel Digitizer") <<
" make digis "<<
" "
1125 <<
" List pixels passing threshold ";
1130 signalMaps::const_iterator it =
_signal.find(detID);
1139 float signalInElectrons = (*i).second ;
1146 if( signalInElectrons >= thePixelThresholdInE) {
1148 int chan = (*i).first;
1155 int col = ip.second;
1156 adc = int(
missCalibrate(detID, col, row, signalInElectrons));
1176 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1177 <<
" " << adc << ip.first <<
" " << ip.second ;
1181 digis.emplace_back(ip.first, ip.second, adc);
1185 if((*i).second.trackIds().size()>0){
1188 for( std::vector<unsigned int>::const_iterator itid = (*i).second.trackIds().begin();
1189 itid != (*i).second.trackIds().end(); ++itid) {
1190 simi[*itid].push_back((*i).second.individualampl()[il]);
1195 for( simlink_map::iterator simiiter=simi.begin();
1196 simiiter!=simi.end();
1199 float sum_samechannel=0;
1200 for (
unsigned int iii=0;iii<(*simiiter).second.size();iii++){
1201 sum_samechannel+=(*simiiter).second[iii];
1203 float fraction=sum_samechannel/(*i).second;
1204 if(fraction>1.) fraction=1.;
1205 simlinks.emplace_back((*i).first, (*simiiter).first, (*i).second.hitIndex(), (*i).second.tofBin(), (*i).second.eventId(), fraction);
1217 float thePixelThreshold,
1218 CLHEP::HepRandomEngine* engine) {
1229 float theSmearedChargeRMS = 0.0;
1235 if((*i).second < 3000)
1237 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1238 }
else if((*i).second < 6000){
1239 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1241 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1245 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1249 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1250 (*i).second.set(0);}
1252 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1262 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1263 (*i).second.set(0);}
1275 int numColumns = topol->
ncolumns();
1276 int numRows = topol->
nrows();
1280 int numberOfPixels = (numRows * numColumns);
1281 std::map<int,float, std::less<int> > otherPixels;
1282 std::map<int,float, std::less<int> >::iterator mapI;
1292 <<
" Add noisy pixels " << numRows <<
" "
1295 << otherPixels.size() ;
1299 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1300 int iy = ((*mapI).first) / numRows;
1301 int ix = ((*mapI).first) - (iy*numRows);
1304 if( iy < 0 || iy > (numColumns-1) )
1305 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1306 if( ix < 0 || ix > (numRows-1) )
1307 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1313 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1314 <<
" " << ix <<
" " << iy <<
" " << chan ;
1317 if(theSignal[chan] == 0){
1319 int noise=int( (*mapI).second );
1320 theSignal[chan] =
Amplitude (noise, -1.);
1332 CLHEP::HepRandomEngine* engine) {
1339 int numColumns = topol->
ncolumns();
1340 int numRows = topol->
nrows();
1343 float pixelEfficiency = 1.0;
1344 float columnEfficiency = 1.0;
1345 float chipEfficiency = 1.0;
1350 int layerIndex=tTopo->
pxbLayer(detID);
1357 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1358 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1362 if (module<=4) module=5-
module;
1378 if(numColumns>260 || numRows>160) {
1379 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1380 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1387 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" "
1388 << columnEfficiency <<
" " << chipEfficiency;
1393 std::auto_ptr<PixelIndices> pIndexConverter(
new PixelIndices(numColumns,numRows));
1398 std::map<int, int, std::less<int> >chips, columns;
1399 std::map<int, int, std::less<int> >::iterator
iter;
1405 int chan =
i->first;
1408 int col = ip.second;
1410 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1411 int dColInChip = pIndexConverter->DColumn(colROC);
1413 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1416 columns[dColInDet]++;
1420 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1422 float rand = CLHEP::RandFlat::shoot(engine);
1423 if( rand > chipEfficiency ) chips[iter->first]=0;
1427 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1429 float rand = CLHEP::RandFlat::shoot(engine);
1430 if( rand > columnEfficiency ) columns[iter->first]=0;
1440 int col = ip.second;
1442 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1443 int dColInChip = pIndexConverter->DColumn(colROC);
1445 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1449 float rand = CLHEP::RandFlat::shoot(engine);
1450 if( chips[chipIndex]==0 || columns[dColInDet]==0
1451 || rand>pixelEfficiency ) {
1469 const float signalInElectrons)
const {
1507 newAmp = p3 + p2 * tanh(p0*signal - p1);
1552 const DetId& detId)
const {
1590 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1591 scale = (1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1596 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1597 scale = (1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1604 alpha2 = lorentzAngle * lorentzAngle;
1606 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1607 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1608 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1609 scale = (1 + alpha2 * Bfield.z()*Bfield.z() );
1615 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is "
1616 << theDriftDirection ;
1619 return theDriftDirection;
1636 int col = ip.second;
1655 Parameters::const_iterator itDeadModules=
DeadModules.begin();
1658 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
1659 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
1660 if(detid == Dead_detID){
1673 if(Module==
"whole"){
1682 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
1686 if( Module==
"tbmB" && ip.first<=79){
1699 std::vector<SiPixelQuality::disabledModuleType>disabledModules =
SiPixelBadModule_->getBadComponentList();
1703 for (
size_t id=0;
id<disabledModules.size();
id++)
1705 if(detID==disabledModules[
id].DetID){
1707 badmodule = disabledModules[id];
1727 std::vector<GlobalPixel> badrocpositions (0);
1728 for(
unsigned int j = 0;
j < 16;
j++){
1731 std::vector<CablingPathToDetUnit>
path =
map_.
product()->pathToDetUnit(detID);
1732 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
1733 for (IT it = path.begin(); it != path.end(); ++it) {
1738 badrocpositions.push_back(global);
1749 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
1750 if(it->row >= 80 && ip.first >= 80 ){
1751 if((fabs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
1752 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
1753 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
1755 else if(it->row < 80 && ip.first < 80 ){
1756 if((fabs(ip.second - it->col) < 26) ){
i->second.set(0.);}
1757 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
1758 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 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, CLHEP::HepRandomEngine *)
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)
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
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
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)
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
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()
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
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_
void primary_ionization(const PSimHit &hit, std::vector< EnergyDepositUnit > &ionization_points, CLHEP::HepRandomEngine *) const
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 int theAdcFullScaleStack
row and collumn in ROC representation
const float tanLorentzAnglePerTesla_BPix
float thePixelChipEfficiency[20]
float thePixelColEfficiency[20]
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 RotationType & rotation() const
std::vector< double > thePUEfficiency_BPix[20]
float thePixelEfficiency[20]
const float theTofLowerCut
const bool addNoisyPixels
const PositionType & position() const
const float theElectronPerADC
Local3DPoint entryPoint() const
Entry point in the local Det frame.
tuple size
Write out results.
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 *)