CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/EventFilter/SiStripRawToDigi/plugins/ExcludedFEDListProducer.cc

Go to the documentation of this file.
00001 #include "EventFilter/SiStripRawToDigi/plugins/ExcludedFEDListProducer.h"
00002 #include "DataFormats/Common/interface/DetSet.h"
00003 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00004 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00005 #include "DataFormats/FEDRawData/src/fed_header.h"
00006 #include "DataFormats/FEDRawData/src/fed_trailer.h"
00007 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00008 #include "DataFormats/SiStripCommon/interface/SiStripEventSummary.h"
00009 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00010 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
00011 #include "EventFilter/SiStripRawToDigi/interface/TFHeaderDescription.h"
00012 #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
00013 #include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h"
00014 #include "FWCore/Utilities/interface/Exception.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016 #include <iostream>
00017 #include <sstream>
00018 #include <iomanip>
00019 #include <ext/algorithm>
00020 
00021 namespace sistrip {
00022 
00023   ExcludedFEDListProducer::ExcludedFEDListProducer( const edm::ParameterSet& pset ) :
00024     runNumber_(0),
00025     productLabel_(pset.getParameter<edm::InputTag>("ProductLabel")),
00026     cabling_(0),
00027     cacheId_(0)
00028   {
00029     produces<DetIdCollection>();
00030   }
00031   
00032   ExcludedFEDListProducer::~ExcludedFEDListProducer()
00033   {
00034   }
00035   
00036   void ExcludedFEDListProducer::beginJob( const edm::EventSetup & )
00037   {
00038   }
00039   
00040   void ExcludedFEDListProducer::beginRun( edm::Run & run, const edm::EventSetup & es)
00041   {
00042     uint32_t cacheId = es.get<SiStripFedCablingRcd>().cacheIdentifier();
00043     
00044     if ( cacheId_ != cacheId ) {
00045       
00046       edm::ESHandle<SiStripFedCabling> c;
00047       es.get<SiStripFedCablingRcd>().get( c );
00048       cabling_ = c.product();
00049     }
00050   }
00051   
00052   void ExcludedFEDListProducer::endJob()
00053   {
00054   }
00055   
00056   void ExcludedFEDListProducer::produce( edm::Event& event, const edm::EventSetup& es)
00057   {
00058     if( runNumber_ != event.run() ) {
00059     
00060       runNumber_ = event.run();
00061 
00062       DetIdCollection emptyDetIdCollection;
00063       detids_.swap(emptyDetIdCollection);
00064       // Reserve space in bad module list
00065       detids_.reserve(100);
00066     
00067       edm::Handle<FEDRawDataCollection> buffers;
00068       event.getByLabel( productLabel_, buffers ); 
00069  
00070       // Retrieve FED ids from cabling map and iterate through 
00071       std::vector<uint16_t>::const_iterator ifed = cabling_->feds().begin();
00072       for ( ; ifed != cabling_->feds().end(); ifed++ ) {
00073       
00074         // ignore trigger FED
00075         // if ( *ifed == triggerFedId_ ) { continue; }
00076         
00077         // Retrieve FED raw data for given FED 
00078         const FEDRawData& input = buffers->FEDData( static_cast<int>(*ifed) );
00079         // The FEDData contains a vector<unsigned char>. Check the size of this vector:
00080         
00081         if( input.size() == 0 ) {
00082           // std::cout << "Input size == 0 for FED number " << static_cast<int>(*ifed) << std::endl;
00083           // get the cabling connections for this FED
00084           const std::vector<FedChannelConnection>& conns = cabling_->connections(*ifed);
00085           // Mark FED modules as bad
00086           detids_.reserve(detids_.size()+conns.size());
00087           std::vector<FedChannelConnection>::const_iterator iconn = conns.begin();
00088           for ( ; iconn != conns.end(); ++iconn ) {
00089             if ( !iconn->detId() || iconn->detId() == sistrip::invalid32_ ) continue;
00090             detids_.push_back(iconn->detId()); //@@ Possible multiple entries
00091           }
00092         }
00093       }
00094     }
00095 
00096     std::auto_ptr< DetIdCollection > detids( new DetIdCollection(detids_) );
00097 
00098     // for( unsigned int it = 0; it < detids->size(); ++it ) {
00099     //   std::cout << "detId = " << (*detids)[it]() << std::endl;
00100     // }
00101 
00102     event.put(detids);
00103   }
00104 }