CMS 3D CMS Logo

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

#include <SiStripFEDEmulator.h>

Public Member Functions

 FEDEmulator ()
 
uint32_t fedIndex (const uint16_t aFedChannel)
 
void fillMedians (const std::map< uint32_t, std::vector< uint32_t > >::const_iterator &meds)
 
void fillNoises (const edm::DetSetVector< SiStripProcessedRawDigi >::const_iterator &noise)
 
void fillPeds (const edm::DetSetVector< SiStripRawDigi >::const_iterator &peds)
 
void initialise (const bool byModule)
 
void initialiseModule (const uint32_t aDetId, const uint32_t aNPairs, const uint32_t aPair)
 
void print (std::ostream &aOs)
 
void printMeds (std::ostream &aOs)
 
void printNoises (std::ostream &aOs)
 
void printPeds (std::ostream &aOs)
 
void retrieveNoises (const edm::ESHandle< SiStripNoises > &aHandle)
 
void retrievePedestals (const edm::ESHandle< SiStripPedestals > &aHandle)
 
void subtractCM (const std::vector< SiStripRawDigi > &pedSubtrDetSetData, std::vector< SiStripRawDigi > &cmSubtrDetSetData)
 
void subtractPedestals (const edm::DetSetVector< SiStripRawDigi >::const_iterator &inputChannel, std::vector< SiStripRawDigi > &pedsDetSetData, std::vector< SiStripProcessedRawDigi > &noiseDetSetData, std::vector< SiStripRawDigi > &pedSubtrDetSetData, std::vector< uint32_t > &medsDetSetData, const bool fillApvsForCM)
 
void zeroSuppress (const std::vector< SiStripRawDigi > &cmSubtrDetSetData, edm::DetSet< SiStripDigi > &zsDetSetData, const std::unique_ptr< SiStripRawProcessingAlgorithms > &algorithms)
 
 ~FEDEmulator ()
 

Private Attributes

bool byModule_
 
uint32_t detId_
 
uint32_t maxStrip_
 
std::vector< uint32_t > medians_
 
uint32_t minStrip_
 
std::vector< float > noises_
 
uint32_t nPairs_
 
uint32_t pair_
 
std::vector< int > pedestals_
 

Static Private Attributes

static const char *const messageLabel_ = "SiStripFEDEmulator"
 

Detailed Description

Definition at line 35 of file SiStripFEDEmulator.h.

Constructor & Destructor Documentation

sistrip::FEDEmulator::FEDEmulator ( )

Definition at line 15 of file SiStripFEDEmulator.cc.

References byModule_, detId_, maxStrip_, medians_, minStrip_, noises_, nPairs_, pair_, and pedestals_.

15  {
16  byModule_ = false;
17  minStrip_ = 0;
18  maxStrip_ = 0;
19  pedestals_.clear();
20  noises_.clear();
21  medians_.clear();
22 
23  detId_ = 0;
24  nPairs_ = 0;
25  pair_ = 0;
26  }
std::vector< float > noises_
std::vector< int > pedestals_
std::vector< uint32_t > medians_
sistrip::FEDEmulator::~FEDEmulator ( )

Definition at line 28 of file SiStripFEDEmulator.cc.

28 {}

Member Function Documentation

uint32_t sistrip::FEDEmulator::fedIndex ( const uint16_t  aFedChannel)
void sistrip::FEDEmulator::fillMedians ( const std::map< uint32_t, std::vector< uint32_t > >::const_iterator &  meds)

Definition at line 215 of file SiStripFEDEmulator.cc.

References SplitLinear::begin, dataset::end, and medians_.

215  {
216  std::vector<uint32_t>::const_iterator iApv = (meds->second).begin();
217  for (; iApv != (meds->second).end(); ++iApv) {
218  medians_.push_back(*iApv);
219  }
220  }
std::vector< uint32_t > medians_
string end
Definition: dataset.py:937
void sistrip::FEDEmulator::fillNoises ( const edm::DetSetVector< SiStripProcessedRawDigi >::const_iterator &  noise)

Definition at line 209 of file SiStripFEDEmulator.cc.

References edm::DetSetVector< T >::begin(), edm::DetSetVector< T >::end(), and noises_.

209  {
210  for (edm::DetSet<SiStripProcessedRawDigi>::const_iterator iApv = noises->begin(); iApv != noises->end(); ++iApv) {
211  noises_.push_back(iApv->adc());
212  }
213  }
std::vector< float > noises_
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
void sistrip::FEDEmulator::fillPeds ( const edm::DetSetVector< SiStripRawDigi >::const_iterator &  peds)

Definition at line 203 of file SiStripFEDEmulator.cc.

References edm::DetSetVector< T >::begin(), edm::DetSetVector< T >::end(), and pedestals_.

203  {
204  for (edm::DetSet<SiStripRawDigi>::const_iterator iApv = peds->begin(); iApv != peds->end(); ++iApv) {
205  pedestals_.push_back(iApv->adc());
206  }
207  }
std::vector< int > pedestals_
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
void sistrip::FEDEmulator::initialise ( const bool  byModule)

Definition at line 30 of file SiStripFEDEmulator.cc.

References MeasureLA_cff::byModule, byModule_, medians_, noises_, and pedestals_.

Referenced by sistrip::FEDEmulatorModule::FEDEmulatorModule().

30  {
32  pedestals_.clear();
33  noises_.clear();
34  medians_.clear();
35  }
std::vector< float > noises_
std::vector< int > pedestals_
std::vector< uint32_t > medians_
void sistrip::FEDEmulator::initialiseModule ( const uint32_t  aDetId,
const uint32_t  aNPairs,
const uint32_t  aPair 
)

Definition at line 37 of file SiStripFEDEmulator.cc.

References byModule_, detId_, maxStrip_, medians_, minStrip_, noises_, nPairs_, pair_, pedestals_, and sistrip::STRIPS_PER_FEDCH.

Referenced by sistrip::FEDEmulatorModule::produce().

37  {
38  detId_ = aDetId;
39  nPairs_ = aNPairs;
40  pair_ = aPair;
41 
42  minStrip_ = 0;
44  if (!byModule_) {
45  minStrip_ = sistrip::STRIPS_PER_FEDCH * pair_;
46  maxStrip_ = sistrip::STRIPS_PER_FEDCH * (pair_ + 1);
47  }
48 
49  //need resize because it will not be filled by push_back...
50  pedestals_.clear();
51  pedestals_.resize(nPairs_ * sistrip::STRIPS_PER_FEDCH);
52 
53  noises_.clear();
54  noises_.resize(nPairs_ * sistrip::STRIPS_PER_FEDCH);
55 
56  medians_.clear();
57  medians_.reserve(nPairs_ * 2);
58  }
std::vector< float > noises_
std::vector< int > pedestals_
static const uint16_t STRIPS_PER_FEDCH
std::vector< uint32_t > medians_
void sistrip::FEDEmulator::print ( std::ostream &  aOs)

Definition at line 222 of file SiStripFEDEmulator.cc.

References byModule_, detId_, maxStrip_, medians_, minStrip_, noises_, nPairs_, pair_, and pedestals_.

222  {
223  aOs << "===============================" << std::endl
224  << " ===== FEDEmulator::print =====" << std::endl
225  << " === byModule = " << byModule_ << std::endl
226  << " === minStrip = " << minStrip_ << std::endl
227  << " === maxStrip = " << maxStrip_ << std::endl
228  << " === size of pedestals = " << pedestals_.size() << std::endl
229  << " === size of noises = " << noises_.size() << std::endl
230  << " === size of medians = " << medians_.size() << std::endl
231  << " === detId = " << detId_ << std::endl
232  << " === nPairs = " << nPairs_ << std::endl
233  << " === pair = " << pair_ << std::endl
234  << "===============================" << std::endl;
235  }
std::vector< float > noises_
std::vector< int > pedestals_
std::vector< uint32_t > medians_
void sistrip::FEDEmulator::printMeds ( std::ostream &  aOs)

Definition at line 259 of file SiStripFEDEmulator.cc.

References mps_fire::i, and medians_.

259  {
260  aOs << "=========================================" << std::endl
261  << " ===== FEDEmulator::printMedians =====" << std::endl;
262  for (unsigned int i(0); i < medians_.size(); i++) {
263  if (i % 32 == 0)
264  aOs << std::endl;
265  aOs << medians_[i] << " ";
266  }
267  aOs << "=========================================" << std::endl;
268  }
std::vector< uint32_t > medians_
void sistrip::FEDEmulator::printNoises ( std::ostream &  aOs)

Definition at line 248 of file SiStripFEDEmulator.cc.

References mps_fire::i, and noises_.

248  {
249  aOs << "=========================================" << std::endl
250  << " ===== FEDEmulator::printNoises =====" << std::endl;
251  for (unsigned int i(0); i < noises_.size(); i++) {
252  if (i % 32 == 0)
253  aOs << std::endl;
254  aOs << noises_[i] << " ";
255  }
256  aOs << "=========================================" << std::endl;
257  }
std::vector< float > noises_
void sistrip::FEDEmulator::printPeds ( std::ostream &  aOs)

Definition at line 237 of file SiStripFEDEmulator.cc.

References mps_fire::i, and pedestals_.

237  {
238  aOs << "=========================================" << std::endl
239  << " ===== FEDEmulator::printPedestals =====" << std::endl;
240  for (unsigned int i(0); i < pedestals_.size(); i++) {
241  if (i % 32 == 0)
242  aOs << std::endl;
243  aOs << pedestals_[i] << " ";
244  }
245  aOs << "=========================================" << std::endl;
246  }
std::vector< int > pedestals_
void sistrip::FEDEmulator::retrieveNoises ( const edm::ESHandle< SiStripNoises > &  aHandle)

Definition at line 72 of file SiStripFEDEmulator.cc.

References detId_, alignCSCRings::e, messageLabel_, noises_, and cms::Exception::what().

Referenced by sistrip::FEDEmulatorModule::produce().

72  {
73  try {
74  SiStripNoises::Range noisesRange = aHandle->getRange(detId_);
75  aHandle->allNoises(noises_, noisesRange);
76  } catch (const cms::Exception& e) {
77  LogError(messageLabel_) << " Something wrong whilst getting noises: size = " << noises_.size()
78  << " detId = " << detId_ << std::endl
79  << e.what();
80  //throw cms::Exception("ProductNotFound") << "Problem with noises..." ;
81  }
82  } //end of retrieveNoises method.
static const char *const messageLabel_
Log< level::Error, false > LogError
std::vector< float > noises_
char const * what() const noexceptoverride
Definition: Exception.cc:103
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
void sistrip::FEDEmulator::retrievePedestals ( const edm::ESHandle< SiStripPedestals > &  aHandle)

Definition at line 60 of file SiStripFEDEmulator.cc.

References detId_, alignCSCRings::e, messageLabel_, pedestals_, and cms::Exception::what().

Referenced by sistrip::FEDEmulatorModule::produce().

60  {
61  try {
62  SiStripPedestals::Range pedestalsRange = aHandle->getRange(detId_);
63  aHandle->allPeds(pedestals_, pedestalsRange);
64  } catch (const cms::Exception& e) {
65  LogError(messageLabel_) << " Something wrong whilst getting pedestals: size = " << pedestals_.size()
66  << " detId = " << detId_ << std::endl
67  << e.what();
68  //throw cms::Exception("ProductNotFound") << "Problem with pedestals..." ;
69  }
70  } //end of retrievePedestals method.
static const char *const messageLabel_
std::pair< ContainerIterator, ContainerIterator > Range
Log< level::Error, false > LogError
char const * what() const noexceptoverride
Definition: Exception.cc:103
std::vector< int > pedestals_
void sistrip::FEDEmulator::subtractCM ( const std::vector< SiStripRawDigi > &  pedSubtrDetSetData,
std::vector< SiStripRawDigi > &  cmSubtrDetSetData 
)

Definition at line 169 of file SiStripFEDEmulator.cc.

References maxStrip_, medians_, minStrip_, sistrip::STRIPS_PER_APV, and relativeConstraints::value.

Referenced by sistrip::FEDEmulatorModule::produce().

170  {
171  //subtract Medians
172  std::vector<SiStripRawDigi>::const_iterator lDigi = pedSubtrDetSetData.begin();
173  uint32_t lCount = 0;
174 
175  for (uint32_t st = minStrip_; st < maxStrip_; st++) {
176  uint32_t lApvNum = static_cast<uint32_t>(lCount * 1. / sistrip::STRIPS_PER_APV);
177 
178  int value = lDigi->adc() - medians_.at(lApvNum);
179  if (value < 0) {
180  //FED doesn't handle negative values
181  value = 0;
182  }
183  cmSubtrDetSetData.push_back(SiStripRawDigi(static_cast<uint16_t>(value)));
184 
185  ++lDigi;
186  lCount++;
187  }
188  }
std::vector< uint32_t > medians_
static const uint16_t STRIPS_PER_APV
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
void sistrip::FEDEmulator::subtractPedestals ( const edm::DetSetVector< SiStripRawDigi >::const_iterator &  inputChannel,
std::vector< SiStripRawDigi > &  pedsDetSetData,
std::vector< SiStripProcessedRawDigi > &  noiseDetSetData,
std::vector< SiStripRawDigi > &  pedSubtrDetSetData,
std::vector< uint32_t > &  medsDetSetData,
const bool  fillApvsForCM 
)

Definition at line 84 of file SiStripFEDEmulator.cc.

References edm::DetSetVector< T >::begin(), detId_, edm::DetSetVector< T >::end(), LogDebug, maxStrip_, medians_, messageLabel_, minStrip_, gpuVertexFinder::noise, noises_, nPairs_, pedestals_, edm::DetSet< T >::push_back(), and sistrip::STRIPS_PER_APV.

Referenced by sistrip::FEDEmulatorModule::produce().

89  {
90  edm::DetSet<SiStripRawDigi>::const_iterator digi_it = inputChannel->begin();
92  uint32_t lCount = 0;
93  std::vector<std::vector<uint16_t> > apvs;
94  apvs.reserve(nPairs_ * 2);
95 
96  //subtract pedestals and fill apv vector
97  //for median calculation
98  //in a module, 256*nPairs, but here we are dealing
99  //channel by channel, so 256 values at a time in the pedestal object.
100  //reordered = 0-127 APV0 128-255 APV1
101 
102  std::vector<uint16_t> apvVec;
103  ;
104  apvVec.reserve(sistrip::STRIPS_PER_APV);
105 
106  for (uint32_t st = minStrip_; st < maxStrip_; st++) {
107  uint16_t ped = static_cast<uint16_t>(pedestals_[st]);
108  pedsDetSetData.push_back(SiStripRawDigi(ped));
109 
110  float noise = noises_[st];
111  noiseDetSetData.push_back(SiStripProcessedRawDigi(noise));
112 
113  if (digi_it == inputChannel->end()) {
114  LogError(messageLabel_) << " Error, end of inputchannel reached for detid " << detId_ << "! Processed "
115  << lCount << " strips." << std::endl;
116  break;
117  }
118 
119  int lVal = digi_it->adc() - ped;
120  if (lVal < 0) {
121  if (digi_it->adc() > 0)
122  LogDebug(messageLabel_) << " Negative value after pedestal subtraction ! Detid = " << detId_ << ", strip "
123  << st << ", digi = " << digi_it->adc() << ", ped = " << ped << std::endl;
124  lVal = 0;
125  }
126  pedSubtrDetSetData.push_back(SiStripRawDigi(static_cast<uint16_t>(lVal)));
127 
128  if (fillApvsForCM) {
129  apvVec.push_back(static_cast<uint16_t>(lVal));
130  }
131 
132  lCount++;
133  ++digi_it;
134 
135  if (lCount % sistrip::STRIPS_PER_APV == 0 && fillApvsForCM) {
136  if (!apvVec.empty())
137  apvs.push_back(apvVec);
138  apvVec.clear();
139  apvVec.reserve(sistrip::STRIPS_PER_APV);
140  }
141 
142  } //end of loop over strips
143 
144  if (fillApvsForCM) {
145  if (apvs.size() != nPairs_ * 2) {
146  LogError(messageLabel_) << " Error, wrong output size for median calculation for detid " << detId_
147  << "! Processed " << apvs.size() << " APVs." << std::endl;
148  }
149 
150  //calculate common mode values
151  for (uint32_t iapv(0); iapv < apvs.size(); iapv++) {
152  std::vector<uint16_t> lVec = apvs[iapv];
153 
154  std::vector<uint16_t>::iterator mid = lVec.begin() + (lVec.size() / 2 - 1);
155  std::nth_element(lVec.begin(), mid, lVec.end());
156 
157  //std::sort(lVec.begin(),lVec.end());
158  //get the 64th element
159  //if (*mid != lVec.at(63)) exit(0);
160  //medians_.push_back(lVec.at(63));
161  //medsDetSetData.push_back(lVec.at(63));
162  medians_.push_back(*mid);
163  medsDetSetData.push_back(*mid);
164  }
165  }
166 
167  } //end of FEDEmulator::subtractPedestals method.
void push_back(const T &t)
Definition: DetSet.h:66
A signed Digi for the silicon strip detector, containing only adc information, and suitable for stori...
static const char *const messageLabel_
Log< level::Error, false > LogError
std::vector< float > noises_
std::vector< int > pedestals_
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
__shared__ int noise
std::vector< uint32_t > medians_
static const uint16_t STRIPS_PER_APV
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
#define LogDebug(id)
void sistrip::FEDEmulator::zeroSuppress ( const std::vector< SiStripRawDigi > &  cmSubtrDetSetData,
edm::DetSet< SiStripDigi > &  zsDetSetData,
const std::unique_ptr< SiStripRawProcessingAlgorithms > &  algorithms 
)

Definition at line 190 of file SiStripFEDEmulator.cc.

References SiStripRawDigi::adc(), and HcalDetIdTransform::transform().

Referenced by sistrip::FEDEmulatorModule::produce().

192  {
193  //transform the input digis to a vector of integers
194  std::vector<int16_t> cmSubtrRawDigis;
195  transform(cmSubtrDetSetData.begin(),
196  cmSubtrDetSetData.end(),
197  back_inserter(cmSubtrRawDigis),
198  std::bind(&SiStripRawDigi::adc, std::placeholders::_1));
199  algorithms->suppressor->suppress(cmSubtrRawDigis, 0, zsDetSetData);
200 
201  } //end of FEDEmulator::zeroSuppress method.
uint16_t adc() const
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Data Documentation

bool sistrip::FEDEmulator::byModule_
private

Definition at line 76 of file SiStripFEDEmulator.h.

Referenced by FEDEmulator(), initialise(), initialiseModule(), and print().

uint32_t sistrip::FEDEmulator::detId_
private
uint32_t sistrip::FEDEmulator::maxStrip_
private
std::vector<uint32_t> sistrip::FEDEmulator::medians_
private
const char *const sistrip::FEDEmulator::messageLabel_ = "SiStripFEDEmulator"
staticprivate

Definition at line 74 of file SiStripFEDEmulator.h.

Referenced by retrieveNoises(), retrievePedestals(), and subtractPedestals().

uint32_t sistrip::FEDEmulator::minStrip_
private
std::vector<float> sistrip::FEDEmulator::noises_
private
uint32_t sistrip::FEDEmulator::nPairs_
private

Definition at line 79 of file SiStripFEDEmulator.h.

Referenced by FEDEmulator(), initialiseModule(), print(), and subtractPedestals().

uint32_t sistrip::FEDEmulator::pair_
private

Definition at line 80 of file SiStripFEDEmulator.h.

Referenced by FEDEmulator(), initialiseModule(), and print().

std::vector<int> sistrip::FEDEmulator::pedestals_
private