CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/SimCalorimetry/HcalTrigPrimProducers/src/HcalTTPTriggerRecord.cc

Go to the documentation of this file.
00001 #include "SimCalorimetry/HcalTrigPrimProducers/src/HcalTTPTriggerRecord.h"
00002 
00003 #include "DataFormats/HcalDigi/interface/HcalTTPDigi.h"
00004 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00005 #include "DataFormats/L1GlobalTrigger/interface/L1GtTechnicalTriggerRecord.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "FWCore/Framework/interface/ESHandle.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 
00010 HcalTTPTriggerRecord::HcalTTPTriggerRecord(const edm::ParameterSet& ps) 
00011 {
00012     ttpDigis_ = ps.getParameter<edm::InputTag>("ttpDigiCollection") ; 
00013     ttpBits_  = ps.getParameter< std::vector<unsigned int> >("ttpBits");
00014     names_    = ps.getParameter< std::vector<std::string> >("ttpBitNames");
00015 
00016     produces<L1GtTechnicalTriggerRecord>();
00017 }
00018 
00019 
00020 HcalTTPTriggerRecord::~HcalTTPTriggerRecord() {
00021 }
00022 
00023 void HcalTTPTriggerRecord::produce(edm::Event& e, const edm::EventSetup& eventSetup) {
00024 
00025     std::vector<L1GtTechnicalTrigger> vecTT(ttpBits_.size()) ;
00026 
00027     // Get Inputs
00028     edm::Handle<HcalTTPDigiCollection> ttpDigiCollection ; 
00029     e.getByLabel(ttpDigis_,ttpDigiCollection) ;
00030 
00031     if ( !ttpDigiCollection.failedToGet() ) { 
00032         const HcalTTPDigiCollection* ttpDigis = ttpDigiCollection.product() ; 
00033         uint8_t ttpResults = ttpDigis->begin()->triggerOutput() ;
00034         bool bit8  = ttpResults & 0x1 ; 
00035         bool bit9  = ttpResults & 0x2 ; 
00036         bool bit10 = ttpResults & 0x4 ;
00037 
00038         for (unsigned int i=0; i<ttpBits_.size(); i++) {
00039             bool bitValue = false ; 
00040             if ( ttpBits_.at(i) == 8 ) bitValue = bit8 ;  
00041             if ( ttpBits_.at(i) == 9 ) bitValue = bit9 ;  
00042             if ( ttpBits_.at(i) == 10 ) bitValue = bit10 ;  
00043             vecTT.at(i) = L1GtTechnicalTrigger(names_.at(i), ttpBits_.at(i), 0, bitValue) ;
00044         }
00045     } else {
00046         vecTT.clear() ;
00047     }
00048 
00049     // Put output into event
00050     std::auto_ptr<L1GtTechnicalTriggerRecord> output(new L1GtTechnicalTriggerRecord()) ;
00051     output->setGtTechnicalTrigger(vecTT) ;    
00052     e.put(output) ;
00053 }
00054