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 <vector>
43 #include <iostream>
44 
48 
49 #include <gsl/gsl_sf_erf.h>
51 #include "CLHEP/Random/RandGaussQ.h"
52 #include "CLHEP/Random/RandFlat.h"
53 
54 //#include "SimTracker/SiPixelDigitizer/interface/PixelIndices.h"
57 
62 
63 // Accessing dead pixel modules from the DB:
65 
75 
82 
83 // Geometry
88 
90 
91 using namespace std;
92 using namespace edm;
93 using namespace sipixelobjects;
94 
95 #define TP_DEBUG // protect all LogDebug with ifdef. Takes too much CPU
96 
98  if(use_ineff_from_db_){// load gain calibration service fromdb...
99  theSiPixelGainCalibrationService_= new SiPixelGainCalibrationOfflineSimService(conf_);
100  theSiPixelGainCalibrationService_->setESObjects( es );
101  }
102 
103  fillDeadModules(es); // gets the dead module from config file or DB.
104  fillLorentzAngle(es); // gets the Lorentz angle from the config file or DB.
105  fillMapandGeom(es); //gets the map and geometry from the DB (to kill ROCs)
106 }
107 
108 //=========================================================================
109 
111  if(!use_deadmodule_DB_){
112  DeadModules = conf_.getParameter<Parameters>("DeadModules"); // get dead module from cfg file
113  }
114  else{ // Get dead module from DB record
115  // ESHandle was defined in the header file edm::ESHandle<SiPixelQuality> SiPixelBadModule_;
116  es.get<SiPixelQualityRcd>().get(SiPixelBadModule_);
117  }
118 }
119 
121  if(!use_LorentzAngle_DB_){
122  // Get the Lorentz angle from the cfg file:
123  tanLorentzAnglePerTesla_FPix=conf_.getParameter<double>("TanLorentzAnglePerTesla_FPix");
124  tanLorentzAnglePerTesla_BPix=conf_.getParameter<double>("TanLorentzAnglePerTesla_BPix");
125  }
126  else {
127  // Get Lorentz angle from DB record
128  // ESHandle was defined in the header file edm::ESHandle<SiPixelLorentzAngle> SiPixelLorentzAngle_;
129  es.get<SiPixelLorentzAngleSimRcd>().get(SiPixelLorentzAngle_);
130  }
131 }
132 
133 // For ROC killing:
135  es.get<SiPixelFedCablingMapRcd>().get(map_);
136  es.get<TrackerDigiGeometryRecord>().get(geom_);
137 }
138 
139 //=========================================================================
140 
142  conf_(conf) , fluctuate(0), theNoiser(0), pIndexConverter(0),
143  use_ineff_from_db_(conf_.getParameter<bool>("useDB")),
144  use_module_killing_(conf_.getParameter<bool>("killModules")), // boolean to kill or not modules
145  use_deadmodule_DB_(conf_.getParameter<bool>("DeadModules_DB")), // boolean to access dead modules from DB
146  use_LorentzAngle_DB_(conf_.getParameter<bool>("LorentzAngle_DB")), // boolean to access Lorentz angle from DB
147  theSiPixelGainCalibrationService_(0),rndEngine(eng)
148 {
149  using std::cout;
150  using std::endl;
151 
152  // Common pixel parameters
153  // These are parameters which are not likely to be changed
154  NumberOfSegments = 20; // Default number of track segment divisions
155  ClusterWidth = 3.; // Charge integration spread on the collection plane
156  GeVperElectron = 3.61E-09; // 1 electron =3.61eV, 1keV=277e, mod 9/06 d.k.
157  Sigma0 = 0.00037; // Charge diffusion constant 7->3.7
158  Dist300 = 0.0300; // normalized to 300micron Silicon
159 
160  alpha2Order = conf_.getParameter<bool>("Alpha2Order"); // switch on/off of E.B effect
161 
162  // get external parameters:
163  // ADC calibration 1adc count = 135e.
164  // Corresponds to 2adc/kev, 270[e/kev]/135[e/adc]=2[adc/kev]
165  // Be carefull, this parameter is also used in SiPixelDet.cc to
166  // calculate the noise in adc counts from noise in electrons.
167  // Both defaults should be the same.
168  theElectronPerADC=conf_.getParameter<double>("ElectronPerAdc");
169 
170  // ADC saturation value, 255=8bit adc.
171  //theAdcFullScale=conf_.getUntrackedParameter<int>("AdcFullScale",255);
172  theAdcFullScale=conf_.getParameter<int>("AdcFullScale");
173 
174  // Pixel threshold in units of noise:
175  // thePixelThreshold=conf_.getParameter<double>("ThresholdInNoiseUnits");
176  // Pixel threshold in electron units.
177  theThresholdInE_FPix=conf_.getParameter<double>("ThresholdInElectrons_FPix");
178  theThresholdInE_BPix=conf_.getParameter<double>("ThresholdInElectrons_BPix");
179 
180  // Add threshold gaussian smearing:
181  addThresholdSmearing = conf_.getParameter<bool>("AddThresholdSmearing");
182  theThresholdSmearing_FPix = conf_.getParameter<double>("ThresholdSmearing_FPix");
183  theThresholdSmearing_BPix = conf_.getParameter<double>("ThresholdSmearing_BPix");
184 
185  // signal response new parameterization: split Fpix and BPix
186  FPix_p0 = conf_.getParameter<double>("FPix_SignalResponse_p0");
187  FPix_p1 = conf_.getParameter<double>("FPix_SignalResponse_p1");
188  FPix_p2 = conf_.getParameter<double>("FPix_SignalResponse_p2");
189  FPix_p3 = conf_.getParameter<double>("FPix_SignalResponse_p3");
190 
191  BPix_p0 = conf_.getParameter<double>("BPix_SignalResponse_p0");
192  BPix_p1 = conf_.getParameter<double>("BPix_SignalResponse_p1");
193  BPix_p2 = conf_.getParameter<double>("BPix_SignalResponse_p2");
194  BPix_p3 = conf_.getParameter<double>("BPix_SignalResponse_p3");
195 
196  // electrons to VCAL conversion needed in misscalibrate()
197  electronsPerVCAL = conf_.getParameter<double>("ElectronsPerVcal");
198  electronsPerVCAL_Offset = conf_.getParameter<double>("ElectronsPerVcal_Offset");
199 
200  // Add noise
201  addNoise=conf_.getParameter<bool>("AddNoise");
202 
203  // Smear the pixel charge with a gaussian which RMS is a function of the
204  // pixel charge (Danek's study)
205  addChargeVCALSmearing=conf_.getParameter<bool>("ChargeVCALSmearing");
206 
207  // Add noisy pixels
208  addNoisyPixels=conf_.getParameter<bool>("AddNoisyPixels");
209  // Noise in electrons:
210  // Pixel cell noise, relevant for generating noisy pixels
211  theNoiseInElectrons=conf_.getParameter<double>("NoiseInElectrons");
212  // Fill readout noise, including all readout chain, relevant for smearing
213  //theReadoutNoise=conf_.getUntrackedParameter<double>("ReadoutNoiseInElec",500.);
214  theReadoutNoise=conf_.getParameter<double>("ReadoutNoiseInElec");
215 
216  //theTofCut 12.5, cut in particle TOD +/- 12.5ns
217  //theTofCut=conf_.getUntrackedParameter<double>("TofCut",12.5);
218  theTofLowerCut=conf_.getParameter<double>("TofLowerCut");
219  theTofUpperCut=conf_.getParameter<double>("TofUpperCut");
220 
221  // Fluctuate charge in track subsegments
222  fluctuateCharge=conf_.getUntrackedParameter<bool>("FluctuateCharge",true);
223 
224  // delta cutoff in MeV, has to be same as in OSCAR=0.030/cmsim=1.0 MeV
225  //tMax = 0.030; // In MeV.
226  //tMax =conf_.getUntrackedParameter<double>("DeltaProductionCut",0.030);
227  tMax =conf_.getParameter<double>("DeltaProductionCut");
228 
229  // Control the pixel inefficiency
230  thePixelLuminosity=conf_.getParameter<int>("AddPixelInefficiency");
231 
232  // Get the constants for the miss-calibration studies
233  doMissCalibrate=conf_.getParameter<bool>("MissCalibrate"); // Enable miss-calibration
234  theGainSmearing=conf_.getParameter<double>("GainSmearing"); // sigma of the gain smearing
235  theOffsetSmearing=conf_.getParameter<double>("OffsetSmearing"); //sigma of the offset smearing
236 
237  //pixel inefficiency
238  if (thePixelLuminosity==-20){
239  thePixelColEfficiency[0] = conf_.getParameter<double>("thePixelColEfficiency_BPix1");
240  thePixelColEfficiency[1] = conf_.getParameter<double>("thePixelColEfficiency_BPix2");
241  thePixelColEfficiency[2] = conf_.getParameter<double>("thePixelColEfficiency_BPix3");
242  thePixelColEfficiency[3] = conf_.getParameter<double>("thePixelColEfficiency_FPix1");
243  thePixelColEfficiency[4] = conf_.getParameter<double>("thePixelColEfficiency_FPix2"); // Not used, but leave it in in case we want use it to later
244  cout<<"\nReading in custom Pixel efficiencies "<<thePixelColEfficiency[0]<<" , "<<thePixelColEfficiency[1]<<" , "
245  <<thePixelColEfficiency[2]<<" , "<<thePixelColEfficiency[3]<<" , "<<thePixelColEfficiency[4]<<"\n";
246  if (thePixelColEfficiency[0]<=0.5) {cout <<"\n\nDid you mean to set the Pixel efficiency at "<<thePixelColEfficiency[0]
247  <<", or did you mean for this to be the inefficiency?\n\n\n";}
248  }
249  // the first 3 settings [0],[1],[2] are for the barrel pixels
250  // the next 3 settings [3],[4],[5] are for the endcaps (undecided how)
251 
252  if(thePixelLuminosity==-1) { // No inefficiency, all 100% efficient
253  pixelInefficiency=false;
254  for (int i=0; i<6;i++) {
255  thePixelEfficiency[i] = 1.; // pixels = 100%
256  thePixelColEfficiency[i] = 1.; // columns = 100%
257  thePixelChipEfficiency[i] = 1.; // chips = 100%
258  }
259 
260  // include only the static (non rate depedent) efficiency
261  // Usefull for very low rates (luminosity)
262  } else if(thePixelLuminosity==0) { // static effciency
263  pixelInefficiency=true;
264  // Default efficiencies
265  for (int i=0; i<6;i++) {
266  if(i<3) { // For the barrel
267  // Assume 1% inefficiency for single pixels,
268  // this is given by faulty bump-bonding and seus.
269  thePixelEfficiency[i] = 1.-0.001; // pixels = 99.9%
270  // For columns make 0.1% default.
271  thePixelColEfficiency[i] = 1.-0.001; // columns = 99.9%
272  // A flat 0.1% inefficiency due to lost rocs
273  thePixelChipEfficiency[i] = 1.-0.001; // chips = 99.9%
274  } else { // For the endcaps
275  // Assume 1% inefficiency for single pixels,
276  // this is given by faulty bump-bonding and seus.
277  thePixelEfficiency[i] = 1.-0.001; // pixels = 99.9%
278  // For columns make 0.1% default.
279  thePixelColEfficiency[i] = 1.-0.001; // columns = 99.9%
280  // A flat 0.1% inefficiency due to lost rocs
281  thePixelChipEfficiency[i] = 1.-0.001; // chips = 99.9%
282  }
283  }
284 
285  // Include also luminosity rate dependent inefficieny
286  } else if(thePixelLuminosity>0) { // Include effciency
287  pixelInefficiency=true;
288  // Default efficiencies
289  for (int i=0; i<6;i++) {
290  if(i<3) { // For the barrel
291  // Assume 1% inefficiency for single pixels,
292  // this is given by faulty bump-bonding and seus.
293  thePixelEfficiency[i] = 1.-0.01; // pixels = 99%
294  // For columns make 1% default.
295  thePixelColEfficiency[i] = 1.-0.01; // columns = 99%
296  // A flat 0.25% inefficiency due to lost data packets from TBM
297  thePixelChipEfficiency[i] = 1.-0.0025; // chips = 99.75%
298  } else { // For the endcaps
299  // Assume 1% inefficiency for single pixels,
300  // this is given by faulty bump-bonding and seus.
301  thePixelEfficiency[i] = 1.-0.01; // pixels = 99%
302  // For columns make 1% default.
303  thePixelColEfficiency[i] = 1.-0.01; // columns = 99%
304  // A flat 0.25% inefficiency due to lost data packets from TBM
305  thePixelChipEfficiency[i] = 1.-0.0025; // chips = 99.75%
306  }
307  }
308 
309  // Special cases ( High-lumi for 4cm layer) where the readout losses are higher
310  if(thePixelLuminosity==10) { // For high luminosity, bar layer 1
311  thePixelColEfficiency[0] = 1.-0.034; // 3.4% for r=4 only
312  thePixelEfficiency[0] = 1.-0.015; // 1.5% for r=4
313  }
314 
315  } // end the pixel inefficiency part
316 
317  // Init the random number services
318  if(addNoise || thePixelLuminosity || fluctuateCharge || addThresholdSmearing ) {
319  gaussDistribution_ = new CLHEP::RandGaussQ(rndEngine, 0., theReadoutNoise);
320  gaussDistributionVCALNoise_ = new CLHEP::RandGaussQ(rndEngine, 0., 1.);
321  flatDistribution_ = new CLHEP::RandFlat(rndEngine, 0., 1.);
322 
323  if(addNoise) {
325  }
326 
327  if(fluctuateCharge) {
329  }
330 
331  // Threshold smearing with gaussian distribution:
332  if(addThresholdSmearing) {
333  smearedThreshold_FPix_ = new CLHEP::RandGaussQ(rndEngine, theThresholdInE_FPix , theThresholdSmearing_FPix);
334  smearedThreshold_BPix_ = new CLHEP::RandGaussQ(rndEngine, theThresholdInE_BPix , theThresholdSmearing_BPix);
335  }
336  } //end Init the random number services
337 
338 
339  // Prepare for the analog amplitude miss-calibration
340  if(doMissCalibrate) {
341  LogDebug ("PixelDigitizer ")
342  << " miss-calibrate the pixel amplitude ";
343 
344  const bool ReadCalParameters = false;
345  if(ReadCalParameters) { // Read the calibration files from file
346  // read the calibration constants from a file (testing only)
347  ifstream in_file; // data file pointer
348  char filename[80] = "phCalibrationFit_C0.dat";
349 
350  in_file.open(filename, ios::in ); // in C++
351  if(in_file.bad()) {
352  cout << " File not found " << endl;
353  return; // signal error
354  }
355  cout << " file opened : " << filename << endl;
356 
357  char line[500];
358  for (int i = 0; i < 3; i++) {
359  in_file.getline(line, 500,'\n');
360  cout<<line<<endl;
361  }
362 
363  cout << " test map" << endl;
364 
365  float par0,par1,par2,par3;
366  int colid,rowid;
367  string name;
368  // Read MC tracks
369  for(int i=0;i<(52*80);i++) { // loop over tracks
370  in_file >> par0 >> par1 >> par2 >> par3 >> name >> colid
371  >> rowid;
372  if(in_file.bad()) { // check for errors
373  cerr << "Cannot read data file" << endl;
374  return;
375  }
376  if( in_file.eof() != 0 ) {
377  cerr << in_file.eof() << " " << in_file.gcount() << " "
378  << in_file.fail() << " " << in_file.good() << " end of file "
379  << endl;
380  return;
381  }
382 
383  //cout << " line " << i << " " <<par0<<" "<<par1<<" "<<par2<<" "<<par3<<" "
384  // <<colid<<" "<<rowid<<endl;
385 
386  CalParameters onePix;
387  onePix.p0=par0;
388  onePix.p1=par1;
389  onePix.p2=par2;
390  onePix.p3=par3;
391 
392  // Convert ROC pixel index to channel
393  int chan = PixelIndices::pixelToChannelROC(rowid,colid);
394  calmap.insert(pair<int,CalParameters>(chan,onePix));
395 
396  // Testing the index conversion, can be skipped
397  pair<int,int> p = PixelIndices::channelToPixelROC(chan);
398  if(rowid!=p.first) cout<<" wrong channel row "<<rowid<<" "<<p.first<<endl;
399  if(colid!=p.second) cout<<" wrong channel col "<<colid<<" "<<p.second<<endl;
400 
401  } // pixel loop in a ROC
402 
403  cout << " map size " << calmap.size() <<" max "<<calmap.max_size() << " "
404  <<calmap.empty()<< endl;
405 
406 // cout << " map size " << calmap.size() << endl;
407 // map<int,CalParameters,less<int> >::iterator ix,it;
408 // map<int,CalParameters,less<int> >::const_iterator ip;
409 // for (ix = calmap.begin(); ix != calmap.end(); ++ix) {
410 // int i = (*ix).first;
411 // pair<int,int> p = channelToPixelROC(i);
412 // it = calmap.find(i);
413 // CalParameters y = (*it).second;
414 // CalParameters z = (*ix).second;
415 // cout << i <<" "<<p.first<<" "<<p.second<<" "<<y.p0<<" "<<z.p0<<" "<<calmap[i].p0<<endl;
416 
417 // //int dummy=0;
418 // //cin>>dummy;
419 // }
420 
421  } // end if readparameters
422  } // end if missCalibration
423 
424  LogInfo ("PixelDigitizer ") <<"SiPixelDigitizerAlgorithm constructed"
425  <<"Configuration parameters:"
426  << "Threshold/Gain = "
427  << "threshold in electron FPix = "
428  << theThresholdInE_FPix
429  << "threshold in electron BPix = "
430  << theThresholdInE_BPix
431  <<" " << theElectronPerADC << " " << theAdcFullScale
432  << " The delta cut-off is set to " << tMax
433  << " pix-inefficiency "<<thePixelLuminosity;
434 
435 }
436 //=========================================================================
438 
439  LogDebug ("PixelDigitizer")<<"SiPixelDigitizerAlgorithm deleted";
440 
441  // Destructor
442  delete gaussDistribution_;
444  delete flatDistribution_;
445 
447 
448  // Threshold gaussian smearing:
450  delete smearedThreshold_FPix_;
451  delete smearedThreshold_BPix_;
452  }
453 
454  if(addNoise) delete theNoiser;
455  if(fluctuateCharge) delete fluctuate;
456 
457 }
458 
459 //=========================================================================
462  const std::vector<PSimHit> &input,
463  PixelGeomDetUnit *pixdet,
464  GlobalVector bfield) {
465 
466  _detp = pixdet; //cache the PixGeomDetUnit
467  _PixelHits=input; //cache the SimHit
468  _bfield=bfield; //cache the drift direction
469 
470  // Pixel Efficiency moved from the constructor to the method run because
471  // the information of the det are not available in the constructor
472  // Effciency parameters. 0 - no inefficiency, 1-low lumi, 10-high lumi
473 
475 
476  _signal.clear();
477 
478  // initalization of pixeldigisimlinks
479  link_coll.clear();
480 
481  //Digitization of the SimHits of a given pixdet
482  vector<PixelDigi> collector =digitize(pixdet);
483 
484  // edm::DetSet<PixelDigi> collector;
485 
486 #ifdef TP_DEBUG
487  LogDebug ("PixelDigitizer") << "[SiPixelDigitizerAlgorithm] converted " << collector.size() << " PixelDigis in DetUnit" << detID;
488 #endif
489 
490  return collector;
491 }
492 
493 //============================================================================
495 
496  if( _PixelHits.size() > 0 || addNoisyPixels) {
497 
498  topol=&det->specificTopology(); // cache topology
499  numColumns = topol->ncolumns(); // det module number of cols&rows
500  numRows = topol->nrows();
501 
502  // full detector thickness
504 
505  // The index converter is only needed when inefficiencies or misscalibration
506  // are simulated.
507  if((pixelInefficiency>0) || doMissCalibrate ) { // Init pixel indices
509  }
510 
511  // Noise already defined in electrons
512  //thePixelThresholdInE = thePixelThreshold * theNoiseInElectrons ;
513  // Find the threshold in noise units, needed for the noiser.
514 
515  unsigned int Sub_detid=DetId(detID).subdetId();
516 
517  if(theNoiseInElectrons>0.){
518  if(Sub_detid == PixelSubdetector::PixelBarrel){ // Barrel modules
520  thePixelThresholdInE = smearedThreshold_BPix_->fire(); // gaussian smearing
521  } else {
523  }
524 
526 
527  } else { // Forward disks modules
529  thePixelThresholdInE = smearedThreshold_FPix_->fire(); // gaussian smearing
530  } else {
532  }
533 
535 
536  }
537  } else {
538  thePixelThreshold = 0.;
539  }
540 
541 
542 #ifdef TP_DEBUG
543  LogDebug ("PixelDigitizer")
544  << " PixelDigitizer "
545  << numColumns << " " << numRows << " " << moduleThickness;
546 #endif
547 
548  // produce SignalPoint's for all SimHit's in detector
549  // Loop over hits
550 
551  vector<PSimHit>::const_iterator ssbegin;
552  for (ssbegin= _PixelHits.begin();ssbegin !=_PixelHits.end(); ++ssbegin) {
553 
554 #ifdef TP_DEBUG
555  LogDebug ("Pixel Digitizer")
556  << (*ssbegin).particleType() << " " << (*ssbegin).pabs() << " "
557  << (*ssbegin).energyLoss() << " " << (*ssbegin).tof() << " "
558  << (*ssbegin).trackId() << " " << (*ssbegin).processType() << " "
559  << (*ssbegin).detUnitId()
560  << (*ssbegin).entryPoint() << " " << (*ssbegin).exitPoint() ;
561 #endif
562 
563  _collection_points.clear(); // Clear the container
564  // fill _collection_points for this SimHit, indpendent of topology
565  // Check the TOF cut
566  //if(std::abs( (*ssbegin).tof() )<theTofCut){ // old cut
567  if( ((*ssbegin).tof() >= theTofLowerCut) && ((*ssbegin).tof() <= theTofUpperCut) ) {
568  primary_ionization(*ssbegin); // fills _ionization_points
569  drift(*ssbegin); // transforms _ionization_points to _collection_points
570  // compute induced signal on readout elements and add to _signal
571  induce_signal(*ssbegin); // *ihit needed only for SimHit<-->Digi link
572  } // end if
573  } // end for
574 
575  if(addNoise) add_noise(); // generate noise
576  // Do only if needed
577 
578  if((pixelInefficiency>0) && (_signal.size()>0))
579  pixel_inefficiency(); // Kill some pixels
580 
581  if(use_ineff_from_db_ && (_signal.size()>0))
583 
584  delete pIndexConverter;
585 
586  if(use_module_killing_ && use_deadmodule_DB_) // remove dead modules using DB
588 
589  if(use_module_killing_ && !use_deadmodule_DB_) // remove dead modules using the list in cfg file
591 
592  }
593 
594  make_digis();
595 
596  return internal_coll;
597 }
598 
599 //***********************************************************************/
600 // Generate primary ionization along the track segment.
601 // Divide the track into small sub-segments
603 
604 // Straight line approximation for trajectory inside active media
605 
606  const float SegmentLength = 0.0010; //10microns in cm
607  float energy;
608 
609  // Get the 3D segment direction vector
610  LocalVector direction = hit.exitPoint() - hit.entryPoint();
611 
612  float eLoss = hit.energyLoss(); // Eloss in GeV
613  float length = direction.mag(); // Track length in Silicon
614 
615  NumberOfSegments = int ( length / SegmentLength); // Number of segments
617 
618 #ifdef TP_DEBUG
619  LogDebug ("Pixel Digitizer")
620  << " enter primary_ionzation " << NumberOfSegments
621  << " shift = "
622  << (hit.exitPoint().x()-hit.entryPoint().x()) << " "
623  << (hit.exitPoint().y()-hit.entryPoint().y()) << " "
624  << (hit.exitPoint().z()-hit.entryPoint().z()) << " "
625  << hit.particleType() <<" "<< hit.pabs() ;
626 #endif
627 
628  float* elossVector = new float[NumberOfSegments]; // Eloss vector
629 
630  if( fluctuateCharge ) {
631  //MP DA RIMUOVERE ASSOLUTAMENTE
632  int pid = hit.particleType();
633  //int pid=211; // assume it is a pion
634 
635  float momentum = hit.pabs();
636  // Generate fluctuated charge points
637  fluctuateEloss(pid, momentum, eLoss, length, NumberOfSegments,
638  elossVector);
639  }
640 
641  _ionization_points.resize( NumberOfSegments); // set size
642 
643  // loop over segments
644  for ( int i = 0; i != NumberOfSegments; i++) {
645  // Divide the segment into equal length subsegments
646  Local3DPoint point = hit.entryPoint() +
647  float((i+0.5)/NumberOfSegments) * direction;
648 
649  if( fluctuateCharge )
650  energy = elossVector[i]/GeVperElectron; // Convert charge to elec.
651  else
652  energy = hit.energyLoss()/GeVperElectron/float(NumberOfSegments);
653 
654  EnergyDepositUnit edu( energy, point); //define position,energy point
655  _ionization_points[i] = edu; // save
656 
657 #ifdef TP_DEBUG
658  LogDebug ("Pixel Digitizer")
659  << i << " " << _ionization_points[i].x() << " "
660  << _ionization_points[i].y() << " "
661  << _ionization_points[i].z() << " "
662  << _ionization_points[i].energy();
663 #endif
664 
665  } // end for loop
666 
667  delete[] elossVector;
668 
669 }
670 //******************************************************************************
671 
672 // Fluctuate the charge comming from a small (10um) track segment.
673 // Use the G4 routine. For mip pions for the moment.
674 void SiPixelDigitizerAlgorithm::fluctuateEloss(int pid, float particleMomentum,
675  float eloss, float length,
676  int NumberOfSegs,float elossVector[]) {
677 
678  // Get dedx for this track
679  //float dedx;
680  //if( length > 0.) dedx = eloss/length;
681  //else dedx = eloss;
682 
683  double particleMass = 139.6; // Mass in MeV, Assume pion
684  pid = abs(pid);
685  if(pid!=211) { // Mass in MeV
686  if(pid==11) particleMass = 0.511;
687  else if(pid==13) particleMass = 105.7;
688  else if(pid==321) particleMass = 493.7;
689  else if(pid==2212) particleMass = 938.3;
690  }
691  // What is the track segment length.
692  float segmentLength = length/NumberOfSegs;
693 
694  // Generate charge fluctuations.
695  float de=0.;
696  float sum=0.;
697  double segmentEloss = (1000.*eloss)/NumberOfSegs; //eloss in MeV
698  for (int i=0;i<NumberOfSegs;i++) {
699  // material,*, momentum,energy,*, *, mass
700  //myglandz_(14.,segmentLength,2.,2.,dedx,de,0.14);
701  // The G4 routine needs momentum in MeV, mass in Mev, delta-cut in MeV,
702  // track segment length in mm, segment eloss in MeV
703  // Returns fluctuated eloss in MeV
704  double deltaCutoff = tMax; // the cutoff is sometimes redefined inside, so fix it.
705  de = fluctuate->SampleFluctuations(double(particleMomentum*1000.),
706  particleMass, deltaCutoff,
707  double(segmentLength*10.),
708  segmentEloss )/1000.; //convert to GeV
709 
710  elossVector[i]=de;
711  sum +=de;
712  }
713 
714  if(sum>0.) { // If fluctuations give eloss>0.
715  // Rescale to the same total eloss
716  float ratio = eloss/sum;
717 
718  for (int ii=0;ii<NumberOfSegs;ii++) elossVector[ii]= ratio*elossVector[ii];
719  } else { // If fluctuations gives 0 eloss
720  float averageEloss = eloss/NumberOfSegs;
721  for (int ii=0;ii<NumberOfSegs;ii++) elossVector[ii]= averageEloss;
722  }
723  return;
724 }
725 
726 //*******************************************************************************
727 // Drift the charge segments to the sensor surface (collection plane)
728 // Include the effect of E-field and B-field
730 
731 
732 #ifdef TP_DEBUG
733  LogDebug ("Pixel Digitizer") << " enter drift " ;
734 #endif
735 
736  _collection_points.resize( _ionization_points.size()); // set size
737 
739  //float LorentzAng = SiPixelLorentzAngle_->getLorentzAngle(hit.detUnitId());
740  lorentzAngle = SiPixelLorentzAngle_->getLorentzAngle(hit.detUnitId());
741  }
742 
743  //LocalVector driftDir=DriftDirection(LorentzAng); // get the charge drift direction
744  LocalVector driftDir=DriftDirection(); // get the charge drift direction
745  if(driftDir.z() ==0.) {
746  LogWarning("Magnetic field") << " pxlx: drift in z is zero ";
747  return;
748  }
749 
750  // tangent of Lorentz angle
751  //float TanLorenzAngleX = driftDir.x()/driftDir.z();
752  //float TanLorenzAngleY = 0.; // force to 0, driftDir.y()/driftDir.z();
753 
754  float TanLorenzAngleX, TanLorenzAngleY,dir_z, CosLorenzAngleX,
755  CosLorenzAngleY;
756  if( alpha2Order) {
757 
758  TanLorenzAngleX = driftDir.x(); // tangen of Lorentz angle
759  TanLorenzAngleY = driftDir.y();
760  dir_z = driftDir.z(); // The z drift direction
761  CosLorenzAngleX = 1./sqrt(1.+TanLorenzAngleX*TanLorenzAngleX); //cosine
762  CosLorenzAngleY = 1./sqrt(1.+TanLorenzAngleY*TanLorenzAngleY); //cosine;
763 
764  } else{
765 
766  TanLorenzAngleX = driftDir.x();
767  TanLorenzAngleY = 0.; // force to 0, driftDir.y()/driftDir.z();
768  dir_z = driftDir.z(); // The z drift direction
769  CosLorenzAngleX = 1./sqrt(1.+TanLorenzAngleX*TanLorenzAngleX); //cosine to estimate the path length
770  CosLorenzAngleY = 1.;
771  }
772 
773 
774 #ifdef TP_DEBUG
775  LogDebug ("Pixel Digitizer")
776  << " Lorentz Tan " << TanLorenzAngleX << " " << TanLorenzAngleY <<" "
777  << CosLorenzAngleX << " " << CosLorenzAngleY << " "
778  << moduleThickness*TanLorenzAngleX << " " << driftDir;
779 #endif
780 
781  float Sigma_x = 1.; // Charge spread
782  float Sigma_y = 1.;
783  float DriftDistance; // Distance between charge generation and collection
784  float DriftLength; // Actual Drift Lentgh
785  float Sigma;
786 
787 
788  for (unsigned int i = 0; i != _ionization_points.size(); i++) {
789 
790  float SegX, SegY, SegZ; // position
791  SegX = _ionization_points[i].x();
792  SegY = _ionization_points[i].y();
793  SegZ = _ionization_points[i].z();
794 
795  // Distance from the collection plane
796  //DriftDistance = (moduleThickness/2. + SegZ); // Drift to -z
797  // Include explixitely the E drift direction (for CMS dir_z=-1)
798  DriftDistance = moduleThickness/2. - (dir_z * SegZ); // Drift to -z
799 
800  //if( DriftDistance <= 0.)
801  //cout<<" <=0 "<<DriftDistance<<" "<<i<<" "<<SegZ<<" "<<dir_z<<" "
802  // <<SegX<<" "<<SegY<<" "<<(moduleThickness/2)<<" "
803  // <<_ionization_points[i].energy()<<" "
804  // <<hit.particleType()<<" "<<hit.pabs()<<" "<<hit.energyLoss()<<" "
805  // <<hit.entryPoint()<<" "<<hit.exitPoint()
806  // <<endl;
807 
808  if( DriftDistance < 0.) {
809  DriftDistance = 0.;
810  } else if( DriftDistance > moduleThickness )
811  DriftDistance = moduleThickness;
812 
813  // Assume full depletion now, partial depletion will come later.
814  float XDriftDueToMagField = DriftDistance * TanLorenzAngleX;
815  float YDriftDueToMagField = DriftDistance * TanLorenzAngleY;
816 
817  // Shift cloud center
818  float CloudCenterX = SegX + XDriftDueToMagField;
819  float CloudCenterY = SegY + YDriftDueToMagField;
820 
821  // Calculate how long is the charge drift path
822  DriftLength = sqrt( DriftDistance*DriftDistance +
823  XDriftDueToMagField*XDriftDueToMagField +
824  YDriftDueToMagField*YDriftDueToMagField );
825 
826  // What is the charge diffusion after this path
827  Sigma = sqrt(DriftLength/Dist300) * Sigma0;
828 
829  // Project the diffusion sigma on the collection plane
830  Sigma_x = Sigma / CosLorenzAngleX ;
831  Sigma_y = Sigma / CosLorenzAngleY ;
832 
833  SignalPoint sp( CloudCenterX, CloudCenterY,
834  Sigma_x, Sigma_y, hit.tof(), _ionization_points[i].energy() );
835 
836  // Load the Charge distribution parameters
837  _collection_points[i] = (sp);
838 
839  } // loop over ionization points, i.
840 
841 } // end drift
842 
843 //*************************************************************************
844 // Induce the signal on the collection plane of the active sensor area.
846 
847  // X - Rows, Left-Right, 160, (1.6cm) for barrel
848  // Y - Columns, Down-Up, 416, (6.4cm)
849 
850 #ifdef TP_DEBUG
851  LogDebug ("Pixel Digitizer")
852  << " enter induce_signal, "
853  << topol->pitch().first << " " << topol->pitch().second; //OK
854 #endif
855 
856  // local map to store pixels hit by 1 Hit.
857  typedef map< int, float, less<int> > hit_map_type;
858  hit_map_type hit_signal;
859 
860  // map to store pixel integrals in the x and in the y directions
861  map<int, float, less<int> > x,y;
862 
863  // Assign signals to readout channels and store sorted by channel number
864 
865  // Iterate over collection points on the collection plane
866  for ( vector<SignalPoint>::const_iterator i=_collection_points.begin();
867  i != _collection_points.end(); i++) {
868 
869  float CloudCenterX = i->position().x(); // Charge position in x
870  float CloudCenterY = i->position().y(); // in y
871  float SigmaX = i->sigma_x(); // Charge spread in x
872  float SigmaY = i->sigma_y(); // in y
873  float Charge = i->amplitude(); // Charge amplitude
874 
875 
876  //if(SigmaX==0 || SigmaY==0) {
877  //cout<<SigmaX<<" "<<SigmaY
878  // << " cloud " << i->position().x() << " " << i->position().y() << " "
879  // << i->sigma_x() << " " << i->sigma_y() << " " << i->amplitude()<<endl;
880  //}
881 
882 #ifdef TP_DEBUG
883  LogDebug ("Pixel Digitizer")
884  << " cloud " << i->position().x() << " " << i->position().y() << " "
885  << i->sigma_x() << " " << i->sigma_y() << " " << i->amplitude();
886 #endif
887 
888  // Find the maximum cloud spread in 2D plane , assume 3*sigma
889  float CloudRight = CloudCenterX + ClusterWidth*SigmaX;
890  float CloudLeft = CloudCenterX - ClusterWidth*SigmaX;
891  float CloudUp = CloudCenterY + ClusterWidth*SigmaY;
892  float CloudDown = CloudCenterY - ClusterWidth*SigmaY;
893 
894  // Define 2D cloud limit points
895  LocalPoint PointRightUp = LocalPoint(CloudRight,CloudUp);
896  LocalPoint PointLeftDown = LocalPoint(CloudLeft,CloudDown);
897 
898  // This points can be located outside the sensor area.
899  // The conversion to measurement point does not check for that
900  // so the returned pixel index might be wrong (outside range).
901  // We rely on the limits check below to fix this.
902  // But remember whatever we do here THE CHARGE OUTSIDE THE ACTIVE
903  // PIXEL ARE IS LOST, it should not be collected.
904 
905  // Convert the 2D points to pixel indices
906  MeasurementPoint mp = topol->measurementPosition(PointRightUp ); //OK
907 
908  int IPixRightUpX = int( floor( mp.x()));
909  int IPixRightUpY = int( floor( mp.y()));
910 
911 #ifdef TP_DEBUG
912  LogDebug ("Pixel Digitizer") << " right-up " << PointRightUp << " "
913  << mp.x() << " " << mp.y() << " "
914  << IPixRightUpX << " " << IPixRightUpY ;
915 #endif
916 
917  mp = topol->measurementPosition(PointLeftDown ); //OK
918 
919  int IPixLeftDownX = int( floor( mp.x()));
920  int IPixLeftDownY = int( floor( mp.y()));
921 
922 #ifdef TP_DEBUG
923  LogDebug ("Pixel Digitizer") << " left-down " << PointLeftDown << " "
924  << mp.x() << " " << mp.y() << " "
925  << IPixLeftDownX << " " << IPixLeftDownY ;
926 #endif
927 
928  // Check detector limits to correct for pixels outside range.
929  IPixRightUpX = numRows>IPixRightUpX ? IPixRightUpX : numRows-1 ;
930  IPixRightUpY = numColumns>IPixRightUpY ? IPixRightUpY : numColumns-1 ;
931  IPixLeftDownX = 0<IPixLeftDownX ? IPixLeftDownX : 0 ;
932  IPixLeftDownY = 0<IPixLeftDownY ? IPixLeftDownY : 0 ;
933 
934  x.clear(); // clear temporary integration array
935  y.clear();
936 
937  // First integrate cahrge strips in x
938  int ix; // TT for compatibility
939  for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) { // loop over x index
940  float xUB, xLB, UpperBound, LowerBound;
941 
942  // Why is set to 0 if ix=0, does it meen that we accept charge
943  // outside the sensor? CHeck How it was done in ORCA?
944  //if(ix == 0) LowerBound = 0.;
945  if(ix == 0 || SigmaX==0. ) // skip for surface segemnts
946  LowerBound = 0.;
947  else {
948  mp = MeasurementPoint( float(ix), 0.0);
949  xLB = topol->localPosition(mp).x();
950  gsl_sf_result result;
951  int status = gsl_sf_erf_Q_e( (xLB-CloudCenterX)/SigmaX, &result);
952  if(status != 0)
953  LogWarning ("Integration")<<"could not compute gaussian probability";
954  LowerBound = 1-result.val;
955  }
956 
957  if(ix == numRows-1 || SigmaX==0. )
958  UpperBound = 1.;
959  else {
960  mp = MeasurementPoint( float(ix+1), 0.0);
961  xUB = topol->localPosition(mp).x();
962  gsl_sf_result result;
963  int status = gsl_sf_erf_Q_e( (xUB-CloudCenterX)/SigmaX, &result);
964  if(status != 0)
965  LogWarning ("Integration")<<"could not compute gaussian probability";
966  UpperBound = 1. - result.val;
967  }
968 
969  float TotalIntegrationRange = UpperBound - LowerBound; // get strip
970  x[ix] = TotalIntegrationRange; // save strip integral
971  //if(SigmaX==0 || SigmaY==0)
972  //cout<<TotalIntegrationRange<<" "<<ix<<endl;
973 
974  }
975 
976  // Now integarte strips in y
977  int iy; // TT for compatibility
978  for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) { //loope over y ind
979  float yUB, yLB, UpperBound, LowerBound;
980 
981  if(iy == 0 || SigmaY==0.)
982  LowerBound = 0.;
983  else {
984  mp = MeasurementPoint( 0.0, float(iy) );
985  yLB = topol->localPosition(mp).y();
986  gsl_sf_result result;
987  int status = gsl_sf_erf_Q_e( (yLB-CloudCenterY)/SigmaY, &result);
988  if(status != 0)
989  LogWarning ("Integration")<<"could not compute gaussian probability";
990  LowerBound = 1. - result.val;
991  }
992 
993  if(iy == numColumns-1 || SigmaY==0. )
994  UpperBound = 1.;
995  else {
996  mp = MeasurementPoint( 0.0, float(iy+1) );
997  yUB = topol->localPosition(mp).y();
998  gsl_sf_result result;
999  int status = gsl_sf_erf_Q_e( (yUB-CloudCenterY)/SigmaY, &result);
1000  if(status != 0)
1001  LogWarning ("Integration")<<"could not compute gaussian probability";
1002  UpperBound = 1. - result.val;
1003  }
1004 
1005  float TotalIntegrationRange = UpperBound - LowerBound;
1006  y[iy] = TotalIntegrationRange; // save strip integral
1007  //if(SigmaX==0 || SigmaY==0)
1008  //cout<<TotalIntegrationRange<<" "<<iy<<endl;
1009  }
1010 
1011  // Get the 2D charge integrals by folding x and y strips
1012  int chan;
1013  for (ix=IPixLeftDownX; ix<=IPixRightUpX; ix++) { // loop over x index
1014  for (iy=IPixLeftDownY; iy<=IPixRightUpY; iy++) { //loope over y ind
1015 
1016  float ChargeFraction = Charge*x[ix]*y[iy];
1017 
1018  if( ChargeFraction > 0. ) {
1019  chan = PixelDigi::pixelToChannel( ix, iy); // Get index
1020  // Load the amplitude
1021  hit_signal[chan] += ChargeFraction;
1022  } // endif
1023 
1024 
1025  mp = MeasurementPoint( float(ix), float(iy) );
1026  LocalPoint lp = topol->localPosition(mp);
1027  chan = topol->channel(lp);
1028 
1029 #ifdef TP_DEBUG
1030  LogDebug ("Pixel Digitizer")
1031  << " pixel " << ix << " " << iy << " - "<<" "
1032  << chan << " " << ChargeFraction<<" "
1033  << mp.x() << " " << mp.y() <<" "
1034  << lp.x() << " " << lp.y() << " " // givex edge position
1035  << chan; // edge belongs to previous ?
1036 #endif
1037 
1038  } // endfor iy
1039  } //endfor ix
1040 
1041 
1042  // Test conversions (THIS IS FOR TESTING ONLY) comment-out.
1043  // mp = topol->measurementPosition( i->position() ); //OK
1044  // LocalPoint lp = topol->localPosition(mp); //OK
1045  // pair<float,float> p = topol->pixel( i->position() ); //OK
1046  // chan = PixelDigi::pixelToChannel( int(p.first), int(p.second));
1047  // pair<int,int> ip = PixelDigi::channelToPixel(chan);
1048  // MeasurementPoint mp1 = MeasurementPoint( float(ip.first),
1049  // float(ip.second) );
1050  // LogDebug ("Pixel Digitizer") << " Test "<< mp.x() << " " << mp.y()
1051  // << " "<< lp.x() << " " << lp.y() << " "<<" "
1052  // <<p.first <<" "<<p.second<<" "<<chan<< " "
1053  // <<" " << ip.first << " " << ip.second << " "
1054  // << mp1.x() << " " << mp1.y() << " " //OK
1055  // << topol->localPosition(mp1).x() << " " //OK
1056  // << topol->localPosition(mp1).y() << " "
1057  // << topol->channel( i->position() ); //OK
1058 
1059 
1060  } // loop over charge distributions
1061 
1062  // Fill the global map with all hit pixels from this event
1063 
1064  for ( hit_map_type::const_iterator im = hit_signal.begin();
1065  im != hit_signal.end(); im++) {
1066  _signal[(*im).first] += Amplitude( (*im).second, &hit, (*im).second);
1067 
1068  int chan = (*im).first;
1069  pair<int,int> ip = PixelDigi::channelToPixel(chan);
1070 
1071 #ifdef TP_DEBUG
1072  LogDebug ("Pixel Digitizer")
1073  << " pixel " << ip.first << " " << ip.second << " "
1074  << _signal[(*im).first];
1075 #endif
1076  }
1077 
1078 } // end induce_signal
1079 
1080 /***********************************************************************/
1081 
1082 // Build pixels, check threshold, add misscalibration, ...
1084  internal_coll.reserve(50); internal_coll.clear();
1085 
1086 #ifdef TP_DEBUG
1087  LogDebug ("Pixel Digitizer") << " make digis "<<" "
1088  << " pixel threshold FPix" << theThresholdInE_FPix << " "
1089  << " pixel threshold BPix" << theThresholdInE_BPix << " "
1090  << " List pixels passing threshold ";
1091 #endif
1092 
1093  // Loop over hit pixels
1094 
1095  for ( signal_map_iterator i = _signal.begin(); i != _signal.end(); i++) {
1096 
1097  float signalInElectrons = (*i).second ; // signal in electrons
1098 
1099  // Do the miss calibration for calibration studies only.
1100  //if(doMissCalibrate) signalInElectrons = missCalibrate(signalInElectrons)
1101 
1102  // Do only for pixels above threshold
1103 
1104  if( signalInElectrons >= thePixelThresholdInE) { // check threshold
1105 
1106  int chan = (*i).first; // channel number
1107  pair<int,int> ip = PixelDigi::channelToPixel(chan);
1108  int adc=0; // ADC count as integer
1109 
1110  // Do the miss calibration for calibration studies only.
1111  if(doMissCalibrate) {
1112  int row = ip.first; // X in row
1113  int col = ip.second; // Y is in col
1114  adc = int(missCalibrate(col,row,signalInElectrons)); //full misscalib.
1115  } else { // Just do a simple electron->adc conversion
1116  adc = int( signalInElectrons / theElectronPerADC ); // calibrate gain
1117  }
1118  adc = min(adc, theAdcFullScale); // Check maximum value
1119 
1120 #ifdef TP_DEBUG
1121  LogDebug ("Pixel Digitizer")
1122  << (*i).first << " " << (*i).second << " " << signalInElectrons
1123  << " " << adc << ip.first << " " << ip.second ;
1124 #endif
1125 
1126  // Load digis
1127  internal_coll.push_back( PixelDigi( ip.first, ip.second, adc));
1128 
1129  //digilink
1130  if((*i).second.hits().size()>0){
1131  simi.clear();
1132  unsigned int il=0;
1133  for( vector<const PSimHit*>::const_iterator ihit = (*i).second.hits().begin();
1134  ihit != (*i).second.hits().end(); ihit++) {
1135  simi[(**ihit).trackId()].push_back((*i).second.individualampl()[il]);
1136  il++;
1137  }
1138 
1139  //sum the contribution of the same trackid
1140  for( simlink_map::iterator simiiter=simi.begin();
1141  simiiter!=simi.end();
1142  simiiter++){
1143 
1144  float sum_samechannel=0;
1145  for (unsigned int iii=0;iii<(*simiiter).second.size();iii++){
1146  sum_samechannel+=(*simiiter).second[iii];
1147  }
1148  float fraction=sum_samechannel/(*i).second;
1149  if(fraction>1.) fraction=1.;
1150  link_coll.push_back(PixelDigiSimLink((*i).first,(*simiiter).first,((*i).second.hits().front())->eventId(),fraction));
1151  }
1152 
1153  }
1154  }
1155 
1156  }
1157 }
1158 
1159 /***********************************************************************/
1160 
1161 // Add electronic noise to pixel charge
1163 
1164 #ifdef TP_DEBUG
1165  LogDebug ("Pixel Digitizer") << " enter add_noise " << theNoiseInElectrons;
1166 #endif
1167 
1168  // First add noise to hit pixels
1169 
1170  for ( signal_map_iterator i = _signal.begin(); i != _signal.end(); i++) {
1171 
1173  {
1174  if((*i).second < 3000)
1175  {
1176  theSmearedChargeRMS = 543.6 - (*i).second * 0.093;
1177  } else if((*i).second < 6000){
1178  theSmearedChargeRMS = 307.6 - (*i).second * 0.01;
1179  } else{
1180  theSmearedChargeRMS = -432.4 +(*i).second * 0.123;
1181  }
1182 
1183  // Noise from Vcal smearing:
1184  float noise_ChargeVCALSmearing = theSmearedChargeRMS * gaussDistributionVCALNoise_->fire() ;
1185  // Noise from full readout:
1186  float noise = gaussDistribution_->fire() ;
1187 
1188  if(((*i).second + Amplitude(noise+noise_ChargeVCALSmearing,0,-1.)) < 0. ) {
1189  (*i).second.set(0);}
1190  else{
1191  (*i).second +=Amplitude(noise+noise_ChargeVCALSmearing,0,-1.);
1192  }
1193 
1194  } // End if addChargeVCalSmearing
1195  else
1196  {
1197  // Noise: ONLY full READOUT Noise.
1198  // Use here the FULL readout noise, including TBM,ALT,AOH,OPT-REC.
1199 
1200  float noise = gaussDistribution_->fire() ;
1201  if(((*i).second + Amplitude(noise,0,-1.)) < 0. ) {
1202  (*i).second.set(0);}
1203  else{
1204  (*i).second +=Amplitude(noise,0,-1.);
1205  }
1206  } // end if only Noise from full readout
1207 
1208  }
1209 
1210  if(!addNoisyPixels) // Option to skip noise in non-hit pixels
1211  return;
1212 
1213  // Add noise on non-hit pixels
1214  // Use here the pixel noise
1215  int numberOfPixels = (numRows * numColumns);
1216  map<int,float, less<int> > otherPixels;
1217  map<int,float, less<int> >::iterator mapI;
1218 
1219  theNoiser->generate(numberOfPixels,
1220  thePixelThreshold, //thr. in un. of nois
1221  theNoiseInElectrons, // noise in elec.
1222  otherPixels );
1223 
1224 #ifdef TP_DEBUG
1225  LogDebug ("Pixel Digitizer")
1226  << " Add noisy pixels " << numRows << " "
1227  << numColumns << " " << theNoiseInElectrons << " "
1228  << theThresholdInE_FPix << theThresholdInE_BPix <<" "<< numberOfPixels<<" "
1229  << otherPixels.size() ;
1230 #endif
1231 
1232  // Add noisy pixels
1233  for (mapI = otherPixels.begin(); mapI!= otherPixels.end(); mapI++) {
1234  int iy = ((*mapI).first) / numRows;
1235  int ix = ((*mapI).first) - (iy*numRows);
1236 
1237  // Keep for a while for testing.
1238  if( iy < 0 || iy > (numColumns-1) )
1239  LogWarning ("Pixel Geometry") << " error in iy " << iy ;
1240  if( ix < 0 || ix > (numRows-1) )
1241  LogWarning ("Pixel Geometry") << " error in ix " << ix ;
1242 
1243  int chan = PixelDigi::pixelToChannel(ix, iy);
1244 
1245 #ifdef TP_DEBUG
1246  LogDebug ("Pixel Digitizer")
1247  <<" Storing noise = " << (*mapI).first << " " << (*mapI).second
1248  << " " << ix << " " << iy << " " << chan ;
1249 #endif
1250 
1251  if(_signal[chan] == 0){
1252  // float noise = float( (*mapI).second );
1253  int noise=int( (*mapI).second );
1254  _signal[chan] = Amplitude (noise, 0,-1.);
1255  }
1256  }
1257 
1258 }
1259 
1260 /***********************************************************************/
1261 
1262 // Simulate the readout inefficiencies.
1263 // Delete a selected number of single pixels, dcols and rocs.
1265 
1266 
1267  // Predefined efficiencies
1268  float pixelEfficiency = 1.0;
1269  float columnEfficiency = 1.0;
1270  float chipEfficiency = 1.0;
1271 
1272  // setup the chip indices conversion
1273  unsigned int Subid=DetId(detID).subdetId();
1274  if (Subid== PixelSubdetector::PixelBarrel){// barrel layers
1275  int layerIndex=PXBDetId(detID).layer();
1276  pixelEfficiency = thePixelEfficiency[layerIndex-1];
1277  columnEfficiency = thePixelColEfficiency[layerIndex-1];
1278  chipEfficiency = thePixelChipEfficiency[layerIndex-1];
1279 
1280  // This should never happen
1281  if(numColumns>416) LogWarning ("Pixel Geometry") <<" wrong columns in barrel "<<numColumns;
1282  if(numRows>160) LogWarning ("Pixel Geometry") <<" wrong rows in barrel "<<numRows;
1283 
1284  } else { // forward disks
1285 
1286  // For endcaps take same for each endcap
1287  pixelEfficiency = thePixelEfficiency[3];
1288  columnEfficiency = thePixelColEfficiency[3];
1289  chipEfficiency = thePixelChipEfficiency[3];
1290 
1291  // Sometimes the forward pixels have wrong size,
1292  // this crashes the index conversion, so exit.
1293  if(numColumns>260 || numRows>160) {
1294  if(numColumns>260) LogWarning ("Pixel Geometry") <<" wrong columns in endcaps "<<numColumns;
1295  if(numRows>160) LogWarning ("Pixel Geometry") <<" wrong rows in endcaps "<<numRows;
1296  return;
1297  }
1298  } // if barrel/forward
1299 
1300 #ifdef TP_DEBUG
1301  LogDebug ("Pixel Digitizer") << " enter pixel_inefficiency " << pixelEfficiency << " "
1302  << columnEfficiency << " " << chipEfficiency;
1303 #endif
1304 
1305  // Initilize the index converter
1306  //PixelIndices indexConverter(numColumns,numRows);
1307  int chipIndex = 0;
1308  int rowROC = 0;
1309  int colROC = 0;
1310  map<int, int, less<int> >chips, columns;
1311  map<int, int, less<int> >::iterator iter;
1312 
1313  // Find out the number of columns and rocs hits
1314  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
1315  for (signal_map_iterator i = _signal.begin();i != _signal.end();i++) {
1316 
1317  int chan = i->first;
1318  pair<int,int> ip = PixelDigi::channelToPixel(chan);
1319  int row = ip.first; // X in row
1320  int col = ip.second; // Y is in col
1321  //transform to ROC index coordinates
1322  pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1323  int dColInChip = pIndexConverter->DColumn(colROC); // get ROC dcol from ROC col
1324  //dcol in mod
1325  int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1326 
1327  chips[chipIndex]++;
1328  columns[dColInDet]++;
1329  }
1330 
1331  // Delete some ROC hits.
1332  for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
1333  //float rand = RandFlat::shoot();
1334  float rand = flatDistribution_->fire();
1335  if( rand > chipEfficiency ) chips[iter->first]=0;
1336  }
1337 
1338  // Delete some Dcol hits.
1339  for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
1340  //float rand = RandFlat::shoot();
1341  float rand = flatDistribution_->fire();
1342  if( rand > columnEfficiency ) columns[iter->first]=0;
1343  }
1344 
1345  // Now loop again over pixels to kill some of them.
1346  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
1347  for(signal_map_iterator i = _signal.begin();i != _signal.end(); i++) {
1348 
1349  // int chan = i->first;
1350  pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1351  int row = ip.first; // X in row
1352  int col = ip.second; // Y is in col
1353  //transform to ROC index coordinates
1354  pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1355  int dColInChip = pIndexConverter->DColumn(colROC); //get ROC dcol from ROC col
1356  //dcol in mod
1357  int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
1358 
1359 
1360  //float rand = RandFlat::shoot();
1361  float rand = flatDistribution_->fire();
1362  if( chips[chipIndex]==0 || columns[dColInDet]==0
1363  || rand>pixelEfficiency ) {
1364  // make pixel amplitude =0, pixel will be lost at clusterization
1365  i->second.set(0.); // reset amplitude,
1366  } // end if
1367 
1368  } // end pixel loop
1369 
1370 } // end pixel_indefficiency
1371 
1372 //***********************************************************************
1373 
1374 // Fluctuate the gain and offset for the amplitude calibration
1375 // Use gaussian smearing.
1376 //float SiPixelDigitizerAlgorithm::missCalibrate(const float amp) const {
1377  //float gain = RandGaussQ::shoot(1.,theGainSmearing);
1378  //float offset = RandGaussQ::shoot(0.,theOffsetSmearing);
1379  //float newAmp = amp * gain + offset;
1380  // More complex misscalibration
1382  const float signalInElectrons) const {
1383 
1384  // Central values
1385  //const float p0=0.00352, p1=0.868, p2=112., p3=113.; // pix(0,0,0)
1386  // const float p0=0.00382, p1=0.886, p2=112.7, p3=113.0; // average roc=0
1387  //const float p0=0.00492, p1=1.998, p2=90.6, p3=134.1; // average roc=6
1388  // Smeared (rms)
1389  //const float s0=0.00020, s1=0.051, s2=5.4, s3=4.4; // average roc=0
1390  //const float s0=0.00015, s1=0.043, s2=3.2, s3=3.1; // col average roc=0
1391 
1392  // Make 2 sets of parameters for Fpix and BPIx:
1393 
1394  float p0=0.0;
1395  float p1=0.0;
1396  float p2=0.0;
1397  float p3=0.0;
1398 
1399  unsigned int Sub_detid=DetId(detID).subdetId();
1400 
1401  if(Sub_detid == PixelSubdetector::PixelBarrel){// barrel layers
1402  p0 = BPix_p0;
1403  p1 = BPix_p1;
1404  p2 = BPix_p2;
1405  p3 = BPix_p3;
1406  } else {// forward disks
1407  p0 = FPix_p0;
1408  p1 = FPix_p1;
1409  p2 = FPix_p2;
1410  p3 = FPix_p3;
1411  }
1412 
1413  // const float electronsPerVCAL = 65.5; // our present VCAL calibration (feb 2009)
1414  // const float electronsPerVCAL_Offset = -414.0; // our present VCAL calibration (feb 2009)
1415  float newAmp = 0.; //Modified signal
1416 
1417  // Convert electrons to VCAL units
1418  float signal = (signalInElectrons-electronsPerVCAL_Offset)/electronsPerVCAL;
1419 
1420  // Simulate the analog response with fixed parametrization
1421  newAmp = p3 + p2 * tanh(p0*signal - p1);
1422 
1423 
1424  // Use the pixel-by-pixel calibrations
1425  //transform to ROC index coordinates
1426  //int chipIndex=0, colROC=0, rowROC=0;
1427  //pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
1428 
1429  // Use calibration from a file
1430  //int chanROC = PixelIndices::pixelToChannelROC(rowROC,colROC); // use ROC coordinates
1431  //float pp0=0, pp1=0,pp2=0,pp3=0;
1432  //map<int,CalParameters,less<int> >::const_iterator it=calmap.find(chanROC);
1433  //CalParameters y = (*it).second;
1434  //pp0 = y.p0;
1435  //pp1 = y.p1;
1436  //pp2 = y.p2;
1437  //pp3 = y.p3;
1438 
1439  //
1440  // Use random smearing
1441  // Randomize the pixel response
1442  //float pp0 = RandGaussQ::shoot(p0,s0);
1443  //float pp1 = RandGaussQ::shoot(p1,s1);
1444  //float pp2 = RandGaussQ::shoot(p2,s2);
1445  //float pp3 = RandGaussQ::shoot(p3,s3);
1446 
1447  //newAmp = pp3 + pp2 * tanh(pp0*signal - pp1); // Final signal
1448 
1449  //cout<<" misscalibrate "<<col<<" "<<row<<" "<<chipIndex<<" "<<colROC<<" "
1450  // <<rowROC<<" "<<signalInElectrons<<" "<<signal<<" "<<newAmp<<" "
1451  // <<(signalInElectrons/theElectronPerADC)<<endl;
1452 
1453  return newAmp;
1454 }
1455 //******************************************************************************
1456 
1457 // Set the drift direction accoring to the Bfield in local det-unit frame
1458 // Works for both barrel and forward pixels.
1459 // Replace the sign convention to fit M.Swartz's formulaes.
1460 // Configurations for barrel and foward pixels possess different tanLorentzAngleperTesla
1461 // parameter value
1462 
1463 //LocalVector SiPixelDigitizerAlgorithm::DriftDirection(float LoAng){
1465  Frame detFrame(_detp->surface().position(),_detp->surface().rotation());
1466  LocalVector Bfield=detFrame.toLocal(_bfield);
1467 
1468  float alpha2_FPix;
1469  float alpha2_BPix;
1470  float alpha2;
1471 
1472  //float dir_x = -tanLorentzAnglePerTesla * Bfield.y();
1473  //float dir_y = +tanLorentzAnglePerTesla * Bfield.x();
1474  //float dir_z = -1.; // E field always in z direction, so electrons go to -z
1475  // The dir_z has to be +/- 1. !
1476  // LocalVector theDriftDirection = LocalVector(dir_x,dir_y,dir_z);
1477 
1478  float dir_x = 0.0;
1479  float dir_y = 0.0;
1480  float dir_z = 0.0;
1481  float scale = 0.0;
1482 
1483  unsigned int Sub_detid=DetId(detID).subdetId();
1484 
1485  // Read Lorentz angle from cfg file:**************************************************************
1486 
1487  if(!use_LorentzAngle_DB_){
1488 
1489  if( alpha2Order) {
1492  }else {
1493  alpha2_FPix = 0.0;
1494  alpha2_BPix = 0.0;
1495  }
1496 
1497  if(Sub_detid == PixelSubdetector::PixelBarrel){// barrel layers
1498  dir_x = -( tanLorentzAnglePerTesla_BPix * Bfield.y() + alpha2_BPix* Bfield.z()* Bfield.x() );
1499  dir_y = +( tanLorentzAnglePerTesla_BPix * Bfield.x() - alpha2_BPix* Bfield.z()* Bfield.y() );
1500  dir_z = -(1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1501  scale = (1 + alpha2_BPix* Bfield.z()*Bfield.z() );
1502 
1503  } else {// forward disks
1504  dir_x = -( tanLorentzAnglePerTesla_FPix * Bfield.y() + alpha2_FPix* Bfield.z()* Bfield.x() );
1505  dir_y = +( tanLorentzAnglePerTesla_FPix * Bfield.x() - alpha2_FPix* Bfield.z()* Bfield.y() );
1506  dir_z = -(1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1507  scale = (1 + alpha2_FPix* Bfield.z()*Bfield.z() );
1508  }
1509  } // end: Read LA from cfg file.
1510 
1511  //Read Lorentz angle from DB:********************************************************************
1513  alpha2 = lorentzAngle * lorentzAngle;
1514  //std::cout << "detID is: "<< it->first <<"The LA per tesla is: "<< it->second << std::endl;
1515  dir_x = -( lorentzAngle * Bfield.y() + alpha2 * Bfield.z()* Bfield.x() );
1516  dir_y = +( lorentzAngle * Bfield.x() - alpha2 * Bfield.z()* Bfield.y() );
1517  dir_z = -(1 + alpha2 * Bfield.z()*Bfield.z() );
1518  scale = (1 + alpha2 * Bfield.z()*Bfield.z() );
1519  }// end: Read LA from DataBase.
1520 
1521  LocalVector theDriftDirection = LocalVector(dir_x/scale, dir_y/scale, dir_z/scale );
1522 
1523 #ifdef TP_DEBUG
1524  LogDebug ("Pixel Digitizer") << " The drift direction in local coordinate is "
1525  << theDriftDirection ;
1526 #endif
1527 
1528  return theDriftDirection;
1529 }
1530 
1531 //****************************************************************************************************
1532 
1534  if(!use_ineff_from_db_)
1535  return;
1536 
1537  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
1538  for(signal_map_iterator i = _signal.begin();i != _signal.end(); i++) {
1539 
1540  // int chan = i->first;
1541  pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1542  int row = ip.first; // X in row
1543  int col = ip.second; // Y is in col
1544  uint32_t detid = detID;
1545  //transform to ROC index coordinates
1546  if(theSiPixelGainCalibrationService_->isDead(detid, col, row)){
1547  // std::cout << "now in isdead check, row " << detid << " " << col << "," << row << std::endl;
1548  // make pixel amplitude =0, pixel will be lost at clusterization
1549  i->second.set(0.); // reset amplitude,
1550  } // end if
1551  } // end pixel loop
1552 } // end pixel_indefficiency
1553 
1554 
1555 //****************************************************************************************************
1556 
1558  if(!use_module_killing_)
1559  return;
1560 
1561  bool isbad=false;
1562  int detid = detID;
1563 
1564  Parameters::iterator itDeadModules=DeadModules.begin();
1565 
1566  for(; itDeadModules != DeadModules.end(); ++itDeadModules){
1567  int Dead_detID = itDeadModules->getParameter<int>("Dead_detID");
1568  if(detid==Dead_detID){
1569  isbad=true;
1570  break;
1571  }
1572  }
1573 
1574  if(!isbad)
1575  return;
1576 
1577  std::string Module = itDeadModules->getParameter<std::string>("Module");
1578 
1579  if(Module=="whole"){
1580  for(signal_map_iterator i = _signal.begin();i != _signal.end(); i++) {
1581  i->second.set(0.); // reset amplitude
1582  }
1583  }
1584 
1585  for(signal_map_iterator i = _signal.begin();i != _signal.end(); i++) {
1586  pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1587 
1588  if(Module=="tbmA" && ip.first>=80 && ip.first<=159){
1589  i->second.set(0.);
1590  }
1591 
1592  if( Module=="tbmB" && ip.first<=79){
1593  i->second.set(0.);
1594 
1595  }
1596  }
1597 }
1598 //****************************************************************************************************
1600  if(!use_module_killing_)
1601  return;
1602 
1603  bool isbad=false;
1604  uint32_t detid = detID;
1605 
1606  std::vector<SiPixelQuality::disabledModuleType>disabledModules = SiPixelBadModule_->getBadComponentList();
1607 
1609 
1610  for (size_t id=0;id<disabledModules.size();id++)
1611  {
1612  if(detid==disabledModules[id].DetID){
1613  isbad=true;
1614  badmodule = disabledModules[id];
1615  break;
1616  }
1617  }
1618 
1619  if(!isbad)
1620  return;
1621 
1622  //cout<<"Hit in: "<< detid <<" errorType "<< badmodule.errorType<<" BadRocs="<<hex<<SiPixelBadModule_->getBadRocs(detid)<<dec<<" "<<endl;
1623  if(badmodule.errorType == 0){ // this is a whole dead module.
1624 
1625  for(signal_map_iterator i = _signal.begin();i != _signal.end(); i++) {
1626  i->second.set(0.); // reset amplitude
1627  }
1628  }
1629  else { // all other module types: half-modules and single ROCs.
1630  // Get Bad ROC position:
1631  //follow the example of getBadRocPositions in CondFormats/SiPixelObjects/src/SiPixelQuality.cc
1632  std::vector<GlobalPixel> badrocpositions (0);
1633  for(unsigned int j = 0; j < 16; j++){
1634  if(SiPixelBadModule_->IsRocBad(detid, j) == true){
1635 
1636  std::vector<CablingPathToDetUnit> path = map_.product()->pathToDetUnit(detid);
1637  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
1638  for (IT it = path.begin(); it != path.end(); ++it) {
1639  const PixelROC* myroc = map_.product()->findItem(*it);
1640  if( myroc->idInDetUnit() == j) {
1641  LocalPixel::RocRowCol local = { 39, 25}; //corresponding to center of ROC row, col
1642  GlobalPixel global = myroc->toGlobal( LocalPixel(local) );
1643  badrocpositions.push_back(global);
1644  break;
1645  }
1646  }
1647  }
1648  }// end of getBadRocPositions
1649 
1650 
1651  for(signal_map_iterator i = _signal.begin();i != _signal.end(); i++) {
1652  pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
1653 
1654  for(std::vector<GlobalPixel>::const_iterator it = badrocpositions.begin(); it != badrocpositions.end(); ++it){
1655  if(it->row >= 80 && ip.first >= 80 ){
1656  if((fabs(ip.second - it->col) < 26) ) {i->second.set(0.);}
1657  else if(it->row==120 && ip.second-it->col==26){i->second.set(0.);}
1658  else if(it->row==119 && it->col-ip.second==26){i->second.set(0.);}
1659  }
1660  else if(it->row < 80 && ip.first < 80 ){
1661  if((fabs(ip.second - it->col) < 26) ){i->second.set(0.);}
1662  else if(it->row==40 && ip.second-it->col==26){i->second.set(0.);}
1663  else if(it->row==39 && it->col-ip.second==26){i->second.set(0.);}
1664  }
1665  }
1666  }
1667  }
1668 }
1669 
int adc(sample_type sample)
get the ADC sample (12 bits)
#define LogDebug(id)
void init(const edm::EventSetup &es)
std::vector< T > collection_type
Definition: DetSet.h:27
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
Local3DVector LocalVector
Definition: LocalVector.h:12
float tof() const
deprecated name for timeOfFlight()
Definition: PSimHit.h:72
edm::ESHandle< SiPixelFedCablingMap > map_
GaussianTailNoiseGenerator * theNoiser
T y() const
Definition: PV2DBase.h:45
GlobalPixel toGlobal(const LocalPixel &loc) const
Definition: PixelROC.cc:44
static int DColumn(const int colROC)
Definition: PixelIndices.h:229
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
virtual int ncolumns() const =0
const PixelGeomDetUnit * _detp
SiG4UniversalFluctuation * fluctuate
T y() const
Definition: PV3DBase.h:62
virtual int nrows() const =0
#define abs(x)
Definition: mlp_lapack.h:159
#define min(a, b)
Definition: mlp_lapack.h:161
int transformToROC(const int col, const int row, int &rocId, int &colROC, int &rowROC) const
Definition: PixelIndices.h:163
#define Module(md)
Definition: vmac.h:202
std::vector< PixelDigi > digitize(PixelGeomDetUnit *det)
void fluctuateEloss(int particleId, float momentum, float eloss, float length, int NumberOfSegments, float elossVector[])
identify pixel inside single ROC
Definition: LocalPixel.h:7
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
const BoundPlane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:38
SiPixelGainCalibrationOfflineSimService * theSiPixelGainCalibrationService_
static int pixelToChannel(int row, int col)
Definition: PixelDigi.h:47
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:45
CLHEP::RandGaussQ * gaussDistributionVCALNoise_
virtual float thickness() const =0
double SampleFluctuations(const double momentum, const double mass, double &tmax, const double length, const double meanLoss)
list path
Definition: scaleCards.py:51
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:66
void fillDeadModules(const edm::EventSetup &es)
T sqrt(T t)
Definition: SSEVec.h:46
T z() const
Definition: PV3DBase.h:63
static int pixelToChannelROC(const int rowROC, const int colROC)
Definition: PixelIndices.h:250
tuple result
Definition: query.py:137
std::vector< PixelDigiSimLink > link_coll
edm::DetSet< PixelDigi >::collection_type run(const std::vector< PSimHit > &input, PixelGeomDetUnit *pixdet, GlobalVector)
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:43
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:72
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
void fillLorentzAngle(const edm::EventSetup &es)
std::vector< LinkConnSpec >::const_iterator IT
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
Definition: PSimHit.h:63
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:39
double p2[4]
Definition: TauolaWrapper.h:90
edm::ESHandle< SiPixelLorentzAngle > SiPixelLorentzAngle_
std::map< int, CalParameters, std::less< int > > calmap
tuple conf
Definition: dbtoconf.py:185
Double_t Sigma(double mHreq, TString proc)
tuple par0
Definition: fitWZ.py:51
virtual std::pair< float, float > pitch() const =0
Definition: DetId.h:20
const Bounds & bounds() const
Definition: BoundSurface.h:89
std::vector< PixelDigi > internal_coll
edm::ESHandle< SiPixelQuality > SiPixelBadModule_
void fillMapandGeom(const edm::EventSetup &es)
const T & get() const
Definition: EventSetup.h:55
static std::pair< int, int > channelToPixel(int ch)
Definition: PixelDigi.h:41
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
T const * product() const
Definition: ESHandle.h:62
row and collumn in ROC representation
Definition: LocalPixel.h:15
CLHEP::RandGaussQ * smearedThreshold_FPix_
std::vector< EnergyDepositUnit > _ionization_points
std::vector< edm::ParameterSet > Parameters
CLHEP::RandGaussQ * smearedThreshold_BPix_
void generate(int NumberOfchannels, float threshold, float noiseRMS, std::map< int, float > &theMap)
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
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
tuple filename
Definition: lut2db_cfg.py:20
Signal rand(Signal arg)
Definition: vlib.cc:442
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
const RotationType & rotation() const
tuple cout
Definition: gather_cfg.py:121
void primary_ionization(const PSimHit &hit)
SiPixelDigitizerAlgorithm(const edm::ParameterSet &conf, CLHEP::HepRandomEngine &)
tuple status
Definition: ntuplemaker.py:245
x
Definition: VDTMath.h:216
std::vector< SignalPoint > _collection_points
float missCalibrate(int col, int row, float amp) const
static int DColumnInModule(const int dcol, const int chipIndex)
Definition: PixelIndices.h:243
T x() const
Definition: PV2DBase.h:44
T x() const
Definition: PV3DBase.h:61
void induce_signal(const PSimHit &hit)
const PositionType & position() const
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
bool isDead(const uint32_t &detID, const int &col, const int &row)
*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
double p3[4]
Definition: TauolaWrapper.h:91
CLHEP::HepRandomEngine & rndEngine