00001 #include <L1Trigger/HardwareValidation/plugins/MuonCandProducerMon.h>
00002
00003 #include "FWCore/Framework/interface/ESHandle.h"
00004
00005 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
00006 #include "CondFormats/DataRecord/interface/L1MuTriggerScalesRcd.h"
00007 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
00008 #include "CondFormats/DataRecord/interface/L1MuTriggerPtScaleRcd.h"
00009
00010 MuonCandProducerMon::MuonCandProducerMon(const edm::ParameterSet& pset) {
00011
00012 verbose_ = pset.getUntrackedParameter<int>("VerboseFlag",0);
00013
00014 CSCinput_ = pset.getUntrackedParameter<edm::InputTag>("CSCinput",(edm::InputTag)("csctfdigis"));
00015 DTinput_ = pset.getUntrackedParameter<edm::InputTag>("DTinput",(edm::InputTag)("dttfdigis"));
00016
00017 cscPtLUT_ = 0;
00018 m_scalesCacheID = 0;
00019 m_ptScaleCacheID = 0;
00020
00021 produces<std::vector<L1MuRegionalCand> >("CSC");
00022 produces<std::vector<L1MuRegionalCand> >("DT");
00023 }
00024
00025 MuonCandProducerMon::~MuonCandProducerMon(){}
00026
00027 void MuonCandProducerMon::beginJob(const edm::EventSetup&) {}
00028
00029 void MuonCandProducerMon::endJob() {
00030 if( cscPtLUT_ ) delete cscPtLUT_;
00031 }
00032
00033 void
00034 MuonCandProducerMon::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00035
00036 edm::Handle<L1CSCTrackCollection> CSCtracks;
00037 iEvent.getByLabel(CSCinput_, CSCtracks);
00038
00039 edm::Handle<L1MuDTTrackContainer> DTtracks;
00040 iEvent.getByLabel(DTinput_, DTtracks);
00041
00042 std::auto_ptr<std::vector<L1MuRegionalCand> >
00043 csc_product(new std::vector<L1MuRegionalCand>);
00044
00045 std::auto_ptr<std::vector<L1MuRegionalCand> >
00046 dt_product(new std::vector<L1MuRegionalCand>);
00047
00048
00049 if(!CSCtracks.isValid()) {
00050
00051 csc_product->push_back(L1MuRegionalCand());
00052
00053 } else {
00054
00055 typedef L1CSCTrackCollection::const_iterator ctcIt;
00056
00057 for(ctcIt tcit=CSCtracks->begin(); tcit!=CSCtracks->end(); tcit++) {
00058
00059 L1MuRegionalCand cand(tcit->first.getDataWord(), tcit->first.bx());
00060
00061
00062
00063
00064
00065 if( iSetup.get< L1MuTriggerScalesRcd >().cacheIdentifier() != m_scalesCacheID ||
00066 iSetup.get< L1MuTriggerPtScaleRcd >().cacheIdentifier() != m_ptScaleCacheID ) {
00067 if( cscPtLUT_ ) delete cscPtLUT_;
00068 edm::ESHandle< L1MuTriggerScales > scales ;
00069 iSetup.get< L1MuTriggerScalesRcd >().get( scales ) ;
00070 edm::ESHandle< L1MuTriggerPtScale > ptScale ;
00071 iSetup.get< L1MuTriggerPtScaleRcd >().get( ptScale ) ;
00072
00073 edm::ParameterSet ptLUTset;
00074 ptLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
00075 ptLUTset.addUntrackedParameter<bool>("Binary", false);
00076 ptLUTset.addUntrackedParameter<std::string>("LUTPath", "./");
00077 cscPtLUT_ = new CSCTFPtLUT(ptLUTset,scales.product(),ptScale.product());
00078 m_scalesCacheID = iSetup.get< L1MuTriggerScalesRcd >().cacheIdentifier() ;
00079 m_ptScaleCacheID = iSetup.get< L1MuTriggerPtScaleRcd >().cacheIdentifier() ;
00080 }
00081
00082 ptadd thePtAddress(tcit->first.ptLUTAddress());
00083 ptdat thePtData = cscPtLUT_->Pt(thePtAddress);
00084 const unsigned int rank =
00085 ( thePtAddress.track_fr ? thePtData.front_rank : thePtData.rear_rank );
00086 unsigned int quality = 0;
00087 unsigned int pt = 0;
00088 csc::L1Track::decodeRank(rank, pt, quality);
00089 cand.setQualityPacked(quality & 0x3);
00090 cand.setPtPacked(pt & 0x1f);
00091 csc_product->push_back(cand);
00092 }
00093 }
00094
00095 if(!DTtracks.isValid()) {
00096
00097 dt_product->push_back(L1MuRegionalCand());
00098
00099 } else {
00100
00101 typedef std::vector<L1MuDTTrackCand>::const_iterator ctcIt;
00102
00103 std::vector<L1MuDTTrackCand> *dttc = DTtracks->getContainer();
00104
00105 for(ctcIt it=dttc->begin(); it!=dttc->end(); it++) {
00106 dt_product->push_back(L1MuRegionalCand(*it));
00107 }
00108 }
00109
00110 iEvent.put(csc_product,"CSC");
00111 iEvent.put(dt_product,"DT");
00112 }
00113