Implements edm::EDProducer.
Definition at line 68 of file L1RCTProducer.cc.
References c, GenMuonPlsPt100GeV_cfg::cout, L1RCT::digiInput(), e, ReconstructionGR_cff::ecal, EcalBarrel, ecalDigisLabel, EcalEndcap, EcalTriggerTower, lat::endl(), edm::EventSetup::get(), L1RCT::getIsolatedEGObjects(), L1RCT::getNonisolatedEGObjects(), L1RCT::getRegions(), EcalTPGScale::getTPGInGeV(), h, hbShift, ReconstructionGR_cff::hcal, hcalDigisLabel, CaloTPGTranscoder::hcaletValue(), hfShift, i, edm::Handle< T >::isValid(), j, L1CaloEcalScale::nBinEta, L1CaloHcalScale::nBinEta, L1CaloHcalScale::nBinRank, L1CaloEcalScale::nBinRank, postSamples, preSamples, L1RCT::processEvent(), edm::ESHandle< T >::product(), r, rct, rctLookupTables, s, L1CaloHcalScale::setBin(), L1CaloEcalScale::setBin(), L1RCTLookupTables::setChannelMask(), L1RCTLookupTables::setEcalScale(), EcalTPGScale::setEventSetup(), L1RCTLookupTables::setHcalScale(), L1RCTLookupTables::setL1CaloEtScale(), HcalTriggerPrimitiveDigi::setPresamples(), L1RCTLookupTables::setRCTParameters(), EcalTriggerPrimitiveDigi::setSample(), HcalTriggerPrimitiveDigi::setSample(), EcalTriggerPrimitiveDigi::setSize(), HcalTriggerPrimitiveDigi::setSize(), useDebugTpgScales, useEcal, useEcalCosmicTiming, useHcal, useHcalCosmicTiming, and useMCAsInput.
00069 {
00070
00071
00072
00073
00074
00075
00076
00077 edm::ESHandle<L1RCTParameters> rctParameters;
00078 eventSetup.get<L1RCTParametersRcd>().get(rctParameters);
00079 const L1RCTParameters* r = rctParameters.product();
00080
00081
00082 edm::ESHandle<L1RCTChannelMask> channelMask;
00083 eventSetup.get<L1RCTChannelMaskRcd>().get(channelMask);
00084 const L1RCTChannelMask* c = channelMask.product();
00085
00086
00087 edm::ESHandle<L1CaloEtScale> emScale;
00088 eventSetup.get<L1EmEtScaleRcd>().get(emScale);
00089 const L1CaloEtScale* s = emScale.product();
00090
00091 rctLookupTables->setRCTParameters(r);
00092 rctLookupTables->setChannelMask(c);
00093 rctLookupTables->setL1CaloEtScale(s);
00094
00095
00096
00097 L1CaloEcalScale* dummyE(0);
00098 L1CaloHcalScale* dummyH(0);
00099
00100 if (useDebugTpgScales)
00101 {
00102
00103 std::cout << "Using old-style TPG scales!" << endl;
00104
00105
00106 edm::ESHandle<CaloTPGTranscoder> transcoder;
00107 eventSetup.get<CaloTPGRecord>().get(transcoder);
00108 const CaloTPGTranscoder* h_tpg = transcoder.product();
00109
00110
00111 EcalTPGScale* e_tpg = new EcalTPGScale();
00112 e_tpg->setEventSetup(eventSetup);
00113
00114 L1CaloEcalScale* ecalScale = new L1CaloEcalScale();
00115 L1CaloHcalScale* hcalScale = new L1CaloHcalScale();
00116
00117
00118
00119
00120 for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta )
00121 {
00122 for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank )
00123 {
00124
00125 EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ;
00126 double etGeVPos =
00127 e_tpg->getTPGInGeV
00128 ( irank, EcalTrigTowerDetId(1,
00129 subdet,
00130 ieta,
00131 1 ));
00132 ecalScale->setBin( irank, ieta, 1, etGeVPos ) ;
00133
00134 }
00135
00136 }
00137
00138
00139
00140 for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta )
00141 {
00142 for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank )
00143 {
00144 EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ;
00145
00146
00147 double etGeVNeg =
00148 e_tpg->getTPGInGeV
00149 ( irank,
00150 EcalTrigTowerDetId(-1,
00151 subdet,
00152 ieta,
00153 2 ));
00154 ecalScale->setBin( irank, ieta, -1, etGeVNeg ) ;
00155
00156 }
00157
00158 }
00159
00160
00161
00162
00163 for( unsigned short ieta = 1 ; ieta <= L1CaloHcalScale::nBinEta; ++ieta )
00164 {
00165 for( unsigned short irank = 0 ; irank < L1CaloHcalScale::nBinRank; ++irank )
00166 {
00167 double etGeV = h_tpg->hcaletValue( ieta, irank ) ;
00168
00169 hcalScale->setBin( irank, ieta, 1, etGeV ) ;
00170 hcalScale->setBin( irank, ieta, -1, etGeV ) ;
00171
00172 }
00173
00174 }
00175
00176
00177
00178 rctLookupTables->setEcalScale(ecalScale);
00179 rctLookupTables->setHcalScale(hcalScale);
00180
00181 dummyE = ecalScale;
00182 dummyH = hcalScale;
00183
00184 delete e_tpg;
00185
00186 }
00187 else
00188 {
00189
00190
00191 edm::ESHandle<L1CaloEcalScale> ecalScale;
00192 eventSetup.get<L1CaloEcalScaleRcd>().get(ecalScale);
00193 const L1CaloEcalScale* e = ecalScale.product();
00194
00195
00196 edm::ESHandle<L1CaloHcalScale> hcalScale;
00197 eventSetup.get<L1CaloHcalScaleRcd>().get(hcalScale);
00198 const L1CaloHcalScale* h = hcalScale.product();
00199
00200
00201 rctLookupTables->setEcalScale(e);
00202 rctLookupTables->setHcalScale(h);
00203
00204 }
00205
00206 edm::Handle<EcalTrigPrimDigiCollection> ecal;
00207 edm::Handle<HcalTrigPrimDigiCollection> hcal;
00208
00209 EcalTrigPrimDigiCollection::const_iterator ecal_it;
00210 HcalTrigPrimDigiCollection::const_iterator hcal_it;
00211
00212 if (useEcal) { event.getByLabel(ecalDigisLabel, ecal); }
00213 if (useHcal) { event.getByLabel(hcalDigisLabel, hcal); }
00214
00215 unsigned nSamples = preSamples + postSamples + 1;
00216
00217
00218
00219 bool tooLittleDataEcal = false;
00220 bool tooLittleDataHcal = false;
00221
00222 std::vector<EcalTrigPrimDigiCollection> ecalColl(nSamples);
00223 std::vector<HcalTrigPrimDigiCollection> hcalColl(nSamples);
00224 if (ecal.isValid())
00225 {
00226
00227 for (ecal_it = ecal->begin(); ecal_it != ecal->end(); ecal_it++)
00228 {
00229 short zside = ecal_it->id().zside();
00230 unsigned short ietaAbs = ecal_it->id().ietaAbs();
00231 short iphi = ecal_it->id().iphi();
00232
00233
00234
00235
00236
00237
00238
00239
00240 unsigned short digiSize = ecal_it->size();
00241
00242 unsigned short nSOI = (unsigned short) ( ecal_it->
00243 sampleOfInterest() );
00244 if (digiSize < nSamples || nSOI < preSamples
00245 || ((digiSize - nSOI) < (nSamples - preSamples)))
00246 {
00247
00248 if (tooLittleDataEcal == false)
00249 {
00250 edm::LogWarning ("TooLittleData")
00251 << "ECAL data should have at least " << nSamples
00252 << " time samples per digi, current digi has "
00253 << digiSize << ". Insufficient data to process "
00254 << "requested bx's. Filling extra with zeros";
00255 tooLittleDataEcal = true;
00256 }
00257 unsigned short preLoopsZero = (unsigned short) (preSamples)
00258 - nSOI;
00259 unsigned short postLoopsZero = (unsigned short) (postSamples)
00260 - (digiSize - nSOI - 1);
00261
00262
00263 for (int sample = 0; sample < preLoopsZero; sample++)
00264 {
00265
00266 EcalTriggerPrimitiveDigi
00267 ecalDigi(EcalTrigTowerDetId((int) zside, EcalTriggerTower,
00268 (int) ietaAbs, (int) iphi));
00269 ecalDigi.setSize(1);
00270 ecalDigi.setSample(0, EcalTriggerPrimitiveSample(0,false,0));
00271 ecalColl[sample].push_back(ecalDigi);
00272 }
00273
00274
00275 for (int sample = preLoopsZero;
00276 sample < (preLoopsZero + digiSize); sample++)
00277 {
00278
00279 EcalTriggerPrimitiveDigi
00280 ecalDigi(EcalTrigTowerDetId((int) zside, EcalTriggerTower,
00281 (int) ietaAbs, (int) iphi));
00282 ecalDigi.setSize(1);
00283
00284 if (useEcalCosmicTiming && iphi >= 1 && iphi <= 36)
00285 {
00286 if (nSOI < (preSamples + 1))
00287 {
00288 edm::LogWarning ("TooLittleData")
00289 << "ECAL data needs at least one presample "
00290 << "more than the number requested "
00291 << "to use ecal cosmic timing mod! "
00292
00293
00294 << "reverting to useEcalCosmicTiming = false "
00295 << "for rest of job.";
00296
00297
00298 useEcalCosmicTiming = false;
00299 }
00300 else
00301 {
00302
00303 ecalDigi.setSample(0, EcalTriggerPrimitiveSample
00304 (ecal_it->sample(nSOI + sample -
00305 preSamples -
00306 1).raw()));
00307 }
00308 }
00309
00310 if ((!useEcalCosmicTiming) || (iphi >=37 && iphi <= 72))
00311 {
00312 ecalDigi.setSample(0, EcalTriggerPrimitiveSample
00313 (ecal_it->sample(nSOI + sample -
00314 preSamples).raw()));
00315 }
00316 ecalColl[sample].push_back(ecalDigi);
00317
00318
00319
00320
00321
00322
00323
00324
00325 }
00326
00327
00328 for (int sample = (preLoopsZero + digiSize);
00329 sample < nSamples; sample++)
00330 {
00331
00332 EcalTriggerPrimitiveDigi
00333 ecalDigi(EcalTrigTowerDetId((int) zside, EcalTriggerTower,
00334 (int) ietaAbs, (int) iphi));
00335 ecalDigi.setSize(1);
00336 ecalDigi.setSample(0, EcalTriggerPrimitiveSample(0,false,0));
00337 ecalColl[sample].push_back(ecalDigi);
00338 }
00339 }
00340 else
00341 {
00342 for (unsigned short sample = 0; sample < nSamples; sample++)
00343 {
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 short zside = ecal_it->id().zside();
00354 unsigned short ietaAbs = ecal_it->id().ietaAbs();
00355 short iphi = ecal_it->id().iphi();
00356 EcalTriggerPrimitiveDigi
00357 ecalDigi(EcalTrigTowerDetId((int) zside, EcalTriggerTower,
00358 (int) ietaAbs, (int) iphi));
00359 ecalDigi.setSize(1);
00360
00361 if (useEcalCosmicTiming && iphi >= 1 && iphi <=36)
00362 {
00363 if (nSOI < (preSamples + 1))
00364 {
00365 edm::LogWarning ("TooLittleData")
00366 << "ECAL data needs at least one presample "
00367 << "more than the number requested "
00368 << "to use ecal cosmic timing mod! "
00369
00370
00371 << "reverting to useEcalCosmicTiming = false "
00372 << "for rest of job.";
00373
00374
00375 useEcalCosmicTiming = false;
00376 }
00377 else
00378 {
00379 ecalDigi.setSample(0, EcalTriggerPrimitiveSample
00380 (ecal_it->sample
00381 (ecal_it->sampleOfInterest() +
00382 sample - preSamples -
00383 1).raw()));
00384 }
00385 }
00386
00387 if ((!useEcalCosmicTiming) || (iphi >=37 && iphi <= 72))
00388 {
00389 ecalDigi.setSample(0, EcalTriggerPrimitiveSample
00390 (ecal_it->sample
00391 (ecal_it->sampleOfInterest() +
00392 sample - preSamples).raw()));
00393 }
00394
00395 ecalColl[sample].push_back(ecalDigi);
00396 }
00397 }
00398 }
00399 }
00400 if (hcal.isValid())
00401 {
00402
00403 for (hcal_it = hcal->begin(); hcal_it != hcal->end(); hcal_it++)
00404 {
00405 short ieta = hcal_it->id().ieta();
00406 short iphi = hcal_it->id().iphi();
00407
00408 unsigned short digiSize = hcal_it->size();
00409
00410 unsigned short nSOI = (unsigned short) (hcal_it->presamples());
00411 if (digiSize < nSamples || nSOI < preSamples
00412 || ((digiSize - nSOI) < (nSamples - preSamples)))
00413 {
00414
00415 if (tooLittleDataHcal == false)
00416 {
00417 edm::LogWarning ("TooLittleData")
00418 << "HCAL data should have at least " << nSamples
00419 << " time samples per digi, current digi has "
00420 << digiSize << ". Insufficient data to process "
00421 << "requested bx's. Filling extra with zeros";
00422 tooLittleDataHcal = true;
00423 }
00424 unsigned short preLoopsZero = (unsigned short) (preSamples)
00425 - nSOI;
00426 unsigned short postLoopsZero = (unsigned short) (postSamples)
00427 - (digiSize - nSOI - 1);
00428
00429
00430 for (int sample = 0; sample < preLoopsZero; sample++)
00431 {
00432
00433 HcalTriggerPrimitiveDigi
00434 hcalDigi(HcalTrigTowerDetId((int) ieta, (int) iphi));
00435 hcalDigi.setSize(1);
00436 hcalDigi.setPresamples(0);
00437 hcalDigi.setSample(0, HcalTriggerPrimitiveSample(0,false,0,0));
00438 hcalColl[sample].push_back(hcalDigi);
00439 }
00440
00441
00442 for (int sample = preLoopsZero;
00443 sample < (preLoopsZero + digiSize); sample++)
00444 {
00445
00446 HcalTriggerPrimitiveDigi
00447 hcalDigi(HcalTrigTowerDetId((int) ieta, (int) iphi));
00448 hcalDigi.setSize(1);
00449 hcalDigi.setPresamples(0);
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462 if (useHcalCosmicTiming && iphi >= 1 && iphi <= 36)
00463 {
00464 if (nSOI < (preSamples + 1))
00465 {
00466 edm::LogWarning ("TooLittleData")
00467 << "HCAL data needs at least one presample "
00468 << "more than the number requested "
00469 << "to use hcal cosmic timing mod! "
00470
00471
00472 << "reverting to useHcalCosmicTiming = false "
00473 << "for rest of job.";
00474
00475
00476 useHcalCosmicTiming = false;
00477 }
00478 else
00479 {
00480 hcalDigi.setSample(0, HcalTriggerPrimitiveSample
00481 (hcal_it->sample(hcal_it->
00482 presamples() +
00483 sample -
00484 preSamples -
00485 1).raw()));
00486 }
00487 }
00488
00489 if ((!useHcalCosmicTiming) || (iphi >= 37 && iphi <= 72))
00490 {
00491
00492
00493
00494
00495 hcalDigi.setSample(0, HcalTriggerPrimitiveSample
00496 (hcal_it->sample(hcal_it->
00497 presamples() +
00498 sample -
00499 preSamples).raw()));
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518 }
00519 hcalColl[sample].push_back(hcalDigi);
00520 }
00521
00522
00523 for (int sample = (preLoopsZero + digiSize);
00524 sample < nSamples; sample++)
00525 {
00526
00527 HcalTriggerPrimitiveDigi
00528 hcalDigi(HcalTrigTowerDetId((int) ieta, (int) iphi));
00529 hcalDigi.setSize(1);
00530 hcalDigi.setPresamples(0);
00531 hcalDigi.setSample(0, HcalTriggerPrimitiveSample(0,false,0,0));
00532 hcalColl[sample].push_back(hcalDigi);
00533 }
00534 }
00535 else
00536 {
00537 for (unsigned short sample = 0; sample < nSamples; sample++)
00538 {
00539
00540 HcalTriggerPrimitiveDigi hcalDigi(HcalTrigTowerDetId(
00541 (int) ieta, (int) iphi));
00542 hcalDigi.setSize(1);
00543 hcalDigi.setPresamples(0);
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556 if (useHcalCosmicTiming && iphi >= 1 && iphi <= 36)
00557 {
00558 if (nSOI < (preSamples + 1))
00559 {
00560 edm::LogWarning ("TooLittleData")
00561 << "HCAL data needs at least one presample "
00562 << "more than the number requested "
00563 << "to use hcal cosmic timing mod! "
00564
00565
00566 << "reverting to useHcalCosmicTiming = false "
00567 << "for rest of job.";
00568
00569
00570 useHcalCosmicTiming = false;
00571 }
00572 else
00573 {
00574 hcalDigi.setSample(0, HcalTriggerPrimitiveSample
00575 (hcal_it->sample(hcal_it->
00576 presamples() +
00577 sample -
00578 preSamples -
00579 1).raw()));
00580 }
00581 }
00582
00583 if ((!useHcalCosmicTiming) || (iphi >= 37 && iphi <= 72))
00584 {
00585
00586
00587
00588
00589
00590
00591 if(useMCAsInput)
00592 {
00593 hcalDigi.setSample(0, HcalTriggerPrimitiveSample
00594 (hcal_it->sample(hcal_it->
00595 presamples() +
00596 sample -
00597 preSamples).raw()));
00598 }
00599 else
00600 {
00601 if(ieta>-29 && ieta<29)
00602 hcalDigi.setSample(0, HcalTriggerPrimitiveSample
00603 (hcal_it->sample(hcal_it->
00604 presamples() +
00605 sample -
00606 preSamples+hbShift).raw()));
00607 if(ieta<=-29 || ieta>=29)
00608 hcalDigi.setSample(0, HcalTriggerPrimitiveSample
00609 (hcal_it->sample(hcal_it->
00610 presamples() +
00611 sample -
00612 preSamples+hfShift).raw()));
00613
00614 }
00615 }
00616 hcalColl[sample].push_back(hcalDigi);
00617 }
00618 }
00619 }
00620 }
00621
00622 std::auto_ptr<L1CaloEmCollection> rctEmCands (new L1CaloEmCollection);
00623 std::auto_ptr<L1CaloRegionCollection> rctRegions (new L1CaloRegionCollection);
00624
00625
00626 for (unsigned short sample = 0; sample < nSamples; sample++)
00627 {
00628 rct->digiInput(ecalColl[sample], hcalColl[sample]);
00629 rct->processEvent();
00630
00631
00632
00633 for (int j = 0; j<18; j++)
00634 {
00635 L1CaloEmCollection isolatedEGObjects = rct->getIsolatedEGObjects(j);
00636 L1CaloEmCollection nonisolatedEGObjects = rct->getNonisolatedEGObjects(j);
00637 for (int i = 0; i<4; i++)
00638 {
00639 isolatedEGObjects.at(i).setBx(sample - preSamples);
00640 nonisolatedEGObjects.at(i).setBx(sample - preSamples);
00641 rctEmCands->push_back(isolatedEGObjects.at(i));
00642 rctEmCands->push_back(nonisolatedEGObjects.at(i));
00643 }
00644 }
00645
00646
00647 for (int i = 0; i < 18; i++)
00648 {
00649 vector<L1CaloRegion> regions = rct->getRegions(i);
00650 for (int j = 0; j < 22; j++)
00651 {
00652 regions.at(j).setBx(sample - preSamples);
00653 rctRegions->push_back(regions.at(j));
00654 }
00655 }
00656 }
00657
00658
00659 event.put(rctEmCands);
00660 event.put(rctRegions);
00661
00662 if (dummyE != 0) delete dummyE;
00663 if (dummyH != 0) delete dummyH;
00664
00665 }