00001 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTInputProducer.h"
00002
00003 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00004 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00005
00006 #include "CondFormats/L1TObjects/interface/L1CaloHcalScale.h"
00007 #include "CondFormats/DataRecord/interface/L1CaloHcalScaleRcd.h"
00008 #include "CondFormats/L1TObjects/interface/L1CaloEcalScale.h"
00009 #include "CondFormats/DataRecord/interface/L1CaloEcalScaleRcd.h"
00010
00011 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
00012 #include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h"
00013
00014 #include "CondFormats/L1TObjects/interface/L1RCTParameters.h"
00015 #include "CondFormats/DataRecord/interface/L1RCTParametersRcd.h"
00016
00017 #include "CondFormats/L1TObjects/interface/L1RCTChannelMask.h"
00018 #include "CondFormats/DataRecord/interface/L1RCTChannelMaskRcd.h"
00019
00020 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCT.h"
00021 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTLookupTables.h"
00022
00023 #include <vector>
00024 using std::vector;
00025
00026 #include <iostream>
00027 using std::cout;
00028 using std::endl;
00029
00030 L1RCTInputProducer::L1RCTInputProducer(const edm::ParameterSet& conf) :
00031 rctLookupTables(new L1RCTLookupTables),
00032 rct(new L1RCT(rctLookupTables)),
00033 useEcal(conf.getParameter<bool>("useEcal")),
00034 useHcal(conf.getParameter<bool>("useHcal")),
00035 ecalDigisLabel(conf.getParameter<edm::InputTag>("ecalDigisLabel")),
00036 hcalDigisLabel(conf.getParameter<edm::InputTag>("hcalDigisLabel"))
00037 {
00038 produces<vector<unsigned short> >("rctCrate");
00039 produces<vector<unsigned short> >("rctCard");
00040 produces<vector<unsigned short> >("rctTower");
00041 produces<vector<unsigned int> >("rctEGammaET");
00042 produces<vector<bool> >("rctHoEFGVetoBit");
00043 produces<vector<unsigned int> >("rctJetMETET");
00044 produces<vector<bool> >("rctTowerActivityBit");
00045 produces<vector<bool> >("rctTowerMIPBit");
00046 produces<vector<unsigned short> >("rctHFCrate");
00047 produces<vector<unsigned short> >("rctHFRegion");
00048 produces<vector<unsigned int> >("rctHFET");
00049 produces<vector<bool> >("rctHFFG");
00050 }
00051
00052 L1RCTInputProducer::~L1RCTInputProducer()
00053 {
00054 if(rct != 0) delete rct;
00055 if(rctLookupTables != 0) delete rctLookupTables;
00056 }
00057
00058 void L1RCTInputProducer::beginJob(const edm::EventSetup& eventSetup)
00059 {
00060 }
00061
00062 void L1RCTInputProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup)
00063 {
00064
00065
00066
00067
00068
00069
00070 edm::ESHandle<L1RCTParameters> rctParameters;
00071 eventSetup.get<L1RCTParametersRcd>().get(rctParameters);
00072 const L1RCTParameters* r = rctParameters.product();
00073 edm::ESHandle<L1RCTChannelMask> channelMask;
00074 eventSetup.get<L1RCTChannelMaskRcd>().get(channelMask);
00075 const L1RCTChannelMask* c = channelMask.product();
00076 edm::ESHandle<L1CaloEcalScale> ecalScale;
00077 eventSetup.get<L1CaloEcalScaleRcd>().get(ecalScale);
00078 const L1CaloEcalScale* e = ecalScale.product();
00079 edm::ESHandle<L1CaloHcalScale> hcalScale;
00080 eventSetup.get<L1CaloHcalScaleRcd>().get(hcalScale);
00081 const L1CaloHcalScale* h = hcalScale.product();
00082 edm::ESHandle<L1CaloEtScale> emScale;
00083 eventSetup.get<L1EmEtScaleRcd>().get(emScale);
00084 const L1CaloEtScale* s = emScale.product();
00085
00086 rctLookupTables->setRCTParameters(r);
00087 rctLookupTables->setChannelMask(c);
00088 rctLookupTables->setHcalScale(h);
00089 rctLookupTables->setEcalScale(e);
00090 rctLookupTables->setL1CaloEtScale(s);
00091
00092 edm::Handle<EcalTrigPrimDigiCollection> ecal;
00093 edm::Handle<HcalTrigPrimDigiCollection> hcal;
00094
00095 if (useEcal) { event.getByLabel(ecalDigisLabel, ecal); }
00096 if (useHcal) { event.getByLabel(hcalDigisLabel, hcal); }
00097
00098 EcalTrigPrimDigiCollection ecalColl;
00099 HcalTrigPrimDigiCollection hcalColl;
00100 if (ecal.isValid()) { ecalColl = *ecal; }
00101 if (hcal.isValid()) { hcalColl = *hcal; }
00102
00103 rct->digiInput(ecalColl, hcalColl);
00104
00105
00106
00107 std::auto_ptr<std::vector<unsigned short> >
00108 rctCrate(new vector<unsigned short>);
00109 std::auto_ptr<std::vector<unsigned short> >
00110 rctCard(new vector<unsigned short>);
00111 std::auto_ptr<std::vector<unsigned short> >
00112 rctTower(new vector<unsigned short>);
00113 std::auto_ptr<std::vector<unsigned int> >
00114 rctEGammaET(new vector<unsigned int>);
00115 std::auto_ptr<std::vector<bool> > rctHoEFGVetoBit(new vector<bool>);
00116 std::auto_ptr<std::vector<unsigned int> >
00117 rctJetMETET(new vector<unsigned int>);
00118 std::auto_ptr<std::vector<bool> > rctTowerActivityBit(new vector<bool>);
00119 std::auto_ptr<std::vector<bool> > rctTowerMIPBit(new vector<bool>);
00120
00121 for(int crate = 0; crate < 18; crate++) {
00122 for(int card = 0; card < 7; card++) {
00123 for(int tower = 0; tower < 32; tower++) {
00124 unsigned short ecalCompressedET =
00125 rct->ecalCompressedET(crate, card, tower);
00126 unsigned short ecalFineGrainBit =
00127 rct->ecalFineGrainBit(crate, card, tower);
00128 unsigned short hcalCompressedET =
00129 rct->hcalCompressedET(crate, card, tower);
00130 unsigned int lutBits =
00131 rctLookupTables->lookup(ecalCompressedET, hcalCompressedET,
00132 ecalFineGrainBit, crate, card, tower);
00133 unsigned int eGammaETCode = lutBits & 0x0000007F;
00134 bool hOeFGVetoBit = (lutBits >> 7) & 0x00000001;
00135 unsigned int jetMETETCode = (lutBits >> 8) & 0x000001FF;
00136 bool activityBit = (lutBits >> 17) & 0x00000001;
00137 if(eGammaETCode > 0 || jetMETETCode > 0 ||
00138 hOeFGVetoBit || activityBit) {
00139 rctCrate->push_back(crate);
00140 rctCard->push_back(card);
00141 rctTower->push_back(tower);
00142 rctEGammaET->push_back(eGammaETCode);
00143 rctHoEFGVetoBit->push_back(hOeFGVetoBit);
00144 rctJetMETET->push_back(jetMETETCode);
00145 rctTowerActivityBit->push_back(activityBit);
00146 rctTowerMIPBit->push_back(0);
00147 }
00148 }
00149 }
00150 }
00151
00152 std::auto_ptr<std::vector<unsigned short> >
00153 rctHFCrate(new vector<unsigned short>);
00154 std::auto_ptr<std::vector<unsigned short> >
00155 rctHFRegion(new vector<unsigned short>);
00156 std::auto_ptr<std::vector<unsigned int> > rctHFET(new vector<unsigned int>);
00157 std::auto_ptr<std::vector<bool> > rctHFFG(new vector<bool>);
00158 for(int crate = 0; crate < 18; crate++) {
00159 for(int hfRegion = 0; hfRegion < 8; hfRegion++) {
00160 unsigned short hfCompressedET = rct->hfCompressedET(crate, hfRegion);
00161 unsigned int hfETCode =
00162 rctLookupTables->lookup(hfCompressedET, crate, 999, hfRegion);
00163 if(hfETCode > 0) {
00164 rctHFCrate->push_back(crate);
00165 rctHFRegion->push_back(hfRegion);
00166 rctHFET->push_back(hfETCode);
00167 rctHFFG->push_back(0);
00168 }
00169 }
00170 }
00171
00172
00173 event.put(rctCrate, "rctCrate");
00174 event.put(rctCard, "rctCard");
00175 event.put(rctTower, "rctTower");
00176 event.put(rctEGammaET, "rctEGammaET");
00177 event.put(rctHoEFGVetoBit, "rctHoEFGVetoBit");
00178 event.put(rctJetMETET, "rctJetMETET");
00179 event.put(rctTowerActivityBit, "rctTowerActivityBit");
00180 event.put(rctTowerMIPBit, "rctTowerMIPBit");
00181 event.put(rctHFCrate, "rctHFCrate");
00182 event.put(rctHFRegion, "rctHFRegion");
00183 event.put(rctHFET, "rctHFET");
00184 event.put(rctHFFG, "rctHFFG");
00185
00186 }