00001 #include "L1Trigger/GlobalCaloTrigger/plugins/L1GctEmulator.h"
00002
00003
00004 #include <memory>
00005 #include <vector>
00006
00007
00008 #include "FWCore/PluginManager/interface/ModuleDef.h"
00009 #include "FWCore/Framework/interface/Frameworkfwd.h"
00010 #include "FWCore/Framework/interface/EDProducer.h"
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/MakerMacros.h"
00013 #include "FWCore/Framework/interface/ESHandle.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017
00018
00019 #include "CondFormats/L1TObjects/interface/L1GctJetFinderParams.h"
00020 #include "CondFormats/L1TObjects/interface/L1GctJetEtCalibrationFunction.h"
00021 #include "CondFormats/L1TObjects/interface/L1GctJetCounterSetup.h"
00022 #include "CondFormats/L1TObjects/interface/L1GctChannelMask.h"
00023 #include "CondFormats/L1TObjects/interface/L1GctHfLutSetup.h"
00024 #include "CondFormats/DataRecord/interface/L1GctJetFinderParamsRcd.h"
00025 #include "CondFormats/DataRecord/interface/L1GctJetCalibFunRcd.h"
00026 #include "CondFormats/DataRecord/interface/L1GctJetCounterPositiveEtaRcd.h"
00027 #include "CondFormats/DataRecord/interface/L1GctJetCounterNegativeEtaRcd.h"
00028 #include "CondFormats/DataRecord/interface/L1GctChannelMaskRcd.h"
00029 #include "CondFormats/DataRecord/interface/L1GctHfLutSetupRcd.h"
00030
00031
00032 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetEtCalibrationLut.h"
00033
00034
00035 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
00036
00037
00038 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
00039
00040 using std::vector;
00041
00042 L1GctEmulator::L1GctEmulator(const edm::ParameterSet& ps) :
00043 m_jetEtCalibLuts(),
00044 m_verbose(ps.getUntrackedParameter<bool>("verbose", false))
00045 {
00046
00047
00048 produces<L1GctEmCandCollection>("isoEm");
00049 produces<L1GctEmCandCollection>("nonIsoEm");
00050 produces<L1GctJetCandCollection>("cenJets");
00051 produces<L1GctJetCandCollection>("forJets");
00052 produces<L1GctJetCandCollection>("tauJets");
00053 produces<L1GctEtTotalCollection>();
00054 produces<L1GctEtHadCollection>();
00055 produces<L1GctEtMissCollection>();
00056 produces<L1GctEtMissCollection>("missingHt");
00057 produces<L1GctJetCountsCollection>();
00058 produces<L1GctHFBitCountsCollection>();
00059 produces<L1GctHFRingEtSumsCollection>();
00060
00061
00062 edm::InputTag inputTag = ps.getParameter<edm::InputTag>("inputLabel");
00063 m_inputLabel = inputTag.label();
00064
00065
00066 int firstBx = -ps.getParameter<unsigned>("preSamples");
00067 int lastBx = ps.getParameter<unsigned>("postSamples");
00068
00069
00070 L1GctJetLeafCard::jetFinderType jfType=L1GctJetLeafCard::hardwareJetFinder;
00071 std::string jfTypeStr = ps.getParameter<std::string>("jetFinderType");
00072 if (jfTypeStr == "tdrJetFinder") { jfType = L1GctJetLeafCard::tdrJetFinder; }
00073 else if (jfTypeStr != "hardwareJetFinder") {
00074 edm::LogWarning ("L1GctEmulatorSetup") << "Unrecognised jetFinder option " << jfTypeStr
00075 << "\nHardware jetFinder will be used";
00076 }
00077 m_gct = new L1GlobalCaloTrigger(jfType);
00078 m_gct->setBxRange(firstBx, lastBx);
00079
00080
00081 lutPtr nextLut( new L1GctJetEtCalibrationLut() );
00082
00083 for (unsigned ieta=0; ieta<L1GctJetFinderBase::COL_OFFSET; ieta++) {
00084 nextLut->setEtaBin(ieta);
00085 m_jetEtCalibLuts.push_back(nextLut);
00086 nextLut.reset ( new L1GctJetEtCalibrationLut() );
00087 }
00088
00089
00090
00091
00092
00093 if (m_verbose) {
00094 m_gct->print();
00095
00096 }
00097 }
00098
00099 L1GctEmulator::~L1GctEmulator() {
00100 if (m_gct != 0) delete m_gct;
00101 }
00102
00103
00104 void L1GctEmulator::beginJob(const edm::EventSetup& c)
00105 {
00106 }
00107
00108 void L1GctEmulator::endJob()
00109 {
00110 }
00111
00112 int L1GctEmulator::configureGct(const edm::EventSetup& c)
00113 {
00114 int success = 0;
00115 if (&c==0) {
00116 success = -1;
00117 if (m_verbose) {
00118 edm::LogWarning("L1GctConfigFailure") << "Cannot find EventSetup information." << std::endl;
00119 }
00120 }
00121
00122 if (success == 0) {
00123
00124 edm::ESHandle< L1GctJetFinderParams > jfPars ;
00125 c.get< L1GctJetFinderParamsRcd >().get( jfPars ) ;
00126 edm::ESHandle< L1GctJetCounterSetup > jcPosPars ;
00127 c.get< L1GctJetCounterPositiveEtaRcd >().get( jcPosPars ) ;
00128 edm::ESHandle< L1GctJetCounterSetup > jcNegPars ;
00129 c.get< L1GctJetCounterNegativeEtaRcd >().get( jcNegPars ) ;
00130 edm::ESHandle< L1GctJetEtCalibrationFunction > calibFun ;
00131 c.get< L1GctJetCalibFunRcd >().get( calibFun ) ;
00132 edm::ESHandle< L1GctHfLutSetup > hfLSetup ;
00133 c.get< L1GctHfLutSetupRcd >().get( hfLSetup ) ;
00134 edm::ESHandle< L1GctChannelMask > chanMask ;
00135 c.get< L1GctChannelMaskRcd >().get( chanMask ) ;
00136 edm::ESHandle< L1CaloEtScale > etScale ;
00137 c.get< L1JetEtScaleRcd >().get( etScale ) ;
00138
00139 if (jfPars.product() == 0) {
00140 success = -1;
00141 if (m_verbose) {
00142 edm::LogWarning("L1GctConfigFailure")
00143 << "Failed to find a L1GctJetFinderParamsRcd:L1GctJetFinderParams in EventSetup!" << std::endl;
00144 }
00145 }
00146
00147 if (calibFun.product() == 0) {
00148 success = -1;
00149 if (m_verbose) {
00150 edm::LogWarning("L1GctConfigFailure")
00151 << "Failed to find a L1GctJetCalibFunRcd:L1GctJetEtCalibrationFunction in EventSetup!" << std::endl;
00152 }
00153 }
00154
00155 if (hfLSetup.product() == 0) {
00156 success = -1;
00157 if (m_verbose) {
00158 edm::LogWarning("L1GctConfigFailure")
00159 << "Failed to find a L1GctHfLutSetupRcd:L1GctHfLutSetup in EventSetup!" << std::endl;
00160 }
00161 }
00162
00163 if (chanMask.product() == 0) {
00164 success = -1;
00165 if (m_verbose) {
00166 edm::LogWarning("L1GctConfigFailure")
00167 << "Failed to find a L1GctChannelMaskRcd:L1GctChannelMask in EventSetup!" << std::endl;
00168 }
00169 }
00170
00171 if (success==0) {
00172
00173 for (unsigned ieta=0; ieta<m_jetEtCalibLuts.size(); ieta++) {
00174 m_jetEtCalibLuts.at(ieta)->setFunction(calibFun.product());
00175 m_jetEtCalibLuts.at(ieta)->setOutputEtScale(etScale.product());
00176 }
00177
00178
00179
00180 m_gct->setJetEtCalibrationLuts(m_jetEtCalibLuts);
00181 m_gct->setJetFinderParams(jfPars.product());
00182 m_gct->setupJetCounterLuts(jcPosPars.product(), jcNegPars.product());
00183 m_gct->setupHfSumLuts(hfLSetup.product());
00184 m_gct->setChannelMask(chanMask.product());
00185 }
00186 }
00187
00188 if (success != 0 && m_verbose) {
00189 edm::LogError("L1GctConfigError")
00190 << "Configuration failed - GCT emulator will not be run" << std::endl;
00191 }
00192 return success;
00193 }
00194
00195 void L1GctEmulator::produce(edm::Event& e, const edm::EventSetup& c) {
00196
00197
00198
00199 if (configureGct(c) == 0) {
00200
00201
00202 edm::Handle<L1CaloEmCollection> em;
00203 edm::Handle<L1CaloRegionCollection> rgn;
00204 e.getByLabel(m_inputLabel, em);
00205 e.getByLabel(m_inputLabel, rgn);
00206
00207
00208 m_gct->reset();
00209
00210
00211 m_gct->fillEmCands(*em);
00212 m_gct->fillRegions(*rgn);
00213
00214
00215 m_gct->process();
00216
00217
00218 std::auto_ptr<L1GctEmCandCollection> isoEmResult (new L1GctEmCandCollection(m_gct->getIsoElectrons() ) );
00219 std::auto_ptr<L1GctEmCandCollection> nonIsoEmResult(new L1GctEmCandCollection(m_gct->getNonIsoElectrons() ) );
00220 std::auto_ptr<L1GctJetCandCollection> cenJetResult(new L1GctJetCandCollection(m_gct->getCentralJets() ) );
00221 std::auto_ptr<L1GctJetCandCollection> forJetResult(new L1GctJetCandCollection(m_gct->getForwardJets() ) );
00222 std::auto_ptr<L1GctJetCandCollection> tauJetResult(new L1GctJetCandCollection(m_gct->getTauJets() ) );
00223
00224
00225 std::auto_ptr<L1GctEtTotalCollection> etTotResult (new L1GctEtTotalCollection(m_gct->getEtSumCollection() ) );
00226 std::auto_ptr<L1GctEtHadCollection> etHadResult (new L1GctEtHadCollection (m_gct->getEtHadCollection() ) );
00227 std::auto_ptr<L1GctEtMissCollection> etMissResult(new L1GctEtMissCollection (m_gct->getEtMissCollection() ) );
00228 std::auto_ptr<L1GctEtMissCollection> htMissResult(new L1GctEtMissCollection (m_gct->getHtMissCollection() ) );
00229
00230
00231 std::auto_ptr<L1GctJetCountsCollection> jetCountResult(new L1GctJetCountsCollection(m_gct->getJetCountsCollection() ) );
00232
00233
00234 std::auto_ptr<L1GctHFBitCountsCollection> hfBitCountResult (new L1GctHFBitCountsCollection (m_gct->getHFBitCountsCollection () ) );
00235 std::auto_ptr<L1GctHFRingEtSumsCollection> hfRingEtSumResult(new L1GctHFRingEtSumsCollection(m_gct->getHFRingEtSumsCollection() ) );
00236
00237
00238 e.put(isoEmResult,"isoEm");
00239 e.put(nonIsoEmResult,"nonIsoEm");
00240 e.put(cenJetResult,"cenJets");
00241 e.put(forJetResult,"forJets");
00242 e.put(tauJetResult,"tauJets");
00243 e.put(etTotResult);
00244 e.put(etHadResult);
00245 e.put(etMissResult);
00246 e.put(htMissResult,"missingHt");
00247 e.put(jetCountResult);
00248 e.put(hfBitCountResult);
00249 e.put(hfRingEtSumResult);
00250 }
00251 }
00252
00253 DEFINE_FWK_MODULE(L1GctEmulator);
00254