#include <src/L1RCTSaveInput/src/L1RCTSaveInput.cc>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
L1RCTSaveInput (const edm::ParameterSet &) | |
~L1RCTSaveInput () | |
Private Attributes | |
edm::InputTag | ecalDigisLabel |
std::string | fileName |
edm::InputTag | hcalDigisLabel |
std::ofstream | ofs |
L1RCT * | rct |
L1RCTLookupTables * | rctLookupTables |
bool | useDebugTpgScales |
bool | useEcal |
bool | useHcal |
Description: Saves the input event from TPGs for loading simulated events in hardware
Implementation: Kind of kludgy -- should think of a better way in future
Definition at line 39 of file L1RCTSaveInput.h.
L1RCTSaveInput::L1RCTSaveInput | ( | const edm::ParameterSet & | conf | ) | [explicit] |
Definition at line 45 of file L1RCTSaveInput.cc.
References benchmark_cfg::cerr, cmsRelvalreport::exit, fileName, and ofs.
: fileName(conf.getUntrackedParameter<std::string>("rctTestInputFile")), rctLookupTables(new L1RCTLookupTables), rct(new L1RCT(rctLookupTables)), useEcal(conf.getParameter<bool>("useEcal")), useHcal(conf.getParameter<bool>("useHcal")), ecalDigisLabel(conf.getParameter<edm::InputTag>("ecalDigisLabel")), hcalDigisLabel(conf.getParameter<edm::InputTag>("hcalDigisLabel")), useDebugTpgScales(conf.getParameter<bool>("useDebugTpgScales")) { ofs.open(fileName.c_str(), std::ios::app); if(!ofs) { std::cerr << "Could not create " << fileName << std::endl; exit(1); } }
L1RCTSaveInput::~L1RCTSaveInput | ( | ) |
Definition at line 63 of file L1RCTSaveInput.cc.
References rct, and rctLookupTables.
{ if(rct != 0) delete rct; if(rctLookupTables != 0) delete rctLookupTables; }
void L1RCTSaveInput::analyze | ( | const edm::Event & | event, |
const edm::EventSetup & | eventSetup | ||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 70 of file L1RCTSaveInput.cc.
References trackerHits::c, gather_cfg::cout, L1RCT::digiInput(), patCandidatesForDimuonsSequences_cff::ecal, EcalBarrel, L1RCT::ecalCompressedET(), ecalDigisLabel, EcalEndcap, L1RCT::ecalFineGrainBit(), edm::EventSetup::get(), EcalTPGScale::getTPGInGeV(), h, patCandidatesForDimuonsSequences_cff::hcal, L1RCT::hcalCompressedET(), hcalDigisLabel, CaloTPGTranscoder::hcaletValue(), L1RCT::hcalFineGrainBit(), edm::HandleBase::isValid(), L1RCTLookupTables::lookup(), L1CaloEcalScale::nBinEta, L1CaloHcalScale::nBinEta, L1CaloHcalScale::nBinRank, L1CaloEcalScale::nBinRank, nEvents, ofs, edm::ESHandle< T >::product(), csvReporter::r, rct, rctLookupTables, asciidump::s, L1CaloHcalScale::setBin(), L1CaloEcalScale::setBin(), L1RCTLookupTables::setChannelMask(), L1RCTLookupTables::setEcalScale(), EcalTPGScale::setEventSetup(), L1RCTLookupTables::setHcalScale(), L1RCTLookupTables::setL1CaloEtScale(), L1RCTLookupTables::setRCTParameters(), and useDebugTpgScales.
{ edm::ESHandle<L1RCTParameters> rctParameters; eventSetup.get<L1RCTParametersRcd>().get(rctParameters); const L1RCTParameters* r = rctParameters.product(); edm::ESHandle<L1RCTChannelMask> channelMask; eventSetup.get<L1RCTChannelMaskRcd>().get(channelMask); const L1RCTChannelMask* c = channelMask.product(); edm::ESHandle<L1CaloEtScale> emScale; eventSetup.get<L1EmEtScaleRcd>().get(emScale); const L1CaloEtScale* s = emScale.product(); rctLookupTables->setRCTParameters(r); rctLookupTables->setChannelMask(c); rctLookupTables->setL1CaloEtScale(s); // use dummies to get delete right when creating new scales from old L1CaloEcalScale* dummyE(0); L1CaloHcalScale* dummyH(0); if (useDebugTpgScales) { // use old-style scales edm::ESHandle<CaloTPGTranscoder> transcoder; eventSetup.get<CaloTPGRecord>().get(transcoder); const CaloTPGTranscoder* h_tpg = transcoder.product(); EcalTPGScale* e_tpg = new EcalTPGScale(); e_tpg->setEventSetup(eventSetup); L1CaloEcalScale* ecalScale = new L1CaloEcalScale(); L1CaloHcalScale* hcalScale = new L1CaloHcalScale(); // create input scales, werner's code // ECAL std::cout << "ECAL Pos " << L1CaloEcalScale::nBinRank << std::endl ; for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta ) { for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank ) { std::cout << ieta << " " << irank ; EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ; double etGeVPos = e_tpg->getTPGInGeV ( irank, EcalTrigTowerDetId(1, // +ve eta subdet, ieta, 1 )); // dummy phi value ecalScale->setBin( irank, ieta, 1, etGeVPos ) ; std::cout << etGeVPos << ", " ; } std::cout << std::endl ; } std::cout << std::endl ; std::cout << "ECAL Neg" << std::endl ; for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta ) { for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank ) { EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ; std::cout << ieta << " " << irank ; double etGeVNeg = e_tpg->getTPGInGeV ( irank, EcalTrigTowerDetId(-1, // -ve eta subdet, ieta, 2 )); // dummy phi value ecalScale->setBin( irank, ieta, -1, etGeVNeg ) ; std::cout << etGeVNeg << ", " ; } std::cout << std::endl ; } std::cout << std::endl ; // HCAL std::cout << "HCAL" << std::endl ; for( unsigned short ieta = 1 ; ieta <= L1CaloHcalScale::nBinEta; ++ieta ) { for( unsigned short irank = 0 ; irank < L1CaloHcalScale::nBinRank; ++irank ) { double etGeV = h_tpg->hcaletValue( ieta, irank ) ; hcalScale->setBin( irank, ieta, 1, etGeV ) ; hcalScale->setBin( irank, ieta, -1, etGeV ) ; std::cout << etGeV << ", " ; std::cout << std::endl ; } std::cout << std::endl ; } // set the input scales rctLookupTables->setEcalScale(ecalScale); rctLookupTables->setHcalScale(hcalScale); dummyE = ecalScale; dummyH = hcalScale; delete e_tpg; } else { edm::ESHandle<L1CaloHcalScale> hcalScale; eventSetup.get<L1CaloHcalScaleRcd>().get(hcalScale); const L1CaloHcalScale* h = hcalScale.product(); edm::ESHandle<L1CaloEcalScale> ecalScale; eventSetup.get<L1CaloEcalScaleRcd>().get(ecalScale); const L1CaloEcalScale* e = ecalScale.product(); rctLookupTables->setHcalScale(h); rctLookupTables->setEcalScale(e); } edm::Handle<EcalTrigPrimDigiCollection> ecal; edm::Handle<HcalTrigPrimDigiCollection> hcal; event.getByLabel(ecalDigisLabel, ecal); event.getByLabel(hcalDigisLabel, hcal); EcalTrigPrimDigiCollection ecalColl; HcalTrigPrimDigiCollection hcalColl; if (ecal.isValid()) { ecalColl = *ecal; } if (hcal.isValid()) { hcalColl = *hcal; } rct->digiInput(ecalColl, hcalColl); static int nEvents = 0; if(nEvents == 0) { ofs << "Crate = 0-17" << std::endl << "Card = 0-7 within the crate" << std::endl << "Tower = 0-31 covers 4 x 8 covered by the card" << std::endl << "EMAddr(0:8) = EMFGBit(0:0)+CompressedEMET(1:8)" << std::endl << "HDAddr(0:8) = HDFGBit(0:0)+CompressedHDET(1:8) - note: HDFGBit(0:0) is not part of the hardware LUT address" << std::endl << "LutOut(0:17)= LinearEMET(0:6)+HoEFGVetoBit(7:7)+LinearJetET(8:16)+ActivityBit(17:17)" << std::endl << "Event" << "\t" << "Crate" << "\t" << "Card" << "\t" << "Tower" << "\t" << "EMAddr" << "\t" << "HDAddr" << "\t" << "LUTOut" << std::endl; } if(nEvents < 64) { for(unsigned short iCrate = 0; iCrate < 18; iCrate++) { for(unsigned short iCard = 0; iCard < 7; iCard++) { // tower numbered from 0-31 for(unsigned short iTower = 0; iTower < 32; iTower++) { unsigned short ecal = rct->ecalCompressedET(iCrate, iCard, iTower); unsigned short hcal = rct->hcalCompressedET(iCrate, iCard, iTower); unsigned short fgbit = rct->ecalFineGrainBit(iCrate, iCard, iTower); unsigned short mubit = rct->hcalFineGrainBit(iCrate, iCard, iTower); unsigned long lutOutput = rctLookupTables->lookup(ecal, hcal, fgbit, iCrate, iCard, iTower); ofs << std::hex << nEvents << "\t" << iCrate << "\t" << iCard << "\t" << iTower << "\t" << ecal * 2 + fgbit << "\t" << hcal * 2 + mubit << "\t" << lutOutput << std::dec << std::endl; } } } } nEvents++; }
edm::InputTag L1RCTSaveInput::ecalDigisLabel [private] |
Definition at line 50 of file L1RCTSaveInput.h.
Referenced by analyze().
std::string L1RCTSaveInput::fileName [private] |
Definition at line 45 of file L1RCTSaveInput.h.
Referenced by L1RCTSaveInput().
edm::InputTag L1RCTSaveInput::hcalDigisLabel [private] |
Definition at line 51 of file L1RCTSaveInput.h.
Referenced by analyze().
std::ofstream L1RCTSaveInput::ofs [private] |
Definition at line 53 of file L1RCTSaveInput.h.
Referenced by analyze(), and L1RCTSaveInput().
L1RCT* L1RCTSaveInput::rct [private] |
Definition at line 47 of file L1RCTSaveInput.h.
Referenced by analyze(), and ~L1RCTSaveInput().
L1RCTLookupTables* L1RCTSaveInput::rctLookupTables [private] |
Definition at line 46 of file L1RCTSaveInput.h.
Referenced by analyze(), and ~L1RCTSaveInput().
bool L1RCTSaveInput::useDebugTpgScales [private] |
Definition at line 52 of file L1RCTSaveInput.h.
Referenced by analyze().
bool L1RCTSaveInput::useEcal [private] |
Definition at line 48 of file L1RCTSaveInput.h.
bool L1RCTSaveInput::useHcal [private] |
Definition at line 49 of file L1RCTSaveInput.h.