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

void doAPVEmulatorCheck (bool do_APVEmulator_check)
 
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 void setEvent (edm::Event const &e) const
 
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 doAPVEmulatorCheck_
 
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 20 of file SiStripRawToClustersLazyUnpacker.h.

Member Typedef Documentation

Definition at line 24 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 8 of file SiStripRawToClustersLazyUnpacker.cc.

References buffers_.

8  :
9 
10  raw_(&data),
11  regions_(&(regioncabling.getRegionCabling())),
12  clusterizer_(&clustalgo),
13  rawAlgos_(&rpAlgos),
14  buffers_(),
15  rawToDigi_(0,0,0,0,0,0,0,0),
16  dump_(dump),
18  {
19  buffers_.assign(1024,static_cast<sistrip::FEDBuffer*>(0));
20  }
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 22 of file SiStripRawToClustersLazyUnpacker.cc.

References buffers_.

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

private default constructor

Member Function Documentation

void sistrip::RawToClustersLazyUnpacker::doAPVEmulatorCheck ( bool  do_APVEmulator_check)
inline

Definition at line 32 of file SiStripRawToClustersLazyUnpacker.h.

References doAPVEmulatorCheck_.

32  {
33  doAPVEmulatorCheck_ = do_APVEmulator_check;
34  };
void sistrip::RawToClustersLazyUnpacker::fill ( const uint32_t &  index,
record_type record 
)
virtual

Implements edm::LazyUnpacker< SiStripCluster >.

Definition at line 30 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(), doAPVEmulatorCheck_, sistrip::FEDBuffer::doChecks(), dump_, sistrip::RawToDigiUnpacker::dumpRawData(), alignCSCRings::e, edm::DetSet< T >::end(), FEDRawDataCollection::FEDData(), sistrip::FEDZSChannelUnpacker::hasData(), sistrip::FEDRawChannelUnpacker::hasData(), sistrip::invalid32_, edm::isDebugEnabled(), SiStripRegionCabling::layer(), LogTrace, sistrip::mlRawToCluster_, sistrip::mlRawToDigi_, alignBH_cfg::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(), GlobalPosition_Frontier_DevDB_cff::record, SiStripRegionCabling::region(), sistrip::FEDZSChannelUnpacker::sampleNumber(), FEDRawData::size(), StripClusterizerAlgorithm::stripByStripAdd(), StripClusterizerAlgorithm::stripByStripBegin(), StripClusterizerAlgorithm::stripByStripEnd(), SiStripRegionCabling::subdet(), SiStripRawProcessingAlgorithms::SuppressProcessedRawData(), SiStripRawProcessingAlgorithms::SuppressVirginRawData(), sistrip::FEDRawChannelUnpacker::virginRawModeUnpacker(), cms::Exception::what(), sistrip::FEDZSChannelUnpacker::zeroSuppressedLiteModeUnpacker(), and sistrip::FEDZSChannelUnpacker::zeroSuppressedModeUnpacker().

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

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

StripClusterizerAlgorithm* const sistrip::RawToClustersLazyUnpacker::clusterizer_
private

clusterizer algorithm

Definition at line 48 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

bool sistrip::RawToClustersLazyUnpacker::doAPVEmulatorCheck_
private

Definition at line 63 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by doAPVEmulatorCheck(), and fill().

bool sistrip::RawToClustersLazyUnpacker::dump_
private

dump frequency

Definition at line 60 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

const FEDRawDataCollection* sistrip::RawToClustersLazyUnpacker::raw_
private

raw data

Definition at line 42 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

SiStripRawProcessingAlgorithms* const sistrip::RawToClustersLazyUnpacker::rawAlgos_
private

raw processing algorithms

Definition at line 51 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

RawToDigiUnpacker sistrip::RawToClustersLazyUnpacker::rawToDigi_
private

raw-to-digi

Definition at line 57 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

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

cabling

Definition at line 45 of file SiStripRawToClustersLazyUnpacker.h.