CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalDigiProducer.cc
Go to the documentation of this file.
14 //#include "SimCalorimetry/EcalSimAlgos/interface/ESFastTDigitizer.h"
45 
55 
56 
59  m_APDShape ( params.getParameter<double>( "apdShapeTstart" ) ,
60  params.getParameter<double>( "apdShapeTau" ) ) ,
61  m_EBShape ( ) ,
62  m_EEShape ( ) ,
63  m_ESShape ( ) ,
64  m_EBdigiCollection ( params.getParameter<std::string>("EBdigiCollection") ) ,
65  m_EEdigiCollection ( params.getParameter<std::string>("EEdigiCollection") ) ,
66  m_ESdigiCollection ( params.getParameter<std::string>("ESdigiCollection") ) ,
67  m_hitsProducerTag ( params.getParameter<std::string>("hitsProducer" ) ) ,
68  m_useLCcorrection ( params.getUntrackedParameter<bool>("UseLCcorrection") ) ,
69  m_apdSeparateDigi ( params.getParameter<bool> ("apdSeparateDigi") ) ,
70 
71  m_EBs25notCont ( params.getParameter<double> ("EBs25notContainment") ) ,
72  m_EEs25notCont ( params.getParameter<double> ("EEs25notContainment") ) ,
73 
74  m_readoutFrameSize ( params.getParameter<int> ("readoutFrameSize") ) ,
75  m_ParameterMap ( new EcalSimParameterMap(
76  params.getParameter<double> ("simHitToPhotoelectronsBarrel") ,
77  params.getParameter<double> ("simHitToPhotoelectronsEndcap") ,
78  params.getParameter<double> ("photoelectronsToAnalogBarrel") ,
79  params.getParameter<double> ("photoelectronsToAnalogEndcap") ,
80  params.getParameter<double> ("samplingFactor") ,
81  params.getParameter<double> ("timePhase") ,
82  m_readoutFrameSize ,
83  params.getParameter<int> ("binOfMaximum") ,
84  params.getParameter<bool> ("doPhotostatistics") ,
85  params.getParameter<bool> ("syncPhase") ) ) ,
86 
87  m_apdDigiTag ( params.getParameter<std::string> ("apdDigiTag" ) ) ,
88  m_apdParameters ( new APDSimParameters(
89  params.getParameter<bool> ("apdAddToBarrel" ) ,
90  m_apdSeparateDigi ,
91  params.getParameter<double> ("apdSimToPELow" ) ,
92  params.getParameter<double> ("apdSimToPEHigh" ) ,
93  params.getParameter<double> ("apdTimeOffset" ) ,
94  params.getParameter<double> ("apdTimeOffWidth" ) ,
95  params.getParameter<bool> ("apdDoPEStats" ) ,
96  m_apdDigiTag ,
97  params.getParameter<std::vector<double> > ( "apdNonlParms" ) ) ) ,
98 
99  m_APDResponse ( !m_apdSeparateDigi ? 0 :
100  new EBHitResponse( m_ParameterMap ,
101  &m_EBShape ,
102  true ,
103  m_apdParameters ,
104  &m_APDShape ) ) ,
105 
106  m_EBResponse ( new EBHitResponse( m_ParameterMap ,
107  &m_EBShape ,
108  false , // barrel
109  m_apdParameters ,
110  &m_APDShape ) ) ,
111 
112  m_EEResponse ( new EEHitResponse( m_ParameterMap,
113  &m_EEShape ) ) ,
114  m_ESResponse ( new ESHitResponse( m_ParameterMap, &m_ESShape ) ) ,
115  m_ESOldResponse ( new CaloHitResponse( m_ParameterMap, &m_ESShape ) ) ,
116 
117  m_addESNoise ( params.getParameter<bool> ("doESNoise") ) ,
118  m_PreMix1 ( params.getParameter<bool> ("EcalPreMixStage1") ) ,
119  m_PreMix2 ( params.getParameter<bool> ("EcalPreMixStage2") ) ,
120 
121  m_doFastES ( params.getParameter<bool> ("doFast" ) ) ,
122 
123  m_ESElectronicsSim ( m_doFastES ? 0 :
124  new ESElectronicsSim( m_addESNoise ) ) ,
125 
126  m_ESOldDigitizer ( m_doFastES ? 0 :
127  new ESOldDigitizer( m_ESOldResponse ,
128  m_ESElectronicsSim ,
129  m_addESNoise ) ) ,
130 
131  m_ESElectronicsSimFast ( !m_doFastES ? 0 :
132  new ESElectronicsSimFast( m_addESNoise ,
133  m_PreMix1) ) ,
134 
135  m_ESDigitizer ( !m_doFastES ? 0 :
136  new ESDigitizer( m_ESResponse ,
137  m_ESElectronicsSimFast ,
138  m_addESNoise ) ) ,
139 
140  m_APDDigitizer ( 0 ) ,
141  m_BarrelDigitizer ( 0 ) ,
142  m_EndcapDigitizer ( 0 ) ,
143  m_ElectronicsSim ( 0 ) ,
144  m_Coder ( 0 ) ,
145  m_APDElectronicsSim ( 0 ) ,
146  m_APDCoder ( 0 ) ,
147  m_Geometry ( 0 ) ,
148  m_EBCorrNoise ( ) ,
149  m_EECorrNoise ( )
150 {
151  if(m_apdSeparateDigi) mixMod.produces<EBDigiCollection>(m_apdDigiTag);
152  mixMod.produces<EBDigiCollection>(m_EBdigiCollection);
153  mixMod.produces<EEDigiCollection>(m_EEdigiCollection);
154  mixMod.produces<ESDigiCollection>(m_ESdigiCollection);
155  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsEB"));
156  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsEE"));
157  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsES"));
158 
159  const std::vector<double> ebCorMatG12 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG12");
160  const std::vector<double> eeCorMatG12 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG12");
161  const std::vector<double> ebCorMatG06 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG06");
162  const std::vector<double> eeCorMatG06 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG06");
163  const std::vector<double> ebCorMatG01 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG01");
164  const std::vector<double> eeCorMatG01 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG01");
165 
166  const bool applyConstantTerm = params.getParameter<bool> ("applyConstantTerm");
167  const double rmsConstantTerm = params.getParameter<double> ("ConstantTerm");
168 
169  const bool addNoise = params.getParameter<bool> ("doENoise");
170  const bool cosmicsPhase = params.getParameter<bool> ("cosmicsPhase");
171  const double cosmicsShift = params.getParameter<double> ("cosmicsShift");
172 
173 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
174 
175  // further phase for cosmics studies
176  if( cosmicsPhase )
177  {
178  m_EBResponse->setPhaseShift( 1. + cosmicsShift ) ;
179  m_EEResponse->setPhaseShift( 1. + cosmicsShift ) ;
180  }
181 
182  EcalCorrMatrix ebMatrix[ 3 ] ;
183  EcalCorrMatrix eeMatrix[ 3 ] ;
184 
185  assert( ebCorMatG12.size() == m_readoutFrameSize ) ;
186  assert( eeCorMatG12.size() == m_readoutFrameSize ) ;
187  assert( ebCorMatG06.size() == m_readoutFrameSize ) ;
188  assert( eeCorMatG06.size() == m_readoutFrameSize ) ;
189  assert( ebCorMatG01.size() == m_readoutFrameSize ) ;
190  assert( eeCorMatG01.size() == m_readoutFrameSize ) ;
191 
192  assert( 1.e-7 > fabs( ebCorMatG12[0] - 1.0 ) ) ;
193  assert( 1.e-7 > fabs( ebCorMatG06[0] - 1.0 ) ) ;
194  assert( 1.e-7 > fabs( ebCorMatG01[0] - 1.0 ) ) ;
195  assert( 1.e-7 > fabs( eeCorMatG12[0] - 1.0 ) ) ;
196  assert( 1.e-7 > fabs( eeCorMatG06[0] - 1.0 ) ) ;
197  assert( 1.e-7 > fabs( eeCorMatG01[0] - 1.0 ) ) ;
198 
199  for ( unsigned int row ( 0 ) ; row != m_readoutFrameSize ; ++row )
200  {
201  assert( 0 == row || 1. >= ebCorMatG12[row] ) ;
202  assert( 0 == row || 1. >= ebCorMatG06[row] ) ;
203  assert( 0 == row || 1. >= ebCorMatG01[row] ) ;
204  assert( 0 == row || 1. >= eeCorMatG12[row] ) ;
205  assert( 0 == row || 1. >= eeCorMatG06[row] ) ;
206  assert( 0 == row || 1. >= eeCorMatG01[row] ) ;
207  for ( unsigned int column ( 0 ) ; column <= row ; ++column )
208  {
209  const unsigned int index ( row - column ) ;
210  ebMatrix[0]( row, column ) = ebCorMatG12[ index ] ;
211  eeMatrix[0]( row, column ) = eeCorMatG12[ index ] ;
212  ebMatrix[1]( row, column ) = ebCorMatG06[ index ] ;
213  eeMatrix[1]( row, column ) = eeCorMatG06[ index ] ;
214  ebMatrix[2]( row, column ) = ebCorMatG01[ index ] ;
215  eeMatrix[2]( row, column ) = eeCorMatG01[ index ] ;
216  }
217  }
218 
219  m_EBCorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[0] ) ;
220  m_EECorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[0] ) ;
221  m_EBCorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[1] ) ;
222  m_EECorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[1] ) ;
223  m_EBCorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[2] ) ;
224  m_EECorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[2] ) ;
225 
226  m_Coder = new EcalCoder( addNoise ,
227  m_PreMix1 ,
228  m_EBCorrNoise[0] ,
229  m_EECorrNoise[0] ,
230  m_EBCorrNoise[1] ,
231  m_EECorrNoise[1] ,
232  m_EBCorrNoise[2] ,
233  m_EECorrNoise[2] ) ;
234 
236  m_Coder ,
237  applyConstantTerm ,
238  rmsConstantTerm ) ;
239 
240  if( m_apdSeparateDigi )
241  {
242  m_APDCoder = new EcalCoder( false ,
243  m_EBCorrNoise[0] ,
244  m_EECorrNoise[0] ,
245  m_EBCorrNoise[1] ,
246  m_EECorrNoise[1] ,
247  m_EBCorrNoise[2] ,
248  m_EECorrNoise[2] ) ;
249 
251  m_APDCoder ,
252  applyConstantTerm ,
253  rmsConstantTerm ) ;
254 
257  false ) ;
258  }
259 
262  addNoise ) ;
263 
266  addNoise ) ;
267 }
268 
269 // duplicate version for Pre-Mixing, for use outside of MixingModule
272  m_APDShape ( params.getParameter<double>( "apdShapeTstart" ) ,
273  params.getParameter<double>( "apdShapeTau" ) ) ,
274  m_EBShape ( ) ,
275  m_EEShape ( ) ,
276  m_ESShape ( ) ,
277  m_EBdigiCollection ( params.getParameter<std::string>("EBdigiCollection") ) ,
278  m_EEdigiCollection ( params.getParameter<std::string>("EEdigiCollection") ) ,
279  m_ESdigiCollection ( params.getParameter<std::string>("ESdigiCollection") ) ,
280  m_hitsProducerTag ( params.getParameter<std::string>("hitsProducer" ) ) ,
281  m_useLCcorrection ( params.getUntrackedParameter<bool>("UseLCcorrection") ) ,
282  m_apdSeparateDigi ( params.getParameter<bool> ("apdSeparateDigi") ) ,
283 
284  m_EBs25notCont ( params.getParameter<double> ("EBs25notContainment") ) ,
285  m_EEs25notCont ( params.getParameter<double> ("EEs25notContainment") ) ,
286 
287  m_readoutFrameSize ( params.getParameter<int> ("readoutFrameSize") ) ,
288  m_ParameterMap ( new EcalSimParameterMap(
289  params.getParameter<double> ("simHitToPhotoelectronsBarrel") ,
290  params.getParameter<double> ("simHitToPhotoelectronsEndcap") ,
291  params.getParameter<double> ("photoelectronsToAnalogBarrel") ,
292  params.getParameter<double> ("photoelectronsToAnalogEndcap") ,
293  params.getParameter<double> ("samplingFactor") ,
294  params.getParameter<double> ("timePhase") ,
295  m_readoutFrameSize ,
296  params.getParameter<int> ("binOfMaximum") ,
297  params.getParameter<bool> ("doPhotostatistics") ,
298  params.getParameter<bool> ("syncPhase") ) ) ,
299 
300  m_apdDigiTag ( params.getParameter<std::string> ("apdDigiTag" ) ) ,
301  m_apdParameters ( new APDSimParameters(
302  params.getParameter<bool> ("apdAddToBarrel" ) ,
303  m_apdSeparateDigi ,
304  params.getParameter<double> ("apdSimToPELow" ) ,
305  params.getParameter<double> ("apdSimToPEHigh" ) ,
306  params.getParameter<double> ("apdTimeOffset" ) ,
307  params.getParameter<double> ("apdTimeOffWidth" ) ,
308  params.getParameter<bool> ("apdDoPEStats" ) ,
309  m_apdDigiTag ,
310  params.getParameter<std::vector<double> > ( "apdNonlParms" ) ) ) ,
311 
312  m_APDResponse ( !m_apdSeparateDigi ? 0 :
313  new EBHitResponse( m_ParameterMap ,
314  &m_EBShape ,
315  true ,
316  m_apdParameters ,
317  &m_APDShape ) ) ,
318 
319  m_EBResponse ( new EBHitResponse( m_ParameterMap ,
320  &m_EBShape ,
321  false , // barrel
322  m_apdParameters ,
323  &m_APDShape ) ) ,
324 
325  m_EEResponse ( new EEHitResponse( m_ParameterMap,
326  &m_EEShape ) ) ,
327  m_ESResponse ( new ESHitResponse( m_ParameterMap, &m_ESShape ) ) ,
328  m_ESOldResponse ( new CaloHitResponse( m_ParameterMap, &m_ESShape ) ) ,
329 
330  m_addESNoise ( params.getParameter<bool> ("doESNoise") ) ,
331  m_PreMix1 ( params.getParameter<bool> ("EcalPreMixStage1") ) ,
332  m_PreMix2 ( params.getParameter<bool> ("EcalPreMixStage2") ) ,
333 
334  m_doFastES ( params.getParameter<bool> ("doFast" ) ) ,
335 
336  m_ESElectronicsSim ( m_doFastES ? 0 :
337  new ESElectronicsSim( m_addESNoise ) ) ,
338 
339  m_ESOldDigitizer ( m_doFastES ? 0 :
340  new ESOldDigitizer( m_ESOldResponse ,
341  m_ESElectronicsSim ,
342  m_addESNoise ) ) ,
343 
344  m_ESElectronicsSimFast ( !m_doFastES ? 0 :
345  new ESElectronicsSimFast( m_addESNoise,
346  m_PreMix1 ) ) ,
347 
348  m_ESDigitizer ( !m_doFastES ? 0 :
349  new ESDigitizer( m_ESResponse ,
350  m_ESElectronicsSimFast ,
351  m_addESNoise ) ) ,
352 
353  m_APDDigitizer ( 0 ) ,
354  m_BarrelDigitizer ( 0 ) ,
355  m_EndcapDigitizer ( 0 ) ,
356  m_ElectronicsSim ( 0 ) ,
357  m_Coder ( 0 ) ,
358  m_APDElectronicsSim ( 0 ) ,
359  m_APDCoder ( 0 ) ,
360  m_Geometry ( 0 ) ,
361  m_EBCorrNoise ( ) ,
362  m_EECorrNoise ( )
363 {
364  // "produces" statements taken care of elsewhere.
365  // if(m_apdSeparateDigi) mixMod.produces<EBDigiCollection>(m_apdDigiTag);
366  // mixMod.produces<EBDigiCollection>(m_EBdigiCollection);
367  // mixMod.produces<EEDigiCollection>(m_EEdigiCollection);
368  // mixMod.produces<ESDigiCollection>(m_ESdigiCollection);
369  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsEB"));
370  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsEE"));
371  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsES"));
372 
373  const std::vector<double> ebCorMatG12 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG12");
374  const std::vector<double> eeCorMatG12 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG12");
375  const std::vector<double> ebCorMatG06 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG06");
376  const std::vector<double> eeCorMatG06 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG06");
377  const std::vector<double> ebCorMatG01 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG01");
378  const std::vector<double> eeCorMatG01 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG01");
379 
380  const bool applyConstantTerm = params.getParameter<bool> ("applyConstantTerm");
381  const double rmsConstantTerm = params.getParameter<double> ("ConstantTerm");
382 
383  const bool addNoise = params.getParameter<bool> ("doNoise");
384  const bool cosmicsPhase = params.getParameter<bool> ("cosmicsPhase");
385  const double cosmicsShift = params.getParameter<double> ("cosmicsShift");
386 
387 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
388 
389  // further phase for cosmics studies
390  if( cosmicsPhase )
391  {
392  m_EBResponse->setPhaseShift( 1. + cosmicsShift ) ;
393  m_EEResponse->setPhaseShift( 1. + cosmicsShift ) ;
394  }
395 
396  EcalCorrMatrix ebMatrix[ 3 ] ;
397  EcalCorrMatrix eeMatrix[ 3 ] ;
398 
399  assert( ebCorMatG12.size() == m_readoutFrameSize ) ;
400  assert( eeCorMatG12.size() == m_readoutFrameSize ) ;
401  assert( ebCorMatG06.size() == m_readoutFrameSize ) ;
402  assert( eeCorMatG06.size() == m_readoutFrameSize ) ;
403  assert( ebCorMatG01.size() == m_readoutFrameSize ) ;
404  assert( eeCorMatG01.size() == m_readoutFrameSize ) ;
405 
406  assert( 1.e-7 > fabs( ebCorMatG12[0] - 1.0 ) ) ;
407  assert( 1.e-7 > fabs( ebCorMatG06[0] - 1.0 ) ) ;
408  assert( 1.e-7 > fabs( ebCorMatG01[0] - 1.0 ) ) ;
409  assert( 1.e-7 > fabs( eeCorMatG12[0] - 1.0 ) ) ;
410  assert( 1.e-7 > fabs( eeCorMatG06[0] - 1.0 ) ) ;
411  assert( 1.e-7 > fabs( eeCorMatG01[0] - 1.0 ) ) ;
412 
413  for ( unsigned int row ( 0 ) ; row != m_readoutFrameSize ; ++row )
414  {
415  assert( 0 == row || 1. >= ebCorMatG12[row] ) ;
416  assert( 0 == row || 1. >= ebCorMatG06[row] ) ;
417  assert( 0 == row || 1. >= ebCorMatG01[row] ) ;
418  assert( 0 == row || 1. >= eeCorMatG12[row] ) ;
419  assert( 0 == row || 1. >= eeCorMatG06[row] ) ;
420  assert( 0 == row || 1. >= eeCorMatG01[row] ) ;
421  for ( unsigned int column ( 0 ) ; column <= row ; ++column )
422  {
423  const unsigned int index ( row - column ) ;
424  ebMatrix[0]( row, column ) = ebCorMatG12[ index ] ;
425  eeMatrix[0]( row, column ) = eeCorMatG12[ index ] ;
426  ebMatrix[1]( row, column ) = ebCorMatG06[ index ] ;
427  eeMatrix[1]( row, column ) = eeCorMatG06[ index ] ;
428  ebMatrix[2]( row, column ) = ebCorMatG01[ index ] ;
429  eeMatrix[2]( row, column ) = eeCorMatG01[ index ] ;
430  }
431  }
432 
433  m_EBCorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[0] ) ;
434  m_EECorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[0] ) ;
435  m_EBCorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[1] ) ;
436  m_EECorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[1] ) ;
437  m_EBCorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[2] ) ;
438  m_EECorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[2] ) ;
439 
440  m_Coder = new EcalCoder( addNoise ,
441  m_PreMix1 ,
442  m_EBCorrNoise[0] ,
443  m_EECorrNoise[0] ,
444  m_EBCorrNoise[1] ,
445  m_EECorrNoise[1] ,
446  m_EBCorrNoise[2] ,
447  m_EECorrNoise[2] ) ;
448 
450  m_Coder ,
451  applyConstantTerm ,
452  rmsConstantTerm ) ;
453 
454  if( m_apdSeparateDigi )
455  {
456  m_APDCoder = new EcalCoder( false ,
457  m_EBCorrNoise[0] ,
458  m_EECorrNoise[0] ,
459  m_EBCorrNoise[1] ,
460  m_EECorrNoise[1] ,
461  m_EBCorrNoise[2] ,
462  m_EECorrNoise[2] ) ;
463 
465  m_APDCoder ,
466  applyConstantTerm ,
467  rmsConstantTerm ) ;
468 
471  false ) ;
472  }
473 
476  addNoise ) ;
477 
480  addNoise ) ;
481 }
482 
483 
485 {
486  delete m_EndcapDigitizer ;
487  delete m_BarrelDigitizer ;
488  delete m_APDDigitizer ;
489  delete m_APDElectronicsSim ;
490  delete m_APDCoder ;
491  delete m_ElectronicsSim ;
492  delete m_Coder ;
493  delete m_EBCorrNoise[0] ;
494  delete m_EECorrNoise[0] ;
495  delete m_EBCorrNoise[1] ;
496  delete m_EECorrNoise[1] ;
497  delete m_EBCorrNoise[2] ;
498  delete m_EECorrNoise[2] ;
499 
500  delete m_ESDigitizer ;
501  delete m_ESElectronicsSimFast ;
502  delete m_ESOldDigitizer ;
503  delete m_ESElectronicsSim ;
504 
505  delete m_ESOldResponse ;
506  delete m_ESResponse ;
507  delete m_EEResponse ;
508  delete m_EBResponse ;
509  delete m_APDResponse ;
510 
511  delete m_apdParameters ;
512  delete m_ParameterMap ;
513 }
514 
515 void
517  checkGeometry( eventSetup );
518  checkCalibrations( event, eventSetup );
520  if(m_apdSeparateDigi) {
522  }
524  if(m_doFastES) {
526  } else {
528  }
529 }
530 
531 void
532 EcalDigiProducer::accumulateCaloHits(HitsHandle const& ebHandle, HitsHandle const& eeHandle, HitsHandle const& esHandle, int bunchCrossing, CLHEP::HepRandomEngine* engine) {
533  if(ebHandle.isValid()) {
534  m_BarrelDigitizer->add(*ebHandle.product(), bunchCrossing, engine);
535 
536  if(m_apdSeparateDigi) {
537  m_APDDigitizer->add(*ebHandle.product(), bunchCrossing, engine);
538  }
539  }
540 
541  if(eeHandle.isValid()) {
542  m_EndcapDigitizer->add(*eeHandle.product(), bunchCrossing, engine);
543  }
544 
545  if(esHandle.isValid()) {
546  if(m_doFastES) {
547  m_ESDigitizer->add(*esHandle.product(), bunchCrossing, engine);
548  } else {
549  m_ESOldDigitizer->add(*esHandle.product(), bunchCrossing, engine);
550  }
551  }
552 }
553 
554 void
556  // Step A: Get Inputs
557  edm::InputTag ebTag(m_hitsProducerTag, "EcalHitsEB");
559  e.getByLabel(ebTag, ebHandle);
560 
561  edm::InputTag eeTag(m_hitsProducerTag, "EcalHitsEE");
563  e.getByLabel(eeTag, eeHandle);
564 
565  edm::InputTag esTag(m_hitsProducerTag, "EcalHitsES");
567  e.getByLabel(esTag, esHandle);
568 
569  accumulateCaloHits(ebHandle, eeHandle, esHandle, 0, randomEngine(e.streamID()));
570 }
571 
572 void
574  // Step A: Get Inputs
575  edm::InputTag ebTag(m_hitsProducerTag, "EcalHitsEB");
577  e.getByLabel(ebTag, ebHandle);
578 
579  edm::InputTag eeTag(m_hitsProducerTag, "EcalHitsEE");
581  e.getByLabel(eeTag, eeHandle);
582 
583  edm::InputTag esTag(m_hitsProducerTag, "EcalHitsES");
585  e.getByLabel(esTag, esHandle);
586 
587  accumulateCaloHits(ebHandle, eeHandle, esHandle, e.bunchCrossing(), randomEngine(streamID));
588 }
589 
590 void
592  // Step B: Create empty output
593  std::auto_ptr<EBDigiCollection> apdResult ( !m_apdSeparateDigi ? 0 :
594  new EBDigiCollection() ) ;
595  std::auto_ptr<EBDigiCollection> barrelResult ( new EBDigiCollection() ) ;
596  std::auto_ptr<EEDigiCollection> endcapResult ( new EEDigiCollection() ) ;
597  std::auto_ptr<ESDigiCollection> preshowerResult( new ESDigiCollection() ) ;
598 
599  // run the algorithm
600 
601  m_BarrelDigitizer->run( *barrelResult, randomEngine(event.streamID()) ) ;
602  cacheEBDigis( &*barrelResult ) ;
603 
604  edm::LogInfo("DigiInfo") << "EB Digis: " << barrelResult->size() ;
605 
606  if( m_apdSeparateDigi ) {
607  m_APDDigitizer->run( *apdResult, randomEngine(event.streamID()) ) ;
608  edm::LogInfo("DigiInfo") << "APD Digis: " << apdResult->size() ;
609  }
610 
611  m_EndcapDigitizer->run( *endcapResult, randomEngine(event.streamID()) ) ;
612  edm::LogInfo("EcalDigi") << "EE Digis: " << endcapResult->size() ;
613  cacheEEDigis( &*endcapResult ) ;
614 
615  if(m_doFastES) {
616  m_ESDigitizer->run( *preshowerResult, randomEngine(event.streamID()) ) ;
617  } else {
618  m_ESOldDigitizer->run( *preshowerResult, randomEngine(event.streamID()) ) ;
619  }
620  edm::LogInfo("EcalDigi") << "ES Digis: " << preshowerResult->size();
621 
622 
623  // Step D: Put outputs into event
624  if( m_apdSeparateDigi ) {
625  //event.put( apdResult, m_apdDigiTag ) ;
626  }
627 
628  event.put( barrelResult, m_EBdigiCollection ) ;
629  event.put( endcapResult, m_EEdigiCollection ) ;
630  event.put( preshowerResult, m_ESdigiCollection ) ;
631 }
632 
633 void
635 {
637  if ( ! rng.isAvailable() ) {
638  throw cms::Exception("Configuration") <<
639  "RandomNumberGenerator service is not available.\n"
640  "You must add the service in the configuration file\n"
641  "or remove the module that requires it.";
642  }
643  CLHEP::HepRandomEngine* engine = &rng->getEngine(lumi.index());
644 
645  if( 0 != m_APDResponse ) m_APDResponse->initialize(engine);
646  m_EBResponse->initialize(engine);
647 }
648 
649 void
651 {
652  // Pedestals from event setup
653 
655  eventSetup.get<EcalPedestalsRcd>().get( dbPed ) ;
656  const EcalPedestals* pedestals ( dbPed.product() ) ;
657 
658  m_Coder->setPedestals( pedestals ) ;
659  if( 0 != m_APDCoder ) m_APDCoder->setPedestals( pedestals ) ;
660 
661  // Ecal Intercalibration Constants
663  eventSetup.get<EcalIntercalibConstantsMCRcd>().get( pIcal ) ;
664  const EcalIntercalibConstantsMC* ical ( pIcal.product() ) ;
665 
667  if( 0 != m_APDCoder) m_APDCoder->setIntercalibConstants( ical ) ;
668 
669  m_EBResponse->setIntercal( ical ) ;
670  if( 0 != m_APDResponse ) m_APDResponse->setIntercal( ical ) ;
671 
672  // Ecal LaserCorrection Constants
674  eventSetup.get<EcalLaserDbRecord>().get(laser);
675  const edm::TimeValue_t eventTimeValue = event.time().value();
676 
677  m_EBResponse->setEventTime(eventTimeValue);
679 
680  m_EEResponse->setEventTime(eventTimeValue);
682 
683  // ADC -> GeV Scale
685  eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
686  const EcalADCToGeVConstant* agc = pAgc.product();
687 
688  // Gain Ratios
690  eventSetup.get<EcalGainRatiosRcd>().get(pRatio);
691  const EcalGainRatios* gr = pRatio.product();
692 
693  m_Coder->setGainRatios( gr );
694  if( 0 != m_APDCoder) m_APDCoder->setGainRatios( gr );
695 
696  EcalMGPAGainRatio * defaultRatios = new EcalMGPAGainRatio();
697 
698  double theGains[m_Coder->NGAINS+1];
699  theGains[0] = 0.;
700  theGains[3] = 1.;
701  theGains[2] = defaultRatios->gain6Over1() ;
702  theGains[1] = theGains[2]*(defaultRatios->gain12Over6()) ;
703 
704  LogDebug("EcalDigi") << " Gains: " << "\n" << " g1 = " << theGains[1]
705  << "\n" << " g2 = " << theGains[2]
706  << "\n" << " g3 = " << theGains[3] ;
707 
708  delete defaultRatios;
709 
710  const double EBscale (
711  ( agc->getEBValue())*theGains[1]*(m_Coder->MAXADC)*m_EBs25notCont ) ;
712 
713  LogDebug("EcalDigi") << " GeV/ADC = " << agc->getEBValue()
714  << "\n" << " notCont = " << m_EBs25notCont
715  << "\n" << " saturation for EB = " << EBscale
716  << ", " << m_EBs25notCont ;
717 
718  const double EEscale (
719  (agc->getEEValue())*theGains[1]*(m_Coder->MAXADC)*m_EEs25notCont ) ;
720 
721  LogDebug("EcalDigi") << " GeV/ADC = " << agc->getEEValue()
722  << "\n" << " notCont = " << m_EEs25notCont
723  << "\n" << " saturation for EB = " << EEscale
724  << ", " << m_EEs25notCont ;
725 
726  m_Coder->setFullScaleEnergy( EBscale ,
727  EEscale ) ;
728  if( 0 != m_APDCoder ) m_APDCoder->setFullScaleEnergy( EBscale ,
729  EEscale ) ;
730 
731  if( 0 != m_ESOldDigitizer ||
732  0 != m_ESDigitizer )
733  {
734  // ES condition objects
735  edm::ESHandle<ESGain> hesgain ;
737  edm::ESHandle<ESPedestals> hesPedestals ;
739 
740  eventSetup.get<ESGainRcd>(). get( hesgain ) ;
741  eventSetup.get<ESMIPToGeVConstantRcd>(). get( hesMIPToGeV ) ;
742  eventSetup.get<ESPedestalsRcd>(). get( hesPedestals ) ;
743  eventSetup.get<ESIntercalibConstantsRcd>().get( hesMIPs ) ;
744 
745  const ESGain* esgain ( hesgain.product() ) ;
746  const ESPedestals* espeds ( hesPedestals.product() ) ;
747  const ESIntercalibConstants* esmips ( hesMIPs.product() ) ;
748  const ESMIPToGeVConstant* esMipToGeV ( hesMIPToGeV.product() ) ;
749  const int ESGain ( 1.1 > esgain->getESGain() ? 1 : 2 ) ;
750  const double ESMIPToGeV ( ( 1 == ESGain ) ?
751  esMipToGeV->getESValueLow() :
752  esMipToGeV->getESValueHigh() ) ;
753 
755 
756  if( !m_doFastES )
757  {
759  m_ESElectronicsSim->setPedestals( espeds ) ;
760  m_ESElectronicsSim->setMIPs( esmips ) ;
761  m_ESElectronicsSim->setMIPToGeV( ESMIPToGeV ) ;
762  }
763  else
764  {
767  m_ESElectronicsSimFast->setMIPs( esmips ) ;
768  m_ESElectronicsSimFast->setMIPToGeV( ESMIPToGeV ) ;
769  }
770  }
771 }
772 
773 void
775 {
776  // TODO find a way to avoid doing this every event
777  edm::ESHandle<CaloGeometry> hGeometry ;
778  eventSetup.get<CaloGeometryRecord>().get( hGeometry ) ;
779 
780  const CaloGeometry* pGeometry = &*hGeometry;
781 
782  if( pGeometry != m_Geometry )
783  {
784  m_Geometry = pGeometry;
785  updateGeometry();
786  }
787 }
788 
789 void
791 {
801 
802  const std::vector<DetId>* theESDets (
805 
806  if( !m_doFastES )
807  {
808  if( 0 != m_ESOldDigitizer &&
809  0 != theESDets )
810  m_ESOldDigitizer->setDetIds( *theESDets ) ;
811  }
812  else
813  {
814  if( 0 != m_ESDigitizer &&
815  0 != theESDets )
816  m_ESDigitizer->setDetIds( *theESDets ) ;
817  }
818 }
819 
820 
821 CLHEP::HepRandomEngine* EcalDigiProducer::randomEngine(edm::StreamID const& streamID) {
822  unsigned int index = streamID.value();
823  if(index >= randomEngines_.size()) {
824  randomEngines_.resize(index + 1, nullptr);
825  }
826  CLHEP::HepRandomEngine* ptr = randomEngines_[index];
827  if(!ptr) {
829  ptr = &rng->getEngine(streamID);
830  randomEngines_[index] = ptr;
831  }
832  return ptr;
833 }
834 
836  //noiseGenerator->setParameterMap(theParameterMap);
838 }
839 
841  //noiseGenerator->setParameterMap(theParameterMap);
843 }
844 
846  //noiseGenerator->setParameterMap(theParameterMap);
848 }
849 
850 
#define LogDebug(id)
EEDigitizer * m_EndcapDigitizer
virtual void accumulate(edm::Event const &e, edm::EventSetup const &c)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *)
void setMIPToGeV(double MIPToGeV)
CaloHitResponse * m_ESOldResponse
void setGain(const int gain)
virtual ~EcalDigiProducer()
EcalTDigitizer< EEDigitizerTraits > EEDigitizer
CorrelatedNoisifier< EcalCorrMatrix > * m_EBCorrNoise[3]
void initializeHits()
LuminosityBlockIndex index() const
const std::string m_ESdigiCollection
const EcalSimParameterMap * m_ParameterMap
Definition: ESGain.h:7
void setGain(const int gain)
Definition: ESShape.h:26
void setDetIds(const std::vector< DetId > &detIds)
tell the digitizer which cells exist; cannot change during a run
Definition: ESDigitizer.cc:36
void setEventTime(const edm::TimeValue_t &iTime)
tuple lumi
Definition: fjr2json.py:35
const std::string m_hitsProducerTag
void setMIPs(const ESIntercalibConstants *mips)
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
void setMIPToGeV(const double MIPToGeV)
void setIntercalibConstants(const EcalIntercalibConstantsMC *ical)
Definition: EcalCoder.cc:63
virtual void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
ESOldDigitizer * m_ESOldDigitizer
void setNoiseSignalGenerator(EcalBaseSignalGenerator *noiseSignalGenerator)
EcalDigiProducer(const edm::ParameterSet &params, edm::one::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
const std::string m_EEdigiCollection
ESElectronicsSimFast * m_ESElectronicsSimFast
virtual void initializeHits()
ESDigitizer * m_ESDigitizer
const APDSimParameters * m_apdParameters
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
void setEENoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator)
void setPedestals(const ESPedestals *peds)
void setPedestals(const ESPedestals *peds)
CorrelatedNoisifier< EcalCorrMatrix > * m_EECorrNoise[3]
const unsigned int m_readoutFrameSize
void setLaserConstants(const EcalLaserDbService *laser, bool &useLCcorrection)
EcalElectronicsSim * m_ElectronicsSim
void setEBNoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator)
void setESNoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator)
void setIntercal(const EcalIntercalibConstantsMC *ical)
EBHitResponse * m_APDResponse
Creates electronics signals from hits.
const double m_EBs25notCont
void setPedestals(const EcalPedestals *pedestals)
can be fetched every event from the EventSetup
Definition: EcalCoder.cc:51
EBHitResponse * m_EBResponse
void setPhaseShift(double phaseShift)
bool isAvailable() const
Definition: Service.h:46
void setGain(const int gain)
Definition: ESDigitizer.cc:44
ESElectronicsSim * m_ESElectronicsSim
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override
EBDigitizer * m_BarrelDigitizer
float gain6Over1() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
math::ErrorD< CaloSamples::MAXSAMPLES >::type EcalCorrMatrix
bool isValid() const
Definition: HandleBase.h:76
unsigned long long TimeValue_t
Definition: Timestamp.h:28
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
const CaloGeometry * m_Geometry
void checkCalibrations(const edm::Event &event, const edm::EventSetup &eventSetup)
EcalCoder * m_APDCoder
void checkGeometry(const edm::EventSetup &eventSetup)
ESHitResponse * m_ESResponse
void setGeometry(const CaloSubdetectorGeometry *geometry)
void setGainRatios(const EcalGainRatios *gainRatios)
Definition: EcalCoder.cc:57
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
unsigned int value() const
Definition: StreamID.h:46
#define column(...)
Definition: DbCore.h:74
virtual void cacheEBDigis(const EBDigiCollection *ebDigiPtr) const
void setFullScaleEnergy(double EBscale, double EEscale)
Definition: EcalCoder.cc:42
EcalTDigitizer< EBDigitizerTraits > EBDigitizer
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
float gain12Over6() const
T const * product() const
Definition: Handle.h:81
EBDigitizer * m_APDDigitizer
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
const bool m_apdSeparateDigi
virtual void finalizeEvent(edm::Event &e, edm::EventSetup const &c)
CLHEP::HepRandomEngine * randomEngine(edm::StreamID const &streamID)
virtual void run(DigiCollection &output, CLHEP::HepRandomEngine *)
void accumulateCaloHits(HitsHandle const &ebHandle, HitsHandle const &eeHandle, HitsHandle const &esHandle, int bunchCrossing, CLHEP::HepRandomEngine *)
void initialize(CLHEP::HepRandomEngine *)
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
StreamID streamID() const
Definition: Event.h:75
const std::string m_apdDigiTag
void setDetIds(const std::vector< DetId > &detIds)
std::vector< CLHEP::HepRandomEngine * > randomEngines_
virtual void run(ESDigiCollection &output, CLHEP::HepRandomEngine *) override
turns hits into digis
Definition: ESDigitizer.cc:167
volatile std::atomic< bool > shutdown_flag false
void setMIPs(const ESIntercalibConstants *mips)
virtual void cacheEEDigis(const EEDigiCollection *eeDigiPtr) const
const std::string m_EBdigiCollection
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
EcalElectronicsSim * m_APDElectronicsSim
const double m_EEs25notCont
EEHitResponse * m_EEResponse