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"
40 
50 
51 
54  m_APDShape ( params.getParameter<double>( "apdShapeTstart" ) ,
55  params.getParameter<double>( "apdShapeTau" ) ) ,
56  m_EBShape ( ) ,
57  m_EEShape ( ) ,
58  m_ESShape ( ) ,
59  m_EBdigiCollection ( params.getParameter<std::string>("EBdigiCollection") ) ,
60  m_EEdigiCollection ( params.getParameter<std::string>("EEdigiCollection") ) ,
61  m_ESdigiCollection ( params.getParameter<std::string>("ESdigiCollection") ) ,
62  m_hitsProducerTag ( params.getParameter<std::string>("hitsProducer" ) ) ,
63  m_useLCcorrection ( params.getUntrackedParameter<bool>("UseLCcorrection") ) ,
64  m_apdSeparateDigi ( params.getParameter<bool> ("apdSeparateDigi") ) ,
65 
66  m_EBs25notCont ( params.getParameter<double> ("EBs25notContainment") ) ,
67  m_EEs25notCont ( params.getParameter<double> ("EEs25notContainment") ) ,
68 
69  m_readoutFrameSize ( params.getParameter<int> ("readoutFrameSize") ) ,
70  m_ParameterMap ( new EcalSimParameterMap(
71  params.getParameter<double> ("simHitToPhotoelectronsBarrel") ,
72  params.getParameter<double> ("simHitToPhotoelectronsEndcap") ,
73  params.getParameter<double> ("photoelectronsToAnalogBarrel") ,
74  params.getParameter<double> ("photoelectronsToAnalogEndcap") ,
75  params.getParameter<double> ("samplingFactor") ,
76  params.getParameter<double> ("timePhase") ,
77  m_readoutFrameSize ,
78  params.getParameter<int> ("binOfMaximum") ,
79  params.getParameter<bool> ("doPhotostatistics") ,
80  params.getParameter<bool> ("syncPhase") ) ) ,
81 
82  m_apdDigiTag ( params.getParameter<std::string> ("apdDigiTag" ) ) ,
83  m_apdParameters ( new APDSimParameters(
84  params.getParameter<bool> ("apdAddToBarrel" ) ,
85  m_apdSeparateDigi ,
86  params.getParameter<double> ("apdSimToPELow" ) ,
87  params.getParameter<double> ("apdSimToPEHigh" ) ,
88  params.getParameter<double> ("apdTimeOffset" ) ,
89  params.getParameter<double> ("apdTimeOffWidth" ) ,
90  params.getParameter<bool> ("apdDoPEStats" ) ,
91  m_apdDigiTag ,
92  params.getParameter<std::vector<double> > ( "apdNonlParms" ) ) ) ,
93 
94  m_APDResponse ( !m_apdSeparateDigi ? 0 :
95  new EBHitResponse( m_ParameterMap ,
96  &m_EBShape ,
97  true ,
98  m_apdParameters ,
99  &m_APDShape ) ) ,
100 
101  m_EBResponse ( new EBHitResponse( m_ParameterMap ,
102  &m_EBShape ,
103  false , // barrel
104  m_apdParameters ,
105  &m_APDShape ) ) ,
106 
107  m_EEResponse ( new EEHitResponse( m_ParameterMap,
108  &m_EEShape ) ) ,
109  m_ESResponse ( new ESHitResponse( m_ParameterMap, &m_ESShape ) ) ,
110  m_ESOldResponse ( new CaloHitResponse( m_ParameterMap, &m_ESShape ) ) ,
111 
112  m_addESNoise ( params.getParameter<bool> ("doESNoise") ) ,
113  m_PreMix1 ( params.getParameter<bool> ("EcalPreMixStage1") ) ,
114  m_PreMix2 ( params.getParameter<bool> ("EcalPreMixStage2") ) ,
115 
116  m_doFastES ( params.getParameter<bool> ("doFast" ) ) ,
117 
118  m_ESElectronicsSim ( m_doFastES ? 0 :
119  new ESElectronicsSim( m_addESNoise ) ) ,
120 
121  m_ESOldDigitizer ( m_doFastES ? 0 :
122  new ESOldDigitizer( m_ESOldResponse ,
123  m_ESElectronicsSim ,
124  m_addESNoise ) ) ,
125 
126  m_ESElectronicsSimFast ( !m_doFastES ? 0 :
127  new ESElectronicsSimFast( m_addESNoise ,
128  m_PreMix1) ) ,
129 
130  m_ESDigitizer ( !m_doFastES ? 0 :
131  new ESDigitizer( m_ESResponse ,
132  m_ESElectronicsSimFast ,
133  m_addESNoise ) ) ,
134 
135  m_APDDigitizer ( 0 ) ,
136  m_BarrelDigitizer ( 0 ) ,
137  m_EndcapDigitizer ( 0 ) ,
138  m_ElectronicsSim ( 0 ) ,
139  m_Coder ( 0 ) ,
140  m_APDElectronicsSim ( 0 ) ,
141  m_APDCoder ( 0 ) ,
142  m_Geometry ( 0 ) ,
143  m_EBCorrNoise ( ) ,
144  m_EECorrNoise ( )
145 {
146  if(m_apdSeparateDigi) mixMod.produces<EBDigiCollection>(m_apdDigiTag);
147  mixMod.produces<EBDigiCollection>(m_EBdigiCollection);
148  mixMod.produces<EEDigiCollection>(m_EEdigiCollection);
149  mixMod.produces<ESDigiCollection>(m_ESdigiCollection);
150  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsEB"));
151  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsEE"));
152  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsES"));
153 
154  const std::vector<double> ebCorMatG12 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG12");
155  const std::vector<double> eeCorMatG12 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG12");
156  const std::vector<double> ebCorMatG06 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG06");
157  const std::vector<double> eeCorMatG06 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG06");
158  const std::vector<double> ebCorMatG01 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG01");
159  const std::vector<double> eeCorMatG01 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG01");
160 
161  const bool applyConstantTerm = params.getParameter<bool> ("applyConstantTerm");
162  const double rmsConstantTerm = params.getParameter<double> ("ConstantTerm");
163 
164  const bool addNoise = params.getParameter<bool> ("doENoise");
165  const bool cosmicsPhase = params.getParameter<bool> ("cosmicsPhase");
166  const double cosmicsShift = params.getParameter<double> ("cosmicsShift");
167 
168 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
169 
170  // further phase for cosmics studies
171  if( cosmicsPhase )
172  {
173  m_EBResponse->setPhaseShift( 1. + cosmicsShift ) ;
174  m_EEResponse->setPhaseShift( 1. + cosmicsShift ) ;
175  }
176 
177  EcalCorrMatrix ebMatrix[ 3 ] ;
178  EcalCorrMatrix eeMatrix[ 3 ] ;
179 
180  assert( ebCorMatG12.size() == m_readoutFrameSize ) ;
181  assert( eeCorMatG12.size() == m_readoutFrameSize ) ;
182  assert( ebCorMatG06.size() == m_readoutFrameSize ) ;
183  assert( eeCorMatG06.size() == m_readoutFrameSize ) ;
184  assert( ebCorMatG01.size() == m_readoutFrameSize ) ;
185  assert( eeCorMatG01.size() == m_readoutFrameSize ) ;
186 
187  assert( 1.e-7 > fabs( ebCorMatG12[0] - 1.0 ) ) ;
188  assert( 1.e-7 > fabs( ebCorMatG06[0] - 1.0 ) ) ;
189  assert( 1.e-7 > fabs( ebCorMatG01[0] - 1.0 ) ) ;
190  assert( 1.e-7 > fabs( eeCorMatG12[0] - 1.0 ) ) ;
191  assert( 1.e-7 > fabs( eeCorMatG06[0] - 1.0 ) ) ;
192  assert( 1.e-7 > fabs( eeCorMatG01[0] - 1.0 ) ) ;
193 
194  for ( unsigned int row ( 0 ) ; row != m_readoutFrameSize ; ++row )
195  {
196  assert( 0 == row || 1. >= ebCorMatG12[row] ) ;
197  assert( 0 == row || 1. >= ebCorMatG06[row] ) ;
198  assert( 0 == row || 1. >= ebCorMatG01[row] ) ;
199  assert( 0 == row || 1. >= eeCorMatG12[row] ) ;
200  assert( 0 == row || 1. >= eeCorMatG06[row] ) ;
201  assert( 0 == row || 1. >= eeCorMatG01[row] ) ;
202  for ( unsigned int column ( 0 ) ; column <= row ; ++column )
203  {
204  const unsigned int index ( row - column ) ;
205  ebMatrix[0]( row, column ) = ebCorMatG12[ index ] ;
206  eeMatrix[0]( row, column ) = eeCorMatG12[ index ] ;
207  ebMatrix[1]( row, column ) = ebCorMatG06[ index ] ;
208  eeMatrix[1]( row, column ) = eeCorMatG06[ index ] ;
209  ebMatrix[2]( row, column ) = ebCorMatG01[ index ] ;
210  eeMatrix[2]( row, column ) = eeCorMatG01[ index ] ;
211  }
212  }
213 
214  m_EBCorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[0] ) ;
215  m_EECorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[0] ) ;
216  m_EBCorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[1] ) ;
217  m_EECorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[1] ) ;
218  m_EBCorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[2] ) ;
219  m_EECorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[2] ) ;
220 
221  m_Coder = new EcalCoder( addNoise ,
222  m_PreMix1 ,
223  m_EBCorrNoise[0] ,
224  m_EECorrNoise[0] ,
225  m_EBCorrNoise[1] ,
226  m_EECorrNoise[1] ,
227  m_EBCorrNoise[2] ,
228  m_EECorrNoise[2] ) ;
229 
231  m_Coder ,
232  applyConstantTerm ,
233  rmsConstantTerm ) ;
234 
235  if( m_apdSeparateDigi )
236  {
237  m_APDCoder = new EcalCoder( false ,
238  m_EBCorrNoise[0] ,
239  m_EECorrNoise[0] ,
240  m_EBCorrNoise[1] ,
241  m_EECorrNoise[1] ,
242  m_EBCorrNoise[2] ,
243  m_EECorrNoise[2] ) ;
244 
246  m_APDCoder ,
247  applyConstantTerm ,
248  rmsConstantTerm ) ;
249 
252  false ) ;
253  }
254 
257  addNoise ) ;
258 
261  addNoise ) ;
262 }
263 
264 // duplicate version for Pre-Mixing, for use outside of MixingModule
267  m_APDShape ( params.getParameter<double>( "apdShapeTstart" ) ,
268  params.getParameter<double>( "apdShapeTau" ) ) ,
269  m_EBShape ( ) ,
270  m_EEShape ( ) ,
271  m_ESShape ( ) ,
272  m_EBdigiCollection ( params.getParameter<std::string>("EBdigiCollection") ) ,
273  m_EEdigiCollection ( params.getParameter<std::string>("EEdigiCollection") ) ,
274  m_ESdigiCollection ( params.getParameter<std::string>("ESdigiCollection") ) ,
275  m_hitsProducerTag ( params.getParameter<std::string>("hitsProducer" ) ) ,
276  m_useLCcorrection ( params.getUntrackedParameter<bool>("UseLCcorrection") ) ,
277  m_apdSeparateDigi ( params.getParameter<bool> ("apdSeparateDigi") ) ,
278 
279  m_EBs25notCont ( params.getParameter<double> ("EBs25notContainment") ) ,
280  m_EEs25notCont ( params.getParameter<double> ("EEs25notContainment") ) ,
281 
282  m_readoutFrameSize ( params.getParameter<int> ("readoutFrameSize") ) ,
283  m_ParameterMap ( new EcalSimParameterMap(
284  params.getParameter<double> ("simHitToPhotoelectronsBarrel") ,
285  params.getParameter<double> ("simHitToPhotoelectronsEndcap") ,
286  params.getParameter<double> ("photoelectronsToAnalogBarrel") ,
287  params.getParameter<double> ("photoelectronsToAnalogEndcap") ,
288  params.getParameter<double> ("samplingFactor") ,
289  params.getParameter<double> ("timePhase") ,
290  m_readoutFrameSize ,
291  params.getParameter<int> ("binOfMaximum") ,
292  params.getParameter<bool> ("doPhotostatistics") ,
293  params.getParameter<bool> ("syncPhase") ) ) ,
294 
295  m_apdDigiTag ( params.getParameter<std::string> ("apdDigiTag" ) ) ,
296  m_apdParameters ( new APDSimParameters(
297  params.getParameter<bool> ("apdAddToBarrel" ) ,
298  m_apdSeparateDigi ,
299  params.getParameter<double> ("apdSimToPELow" ) ,
300  params.getParameter<double> ("apdSimToPEHigh" ) ,
301  params.getParameter<double> ("apdTimeOffset" ) ,
302  params.getParameter<double> ("apdTimeOffWidth" ) ,
303  params.getParameter<bool> ("apdDoPEStats" ) ,
304  m_apdDigiTag ,
305  params.getParameter<std::vector<double> > ( "apdNonlParms" ) ) ) ,
306 
307  m_APDResponse ( !m_apdSeparateDigi ? 0 :
308  new EBHitResponse( m_ParameterMap ,
309  &m_EBShape ,
310  true ,
311  m_apdParameters ,
312  &m_APDShape ) ) ,
313 
314  m_EBResponse ( new EBHitResponse( m_ParameterMap ,
315  &m_EBShape ,
316  false , // barrel
317  m_apdParameters ,
318  &m_APDShape ) ) ,
319 
320  m_EEResponse ( new EEHitResponse( m_ParameterMap,
321  &m_EEShape ) ) ,
322  m_ESResponse ( new ESHitResponse( m_ParameterMap, &m_ESShape ) ) ,
323  m_ESOldResponse ( new CaloHitResponse( m_ParameterMap, &m_ESShape ) ) ,
324 
325  m_addESNoise ( params.getParameter<bool> ("doESNoise") ) ,
326  m_PreMix1 ( params.getParameter<bool> ("EcalPreMixStage1") ) ,
327  m_PreMix2 ( params.getParameter<bool> ("EcalPreMixStage2") ) ,
328 
329  m_doFastES ( params.getParameter<bool> ("doFast" ) ) ,
330 
331  m_ESElectronicsSim ( m_doFastES ? 0 :
332  new ESElectronicsSim( m_addESNoise ) ) ,
333 
334  m_ESOldDigitizer ( m_doFastES ? 0 :
335  new ESOldDigitizer( m_ESOldResponse ,
336  m_ESElectronicsSim ,
337  m_addESNoise ) ) ,
338 
339  m_ESElectronicsSimFast ( !m_doFastES ? 0 :
340  new ESElectronicsSimFast( m_addESNoise,
341  m_PreMix1 ) ) ,
342 
343  m_ESDigitizer ( !m_doFastES ? 0 :
344  new ESDigitizer( m_ESResponse ,
345  m_ESElectronicsSimFast ,
346  m_addESNoise ) ) ,
347 
348  m_APDDigitizer ( 0 ) ,
349  m_BarrelDigitizer ( 0 ) ,
350  m_EndcapDigitizer ( 0 ) ,
351  m_ElectronicsSim ( 0 ) ,
352  m_Coder ( 0 ) ,
353  m_APDElectronicsSim ( 0 ) ,
354  m_APDCoder ( 0 ) ,
355  m_Geometry ( 0 ) ,
356  m_EBCorrNoise ( ) ,
357  m_EECorrNoise ( )
358 {
359  // "produces" statements taken care of elsewhere.
360  // if(m_apdSeparateDigi) mixMod.produces<EBDigiCollection>(m_apdDigiTag);
361  // mixMod.produces<EBDigiCollection>(m_EBdigiCollection);
362  // mixMod.produces<EEDigiCollection>(m_EEdigiCollection);
363  // mixMod.produces<ESDigiCollection>(m_ESdigiCollection);
364  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsEB"));
365  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsEE"));
366  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(m_hitsProducerTag, "EcalHitsES"));
367 
368  const std::vector<double> ebCorMatG12 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG12");
369  const std::vector<double> eeCorMatG12 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG12");
370  const std::vector<double> ebCorMatG06 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG06");
371  const std::vector<double> eeCorMatG06 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG06");
372  const std::vector<double> ebCorMatG01 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG01");
373  const std::vector<double> eeCorMatG01 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG01");
374 
375  const bool applyConstantTerm = params.getParameter<bool> ("applyConstantTerm");
376  const double rmsConstantTerm = params.getParameter<double> ("ConstantTerm");
377 
378  const bool addNoise = params.getParameter<bool> ("doNoise");
379  const bool cosmicsPhase = params.getParameter<bool> ("cosmicsPhase");
380  const double cosmicsShift = params.getParameter<double> ("cosmicsShift");
381 
382 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
383 
384  // further phase for cosmics studies
385  if( cosmicsPhase )
386  {
387  m_EBResponse->setPhaseShift( 1. + cosmicsShift ) ;
388  m_EEResponse->setPhaseShift( 1. + cosmicsShift ) ;
389  }
390 
391  EcalCorrMatrix ebMatrix[ 3 ] ;
392  EcalCorrMatrix eeMatrix[ 3 ] ;
393 
394  assert( ebCorMatG12.size() == m_readoutFrameSize ) ;
395  assert( eeCorMatG12.size() == m_readoutFrameSize ) ;
396  assert( ebCorMatG06.size() == m_readoutFrameSize ) ;
397  assert( eeCorMatG06.size() == m_readoutFrameSize ) ;
398  assert( ebCorMatG01.size() == m_readoutFrameSize ) ;
399  assert( eeCorMatG01.size() == m_readoutFrameSize ) ;
400 
401  assert( 1.e-7 > fabs( ebCorMatG12[0] - 1.0 ) ) ;
402  assert( 1.e-7 > fabs( ebCorMatG06[0] - 1.0 ) ) ;
403  assert( 1.e-7 > fabs( ebCorMatG01[0] - 1.0 ) ) ;
404  assert( 1.e-7 > fabs( eeCorMatG12[0] - 1.0 ) ) ;
405  assert( 1.e-7 > fabs( eeCorMatG06[0] - 1.0 ) ) ;
406  assert( 1.e-7 > fabs( eeCorMatG01[0] - 1.0 ) ) ;
407 
408  for ( unsigned int row ( 0 ) ; row != m_readoutFrameSize ; ++row )
409  {
410  assert( 0 == row || 1. >= ebCorMatG12[row] ) ;
411  assert( 0 == row || 1. >= ebCorMatG06[row] ) ;
412  assert( 0 == row || 1. >= ebCorMatG01[row] ) ;
413  assert( 0 == row || 1. >= eeCorMatG12[row] ) ;
414  assert( 0 == row || 1. >= eeCorMatG06[row] ) ;
415  assert( 0 == row || 1. >= eeCorMatG01[row] ) ;
416  for ( unsigned int column ( 0 ) ; column <= row ; ++column )
417  {
418  const unsigned int index ( row - column ) ;
419  ebMatrix[0]( row, column ) = ebCorMatG12[ index ] ;
420  eeMatrix[0]( row, column ) = eeCorMatG12[ index ] ;
421  ebMatrix[1]( row, column ) = ebCorMatG06[ index ] ;
422  eeMatrix[1]( row, column ) = eeCorMatG06[ index ] ;
423  ebMatrix[2]( row, column ) = ebCorMatG01[ index ] ;
424  eeMatrix[2]( row, column ) = eeCorMatG01[ index ] ;
425  }
426  }
427 
428  m_EBCorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[0] ) ;
429  m_EECorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[0] ) ;
430  m_EBCorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[1] ) ;
431  m_EECorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[1] ) ;
432  m_EBCorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[2] ) ;
433  m_EECorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[2] ) ;
434 
435  m_Coder = new EcalCoder( addNoise ,
436  m_PreMix1 ,
437  m_EBCorrNoise[0] ,
438  m_EECorrNoise[0] ,
439  m_EBCorrNoise[1] ,
440  m_EECorrNoise[1] ,
441  m_EBCorrNoise[2] ,
442  m_EECorrNoise[2] ) ;
443 
445  m_Coder ,
446  applyConstantTerm ,
447  rmsConstantTerm ) ;
448 
449  if( m_apdSeparateDigi )
450  {
451  m_APDCoder = new EcalCoder( false ,
452  m_EBCorrNoise[0] ,
453  m_EECorrNoise[0] ,
454  m_EBCorrNoise[1] ,
455  m_EECorrNoise[1] ,
456  m_EBCorrNoise[2] ,
457  m_EECorrNoise[2] ) ;
458 
460  m_APDCoder ,
461  applyConstantTerm ,
462  rmsConstantTerm ) ;
463 
466  false ) ;
467  }
468 
471  addNoise ) ;
472 
475  addNoise ) ;
476 }
477 
478 
480 {
481  delete m_EndcapDigitizer ;
482  delete m_BarrelDigitizer ;
483  delete m_APDDigitizer ;
484  delete m_APDElectronicsSim ;
485  delete m_APDCoder ;
486  delete m_ElectronicsSim ;
487  delete m_Coder ;
488  delete m_EBCorrNoise[0] ;
489  delete m_EECorrNoise[0] ;
490  delete m_EBCorrNoise[1] ;
491  delete m_EECorrNoise[1] ;
492  delete m_EBCorrNoise[2] ;
493  delete m_EECorrNoise[2] ;
494 
495  delete m_ESDigitizer ;
496  delete m_ESElectronicsSimFast ;
497  delete m_ESOldDigitizer ;
498  delete m_ESElectronicsSim ;
499 
500  delete m_ESOldResponse ;
501  delete m_ESResponse ;
502  delete m_EEResponse ;
503  delete m_EBResponse ;
504  delete m_APDResponse ;
505 
506  delete m_apdParameters ;
507  delete m_ParameterMap ;
508 }
509 
510 void
512  checkGeometry( eventSetup );
513  checkCalibrations( event, eventSetup );
515  if(m_apdSeparateDigi) {
517  }
519  if(m_doFastES) {
521  } else {
523  }
524 }
525 
526 void
527 EcalDigiProducer::accumulateCaloHits(HitsHandle const& ebHandle, HitsHandle const& eeHandle, HitsHandle const& esHandle, int bunchCrossing) {
528  if(ebHandle.isValid()) {
529  m_BarrelDigitizer->add(*ebHandle.product(), bunchCrossing);
530 
531  if(m_apdSeparateDigi) {
532  m_APDDigitizer->add(*ebHandle.product(), bunchCrossing);
533  }
534  }
535 
536  if(eeHandle.isValid()) {
537  m_EndcapDigitizer->add(*eeHandle.product(), bunchCrossing);
538  }
539 
540  if(esHandle.isValid()) {
541  if(m_doFastES) {
542  m_ESDigitizer->add(*esHandle.product(), bunchCrossing);
543  } else {
544  m_ESOldDigitizer->add(*esHandle.product(), bunchCrossing);
545  }
546  }
547 }
548 
549 void
551  // Step A: Get Inputs
552  edm::InputTag ebTag(m_hitsProducerTag, "EcalHitsEB");
554  e.getByLabel(ebTag, ebHandle);
555 
556  edm::InputTag eeTag(m_hitsProducerTag, "EcalHitsEE");
558  e.getByLabel(eeTag, eeHandle);
559 
560  edm::InputTag esTag(m_hitsProducerTag, "EcalHitsES");
562  e.getByLabel(esTag, esHandle);
563 
564  accumulateCaloHits(ebHandle, eeHandle, esHandle, 0);
565 }
566 
567 void
569  // Step A: Get Inputs
570  edm::InputTag ebTag(m_hitsProducerTag, "EcalHitsEB");
572  e.getByLabel(ebTag, ebHandle);
573 
574  edm::InputTag eeTag(m_hitsProducerTag, "EcalHitsEE");
576  e.getByLabel(eeTag, eeHandle);
577 
578  edm::InputTag esTag(m_hitsProducerTag, "EcalHitsES");
580  e.getByLabel(esTag, esHandle);
581 
582  accumulateCaloHits(ebHandle, eeHandle, esHandle, e.bunchCrossing());
583 }
584 
585 void
587  // Step B: Create empty output
588  std::auto_ptr<EBDigiCollection> apdResult ( !m_apdSeparateDigi ? 0 :
589  new EBDigiCollection() ) ;
590  std::auto_ptr<EBDigiCollection> barrelResult ( new EBDigiCollection() ) ;
591  std::auto_ptr<EEDigiCollection> endcapResult ( new EEDigiCollection() ) ;
592  std::auto_ptr<ESDigiCollection> preshowerResult( new ESDigiCollection() ) ;
593 
594  // run the algorithm
595 
596  m_BarrelDigitizer->run( *barrelResult ) ;
597  cacheEBDigis( &*barrelResult ) ;
598 
599  edm::LogInfo("DigiInfo") << "EB Digis: " << barrelResult->size() ;
600 
601  if( m_apdSeparateDigi ) {
602  m_APDDigitizer->run( *apdResult ) ;
603  edm::LogInfo("DigiInfo") << "APD Digis: " << apdResult->size() ;
604  }
605 
606  m_EndcapDigitizer->run( *endcapResult ) ;
607  edm::LogInfo("EcalDigi") << "EE Digis: " << endcapResult->size() ;
608  cacheEEDigis( &*endcapResult ) ;
609 
610  if(m_doFastES) {
611  m_ESDigitizer->run( *preshowerResult ) ;
612  } else {
613  m_ESOldDigitizer->run( *preshowerResult ) ;
614  }
615  edm::LogInfo("EcalDigi") << "ES Digis: " << preshowerResult->size();
616 
617 
618  // Step D: Put outputs into event
619  if( m_apdSeparateDigi ) {
620  //event.put( apdResult, m_apdDigiTag ) ;
621  }
622 
623  event.put( barrelResult, m_EBdigiCollection ) ;
624  event.put( endcapResult, m_EEdigiCollection ) ;
625  event.put( preshowerResult, m_ESdigiCollection ) ;
626 }
627 
628 void
630 {
631  // Pedestals from event setup
632 
634  eventSetup.get<EcalPedestalsRcd>().get( dbPed ) ;
635  const EcalPedestals* pedestals ( dbPed.product() ) ;
636 
637  m_Coder->setPedestals( pedestals ) ;
638  if( 0 != m_APDCoder ) m_APDCoder->setPedestals( pedestals ) ;
639 
640  // Ecal Intercalibration Constants
642  eventSetup.get<EcalIntercalibConstantsMCRcd>().get( pIcal ) ;
643  const EcalIntercalibConstantsMC* ical ( pIcal.product() ) ;
644 
646  if( 0 != m_APDCoder) m_APDCoder->setIntercalibConstants( ical ) ;
647 
648  m_EBResponse->setIntercal( ical ) ;
649  if( 0 != m_APDResponse ) m_APDResponse->setIntercal( ical ) ;
650 
651  // Ecal LaserCorrection Constants
653  eventSetup.get<EcalLaserDbRecord>().get(laser);
654  const edm::TimeValue_t eventTimeValue = event.time().value();
655 
656  m_EBResponse->setEventTime(eventTimeValue);
658 
659  m_EEResponse->setEventTime(eventTimeValue);
661 
662  // ADC -> GeV Scale
664  eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
665  const EcalADCToGeVConstant* agc = pAgc.product();
666 
667  // Gain Ratios
669  eventSetup.get<EcalGainRatiosRcd>().get(pRatio);
670  const EcalGainRatios* gr = pRatio.product();
671 
672  m_Coder->setGainRatios( gr );
673  if( 0 != m_APDCoder) m_APDCoder->setGainRatios( gr );
674 
675  EcalMGPAGainRatio * defaultRatios = new EcalMGPAGainRatio();
676 
677  double theGains[m_Coder->NGAINS+1];
678  theGains[0] = 0.;
679  theGains[3] = 1.;
680  theGains[2] = defaultRatios->gain6Over1() ;
681  theGains[1] = theGains[2]*(defaultRatios->gain12Over6()) ;
682 
683  LogDebug("EcalDigi") << " Gains: " << "\n" << " g1 = " << theGains[1]
684  << "\n" << " g2 = " << theGains[2]
685  << "\n" << " g3 = " << theGains[3] ;
686 
687  delete defaultRatios;
688 
689  const double EBscale (
690  ( agc->getEBValue())*theGains[1]*(m_Coder->MAXADC)*m_EBs25notCont ) ;
691 
692  LogDebug("EcalDigi") << " GeV/ADC = " << agc->getEBValue()
693  << "\n" << " notCont = " << m_EBs25notCont
694  << "\n" << " saturation for EB = " << EBscale
695  << ", " << m_EBs25notCont ;
696 
697  const double EEscale (
698  (agc->getEEValue())*theGains[1]*(m_Coder->MAXADC)*m_EEs25notCont ) ;
699 
700  LogDebug("EcalDigi") << " GeV/ADC = " << agc->getEEValue()
701  << "\n" << " notCont = " << m_EEs25notCont
702  << "\n" << " saturation for EB = " << EEscale
703  << ", " << m_EEs25notCont ;
704 
705  m_Coder->setFullScaleEnergy( EBscale ,
706  EEscale ) ;
707  if( 0 != m_APDCoder ) m_APDCoder->setFullScaleEnergy( EBscale ,
708  EEscale ) ;
709 
710  if( 0 != m_ESOldDigitizer ||
711  0 != m_ESDigitizer )
712  {
713  // ES condition objects
714  edm::ESHandle<ESGain> hesgain ;
716  edm::ESHandle<ESPedestals> hesPedestals ;
718 
719  eventSetup.get<ESGainRcd>(). get( hesgain ) ;
720  eventSetup.get<ESMIPToGeVConstantRcd>(). get( hesMIPToGeV ) ;
721  eventSetup.get<ESPedestalsRcd>(). get( hesPedestals ) ;
722  eventSetup.get<ESIntercalibConstantsRcd>().get( hesMIPs ) ;
723 
724  const ESGain* esgain ( hesgain.product() ) ;
725  const ESPedestals* espeds ( hesPedestals.product() ) ;
726  const ESIntercalibConstants* esmips ( hesMIPs.product() ) ;
727  const ESMIPToGeVConstant* esMipToGeV ( hesMIPToGeV.product() ) ;
728  const int ESGain ( 1.1 > esgain->getESGain() ? 1 : 2 ) ;
729  const double ESMIPToGeV ( ( 1 == ESGain ) ?
730  esMipToGeV->getESValueLow() :
731  esMipToGeV->getESValueHigh() ) ;
732 
734 
735  if( !m_doFastES )
736  {
738  m_ESElectronicsSim->setPedestals( espeds ) ;
739  m_ESElectronicsSim->setMIPs( esmips ) ;
740  m_ESElectronicsSim->setMIPToGeV( ESMIPToGeV ) ;
741  }
742  else
743  {
746  m_ESElectronicsSimFast->setMIPs( esmips ) ;
747  m_ESElectronicsSimFast->setMIPToGeV( ESMIPToGeV ) ;
748  }
749  }
750 }
751 
752 void
754 {
755  // TODO find a way to avoid doing this every event
756  edm::ESHandle<CaloGeometry> hGeometry ;
757  eventSetup.get<CaloGeometryRecord>().get( hGeometry ) ;
758 
759  const CaloGeometry* pGeometry = &*hGeometry;
760 
761  if( pGeometry != m_Geometry )
762  {
763  m_Geometry = pGeometry;
764  updateGeometry();
765  }
766 }
767 
768 void
770 {
780 
781  const std::vector<DetId>* theESDets (
784 
785  if( !m_doFastES )
786  {
787  if( 0 != m_ESOldDigitizer &&
788  0 != theESDets )
789  m_ESOldDigitizer->setDetIds( *theESDets ) ;
790  }
791  else
792  {
793  if( 0 != m_ESDigitizer &&
794  0 != theESDets )
795  m_ESDigitizer->setDetIds( *theESDets ) ;
796  }
797 }
798 
800  //noiseGenerator->setParameterMap(theParameterMap);
802 }
803 
805  //noiseGenerator->setParameterMap(theParameterMap);
807 }
808 
810  //noiseGenerator->setParameterMap(theParameterMap);
812 }
813 
#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 setMIPToGeV(double MIPToGeV)
CaloHitResponse * m_ESOldResponse
void setGain(const int gain)
virtual ~EcalDigiProducer()
EcalTDigitizer< EEDigitizerTraits > EEDigitizer
CorrelatedNoisifier< EcalCorrMatrix > * m_EBCorrNoise[3]
void initializeHits()
const std::string m_ESdigiCollection
const EcalSimParameterMap * m_ParameterMap
Definition: ESGain.h:5
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:53
void setEventTime(const edm::TimeValue_t &iTime)
void add(const std::vector< PCaloHit > &hits, int bunchCrossing)
const std::string m_hitsProducerTag
void add(const std::vector< PCaloHit > &hits, int bunchCrossing)
void setMIPs(const ESIntercalibConstants *mips)
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 accumulateCaloHits(HitsHandle const &ebHandle, HitsHandle const &eeHandle, HitsHandle const &esHandle, int bunchCrossing)
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)
void setGain(const int gain)
Definition: ESDigitizer.cc:61
ESElectronicsSim * m_ESElectronicsSim
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
#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
const bool m_apdSeparateDigi
virtual void finalizeEvent(edm::Event &e, edm::EventSetup const &c)
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
const std::string m_apdDigiTag
void setDetIds(const std::vector< DetId > &detIds)
volatile std::atomic< bool > shutdown_flag false
virtual void run(DigiCollection &output)
void setMIPs(const ESIntercalibConstants *mips)
virtual void cacheEEDigis(const EEDigiCollection *eeDigiPtr) const
const std::string m_EBdigiCollection
virtual void run(ESDigiCollection &output)
turns hits into digis
Definition: ESDigitizer.cc:189
EcalElectronicsSim * m_APDElectronicsSim
const double m_EEs25notCont
EEHitResponse * m_EEResponse