CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
sistrip::RawToClustersLazyUnpacker Class Reference

#include <SiStripRawToClustersLazyUnpacker.h>

Inheritance diagram for sistrip::RawToClustersLazyUnpacker:
edm::LazyUnpacker< SiStripCluster >

Public Types

typedef edm::DetSet
< SiStripCluster
DetSet
 
- Public Types inherited from edm::LazyUnpacker< SiStripCluster >
typedef std::vector
< SiStripCluster
record_type
 

Public Member Functions

virtual void fill (const uint32_t &, record_type &)
 
 RawToClustersLazyUnpacker (const SiStripRegionCabling &, StripClusterizerAlgorithm &, SiStripRawProcessingAlgorithms &, const FEDRawDataCollection &, bool=false)
 
virtual ~RawToClustersLazyUnpacker ()
 
- Public Member Functions inherited from edm::LazyUnpacker< SiStripCluster >
virtual ~LazyUnpacker ()
 

Private Member Functions

 RawToClustersLazyUnpacker ()
 private default constructor More...
 

Private Attributes

std::vector< sistrip::FEDBuffer * > buffers_
 FED event cache. More...
 
StripClusterizerAlgorithm *const clusterizer_
 clusterizer algorithm More...
 
bool dump_
 dump frequency More...
 
const FEDRawDataCollectionraw_
 raw data More...
 
SiStripRawProcessingAlgorithms
*const 
rawAlgos_
 raw processing algorithms More...
 
RawToDigiUnpacker rawToDigi_
 raw-to-digi More...
 
const
SiStripRegionCabling::Cabling
regions_
 cabling More...
 

Detailed Description

Definition at line 19 of file SiStripRawToClustersLazyUnpacker.h.

Member Typedef Documentation

Definition at line 23 of file SiStripRawToClustersLazyUnpacker.h.

Constructor & Destructor Documentation

sistrip::RawToClustersLazyUnpacker::RawToClustersLazyUnpacker ( const SiStripRegionCabling regioncabling,
StripClusterizerAlgorithm clustalgo,
SiStripRawProcessingAlgorithms rpAlgos,
const FEDRawDataCollection data,
bool  dump = false 
)

Definition at line 7 of file SiStripRawToClustersLazyUnpacker.cc.

References buffers_.

7  :
8 
9  raw_(&data),
10  regions_(&(regioncabling.getRegionCabling())),
11  clusterizer_(&clustalgo),
12  rawAlgos_(&rpAlgos),
13  buffers_(),
14  rawToDigi_(0,0,0,0,0,0,0,0),
15  dump_(dump)
16  {
17  buffers_.assign(1024,static_cast<sistrip::FEDBuffer*>(0));
18  }
SiStripRawProcessingAlgorithms *const rawAlgos_
raw processing algorithms
const Cabling & getRegionCabling() const
StripClusterizerAlgorithm *const clusterizer_
clusterizer algorithm
std::vector< sistrip::FEDBuffer * > buffers_
FED event cache.
const FEDRawDataCollection * raw_
raw data
const SiStripRegionCabling::Cabling * regions_
cabling
sistrip::RawToClustersLazyUnpacker::~RawToClustersLazyUnpacker ( )
virtual

Definition at line 20 of file SiStripRawToClustersLazyUnpacker.cc.

References buffers_.

20  {
21 
22  std::vector< sistrip::FEDBuffer*>::iterator ibuffer = buffers_.begin();
23  for (; ibuffer!=buffers_.end(); ibuffer++) {
24  if (*ibuffer) delete *ibuffer;
25  }
26  }
std::vector< sistrip::FEDBuffer * > buffers_
FED event cache.
sistrip::RawToClustersLazyUnpacker::RawToClustersLazyUnpacker ( )
private

private default constructor

Member Function Documentation

void sistrip::RawToClustersLazyUnpacker::fill ( const uint32_t &  index,
record_type record 
)
virtual

Implements edm::LazyUnpacker< SiStripCluster >.

Definition at line 28 of file SiStripRawToClustersLazyUnpacker.cc.

References sistrip::FEDZSChannelUnpacker::adc(), sistrip::FEDRawChannelUnpacker::adc(), edm::DetSet< T >::begin(), buffers_, sistrip::FEDBufferBase::channel(), sistrip::FEDBuffer::channelGood(), clusterizer_, FEDRawData::data(), sistrip::FEDBuffer::doChecks(), dump_, sistrip::RawToDigiUnpacker::dumpRawData(), edm::DetSet< T >::end(), FEDRawDataCollection::FEDData(), sistrip::FEDZSChannelUnpacker::hasData(), sistrip::FEDRawChannelUnpacker::hasData(), sistrip::invalid32_, edm::isDebugEnabled(), SiStripRegionCabling::layer(), LogTrace, sistrip::mlRawToCluster_, sistrip::mlRawToDigi_, mode, sistrip::FEDRawChannelUnpacker::procRawModeUnpacker(), raw_, rawAlgos_, rawToDigi_, sistrip::READOUT_MODE_PROC_RAW, sistrip::READOUT_MODE_VIRGIN_RAW, sistrip::READOUT_MODE_ZERO_SUPPRESSED, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE, sistrip::FEDBufferBase::readoutMode(), record, SiStripRegionCabling::region(), sistrip::FEDZSChannelUnpacker::sampleNumber(), FEDRawData::size(), StripClusterizerAlgorithm::stripByStripAdd(), StripClusterizerAlgorithm::stripByStripBegin(), StripClusterizerAlgorithm::stripByStripEnd(), SiStripRegionCabling::subdet(), SiStripRawProcessingAlgorithms::subtractorCMN, SiStripRawProcessingAlgorithms::subtractorPed, SiStripRawProcessingAlgorithms::suppressor, sistrip::FEDRawChannelUnpacker::virginRawModeUnpacker(), cms::Exception::what(), sistrip::FEDZSChannelUnpacker::zeroSuppressedLiteModeUnpacker(), and sistrip::FEDZSChannelUnpacker::zeroSuppressedModeUnpacker().

28  {
29 
30  // Get region, subdet and layer from element-index
31  uint32_t region = SiStripRegionCabling::region(index);
32  uint32_t subdet = static_cast<uint32_t>(SiStripRegionCabling::subdet(index));
33  uint32_t layer = SiStripRegionCabling::layer(index);
34 
35  // Retrieve cabling for element
36  const SiStripRegionCabling::ElementCabling& element = (*regions_)[region][subdet][layer];
37 
38  // Loop dets
39  SiStripRegionCabling::ElementCabling::const_iterator idet = element.begin();
40  for (;idet!=element.end();idet++) {
41 
42  // If det id is null or invalid continue.
43  if ( !(idet->first) || (idet->first == sistrip::invalid32_) || !clusterizer_->stripByStripBegin(idet->first)) { continue; }
44 
45  // Loop over apv-pairs of det
46  std::vector<FedChannelConnection>::const_iterator iconn = idet->second.begin();
47  for (;iconn!=idet->second.end();iconn++) {
48  const uint16_t fedId = iconn->fedId();
49 
50  // If fed id is null or connection is invalid continue
51  if ( !fedId || !iconn->isConnected() ) { continue; }
52 
53  // If Fed hasnt already been initialised, extract data and initialise
54  FEDBuffer* buffer = buffers_[fedId];
55  if (!buffer) {
56 
57  // Retrieve FED raw data for given FED
58  const FEDRawData& rawData = raw_->FEDData( static_cast<int>(fedId) );
59 
60  // Check on FEDRawData pointer
61  if ( !rawData.data() ) {
62  if (edm::isDebugEnabled()) {
64  << "[sistrip::RawToClustersLazyGetter::"
65  << __func__
66  << "]"
67  << " NULL pointer to FEDRawData for FED id "
68  << fedId;
69  }
70  continue;
71  }
72 
73  // Check on FEDRawData size
74  if ( !rawData.size() ) {
75  if (edm::isDebugEnabled()) {
77  << "[sistrip::RawToClustersLazyGetter::"
78  << __func__ << "]"
79  << " FEDRawData has zero size for FED id "
80  << fedId;
81  }
82  continue;
83  }
84 
85  // construct FEDBuffer
86  try {
87  buffers_[fedId] = buffer = new sistrip::FEDBuffer(rawData.data(),rawData.size());
88  if (!buffer->doChecks()) throw cms::Exception("FEDBuffer") << "FED Buffer check fails for FED ID" << fedId << ".";
89  }
90  catch (const cms::Exception& e) {
91  if (edm::isDebugEnabled()) {
93  << "Exception caught when creating FEDBuffer object for FED " << fedId << ": " << e.what();
94  }
95  if ( buffer ) { delete buffer; }
96  buffers_[fedId] = 0;
97  continue;
98  }
99 
100  // dump of FEDRawData to stdout
101  if ( dump_ ) {
102  std::stringstream ss;
103  rawToDigi_.dumpRawData( fedId, rawData, ss );
105  << ss.str();
106  }
107  }
108 
109  // check channel
110  const uint8_t fedCh = iconn->fedCh();
111  if (!buffer->channelGood(fedCh)) {
112  if (edm::isDebugEnabled()) {
113  std::ostringstream ss;
114  ss << "Problem unpacking channel " << fedCh << " on FED " << fedId;
116  }
117  continue;
118  }
119 
120  // Determine APV std::pair number
121  uint16_t ipair = iconn->apvPairNumber();
122 
123  const sistrip::FEDReadoutMode mode = buffer->readoutMode();
125 
126  try {
127  // create unpacker
129 
130  // unpack
131  while (unpacker.hasData()) {
132  clusterizer_->stripByStripAdd(unpacker.sampleNumber()+ipair*256,unpacker.adc(),record);
133  unpacker++;
134  }
135  } catch (const cms::Exception& e) {
136  if (edm::isDebugEnabled()) {
137  std::ostringstream ss;
138  ss << "Unordered clusters for channel " << fedCh << " on FED " << fedId << ": " << e.what();
140  }
141  continue;
142  }
143  }
144 
145  else if (mode == sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE ) {
146 
147  try {
148  // create unpacker
150 
151  // unpack
152  while (unpacker.hasData()) {
153  clusterizer_->stripByStripAdd(unpacker.sampleNumber()+ipair*256,unpacker.adc(),record);
154  unpacker++;
155  }
156  } catch (const cms::Exception& e) {
157  if (edm::isDebugEnabled()) {
158  std::ostringstream ss;
159  ss << "Unordered clusters for channel " << fedCh << " on FED " << fedId << ": " << e.what();
161  }
162  continue;
163  }
164  }
165 
166  else if (mode == sistrip::READOUT_MODE_VIRGIN_RAW ) {
167 
168  // create unpacker
170 
171  // unpack
172  std::vector<int16_t> digis;
173  while (unpacker.hasData()) {
174  digis.push_back(unpacker.adc());
175  unpacker++;
176  }
177 
178  //process raw
179  uint32_t id = iconn->detId();
180  rawAlgos_->subtractorPed->subtract( id, ipair*256, digis);
181  rawAlgos_->subtractorCMN->subtract( id, digis);
182  edm::DetSet<SiStripDigi> zsdigis(id);
183  rawAlgos_->suppressor->suppress( digis, zsdigis);
184  for( edm::DetSet<SiStripDigi>::const_iterator it = zsdigis.begin(); it!=zsdigis.end(); it++) {
185  clusterizer_->stripByStripAdd( it->strip(), it->adc(), record);
186  }
187  }
188 
189  else if (mode == sistrip::READOUT_MODE_PROC_RAW ) {
190 
191  // create unpacker
193 
194  // unpack
195  std::vector<int16_t> digis;
196  while (unpacker.hasData()) {
197  digis.push_back(unpacker.adc());
198  unpacker++;
199  }
200 
201  //process raw
202  uint32_t id = iconn->detId();
203  rawAlgos_->subtractorCMN->subtract( id, digis);
204  edm::DetSet<SiStripDigi> zsdigis(id);
205  rawAlgos_->suppressor->suppress( digis, zsdigis);
206  for( edm::DetSet<SiStripDigi>::const_iterator it = zsdigis.begin(); it!=zsdigis.end(); it++) {
207  clusterizer_->stripByStripAdd( it->strip(), it->adc(), record);
208  }
209  }
210 
211  else {
213  << "[sistrip::RawToClustersLazyGetter::"
214  << __func__ << "]"
215  << " FEDRawData readout mode "
216  << mode
217  << " from FED id "
218  << fedId
219  << " not supported.";
220  continue;
221  }
222  }
224  }
225  }
static FEDRawChannelUnpacker procRawModeUnpacker(const FEDChannel &channel)
virtual char const * what() const
Definition: Exception.cc:97
bool isDebugEnabled()
static FEDZSChannelUnpacker zeroSuppressedModeUnpacker(const FEDChannel &channel)
SiStripRawProcessingAlgorithms *const rawAlgos_
raw processing algorithms
const std::auto_ptr< SiStripPedestalsSubtractor > subtractorPed
static const char mlRawToCluster_[]
JetCorrectorParameters::Record record
Definition: classes.h:11
static const uint32_t invalid32_
Definition: Constants.h:16
static FEDRawChannelUnpacker virginRawModeUnpacker(const FEDChannel &channel)
static const char mlRawToDigi_[]
const std::auto_ptr< SiStripFedZeroSuppression > suppressor
virtual void stripByStripEnd(std::vector< SiStripCluster > &out)=0
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
virtual bool stripByStripBegin(uint32_t id)=0
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void dumpRawData(uint16_t fed_id, const FEDRawData &, std::stringstream &)
dumps raw data to stdout (NB: payload is byte-swapped,headers/trailer are not).
static const SubDet subdet(const ElementIndex)
#define LogTrace(id)
StripClusterizerAlgorithm *const clusterizer_
clusterizer algorithm
std::vector< sistrip::FEDBuffer * > buffers_
FED event cache.
static FEDZSChannelUnpacker zeroSuppressedLiteModeUnpacker(const FEDChannel &channel)
int mode
Definition: AMPTWrapper.h:139
virtual void stripByStripAdd(uint16_t strip, uint16_t adc, std::vector< SiStripCluster > &out)=0
const FEDRawDataCollection * raw_
raw data
const uint32_t region(const Position) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
const std::auto_ptr< SiStripCommonModeNoiseSubtractor > subtractorCMN
collection_type::const_iterator const_iterator
Definition: DetSet.h:32
static const uint32_t layer(const ElementIndex)
std::map< uint32_t, std::vector< FedChannelConnection > > ElementCabling

Member Data Documentation

std::vector< sistrip::FEDBuffer* > sistrip::RawToClustersLazyUnpacker::buffers_
private

FED event cache.

Definition at line 49 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill(), RawToClustersLazyUnpacker(), and ~RawToClustersLazyUnpacker().

StripClusterizerAlgorithm* const sistrip::RawToClustersLazyUnpacker::clusterizer_
private

clusterizer algorithm

Definition at line 43 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

bool sistrip::RawToClustersLazyUnpacker::dump_
private

dump frequency

Definition at line 55 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

const FEDRawDataCollection* sistrip::RawToClustersLazyUnpacker::raw_
private

raw data

Definition at line 37 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

SiStripRawProcessingAlgorithms* const sistrip::RawToClustersLazyUnpacker::rawAlgos_
private

raw processing algorithms

Definition at line 46 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

RawToDigiUnpacker sistrip::RawToClustersLazyUnpacker::rawToDigi_
private

raw-to-digi

Definition at line 52 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

const SiStripRegionCabling::Cabling* sistrip::RawToClustersLazyUnpacker::regions_
private

cabling

Definition at line 40 of file SiStripRawToClustersLazyUnpacker.h.