CMS 3D CMS Logo

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 * messageLabel_ = "SiStripFEDEmulator"
 

Detailed Description

Definition at line 35 of file SiStripFEDEmulator.h.

Constructor & Destructor Documentation

◆ FEDEmulator()

sistrip::FEDEmulator::FEDEmulator ( )

Definition at line 15 of file SiStripFEDEmulator.cc.

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  }

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

◆ ~FEDEmulator()

sistrip::FEDEmulator::~FEDEmulator ( )

Definition at line 28 of file SiStripFEDEmulator.cc.

28 {}

Member Function Documentation

◆ fedIndex()

uint32_t sistrip::FEDEmulator::fedIndex ( const uint16_t  aFedChannel)

◆ fillMedians()

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

Definition at line 215 of file SiStripFEDEmulator.cc.

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  }

References mps_fire::end, and medians_.

◆ fillNoises()

void sistrip::FEDEmulator::fillNoises ( const edm::DetSetVector< SiStripProcessedRawDigi >::const_iterator &  noise)

Definition at line 209 of file SiStripFEDEmulator.cc.

209  {
210  for (edm::DetSet<SiStripProcessedRawDigi>::const_iterator iApv = noises->begin(); iApv != noises->end(); ++iApv) {
211  noises_.push_back(iApv->adc());
212  }
213  }

References HLTEgPhaseIITestSequence_cff::noises, and noises_.

◆ fillPeds()

void sistrip::FEDEmulator::fillPeds ( const edm::DetSetVector< SiStripRawDigi >::const_iterator &  peds)

Definition at line 203 of file SiStripFEDEmulator.cc.

203  {
204  for (edm::DetSet<SiStripRawDigi>::const_iterator iApv = peds->begin(); iApv != peds->end(); ++iApv) {
205  pedestals_.push_back(iApv->adc());
206  }
207  }

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

◆ initialise()

void sistrip::FEDEmulator::initialise ( const bool  byModule)

Definition at line 30 of file SiStripFEDEmulator.cc.

30  {
31  byModule_ = byModule;
32  pedestals_.clear();
33  noises_.clear();
34  medians_.clear();
35  }

References byModule_, medians_, noises_, and pedestals_.

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

◆ initialiseModule()

void sistrip::FEDEmulator::initialiseModule ( const uint32_t  aDetId,
const uint32_t  aNPairs,
const uint32_t  aPair 
)

Definition at line 37 of file SiStripFEDEmulator.cc.

37  {
38  detId_ = aDetId;
39  nPairs_ = aNPairs;
40  pair_ = aPair;
41 
42  minStrip_ = 0;
44  if (!byModule_) {
47  }
48 
49  //need resize because it will not be filled by push_back...
50  pedestals_.clear();
52 
53  noises_.clear();
55 
56  medians_.clear();
57  medians_.reserve(nPairs_ * 2);
58  }

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

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

◆ print()

void sistrip::FEDEmulator::print ( std::ostream &  aOs)

Definition at line 222 of file SiStripFEDEmulator.cc.

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  }

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

◆ printMeds()

void sistrip::FEDEmulator::printMeds ( std::ostream &  aOs)

Definition at line 259 of file SiStripFEDEmulator.cc.

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  }

References mps_fire::i, and medians_.

◆ printNoises()

void sistrip::FEDEmulator::printNoises ( std::ostream &  aOs)

Definition at line 248 of file SiStripFEDEmulator.cc.

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  }

References mps_fire::i, and noises_.

◆ printPeds()

void sistrip::FEDEmulator::printPeds ( std::ostream &  aOs)

Definition at line 237 of file SiStripFEDEmulator.cc.

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  }

References mps_fire::i, and pedestals_.

◆ retrieveNoises()

void sistrip::FEDEmulator::retrieveNoises ( const edm::ESHandle< SiStripNoises > &  aHandle)

Definition at line 72 of file SiStripFEDEmulator.cc.

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.

References SiStripNoises::allNoises(), detId_, MillePedeFileConverter_cfg::e, SiStripNoises::getRange(), messageLabel_, and noises_.

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

◆ retrievePedestals()

void sistrip::FEDEmulator::retrievePedestals ( const edm::ESHandle< SiStripPedestals > &  aHandle)

Definition at line 60 of file SiStripFEDEmulator.cc.

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.

References SiStripPedestals::allPeds(), detId_, MillePedeFileConverter_cfg::e, SiStripPedestals::getRange(), messageLabel_, and pedestals_.

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

◆ subtractCM()

void sistrip::FEDEmulator::subtractCM ( const std::vector< SiStripRawDigi > &  pedSubtrDetSetData,
std::vector< SiStripRawDigi > &  cmSubtrDetSetData 
)

Definition at line 169 of file SiStripFEDEmulator.cc.

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  }

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

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

◆ subtractPedestals()

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.

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.

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

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

◆ zeroSuppress()

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.

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.

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

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

Member Data Documentation

◆ byModule_

bool sistrip::FEDEmulator::byModule_
private

Definition at line 76 of file SiStripFEDEmulator.h.

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

◆ detId_

uint32_t sistrip::FEDEmulator::detId_
private

◆ maxStrip_

uint32_t sistrip::FEDEmulator::maxStrip_
private

◆ medians_

std::vector<uint32_t> sistrip::FEDEmulator::medians_
private

◆ messageLabel_

const char * sistrip::FEDEmulator::messageLabel_ = "SiStripFEDEmulator"
staticprivate

Definition at line 74 of file SiStripFEDEmulator.h.

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

◆ minStrip_

uint32_t sistrip::FEDEmulator::minStrip_
private

◆ noises_

std::vector<float> sistrip::FEDEmulator::noises_
private

◆ nPairs_

uint32_t sistrip::FEDEmulator::nPairs_
private

Definition at line 79 of file SiStripFEDEmulator.h.

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

◆ pair_

uint32_t sistrip::FEDEmulator::pair_
private

Definition at line 80 of file SiStripFEDEmulator.h.

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

◆ pedestals_

std::vector<int> sistrip::FEDEmulator::pedestals_
private
edm::DetSet::push_back
void push_back(const T &t)
Definition: DetSet.h:66
mps_fire.i
i
Definition: mps_fire.py:428
edm::DetSetVector::end
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
SiStripPedestals::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripPedestals.h:51
edm::DetSetVector::begin
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
SiStripNoises::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripNoises.cc:34
SiStripRawDigi
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
Definition: SiStripRawDigi.h:15
SiStripNoises::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
SiStripRawDigi::adc
uint16_t adc() const
Definition: SiStripRawDigi.h:22
mps_fire.end
end
Definition: mps_fire.py:242
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
sistrip::FEDEmulator::noises_
std::vector< float > noises_
Definition: SiStripFEDEmulator.h:86
sistrip::FEDEmulator::messageLabel_
static const char * messageLabel_
Definition: SiStripFEDEmulator.h:74
SiStripPedestals::allPeds
void allPeds(std::vector< int > &pefs, const Range &range) const
Definition: SiStripPedestals.cc:143
sistrip::FEDEmulator::minStrip_
uint32_t minStrip_
Definition: SiStripFEDEmulator.h:82
SiStripPedestals::getRange
const Range getRange(const uint32_t &detID) const
Definition: SiStripPedestals.cc:28
sistrip::FEDEmulator::pedestals_
std::vector< int > pedestals_
Definition: SiStripFEDEmulator.h:85
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
hgcalDigitizer_cfi.noise
noise
Definition: hgcalDigitizer_cfi.py:155
sistrip::STRIPS_PER_FEDCH
static const uint16_t STRIPS_PER_FEDCH
Definition: ConstantsForHardwareSystems.h:44
value
Definition: value.py:1
analysisFilters_cff.algorithms
algorithms
Definition: analysisFilters_cff.py:30
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
sistrip::FEDEmulator::detId_
uint32_t detId_
Definition: SiStripFEDEmulator.h:78
sistrip::FEDEmulator::maxStrip_
uint32_t maxStrip_
Definition: SiStripFEDEmulator.h:83
sistrip::STRIPS_PER_APV
static const uint16_t STRIPS_PER_APV
Definition: ConstantsForHardwareSystems.h:43
SiStripNoises::allNoises
void allNoises(std::vector< float > &noises, const Range &range) const
Definition: SiStripNoises.cc:122
sistrip::FEDEmulator::byModule_
bool byModule_
Definition: SiStripFEDEmulator.h:76
sistrip::FEDEmulator::nPairs_
uint32_t nPairs_
Definition: SiStripFEDEmulator.h:79
SiStripProcessedRawDigi
A signed Digi for the silicon strip detector, containing only adc information, and suitable for stori...
Definition: SiStripProcessedRawDigi.h:16
cms::Exception
Definition: Exception.h:70
sistrip::FEDEmulator::pair_
uint32_t pair_
Definition: SiStripFEDEmulator.h:80
sistrip::FEDEmulator::medians_
std::vector< uint32_t > medians_
Definition: SiStripFEDEmulator.h:87
HLTEgPhaseIITestSequence_cff.noises
noises
Definition: HLTEgPhaseIITestSequence_cff.py:1348
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31