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

sistrip::FEDEmulator::FEDEmulator ( )

Definition at line 16 of file SiStripFEDEmulator.cc.

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

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

Definition at line 32 of file SiStripFEDEmulator.cc.

32  {
33 
34  }

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 236 of file SiStripFEDEmulator.cc.

References begin, end, and medians_.

236  {
237  std::vector<uint32_t>::const_iterator iApv = (meds->second).begin();
238  for ( ; iApv != (meds->second).end(); ++iApv) {
239  medians_.push_back(*iApv);
240  }
241  }
#define end
Definition: vmac.h:39
std::vector< uint32_t > medians_
#define begin
Definition: vmac.h:32
void sistrip::FEDEmulator::fillNoises ( const edm::DetSetVector< SiStripProcessedRawDigi >::const_iterator &  noise)

Definition at line 229 of file SiStripFEDEmulator.cc.

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

229  {
231  iApv != noises->end(); ++iApv) {
232  noises_.push_back(iApv->adc());
233  }
234  }
std::vector< float > noises_
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
void sistrip::FEDEmulator::fillPeds ( const edm::DetSetVector< SiStripRawDigi >::const_iterator &  peds)

Definition at line 222 of file SiStripFEDEmulator.cc.

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

222  {
224  iApv != peds->end(); ++iApv) {
225  pedestals_.push_back(iApv->adc());
226  }
227  }
std::vector< int > pedestals_
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
void sistrip::FEDEmulator::initialise ( const bool  byModule)

Definition at line 36 of file SiStripFEDEmulator.cc.

References byModule_, medians_, noises_, and pedestals_.

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

37  {
38  byModule_ = byModule;
39  pedestals_.clear();
40  noises_.clear();
41  medians_.clear();
42  }
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 44 of file SiStripFEDEmulator.cc.

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

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

47  {
48  detId_ = aDetId;
49  nPairs_ = aNPairs;
50  pair_ = aPair;
51 
52  minStrip_ = 0;
54  if (!byModule_) {
55  minStrip_ = sistrip::STRIPS_PER_FEDCH*pair_;
56  maxStrip_ = sistrip::STRIPS_PER_FEDCH*(pair_+1);
57  }
58 
59  //need resize because it will not be filled by push_back...
60  pedestals_.clear();
61  pedestals_.resize(nPairs_*sistrip::STRIPS_PER_FEDCH);
62 
63  noises_.clear();
64  noises_.resize(nPairs_*sistrip::STRIPS_PER_FEDCH);
65 
66  medians_.clear();
67  medians_.reserve(nPairs_*2);
68 
69  }
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 243 of file SiStripFEDEmulator.cc.

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

243  {
244  aOs << "===============================" << std::endl
245  << " ===== FEDEmulator::print =====" << std::endl
246  << " === byModule = " << byModule_ << std::endl
247  << " === minStrip = " << minStrip_ << std::endl
248  << " === maxStrip = " << maxStrip_ << std::endl
249  << " === size of pedestals = " << pedestals_.size() << std::endl
250  << " === size of noises = " << noises_.size() << std::endl
251  << " === size of medians = " << medians_.size() << std::endl
252  << " === detId = " << detId_ << std::endl
253  << " === nPairs = " << nPairs_ << std::endl
254  << " === pair = " << pair_ << std::endl
255  << "===============================" << std::endl;
256  }
std::vector< float > noises_
std::vector< int > pedestals_
std::vector< uint32_t > medians_
void sistrip::FEDEmulator::printMeds ( std::ostream &  aOs)

Definition at line 279 of file SiStripFEDEmulator.cc.

References mps_fire::i, and medians_.

279  {
280  aOs << "=========================================" << std::endl
281  << " ===== FEDEmulator::printMedians =====" << std::endl;
282  for (unsigned int i(0); i<medians_.size(); i++){
283  if (i%32 == 0) aOs << std::endl;
284  aOs << medians_[i] << " " ;
285  }
286  aOs << "=========================================" << std::endl;
287  }
std::vector< uint32_t > medians_
void sistrip::FEDEmulator::printNoises ( std::ostream &  aOs)

Definition at line 269 of file SiStripFEDEmulator.cc.

References mps_fire::i, and noises_.

269  {
270  aOs << "=========================================" << std::endl
271  << " ===== FEDEmulator::printNoises =====" << std::endl;
272  for (unsigned int i(0); i<noises_.size(); i++){
273  if (i%32 == 0) aOs << std::endl;
274  aOs << noises_[i] << " " ;
275  }
276  aOs << "=========================================" << std::endl;
277  }
std::vector< float > noises_
void sistrip::FEDEmulator::printPeds ( std::ostream &  aOs)

Definition at line 259 of file SiStripFEDEmulator.cc.

References mps_fire::i, and pedestals_.

259  {
260  aOs << "=========================================" << std::endl
261  << " ===== FEDEmulator::printPedestals =====" << std::endl;
262  for (unsigned int i(0); i<pedestals_.size(); i++){
263  if (i%32 == 0) aOs << std::endl;
264  aOs << pedestals_[i] << " " ;
265  }
266  aOs << "=========================================" << std::endl;
267  }
std::vector< int > pedestals_
void sistrip::FEDEmulator::retrieveNoises ( const edm::ESHandle< SiStripNoises > &  aHandle)

Definition at line 84 of file SiStripFEDEmulator.cc.

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

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

84  {
85  try {
86  SiStripNoises::Range noisesRange = aHandle->getRange(detId_);
87  aHandle->allNoises(noises_,noisesRange);
88  }
89  catch(const cms::Exception& e) {
90  LogError(messageLabel_) << " Something wrong whilst getting noises: size = "
91  << noises_.size() << " detId = "
92  << detId_ << std::endl << e.what();
93  //throw cms::Exception("ProductNotFound") << "Problem with noises..." ;
94  }
95  }//end of retrieveNoises method.
char const * what() const override
Definition: Exception.cc:103
std::vector< float > noises_
const Range getRange(const uint32_t detID) const
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:50
void allNoises(std::vector< float > &noises, const Range &range) const
static const char * messageLabel_
void sistrip::FEDEmulator::retrievePedestals ( const edm::ESHandle< SiStripPedestals > &  aHandle)

Definition at line 71 of file SiStripFEDEmulator.cc.

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

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

71  {
72  try {
73  SiStripPedestals::Range pedestalsRange = aHandle->getRange(detId_);
74  aHandle->allPeds(pedestals_,pedestalsRange);
75  }
76  catch(const cms::Exception& e) {
77  LogError(messageLabel_) << " Something wrong whilst getting pedestals: size = "
78  << pedestals_.size() << " detId = "
79  << detId_ << std::endl << e.what();
80  //throw cms::Exception("ProductNotFound") << "Problem with pedestals..." ;
81  }
82  }//end of retrievePedestals method.
char const * what() const override
Definition: Exception.cc:103
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< int > pedestals_
void allPeds(std::vector< int > &pefs, const Range &range) const
const Range getRange(const uint32_t &detID) const
static const char * messageLabel_
void sistrip::FEDEmulator::subtractCM ( const std::vector< SiStripRawDigi > &  pedSubtrDetSetData,
std::vector< SiStripRawDigi > &  cmSubtrDetSetData 
)

Definition at line 181 of file SiStripFEDEmulator.cc.

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

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

183  {
184  //subtract Medians
185  std::vector<SiStripRawDigi>::const_iterator lDigi = pedSubtrDetSetData.begin();
186  uint32_t lCount = 0;
187 
188  for (uint32_t st = minStrip_; st < maxStrip_; st++) {
189  uint32_t lApvNum = static_cast<uint32_t>(lCount*1./sistrip::STRIPS_PER_APV);
190 
191  int value = lDigi->adc() - medians_.at(lApvNum);
192  if (value < 0) {
193  //FED doesn't handle negative values
194  value = 0;
195  }
196  cmSubtrDetSetData.push_back(SiStripRawDigi(static_cast<uint16_t>(value)));
197 
198  ++lDigi;
199  lCount++;
200  }
201 
202  }
Definition: value.py:1
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 97 of file SiStripFEDEmulator.cc.

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

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

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

Definition at line 204 of file SiStripFEDEmulator.cc.

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

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

207  {
208  //transform the input digis to a vector of integers
209  std::vector<int16_t> cmSubtrRawDigis;
210  transform(cmSubtrDetSetData.begin(),
211  cmSubtrDetSetData.end(),
212  back_inserter(cmSubtrRawDigis),
213  boost::bind(&SiStripRawDigi::adc ,_1)
214  );
215  algorithms->suppressor->suppress(cmSubtrRawDigis, 0,
216  zsDetSetData);
217 
218  }//end of FEDEmulator::zeroSuppress method.
const uint16_t & adc() const

Member Data Documentation

bool sistrip::FEDEmulator::byModule_
private

Definition at line 80 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 * sistrip::FEDEmulator::messageLabel_ = "SiStripFEDEmulator"
staticprivate

Definition at line 78 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 83 of file SiStripFEDEmulator.h.

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

uint32_t sistrip::FEDEmulator::pair_
private

Definition at line 84 of file SiStripFEDEmulator.h.

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

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