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...
 
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 12 of file SiStripRawToClustersLazyUnpacker.cc.

References buffers_.

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

References buffers_.

25  {
26 
27  std::vector< sistrip::FEDBuffer*>::iterator ibuffer = buffers_.begin();
28  for (; ibuffer!=buffers_.end(); ibuffer++) {
29  if (*ibuffer) delete *ibuffer;
30  }
31  }
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 31 of file SiStripRawToClustersLazyUnpacker.h.

References doAPVEmulatorCheck_.

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

Implements edm::LazyUnpacker< SiStripCluster >.

Definition at line 33 of file SiStripRawToClustersLazyUnpacker.cc.

References sistrip::FEDRawChannelUnpacker::adc(), StripClusterizerAlgorithm::addFed(), 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::FEDRawChannelUnpacker::hasData(), sistrip::invalid32_, edm::isDebugEnabled(), SiStripRegionCabling::layer(), LogTrace, sistrip::mlRawToCluster_, sistrip::mlRawToDigi_, alignBH_cfg::mode, sistrip::FEDRawChannelUnpacker::procRawModeUnpacker(), raw_, rawAlgos_, 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(), 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().

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

Member Data Documentation

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

FED event cache.

Definition at line 53 of file SiStripRawToClustersLazyUnpacker.h.

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

StripClusterizerAlgorithm* const sistrip::RawToClustersLazyUnpacker::clusterizer_
private

clusterizer algorithm

Definition at line 47 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

bool sistrip::RawToClustersLazyUnpacker::doAPVEmulatorCheck_
private

Definition at line 59 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by doAPVEmulatorCheck(), and fill().

bool sistrip::RawToClustersLazyUnpacker::dump_
private

dump frequency

Definition at line 56 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

const FEDRawDataCollection* sistrip::RawToClustersLazyUnpacker::raw_
private

raw data

Definition at line 41 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

SiStripRawProcessingAlgorithms* const sistrip::RawToClustersLazyUnpacker::rawAlgos_
private

raw processing algorithms

Definition at line 50 of file SiStripRawToClustersLazyUnpacker.h.

Referenced by fill().

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

cabling

Definition at line 44 of file SiStripRawToClustersLazyUnpacker.h.