CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/L1Trigger/HardwareValidation/plugins/MuonCandProducerMon.cc

Go to the documentation of this file.
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",
00015             (edm::InputTag) ("csctfdigis"));
00016     DTinput_ = pset.getUntrackedParameter<edm::InputTag>("DTinput",
00017             (edm::InputTag) ("dttfdigis"));
00018 
00019     cscPtLUT_ = 0;
00020     m_scalesCacheID = 0;
00021     m_ptScaleCacheID = 0;
00022 
00023     produces<std::vector<L1MuRegionalCand> >("CSC");
00024     produces<std::vector<L1MuRegionalCand> >("DT");
00025 }
00026 
00027 MuonCandProducerMon::~MuonCandProducerMon() {
00028 }
00029 
00030 void MuonCandProducerMon::endJob() {
00031     if (cscPtLUT_)
00032         delete cscPtLUT_;
00033 }
00034 
00035 void MuonCandProducerMon::produce(edm::Event& iEvent,
00036         const edm::EventSetup& iSetup) {
00037 
00038     edm::Handle<L1CSCTrackCollection> CSCtracks;
00039     iEvent.getByLabel(CSCinput_, CSCtracks);
00040 
00041     edm::Handle<L1MuDTTrackContainer> DTtracks;
00042     iEvent.getByLabel(DTinput_, DTtracks);
00043 
00044     std::auto_ptr<std::vector<L1MuRegionalCand> > csc_product(
00045             new std::vector<L1MuRegionalCand>);
00046 
00047     std::auto_ptr<std::vector<L1MuRegionalCand> > dt_product(
00048             new std::vector<L1MuRegionalCand>);
00049 
00050     if (!CSCtracks.isValid()) {
00051 
00052         csc_product->push_back(L1MuRegionalCand());
00053 
00054     } else {
00055 
00056         typedef L1CSCTrackCollection::const_iterator ctcIt;
00057 
00058         for (ctcIt tcit = CSCtracks->begin(); tcit != CSCtracks->end(); tcit++) {
00059 
00060             L1MuRegionalCand cand(tcit->first.getDataWord(), tcit->first.bx());
00061 
00062             // set pt value
00063 
00064             // Update CSCTFTrackBuilder only if the scales have changed.  Use the
00065             // EventSetup cacheIdentifier to tell when this has happened.
00066             if (iSetup.get<L1MuTriggerScalesRcd>().cacheIdentifier()
00067                     != m_scalesCacheID
00068                     || iSetup.get<L1MuTriggerPtScaleRcd>().cacheIdentifier()
00069                             != m_ptScaleCacheID) {
00070                 if (cscPtLUT_)
00071                     delete cscPtLUT_;
00072                 edm::ESHandle<L1MuTriggerScales> scales;
00073                 iSetup.get<L1MuTriggerScalesRcd>().get(scales);
00074                 edm::ESHandle<L1MuTriggerPtScale> ptScale;
00075                 iSetup.get<L1MuTriggerPtScaleRcd>().get(ptScale);
00076                 // Create a dummy pset for CSC Pt LUTs
00077 
00078                 edm::ParameterSet ptLUTset;
00079                 ptLUTset.addParameter<bool>("ReadPtLUT", false);
00080                 ptLUTset.addParameter<bool>("isBinary", false);
00081                 ptLUTset.addUntrackedParameter<std::string>("LUTPath", "./");
00082 
00083                 cscPtLUT_ = new CSCTFPtLUT(ptLUTset, scales.product(),
00084                         ptScale.product());
00085                 m_scalesCacheID
00086                         = iSetup.get<L1MuTriggerScalesRcd>().cacheIdentifier();
00087                 m_ptScaleCacheID
00088                         = iSetup.get<L1MuTriggerPtScaleRcd>().cacheIdentifier();
00089             }
00090 
00091             ptadd thePtAddress(tcit->first.ptLUTAddress());
00092             ptdat thePtData = cscPtLUT_->Pt(thePtAddress);
00093             const unsigned int rank =
00094                     (thePtAddress.track_fr ? thePtData.front_rank
00095                             : thePtData.rear_rank);
00096             unsigned int quality = 0;
00097             unsigned int pt = 0;
00098             csc::L1Track::decodeRank(rank, pt, quality);
00099             cand.setQualityPacked(quality & 0x3);
00100             cand.setPtPacked(pt & 0x1f);
00101             csc_product->push_back(cand);
00102         }
00103     }
00104 
00105     if (!DTtracks.isValid()) {
00106 
00107         dt_product->push_back(L1MuRegionalCand());
00108 
00109     } else {
00110 
00111         typedef std::vector<L1MuDTTrackCand>::const_iterator ctcIt;
00112 
00113         std::vector<L1MuDTTrackCand> *dttc = DTtracks->getContainer();
00114 
00115         for (ctcIt it = dttc->begin(); it != dttc->end(); it++) {
00116             dt_product->push_back(L1MuRegionalCand(*it));
00117         }
00118     }
00119 
00120     iEvent.put(csc_product, "CSC");
00121     iEvent.put(dt_product, "DT");
00122 }
00123