CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DataMixingSiPixelMCDigiWorker.cc
Go to the documentation of this file.
1 // File: DataMixingSiPixelWorker.cc
2 // Description: see DataMixingSiPixelMCDigiWorker.h
3 // Author: Mike Hildreth, University of Notre Dame
4 //
5 //--------------------------------------------
6 
7 #include <map>
8 #include <memory>
16 //
17 //
18 
26 #include "CLHEP/Random/RandFlat.h"
27 
29 
30 
31 using namespace std;
32 
33 namespace edm
34 {
35 
36  // Virtual constructor
37 
38  // DataMixingSiPixelMCDigiWorker::DataMixingSiPixelMCDigiWorker() { }
39 
40  // Constructor
41  DataMixingSiPixelMCDigiWorker::DataMixingSiPixelMCDigiWorker(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) :
42  label_(ps.getParameter<std::string>("Label")),
43  geometryType_(ps.getParameter<std::string>("GeometryType")),
44  // get external parameters:
45  // To account for upgrade geometries do not assume the number
46  // of layers or disks.
47  NumberOfBarrelLayers(ps.exists("NumPixelBarrel")?ps.getParameter<int>("NumPixelBarrel"):3),
48  NumberOfEndcapDisks(ps.exists("NumPixelEndcap")?ps.getParameter<int>("NumPixelEndcap"):2),
49  theInstLumiScaleFactor(ps.getParameter<double>("theInstLumiScaleFactor")), //For dynamic inefficiency PU scaling
50  bunchScaleAt25(ps.getParameter<double>("bunchScaleAt25")), //For dynamic inefficiency bunchspace scaling
51  // Control the pixel inefficiency
52  AddPixelInefficiency(ps.getParameter<bool>("AddPixelInefficiencyFromPython")),
53  pixelEff_(ps, AddPixelInefficiency,NumberOfBarrelLayers,NumberOfEndcapDisks)
54  {
55 
56  // get the subdetector names
57  // this->getSubdetectorNames(); //something like this may be useful to check what we are supposed to do...
58 
59  // declare the products to produce
60 
61  pixeldigi_collectionSig_ = ps.getParameter<edm::InputTag>("pixeldigiCollectionSig");
62  pixeldigi_collectionPile_ = ps.getParameter<edm::InputTag>("pixeldigiCollectionPile");
63  PixelDigiCollectionDM_ = ps.getParameter<std::string>("PixelDigiCollectionDM");
64 
67 
68  // clear local storage for this event
69  SiHitStorage_.clear();
70 
71  }
72 
73 
74  // Virtual destructor needed.
76  }
77 
78  // Need an event initialization
79 
81 
83  //edm::ESHandle<TrackerTopology> tTopoHand;
84  //iSetup.get<IdealGeometryRecord>().get(tTopoHand);
85  //const TrackerTopology *tTopo=tTopoHand.product();
86  }
87 
88 
89  DataMixingSiPixelMCDigiWorker::PixelEfficiencies::PixelEfficiencies(const edm::ParameterSet& conf, bool AddPixelInefficiency, int NumberOfBarrelLayers, int NumberOfEndcapDisks) {
90  // pixel inefficiency
91  // Don't use Hard coded values, read inefficiencies in from python or don't use any
92  int NumberOfTotLayers = NumberOfBarrelLayers + NumberOfEndcapDisks;
94  if (AddPixelInefficiency){
95  int i=0;
96  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix1");
97  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix2");
98  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix3");
99  if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix4");}
100  //
101  i=0;
102  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix1");
103  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix2");
104  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix3");
105  if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix4");}
106  //
107  i=0;
108  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix1");
109  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix2");
110  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix3");
111  if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix4");}
112  //
113  i=0;
114  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix1");
115  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix2");
116  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix3");
117  if ( ((theLadderEfficiency_BPix[0].size()!=20) || (theLadderEfficiency_BPix[1].size()!=32) ||
118  (theLadderEfficiency_BPix[2].size()!=44)) && (NumberOfBarrelLayers==3) )
119  throw cms::Exception("Configuration") << "Wrong ladder number in efficiency config!";
120  //
121  i=0;
122  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix1");
123  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix2");
124  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix3");
125  if ( ((theModuleEfficiency_BPix[0].size()!=4) || (theModuleEfficiency_BPix[1].size()!=4) ||
126  (theModuleEfficiency_BPix[2].size()!=4)) && (NumberOfBarrelLayers==3) )
127  throw cms::Exception("Configuration") << "Wrong module number in efficiency config!";
128  //
129  i=0;
130  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_BPix1");
131  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_BPix2");
132  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_BPix3");
133  if ( ((thePUEfficiency[0].size()==0) || (thePUEfficiency[1].size()==0) ||
134  (thePUEfficiency[2].size()==0)) && (NumberOfBarrelLayers==3) )
135  throw cms::Exception("Configuration") << "At least one PU efficiency (BPix) number is needed in efficiency config!";
136  // The next is needed for Phase2 Tracker studies
137  if (NumberOfBarrelLayers>=5){
138  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
139  // For Phase2 tracker layers just set the outermost BPix inefficiency to 99.9% THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
140  for (int j=5 ; j<=NumberOfBarrelLayers ; j++){
141  thePixelColEfficiency[j-1]=0.999;
142  thePixelEfficiency[j-1]=0.999;
143  thePixelChipEfficiency[j-1]=0.999;
144  }
145  }
146  //
147  i=FPixIndex;
148  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_FPix1");
149  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_FPix2");
150  if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_FPix3");}
151  i=FPixIndex;
152  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_FPix1");
153  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_FPix2");
154  if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_FPix3");}
155  i=FPixIndex;
156  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_FPix1");
157  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_FPix2");
158  if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_FPix3");}
159  // The next is needed for Phase2 Tracker studies
160  if (NumberOfEndcapDisks>=4){
161  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
162  // For Phase2 tracker layers just set the extra FPix disk inefficiency to 99.9% THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
163  for (int j=4+FPixIndex ; j<=NumberOfEndcapDisks+NumberOfBarrelLayers ; j++){
164  thePixelColEfficiency[j-1]=0.999;
165  thePixelEfficiency[j-1]=0.999;
166  thePixelChipEfficiency[j-1]=0.999;
167  }
168  }
169  //FPix Dynamic Inefficiency
170  i=FPixIndex;
171  theInnerEfficiency_FPix[i++] = conf.getParameter<double>("theInnerEfficiency_FPix1");
172  theInnerEfficiency_FPix[i++] = conf.getParameter<double>("theInnerEfficiency_FPix2");
173  i=FPixIndex;
174  theOuterEfficiency_FPix[i++] = conf.getParameter<double>("theOuterEfficiency_FPix1");
175  theOuterEfficiency_FPix[i++] = conf.getParameter<double>("theOuterEfficiency_FPix2");
176  i=FPixIndex;
177  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_FPix_Inner");
178  thePUEfficiency[i++] = conf.getParameter<std::vector<double> >("thePUEfficiency_FPix_Outer");
179  if ( ((thePUEfficiency[3].size()==0) || (thePUEfficiency[4].size()==0)) && (NumberOfEndcapDisks==2) )
180  throw cms::Exception("Configuration") << "At least one (FPix) PU efficiency number is needed in efficiency config!";
181  }
182  // the first "NumberOfBarrelLayers" settings [0],[1], ... , [NumberOfBarrelLayers-1] are for the barrel pixels
183  // the next "NumberOfEndcapDisks" settings [NumberOfBarrelLayers],[NumberOfBarrelLayers+1], ... [NumberOfEndcapDisks+NumberOfBarrelLayers-1]
184  }
185 
186 
187 
188 
190  // fill in maps of hits
191 
192  LogDebug("DataMixingSiPixelMCDigiWorker")<<"===============> adding MC signals for "<<e.id();
193 
195 
196  if( e.getByToken(PixelDigiToken_,input) ) {
197 
198  //loop on all detsets (detectorIDs) inside the input collection
199  edm::DetSetVector<PixelDigi>::const_iterator DSViter=input->begin();
200  for (; DSViter!=input->end();DSViter++){
201 
202 #ifdef DEBUG
203  LogDebug("DataMixingSiPixelMCDigiWorker") << "Processing DetID " << DSViter->id;
204 #endif
205 
206  uint32_t detID = DSViter->id;
210 
211  OneDetectorMap LocalMap;
212 
213  for (icopy=begin; icopy!=end; icopy++) {
214  LocalMap.insert(OneDetectorMap::value_type( (icopy->channel()), *icopy ));
215  }
216 
217  SiHitStorage_.insert( SiGlobalIndex::value_type( detID, LocalMap ) );
218  }
219 
220  }
221  } // end of addSiPixelSignals
222 
223 
224 
225  void DataMixingSiPixelMCDigiWorker::addSiPixelPileups(const int bcr, const EventPrincipal *ep, unsigned int eventNr,
226  ModuleCallingContext const* mcc) {
227 
228  LogDebug("DataMixingSiPixelMCDigiWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
229 
230  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
231 
232  std::shared_ptr<Wrapper<edm::DetSetVector<PixelDigi> > const> inputPTR =
233  getProductByTag<edm::DetSetVector<PixelDigi> >(*ep, pixeldigi_collectionPile_, mcc);
234 
235  if(inputPTR ) {
236 
237  const edm::DetSetVector<PixelDigi> *input = const_cast< edm::DetSetVector<PixelDigi> * >(inputPTR->product());
238 
239 
240 
241  // Handle< edm::DetSetVector<PixelDigi> > input;
242 
243  // if( e->getByLabel(pixeldigi_collectionPile_,input) ) {
244 
245  //loop on all detsets (detectorIDs) inside the input collection
247  for (; DSViter!=input->end();DSViter++){
248 
249 #ifdef DEBUG
250  LogDebug("DataMixingSiPixelMCDigiWorker") << "Pileups: Processing DetID " << DSViter->id;
251 #endif
252 
253  uint32_t detID = DSViter->id;
257 
258  // find correct local map (or new one) for this detector ID
259 
260  SiGlobalIndex::const_iterator itest;
261 
262  itest = SiHitStorage_.find(detID);
263 
264  if(itest!=SiHitStorage_.end()) { // this detID already has hits, add to existing map
265 
266  OneDetectorMap LocalMap = itest->second;
267 
268  // fill in local map with extra channels
269  for (icopy=begin; icopy!=end; icopy++) {
270  LocalMap.insert(OneDetectorMap::value_type( (icopy->channel()), *icopy ));
271  }
272 
273  SiHitStorage_[detID]=LocalMap;
274 
275  }
276  else{ // fill local storage with this information, put in global collection
277 
278  OneDetectorMap LocalMap;
279 
280  for (icopy=begin; icopy!=end; icopy++) {
281  LocalMap.insert(OneDetectorMap::value_type( (icopy->channel()), *icopy ));
282  }
283 
284  SiHitStorage_.insert( SiGlobalIndex::value_type( detID, LocalMap ) );
285  }
286 
287  }
288  }
289  }
290 
291 
292 
293  void DataMixingSiPixelMCDigiWorker::putSiPixel(edm::Event &e, edm::EventSetup const& iSetup, std::vector<PileupSummaryInfo> &ps, int &bs) {
294 
295  // collection of Digis to put in the event
296 
297  std::vector< edm::DetSet<PixelDigi> > vPixelDigi;
298 
299  // loop through our collection of detectors, merging hits and putting new ones in the output
300 
301  _signal.clear();
302 
303  // big loop over Detector IDs:
304 
305  for(SiGlobalIndex::const_iterator IDet = SiHitStorage_.begin();
306  IDet != SiHitStorage_.end(); IDet++) {
307 
308  uint32_t detID = IDet->first;
309 
310  OneDetectorMap LocalMap = IDet->second;
311 
312  signal_map_type Signals;
313  Signals.clear();
314 
315  //counter variables
316  int formerPixel = -1;
317  int currentPixel;
318  int ADCSum = 0;
319 
320 
321  OneDetectorMap::const_iterator iLocalchk;
322 
323  for(OneDetectorMap::const_iterator iLocal = LocalMap.begin();
324  iLocal != LocalMap.end(); ++iLocal) {
325 
326  currentPixel = iLocal->first;
327 
328  if (currentPixel == formerPixel) { // we have to add these digis together
329  ADCSum+=(iLocal->second).adc();
330  }
331  else{
332  if(formerPixel!=-1){ // ADC info stolen from SiStrips...
333  if (ADCSum > 511) ADCSum = 255;
334  else if (ADCSum > 253 && ADCSum < 512) ADCSum = 254;
335 
336  Signals.insert( std::make_pair(formerPixel, ADCSum));
337  //PixelDigi aHit(formerPixel, ADCSum);
338  //SPD.push_back( aHit );
339  }
340  // save pointers for next iteration
341  formerPixel = currentPixel;
342  ADCSum = (iLocal->second).adc();
343  }
344 
345  iLocalchk = iLocal;
346  if((++iLocalchk) == LocalMap.end()) { //make sure not to lose the last one
347  if (ADCSum > 511) ADCSum = 255;
348  else if (ADCSum > 253 && ADCSum < 512) ADCSum = 254;
349  Signals.insert( std::make_pair(formerPixel, ADCSum));
350  //SPD.push_back( PixelDigi(formerPixel, ADCSum) );
351  }
352 
353  }// end of loop over one detector
354 
355  // stick this into the global vector of detector info
356  _signal.insert( std::make_pair( detID, Signals));
357 
358  } // end of big loop over all detector IDs
359 
360  // put the collection of digis in the event
361  LogInfo("DataMixingSiPixelMCDigiWorker") << "total # Merged Pixels: " << _signal.size() ;
362 
363  // Now, we have to run Lumi-Dependent efficiency calculation on the merged pixels.
364  // This is the only place where we have the PreMixed pileup information so that we can calculate
365  // the instantaneous luminosity and do the dynamic inefficiency.
366 
368  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
369 
371  iSetup.get<IdealGeometryRecord>().get(tTopoHand);
372  const TrackerTopology *tTopo=tTopoHand.product();
373 
374  // set pileup information.
375 
376  setPileupInfo(ps, bs);
377 
378  for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); iu ++){
379 
380  if((*iu)->type().isTrackerPixel()) {
381 
382  //
383  const PixelGeomDetUnit* pixdet = dynamic_cast<const PixelGeomDetUnit*>((*iu));
384  uint32_t detID = pixdet->geographicalId().rawId();
385 
386  // fetch merged hits for this detID
387 
388  signal_map_type& theSignal = _signal[detID];
389 
390  // if we have some hits...
391  if(theSignal.size()>0) {
392 
393  edm::DetSet<PixelDigi> SPD(detID); // make empty vector with this detID so we can push back digis at the end
394 
395  const PixelTopology* topol=&pixdet->specificTopology();
396  int numColumns = topol->ncolumns(); // det module number of cols&rows
397  int numRows = topol->nrows();
398 
399  // do inefficiency calculation, drop some pixel hits
400 
401  // Predefined efficiencies
402  double pixelEfficiency = 1.0;
403  double columnEfficiency = 1.0;
404  double chipEfficiency = 1.0;
405 
406  // setup the chip indices conversion
408  pixdet->subDetector()==GeomDetEnumerators::SubDetector::P1PXB){// barrel layers
409  int layerIndex=tTopo->layer(detID);
410  pixelEfficiency = pixelEff_.thePixelEfficiency[layerIndex-1];
411  columnEfficiency = pixelEff_.thePixelColEfficiency[layerIndex-1];
412  chipEfficiency = pixelEff_.thePixelChipEfficiency[layerIndex-1];
413  //std::cout <<"Using BPix columnEfficiency = "<<columnEfficiency<< " for layer = "<<layerIndex <<"\n";
414  // This should never happen, but only check if it is not an upgrade geometry
415  if (NumberOfBarrelLayers==3){
416  if(numColumns>416) LogWarning ("Pixel Geometry") <<" wrong columns in barrel "<<numColumns;
417  if(numRows>160) LogWarning ("Pixel Geometry") <<" wrong rows in barrel "<<numRows;
418 
419  int ladder=tTopo->pxbLadder(detID);
420  int module=tTopo->pxbModule(detID);
421  if (module<=4) module=5-module;
422  else module-=4;
423 
424  columnEfficiency *= pixelEff_.theLadderEfficiency_BPix[layerIndex-1][ladder-1]*pixelEff_.theModuleEfficiency_BPix[layerIndex-1][module-1]*_pu_scale[layerIndex-1];
425  }
428  pixdet->subDetector()==GeomDetEnumerators::SubDetector::P2PXEC){ // forward disks
429 
430  unsigned int diskIndex=tTopo->layer(detID)+pixelEff_.FPixIndex; // Use diskIndex-1 later to stay consistent with BPix
431  unsigned int panelIndex=tTopo->pxfPanel(detID);
432  unsigned int moduleIndex=tTopo->pxfModule(detID);
433  //if (pixelEff_.FPixIndex>diskIndex-1){throw cms::Exception("Configuration") <<"SiPixelDigitizer is using the wrong efficiency value. index = "
434  // <<diskIndex-1<<" , MinIndex = "<<pixelEff_.FPixIndex<<" ... "<<tTopo->pxfDisk(detID);}
435  pixelEfficiency = pixelEff_.thePixelEfficiency[diskIndex-1];
436  columnEfficiency = pixelEff_.thePixelColEfficiency[diskIndex-1];
437  chipEfficiency = pixelEff_.thePixelChipEfficiency[diskIndex-1];
438  //std::cout <<"Using FPix columnEfficiency = "<<columnEfficiency<<" for Disk = "<< tTopo->pxfDisk(detID)<<"\n";
439  // Sometimes the forward pixels have wrong size,
440  // this crashes the index conversion, so exit, but only check if it is not an upgrade geometry
441  if (NumberOfBarrelLayers==3){ // whether it is the present or the phase 1 detector can be checked using GeomDetEnumerators::SubDetector
442  if(numColumns>260 || numRows>160) {
443  if(numColumns>260) LogWarning ("Pixel Geometry") <<" wrong columns in endcaps "<<numColumns;
444  if(numRows>160) LogWarning ("Pixel Geometry") <<" wrong rows in endcaps "<<numRows;
445  return;
446  }
447  if ((panelIndex==1 && (moduleIndex==1 || moduleIndex==2)) || (panelIndex==2 && moduleIndex==1)) { //inner modules
448  columnEfficiency*=pixelEff_.theInnerEfficiency_FPix[diskIndex-1]*_pu_scale[3];
449  } else { //outer modules
450  columnEfficiency*=pixelEff_.theOuterEfficiency_FPix[diskIndex-1]*_pu_scale[4];
451  }
452  } // current detector, forward
454  // If phase 2 outer tracker, hardcoded values as they have been so far
455  pixelEfficiency = 0.999;
456  columnEfficiency = 0.999;
457  chipEfficiency = 0.999;
458  } // if barrel/forward
459 
460 
461  // Initilize the index converter
462  //PixelIndices indexConverter(numColumns,numRows);
463  std::auto_ptr<PixelIndices> pIndexConverter(new PixelIndices(numColumns,numRows));
464 
465  int chipIndex = 0;
466  int rowROC = 0;
467  int colROC = 0;
468  std::map<int, int, std::less<int> >chips, columns;
469  std::map<int, int, std::less<int> >::iterator iter;
470 
471  // Find out the number of columns and rocs hits
472  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
473  for (signal_map_const_iterator i = theSignal.begin(); i != theSignal.end(); ++i) {
474 
475  int chan = i->first;
476  std::pair<int,int> ip = PixelDigi::channelToPixel(chan);
477  int row = ip.first; // X in row
478  int col = ip.second; // Y is in col
479  //transform to ROC index coordinates
480  pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
481  int dColInChip = pIndexConverter->DColumn(colROC); // get ROC dcol from ROC col
482  //dcol in mod
483  int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
484 
485  chips[chipIndex]++;
486  columns[dColInDet]++;
487  }
488 
489  // Delete some ROC hits.
490  for ( iter = chips.begin(); iter != chips.end() ; iter++ ) {
491  //float rand = RandFlat::shoot();
492  float rand = CLHEP::RandFlat::shoot(engine);
493  if( rand > chipEfficiency ) chips[iter->first]=0;
494  }
495 
496  // Delete some Dcol hits.
497  for ( iter = columns.begin(); iter != columns.end() ; iter++ ) {
498  //float rand = RandFlat::shoot();
499  float rand = CLHEP::RandFlat::shoot(engine);
500  if( rand > columnEfficiency ) columns[iter->first]=0;
501  }
502 
503  // Now loop again over pixels to kill some of them.
504  // Loop over hit pixels, amplitude in electrons, channel = coded row,col
505  for(signal_map_iterator i = theSignal.begin();i != theSignal.end(); ++i) {
506 
507  // int chan = i->first;
508  std::pair<int,int> ip = PixelDigi::channelToPixel(i->first);//get pixel pos
509  int row = ip.first; // X in row
510  int col = ip.second; // Y is in col
511  //transform to ROC index coordinates
512  pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC);
513  int dColInChip = pIndexConverter->DColumn(colROC); //get ROC dcol from ROC col
514  //dcol in mod
515  int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex);
516 
517  //float rand = RandFlat::shoot();
518  float rand = CLHEP::RandFlat::shoot(engine);
519  if( chips[chipIndex]==0 || columns[dColInDet]==0
520  || rand>pixelEfficiency ) {
521  // make pixel amplitude =0, pixel will be lost at clusterization
522  i->second=(0.); // reset amplitude
523  } // end if
524  //Make a new Digi:
525 
526  SPD.push_back( PixelDigi(i->first, i->second) );
527 
528  } // end pixel loop
529  // push back vector here of one detID
530 
531  vPixelDigi.push_back(SPD);
532  }
533  }
534  }// end of loop over detectors
535 
536  // make new digi collection
537 
538  std::auto_ptr< edm::DetSetVector<PixelDigi> > MyPixelDigis(new edm::DetSetVector<PixelDigi>(vPixelDigi) );
539 
540  // put collection
541 
542  e.put( MyPixelDigis, PixelDigiCollectionDM_ );
543 
544  // clear local storage for this event
545  SiHitStorage_.clear();
546  }
547 
548 void DataMixingSiPixelMCDigiWorker::setPileupInfo(const std::vector<PileupSummaryInfo> &ps, const int &bunchSpacing) {
549 
550  double bunchScale=1.0;
551  if (bunchSpacing==25) bunchScale=bunchScaleAt25;
552 
553  int p = -1;
554  for ( unsigned int i=0; i<ps.size(); i++)
555  if ( ps[i].getBunchCrossing() == 0 )
556  p=i;
557 
558  if ( p>=0 ) {
559  for (size_t i=0; i<5; i++) {
560  double instlumi = ps[p].getTrueNumInteractions()*theInstLumiScaleFactor*bunchScale;
561  double instlumi_pow=1.;
562  _pu_scale[i] = 0;
563  for (size_t j=0; j<pixelEff_.thePUEfficiency[i].size(); j++){
564  _pu_scale[i]+=instlumi_pow*pixelEff_.thePUEfficiency[i][j];
565  instlumi_pow*=instlumi;
566  }
567  }
568  }
569 
570 
571 } //this sets pu_scale
572 
573 } //edm
int adc(sample_type sample)
get the ADC sample (12 bits)
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::multimap< int, PixelDigi > OneDetectorMap
void push_back(const T &t)
Definition: DetSet.h:68
virtual int ncolumns() const =0
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > PixelDigiToken_
EventID const & id() const
unsigned int pxbLadder(const DetId &id) const
virtual int nrows() const =0
virtual void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
unsigned int pxbModule(const DetId &id) const
static std::string const input
Definition: EdmProvDump.cc:43
signal_map_type::const_iterator signal_map_const_iterator
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
int j
Definition: DBlmapReader.cc:9
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:77
#define end
Definition: vmac.h:37
std::map< int, Amplitude, std::less< int > > signal_map_type
Container::value_type value_type
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:365
tuple conf
Definition: dbtoconf.py:185
unsigned int pxfModule(const DetId &id) const
void setPileupInfo(const std::vector< PileupSummaryInfo > &ps, const int &bs)
const T & get() const
Definition: EventSetup.h:55
static std::pair< int, int > channelToPixel(int ch)
Definition: PixelDigi.h:62
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
T const * product() const
Definition: ESHandle.h:86
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
unsigned int layer(const DetId &id) const
edm::EventID id() const
Definition: EventBase.h:60
#define begin
Definition: vmac.h:30
void addSiPixelPileups(const int bcr, const edm::EventPrincipal *, unsigned int EventId, ModuleCallingContext const *)
StreamID streamID() const
Definition: Event.h:72
Signal rand(Signal arg)
Definition: vlib.cc:442
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > PixelDigiPToken_
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:350
PixelEfficiencies(const edm::ParameterSet &conf, bool AddPixelInefficiency, int NumberOfBarrelLayers, int NumberOfEndcapDisks)
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
int col
Definition: cuy.py:1008
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
virtual SubDetector subDetector() const
Which subdetector.
Definition: GeomDet.cc:49
void putSiPixel(edm::Event &e, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > &ps, int &bs)
Definition: vlib.h:208
tuple size
Write out results.
unsigned int pxfPanel(const DetId &id) const