#include <EventFilter/SiStripRawToDigi/interface/SiStripRawToClustersLazyUnpacker.h>
Public Types | |
typedef edm::DetSet < SiStripCluster > | DetSet |
Public Member Functions | |
virtual void | fill (const uint32_t &, record_type &) |
SiStripRawToClustersLazyUnpacker (const SiStripRegionCabling &, const SiStripClusterizerFactory &, const FEDRawDataCollection &) | |
virtual | ~SiStripRawToClustersLazyUnpacker () |
Private Member Functions | |
SiStripRawToClustersLazyUnpacker () | |
Private Attributes | |
const SiStripClusterizerFactory * | clusterizer_ |
Clusterizer Factory. | |
std::vector< Fed9U::Fed9UEvent * > | fedEvents_ |
Fed9UEvent cache. | |
std::vector < sistrip::FedReadoutMode > | fedModes_ |
Fed9UEvent readout mode. | |
std::list< FEDRawData > | fedRawData_ |
Cache of buffers pointed to by FED9UEvent. | |
const FEDRawDataCollection * | raw_ |
Raw data. | |
SiStripRawToDigiUnpacker | rawToDigi_ |
RawToDigi. | |
const SiStripRegionCabling::Cabling * | regions_ |
Cabling. |
Definition at line 16 of file SiStripRawToClustersLazyUnpacker.h.
Definition at line 20 of file SiStripRawToClustersLazyUnpacker.h.
SiStripRawToClustersLazyUnpacker::SiStripRawToClustersLazyUnpacker | ( | const SiStripRegionCabling & | regioncabling, | |
const SiStripClusterizerFactory & | clustfact, | |||
const FEDRawDataCollection & | data | |||
) |
Definition at line 7 of file SiStripRawToClustersLazyUnpacker.cc.
References fedEvents_, fedModes_, and sistrip::UNDEFINED_FED_READOUT_MODE.
00007 : 00008 00009 raw_(&data), 00010 regions_(&(regioncabling.getRegionCabling())), 00011 clusterizer_(&clustfact), 00012 fedEvents_(), 00013 fedModes_(), 00014 rawToDigi_(0,0,0,0,0), 00015 fedRawData_() 00016 { 00017 fedEvents_.assign(1024,static_cast<Fed9U::Fed9UEvent*>(0)); 00018 fedModes_.assign(1024,sistrip::UNDEFINED_FED_READOUT_MODE); 00019 }
SiStripRawToClustersLazyUnpacker::~SiStripRawToClustersLazyUnpacker | ( | ) | [virtual] |
Definition at line 21 of file SiStripRawToClustersLazyUnpacker.cc.
References fedEvents_.
00021 { 00022 00023 std::vector< Fed9U::Fed9UEvent*>::iterator ifedevent = fedEvents_.begin(); 00024 for (; ifedevent!=fedEvents_.end(); ifedevent++) { 00025 if (*ifedevent) { 00026 delete (*ifedevent); 00027 *ifedevent = 0; 00028 } 00029 } 00030 }
SiStripRawToClustersLazyUnpacker::SiStripRawToClustersLazyUnpacker | ( | ) | [private] |
void SiStripRawToClustersLazyUnpacker::fill | ( | const uint32_t & | index, | |
record_type & | record | |||
) | [virtual] |
Definition at line 32 of file SiStripRawToClustersLazyUnpacker.cc.
References SiStripClusterizerAlgo::add(), addr, SiStripClusterizerFactory::algorithm(), clusterizer_, element(), SiStripClusterizerAlgo::endDet(), sistrip::FED_ZERO_SUPPR, sistrip::FED_ZERO_SUPPR_LITE, FEDRawDataCollection::FEDData(), fedEvents_, fedModes_, fedRawData_, SiStripRawToDigiUnpacker::fedReadoutMode(), SiStripRawToDigiUnpacker::handleException(), i, iggi_31X_cfg::input, sistrip::invalid32_, edm::isDebugEnabled(), SiStripRegionCabling::layer(), SiStripRawToDigiUnpacker::locateStartOfFedBuffer(), sistrip::mlRawToCluster_, sistrip::mlRawToDigi_, raw_, rawToDigi_, SiStripRegionCabling::region(), ss, strip(), SiStripRegionCabling::subdet(), sistrip::UNDEFINED_FED_READOUT_MODE, and width.
00032 { 00033 00034 // Get region, subdet and layer from element-index 00035 uint32_t region = SiStripRegionCabling::region(index); 00036 uint32_t subdet = static_cast<uint32_t>(SiStripRegionCabling::subdet(index)); 00037 uint32_t layer = SiStripRegionCabling::layer(index); 00038 00039 // Retrieve cabling for element 00040 const SiStripRegionCabling::ElementCabling& element = (*regions_)[region][subdet][layer]; 00041 00042 // Loop dets 00043 SiStripRegionCabling::ElementCabling::const_iterator idet = element.begin(); 00044 for (;idet!=element.end();idet++) { 00045 00046 // If det id is null or invalid continue. 00047 if ( !(idet->first) || (idet->first == sistrip::invalid32_) ) { continue; } 00048 00049 // Loop over apv-pairs of det 00050 std::vector<FedChannelConnection>::const_iterator iconn = idet->second.begin(); 00051 for (;iconn!=idet->second.end();iconn++) { 00052 00053 // If fed id is null or connection is invalid continue 00054 if ( !iconn->fedId() || !iconn->isConnected() ) { continue; } 00055 00056 // If Fed hasnt already been initialised, extract data and initialise 00057 if (!fedEvents_[iconn->fedId()]) { 00058 00059 // Retrieve FED raw data for given FED 00060 const FEDRawData& input = raw_->FEDData( static_cast<int>(iconn->fedId()) ); 00061 00062 // Cache new correctly-ordered FEDRawData object (to maintain scope for Fed9UEvent) 00063 fedRawData_.push_back( FEDRawData() ); 00064 rawToDigi_.locateStartOfFedBuffer( iconn->fedId(), input, fedRawData_.back() ); 00065 00066 // Recast data to suit Fed9UEvent 00067 Fed9U::u32* data_u32 = reinterpret_cast<Fed9U::u32*>( const_cast<unsigned char*>( fedRawData_.back().data() ) ); 00068 Fed9U::u32 size_u32 = static_cast<Fed9U::u32>( fedRawData_.back().size() / 4 ); 00069 00070 // Check on FEDRawData pointer 00071 if ( !data_u32 ) { 00072 if ( edm::isDebugEnabled() ) { 00073 edm::LogWarning(mlRawToCluster_) 00074 << "[SiStripRawToClustersLazyGetter::" 00075 << __func__ 00076 << "]" 00077 << " NULL pointer to FEDRawData for FED id " 00078 << iconn->fedId(); 00079 } 00080 continue; 00081 } 00082 00083 // Check on FEDRawData size 00084 if ( !size_u32 ) { 00085 if ( edm::isDebugEnabled() ) { 00086 edm::LogWarning(mlRawToCluster_) 00087 << "[SiStripRawToClustersLazyGetter::" 00088 << __func__ << "]" 00089 << " FEDRawData has zero size for FED id " 00090 << iconn->fedId(); 00091 } 00092 continue; 00093 } 00094 00095 // Construct Fed9UEvent using present FED buffer 00096 try { 00097 fedEvents_[iconn->fedId()] = new Fed9U::Fed9UEvent(data_u32,0,size_u32); 00098 } catch(...) { 00099 rawToDigi_.handleException( __func__, "Problem when constructing Fed9UEvent" ); 00100 if ( fedEvents_[iconn->fedId()] ) { delete fedEvents_[iconn->fedId()]; } 00101 fedEvents_[iconn->fedId()] = 0; 00102 fedModes_[iconn->fedId()] = sistrip::UNDEFINED_FED_READOUT_MODE; 00103 continue; 00104 } 00105 00106 /* 00107 // Check Fed9UEvent 00108 try {fedEvents_[iconn->fedId()]->checkEvent();} 00109 catch(...) {rawToDigi_.handleException( __func__, "Problem when checking Fed9UEventStreamLine" );} 00110 */ 00111 00112 // Retrieve readout mode 00113 try {fedModes_[iconn->fedId()] = rawToDigi_.fedReadoutMode( static_cast<unsigned int>( fedEvents_[iconn->fedId()]->getSpecialTrackerEventType() ) );} 00114 catch(...) {rawToDigi_.handleException( __func__, "Problem extracting readout mode from Fed9UEvent" );} 00115 } 00116 00117 // Check readout mode is ZERO_SUPPRESSED or ZERO_SUPPRESSED_LITE 00118 if (fedModes_[iconn->fedId()] != sistrip::FED_ZERO_SUPPR && fedModes_[iconn->fedId()] != sistrip::FED_ZERO_SUPPR_LITE) { 00119 edm::LogWarning(sistrip::mlRawToCluster_) 00120 << "[SiStripRawClustersLazyGetter::" 00121 << __func__ 00122 << "]" 00123 << " Readout mode for FED id " 00124 << iconn->fedId() 00125 << " not zero-suppressed or zero-suppressed lite."; 00126 continue; 00127 } 00128 00129 // Calculate corresponding FED unit, channel 00130 uint16_t iunit = 0, ichan = 0, chan = 0; 00131 try { 00132 Fed9U::Fed9UAddress addr; 00133 addr.setFedChannel( static_cast<unsigned char>(iconn->fedCh())); 00134 iunit = addr.getFedFeUnit(); //0-7 (internal) 00135 ichan = addr.getFeUnitChannel(); //0-11 (internal) 00136 chan = 12*( iunit ) + ichan; //0-95 (internal) 00137 } catch(...) { 00138 rawToDigi_.handleException(__func__, "Problem using Fed9UAddress"); 00139 } 00140 00141 try { 00142 #ifdef USE_PATCH_TO_CATCH_CORRUPT_FED_DATA 00143 uint16_t last_strip = 0; 00144 uint16_t strips = 256 * iconn->nApvPairs(); 00145 #endif 00146 00147 Fed9U::Fed9UEventIterator fed_iter = const_cast<Fed9U::Fed9UEventChannel&>(fedEvents_[iconn->fedId()]->channel( iunit, ichan )).getIterator(); 00148 Fed9U::Fed9UEventIterator i = fed_iter+(fedModes_[iconn->fedId()] == sistrip::FED_ZERO_SUPPR ? 7 : 2); 00149 for (;i.size() > 0;) { 00150 uint16_t first_strip = iconn->apvPairNumber()*256 + *i++; 00151 unsigned char width = *i++; 00152 for ( uint16_t istr = 0; istr < ((uint16_t)width); istr++) { 00153 uint16_t strip = first_strip + istr; 00154 00155 #ifdef USE_PATCH_TO_CATCH_CORRUPT_FED_DATA 00156 if ( !( strip < strips && ( !strip || strip > last_strip ) ) ) { // check for corrupt FED data 00157 if ( edm::isDebugEnabled() ) { 00158 std::stringstream ss; 00159 ss << "[SiStripRawToDigiUnpacker::" << __func__ << "]" 00160 << " Corrupt FED data found for FED id " << iconn->fedId() 00161 << " and channel " << iconn->fedCh() 00162 << "! present strip: " << strip 00163 << " last strip: " << last_strip 00164 << " detector strips: " << strips; 00165 edm::LogWarning(mlRawToDigi_) << ss.str(); 00166 } 00167 continue; 00168 } 00169 last_strip = strip; 00170 #endif 00171 00172 clusterizer_->algorithm()->add(record,idet->first,strip,(uint16_t)(*i++)); 00173 } 00174 } 00175 } catch(...) { 00176 std::stringstream sss; 00177 sss << "Problem accessing data for FED id/ch: " 00178 << iconn->fedId() 00179 << "/" 00180 << chan; 00181 rawToDigi_.handleException( __func__, sss.str() ); 00182 } 00183 } 00184 clusterizer_->algorithm()->endDet(record,idet->first); 00185 } 00186 }
const SiStripClusterizerFactory* SiStripRawToClustersLazyUnpacker::clusterizer_ [private] |
Clusterizer Factory.
Definition at line 39 of file SiStripRawToClustersLazyUnpacker.h.
Referenced by fill().
std::vector< Fed9U::Fed9UEvent* > SiStripRawToClustersLazyUnpacker::fedEvents_ [private] |
Fed9UEvent cache.
Definition at line 42 of file SiStripRawToClustersLazyUnpacker.h.
Referenced by fill(), SiStripRawToClustersLazyUnpacker(), and ~SiStripRawToClustersLazyUnpacker().
std::vector<sistrip::FedReadoutMode> SiStripRawToClustersLazyUnpacker::fedModes_ [private] |
Fed9UEvent readout mode.
Definition at line 45 of file SiStripRawToClustersLazyUnpacker.h.
Referenced by fill(), and SiStripRawToClustersLazyUnpacker().
std::list<FEDRawData> SiStripRawToClustersLazyUnpacker::fedRawData_ [private] |
Cache of buffers pointed to by FED9UEvent.
Definition at line 51 of file SiStripRawToClustersLazyUnpacker.h.
Referenced by fill().
const FEDRawDataCollection* SiStripRawToClustersLazyUnpacker::raw_ [private] |
const SiStripRegionCabling::Cabling* SiStripRawToClustersLazyUnpacker::regions_ [private] |