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,
456 CLHEP::HepRandomEngine* engine) {
461 for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin) {
463 if((*ssbegin).detUnitId() != detId) {
469 << (*ssbegin).particleType() <<
" " << (*ssbegin).pabs() <<
" "
470 << (*ssbegin).energyLoss() <<
" " << (*ssbegin).tof() <<
" "
471 << (*ssbegin).trackId() <<
" " << (*ssbegin).processType() <<
" "
472 << (*ssbegin).detUnitId()
473 << (*ssbegin).entryPoint() <<
" " << (*ssbegin).exitPoint() ;
477 std::vector<EnergyDepositUnit> ionization_points;
478 std::vector<SignalPoint> collection_points;
485 drift(*ssbegin, pixdet, bfield, ionization_points, collection_points);
503 std::vector<int>::const_iterator pu;
504 std::vector<int>::const_iterator pu0 = bunchCrossing.end();
506 for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++pu) {
514 if (pu0!=bunchCrossing.end()) {
515 for (
size_t i=0;
i<3;
i++) {
516 double instlumi = TrueInteractionList.at(
p)*221.95;
517 double instlumi_pow=1.;
521 instlumi_pow*=instlumi;
527 for (
int i=0;
i<3;
i++) {
535 std::vector<PixelDigi>& digis,
537 CLHEP::HepRandomEngine* engine) {
548 int numRows = topol->
nrows();
556 float thePixelThresholdInE = 0.;
588 <<
" PixelDigitizer "
589 << numColumns <<
" " << numRows <<
" " << moduleThickness;
610 make_digis(thePixelThresholdInE, detID, digis, simlinks, tTopo);
613 LogDebug (
"PixelDigitizer") <<
"[SiPixelDigitizerAlgorithm] converted " << digis.size() <<
" PixelDigis in DetUnit" << detID;
624 const float SegmentLength = 0.0010;
631 float length = direction.
mag();
633 int NumberOfSegments = int ( length / SegmentLength);
634 if(NumberOfSegments < 1) NumberOfSegments = 1;
638 <<
" enter primary_ionzation " << NumberOfSegments
646 float* elossVector =
new float[NumberOfSegments];
653 float momentum = hit.
pabs();
656 elossVector, engine);
659 ionization_points.resize( NumberOfSegments);
662 for (
int i = 0;
i != NumberOfSegments;
i++) {
665 float((
i+0.5)/NumberOfSegments) * direction;
673 ionization_points[
i] = edu;
677 <<
i <<
" " << ionization_points[
i].x() <<
" "
678 << ionization_points[
i].y() <<
" "
679 << ionization_points[
i].z() <<
" "
680 << ionization_points[
i].energy();
685 delete[] elossVector;
693 float eloss,
float length,
694 int NumberOfSegs,
float elossVector[],
695 CLHEP::HepRandomEngine* engine)
const {
702 double particleMass = 139.6;
705 if(pid==11) particleMass = 0.511;
706 else if(pid==13) particleMass = 105.7;
707 else if(pid==321) particleMass = 493.7;
708 else if(pid==2212) particleMass = 938.3;
711 float segmentLength = length/NumberOfSegs;
716 double segmentEloss = (1000.*eloss)/NumberOfSegs;
717 for (
int i=0;
i<NumberOfSegs;
i++) {
723 double deltaCutoff =
tMax;
724 de =
fluctuate->SampleFluctuations(
double(particleMomentum*1000.),
725 particleMass, deltaCutoff,
726 double(segmentLength*10.),
727 segmentEloss, engine )/1000.;
735 float ratio = eloss/sum;
737 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= ratio*elossVector[
ii];
739 float averageEloss = eloss/NumberOfSegs;
740 for (
int ii=0;
ii<NumberOfSegs;
ii++) elossVector[
ii]= averageEloss;
751 const std::vector<EnergyDepositUnit>& ionization_points,
752 std::vector<SignalPoint>& collection_points)
const {
755 LogDebug (
"Pixel Digitizer") <<
" enter drift " ;
758 collection_points.resize(ionization_points.size());
761 if(driftDir.
z() ==0.) {
762 LogWarning(
"Magnetic field") <<
" pxlx: drift in z is zero ";
770 float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
774 TanLorenzAngleX = driftDir.
x();
775 TanLorenzAngleY = driftDir.
y();
776 dir_z = driftDir.
z();
777 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
778 CosLorenzAngleY = 1./
sqrt(1.+TanLorenzAngleY*TanLorenzAngleY);
782 TanLorenzAngleX = driftDir.
x();
783 TanLorenzAngleY = 0.;
784 dir_z = driftDir.
z();
785 CosLorenzAngleX = 1./
sqrt(1.+TanLorenzAngleX*TanLorenzAngleX);
786 CosLorenzAngleY = 1.;
792 <<
" Lorentz Tan " << TanLorenzAngleX <<
" " << TanLorenzAngleY <<
" "
793 << CosLorenzAngleX <<
" " << CosLorenzAngleY <<
" "
794 << moduleThickness*TanLorenzAngleX <<
" " << driftDir;
804 for (
unsigned int i = 0;
i != ionization_points.size();
i++) {
806 float SegX, SegY, SegZ;
807 SegX = ionization_points[
i].
x();
808 SegY = ionization_points[
i].y();
809 SegZ = ionization_points[
i].z();
814 DriftDistance = moduleThickness/2. - (dir_z * SegZ);
824 if( DriftDistance < 0.) {
826 }
else if( DriftDistance > moduleThickness )
827 DriftDistance = moduleThickness;
830 float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
831 float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
834 float CloudCenterX = SegX + XDriftDueToMagField;
835 float CloudCenterY = SegY + YDriftDueToMagField;
838 DriftLength =
sqrt( DriftDistance*DriftDistance +
839 XDriftDueToMagField*XDriftDueToMagField +
840 YDriftDueToMagField*YDriftDueToMagField );
846 Sigma_x = Sigma / CosLorenzAngleX ;
847 Sigma_y = Sigma / CosLorenzAngleY ;
850 float energyOnCollector = ionization_points[
i].energy();
858 energyOnCollector = energyOnCollector *
exp( -1*kValue*DriftDistance/moduleThickness );
863 <<
" Dift DistanceZ= "<<DriftDistance<<
" module thickness= "<<moduleThickness
864 <<
" Start Energy= "<<ionization_points[
i].energy()<<
" Energy after loss= "<<energyOnCollector;
867 Sigma_x, Sigma_y, hit.
tof(), energyOnCollector );
870 collection_points[
i] = (sp);
880 const std::vector<SignalPoint>& collection_points) {
891 <<
" enter induce_signal, "
892 << topol->
pitch().first <<
" " << topol->
pitch().second;
896 typedef std::map< int, float, std::less<int> > hit_map_type;
897 hit_map_type hit_signal;
900 std::map<int, float, std::less<int> >
x,
y;
905 for ( std::vector<SignalPoint>::const_iterator
i=collection_points.begin();
906 i != collection_points.end(); ++
i) {
908 float CloudCenterX =
i->position().x();
909 float CloudCenterY =
i->position().y();
910 float SigmaX =
i->sigma_x();
911 float SigmaY =
i->sigma_y();
912 float Charge =
i->amplitude();
923 <<
" cloud " <<
i->position().x() <<
" " <<
i->position().y() <<
" "
924 <<
i->sigma_x() <<
" " <<
i->sigma_y() <<
" " <<
i->amplitude();
947 int IPixRightUpX = int( floor( mp.
x()));
948 int IPixRightUpY = int( floor( mp.
y()));
951 LogDebug (
"Pixel Digitizer") <<
" right-up " << PointRightUp <<
" "
952 << mp.
x() <<
" " << mp.
y() <<
" "
953 << IPixRightUpX <<
" " << IPixRightUpY ;
958 int IPixLeftDownX = int( floor( mp.
x()));
959 int IPixLeftDownY = int( floor( mp.
y()));
962 LogDebug (
"Pixel Digitizer") <<
" left-down " << PointLeftDown <<
" "
963 << mp.
x() <<
" " << mp.
y() <<
" "
964 << IPixLeftDownX <<
" " << IPixLeftDownY ;
969 int numRows = topol->
nrows();
971 IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
972 IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
973 IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
974 IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
981 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
982 float xUB, xLB, UpperBound, LowerBound;
987 if(ix == 0 || SigmaX==0. )
992 LowerBound = 1-
calcQ((xLB-CloudCenterX)/SigmaX);
995 if(ix == numRows-1 || SigmaX==0. )
1000 UpperBound = 1. -
calcQ((xUB-CloudCenterX)/SigmaX);
1003 float TotalIntegrationRange = UpperBound - LowerBound;
1004 x[ix] = TotalIntegrationRange;
1012 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1013 float yUB, yLB, UpperBound, LowerBound;
1015 if(iy == 0 || SigmaY==0.)
1020 LowerBound = 1. -
calcQ((yLB-CloudCenterY)/SigmaY);
1023 if(iy == numColumns-1 || SigmaY==0. )
1028 UpperBound = 1. -
calcQ((yUB-CloudCenterY)/SigmaY);
1031 float TotalIntegrationRange = UpperBound - LowerBound;
1032 y[iy] = TotalIntegrationRange;
1039 for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) {
1040 for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) {
1042 float ChargeFraction = Charge*x[ix]*y[iy];
1044 if( ChargeFraction > 0. ) {
1047 hit_signal[chan] += ChargeFraction;
1057 <<
" pixel " << ix <<
" " << iy <<
" - "<<
" "
1058 << chan <<
" " << ChargeFraction<<
" "
1059 << mp.
x() <<
" " << mp.
y() <<
" "
1060 << lp.
x() <<
" " << lp.
y() <<
" "
1090 for ( hit_map_type::const_iterator im = hit_signal.begin();
1091 im != hit_signal.end(); ++im) {
1092 int chan = (*im).first;
1093 theSignal[chan] += (
makeDigiSimLinks_ ?
Amplitude( (*im).second, &hit, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1098 <<
" pixel " << ip.first <<
" " << ip.second <<
" "
1110 std::vector<PixelDigi>& digis,
1111 std::vector<PixelDigiSimLink>& simlinks,
1115 LogDebug (
"Pixel Digitizer") <<
" make digis "<<
" "
1119 <<
" List pixels passing threshold ";
1124 signalMaps::const_iterator it =
_signal.find(detID);
1133 float signalInElectrons = (*i).second ;
1140 if( signalInElectrons >= thePixelThresholdInE) {
1142 int chan = (*i).first;
1149 int col = ip.second;
1150 adc = int(
missCalibrate(detID, col, row, signalInElectrons));
1170 << (*i).first <<
" " << (*i).second <<
" " << signalInElectrons
1171 <<
" " << adc << ip.first <<
" " << ip.second ;
1175 digis.emplace_back(ip.first, ip.second, adc);
1179 if((*i).second.trackIds().size()>0){
1182 for( std::vector<unsigned int>::const_iterator itid = (*i).second.trackIds().begin();
1183 itid != (*i).second.trackIds().end(); ++itid) {
1184 simi[*itid].push_back((*i).second.individualampl()[il]);
1189 for( simlink_map::iterator simiiter=simi.begin();
1190 simiiter!=simi.end();
1193 float sum_samechannel=0;
1194 for (
unsigned int iii=0;iii<(*simiiter).second.size();iii++){
1195 sum_samechannel+=(*simiiter).second[iii];
1197 float fraction=sum_samechannel/(*i).second;
1198 if(fraction>1.) fraction=1.;
1199 simlinks.emplace_back((*i).first, (*simiiter).first, (*i).second.eventId(), fraction);
1211 float thePixelThreshold,
1212 CLHEP::HepRandomEngine* engine) {
1223 float theSmearedChargeRMS = 0.0;
1229 if((*i).second < 3000)
1231 theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1232 }
else if((*i).second < 6000){
1233 theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1235 theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1239 float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1243 if(((*i).second +
Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1244 (*i).second.set(0);}
1246 (*i).second +=
Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1256 if(((*i).second +
Amplitude(noise, -1.)) < 0. ) {
1257 (*i).second.set(0);}
1269 int numColumns = topol->
ncolumns();
1270 int numRows = topol->
nrows();
1274 int numberOfPixels = (numRows * numColumns);
1275 std::map<int,float, std::less<int> > otherPixels;
1276 std::map<int,float, std::less<int> >::iterator mapI;
1286 <<
" Add noisy pixels " << numRows <<
" "
1289 << otherPixels.size() ;
1293 for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1294 int iy = ((*mapI).first) / numRows;
1295 int ix = ((*mapI).first) - (iy*numRows);
1298 if( iy < 0 || iy > (numColumns-1) )
1299 LogWarning (
"Pixel Geometry") <<
" error in iy " << iy ;
1300 if( ix < 0 || ix > (numRows-1) )
1301 LogWarning (
"Pixel Geometry") <<
" error in ix " << ix ;
1307 <<
" Storing noise = " << (*mapI).first <<
" " << (*mapI).second
1308 <<
" " << ix <<
" " << iy <<
" " << chan ;
1311 if(theSignal[chan] == 0){
1313 int noise=int( (*mapI).second );
1314 theSignal[chan] =
Amplitude (noise, -1.);
1326 CLHEP::HepRandomEngine* engine) {
1333 int numColumns = topol->
ncolumns();
1334 int numRows = topol->
nrows();
1337 float pixelEfficiency = 1.0;
1338 float columnEfficiency = 1.0;
1339 float chipEfficiency = 1.0;
1344 int layerIndex=tTopo->
pxbLayer(detID);
1351 if(numColumns>416)
LogWarning (
"Pixel Geometry") <<
" wrong columns in barrel "<<numColumns;
1352 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in barrel "<<numRows;
1356 if (module<=4) module=5-
module;
1372 if(numColumns>260 || numRows>160) {
1373 if(numColumns>260)
LogWarning (
"Pixel Geometry") <<
" wrong columns in endcaps "<<numColumns;
1374 if(numRows>160)
LogWarning (
"Pixel Geometry") <<
" wrong rows in endcaps "<<numRows;
1381 LogDebug (
"Pixel Digitizer") <<
" enter pixel_inefficiency " << pixelEfficiency <<
" "
1382 << columnEfficiency <<
" " << chipEfficiency;
1387 std::auto_ptr<PixelIndices> pIndexConverter(
new PixelIndices(numColumns,numRows));
1392 std::map<int, int, std::less<int> >chips, columns;
1393 std::map<int, int, std::less<int> >::iterator
iter;
1399 int chan =
i->first;
1402 int col = ip.second;
1404 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1405 int dColInChip = pIndexConverter->DColumn(colROC);
1407 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1410 columns[dColInDet]++;
1414 for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1416 float rand = CLHEP::RandFlat::shoot(engine);
1417 if( rand > chipEfficiency ) chips[iter->first]=0;
1421 for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1423 float rand = CLHEP::RandFlat::shoot(engine);
1424 if( rand > columnEfficiency ) columns[iter->first]=0;
1434 int col = ip.second;
1436 pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1437 int dColInChip = pIndexConverter->DColumn(colROC);
1439 int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1443 float rand = CLHEP::RandFlat::shoot(engine);
1444 if( chips[chipIndex]==0 || columns[dColInDet]==0
1445 || rand>pixelEfficiency ) {
1463 const float signalInElectrons)
const {
1501 newAmp = p3 + p2 * tanh(p0*signal - p1);
1546 const DetId& detId)
const {
1584 dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1585 scale = (1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1590 dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1591 scale = (1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1598 alpha2 = lorentzAngle * lorentzAngle;
1600 dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1601 dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1602 dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1603 scale = (1 + alpha2 * Bfield.z()*Bfield.z() );
1609 LogDebug (
"Pixel Digitizer") <<
" The drift direction in local coordinate is "
1610 << theDriftDirection ;
1613 return theDriftDirection;
1630 int col = ip.second;
1649 Parameters::const_iterator itDeadModules=
DeadModules.begin();
1652 for(; itDeadModules !=
DeadModules.end(); ++itDeadModules){
1653 int Dead_detID = itDeadModules->getParameter<
int>(
"Dead_detID");
1654 if(detid == Dead_detID){
1667 if(Module==
"whole"){
1676 if(Module==
"tbmA" && ip.first>=80 && ip.first<=159){
1680 if( Module==
"tbmB" && ip.first<=79){
1693 std::vector<SiPixelQuality::disabledModuleType>disabledModules =
SiPixelBadModule_->getBadComponentList();
1697 for (
size_t id=0;
id<disabledModules.size();
id++)
1699 if(detID==disabledModules[
id].DetID){
1701 badmodule = disabledModules[id];
1721 std::vector<GlobalPixel> badrocpositions (0);
1722 for(
unsigned int j = 0;
j < 16;
j++){
1725 std::vector<CablingPathToDetUnit>
path =
map_.
product()->pathToDetUnit(detID);
1726 typedef std::vector<CablingPathToDetUnit>::const_iterator
IT;
1727 for (IT it = path.begin(); it != path.end(); ++it) {
1732 badrocpositions.push_back(global);
1743 for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
1744 if(it->row >= 80 && ip.first >= 80 ){
1745 if((fabs(ip.second - it->col) < 26) ) {
i->second.set(0.);}
1746 else if(it->row==120 && ip.second-it->col==26){
i->second.set(0.);}
1747 else if(it->row==119 && it->col-ip.second==26){
i->second.set(0.);}
1749 else if(it->row < 80 && ip.first < 80 ){
1750 if((fabs(ip.second - it->col) < 26) ){
i->second.set(0.);}
1751 else if(it->row==40 && ip.second-it->col==26){
i->second.set(0.);}
1752 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_
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
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.
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
void accumulateSimHits(const std::vector< PSimHit >::const_iterator inputBegin, const std::vector< PSimHit >::const_iterator inputEnd, const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, CLHEP::HepRandomEngine *)
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 *)