CMS 3D CMS Logo

SiPixelDigitizerAlgorithm.cc
Go to the documentation of this file.
1 //class SiPixelDigitizerAlgorithm SimTracker/SiPixelDigitizer/src/SiPixelDigitizerAlgoithm.cc
2 
3 // Original Author Danek Kotlinski
4 // Ported in CMSSW by Michele Pioppi-INFN perugia
5 // Added DB capabilities by F.Blekman, Cornell University
6 // Created: Mon Sep 26 11:08:32 CEST 2005
7 // Add tof, change AddNoise to tracked. 4/06
8 // Change drift direction. 6/06 d.k.
9 // Add the statuis (non-rate dependent) inefficiency.
10 // -1 - no ineffciency
11 // 0 - static inefficency only
12 // 1,2 - low-lumi rate dependent inefficency added
13 // 10 - high-lumi inefficiency added
14 // Adopt the correct drift sign convetion from Morris Swartz. d.k. 8/06
15 // Add more complex misscalinbration, change kev/e to 3.61, diff=3.7,d.k.9/06
16 // Add the readout channel electronic noise. d.k. 3/07
17 // Lower the pixel noise from 500 to 175elec.
18 // Change the input threshold from noise units to electrons.
19 // Lower the amount of static dead pixels from 0.01 to 0.001.
20 // Modify to the new random number services. d.k. 5/07
21 // Protect against sigma=0 (delta tracks on the surface). d.k.5/07
22 // Change the TOF cut to lower and upper limit. d.k. 7/07
23 //
24 // July 2008: Split Lorentz Angle configuration in BPix/FPix (V. Cuplov)
25 // tanLorentzAngleperTesla_FPix=0.0912 and tanLorentzAngleperTesla_BPix=0.106
26 // Sept. 2008: Disable Pixel modules which are declared dead in the configuration python file. (V. Cuplov)
27 // Oct. 2008: Accessing/Reading the Lorentz angle from the DataBase instead of the cfg file. (V. Cuplov)
28 // Accessing dead modules from the DB. Implementation done and tested on a test.db
29 // Do not use this option for now. The PixelQuality Objects are not in the official DB yet.
30 // Feb. 2009: Split Fpix and Bpix threshold and use official numbers (V. Cuplov)
31 // ThresholdInElectrons_FPix = 2870 and ThresholdInElectrons_BPix = 3700
32 // update the electron to VCAL conversion using: VCAL_electrons = VCAL * 65.5 - 414
33 // Feb. 2009: Threshold gaussian smearing (V. Cuplov)
34 // March, 2009: changed DB access to *SimRcd objects (to de-couple the DB objects from reco chain) (F. Blekman)
35 // May, 2009: Pixel charge VCAL smearing. (V. Cuplov)
36 // November, 2009: new parameterization of the pixel response. (V. Cuplov)
37 // December, 2009: Fix issue with different compilers.
38 // October, 2010: Improvement: Removing single dead ROC (V. Cuplov)
39 // November, 2010: Bug fix in removing TBMB/A half-modules (V. Cuplov)
40 // February, 2011: Time improvement in DriftDirection() (J. Bashir Butt)
41 // June, 2011: Bug Fix for pixels on ROC edges in module_killing_DB() (J. Bashir Butt)
42 #include <iostream>
43 
45 
51 
52 #include <gsl/gsl_sf_erf.h>
54 #include "CLHEP/Random/RandGaussQ.h"
55 #include "CLHEP/Random/RandFlat.h"
56 
57 //#include "PixelIndices.h"
61 
67 
68 // Accessing dead pixel modules from the DB:
70 
72 
87 
94 
95 // Geometry
100 
102 
103 using namespace edm;
104 using namespace sipixelobjects;
105 
106 #define TP_DEBUG // protect all LogDebug with ifdef. Takes too much CPU
107 
108 
110  if(use_ineff_from_db_){// load gain calibration service fromdb...
111  theSiPixelGainCalibrationService_->setESObjects( es );
112  }
113  if(use_deadmodule_DB_) {
114  es.get<SiPixelQualityRcd>().get(SiPixelBadModule_);
115  }
116  if(use_LorentzAngle_DB_) {
117  // Get Lorentz angle from DB record
118  es.get<SiPixelLorentzAngleSimRcd>().get(SiPixelLorentzAngle_);
119  }
120  //gets the map and geometry from the DB (to kill ROCs)
121  es.get<SiPixelFedCablingMapRcd>().get(map_);
122  es.get<TrackerDigiGeometryRecord>().get(geom_);
123 }
124 
125 //=========================================================================
126 
128 
129  _signal(),
130  makeDigiSimLinks_(conf.getUntrackedParameter<bool>("makeDigiSimLinks", true)),
131  use_ineff_from_db_(conf.getParameter<bool>("useDB")),
132  use_module_killing_(conf.getParameter<bool>("killModules")), // boolean to kill or not modules
133  use_deadmodule_DB_(conf.getParameter<bool>("DeadModules_DB")), // boolean to access dead modules from DB
134  use_LorentzAngle_DB_(conf.getParameter<bool>("LorentzAngle_DB")), // boolean to access Lorentz angle from DB
135 
136  DeadModules(use_deadmodule_DB_ ? Parameters() : conf.getParameter<Parameters>("DeadModules")), // get dead module from cfg file
137 
138  // Common pixel parameters
139  // These are parameters which are not likely to be changed
140  GeVperElectron(3.61E-09), // 1 electron(3.61eV, 1keV(277e, mod 9/06 d.k.
141  Sigma0(0.00037), // Charge diffusion constant 7->3.7
142  Dist300(0.0300), // normalized to 300micron Silicon
143  alpha2Order(conf.getParameter<bool>("Alpha2Order")), // switch on/off of E.B effect
144  ClusterWidth(3.), // Charge integration spread on the collection plane
145 
146  // get external parameters:
147  // To account for upgrade geometries do not assume the number
148  // of layers or disks.
149  NumberOfBarrelLayers(conf.exists("NumPixelBarrel")?conf.getParameter<int>("NumPixelBarrel"):3),
150  NumberOfEndcapDisks(conf.exists("NumPixelEndcap")?conf.getParameter<int>("NumPixelEndcap"):2),
151 
152  // ADC calibration 1adc count(135e.
153  // Corresponds to 2adc/kev, 270[e/kev]/135[e/adc](2[adc/kev]
154  // Be carefull, this parameter is also used in SiPixelDet.cc to
155  // calculate the noise in adc counts from noise in electrons.
156  // Both defaults should be the same.
157  theElectronPerADC(conf.getParameter<double>("ElectronPerAdc")),
158 
159  // ADC saturation value, 255(8bit adc.
160  //theAdcFullScale(conf.getUntrackedParameter<int>("AdcFullScale",255)),
161  theAdcFullScale(conf.getParameter<int>("AdcFullScale")),
162  theAdcFullScaleStack(conf.exists("AdcFullScaleStack")?conf.getParameter<int>("AdcFullScaleStack"):255),
163 
164  // Noise in electrons:
165  // Pixel cell noise, relevant for generating noisy pixels
166  theNoiseInElectrons(conf.getParameter<double>("NoiseInElectrons")),
167 
168  // Fill readout noise, including all readout chain, relevant for smearing
169  //theReadoutNoise(conf.getUntrackedParameter<double>("ReadoutNoiseInElec",500.)),
170  theReadoutNoise(conf.getParameter<double>("ReadoutNoiseInElec")),
171 
172  // Pixel threshold in units of noise:
173  // thePixelThreshold(conf.getParameter<double>("ThresholdInNoiseUnits")),
174  // Pixel threshold in electron units.
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),
178 
179  // Add threshold gaussian smearing:
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),
183 
184  // electrons to VCAL conversion needed in misscalibrate()
185  electronsPerVCAL(conf.getParameter<double>("ElectronsPerVcal")),
186  electronsPerVCAL_Offset(conf.getParameter<double>("ElectronsPerVcal_Offset")),
187 
188  //theTofCut 12.5, cut in particle TOD +/- 12.5ns
189  //theTofCut(conf.getUntrackedParameter<double>("TofCut",12.5)),
190  theTofLowerCut(conf.getParameter<double>("TofLowerCut")),
191  theTofUpperCut(conf.getParameter<double>("TofUpperCut")),
192 
193  // Get the Lorentz angle from the cfg file:
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")),
196 
197  // signal response new parameterization: split Fpix and 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")),
202 
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")),
207 
208  // Add noise
209  addNoise(conf.getParameter<bool>("AddNoise")),
210 
211  // Smear the pixel charge with a gaussian which RMS is a function of the
212  // pixel charge (Danek's study)
213  addChargeVCALSmearing(conf.getParameter<bool>("ChargeVCALSmearing")),
214 
215  // Add noisy pixels
216  addNoisyPixels(conf.getParameter<bool>("AddNoisyPixels")),
217 
218  // Fluctuate charge in track subsegments
219  fluctuateCharge(conf.getUntrackedParameter<bool>("FluctuateCharge",true)),
220 
221  // Control the pixel inefficiency
222  AddPixelInefficiency(conf.getParameter<bool>("AddPixelInefficiency")),
223 
224  // Add threshold gaussian smearing:
225  addThresholdSmearing(conf.getParameter<bool>("AddThresholdSmearing")),
226 
227  // Get the constants for the miss-calibration studies
228  doMissCalibrate(conf.getParameter<bool>("MissCalibrate")), // Enable miss-calibration
229  theGainSmearing(conf.getParameter<double>("GainSmearing")), // sigma of the gain smearing
230  theOffsetSmearing(conf.getParameter<double>("OffsetSmearing")), //sigma of the offset smearing
231 
232  // Add pixel radiation damage for upgrade studies
233  AddPixelAging(conf.getParameter<bool>("DoPixelAging")),
234 
235  // delta cutoff in MeV, has to be same as in OSCAR(0.030/cmsim=1.0 MeV
236  //tMax(0.030), // In MeV.
237  //tMax(conf.getUntrackedParameter<double>("deltaProductionCut",0.030)),
238  tMax(conf.getParameter<double>("deltaProductionCut")),
239 
240  fluctuate(fluctuateCharge ? new SiG4UniversalFluctuation() : 0),
241  theNoiser(addNoise ? new GaussianTailNoiseGenerator() : 0),
242  calmap(doMissCalibrate ? initCal() : std::map<int,CalParameters,std::less<int> >()),
243  theSiPixelGainCalibrationService_(use_ineff_from_db_ ? new SiPixelGainCalibrationOfflineSimService(conf) : 0),
244  pixelEfficiencies_(conf, AddPixelInefficiency,NumberOfBarrelLayers,NumberOfEndcapDisks),
245  pixelAging_(conf,AddPixelAging,NumberOfBarrelLayers,NumberOfEndcapDisks)
246 {
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 = "
256  <<" " << theElectronPerADC << " " << theAdcFullScale
257  << " The delta cut-off is set to " << tMax
258  << " pix-inefficiency "<<AddPixelInefficiency;
259 
260 }
261 
262 std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> >
264 
265  using std::cerr;
266  using std::cout;
267  using std::endl;
268 
269  std::map<int, SiPixelDigitizerAlgorithm::CalParameters, std::less<int> > calmap;
270  // Prepare for the analog amplitude miss-calibration
271  LogDebug ("PixelDigitizer ")
272  << " miss-calibrate the pixel amplitude ";
273 
274  const bool ReadCalParameters = false;
275  if(ReadCalParameters) { // Read the calibration files from file
276  // read the calibration constants from a file (testing only)
277  std::ifstream in_file; // data file pointer
278  char filename[80] = "phCalibrationFit_C0.dat";
279 
280  in_file.open(filename, std::ios::in ); // in C++
281  if(in_file.bad()) {
282  cout << " File not found " << endl;
283  return calmap; // signal error
284  }
285  cout << " file opened : " << filename << endl;
286 
287  char line[500];
288  for (int i = 0; i < 3; i++) {
289  in_file.getline(line, 500,'\n');
290  cout<<line<<endl;
291  }
292 
293  cout << " test map" << endl;
294 
295  float par0,par1,par2,par3;
296  int colid,rowid;
298  // Read MC tracks
299  for(int i=0;i<(52*80);i++) { // loop over tracks
300  in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid >> rowid;
301  if(in_file.bad()) { // check for errors
302  cerr << "Cannot read data file" << endl;
303  return calmap;
304  }
305  if( in_file.eof() != 0 ) {
306  cerr << in_file.eof() << " " << in_file.gcount() << " "
307  << in_file.fail() << " " << in_file.good() << " end of file "
308  << endl;
309  return calmap;
310  }
311 
312  //cout << " line " << i << " " <<par0<<" "<<par1<<" "<<par2<<" "<<par3<<" "
313  // <<colid<<" "<<rowid<<endl;
314 
315  CalParameters onePix;
316  onePix.p0=par0;
317  onePix.p1=par1;
318  onePix.p2=par2;
319  onePix.p3=par3;
320 
321  // Convert ROC pixel index to channel
322  int chan = PixelIndices::pixelToChannelROC(rowid,colid);
323  calmap.insert(std::pair<int,CalParameters>(chan,onePix));
324 
325  // Testing the index conversion, can be skipped
326  std::pair<int,int> p = PixelIndices::channelToPixelROC(chan);
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;
329 
330  } // pixel loop in a ROC
331 
332  cout << " map size " << calmap.size() <<" max "<<calmap.max_size() << " "
333  <<calmap.empty()<< endl;
334 
335 // cout << " map size " << calmap.size() << endl;
336 // map<int,CalParameters,std::less<int> >::iterator ix,it;
337 // map<int,CalParameters,std::less<int> >::const_iterator ip;
338 // for (ix = calmap.begin(); ix != calmap.end(); ++ix) {
339 // int i = (*ix).first;
340 // std::pair<int,int> p = channelToPixelROC(i);
341 // it = calmap.find(i);
342 // CalParameters y = (*it).second;
343 // CalParameters z = (*ix).second;
344 // cout << i <<" "<<p.first<<" "<<p.second<<" "<<y.p0<<" "<<z.p0<<" "<<calmap[i].p0<<endl;
345 
346 // //int dummy=0;
347 // //cin>>dummy;
348 // }
349 
350  } // end if readparameters
351  return calmap;
352 } // end initCal()
353 
354 //=========================================================================
356  LogDebug ("PixelDigitizer")<<"SiPixelDigitizerAlgorithm deleted";
357 }
358 
359 // Read DynIneff Scale factors from Configuration
361  // pixel inefficiency
362  // Don't use Hard coded values, read inefficiencies in from DB/python config or don't use any
363  int NumberOfTotLayers = NumberOfBarrelLayers + NumberOfEndcapDisks;
364  FPixIndex=NumberOfBarrelLayers;
365  if (AddPixelInefficiency){
366  FromConfig =
367  conf.exists("thePixelColEfficiency_BPix1") && conf.exists("thePixelColEfficiency_BPix2") && conf.exists("thePixelColEfficiency_BPix3") &&
368  conf.exists("thePixelColEfficiency_FPix1") && conf.exists("thePixelColEfficiency_FPix2") &&
369  conf.exists("thePixelEfficiency_BPix1") && conf.exists("thePixelEfficiency_BPix2") && conf.exists("thePixelEfficiency_BPix3") &&
370  conf.exists("thePixelEfficiency_FPix1") && conf.exists("thePixelEfficiency_FPix2") &&
371  conf.exists("thePixelChipEfficiency_BPix1") && conf.exists("thePixelChipEfficiency_BPix2") && conf.exists("thePixelChipEfficiency_BPix3") &&
372  conf.exists("thePixelChipEfficiency_FPix1") && conf.exists("thePixelChipEfficiency_FPix2");
373  if (NumberOfBarrelLayers==3) FromConfig = FromConfig && conf.exists("theLadderEfficiency_BPix1") && conf.exists("theLadderEfficiency_BPix2") && conf.exists("theLadderEfficiency_BPix3") &&
374  conf.exists("theModuleEfficiency_BPix1") && conf.exists("theModuleEfficiency_BPix2") && conf.exists("theModuleEfficiency_BPix3") &&
375  conf.exists("thePUEfficiency_BPix1") && conf.exists("thePUEfficiency_BPix2") && conf.exists("thePUEfficiency_BPix3") &&
376  conf.exists("theInnerEfficiency_FPix1") && conf.exists("theInnerEfficiency_FPix2") &&
377  conf.exists("theOuterEfficiency_FPix1") && conf.exists("theOuterEfficiency_FPix2") &&
378  conf.exists("thePUEfficiency_FPix_Inner") && conf.exists("thePUEfficiency_FPix_Outer") &&
379  conf.exists("theInstLumiScaleFactor");
380  if (NumberOfBarrelLayers>=4) FromConfig = FromConfig && conf.exists("thePixelColEfficiency_BPix4") &&
381  conf.exists("thePixelEfficiency_BPix4") && conf.exists("thePixelChipEfficiency_BPix4");
382  if (NumberOfEndcapDisks>=3) FromConfig = FromConfig && conf.exists("thePixelColEfficiency_FPix4") &&
383  conf.exists("thePixelEfficiency_FPix3") && conf.exists("thePixelChipEfficiency_FPix3");
384  if (FromConfig) {
385  LogInfo ("PixelDigitizer ") <<"The PixelDigitizer inefficiency configuration is read from the config file.\n";
386  theInstLumiScaleFactor = conf.getParameter<double>("theInstLumiScaleFactor");
387  int i=0;
388  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix1");
389  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix2");
390  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix3");
391  if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix4");}
392  //
393  i=0;
394  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix1");
395  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix2");
396  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix3");
397  if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix4");}
398  //
399  i=0;
400  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix1");
401  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix2");
402  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix3");
403  if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix4");}
404  //
405  if (NumberOfBarrelLayers==3){
406  i=0;
407  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix1");
408  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix2");
409  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix3");
410  if ( ((theLadderEfficiency_BPix[0].size()!=20) || (theLadderEfficiency_BPix[1].size()!=32) ||
411  (theLadderEfficiency_BPix[2].size()!=44)) && (NumberOfBarrelLayers==3) )
412  throw cms::Exception("Configuration") << "Wrong ladder number in efficiency config!";
413  //
414  i=0;
415  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix1");
416  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix2");
417  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix3");
418  if ( ((theModuleEfficiency_BPix[0].size()!=4) || (theModuleEfficiency_BPix[1].size()!=4) ||
419  (theModuleEfficiency_BPix[2].size()!=4)) && (NumberOfBarrelLayers==3) )
420  throw cms::Exception("Configuration") << "Wrong module number in efficiency config!";
421  //
422  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_BPix1"));
423  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_BPix2"));
424  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_BPix3"));
425  if ( ((thePUEfficiency[0].size()==0) || (thePUEfficiency[1].size()==0) ||
426  (thePUEfficiency[2].size()==0)) && (NumberOfBarrelLayers==3) )
427  throw cms::Exception("Configuration") << "At least one PU efficiency (BPix) number is needed in efficiency config!";
428  }
429  // The next is needed for Phase2 Tracker studies
430  if (NumberOfBarrelLayers>=5){
431  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
432  // For Phase2 tracker layers just set the outermost BPix inefficiency to 99.9% THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
433  for (int j=5 ; j<=NumberOfBarrelLayers ; j++){
434  thePixelColEfficiency[j-1]=0.999;
435  thePixelEfficiency[j-1]=0.999;
436  thePixelChipEfficiency[j-1]=0.999;
437  }
438  }
439  //
440  i=FPixIndex;
441  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_FPix1");
442  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_FPix2");
443  if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_FPix3");}
444  i=FPixIndex;
445  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_FPix1");
446  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_FPix2");
447  if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_FPix3");}
448  i=FPixIndex;
449  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_FPix1");
450  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_FPix2");
451  if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_FPix3");}
452  // The next is needed for Phase2 Tracker studies
453  if (NumberOfEndcapDisks>=4){
454  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
455  // For Phase2 tracker layers just set the extra FPix disk inefficiency to 99.9% THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
456  for (int j=4+FPixIndex ; j<=NumberOfEndcapDisks+NumberOfBarrelLayers ; j++){
457  thePixelColEfficiency[j-1]=0.999;
458  thePixelEfficiency[j-1]=0.999;
459  thePixelChipEfficiency[j-1]=0.999;
460  }
461  }
462  //FPix Dynamic Inefficiency
463  if (NumberOfBarrelLayers==3){
464  i=FPixIndex;
465  theInnerEfficiency_FPix[i++] = conf.getParameter<double>("theInnerEfficiency_FPix1");
466  theInnerEfficiency_FPix[i++] = conf.getParameter<double>("theInnerEfficiency_FPix2");
467  i=FPixIndex;
468  theOuterEfficiency_FPix[i++] = conf.getParameter<double>("theOuterEfficiency_FPix1");
469  theOuterEfficiency_FPix[i++] = conf.getParameter<double>("theOuterEfficiency_FPix2");
470  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_FPix_Inner"));
471  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_FPix_Outer"));
472  if ( ((thePUEfficiency[3].size()==0) || (thePUEfficiency[4].size()==0)) && (NumberOfEndcapDisks==2) )
473  throw cms::Exception("Configuration") << "At least one (FPix) PU efficiency number is needed in efficiency config!";
474  pu_scale.resize(thePUEfficiency.size());
475  }
476  }
477  else LogInfo ("PixelDigitizer ") <<"The PixelDigitizer inefficiency configuration is read from the database.\n";
478  }
479  // the first "NumberOfBarrelLayers" settings [0],[1], ... , [NumberOfBarrelLayers-1] are for the barrel pixels
480  // the next "NumberOfEndcapDisks" settings [NumberOfBarrelLayers],[NumberOfBarrelLayers+1], ... [NumberOfEndcapDisks+NumberOfBarrelLayers-1]
481 }
482 
483 // Read DynIneff Scale factors from DB
486  if (bunchspace == 50) es.get<SiPixelDynamicInefficiencyRcd>().get("50ns",SiPixelDynamicInefficiency_);
489  }
490 }
491 
493 
494  theInstLumiScaleFactor = SiPixelDynamicInefficiency->gettheInstLumiScaleFactor();
495  const std::map<uint32_t, double>& PixelGeomFactorsDB = SiPixelDynamicInefficiency->getPixelGeomFactors();
496  const std::map<uint32_t, double>& ColGeomFactorsDB = SiPixelDynamicInefficiency->getColGeomFactors();
497  const std::map<uint32_t, double>& ChipGeomFactorsDB = SiPixelDynamicInefficiency->getChipGeomFactors();
498  const std::map<uint32_t, std::vector<double> >& PUFactors = SiPixelDynamicInefficiency->getPUFactors();
499  std::vector<uint32_t > DetIdmasks = SiPixelDynamicInefficiency->getDetIdmasks();
500 
501  // Loop on all modules, calculate geometrical scale factors and store in map for easy access
502  for(TrackerGeometry::DetUnitContainer::const_iterator it_module = geom->detUnits().begin(); it_module != geom->detUnits().end(); it_module++) {
503  if( dynamic_cast<PixelGeomDetUnit const*>((*it_module))==0) continue;
504  const DetId detid = (*it_module)->geographicalId();
505  uint32_t rawid = detid.rawId();
506  PixelGeomFactors[rawid] = 1;
507  ColGeomFactors[rawid] = 1;
508  ChipGeomFactors[rawid] = 1;
509  for (auto db_factor : PixelGeomFactorsDB) if (matches(detid, DetId(db_factor.first), DetIdmasks)) PixelGeomFactors[rawid] *= db_factor.second;
510  for (auto db_factor : ColGeomFactorsDB) if (matches(detid, DetId(db_factor.first), DetIdmasks)) ColGeomFactors[rawid] *= db_factor.second;
511  for (auto db_factor : ChipGeomFactorsDB) if (matches(detid, DetId(db_factor.first), DetIdmasks)) ChipGeomFactors[rawid] *= db_factor.second;
512  }
513 
514  // piluep scale factors are calculated once per event
515  // therefore vector index is stored in a map for each module that matches to a db_id
516  size_t i=0;
517  for (auto factor : PUFactors) {
518  const DetId db_id = DetId(factor.first);
519  for(TrackerGeometry::DetUnitContainer::const_iterator it_module = geom->detUnits().begin(); it_module != geom->detUnits().end(); it_module++) {
520  if( dynamic_cast<PixelGeomDetUnit const*>((*it_module))==0) continue;
521  const DetId detid = (*it_module)->geographicalId();
522  if (!matches(detid, db_id, DetIdmasks)) continue;
523  if (iPU.count(detid.rawId())) {
524  throw cms::Exception("Database")<<"Multiple db_ids match to same module in SiPixelDynamicInefficiency DB Object";
525  } else {
526  iPU[detid.rawId()] = i;
527  }
528  }
529  thePUEfficiency.push_back(factor.second);
530  ++i;
531  }
532  pu_scale.resize(thePUEfficiency.size());
533 }
534 
535 bool SiPixelDigitizerAlgorithm::PixelEfficiencies::matches(const DetId& detid, const DetId& db_id, const std::vector<uint32_t >& DetIdmasks) {
536  if (detid.subdetId() != db_id.subdetId()) return false;
537  for (size_t i=0; i<DetIdmasks.size(); ++i) {
538  DetId maskid = DetId(DetIdmasks.at(i));
539  if (maskid.subdetId() != db_id.subdetId()) continue;
540  if ((detid.rawId()&maskid.rawId()) != (db_id.rawId()&maskid.rawId()) &&
541  (db_id.rawId()&maskid.rawId()) != DetId(db_id.det(), db_id.subdetId()).rawId()) return false;
542  }
543  return true;
544 }
545 
547  // pixel aging
548  // Don't use Hard coded values, read aging in from python or don't use any
549  if(AddAging) {
550  int NumberOfTotLayers = NumberOfBarrelLayers + NumberOfEndcapDisks;
551  FPixIndex=NumberOfBarrelLayers;
552 
553  int i=0;
554  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_BPix1");
555  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_BPix2");
556  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_BPix3");
557  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_BPix4");
558 
559  // to be removed when Gaelle will have the phase2 digitizer
560  if (NumberOfBarrelLayers>=5){
561  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
562  // For Phase2 tracker layers just set the outermost BPix aging 0.
563  for (int j=5 ; j<=NumberOfBarrelLayers ; j++){
564  thePixelPseudoRadDamage[j-1]=0.;
565  }
566  }
567  //
568  i=FPixIndex;
569  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_FPix1");
570  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_FPix2");
571  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_FPix3");
572 
573  //To be removed when Phase2 digitizer will be available
574  if (NumberOfEndcapDisks>=4){
575  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
576  // For Phase2 tracker layers just set the extra FPix disk aging to 0. BE CAREFUL THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
577  for (int j=4+FPixIndex ; j<=NumberOfEndcapDisks+NumberOfBarrelLayers ; j++){
578  thePixelPseudoRadDamage[j-1]=0.;
579  }
580  }
581  }
582  // the first "NumberOfBarrelLayers" settings [0],[1], ... , [NumberOfBarrelLayers-1] are for the barrel pixels
583  // the next "NumberOfEndcapDisks" settings [NumberOfBarrelLayers],[NumberOfBarrelLayers+1], ... [NumberOfEndcapDisks+NumberOfBarrelLayers-1]
584 }
585 
586 //=========================================================================
587 void SiPixelDigitizerAlgorithm::accumulateSimHits(std::vector<PSimHit>::const_iterator inputBegin,
588  std::vector<PSimHit>::const_iterator inputEnd,
589  const size_t inputBeginGlobalIndex,
590  const unsigned int tofBin,
591  const PixelGeomDetUnit* pixdet,
592  const GlobalVector& bfield,
593  const TrackerTopology *tTopo,
594  CLHEP::HepRandomEngine* engine) {
595  // produce SignalPoint's for all SimHit's in detector
596  // Loop over hits
597 
598  uint32_t detId = pixdet->geographicalId().rawId();
599  size_t simHitGlobalIndex=inputBeginGlobalIndex; // This needs to stored to create the digi-sim link later
600  for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
601  // skip hits not in this detector.
602  if((*ssbegin).detUnitId() != detId) {
603  continue;
604  }
605 
606 #ifdef TP_DEBUG
607  LogDebug ("Pixel Digitizer")
608  << (*ssbegin).particleType() << " " << (*ssbegin).pabs() << " "
609  << (*ssbegin).energyLoss() << " " << (*ssbegin).tof() << " "
610  << (*ssbegin).trackId() << " " << (*ssbegin).processType() << " "
611  << (*ssbegin).detUnitId()
612  << (*ssbegin).entryPoint() << " " << (*ssbegin).exitPoint() ;
613 #endif
614 
615 
616  std::vector<EnergyDepositUnit> ionization_points;
617  std::vector<SignalPoint> collection_points;
618 
619  // fill collection_points for this SimHit, indpendent of topology
620  // Check the TOF cut
621  if ( ((*ssbegin).tof() - pixdet->surface().toGlobal((*ssbegin).localPosition()).mag()/30.)>= theTofLowerCut &&
622  ((*ssbegin).tof()- pixdet->surface().toGlobal((*ssbegin).localPosition()).mag()/30.) <= theTofUpperCut ) {
623  primary_ionization(*ssbegin, ionization_points, engine); // fills _ionization_points
624  drift(*ssbegin, pixdet, bfield, tTopo, ionization_points, collection_points); // transforms _ionization_points to collection_points
625  // compute induced signal on readout elements and add to _signal
626  induce_signal(*ssbegin, simHitGlobalIndex, tofBin, pixdet, collection_points); // 1st 3 args needed only for SimHit<-->Digi link
627  } // end if
628  } // end for
629 
630 }
631 
632 //============================================================================
634  //Instlumi scalefactor calculating for dynamic inefficiency
635 
636  if (puInfo) {
637  const std::vector<int> bunchCrossing = puInfo->getMix_bunchCrossing();
638  const std::vector<float> TrueInteractionList = puInfo->getMix_TrueInteractions();
639  //const int bunchSpacing = puInfo->getMix_bunchSpacing();
640 
641  int pui = 0, p = 0;
642  std::vector<int>::const_iterator pu;
643  std::vector<int>::const_iterator pu0 = bunchCrossing.end();
644 
645  for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++pu) {
646  if (*pu==0) {
647  pu0 = pu;
648  p = pui;
649  }
650  pui++;
651  }
652  if (pu0!=bunchCrossing.end()) {
653  for (size_t i=0, n = pixelEfficiencies_.thePUEfficiency.size(); i<n; i++) {
654  double instlumi = TrueInteractionList.at(p)*pixelEfficiencies_.theInstLumiScaleFactor;
655  double instlumi_pow=1.;
657  for (size_t j=0; j<pixelEfficiencies_.thePUEfficiency[i].size(); j++){
659  instlumi_pow*=instlumi;
660  }
661  }
662  }
663  }
664  else {
665  for (int i=0, n = pixelEfficiencies_.thePUEfficiency.size(); i<n; i++) {
667  }
668  }
669 }
670 
671 //============================================================================
673  std::vector<PixelDigi>& digis,
674  std::vector<PixelDigiSimLink>& simlinks,
675  const TrackerTopology *tTopo,
676  CLHEP::HepRandomEngine* engine) {
677 
678  // Pixel Efficiency moved from the constructor to this method because
679  // the information of the det are not available in the constructor
680  // Efficiency parameters. 0 - no inefficiency, 1-low lumi, 10-high lumi
681 
682  uint32_t detID = pixdet->geographicalId().rawId();
683  const signal_map_type& theSignal = _signal[detID];
684 
685  const PixelTopology* topol=&pixdet->specificTopology();
686  int numColumns = topol->ncolumns(); // det module number of cols&rows
687  int numRows = topol->nrows();
688 
689  // Noise already defined in electrons
690  // thePixelThresholdInE = thePixelThreshold * theNoiseInElectrons ;
691  // Find the threshold in noise units, needed for the noiser.
692 
693 
694  float thePixelThresholdInE = 0.;
695 
696  if(theNoiseInElectrons>0.){
697  if(pixdet->type().isTrackerPixel() && pixdet->type().isBarrel()){ // Barrel modules
698  int lay = tTopo->layer(detID);
701  thePixelThresholdInE = CLHEP::RandGaussQ::shoot(engine, theThresholdInE_BPix_L1, theThresholdSmearing_BPix_L1); // gaussian smearing
702  } else {
703  thePixelThresholdInE = CLHEP::RandGaussQ::shoot(engine, theThresholdInE_BPix , theThresholdSmearing_BPix); // gaussian smearing
704  }
705  } else {
707  thePixelThresholdInE = theThresholdInE_BPix_L1;
708  } else {
709  thePixelThresholdInE = theThresholdInE_BPix; // no smearing
710  }
711  }
712  } else if(pixdet->type().isTrackerPixel()) { // Forward disks modules
714  thePixelThresholdInE = CLHEP::RandGaussQ::shoot(engine, theThresholdInE_FPix, theThresholdSmearing_FPix); // gaussian smearing
715  } else {
716  thePixelThresholdInE = theThresholdInE_FPix; // no smearing
717  }
718  }
719  else {throw cms::Exception("NotAPixelGeomDetUnit") << "Not a pixel geomdet unit" << detID;}
720  }
721 
722 
723 #ifdef TP_DEBUG
724  // full detector thickness
725  float moduleThickness = pixdet->specificSurface().bounds().thickness();
726  LogDebug ("PixelDigitizer")
727  << " PixelDigitizer "
728  << numColumns << " " << numRows << " " << moduleThickness;
729 #endif
730 
731  if(addNoise) add_noise(pixdet, thePixelThresholdInE/theNoiseInElectrons, engine); // generate noise
732 
733  // Do only if needed
734 
735  if((AddPixelInefficiency) && (theSignal.size()>0))
736  pixel_inefficiency(pixelEfficiencies_, pixdet, tTopo, engine); // Kill some pixels
737 
738  if(use_ineff_from_db_ && (theSignal.size()>0))
739  pixel_inefficiency_db(detID);
740 
741  if(use_module_killing_) {
742  if (use_deadmodule_DB_) { // remove dead modules using DB
743  module_killing_DB(detID);
744  } else { // remove dead modules using the list in cfg file
745  module_killing_conf(detID);
746  }
747  }
748 
749  make_digis(thePixelThresholdInE, detID, pixdet, digis, simlinks, tTopo);
750 
751 #ifdef TP_DEBUG
752  LogDebug ("PixelDigitizer") << "[SiPixelDigitizerAlgorithm] converted " << digis.size() << " PixelDigis in DetUnit" << detID;
753 #endif
754 }
755 
756 //***********************************************************************/
757 // Generate primary ionization along the track segment.
758 // Divide the track into small sub-segments
759 void SiPixelDigitizerAlgorithm::primary_ionization(const PSimHit& hit, std::vector<EnergyDepositUnit>& ionization_points, CLHEP::HepRandomEngine* engine) const {
760 
761  // Straight line approximation for trajectory inside active media
762 
763  const float SegmentLength = 0.0010; //10microns in cm
764  float energy;
765 
766  // Get the 3D segment direction vector
767  LocalVector direction = hit.exitPoint() - hit.entryPoint();
768 
769  float eLoss = hit.energyLoss(); // Eloss in GeV
770  float length = direction.mag(); // Track length in Silicon
771 
772  int NumberOfSegments = int ( length / SegmentLength); // Number of segments
773  if(NumberOfSegments < 1) NumberOfSegments = 1;
774 
775 #ifdef TP_DEBUG
776  LogDebug ("Pixel Digitizer")
777  << " enter primary_ionzation " << NumberOfSegments
778  << " shift = "
779  << (hit.exitPoint().x()-hit.entryPoint().x()) << " "
780  << (hit.exitPoint().y()-hit.entryPoint().y()) << " "
781  << (hit.exitPoint().z()-hit.entryPoint().z()) << " "
782  << hit.particleType() <<" "<< hit.pabs() ;
783 #endif
784 
785  float* elossVector = new float[NumberOfSegments]; // Eloss vector
786 
787  if( fluctuateCharge ) {
788  //MP DA RIMUOVERE ASSOLUTAMENTE
789  int pid = hit.particleType();
790  //int pid=211; // assume it is a pion
791 
792  float momentum = hit.pabs();
793  // Generate fluctuated charge points
794  fluctuateEloss(pid, momentum, eLoss, length, NumberOfSegments,
795  elossVector, engine);
796  }
797 
798  ionization_points.resize( NumberOfSegments); // set size
799 
800  // loop over segments
801  for ( int i = 0; i != NumberOfSegments; i++) {
802  // Divide the segment into equal length subsegments
803  Local3DPoint point = hit.entryPoint() +
804  float((i+0.5)/NumberOfSegments) * direction;
805 
806  if( fluctuateCharge )
807  energy = elossVector[i]/GeVperElectron; // Convert charge to elec.
808  else
809  energy = hit.energyLoss()/GeVperElectron/float(NumberOfSegments);
810 
811  EnergyDepositUnit edu( energy, point); //define position,energy point
812  ionization_points[i] = edu; // save
813 
814 #ifdef TP_DEBUG
815  LogDebug ("Pixel Digitizer")
816  << i << " " << ionization_points[i].x() << " "
817  << ionization_points[i].y() << " "
818  << ionization_points[i].z() << " "
819  << ionization_points[i].energy();
820 #endif
821 
822  } // end for loop
823 
824  delete[] elossVector;
825 
826 }
827 //******************************************************************************
828 
829 // Fluctuate the charge comming from a small (10um) track segment.
830 // Use the G4 routine. For mip pions for the moment.
831 void SiPixelDigitizerAlgorithm::fluctuateEloss(int pid, float particleMomentum,
832  float eloss, float length,
833  int NumberOfSegs,float elossVector[],
834  CLHEP::HepRandomEngine* engine) const {
835 
836  // Get dedx for this track
837  //float dedx;
838  //if( length > 0.) dedx = eloss/length;
839  //else dedx = eloss;
840 
841  double particleMass = 139.6; // Mass in MeV, Assume pion
842  pid = std::abs(pid);
843  if(pid!=211) { // Mass in MeV
844  if(pid==11) particleMass = 0.511;
845  else if(pid==13) particleMass = 105.7;
846  else if(pid==321) particleMass = 493.7;
847  else if(pid==2212) particleMass = 938.3;
848  }
849  // What is the track segment length.
850  float segmentLength = length/NumberOfSegs;
851 
852  // Generate charge fluctuations.
853  float de=0.;
854  float sum=0.;
855  double segmentEloss = (1000.*eloss)/NumberOfSegs; //eloss in MeV
856  for (int i=0;i<NumberOfSegs;i++) {
857  // material,*, momentum,energy,*, *, mass
858  //myglandz_(14.,segmentLength,2.,2.,dedx,de,0.14);
859  // The G4 routine needs momentum in MeV, mass in Mev, delta-cut in MeV,
860  // track segment length in mm, segment eloss in MeV
861  // Returns fluctuated eloss in MeV
862  double deltaCutoff = tMax; // the cutoff is sometimes redefined inside, so fix it.
863  de = fluctuate->SampleFluctuations(double(particleMomentum*1000.),
864  particleMass, deltaCutoff,
865  double(segmentLength*10.),
866  segmentEloss, engine )/1000.; //convert to GeV
867  elossVector[i]=de;
868  sum +=de;
869  }
870 
871  if(sum>0.) { // If fluctuations give eloss>0.
872  // Rescale to the same total eloss
873  float ratio = eloss/sum;
874 
875  for (int ii=0;ii<NumberOfSegs;ii++) elossVector[ii]= ratio*elossVector[ii];
876  } else { // If fluctuations gives 0 eloss
877  float averageEloss = eloss/NumberOfSegs;
878  for (int ii=0;ii<NumberOfSegs;ii++) elossVector[ii]= averageEloss;
879  }
880  return;
881 }
882 
883 //*******************************************************************************
884 // Drift the charge segments to the sensor surface (collection plane)
885 // Include the effect of E-field and B-field
887  const PixelGeomDetUnit* pixdet,
888  const GlobalVector& bfield,
889  const TrackerTopology *tTopo,
890  const std::vector<EnergyDepositUnit>& ionization_points,
891  std::vector<SignalPoint>& collection_points) const {
892 
893 #ifdef TP_DEBUG
894  LogDebug ("Pixel Digitizer") << " enter drift " ;
895 #endif
896 
897  collection_points.resize(ionization_points.size()); // set size
898 
899  LocalVector driftDir=DriftDirection(pixdet, bfield, hit.detUnitId()); // get the charge drift direction
900  if(driftDir.z() ==0.) {
901  LogWarning("Magnetic field") << " pxlx: drift in z is zero ";
902  return;
903  }
904 
905  // tangent of Lorentz angle
906  //float TanLorenzAngleX = driftDir.x()/driftDir.z();
907  //float TanLorenzAngleY = 0.; // force to 0, driftDir.y()/driftDir.z();
908 
909  float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
910  CosLorenzAngleY;
911  if( alpha2Order) {
912  TanLorenzAngleX = driftDir.x(); // tangen of Lorentz angle
913  TanLorenzAngleY = driftDir.y();
914  dir_z = driftDir.z(); // The z drift direction
915  CosLorenzAngleX = 1./sqrt(1.+TanLorenzAngleX*TanLorenzAngleX); //cosine
916  CosLorenzAngleY = 1./sqrt(1.+TanLorenzAngleY*TanLorenzAngleY); //cosine;
917 
918  } else{
919  TanLorenzAngleX = driftDir.x();
920  TanLorenzAngleY = 0.; // force to 0, driftDir.y()/driftDir.z();
921  dir_z = driftDir.z(); // The z drift direction
922  CosLorenzAngleX = 1./sqrt(1.+TanLorenzAngleX*TanLorenzAngleX); //cosine to estimate the path length
923  CosLorenzAngleY = 1.;
924  }
925 
926  float moduleThickness = pixdet->specificSurface().bounds().thickness();
927 #ifdef TP_DEBUG
928  LogDebug ("Pixel Digitizer")
929  << " Lorentz Tan " << TanLorenzAngleX << " " << TanLorenzAngleY <<" "
930  << CosLorenzAngleX << " " << CosLorenzAngleY << " "
931  << moduleThickness*TanLorenzAngleX << " " << driftDir;
932 #endif
933 
934  float Sigma_x = 1.; // Charge spread
935  float Sigma_y = 1.;
936  float DriftDistance; // Distance between charge generation and collection
937  float DriftLength; // Actual Drift Lentgh
938  float Sigma;
939 
940  for (unsigned int i = 0; i != ionization_points.size(); i++) {
941 
942  float SegX, SegY, SegZ; // position
943  SegX = ionization_points[i].x();
944  SegY = ionization_points[i].y();
945  SegZ = ionization_points[i].z();
946 
947  // Distance from the collection plane
948  //DriftDistance = (moduleThickness/2. + SegZ); // Drift to -z
949  // Include explixitely the E drift direction (for CMS dir_z=-1)
950  DriftDistance = moduleThickness/2. - (dir_z * SegZ); // Drift to -z
951 
952  //if( DriftDistance <= 0.)
953  //cout<<" <=0 "<<DriftDistance<<" "<<i<<" "<<SegZ<<" "<<dir_z<<" "
954  // <<SegX<<" "<<SegY<<" "<<(moduleThickness/2)<<" "
955  // <<ionization_points[i].energy()<<" "
956  // <<hit.particleType()<<" "<<hit.pabs()<<" "<<hit.energyLoss()<<" "
957  // <<hit.entryPoint()<<" "<<hit.exitPoint()
958  // <<std::endl;
959 
960  if( DriftDistance < 0.) {
961  DriftDistance = 0.;
962  } else if( DriftDistance > moduleThickness )
963  DriftDistance = moduleThickness;
964 
965  // Assume full depletion now, partial depletion will come later.
966  float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
967  float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
968 
969  // Shift cloud center
970  float CloudCenterX = SegX + XDriftDueToMagField;
971  float CloudCenterY = SegY + YDriftDueToMagField;
972 
973  // Calculate how long is the charge drift path
974  DriftLength = sqrt( DriftDistance*DriftDistance +
975  XDriftDueToMagField*XDriftDueToMagField +
976  YDriftDueToMagField*YDriftDueToMagField );
977 
978  // What is the charge diffusion after this path
979  Sigma = sqrt(DriftLength/Dist300) * Sigma0;
980 
981  // Project the diffusion sigma on the collection plane
982  Sigma_x = Sigma / CosLorenzAngleX ;
983  Sigma_y = Sigma / CosLorenzAngleY ;
984 
985  // Insert a charge loss due to Rad Damage here
986  float energyOnCollector = ionization_points[i].energy(); // The energy that reaches the collector
987 
988  // add pixel aging
989  if (AddPixelAging) {
990  float kValue = pixel_aging(pixelAging_,pixdet,tTopo);
991  energyOnCollector *= exp( -1*kValue*DriftDistance/moduleThickness );
992  }
993 
994 #ifdef TP_DEBUG
995  LogDebug ("Pixel Digitizer")
996  <<" Dift DistanceZ= "<<DriftDistance<<" module thickness= "<<moduleThickness
997  <<" Start Energy= "<<ionization_points[i].energy()<<" Energy after loss= "<<energyOnCollector;
998 #endif
999  SignalPoint sp( CloudCenterX, CloudCenterY,
1000  Sigma_x, Sigma_y, hit.tof(), energyOnCollector );
1001 
1002  // Load the Charge distribution parameters
1003  collection_points[i] = (sp);
1004 
1005  } // loop over ionization points, i.
1006 
1007 } // end drift
1008 
1009 //*************************************************************************
1010 // Induce the signal on the collection plane of the active sensor area.
1012  const size_t hitIndex,
1013  const unsigned int tofBin,
1014  const PixelGeomDetUnit* pixdet,
1015  const std::vector<SignalPoint>& collection_points) {
1016 
1017  // X - Rows, Left-Right, 160, (1.6cm) for barrel
1018  // Y - Columns, Down-Up, 416, (6.4cm)
1019 
1020  const PixelTopology* topol=&pixdet->specificTopology();
1021  uint32_t detID= pixdet->geographicalId().rawId();
1022  signal_map_type& theSignal = _signal[detID];
1023 
1024 #ifdef TP_DEBUG
1025  LogDebug ("Pixel Digitizer")
1026  << " enter induce_signal, "
1027  << topol->pitch().first << " " << topol->pitch().second; //OK
1028 #endif
1029 
1030  // local map to store pixels hit by 1 Hit.
1031  typedef std::map< int, float, std::less<int> > hit_map_type;
1032  hit_map_type hit_signal;
1033 
1034  // map to store pixel integrals in the x and in the y directions
1035  std::map<int, float, std::less<int> > x,y;
1036 
1037  // Assign signals to readout channels and store sorted by channel number
1038 
1039  // Iterate over collection points on the collection plane
1040  for ( std::vector<SignalPoint>::const_iterator i=collection_points.begin();
1041  i != collection_points.end(); ++i) {
1042 
1043  float CloudCenterX = i->position().x(); // Charge position in x
1044  float CloudCenterY = i->position().y(); // in y
1045  float SigmaX = i->sigma_x(); // Charge spread in x
1046  float SigmaY = i->sigma_y(); // in y
1047  float Charge = i->amplitude(); // Charge amplitude
1048 
1049 
1050  //if(SigmaX==0 || SigmaY==0) {
1051  //cout<<SigmaX<<" "<<SigmaY
1052  // << " cloud " << i->position().x() << " " << i->position().y() << " "
1053  // << i->sigma_x() << " " << i->sigma_y() << " " << i->amplitude()<<std::endl;
1054  //}
1055 
1056 #ifdef TP_DEBUG
1057  LogDebug ("Pixel Digitizer")
1058  << " cloud " << i->position().x() << " " << i->position().y() << " "
1059  << i->sigma_x() << " " << i->sigma_y() << " " << i->amplitude();
1060 #endif
1061 
1062  // Find the maximum cloud spread in 2D plane , assume 3*sigma
1063  float CloudRight = CloudCenterX + ClusterWidth*SigmaX;
1064  float CloudLeft = CloudCenterX - ClusterWidth*SigmaX;
1065  float CloudUp = CloudCenterY + ClusterWidth*SigmaY;
1066  float CloudDown = CloudCenterY - ClusterWidth*SigmaY;
1067 
1068  // Define 2D cloud limit points
1069  LocalPoint PointRightUp = LocalPoint(CloudRight,CloudUp);
1070  LocalPoint PointLeftDown = LocalPoint(CloudLeft,CloudDown);
1071 
1072  // This points can be located outside the sensor area.
1073  // The conversion to measurement point does not check for that
1074  // so the returned pixel index might be wrong (outside range).
1075  // We rely on the limits check below to fix this.
1076  // But remember whatever we do here THE CHARGE OUTSIDE THE ACTIVE
1077  // PIXEL AREA IS LOST, it should not be collected.
1078 
1079  // Convert the 2D points to pixel indices
1080  MeasurementPoint mp = topol->measurementPosition(PointRightUp ); //OK
1081 
1082  int IPixRightUpX = int( floor( mp.x()));
1083  int IPixRightUpY = int( floor( mp.y()));
1084 
1085 #ifdef TP_DEBUG
1086  LogDebug ("Pixel Digitizer") << " right-up " << PointRightUp << " "
1087  << mp.x() << " " << mp.y() << " "
1088  << IPixRightUpX << " " << IPixRightUpY ;
1089 #endif
1090 
1091  mp = topol->measurementPosition(PointLeftDown ); //OK
1092 
1093  int IPixLeftDownX = int( floor( mp.x()));
1094  int IPixLeftDownY = int( floor( mp.y()));
1095 
1096 #ifdef TP_DEBUG
1097  LogDebug ("Pixel Digitizer") << " left-down " << PointLeftDown << " "
1098  << mp.x() << " " << mp.y() << " "
1099  << IPixLeftDownX << " " << IPixLeftDownY ;
1100 #endif
1101 
1102  // Check detector limits to correct for pixels outside range.
1103  int numColumns = topol->ncolumns(); // det module number of cols&rows
1104  int numRows = topol->nrows();
1105 
1106  IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
1107  IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
1108  IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
1109  IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
1110 
1111  x.clear(); // clear temporary integration array
1112  y.clear();
1113 
1114  // First integrate charge strips in x
1115  int ix; // TT for compatibility
1116  for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) { // loop over x index
1117  float xUB, xLB, UpperBound, LowerBound;
1118 
1119  // Why is set to 0 if ix=0, does it meen that we accept charge
1120  // outside the sensor? CHeck How it was done in ORCA?
1121  //if(ix == 0) LowerBound = 0.;
1122  if(ix == 0 || SigmaX==0. ) // skip for surface segemnts
1123  LowerBound = 0.;
1124  else {
1125  mp = MeasurementPoint( float(ix), 0.0);
1126  xLB = topol->localPosition(mp).x();
1127  LowerBound = 1-calcQ((xLB-CloudCenterX)/SigmaX);
1128  }
1129 
1130  if(ix == numRows-1 || SigmaX==0. )
1131  UpperBound = 1.;
1132  else {
1133  mp = MeasurementPoint( float(ix+1), 0.0);
1134  xUB = topol->localPosition(mp).x();
1135  UpperBound = 1. - calcQ((xUB-CloudCenterX)/SigmaX);
1136  }
1137 
1138  float TotalIntegrationRange = UpperBound - LowerBound; // get strip
1139  x[ix] = TotalIntegrationRange; // save strip integral
1140  //if(SigmaX==0 || SigmaY==0)
1141  //cout<<TotalIntegrationRange<<" "<<ix<<std::endl;
1142 
1143  }
1144 
1145  // Now integrate strips in y
1146  int iy; // TT for compatibility
1147  for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) { //loope over y ind
1148  float yUB, yLB, UpperBound, LowerBound;
1149 
1150  if(iy == 0 || SigmaY==0.)
1151  LowerBound = 0.;
1152  else {
1153  mp = MeasurementPoint( 0.0, float(iy) );
1154  yLB = topol->localPosition(mp).y();
1155  LowerBound = 1. - calcQ((yLB-CloudCenterY)/SigmaY);
1156  }
1157 
1158  if(iy == numColumns-1 || SigmaY==0. )
1159  UpperBound = 1.;
1160  else {
1161  mp = MeasurementPoint( 0.0, float(iy+1) );
1162  yUB = topol->localPosition(mp).y();
1163  UpperBound = 1. - calcQ((yUB-CloudCenterY)/SigmaY);
1164  }
1165 
1166  float TotalIntegrationRange = UpperBound - LowerBound;
1167  y[iy] = TotalIntegrationRange; // save strip integral
1168  //if(SigmaX==0 || SigmaY==0)
1169  //cout<<TotalIntegrationRange<<" "<<iy<<std::endl;
1170  }
1171 
1172  // Get the 2D charge integrals by folding x and y strips
1173  int chan;
1174  for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) { // loop over x index
1175  for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) { //loope over y ind
1176 
1177  float ChargeFraction = Charge*x[ix]*y[iy];
1178 
1179  if( ChargeFraction > 0. ) {
1180  chan = PixelDigi::pixelToChannel( ix, iy); // Get index
1181  // Load the amplitude
1182  hit_signal[chan] += ChargeFraction;
1183  } // endif
1184 
1185 
1186  mp = MeasurementPoint( float(ix), float(iy) );
1187  LocalPoint lp = topol->localPosition(mp);
1188  chan = topol->channel(lp);
1189 
1190 #ifdef TP_DEBUG
1191  LogDebug ("Pixel Digitizer")
1192  << " pixel " << ix << " " << iy << " - "<<" "
1193  << chan << " " << ChargeFraction<<" "
1194  << mp.x() << " " << mp.y() <<" "
1195  << lp.x() << " " << lp.y() << " " // givex edge position
1196  << chan; // edge belongs to previous ?
1197 #endif
1198 
1199  } // endfor iy
1200  } //endfor ix
1201 
1202 
1203  // Test conversions (THIS IS FOR TESTING ONLY) comment-out.
1204  // mp = topol->measurementPosition( i->position() ); //OK
1205  // LocalPoint lp = topol->localPosition(mp); //OK
1206  // std::pair<float,float> p = topol->pixel( i->position() ); //OK
1207  // chan = PixelDigi::pixelToChannel( int(p.first), int(p.second));
1208  // std::pair<int,int> ip = PixelDigi::channelToPixel(chan);
1209  // MeasurementPoint mp1 = MeasurementPoint( float(ip.first),
1210  // float(ip.second) );
1211  // LogDebug ("Pixel Digitizer") << " Test "<< mp.x() << " " << mp.y()
1212  // << " "<< lp.x() << " " << lp.y() << " "<<" "
1213  // <<p.first <<" "<<p.second<<" "<<chan<< " "
1214  // <<" " << ip.first << " " << ip.second << " "
1215  // << mp1.x() << " " << mp1.y() << " " //OK
1216  // << topol->localPosition(mp1).x() << " " //OK
1217  // << topol->localPosition(mp1).y() << " "
1218  // << topol->channel( i->position() ); //OK
1219 
1220 
1221  } // loop over charge distributions
1222 
1223  // Fill the global map with all hit pixels from this event
1224 
1225  for ( hit_map_type::const_iterator im = hit_signal.begin();
1226  im != hit_signal.end(); ++im) {
1227  int chan = (*im).first;
1228  theSignal[chan] += (makeDigiSimLinks_ ? Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1229 
1230 #ifdef TP_DEBUG
1231  std::pair<int,int> ip = PixelDigi::channelToPixel(chan);
1232  LogDebug ("Pixel Digitizer")
1233  << " pixel " << ip.first << " " << ip.second << " "
1234  << theSignal[chan];
1235 #endif
1236  }
1237 
1238 } // end induce_signal
1239 
1240 /***********************************************************************/
1241 
1242 // Build pixels, check threshold, add misscalibration, ...
1243 void SiPixelDigitizerAlgorithm::make_digis(float thePixelThresholdInE,
1244  uint32_t detID,
1245  const PixelGeomDetUnit* pixdet,
1246  std::vector<PixelDigi>& digis,
1247  std::vector<PixelDigiSimLink>& simlinks,
1248  const TrackerTopology *tTopo) const {
1249 
1250 #ifdef TP_DEBUG
1251  LogDebug ("Pixel Digitizer") << " make digis "<<" "
1252  << " pixel threshold FPix" << theThresholdInE_FPix << " "
1253  << " pixel threshold BPix" << theThresholdInE_BPix << " "
1254  << " pixel threshold BPix Layer1" << theThresholdInE_BPix_L1 << " "
1255  << " List pixels passing threshold ";
1256 #endif
1257 
1258  // Loop over hit pixels
1259 
1260  signalMaps::const_iterator it = _signal.find(detID);
1261  if (it == _signal.end()) {
1262  return;
1263  }
1264 
1265  const signal_map_type& theSignal = (*it).second;
1266 
1267  // unsigned long is enough to store SimTrack id and EncodedEventId
1268  using TrackEventId = std::pair<decltype(SimTrack().trackId()), decltype(EncodedEventId().rawId())>;
1269  std::map<TrackEventId, float> simi; // re-used
1270 
1271  for (signal_map_const_iterator i = theSignal.begin(); i != theSignal.end(); ++i) {
1272 
1273  float signalInElectrons = (*i).second ; // signal in electrons
1274 
1275  // Do the miss calibration for calibration studies only.
1276  //if(doMissCalibrate) signalInElectrons = missCalibrate(signalInElectrons)
1277 
1278  // Do only for pixels above threshold
1279 
1280  if( signalInElectrons >= thePixelThresholdInE) { // check threshold
1281 
1282  int chan = (*i).first; // channel number
1283  std::pair<int,int> ip = PixelDigi::channelToPixel(chan);
1284  int adc=0; // ADC count as integer
1285 
1286  // Do the miss calibration for calibration studies only.
1287  if(doMissCalibrate) {
1288  int row = ip.first; // X in row
1289  int col = ip.second; // Y is in col
1290  adc = int(missCalibrate(detID, pixdet, col, row, signalInElectrons)); //full misscalib.
1291  } else { // Just do a simple electron->adc conversion
1292  adc = int( signalInElectrons / theElectronPerADC ); // calibrate gain
1293  }
1294  adc = std::min(adc, theAdcFullScale); // Check maximum value
1295 // Calculate layerIndex
1297  if(pixdet->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) { // Phase 2 OT Barrel only
1298  // Set to 1 if over the threshold
1299  if (theAdcFullScaleStack==1) {adc=1;}
1300  // Make it a linear fit to the full scale of the normal adc count. Start new adc from 1 not zero.
1302  }
1303  } // Only enter this if the Adc changes for the outer layers
1304 #ifdef TP_DEBUG
1305  LogDebug ("Pixel Digitizer")
1306  << (*i).first << " " << (*i).second << " " << signalInElectrons
1307  << " " << adc << ip.first << " " << ip.second ;
1308 #endif
1309 
1310  // Load digis
1311  digis.emplace_back(ip.first, ip.second, adc);
1312 
1313  if (makeDigiSimLinks_ && !(*i).second.hitInfos().empty()) {
1314  //digilink
1315  unsigned int il=0;
1316  for(const auto& info: (*i).second.hitInfos()) {
1317  // note: according to C++ standard operator[] does
1318  // value-initializiation, which for float means initial value of 0
1319  simi[std::make_pair(info.trackId(), info.eventId().rawId())] += (*i).second.individualampl()[il];
1320  il++;
1321  }
1322 
1323  //sum the contribution of the same trackid
1324  for(const auto& info: (*i).second.hitInfos()) {
1325  // skip if track already processed
1326  auto found = simi.find(std::make_pair(info.trackId(), info.eventId().rawId()));
1327  if(found == simi.end())
1328  continue;
1329 
1330  float sum_samechannel = found->second;
1331  float fraction=sum_samechannel/(*i).second;
1332  if(fraction>1.f) fraction=1.f;
1333 
1334  // Approximation: pick hitIndex and tofBin only from the first SimHit
1335  simlinks.emplace_back((*i).first, info.trackId(), info.hitIndex(), info.tofBin(), info.eventId(), fraction);
1336  simi.erase(found);
1337  }
1338  simi.clear(); // although should be empty already
1339  }
1340  }
1341  }
1342 }
1343 
1344 /***********************************************************************/
1345 
1346 // Add electronic noise to pixel charge
1348  float thePixelThreshold,
1349  CLHEP::HepRandomEngine* engine) {
1350 
1351 #ifdef TP_DEBUG
1352  LogDebug ("Pixel Digitizer") << " enter add_noise " << theNoiseInElectrons;
1353 #endif
1354 
1355  uint32_t detID= pixdet->geographicalId().rawId();
1356  signal_map_type& theSignal = _signal[detID];
1357 
1358 
1359  // First add noise to hit pixels
1360  float theSmearedChargeRMS = 0.0;
1361 
1362  for ( signal_map_iterator i = theSignal.begin(); i != theSignal.end(); i++) {
1363 
1365  {
1366  if((*i).second < 3000)
1367  {
1368  theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1369  } else if((*i).second < 6000){
1370  theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1371  } else{
1372  theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1373  }
1374 
1375  // Noise from Vcal smearing:
1376  float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1377  // Noise from full readout:
1378  float noise = CLHEP::RandGaussQ::shoot(engine, 0., theReadoutNoise);
1379 
1380  if(((*i).second + Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1381  (*i).second.set(0);}
1382  else{
1383  (*i).second +=Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1384  }
1385 
1386  } // End if addChargeVCalSmearing
1387  else
1388  {
1389  // Noise: ONLY full READOUT Noise.
1390  // Use here the FULL readout noise, including TBM,ALT,AOH,OPT-REC.
1391  float noise = CLHEP::RandGaussQ::shoot(engine, 0., theReadoutNoise);
1392 
1393  if(((*i).second + Amplitude(noise, -1.)) < 0. ) {
1394  (*i).second.set(0);}
1395  else{
1396  (*i).second +=Amplitude(noise, -1.);
1397  }
1398  } // end if only Noise from full readout
1399 
1400  }
1401 
1402  if(!addNoisyPixels) // Option to skip noise in non-hit pixels
1403  return;
1404 
1405  const PixelTopology* topol=&pixdet->specificTopology();
1406  int numColumns = topol->ncolumns(); // det module number of cols&rows
1407  int numRows = topol->nrows();
1408 
1409  // Add noise on non-hit pixels
1410  // Use here the pixel noise
1411  int numberOfPixels = (numRows * numColumns);
1412  std::map<int,float, std::less<int> > otherPixels;
1413  std::map<int,float, std::less<int> >::iterator mapI;
1414 
1415  theNoiser->generate(numberOfPixels,
1416  thePixelThreshold, //thr. in un. of nois
1417  theNoiseInElectrons, // noise in elec.
1418  otherPixels,
1419  engine );
1420 
1421 #ifdef TP_DEBUG
1422  LogDebug ("Pixel Digitizer")
1423  << " Add noisy pixels " << numRows << " "
1424  << numColumns << " " << theNoiseInElectrons << " "
1425  << theThresholdInE_FPix << theThresholdInE_BPix <<" "<< numberOfPixels<<" "
1426  << otherPixels.size() ;
1427 #endif
1428 
1429  // Add noisy pixels
1430  for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1431  int iy = ((*mapI).first) / numRows;
1432  int ix = ((*mapI).first) - (iy*numRows);
1433 
1434  // Keep for a while for testing.
1435  if( iy < 0 || iy > (numColumns-1) )
1436  LogWarning ("Pixel Geometry") << " error in iy " << iy ;
1437  if( ix < 0 || ix > (numRows-1) )
1438  LogWarning ("Pixel Geometry") << " error in ix " << ix ;
1439 
1440  int chan = PixelDigi::pixelToChannel(ix, iy);
1441 
1442 #ifdef TP_DEBUG
1443  LogDebug ("Pixel Digitizer")
1444  <<" Storing noise = " << (*mapI).first << " " << (*mapI).second
1445  << " " << ix << " " << iy << " " << chan ;
1446 #endif
1447 
1448  if(theSignal[chan] == 0){
1449  // float noise = float( (*mapI).second );
1450  int noise=int( (*mapI).second );
1451  theSignal[chan] = Amplitude (noise, -1.);
1452  }
1453  }
1454 }
1455 
1456 /***********************************************************************/
1457 
1458 // Simulate the readout inefficiencies.
1459 // Delete a selected number of single pixels, dcols and rocs.
1461  const PixelGeomDetUnit* pixdet,
1462  const TrackerTopology *tTopo,
1463  CLHEP::HepRandomEngine* engine) {
1464 
1465  uint32_t detID= pixdet->geographicalId().rawId();
1466  signal_map_type& theSignal = _signal[detID];
1467  const PixelTopology* topol=&pixdet->specificTopology();
1468  int numColumns = topol->ncolumns(); // det module number of cols&rows
1469  int numRows = topol->nrows();
1470 
1471  // Predefined efficiencies
1472  double pixelEfficiency = 1.0;
1473  double columnEfficiency = 1.0;
1474  double chipEfficiency = 1.0;
1475 
1476  if (eff.FromConfig) {
1477  // setup the chip indices conversion
1479  pixdet->subDetector()==GeomDetEnumerators::SubDetector::P1PXB){// barrel layers
1480  int layerIndex=tTopo->layer(detID);
1481  pixelEfficiency = eff.thePixelEfficiency[layerIndex-1];
1482  columnEfficiency = eff.thePixelColEfficiency[layerIndex-1];
1483  chipEfficiency = eff.thePixelChipEfficiency[layerIndex-1];
1484  //std::cout <<"Using BPix columnEfficiency = "<<columnEfficiency<< " for layer = "<<layerIndex <<"\n";
1485  // This should never happen, but only check if it is not an upgrade geometry
1486  if (NumberOfBarrelLayers==3){
1487  if(numColumns>416) LogWarning ("Pixel Geometry") <<" wrong columns in barrel "<<numColumns;
1488  if(numRows>160) LogWarning ("Pixel Geometry") <<" wrong rows in barrel "<<numRows;
1489 
1490  int ladder=tTopo->pxbLadder(detID);
1491  int module=tTopo->pxbModule(detID);
1492  if (module<=4) module=5-module;
1493  else module-=4;
1494 
1495  columnEfficiency *= eff.theLadderEfficiency_BPix[layerIndex-1][ladder-1]*eff.theModuleEfficiency_BPix[layerIndex-1][module-1]*eff.pu_scale[layerIndex-1];
1496  }
1499  pixdet->subDetector()==GeomDetEnumerators::SubDetector::P2PXEC){ // forward disks
1500 
1501  unsigned int diskIndex=tTopo->layer(detID)+eff.FPixIndex; // Use diskIndex-1 later to stay consistent with BPix
1502  unsigned int panelIndex=tTopo->pxfPanel(detID);
1503  unsigned int moduleIndex=tTopo->pxfModule(detID);
1504  //if (eff.FPixIndex>diskIndex-1){throw cms::Exception("Configuration") <<"SiPixelDigitizer is using the wrong efficiency value. index = "
1505  // <<diskIndex-1<<" , MinIndex = "<<eff.FPixIndex<<" ... "<<tTopo->pxfDisk(detID);}
1506  pixelEfficiency = eff.thePixelEfficiency[diskIndex-1];
1507  columnEfficiency = eff.thePixelColEfficiency[diskIndex-1];
1508  chipEfficiency = eff.thePixelChipEfficiency[diskIndex-1];
1509  //std::cout <<"Using FPix columnEfficiency = "<<columnEfficiency<<" for Disk = "<< tTopo->pxfDisk(detID)<<"\n";
1510  // Sometimes the forward pixels have wrong size,
1511  // this crashes the index conversion, so exit, but only check if it is not an upgrade geometry
1512  if (NumberOfBarrelLayers==3){ // whether it is the present or the phase 1 detector can be checked using GeomDetEnumerators::SubDetector
1513  if(numColumns>260 || numRows>160) {
1514  if(numColumns>260) LogWarning ("Pixel Geometry") <<" wrong columns in endcaps "<<numColumns;
1515  if(numRows>160) LogWarning ("Pixel Geometry") <<" wrong rows in endcaps "<<numRows;
1516  return;
1517  }
1518  if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) { //inner modules
1519  columnEfficiency*=eff.theInnerEfficiency_FPix[diskIndex-1]*eff.pu_scale[3];
1520  } else { //outer modules
1521  columnEfficiency*=eff.theOuterEfficiency_FPix[diskIndex-1]*eff.pu_scale[4];
1522  }
1523  } // current detector, forward
1525  // If phase 2 outer tracker, hardcoded values as they have been so far
1526  pixelEfficiency = 0.999;
1527  columnEfficiency = 0.999;
1528  chipEfficiency = 0.999;
1529  } // if barrel/forward
1530  } else { // Load precomputed factors from Database
1531  pixelEfficiency = eff.PixelGeomFactors.at(detID);
1532  columnEfficiency = eff.ColGeomFactors.at(detID)*eff.pu_scale[eff.iPU.at(detID)];
1533  chipEfficiency = eff.ChipGeomFactors.at(detID);
1534  }
1535 
1536 #ifdef TP_DEBUG
1537  LogDebug ("Pixel Digitizer") << " enter pixel_inefficiency " << pixelEfficiency << " "
1538  << columnEfficiency << " " << chipEfficiency;
1539 #endif
1540 
1541  // Initilize the index converter
1542  //PixelIndices indexConverter(numColumns,numRows);
1543  std::unique_ptr<PixelIndices> pIndexConverter(new PixelIndices(numColumns,numRows));
1544 
1545  int chipIndex = 0;
1546  int rowROC = 0;
1547  int colROC = 0;
1548  std::map<int, int, std::less<int> >chips, columns;
1549  std::map<int, int, std::less<int> >::iterator iter;
1550 
1551  // Find out the number of columns and rocs hits
1552  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
1553  for (signal_map_const_iterator i = theSignal.begin(); i != theSignal.end(); ++i) {
1554 
1555  int chan = i->first;
1556  std::pair<int,int> ip = PixelDigi::channelToPixel(chan);
1557  int row = ip.first; // X in row
1558  int col = ip.second; // Y is in col
1559  //transform to ROC index coordinates
1560  pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1561  int dColInChip = pIndexConverter->DColumn(colROC); // get ROC dcol from ROC col
1562  //dcol in mod
1563  int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1564 
1565  chips[chipIndex]++;
1566  columns[dColInDet]++;
1567  }
1568 
1569  // Delete some ROC hits.
1570  for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1571  //float rand = RandFlat::shoot();
1572  float rand = CLHEP::RandFlat::shoot(engine);
1573  if( rand > chipEfficiency ) chips[iter->first]=0;
1574  }
1575 
1576  // Delete some Dcol hits.
1577  for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1578  //float rand = RandFlat::shoot();
1579  float rand = CLHEP::RandFlat::shoot(engine);
1580  if( rand > columnEfficiency ) columns[iter->first]=0;
1581  }
1582 
1583  // Now loop again over pixels to kill some of them.
1584  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
1585  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1586 
1587  // int chan = i->first;
1588  std::pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1589  int row = ip.first; // X in row
1590  int col = ip.second; // Y is in col
1591  //transform to ROC index coordinates
1592  pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1593  int dColInChip = pIndexConverter->DColumn(colROC); //get ROC dcol from ROC col
1594  //dcol in mod
1595  int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1596 
1597  //float rand = RandFlat::shoot();
1598  float rand = CLHEP::RandFlat::shoot(engine);
1599  if( chips[chipIndex]==0 || columns[dColInDet]==0
1600  || rand>pixelEfficiency ) {
1601  // make pixel amplitude =0, pixel will be lost at clusterization
1602  i->second.set(0.); // reset amplitude,
1603  } // end if
1604 
1605  } // end pixel loop
1606 } // end pixel_indefficiency
1607 
1608 //***************************************************************************************
1609 // Simulate pixel aging with an exponential function
1610 //**************************************************************************************
1611 
1613  const PixelGeomDetUnit *pixdet,
1614  const TrackerTopology *tTopo) const {
1615 
1616  uint32_t detID= pixdet->geographicalId().rawId();
1617 
1618 
1619  // Predefined damage parameter (no aging)
1620  float pseudoRadDamage = 0.0;
1621 
1622  // setup the chip indices conversion
1624  pixdet->subDetector() == GeomDetEnumerators::SubDetector::P1PXB){// barrel layers
1625  int layerIndex=tTopo->layer(detID);
1626 
1627  pseudoRadDamage = aging.thePixelPseudoRadDamage[layerIndex-1];
1628 
1629  // std::cout << "pixel_aging: " << std::endl;
1630  // std::cout << "Subid " << Subid << " layerIndex " << layerIndex << " ladder " << tTopo->pxbLadder(detID) << " module " << tTopo->pxbModule(detID) << std::endl;
1631 
1634  pixdet->subDetector() == GeomDetEnumerators::SubDetector::P2PXEC) { // forward disks
1635  unsigned int diskIndex=tTopo->layer(detID)+aging.FPixIndex; // Use diskIndex-1 later to stay consistent with BPix
1636 
1637  pseudoRadDamage = aging.thePixelPseudoRadDamage[diskIndex-1];
1638 
1639  // std::cout << "pixel_aging: " << std::endl;
1640  // std::cout << "Subid " << Subid << " diskIndex " << diskIndex << std::endl;
1642  // if phase 2 OT hardcoded value as it has always been
1643  pseudoRadDamage = 0.;
1644  } // if barrel/forward
1645 
1646  // std::cout << " pseudoRadDamage " << pseudoRadDamage << std::endl;
1647  // std::cout << " end pixel_aging " << std::endl;
1648 
1649  return pseudoRadDamage;
1650 #ifdef TP_DEBUG
1651  LogDebug ("Pixel Digitizer") << " enter pixel_aging " << pseudoRadDamage;
1652 #endif
1653 
1654 }
1655 
1656 //***********************************************************************
1657 
1658 // Fluctuate the gain and offset for the amplitude calibration
1659 // Use gaussian smearing.
1660 //float SiPixelDigitizerAlgorithm::missCalibrate(const float amp) const {
1661  //float gain = RandGaussQ::shoot(1.,theGainSmearing);
1662  //float offset = RandGaussQ::shoot(0.,theOffsetSmearing);
1663  //float newAmp = amp * gain + offset;
1664  // More complex misscalibration
1665 float SiPixelDigitizerAlgorithm::missCalibrate(uint32_t detID, const PixelGeomDetUnit* pixdet, int col,int row,
1666  const float signalInElectrons) const {
1667  // Central values
1668  //const float p0=0.00352, p1=0.868, p2=112., p3=113.; // pix(0,0,0)
1669  // const float p0=0.00382, p1=0.886, p2=112.7, p3=113.0; // average roc=0
1670  //const float p0=0.00492, p1=1.998, p2=90.6, p3=134.1; // average roc=6
1671  // Smeared (rms)
1672  //const float s0=0.00020, s1=0.051, s2=5.4, s3=4.4; // average roc=0
1673  //const float s0=0.00015, s1=0.043, s2=3.2, s3=3.1; // col average roc=0
1674 
1675  // Make 2 sets of parameters for Fpix and BPIx:
1676 
1677  float p0=0.0;
1678  float p1=0.0;
1679  float p2=0.0;
1680  float p3=0.0;
1681 
1682  if(pixdet->type().isTrackerPixel() && pixdet->type().isBarrel()){// barrel layers
1683  p0 = BPix_p0;
1684  p1 = BPix_p1;
1685  p2 = BPix_p2;
1686  p3 = BPix_p3;
1687  } else if(pixdet->type().isTrackerPixel()) {// forward disks
1688  p0 = FPix_p0;
1689  p1 = FPix_p1;
1690  p2 = FPix_p2;
1691  p3 = FPix_p3;
1692  } else {
1693  throw cms::Exception("NotAPixelGeomDetUnit") << "Not a pixel geomdet unit" << detID;
1694  }
1695 
1696  // const float electronsPerVCAL = 65.5; // our present VCAL calibration (feb 2009)
1697  // const float electronsPerVCAL_Offset = -414.0; // our present VCAL calibration (feb 2009)
1698  float newAmp = 0.; //Modified signal
1699 
1700  // Convert electrons to VCAL units
1701  float signal = (signalInElectrons-electronsPerVCAL_Offset)/electronsPerVCAL;
1702 
1703  // Simulate the analog response with fixed parametrization
1704  newAmp = p3 + p2 * tanh(p0*signal - p1);
1705 
1706 
1707  // Use the pixel-by-pixel calibrations
1708  //transform to ROC index coordinates
1709  //int chipIndex=0, colROC=0, rowROC=0;
1710  //std::unique_ptr<PixelIndices> pIndexConverter(new PixelIndices(numColumns,numRows));
1711  //pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1712 
1713  // Use calibration from a file
1714  //int chanROC = PixelIndices::pixelToChannelROC(rowROC,colROC); // use ROC coordinates
1715  //float pp0=0, pp1=0,pp2=0,pp3=0;
1716  //map<int,CalParameters,std::less<int> >::const_iterator it=calmap.find(chanROC);
1717  //CalParameters y = (*it).second;
1718  //pp0 = y.p0;
1719  //pp1 = y.p1;
1720  //pp2 = y.p2;
1721  //pp3 = y.p3;
1722 
1723  //
1724  // Use random smearing
1725  // Randomize the pixel response
1726  //float pp0 = RandGaussQ::shoot(p0,s0);
1727  //float pp1 = RandGaussQ::shoot(p1,s1);
1728  //float pp2 = RandGaussQ::shoot(p2,s2);
1729  //float pp3 = RandGaussQ::shoot(p3,s3);
1730 
1731  //newAmp = pp3 + pp2 * tanh(pp0*signal - pp1); // Final signal
1732 
1733  //cout<<" misscalibrate "<<col<<" "<<row<<" "<<chipIndex<<" "<<colROC<<" "
1734  // <<rowROC<<" "<<signalInElectrons<<" "<<signal<<" "<<newAmp<<" "
1735  // <<(signalInElectrons/theElectronPerADC)<<std::endl;
1736 
1737  return newAmp;
1738 }
1739 //******************************************************************************
1740 
1741 // Set the drift direction accoring to the Bfield in local det-unit frame
1742 // Works for both barrel and forward pixels.
1743 // Replace the sign convention to fit M.Swartz's formulaes.
1744 // Configurations for barrel and foward pixels possess different tanLorentzAngleperTesla
1745 // parameter value
1746 
1748  const GlobalVector& bfield,
1749  const DetId& detId) const {
1750  Frame detFrame(pixdet->surface().position(),pixdet->surface().rotation());
1751  LocalVector Bfield=detFrame.toLocal(bfield);
1752 
1753  float alpha2_FPix;
1754  float alpha2_BPix;
1755  float alpha2;
1756 
1757  //float dir_x = -tanLorentzAnglePerTesla * Bfield.y();
1758  //float dir_y = +tanLorentzAnglePerTesla * Bfield.x();
1759  //float dir_z = -1.; // E field always in z direction, so electrons go to -z
1760  // The dir_z has to be +/- 1. !
1761  // LocalVector theDriftDirection = LocalVector(dir_x,dir_y,dir_z);
1762 
1763  float dir_x = 0.0;
1764  float dir_y = 0.0;
1765  float dir_z = 0.0;
1766  float scale = 0.0;
1767 
1768  uint32_t detID= pixdet->geographicalId().rawId();
1769 
1770 
1771  // Read Lorentz angle from cfg file:**************************************************************
1772 
1773  if(!use_LorentzAngle_DB_){
1774 
1775  if( alpha2Order) {
1778  }else {
1779  alpha2_FPix = 0.0;
1780  alpha2_BPix = 0.0;
1781  }
1782 
1783  if(pixdet->type().isTrackerPixel() && pixdet->type().isBarrel()){// barrel layers
1784  dir_x = -( tanLorentzAnglePerTesla_BPix * Bfield.y() + alpha2_BPix* Bfield.z()* Bfield.x() );
1785  dir_y = +( tanLorentzAnglePerTesla_BPix * Bfield.x() - alpha2_BPix* Bfield.z()* Bfield.y() );
1786  dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1787  scale = -dir_z;
1788  } else if (pixdet->type().isTrackerPixel()) {// forward disks
1789  dir_x = -( tanLorentzAnglePerTesla_FPix * Bfield.y() + alpha2_FPix* Bfield.z()* Bfield.x() );
1790  dir_y = +( tanLorentzAnglePerTesla_FPix * Bfield.x() - alpha2_FPix* Bfield.z()* Bfield.y() );
1791  dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1792  scale = -dir_z;
1793  } else {
1794  throw cms::Exception("NotAPixelGeomDetUnit") << "Not a pixel geomdet unit" << detID;
1795  }
1796  } // end: Read LA from cfg file.
1797 
1798  //Read Lorentz angle from DB:********************************************************************
1800  float lorentzAngle = SiPixelLorentzAngle_->getLorentzAngle(detId);
1801  alpha2 = lorentzAngle * lorentzAngle;
1802  //std::cout << "detID is: "<< it->first <<"The LA per tesla is: "<< it->second << std::std::endl;
1803  dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1804  dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1805  dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1806  scale = -dir_z;
1807  }// end: Read LA from DataBase.
1808 
1809  LocalVector theDriftDirection = LocalVector(dir_x/scale, dir_y/scale, dir_z/scale );
1810 
1811 #ifdef TP_DEBUG
1812  LogDebug ("Pixel Digitizer") << " The drift direction in local coordinate is "
1813  << theDriftDirection ;
1814 #endif
1815 
1816  return theDriftDirection;
1817 }
1818 
1819 //****************************************************************************************************
1820 
1822 
1823  signal_map_type& theSignal = _signal[detID];
1824 
1825  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
1826  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1827 
1828  // int chan = i->first;
1829  std::pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1830  int row = ip.first; // X in row
1831  int col = ip.second; // Y is in col
1832  //transform to ROC index coordinates
1833  if(theSiPixelGainCalibrationService_->isDead(detID, col, row)){
1834  // std::cout << "now in isdead check, row " << detID << " " << col << "," << row << std::std::endl;
1835  // make pixel amplitude =0, pixel will be lost at clusterization
1836  i->second.set(0.); // reset amplitude,
1837  } // end if
1838  } // end pixel loop
1839 } // end pixel_indefficiency
1840 
1841 
1842 //****************************************************************************************************
1843 
1845 
1846  bool isbad=false;
1847 
1848  Parameters::const_iterator itDeadModules=DeadModules.begin();
1849 
1850  int detid = detID;
1851  for(; itDeadModules != DeadModules.end(); ++itDeadModules){
1852  int Dead_detID = itDeadModules->getParameter<int>("Dead_detID");
1853  if(detid == Dead_detID){
1854  isbad=true;
1855  break;
1856  }
1857  }
1858 
1859  if(!isbad)
1860  return;
1861 
1862  signal_map_type& theSignal = _signal[detID];
1863 
1864  std::string Module = itDeadModules->getParameter<std::string>("Module");
1865 
1866  if(Module=="whole"){
1867  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1868  i->second.set(0.); // reset amplitude
1869  }
1870  }
1871 
1872  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1873  std::pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1874 
1875  if(Module=="tbmA" && ip.first>=80 && ip.first<=159){
1876  i->second.set(0.);
1877  }
1878 
1879  if( Module=="tbmB" && ip.first<=79){
1880  i->second.set(0.);
1881  }
1882  }
1883 }
1884 //****************************************************************************************************
1886 // Not SLHC safe for now
1887 
1888  bool isbad=false;
1889 
1890  std::vector<SiPixelQuality::disabledModuleType>disabledModules = SiPixelBadModule_->getBadComponentList();
1891 
1893 
1894  for (size_t id=0;id<disabledModules.size();id++)
1895  {
1896  if(detID==disabledModules[id].DetID){
1897  isbad=true;
1898  badmodule = disabledModules[id];
1899  break;
1900  }
1901  }
1902 
1903  if(!isbad)
1904  return;
1905 
1906  signal_map_type& theSignal = _signal[detID];
1907 
1908  //std::cout<<"Hit in: "<< detID <<" errorType "<< badmodule.errorType<<" BadRocs="<<std::hex<<SiPixelBadModule_->getBadRocs(detID)<<dec<<" "<<std::endl;
1909  if(badmodule.errorType == 0){ // this is a whole dead module.
1910 
1911  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1912  i->second.set(0.); // reset amplitude
1913  }
1914  }
1915  else { // all other module types: half-modules and single ROCs.
1916  // Get Bad ROC position:
1917  //follow the example of getBadRocPositions in CondFormats/SiPixelObjects/src/SiPixelQuality.cc
1918  std::vector<GlobalPixel> badrocpositions (0);
1919  for(unsigned int j = 0; j < 16; j++){
1920  if(SiPixelBadModule_->IsRocBad(detID, j) == true){
1921 
1922  std::vector<CablingPathToDetUnit> path = map_.product()->pathToDetUnit(detID);
1923  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
1924  for (IT it = path.begin(); it != path.end(); ++it) {
1925  const PixelROC* myroc = map_.product()->findItem(*it);
1926  if( myroc->idInDetUnit() == j) {
1927  LocalPixel::RocRowCol local = { 39, 25}; //corresponding to center of ROC row, col
1928  GlobalPixel global = myroc->toGlobal( LocalPixel(local) );
1929  badrocpositions.push_back(global);
1930  break;
1931  }
1932  }
1933  }
1934  }// end of getBadRocPositions
1935 
1936 
1937  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1938  std::pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1939 
1940  for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
1941  if(it->row >= 80 && ip.first >= 80 ){
1942  if((std::abs(ip.second - it->col) < 26) ) {i->second.set(0.);}
1943  else if(it->row==120 && ip.second-it->col==26){i->second.set(0.);}
1944  else if(it->row==119 && it->col-ip.second==26){i->second.set(0.);}
1945  }
1946  else if(it->row < 80 && ip.first < 80 ){
1947  if((std::abs(ip.second - it->col) < 26) ){i->second.set(0.);}
1948  else if(it->row==40 && ip.second-it->col==26){i->second.set(0.);}
1949  else if(it->row==39 && it->col-ip.second==26){i->second.set(0.);}
1950  }
1951  }
1952  }
1953  }
1954 }
1955 
int adc(sample_type sample)
get the ADC sample (12 bits)
#define LogDebug(id)
void init(const edm::EventSetup &es)
size
Write out results.
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
T getParameter(std::string const &) const
Map map_
int i
Definition: DBlmapReader.cc:9
virtual int nrows() const =0
virtual const GeomDetType & type() const override
void pixel_inefficiency_db(uint32_t detID)
signal_map_type::const_iterator signal_map_const_iterator
static const TGPicture * info(bool iBackgroundIsBlack)
Local3DVector LocalVector
Definition: LocalVector.h:12
float tof() const
deprecated name for timeOfFlight()
Definition: PSimHit.h:72
edm::ESHandle< SiPixelFedCablingMap > map_
void init_DynIneffDB(const edm::EventSetup &, const unsigned int &)
bool isBarrel() const
Definition: GeomDetType.cc:13
T y() const
Definition: PV2DBase.h:46
std::map< int, CalParameters, std::less< int > > initCal() const
const std::unique_ptr< SiPixelGainCalibrationOfflineSimService > theSiPixelGainCalibrationService_
LocalVector DriftDirection(const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const DetId &detId) const
SiPixelDigitizerAlgorithm(const edm::ParameterSet &conf)
const std::vector< float > & getMix_TrueInteractions() const
const std::unique_ptr< SiG4UniversalFluctuation > fluctuate
PixelEfficiencies(const edm::ParameterSet &conf, bool AddPixelInefficiency, int NumberOfBarrelLayers, int NumberOfEndcapDisks)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const std::vector< int > & getMix_bunchCrossing() const
unsigned int pxbLadder(const DetId &id) const
T y() const
Definition: PV3DBase.h:63
bool exists(std::string const &parameterName) const
checks if a parameter exists
virtual std::pair< float, float > pitch() const =0
const Bounds & bounds() const
Definition: Surface.h:120
std::vector< std::vector< double > > thePUEfficiency
unsigned int pxbModule(const DetId &id) const
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
edm::ESHandle< TrackerGeometry > geom_
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
SigmaX
Definition: gun_cff.py:25
identify pixel inside single ROC
Definition: LocalPixel.h:7
void make_digis(float thePixelThresholdInE, uint32_t detID, const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelDigiSimLink > &simlinks, const TrackerTopology *tTopo) const
static int pixelToChannel(int row, int col)
Definition: PixelDigi.h:68
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void induce_signal(const PSimHit &hit, const size_t hitIndex, const unsigned int tofBin, const PixelGeomDetUnit *pixdet, const std::vector< SignalPoint > &collection_points)
const std::vector< uint32_t > getDetIdmasks() const
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:38
T mag() const
Definition: PV3DBase.h:67
bunchspace
in terms of 25 ns
float missCalibrate(uint32_t detID, const PixelGeomDetUnit *pixdet, int col, int row, float amp) const
const std::map< int, CalParameters, std::less< int > > calmap
float pixel_aging(const PixelAging &aging, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo) const
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
static int pixelToChannelROC(const int rowROC, const int colROC)
Definition: PixelIndices.h:250
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
static std::pair< int, int > channelToPixelROC(const int chan)
Definition: PixelIndices.h:253
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:40
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)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
virtual std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
double f[11][100]
virtual int channel(const LocalPoint &p) const =0
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const
const std::vector< disabledModuleType > getBadComponentList() const
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< LinkConnSpec >::const_iterator IT
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
Definition: PSimHit.h:63
bool isTrackerPixel() const
Definition: GeomDetType.cc:29
signal_map_type::iterator signal_map_iterator
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
double p2[4]
Definition: TauolaWrapper.h:90
edm::ESHandle< SiPixelLorentzAngle > SiPixelLorentzAngle_
unsigned int pxfModule(const DetId &id) const
ii
Definition: cuy.py:588
void fluctuateEloss(int particleId, float momentum, float eloss, float length, int NumberOfSegments, float elossVector[], CLHEP::HepRandomEngine *) const
const std::unique_ptr< GaussianTailNoiseGenerator > theNoiser
Definition: DetId.h:18
std::map< int, Amplitude, std::less< int > > signal_map_type
edm::ESHandle< SiPixelQuality > SiPixelBadModule_
virtual float thickness() const =0
SigmaY
Definition: gun_cff.py:26
void primary_ionization(const PSimHit &hit, std::vector< EnergyDepositUnit > &ionization_points, CLHEP::HepRandomEngine *) const
void init_from_db(const edm::ESHandle< TrackerGeometry > &, const edm::ESHandle< SiPixelDynamicInefficiency > &)
void calculateInstlumiFactor(PileupMixingContent *puInfo)
const T & get() const
Definition: EventSetup.h:56
static std::pair< int, int > channelToPixel(int ch)
Definition: PixelDigi.h:62
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
void accumulateSimHits(const std::vector< PSimHit >::const_iterator inputBegin, const std::vector< PSimHit >::const_iterator inputEnd, const size_t inputBeginGlobalIndex, const unsigned int tofBin, const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
row and collumn in ROC representation
Definition: LocalPixel.h:15
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
edm::ESHandle< SiPixelDynamicInefficiency > SiPixelDynamicInefficiency_
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
unsigned int layer(const DetId &id) const
bool matches(const DetId &, const DetId &, const std::vector< uint32_t > &)
std::vector< edm::ParameterSet > Parameters
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:75
HLT enums.
virtual int ncolumns() const =0
int particleType() const
Definition: PSimHit.h:85
double p1[4]
Definition: TauolaWrapper.h:89
col
Definition: cuy.py:1008
Signal rand(Signal arg)
Definition: vlib.cc:442
float getLorentzAngle(const uint32_t &) const
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
const std::map< unsigned int, std::vector< double > > & getPUFactors() const
const RotationType & rotation() const
Definition: sp.h:21
PixelAging(const edm::ParameterSet &conf, bool AddPixelAging, int NumberOfBarrelLayers, int NumberOfEndcapDisks)
void drift(const PSimHit &hit, const PixelGeomDetUnit *pixdet, const GlobalVector &bfield, const TrackerTopology *tTopo, const std::vector< EnergyDepositUnit > &ionization_points, std::vector< SignalPoint > &collection_points) const
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
virtual SubDetector subDetector() const
Which subdetector.
Definition: GeomDet.cc:44
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
T const * product() const
Definition: ESHandle.h:86
Definition: vlib.h:208
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
unsigned int pxfPanel(const DetId &id) const
const std::map< unsigned int, double > & getColGeomFactors() const
*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
Definition: invegas.h:5
unsigned int detUnitId() const
Definition: PSimHit.h:93
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:45
const std::map< unsigned int, double > & getPixelGeomFactors() const
Definition: aging.py:1
GlobalPixel toGlobal(const LocalPixel &loc) const
Definition: PixelROC.h:59
void add_noise(const PixelGeomDetUnit *pixdet, float thePixelThreshold, CLHEP::HepRandomEngine *)
double p3[4]
Definition: TauolaWrapper.h:91
void pixel_inefficiency(const PixelEfficiencies &eff, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
const std::map< unsigned int, double > & getChipGeomFactors() const
const DetUnitContainer & detUnits() const
Returm a vector of all GeomDetUnit.