CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
85 
91 
92 // Geometry
97 
99 
100 using namespace edm;
101 using namespace sipixelobjects;
102 
103 #define TP_DEBUG // protect all LogDebug with ifdef. Takes too much CPU
104 
105 
107  if(use_ineff_from_db_){// load gain calibration service fromdb...
108  theSiPixelGainCalibrationService_->setESObjects( es );
109  }
110  if(use_deadmodule_DB_) {
111  es.get<SiPixelQualityRcd>().get(SiPixelBadModule_);
112  }
113  if(use_LorentzAngle_DB_) {
114  // Get Lorentz angle from DB record
115  es.get<SiPixelLorentzAngleSimRcd>().get(SiPixelLorentzAngle_);
116  }
117  //gets the map and geometry from the DB (to kill ROCs)
118  es.get<SiPixelFedCablingMapRcd>().get(map_);
119  es.get<TrackerDigiGeometryRecord>().get(geom_);
120 }
121 
122 //=========================================================================
123 
125 
126  _signal(),
127  makeDigiSimLinks_(conf.getUntrackedParameter<bool>("makeDigiSimLinks", true)),
128  use_ineff_from_db_(conf.getParameter<bool>("useDB")),
129  use_module_killing_(conf.getParameter<bool>("killModules")), // boolean to kill or not modules
130  use_deadmodule_DB_(conf.getParameter<bool>("DeadModules_DB")), // boolean to access dead modules from DB
131  use_LorentzAngle_DB_(conf.getParameter<bool>("LorentzAngle_DB")), // boolean to access Lorentz angle from DB
132 
133  DeadModules(use_deadmodule_DB_ ? Parameters() : conf.getParameter<Parameters>("DeadModules")), // get dead module from cfg file
134 
135  // Common pixel parameters
136  // These are parameters which are not likely to be changed
137  GeVperElectron(3.61E-09), // 1 electron(3.61eV, 1keV(277e, mod 9/06 d.k.
138  Sigma0(0.00037), // Charge diffusion constant 7->3.7
139  Dist300(0.0300), // normalized to 300micron Silicon
140  alpha2Order(conf.getParameter<bool>("Alpha2Order")), // switch on/off of E.B effect
141  ClusterWidth(3.), // Charge integration spread on the collection plane
142 
143  // get external parameters:
144  // To account for upgrade geometries do not assume the number
145  // of layers or disks.
146  NumberOfBarrelLayers(conf.exists("NumPixelBarrel")?conf.getParameter<int>("NumPixelBarrel"):3),
147  NumberOfEndcapDisks(conf.exists("NumPixelEndcap")?conf.getParameter<int>("NumPixelEndcap"):2),
148 
149  theInstLumiScaleFactor(conf.getParameter<double>("theInstLumiScaleFactor")), //For dynamic inefficiency PU scaling
150  bunchScaleAt25(conf.getParameter<double>("bunchScaleAt25")), //For dynamic inefficiency bunchspace scaling
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>("AddPixelInefficiencyFromPython")),
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 SiPixelDigitizerAlgorithm::PixelEfficiencies::PixelEfficiencies(const edm::ParameterSet& conf, bool AddPixelInefficiency, int NumberOfBarrelLayers, int NumberOfEndcapDisks) {
360  // pixel inefficiency
361  // Don't use Hard coded values, read inefficiencies in from python or don't use any
362  int NumberOfTotLayers = NumberOfBarrelLayers + NumberOfEndcapDisks;
364  if (AddPixelInefficiency){
365  int i=0;
366  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix1");
367  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix2");
368  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix3");
369  if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix4");}
370  //
371  i=0;
372  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix1");
373  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix2");
374  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix3");
375  if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix4");}
376  //
377  i=0;
378  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix1");
379  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix2");
380  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix3");
381  if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix4");}
382  //
383  i=0;
384  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix1");
385  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix2");
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!";
390  //
391  i=0;
392  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix1");
393  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix2");
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!";
398  //
399  i=0;
400  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_BPix1");
401  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_BPix2");
402  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_BPix3");
403  if ( ((thePUEfficiency[0].size()==0) || (thePUEfficiency[1].size()==0) ||
404  (thePUEfficiency[2].size()==0)) && (NumberOfBarrelLayers==3) )
405  throw cms::Exception("Configuration") << "At least one PU efficiency (BPix) number is needed in efficiency config!";
406  // The next is needed for Phase2 Tracker studies
407  if (NumberOfBarrelLayers>=5){
408  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
409  // For Phase2 tracker layers just set the outermost BPix inefficiency to 99.9% THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
410  for (int j=5 ; j<=NumberOfBarrelLayers ; j++){
411  thePixelColEfficiency[j-1]=0.999;
412  thePixelEfficiency[j-1]=0.999;
413  thePixelChipEfficiency[j-1]=0.999;
414  }
415  }
416  //
417  i=FPixIndex;
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");}
421  i=FPixIndex;
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");}
425  i=FPixIndex;
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");}
429  // The next is needed for Phase2 Tracker studies
430  if (NumberOfEndcapDisks>=4){
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 extra FPix disk inefficiency to 99.9% THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
433  for (int j=4+FPixIndex ; j<=NumberOfEndcapDisks+NumberOfBarrelLayers ; j++){
434  thePixelColEfficiency[j-1]=0.999;
435  thePixelEfficiency[j-1]=0.999;
436  thePixelChipEfficiency[j-1]=0.999;
437  }
438  }
439  //FPix Dynamic Inefficiency
440  i=FPixIndex;
441  theInnerEfficiency_FPix[i++] = conf.getParameter<double>("theInnerEfficiency_FPix1");
442  theInnerEfficiency_FPix[i++] = conf.getParameter<double>("theInnerEfficiency_FPix2");
443  i=FPixIndex;
444  theOuterEfficiency_FPix[i++] = conf.getParameter<double>("theOuterEfficiency_FPix1");
445  theOuterEfficiency_FPix[i++] = conf.getParameter<double>("theOuterEfficiency_FPix2");
446  i=FPixIndex;
447  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_FPix_Inner");
448  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_FPix_Outer");
449  if ( ((thePUEfficiency[3].size()==0) || (thePUEfficiency[4].size()==0)) && (NumberOfEndcapDisks==2) )
450  throw cms::Exception("Configuration") << "At least one (FPix) PU efficiency number is needed in efficiency config!";
451  }
452  // the first "NumberOfBarrelLayers" settings [0],[1], ... , [NumberOfBarrelLayers-1] are for the barrel pixels
453  // the next "NumberOfEndcapDisks" settings [NumberOfBarrelLayers],[NumberOfBarrelLayers+1], ... [NumberOfEndcapDisks+NumberOfBarrelLayers-1]
454 }
455 
457  // pixel aging
458  // Don't use Hard coded values, read aging in from python or don't use any
459  if(AddAging) {
460  int NumberOfTotLayers = NumberOfBarrelLayers + NumberOfEndcapDisks;
461  FPixIndex=NumberOfBarrelLayers;
462 
463  int i=0;
464  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_BPix1");
465  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_BPix2");
466  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_BPix3");
467  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_BPix4");
468 
469  // to be removed when Gaelle will have the phase2 digitizer
470  if (NumberOfBarrelLayers>=5){
471  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
472  // For Phase2 tracker layers just set the outermost BPix aging 0.
473  for (int j=5 ; j<=NumberOfBarrelLayers ; j++){
474  thePixelPseudoRadDamage[j-1]=0.;
475  }
476  }
477  //
478  i=FPixIndex;
479  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_FPix1");
480  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_FPix2");
481  thePixelPseudoRadDamage[i++] = conf.getParameter<double>("thePixelPseudoRadDamage_FPix3");
482 
483  //To be removed when Phase2 digitizer will be available
484  if (NumberOfEndcapDisks>=4){
485  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
486  // For Phase2 tracker layers just set the extra FPix disk aging to 0. BE CAREFUL THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
487  for (int j=4+FPixIndex ; j<=NumberOfEndcapDisks+NumberOfBarrelLayers ; j++){
488  thePixelPseudoRadDamage[j-1]=0.;
489  }
490  }
491  }
492  // the first "NumberOfBarrelLayers" settings [0],[1], ... , [NumberOfBarrelLayers-1] are for the barrel pixels
493  // the next "NumberOfEndcapDisks" settings [NumberOfBarrelLayers],[NumberOfBarrelLayers+1], ... [NumberOfEndcapDisks+NumberOfBarrelLayers-1]
494 }
495 
496 //=========================================================================
497 void SiPixelDigitizerAlgorithm::accumulateSimHits(std::vector<PSimHit>::const_iterator inputBegin,
498  std::vector<PSimHit>::const_iterator inputEnd,
499  const size_t inputBeginGlobalIndex,
500  const unsigned int tofBin,
501  const PixelGeomDetUnit* pixdet,
502  const GlobalVector& bfield,
503  const TrackerTopology *tTopo,
504  CLHEP::HepRandomEngine* engine) {
505  // produce SignalPoint's for all SimHit's in detector
506  // Loop over hits
507 
508  uint32_t detId = pixdet->geographicalId().rawId();
509  size_t simHitGlobalIndex=inputBeginGlobalIndex; // This needs to stored to create the digi-sim link later
510  for (std::vector<PSimHit>::const_iterator ssbegin = inputBegin; ssbegin != inputEnd; ++ssbegin, ++simHitGlobalIndex) {
511  // skip hits not in this detector.
512  if((*ssbegin).detUnitId() != detId) {
513  continue;
514  }
515 
516 #ifdef TP_DEBUG
517  LogDebug ("Pixel Digitizer")
518  << (*ssbegin).particleType() << " " << (*ssbegin).pabs() << " "
519  << (*ssbegin).energyLoss() << " " << (*ssbegin).tof() << " "
520  << (*ssbegin).trackId() << " " << (*ssbegin).processType() << " "
521  << (*ssbegin).detUnitId()
522  << (*ssbegin).entryPoint() << " " << (*ssbegin).exitPoint() ;
523 #endif
524 
525 
526  std::vector<EnergyDepositUnit> ionization_points;
527  std::vector<SignalPoint> collection_points;
528 
529  // fill collection_points for this SimHit, indpendent of topology
530  // Check the TOF cut
531  if ( ((*ssbegin).tof() - pixdet->surface().toGlobal((*ssbegin).localPosition()).mag()/30.)>= theTofLowerCut &&
532  ((*ssbegin).tof()- pixdet->surface().toGlobal((*ssbegin).localPosition()).mag()/30.) <= theTofUpperCut ) {
533  primary_ionization(*ssbegin, ionization_points, engine); // fills _ionization_points
534  drift(*ssbegin, pixdet, bfield, tTopo, ionization_points, collection_points); // transforms _ionization_points to collection_points
535  // compute induced signal on readout elements and add to _signal
536  induce_signal(*ssbegin, simHitGlobalIndex, tofBin, pixdet, collection_points); // 1st 3 args needed only for SimHit<-->Digi link
537  } // end if
538  } // end for
539 
540 }
541 
542 //============================================================================
544  //Instlumi scalefactor calculating for dynamic inefficiency
545 
546  if (puInfo) {
547  const std::vector<int> bunchCrossing = puInfo->getMix_bunchCrossing();
548  const std::vector<float> TrueInteractionList = puInfo->getMix_TrueInteractions();
549  const int bunchSpacing = puInfo->getMix_bunchSpacing();
550  double bunchScale=1.0;
551 
552  if (bunchSpacing==25) bunchScale=bunchScaleAt25;
553 
554  int pui = 0, p = 0;
555  std::vector<int>::const_iterator pu;
556  std::vector<int>::const_iterator pu0 = bunchCrossing.end();
557 
558  for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++pu) {
559  if (*pu==0) {
560  pu0 = pu;
561  p = pui;
562  }
563  pui++;
564  }
565 
566  if (pu0!=bunchCrossing.end()) {
567  for (size_t i=0; i<5; i++) {
568  double instlumi = TrueInteractionList.at(p)*theInstLumiScaleFactor*bunchScale;
569  double instlumi_pow=1.;
570  _pu_scale[i] = 0;
571  for (size_t j=0; j<pixelEfficiencies_.thePUEfficiency[i].size(); j++){
572  _pu_scale[i]+=instlumi_pow*pixelEfficiencies_.thePUEfficiency[i][j];
573  instlumi_pow*=instlumi;
574  }
575  }
576  }
577  }
578  else {
579  for (int i=0; i<5;i++) {
580  _pu_scale[i] = 1.;
581  }
582  }
583 }
584 
585 //============================================================================
587  std::vector<PixelDigi>& digis,
588  std::vector<PixelDigiSimLink>& simlinks,
589  const TrackerTopology *tTopo,
590  CLHEP::HepRandomEngine* engine) {
591 
592  // Pixel Efficiency moved from the constructor to this method because
593  // the information of the det are not available in the constructor
594  // Efficiency parameters. 0 - no inefficiency, 1-low lumi, 10-high lumi
595 
596  uint32_t detID = pixdet->geographicalId().rawId();
597  const signal_map_type& theSignal = _signal[detID];
598 
599  const PixelTopology* topol=&pixdet->specificTopology();
600  int numColumns = topol->ncolumns(); // det module number of cols&rows
601  int numRows = topol->nrows();
602 
603  // Noise already defined in electrons
604  // thePixelThresholdInE = thePixelThreshold * theNoiseInElectrons ;
605  // Find the threshold in noise units, needed for the noiser.
606 
607 
608  float thePixelThresholdInE = 0.;
609 
610  if(theNoiseInElectrons>0.){
611  if(pixdet->type().isTrackerPixel() && pixdet->type().isBarrel()){ // Barrel modules
612  int lay = tTopo->layer(detID);
615  thePixelThresholdInE = CLHEP::RandGaussQ::shoot(engine, theThresholdInE_BPix_L1, theThresholdSmearing_BPix_L1); // gaussian smearing
616  } else {
617  thePixelThresholdInE = CLHEP::RandGaussQ::shoot(engine, theThresholdInE_BPix , theThresholdSmearing_BPix); // gaussian smearing
618  }
619  } else {
621  thePixelThresholdInE = theThresholdInE_BPix_L1;
622  } else {
623  thePixelThresholdInE = theThresholdInE_BPix; // no smearing
624  }
625  }
626  } else if(pixdet->type().isTrackerPixel()) { // Forward disks modules
628  thePixelThresholdInE = CLHEP::RandGaussQ::shoot(engine, theThresholdInE_FPix, theThresholdSmearing_FPix); // gaussian smearing
629  } else {
630  thePixelThresholdInE = theThresholdInE_FPix; // no smearing
631  }
632  }
633  else {throw cms::Exception("NotAPixelGeomDetUnit") << "Not a pixel geomdet unit" << detID;}
634  }
635 
636 
637 #ifdef TP_DEBUG
638  // full detector thickness
639  float moduleThickness = pixdet->specificSurface().bounds().thickness();
640  LogDebug ("PixelDigitizer")
641  << " PixelDigitizer "
642  << numColumns << " " << numRows << " " << moduleThickness;
643 #endif
644 
645  if(addNoise) add_noise(pixdet, thePixelThresholdInE/theNoiseInElectrons, engine); // generate noise
646 
647  // Do only if needed
648 
649  if((AddPixelInefficiency) && (theSignal.size()>0))
650  pixel_inefficiency(pixelEfficiencies_, pixdet, tTopo, engine); // Kill some pixels
651 
652  if(use_ineff_from_db_ && (theSignal.size()>0))
653  pixel_inefficiency_db(detID);
654 
655  if(use_module_killing_) {
656  if (use_deadmodule_DB_) { // remove dead modules using DB
657  module_killing_DB(detID);
658  } else { // remove dead modules using the list in cfg file
659  module_killing_conf(detID);
660  }
661  }
662 
663  make_digis(thePixelThresholdInE, detID, pixdet, digis, simlinks, tTopo);
664 
665 #ifdef TP_DEBUG
666  LogDebug ("PixelDigitizer") << "[SiPixelDigitizerAlgorithm] converted " << digis.size() << " PixelDigis in DetUnit" << detID;
667 #endif
668 }
669 
670 //***********************************************************************/
671 // Generate primary ionization along the track segment.
672 // Divide the track into small sub-segments
673 void SiPixelDigitizerAlgorithm::primary_ionization(const PSimHit& hit, std::vector<EnergyDepositUnit>& ionization_points, CLHEP::HepRandomEngine* engine) const {
674 
675  // Straight line approximation for trajectory inside active media
676 
677  const float SegmentLength = 0.0010; //10microns in cm
678  float energy;
679 
680  // Get the 3D segment direction vector
681  LocalVector direction = hit.exitPoint() - hit.entryPoint();
682 
683  float eLoss = hit.energyLoss(); // Eloss in GeV
684  float length = direction.mag(); // Track length in Silicon
685 
686  int NumberOfSegments = int ( length / SegmentLength); // Number of segments
687  if(NumberOfSegments < 1) NumberOfSegments = 1;
688 
689 #ifdef TP_DEBUG
690  LogDebug ("Pixel Digitizer")
691  << " enter primary_ionzation " << NumberOfSegments
692  << " shift = "
693  << (hit.exitPoint().x()-hit.entryPoint().x()) << " "
694  << (hit.exitPoint().y()-hit.entryPoint().y()) << " "
695  << (hit.exitPoint().z()-hit.entryPoint().z()) << " "
696  << hit.particleType() <<" "<< hit.pabs() ;
697 #endif
698 
699  float* elossVector = new float[NumberOfSegments]; // Eloss vector
700 
701  if( fluctuateCharge ) {
702  //MP DA RIMUOVERE ASSOLUTAMENTE
703  int pid = hit.particleType();
704  //int pid=211; // assume it is a pion
705 
706  float momentum = hit.pabs();
707  // Generate fluctuated charge points
708  fluctuateEloss(pid, momentum, eLoss, length, NumberOfSegments,
709  elossVector, engine);
710  }
711 
712  ionization_points.resize( NumberOfSegments); // set size
713 
714  // loop over segments
715  for ( int i = 0; i != NumberOfSegments; i++) {
716  // Divide the segment into equal length subsegments
717  Local3DPoint point = hit.entryPoint() +
718  float((i+0.5)/NumberOfSegments) * direction;
719 
720  if( fluctuateCharge )
721  energy = elossVector[i]/GeVperElectron; // Convert charge to elec.
722  else
723  energy = hit.energyLoss()/GeVperElectron/float(NumberOfSegments);
724 
725  EnergyDepositUnit edu( energy, point); //define position,energy point
726  ionization_points[i] = edu; // save
727 
728 #ifdef TP_DEBUG
729  LogDebug ("Pixel Digitizer")
730  << i << " " << ionization_points[i].x() << " "
731  << ionization_points[i].y() << " "
732  << ionization_points[i].z() << " "
733  << ionization_points[i].energy();
734 #endif
735 
736  } // end for loop
737 
738  delete[] elossVector;
739 
740 }
741 //******************************************************************************
742 
743 // Fluctuate the charge comming from a small (10um) track segment.
744 // Use the G4 routine. For mip pions for the moment.
745 void SiPixelDigitizerAlgorithm::fluctuateEloss(int pid, float particleMomentum,
746  float eloss, float length,
747  int NumberOfSegs,float elossVector[],
748  CLHEP::HepRandomEngine* engine) const {
749 
750  // Get dedx for this track
751  //float dedx;
752  //if( length > 0.) dedx = eloss/length;
753  //else dedx = eloss;
754 
755  double particleMass = 139.6; // Mass in MeV, Assume pion
756  pid = std::abs(pid);
757  if(pid!=211) { // Mass in MeV
758  if(pid==11) particleMass = 0.511;
759  else if(pid==13) particleMass = 105.7;
760  else if(pid==321) particleMass = 493.7;
761  else if(pid==2212) particleMass = 938.3;
762  }
763  // What is the track segment length.
764  float segmentLength = length/NumberOfSegs;
765 
766  // Generate charge fluctuations.
767  float de=0.;
768  float sum=0.;
769  double segmentEloss = (1000.*eloss)/NumberOfSegs; //eloss in MeV
770  for (int i=0;i<NumberOfSegs;i++) {
771  // material,*, momentum,energy,*, *, mass
772  //myglandz_(14.,segmentLength,2.,2.,dedx,de,0.14);
773  // The G4 routine needs momentum in MeV, mass in Mev, delta-cut in MeV,
774  // track segment length in mm, segment eloss in MeV
775  // Returns fluctuated eloss in MeV
776  double deltaCutoff = tMax; // the cutoff is sometimes redefined inside, so fix it.
777  de = fluctuate->SampleFluctuations(double(particleMomentum*1000.),
778  particleMass, deltaCutoff,
779  double(segmentLength*10.),
780  segmentEloss, engine )/1000.; //convert to GeV
781  elossVector[i]=de;
782  sum +=de;
783  }
784 
785  if(sum>0.) { // If fluctuations give eloss>0.
786  // Rescale to the same total eloss
787  float ratio = eloss/sum;
788 
789  for (int ii=0;ii<NumberOfSegs;ii++) elossVector[ii]= ratio*elossVector[ii];
790  } else { // If fluctuations gives 0 eloss
791  float averageEloss = eloss/NumberOfSegs;
792  for (int ii=0;ii<NumberOfSegs;ii++) elossVector[ii]= averageEloss;
793  }
794  return;
795 }
796 
797 //*******************************************************************************
798 // Drift the charge segments to the sensor surface (collection plane)
799 // Include the effect of E-field and B-field
801  const PixelGeomDetUnit* pixdet,
802  const GlobalVector& bfield,
803  const TrackerTopology *tTopo,
804  const std::vector<EnergyDepositUnit>& ionization_points,
805  std::vector<SignalPoint>& collection_points) const {
806 
807 #ifdef TP_DEBUG
808  LogDebug ("Pixel Digitizer") << " enter drift " ;
809 #endif
810 
811  collection_points.resize(ionization_points.size()); // set size
812 
813  LocalVector driftDir=DriftDirection(pixdet, bfield, hit.detUnitId()); // get the charge drift direction
814  if(driftDir.z() ==0.) {
815  LogWarning("Magnetic field") << " pxlx: drift in z is zero ";
816  return;
817  }
818 
819  // tangent of Lorentz angle
820  //float TanLorenzAngleX = driftDir.x()/driftDir.z();
821  //float TanLorenzAngleY = 0.; // force to 0, driftDir.y()/driftDir.z();
822 
823  float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
824  CosLorenzAngleY;
825  if( alpha2Order) {
826  TanLorenzAngleX = driftDir.x(); // tangen of Lorentz angle
827  TanLorenzAngleY = driftDir.y();
828  dir_z = driftDir.z(); // The z drift direction
829  CosLorenzAngleX = 1./sqrt(1.+TanLorenzAngleX*TanLorenzAngleX); //cosine
830  CosLorenzAngleY = 1./sqrt(1.+TanLorenzAngleY*TanLorenzAngleY); //cosine;
831 
832  } else{
833  TanLorenzAngleX = driftDir.x();
834  TanLorenzAngleY = 0.; // force to 0, driftDir.y()/driftDir.z();
835  dir_z = driftDir.z(); // The z drift direction
836  CosLorenzAngleX = 1./sqrt(1.+TanLorenzAngleX*TanLorenzAngleX); //cosine to estimate the path length
837  CosLorenzAngleY = 1.;
838  }
839 
840  float moduleThickness = pixdet->specificSurface().bounds().thickness();
841 #ifdef TP_DEBUG
842  LogDebug ("Pixel Digitizer")
843  << " Lorentz Tan " << TanLorenzAngleX << " " << TanLorenzAngleY <<" "
844  << CosLorenzAngleX << " " << CosLorenzAngleY << " "
845  << moduleThickness*TanLorenzAngleX << " " << driftDir;
846 #endif
847 
848  float Sigma_x = 1.; // Charge spread
849  float Sigma_y = 1.;
850  float DriftDistance; // Distance between charge generation and collection
851  float DriftLength; // Actual Drift Lentgh
852  float Sigma;
853 
854  for (unsigned int i = 0; i != ionization_points.size(); i++) {
855 
856  float SegX, SegY, SegZ; // position
857  SegX = ionization_points[i].x();
858  SegY = ionization_points[i].y();
859  SegZ = ionization_points[i].z();
860 
861  // Distance from the collection plane
862  //DriftDistance = (moduleThickness/2. + SegZ); // Drift to -z
863  // Include explixitely the E drift direction (for CMS dir_z=-1)
864  DriftDistance = moduleThickness/2. - (dir_z * SegZ); // Drift to -z
865 
866  //if( DriftDistance <= 0.)
867  //cout<<" <=0 "<<DriftDistance<<" "<<i<<" "<<SegZ<<" "<<dir_z<<" "
868  // <<SegX<<" "<<SegY<<" "<<(moduleThickness/2)<<" "
869  // <<ionization_points[i].energy()<<" "
870  // <<hit.particleType()<<" "<<hit.pabs()<<" "<<hit.energyLoss()<<" "
871  // <<hit.entryPoint()<<" "<<hit.exitPoint()
872  // <<std::endl;
873 
874  if( DriftDistance < 0.) {
875  DriftDistance = 0.;
876  } else if( DriftDistance > moduleThickness )
877  DriftDistance = moduleThickness;
878 
879  // Assume full depletion now, partial depletion will come later.
880  float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
881  float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
882 
883  // Shift cloud center
884  float CloudCenterX = SegX + XDriftDueToMagField;
885  float CloudCenterY = SegY + YDriftDueToMagField;
886 
887  // Calculate how long is the charge drift path
888  DriftLength = sqrt( DriftDistance*DriftDistance +
889  XDriftDueToMagField*XDriftDueToMagField +
890  YDriftDueToMagField*YDriftDueToMagField );
891 
892  // What is the charge diffusion after this path
893  Sigma = sqrt(DriftLength/Dist300) * Sigma0;
894 
895  // Project the diffusion sigma on the collection plane
896  Sigma_x = Sigma / CosLorenzAngleX ;
897  Sigma_y = Sigma / CosLorenzAngleY ;
898 
899  // Insert a charge loss due to Rad Damage here
900  float energyOnCollector = ionization_points[i].energy(); // The energy that reaches the collector
901 
902  // add pixel aging
903  if (AddPixelAging) {
904  float kValue = pixel_aging(pixelAging_,pixdet,tTopo);
905  energyOnCollector *= exp( -1*kValue*DriftDistance/moduleThickness );
906  }
907 
908 #ifdef TP_DEBUG
909  LogDebug ("Pixel Digitizer")
910  <<" Dift DistanceZ= "<<DriftDistance<<" module thickness= "<<moduleThickness
911  <<" Start Energy= "<<ionization_points[i].energy()<<" Energy after loss= "<<energyOnCollector;
912 #endif
913  SignalPoint sp( CloudCenterX, CloudCenterY,
914  Sigma_x, Sigma_y, hit.tof(), energyOnCollector );
915 
916  // Load the Charge distribution parameters
917  collection_points[i] = (sp);
918 
919  } // loop over ionization points, i.
920 
921 } // end drift
922 
923 //*************************************************************************
924 // Induce the signal on the collection plane of the active sensor area.
926  const size_t hitIndex,
927  const unsigned int tofBin,
928  const PixelGeomDetUnit* pixdet,
929  const std::vector<SignalPoint>& collection_points) {
930 
931  // X - Rows, Left-Right, 160, (1.6cm) for barrel
932  // Y - Columns, Down-Up, 416, (6.4cm)
933 
934  const PixelTopology* topol=&pixdet->specificTopology();
935  uint32_t detID= pixdet->geographicalId().rawId();
936  signal_map_type& theSignal = _signal[detID];
937 
938 #ifdef TP_DEBUG
939  LogDebug ("Pixel Digitizer")
940  << " enter induce_signal, "
941  << topol->pitch().first << " " << topol->pitch().second; //OK
942 #endif
943 
944  // local map to store pixels hit by 1 Hit.
945  typedef std::map< int, float, std::less<int> > hit_map_type;
946  hit_map_type hit_signal;
947 
948  // map to store pixel integrals in the x and in the y directions
949  std::map<int, float, std::less<int> > x,y;
950 
951  // Assign signals to readout channels and store sorted by channel number
952 
953  // Iterate over collection points on the collection plane
954  for ( std::vector<SignalPoint>::const_iterator i=collection_points.begin();
955  i != collection_points.end(); ++i) {
956 
957  float CloudCenterX = i->position().x(); // Charge position in x
958  float CloudCenterY = i->position().y(); // in y
959  float SigmaX = i->sigma_x(); // Charge spread in x
960  float SigmaY = i->sigma_y(); // in y
961  float Charge = i->amplitude(); // Charge amplitude
962 
963 
964  //if(SigmaX==0 || SigmaY==0) {
965  //cout<<SigmaX<<" "<<SigmaY
966  // << " cloud " << i->position().x() << " " << i->position().y() << " "
967  // << i->sigma_x() << " " << i->sigma_y() << " " << i->amplitude()<<std::endl;
968  //}
969 
970 #ifdef TP_DEBUG
971  LogDebug ("Pixel Digitizer")
972  << " cloud " << i->position().x() << " " << i->position().y() << " "
973  << i->sigma_x() << " " << i->sigma_y() << " " << i->amplitude();
974 #endif
975 
976  // Find the maximum cloud spread in 2D plane , assume 3*sigma
977  float CloudRight = CloudCenterX + ClusterWidth*SigmaX;
978  float CloudLeft = CloudCenterX - ClusterWidth*SigmaX;
979  float CloudUp = CloudCenterY + ClusterWidth*SigmaY;
980  float CloudDown = CloudCenterY - ClusterWidth*SigmaY;
981 
982  // Define 2D cloud limit points
983  LocalPoint PointRightUp = LocalPoint(CloudRight,CloudUp);
984  LocalPoint PointLeftDown = LocalPoint(CloudLeft,CloudDown);
985 
986  // This points can be located outside the sensor area.
987  // The conversion to measurement point does not check for that
988  // so the returned pixel index might be wrong (outside range).
989  // We rely on the limits check below to fix this.
990  // But remember whatever we do here THE CHARGE OUTSIDE THE ACTIVE
991  // PIXEL AREA IS LOST, it should not be collected.
992 
993  // Convert the 2D points to pixel indices
994  MeasurementPoint mp = topol->measurementPosition(PointRightUp ); //OK
995 
996  int IPixRightUpX = int( floor( mp.x()));
997  int IPixRightUpY = int( floor( mp.y()));
998 
999 #ifdef TP_DEBUG
1000  LogDebug ("Pixel Digitizer") << " right-up " << PointRightUp << " "
1001  << mp.x() << " " << mp.y() << " "
1002  << IPixRightUpX << " " << IPixRightUpY ;
1003 #endif
1004 
1005  mp = topol->measurementPosition(PointLeftDown ); //OK
1006 
1007  int IPixLeftDownX = int( floor( mp.x()));
1008  int IPixLeftDownY = int( floor( mp.y()));
1009 
1010 #ifdef TP_DEBUG
1011  LogDebug ("Pixel Digitizer") << " left-down " << PointLeftDown << " "
1012  << mp.x() << " " << mp.y() << " "
1013  << IPixLeftDownX << " " << IPixLeftDownY ;
1014 #endif
1015 
1016  // Check detector limits to correct for pixels outside range.
1017  int numColumns = topol->ncolumns(); // det module number of cols&rows
1018  int numRows = topol->nrows();
1019 
1020  IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
1021  IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
1022  IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
1023  IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
1024 
1025  x.clear(); // clear temporary integration array
1026  y.clear();
1027 
1028  // First integrate charge strips in x
1029  int ix; // TT for compatibility
1030  for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) { // loop over x index
1031  float xUB, xLB, UpperBound, LowerBound;
1032 
1033  // Why is set to 0 if ix=0, does it meen that we accept charge
1034  // outside the sensor? CHeck How it was done in ORCA?
1035  //if(ix == 0) LowerBound = 0.;
1036  if(ix == 0 || SigmaX==0. ) // skip for surface segemnts
1037  LowerBound = 0.;
1038  else {
1039  mp = MeasurementPoint( float(ix), 0.0);
1040  xLB = topol->localPosition(mp).x();
1041  LowerBound = 1-calcQ((xLB-CloudCenterX)/SigmaX);
1042  }
1043 
1044  if(ix == numRows-1 || SigmaX==0. )
1045  UpperBound = 1.;
1046  else {
1047  mp = MeasurementPoint( float(ix+1), 0.0);
1048  xUB = topol->localPosition(mp).x();
1049  UpperBound = 1. - calcQ((xUB-CloudCenterX)/SigmaX);
1050  }
1051 
1052  float TotalIntegrationRange = UpperBound - LowerBound; // get strip
1053  x[ix] = TotalIntegrationRange; // save strip integral
1054  //if(SigmaX==0 || SigmaY==0)
1055  //cout<<TotalIntegrationRange<<" "<<ix<<std::endl;
1056 
1057  }
1058 
1059  // Now integrate strips in y
1060  int iy; // TT for compatibility
1061  for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) { //loope over y ind
1062  float yUB, yLB, UpperBound, LowerBound;
1063 
1064  if(iy == 0 || SigmaY==0.)
1065  LowerBound = 0.;
1066  else {
1067  mp = MeasurementPoint( 0.0, float(iy) );
1068  yLB = topol->localPosition(mp).y();
1069  LowerBound = 1. - calcQ((yLB-CloudCenterY)/SigmaY);
1070  }
1071 
1072  if(iy == numColumns-1 || SigmaY==0. )
1073  UpperBound = 1.;
1074  else {
1075  mp = MeasurementPoint( 0.0, float(iy+1) );
1076  yUB = topol->localPosition(mp).y();
1077  UpperBound = 1. - calcQ((yUB-CloudCenterY)/SigmaY);
1078  }
1079 
1080  float TotalIntegrationRange = UpperBound - LowerBound;
1081  y[iy] = TotalIntegrationRange; // save strip integral
1082  //if(SigmaX==0 || SigmaY==0)
1083  //cout<<TotalIntegrationRange<<" "<<iy<<std::endl;
1084  }
1085 
1086  // Get the 2D charge integrals by folding x and y strips
1087  int chan;
1088  for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) { // loop over x index
1089  for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) { //loope over y ind
1090 
1091  float ChargeFraction = Charge*x[ix]*y[iy];
1092 
1093  if( ChargeFraction > 0. ) {
1094  chan = PixelDigi::pixelToChannel( ix, iy); // Get index
1095  // Load the amplitude
1096  hit_signal[chan] += ChargeFraction;
1097  } // endif
1098 
1099 
1100  mp = MeasurementPoint( float(ix), float(iy) );
1101  LocalPoint lp = topol->localPosition(mp);
1102  chan = topol->channel(lp);
1103 
1104 #ifdef TP_DEBUG
1105  LogDebug ("Pixel Digitizer")
1106  << " pixel " << ix << " " << iy << " - "<<" "
1107  << chan << " " << ChargeFraction<<" "
1108  << mp.x() << " " << mp.y() <<" "
1109  << lp.x() << " " << lp.y() << " " // givex edge position
1110  << chan; // edge belongs to previous ?
1111 #endif
1112 
1113  } // endfor iy
1114  } //endfor ix
1115 
1116 
1117  // Test conversions (THIS IS FOR TESTING ONLY) comment-out.
1118  // mp = topol->measurementPosition( i->position() ); //OK
1119  // LocalPoint lp = topol->localPosition(mp); //OK
1120  // std::pair<float,float> p = topol->pixel( i->position() ); //OK
1121  // chan = PixelDigi::pixelToChannel( int(p.first), int(p.second));
1122  // std::pair<int,int> ip = PixelDigi::channelToPixel(chan);
1123  // MeasurementPoint mp1 = MeasurementPoint( float(ip.first),
1124  // float(ip.second) );
1125  // LogDebug ("Pixel Digitizer") << " Test "<< mp.x() << " " << mp.y()
1126  // << " "<< lp.x() << " " << lp.y() << " "<<" "
1127  // <<p.first <<" "<<p.second<<" "<<chan<< " "
1128  // <<" " << ip.first << " " << ip.second << " "
1129  // << mp1.x() << " " << mp1.y() << " " //OK
1130  // << topol->localPosition(mp1).x() << " " //OK
1131  // << topol->localPosition(mp1).y() << " "
1132  // << topol->channel( i->position() ); //OK
1133 
1134 
1135  } // loop over charge distributions
1136 
1137  // Fill the global map with all hit pixels from this event
1138 
1139  for ( hit_map_type::const_iterator im = hit_signal.begin();
1140  im != hit_signal.end(); ++im) {
1141  int chan = (*im).first;
1142  theSignal[chan] += (makeDigiSimLinks_ ? Amplitude( (*im).second, &hit, hitIndex, tofBin, (*im).second) : Amplitude( (*im).second, (*im).second) ) ;
1143 
1144 #ifdef TP_DEBUG
1145  std::pair<int,int> ip = PixelDigi::channelToPixel(chan);
1146  LogDebug ("Pixel Digitizer")
1147  << " pixel " << ip.first << " " << ip.second << " "
1148  << theSignal[chan];
1149 #endif
1150  }
1151 
1152 } // end induce_signal
1153 
1154 /***********************************************************************/
1155 
1156 // Build pixels, check threshold, add misscalibration, ...
1157 void SiPixelDigitizerAlgorithm::make_digis(float thePixelThresholdInE,
1158  uint32_t detID,
1159  const PixelGeomDetUnit* pixdet,
1160  std::vector<PixelDigi>& digis,
1161  std::vector<PixelDigiSimLink>& simlinks,
1162  const TrackerTopology *tTopo) const {
1163 
1164 #ifdef TP_DEBUG
1165  LogDebug ("Pixel Digitizer") << " make digis "<<" "
1166  << " pixel threshold FPix" << theThresholdInE_FPix << " "
1167  << " pixel threshold BPix" << theThresholdInE_BPix << " "
1168  << " pixel threshold BPix Layer1" << theThresholdInE_BPix_L1 << " "
1169  << " List pixels passing threshold ";
1170 #endif
1171 
1172  // Loop over hit pixels
1173 
1174  signalMaps::const_iterator it = _signal.find(detID);
1175  if (it == _signal.end()) {
1176  return;
1177  }
1178 
1179  const signal_map_type& theSignal = (*it).second;
1180 
1181  for (signal_map_const_iterator i = theSignal.begin(); i != theSignal.end(); ++i) {
1182 
1183  float signalInElectrons = (*i).second ; // signal in electrons
1184 
1185  // Do the miss calibration for calibration studies only.
1186  //if(doMissCalibrate) signalInElectrons = missCalibrate(signalInElectrons)
1187 
1188  // Do only for pixels above threshold
1189 
1190  if( signalInElectrons >= thePixelThresholdInE) { // check threshold
1191 
1192  int chan = (*i).first; // channel number
1193  std::pair<int,int> ip = PixelDigi::channelToPixel(chan);
1194  int adc=0; // ADC count as integer
1195 
1196  // Do the miss calibration for calibration studies only.
1197  if(doMissCalibrate) {
1198  int row = ip.first; // X in row
1199  int col = ip.second; // Y is in col
1200  adc = int(missCalibrate(detID, pixdet, col, row, signalInElectrons)); //full misscalib.
1201  } else { // Just do a simple electron->adc conversion
1202  adc = int( signalInElectrons / theElectronPerADC ); // calibrate gain
1203  }
1204  adc = std::min(adc, theAdcFullScale); // Check maximum value
1205 // Calculate layerIndex
1207  if(pixdet->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) { // Phase 2 OT Barrel only
1208  // Set to 1 if over the threshold
1209  if (theAdcFullScaleStack==1) {adc=1;}
1210  // Make it a linear fit to the full scale of the normal adc count. Start new adc from 1 not zero.
1212  }
1213  } // Only enter this if the Adc changes for the outer layers
1214 #ifdef TP_DEBUG
1215  LogDebug ("Pixel Digitizer")
1216  << (*i).first << " " << (*i).second << " " << signalInElectrons
1217  << " " << adc << ip.first << " " << ip.second ;
1218 #endif
1219 
1220  // Load digis
1221  digis.emplace_back(ip.first, ip.second, adc);
1222 
1223  if (makeDigiSimLinks_ && (*i).second.hitInfo()!=0) {
1224  //digilink
1225  if((*i).second.trackIds().size()>0){
1226  simlink_map simi;
1227  unsigned int il=0;
1228  for( std::vector<unsigned int>::const_iterator itid = (*i).second.trackIds().begin();
1229  itid != (*i).second.trackIds().end(); ++itid) {
1230  simi[*itid].push_back((*i).second.individualampl()[il]);
1231  il++;
1232  }
1233 
1234  //sum the contribution of the same trackid
1235  for( simlink_map::iterator simiiter=simi.begin();
1236  simiiter!=simi.end();
1237  simiiter++){
1238 
1239  float sum_samechannel=0;
1240  for (unsigned int iii=0;iii<(*simiiter).second.size();iii++){
1241  sum_samechannel+=(*simiiter).second[iii];
1242  }
1243  float fraction=sum_samechannel/(*i).second;
1244  if(fraction>1.) fraction=1.;
1245  simlinks.emplace_back((*i).first, (*simiiter).first, (*i).second.hitIndex(), (*i).second.tofBin(), (*i).second.eventId(), fraction);
1246  }
1247  }
1248  }
1249  }
1250  }
1251 }
1252 
1253 /***********************************************************************/
1254 
1255 // Add electronic noise to pixel charge
1257  float thePixelThreshold,
1258  CLHEP::HepRandomEngine* engine) {
1259 
1260 #ifdef TP_DEBUG
1261  LogDebug ("Pixel Digitizer") << " enter add_noise " << theNoiseInElectrons;
1262 #endif
1263 
1264  uint32_t detID= pixdet->geographicalId().rawId();
1265  signal_map_type& theSignal = _signal[detID];
1266 
1267 
1268  // First add noise to hit pixels
1269  float theSmearedChargeRMS = 0.0;
1270 
1271  for ( signal_map_iterator i = theSignal.begin(); i != theSignal.end(); i++) {
1272 
1274  {
1275  if((*i).second < 3000)
1276  {
1277  theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1278  } else if((*i).second < 6000){
1279  theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1280  } else{
1281  theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1282  }
1283 
1284  // Noise from Vcal smearing:
1285  float noise_ChargeVCALSmearing = theSmearedChargeRMS * CLHEP::RandGaussQ::shoot(engine, 0., 1.);
1286  // Noise from full readout:
1287  float noise = CLHEP::RandGaussQ::shoot(engine, 0., theReadoutNoise);
1288 
1289  if(((*i).second + Amplitude(noise+noise_ChargeVCALSmearing, -1.)) < 0. ) {
1290  (*i).second.set(0);}
1291  else{
1292  (*i).second +=Amplitude(noise+noise_ChargeVCALSmearing, -1.);
1293  }
1294 
1295  } // End if addChargeVCalSmearing
1296  else
1297  {
1298  // Noise: ONLY full READOUT Noise.
1299  // Use here the FULL readout noise, including TBM,ALT,AOH,OPT-REC.
1300  float noise = CLHEP::RandGaussQ::shoot(engine, 0., theReadoutNoise);
1301 
1302  if(((*i).second + Amplitude(noise, -1.)) < 0. ) {
1303  (*i).second.set(0);}
1304  else{
1305  (*i).second +=Amplitude(noise, -1.);
1306  }
1307  } // end if only Noise from full readout
1308 
1309  }
1310 
1311  if(!addNoisyPixels) // Option to skip noise in non-hit pixels
1312  return;
1313 
1314  const PixelTopology* topol=&pixdet->specificTopology();
1315  int numColumns = topol->ncolumns(); // det module number of cols&rows
1316  int numRows = topol->nrows();
1317 
1318  // Add noise on non-hit pixels
1319  // Use here the pixel noise
1320  int numberOfPixels = (numRows * numColumns);
1321  std::map<int,float, std::less<int> > otherPixels;
1322  std::map<int,float, std::less<int> >::iterator mapI;
1323 
1324  theNoiser->generate(numberOfPixels,
1325  thePixelThreshold, //thr. in un. of nois
1326  theNoiseInElectrons, // noise in elec.
1327  otherPixels,
1328  engine );
1329 
1330 #ifdef TP_DEBUG
1331  LogDebug ("Pixel Digitizer")
1332  << " Add noisy pixels " << numRows << " "
1333  << numColumns << " " << theNoiseInElectrons << " "
1334  << theThresholdInE_FPix << theThresholdInE_BPix <<" "<< numberOfPixels<<" "
1335  << otherPixels.size() ;
1336 #endif
1337 
1338  // Add noisy pixels
1339  for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1340  int iy = ((*mapI).first) / numRows;
1341  int ix = ((*mapI).first) - (iy*numRows);
1342 
1343  // Keep for a while for testing.
1344  if( iy < 0 || iy > (numColumns-1) )
1345  LogWarning ("Pixel Geometry") << " error in iy " << iy ;
1346  if( ix < 0 || ix > (numRows-1) )
1347  LogWarning ("Pixel Geometry") << " error in ix " << ix ;
1348 
1349  int chan = PixelDigi::pixelToChannel(ix, iy);
1350 
1351 #ifdef TP_DEBUG
1352  LogDebug ("Pixel Digitizer")
1353  <<" Storing noise = " << (*mapI).first << " " << (*mapI).second
1354  << " " << ix << " " << iy << " " << chan ;
1355 #endif
1356 
1357  if(theSignal[chan] == 0){
1358  // float noise = float( (*mapI).second );
1359  int noise=int( (*mapI).second );
1360  theSignal[chan] = Amplitude (noise, -1.);
1361  }
1362  }
1363 }
1364 
1365 /***********************************************************************/
1366 
1367 // Simulate the readout inefficiencies.
1368 // Delete a selected number of single pixels, dcols and rocs.
1370  const PixelGeomDetUnit* pixdet,
1371  const TrackerTopology *tTopo,
1372  CLHEP::HepRandomEngine* engine) {
1373 
1374  uint32_t detID= pixdet->geographicalId().rawId();
1375  signal_map_type& theSignal = _signal[detID];
1376  const PixelTopology* topol=&pixdet->specificTopology();
1377  int numColumns = topol->ncolumns(); // det module number of cols&rows
1378  int numRows = topol->nrows();
1379 
1380  // Predefined efficiencies
1381  double pixelEfficiency = 1.0;
1382  double columnEfficiency = 1.0;
1383  double chipEfficiency = 1.0;
1384 
1385  // setup the chip indices conversion
1387  pixdet->subDetector()==GeomDetEnumerators::SubDetector::P1PXB){// barrel layers
1388  int layerIndex=tTopo->layer(detID);
1389  pixelEfficiency = eff.thePixelEfficiency[layerIndex-1];
1390  columnEfficiency = eff.thePixelColEfficiency[layerIndex-1];
1391  chipEfficiency = eff.thePixelChipEfficiency[layerIndex-1];
1392  //std::cout <<"Using BPix columnEfficiency = "<<columnEfficiency<< " for layer = "<<layerIndex <<"\n";
1393  // This should never happen, but only check if it is not an upgrade geometry
1394  if (NumberOfBarrelLayers==3){
1395  if(numColumns>416) LogWarning ("Pixel Geometry") <<" wrong columns in barrel "<<numColumns;
1396  if(numRows>160) LogWarning ("Pixel Geometry") <<" wrong rows in barrel "<<numRows;
1397 
1398  int ladder=tTopo->pxbLadder(detID);
1399  int module=tTopo->pxbModule(detID);
1400  if (module<=4) module=5-module;
1401  else module-=4;
1402 
1403  columnEfficiency *= eff.theLadderEfficiency_BPix[layerIndex-1][ladder-1]*eff.theModuleEfficiency_BPix[layerIndex-1][module-1]*_pu_scale[layerIndex-1];
1404  }
1407  pixdet->subDetector()==GeomDetEnumerators::SubDetector::P2PXEC){ // forward disks
1408 
1409  unsigned int diskIndex=tTopo->layer(detID)+eff.FPixIndex; // Use diskIndex-1 later to stay consistent with BPix
1410  unsigned int panelIndex=tTopo->pxfPanel(detID);
1411  unsigned int moduleIndex=tTopo->pxfModule(detID);
1412  //if (eff.FPixIndex>diskIndex-1){throw cms::Exception("Configuration") <<"SiPixelDigitizer is using the wrong efficiency value. index = "
1413  // <<diskIndex-1<<" , MinIndex = "<<eff.FPixIndex<<" ... "<<tTopo->pxfDisk(detID);}
1414  pixelEfficiency = eff.thePixelEfficiency[diskIndex-1];
1415  columnEfficiency = eff.thePixelColEfficiency[diskIndex-1];
1416  chipEfficiency = eff.thePixelChipEfficiency[diskIndex-1];
1417  //std::cout <<"Using FPix columnEfficiency = "<<columnEfficiency<<" for Disk = "<< tTopo->pxfDisk(detID)<<"\n";
1418  // Sometimes the forward pixels have wrong size,
1419  // this crashes the index conversion, so exit, but only check if it is not an upgrade geometry
1420  if (NumberOfBarrelLayers==3){ // whether it is the present or the phase 1 detector can be checked using GeomDetEnumerators::SubDetector
1421  if(numColumns>260 || numRows>160) {
1422  if(numColumns>260) LogWarning ("Pixel Geometry") <<" wrong columns in endcaps "<<numColumns;
1423  if(numRows>160) LogWarning ("Pixel Geometry") <<" wrong rows in endcaps "<<numRows;
1424  return;
1425  }
1426  if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) { //inner modules
1427  columnEfficiency*=eff.theInnerEfficiency_FPix[diskIndex-1]*_pu_scale[3];
1428  } else { //outer modules
1429  columnEfficiency*=eff.theOuterEfficiency_FPix[diskIndex-1]*_pu_scale[4];
1430  }
1431  } // current detector, forward
1433  // If phase 2 outer tracker, hardcoded values as they have been so far
1434  pixelEfficiency = 0.999;
1435  columnEfficiency = 0.999;
1436  chipEfficiency = 0.999;
1437  } // if barrel/forward
1438 
1439 #ifdef TP_DEBUG
1440  LogDebug ("Pixel Digitizer") << " enter pixel_inefficiency " << pixelEfficiency << " "
1441  << columnEfficiency << " " << chipEfficiency;
1442 #endif
1443 
1444  // Initilize the index converter
1445  //PixelIndices indexConverter(numColumns,numRows);
1446  std::auto_ptr<PixelIndices> pIndexConverter(new PixelIndices(numColumns,numRows));
1447 
1448  int chipIndex = 0;
1449  int rowROC = 0;
1450  int colROC = 0;
1451  std::map<int, int, std::less<int> >chips, columns;
1452  std::map<int, int, std::less<int> >::iterator iter;
1453 
1454  // Find out the number of columns and rocs hits
1455  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
1456  for (signal_map_const_iterator i = theSignal.begin(); i != theSignal.end(); ++i) {
1457 
1458  int chan = i->first;
1459  std::pair<int,int> ip = PixelDigi::channelToPixel(chan);
1460  int row = ip.first; // X in row
1461  int col = ip.second; // Y is in col
1462  //transform to ROC index coordinates
1463  pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1464  int dColInChip = pIndexConverter->DColumn(colROC); // get ROC dcol from ROC col
1465  //dcol in mod
1466  int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1467 
1468  chips[chipIndex]++;
1469  columns[dColInDet]++;
1470  }
1471 
1472  // Delete some ROC hits.
1473  for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1474  //float rand = RandFlat::shoot();
1475  float rand = CLHEP::RandFlat::shoot(engine);
1476  if( rand > chipEfficiency ) chips[iter->first]=0;
1477  }
1478 
1479  // Delete some Dcol hits.
1480  for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1481  //float rand = RandFlat::shoot();
1482  float rand = CLHEP::RandFlat::shoot(engine);
1483  if( rand > columnEfficiency ) columns[iter->first]=0;
1484  }
1485 
1486  // Now loop again over pixels to kill some of them.
1487  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
1488  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1489 
1490  // int chan = i->first;
1491  std::pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1492  int row = ip.first; // X in row
1493  int col = ip.second; // Y is in col
1494  //transform to ROC index coordinates
1495  pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1496  int dColInChip = pIndexConverter->DColumn(colROC); //get ROC dcol from ROC col
1497  //dcol in mod
1498  int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1499 
1500  //float rand = RandFlat::shoot();
1501  float rand = CLHEP::RandFlat::shoot(engine);
1502  if( chips[chipIndex]==0 || columns[dColInDet]==0
1503  || rand>pixelEfficiency ) {
1504  // make pixel amplitude =0, pixel will be lost at clusterization
1505  i->second.set(0.); // reset amplitude,
1506  } // end if
1507 
1508  } // end pixel loop
1509 } // end pixel_indefficiency
1510 
1511 //***************************************************************************************
1512 // Simulate pixel aging with an exponential function
1513 //**************************************************************************************
1514 
1516  const PixelGeomDetUnit *pixdet,
1517  const TrackerTopology *tTopo) const {
1518 
1519  uint32_t detID= pixdet->geographicalId().rawId();
1520 
1521 
1522  // Predefined damage parameter (no aging)
1523  float pseudoRadDamage = 0.0;
1524 
1525  // setup the chip indices conversion
1527  pixdet->subDetector() == GeomDetEnumerators::SubDetector::P1PXB){// barrel layers
1528  int layerIndex=tTopo->layer(detID);
1529 
1530  pseudoRadDamage = aging.thePixelPseudoRadDamage[layerIndex-1];
1531 
1532  // std::cout << "pixel_aging: " << std::endl;
1533  // std::cout << "Subid " << Subid << " layerIndex " << layerIndex << " ladder " << tTopo->pxbLadder(detID) << " module " << tTopo->pxbModule(detID) << std::endl;
1534 
1537  pixdet->subDetector() == GeomDetEnumerators::SubDetector::P2PXEC) { // forward disks
1538  unsigned int diskIndex=tTopo->layer(detID)+aging.FPixIndex; // Use diskIndex-1 later to stay consistent with BPix
1539 
1540  pseudoRadDamage = aging.thePixelPseudoRadDamage[diskIndex-1];
1541 
1542  // std::cout << "pixel_aging: " << std::endl;
1543  // std::cout << "Subid " << Subid << " diskIndex " << diskIndex << std::endl;
1545  // if phase 2 OT hardcoded value as it has always been
1546  pseudoRadDamage = 0.;
1547  } // if barrel/forward
1548 
1549  // std::cout << " pseudoRadDamage " << pseudoRadDamage << std::endl;
1550  // std::cout << " end pixel_aging " << std::endl;
1551 
1552  return pseudoRadDamage;
1553 #ifdef TP_DEBUG
1554  LogDebug ("Pixel Digitizer") << " enter pixel_aging " << pseudoRadDamage;
1555 #endif
1556 
1557 }
1558 
1559 //***********************************************************************
1560 
1561 // Fluctuate the gain and offset for the amplitude calibration
1562 // Use gaussian smearing.
1563 //float SiPixelDigitizerAlgorithm::missCalibrate(const float amp) const {
1564  //float gain = RandGaussQ::shoot(1.,theGainSmearing);
1565  //float offset = RandGaussQ::shoot(0.,theOffsetSmearing);
1566  //float newAmp = amp * gain + offset;
1567  // More complex misscalibration
1568 float SiPixelDigitizerAlgorithm::missCalibrate(uint32_t detID, const PixelGeomDetUnit* pixdet, int col,int row,
1569  const float signalInElectrons) const {
1570  // Central values
1571  //const float p0=0.00352, p1=0.868, p2=112., p3=113.; // pix(0,0,0)
1572  // const float p0=0.00382, p1=0.886, p2=112.7, p3=113.0; // average roc=0
1573  //const float p0=0.00492, p1=1.998, p2=90.6, p3=134.1; // average roc=6
1574  // Smeared (rms)
1575  //const float s0=0.00020, s1=0.051, s2=5.4, s3=4.4; // average roc=0
1576  //const float s0=0.00015, s1=0.043, s2=3.2, s3=3.1; // col average roc=0
1577 
1578  // Make 2 sets of parameters for Fpix and BPIx:
1579 
1580  float p0=0.0;
1581  float p1=0.0;
1582  float p2=0.0;
1583  float p3=0.0;
1584 
1585  if(pixdet->type().isTrackerPixel() && pixdet->type().isBarrel()){// barrel layers
1586  p0 = BPix_p0;
1587  p1 = BPix_p1;
1588  p2 = BPix_p2;
1589  p3 = BPix_p3;
1590  } else if(pixdet->type().isTrackerPixel()) {// forward disks
1591  p0 = FPix_p0;
1592  p1 = FPix_p1;
1593  p2 = FPix_p2;
1594  p3 = FPix_p3;
1595  } else {
1596  throw cms::Exception("NotAPixelGeomDetUnit") << "Not a pixel geomdet unit" << detID;
1597  }
1598 
1599  // const float electronsPerVCAL = 65.5; // our present VCAL calibration (feb 2009)
1600  // const float electronsPerVCAL_Offset = -414.0; // our present VCAL calibration (feb 2009)
1601  float newAmp = 0.; //Modified signal
1602 
1603  // Convert electrons to VCAL units
1604  float signal = (signalInElectrons-electronsPerVCAL_Offset)/electronsPerVCAL;
1605 
1606  // Simulate the analog response with fixed parametrization
1607  newAmp = p3 + p2 * tanh(p0*signal - p1);
1608 
1609 
1610  // Use the pixel-by-pixel calibrations
1611  //transform to ROC index coordinates
1612  //int chipIndex=0, colROC=0, rowROC=0;
1613  //std::auto_ptr<PixelIndices> pIndexConverter(new PixelIndices(numColumns,numRows));
1614  //pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1615 
1616  // Use calibration from a file
1617  //int chanROC = PixelIndices::pixelToChannelROC(rowROC,colROC); // use ROC coordinates
1618  //float pp0=0, pp1=0,pp2=0,pp3=0;
1619  //map<int,CalParameters,std::less<int> >::const_iterator it=calmap.find(chanROC);
1620  //CalParameters y = (*it).second;
1621  //pp0 = y.p0;
1622  //pp1 = y.p1;
1623  //pp2 = y.p2;
1624  //pp3 = y.p3;
1625 
1626  //
1627  // Use random smearing
1628  // Randomize the pixel response
1629  //float pp0 = RandGaussQ::shoot(p0,s0);
1630  //float pp1 = RandGaussQ::shoot(p1,s1);
1631  //float pp2 = RandGaussQ::shoot(p2,s2);
1632  //float pp3 = RandGaussQ::shoot(p3,s3);
1633 
1634  //newAmp = pp3 + pp2 * tanh(pp0*signal - pp1); // Final signal
1635 
1636  //cout<<" misscalibrate "<<col<<" "<<row<<" "<<chipIndex<<" "<<colROC<<" "
1637  // <<rowROC<<" "<<signalInElectrons<<" "<<signal<<" "<<newAmp<<" "
1638  // <<(signalInElectrons/theElectronPerADC)<<std::endl;
1639 
1640  return newAmp;
1641 }
1642 //******************************************************************************
1643 
1644 // Set the drift direction accoring to the Bfield in local det-unit frame
1645 // Works for both barrel and forward pixels.
1646 // Replace the sign convention to fit M.Swartz's formulaes.
1647 // Configurations for barrel and foward pixels possess different tanLorentzAngleperTesla
1648 // parameter value
1649 
1651  const GlobalVector& bfield,
1652  const DetId& detId) const {
1653  Frame detFrame(pixdet->surface().position(),pixdet->surface().rotation());
1654  LocalVector Bfield=detFrame.toLocal(bfield);
1655 
1656  float alpha2_FPix;
1657  float alpha2_BPix;
1658  float alpha2;
1659 
1660  //float dir_x = -tanLorentzAnglePerTesla * Bfield.y();
1661  //float dir_y = +tanLorentzAnglePerTesla * Bfield.x();
1662  //float dir_z = -1.; // E field always in z direction, so electrons go to -z
1663  // The dir_z has to be +/- 1. !
1664  // LocalVector theDriftDirection = LocalVector(dir_x,dir_y,dir_z);
1665 
1666  float dir_x = 0.0;
1667  float dir_y = 0.0;
1668  float dir_z = 0.0;
1669  float scale = 0.0;
1670 
1671  uint32_t detID= pixdet->geographicalId().rawId();
1672 
1673 
1674  // Read Lorentz angle from cfg file:**************************************************************
1675 
1676  if(!use_LorentzAngle_DB_){
1677 
1678  if( alpha2Order) {
1681  }else {
1682  alpha2_FPix = 0.0;
1683  alpha2_BPix = 0.0;
1684  }
1685 
1686  if(pixdet->type().isTrackerPixel() && pixdet->type().isBarrel()){// barrel layers
1687  dir_x = -( tanLorentzAnglePerTesla_BPix * Bfield.y() + alpha2_BPix* Bfield.z()* Bfield.x() );
1688  dir_y = +( tanLorentzAnglePerTesla_BPix * Bfield.x() - alpha2_BPix* Bfield.z()* Bfield.y() );
1689  dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1690  scale = -dir_z;
1691  } else if (pixdet->type().isTrackerPixel()) {// forward disks
1692  dir_x = -( tanLorentzAnglePerTesla_FPix * Bfield.y() + alpha2_FPix* Bfield.z()* Bfield.x() );
1693  dir_y = +( tanLorentzAnglePerTesla_FPix * Bfield.x() - alpha2_FPix* Bfield.z()* Bfield.y() );
1694  dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1695  scale = -dir_z;
1696  } else {
1697  throw cms::Exception("NotAPixelGeomDetUnit") << "Not a pixel geomdet unit" << detID;
1698  }
1699  } // end: Read LA from cfg file.
1700 
1701  //Read Lorentz angle from DB:********************************************************************
1703  float lorentzAngle = SiPixelLorentzAngle_->getLorentzAngle(detId);
1704  alpha2 = lorentzAngle * lorentzAngle;
1705  //std::cout << "detID is: "<< it->first <<"The LA per tesla is: "<< it->second << std::std::endl;
1706  dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1707  dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1708  dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1709  scale = -dir_z;
1710  }// end: Read LA from DataBase.
1711 
1712  LocalVector theDriftDirection = LocalVector(dir_x/scale, dir_y/scale, dir_z/scale );
1713 
1714 #ifdef TP_DEBUG
1715  LogDebug ("Pixel Digitizer") << " The drift direction in local coordinate is "
1716  << theDriftDirection ;
1717 #endif
1718 
1719  return theDriftDirection;
1720 }
1721 
1722 //****************************************************************************************************
1723 
1725 
1726  signal_map_type& theSignal = _signal[detID];
1727 
1728  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
1729  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1730 
1731  // int chan = i->first;
1732  std::pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1733  int row = ip.first; // X in row
1734  int col = ip.second; // Y is in col
1735  //transform to ROC index coordinates
1736  if(theSiPixelGainCalibrationService_->isDead(detID, col, row)){
1737  // std::cout << "now in isdead check, row " << detID << " " << col << "," << row << std::std::endl;
1738  // make pixel amplitude =0, pixel will be lost at clusterization
1739  i->second.set(0.); // reset amplitude,
1740  } // end if
1741  } // end pixel loop
1742 } // end pixel_indefficiency
1743 
1744 
1745 //****************************************************************************************************
1746 
1748 
1749  bool isbad=false;
1750 
1751  Parameters::const_iterator itDeadModules=DeadModules.begin();
1752 
1753  int detid = detID;
1754  for(; itDeadModules != DeadModules.end(); ++itDeadModules){
1755  int Dead_detID = itDeadModules->getParameter<int>("Dead_detID");
1756  if(detid == Dead_detID){
1757  isbad=true;
1758  break;
1759  }
1760  }
1761 
1762  if(!isbad)
1763  return;
1764 
1765  signal_map_type& theSignal = _signal[detID];
1766 
1767  std::string Module = itDeadModules->getParameter<std::string>("Module");
1768 
1769  if(Module=="whole"){
1770  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1771  i->second.set(0.); // reset amplitude
1772  }
1773  }
1774 
1775  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1776  std::pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1777 
1778  if(Module=="tbmA" && ip.first>=80 && ip.first<=159){
1779  i->second.set(0.);
1780  }
1781 
1782  if( Module=="tbmB" && ip.first<=79){
1783  i->second.set(0.);
1784  }
1785  }
1786 }
1787 //****************************************************************************************************
1789 // Not SLHC safe for now
1790 
1791  bool isbad=false;
1792 
1793  std::vector<SiPixelQuality::disabledModuleType>disabledModules = SiPixelBadModule_->getBadComponentList();
1794 
1796 
1797  for (size_t id=0;id<disabledModules.size();id++)
1798  {
1799  if(detID==disabledModules[id].DetID){
1800  isbad=true;
1801  badmodule = disabledModules[id];
1802  break;
1803  }
1804  }
1805 
1806  if(!isbad)
1807  return;
1808 
1809  signal_map_type& theSignal = _signal[detID];
1810 
1811  //std::cout<<"Hit in: "<< detID <<" errorType "<< badmodule.errorType<<" BadRocs="<<std::hex<<SiPixelBadModule_->getBadRocs(detID)<<dec<<" "<<std::endl;
1812  if(badmodule.errorType == 0){ // this is a whole dead module.
1813 
1814  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1815  i->second.set(0.); // reset amplitude
1816  }
1817  }
1818  else { // all other module types: half-modules and single ROCs.
1819  // Get Bad ROC position:
1820  //follow the example of getBadRocPositions in CondFormats/SiPixelObjects/src/SiPixelQuality.cc
1821  std::vector<GlobalPixel> badrocpositions (0);
1822  for(unsigned int j = 0; j < 16; j++){
1823  if(SiPixelBadModule_->IsRocBad(detID, j) == true){
1824 
1825  std::vector<CablingPathToDetUnit> path = map_.product()->pathToDetUnit(detID);
1826  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
1827  for (IT it = path.begin(); it != path.end(); ++it) {
1828  const PixelROC* myroc = map_.product()->findItem(*it);
1829  if( myroc->idInDetUnit() == j) {
1830  LocalPixel::RocRowCol local = { 39, 25}; //corresponding to center of ROC row, col
1831  GlobalPixel global = myroc->toGlobal( LocalPixel(local) );
1832  badrocpositions.push_back(global);
1833  break;
1834  }
1835  }
1836  }
1837  }// end of getBadRocPositions
1838 
1839 
1840  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
1841  std::pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1842 
1843  for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
1844  if(it->row >= 80 && ip.first >= 80 ){
1845  if((fabs(ip.second - it->col) < 26) ) {i->second.set(0.);}
1846  else if(it->row==120 && ip.second-it->col==26){i->second.set(0.);}
1847  else if(it->row==119 && it->col-ip.second==26){i->second.set(0.);}
1848  }
1849  else if(it->row < 80 && ip.first < 80 ){
1850  if((fabs(ip.second - it->col) < 26) ){i->second.set(0.);}
1851  else if(it->row==40 && ip.second-it->col==26){i->second.set(0.);}
1852  else if(it->row==39 && it->col-ip.second==26){i->second.set(0.);}
1853  }
1854  }
1855  }
1856  }
1857 }
1858 
int adc(sample_type sample)
get the ADC sample (12 bits)
#define LogDebug(id)
void init(const edm::EventSetup &es)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void pixel_inefficiency_db(uint32_t detID)
signal_map_type::const_iterator signal_map_const_iterator
Local3DVector LocalVector
Definition: LocalVector.h:12
float tof() const
deprecated name for timeOfFlight()
Definition: PSimHit.h:72
edm::ESHandle< SiPixelFedCablingMap > map_
bool isBarrel() const
Definition: GeomDetType.cc:13
T y() const
Definition: PV2DBase.h:46
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 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
virtual const GeomDetType & type() const override
unsigned int pxbLadder(const DetId &id) const
T y() const
Definition: PV3DBase.h:63
virtual int nrows() const =0
const Bounds & bounds() const
Definition: Surface.h:128
unsigned int pxbModule(const DetId &id) const
#define Module(md)
Definition: vmac.h:201
int ii
Definition: cuy.py:588
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
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
virtual float thickness() const =0
void induce_signal(const PSimHit &hit, const size_t hitIndex, const unsigned int tofBin, const PixelGeomDetUnit *pixdet, const std::vector< SignalPoint > &collection_points)
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
tuple path
else: Piece not in the list, fine.
float missCalibrate(uint32_t detID, const PixelGeomDetUnit *pixdet, int col, int row, float amp) const
const std::map< int, CalParameters, std::less< int > > calmap
float pixel_aging(const PixelAging &aging, const PixelGeomDetUnit *pixdet, const TrackerTopology *tTopo) const
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
static int pixelToChannelROC(const int rowROC, const int colROC)
Definition: PixelIndices.h:250
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:39
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 int channel(const LocalPoint &p) const =0
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:77
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
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
double p2[4]
Definition: TauolaWrapper.h:90
edm::ESHandle< SiPixelLorentzAngle > SiPixelLorentzAngle_
tuple conf
Definition: dbtoconf.py:185
unsigned int pxfModule(const DetId &id) const
tuple par0
Definition: fitWZ.py:51
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 std::unique_ptr< GaussianTailNoiseGenerator > theNoiser
Definition: DetId.h:18
std::map< int, Amplitude, std::less< int > > signal_map_type
const PixelEfficiencies pixelEfficiencies_
edm::ESHandle< SiPixelQuality > SiPixelBadModule_
void primary_ionization(const PSimHit &hit, std::vector< EnergyDepositUnit > &ionization_points, CLHEP::HepRandomEngine *) const
void calculateInstlumiFactor(PileupMixingContent *puInfo)
const T & get() const
Definition: EventSetup.h:55
static std::pair< int, int > channelToPixel(int ch)
Definition: PixelDigi.h:62
tuple pid
Definition: sysUtil.py:22
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
T const * product() const
Definition: ESHandle.h:86
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
unsigned int layer(const DetId &id) const
std::vector< edm::ParameterSet > Parameters
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:75
int particleType() const
Definition: PSimHit.h:85
double p1[4]
Definition: TauolaWrapper.h:89
tuple filename
Definition: lut2db_cfg.py:20
Signal rand(Signal arg)
Definition: vlib.cc:442
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
const int & getMix_bunchSpacing() const
const RotationType & rotation() const
tuple cout
Definition: gather_cfg.py:121
PixelAging(const edm::ParameterSet &conf, bool AddPixelAging, int NumberOfBarrelLayers, int NumberOfEndcapDisks)
Definition: DDAxes.h:10
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
int col
Definition: cuy.py:1008
virtual SubDetector subDetector() const
Which subdetector.
Definition: GeomDet.cc:49
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
Definition: vlib.h:208
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
tuple size
Write out results.
unsigned int pxfPanel(const DetId &id) 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:43
GlobalPixel toGlobal(const LocalPixel &loc) const
Definition: PixelROC.h:58
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 *)