CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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::auto_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 14 of file SiStripFEDEmulator.cc.

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

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

Definition at line 30 of file SiStripFEDEmulator.cc.

30  {
31 
32  }

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

References begin, end, and medians_.

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

Definition at line 227 of file SiStripFEDEmulator.cc.

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

227  {
228  for (edm::DetSet<SiStripProcessedRawDigi>::const_iterator iApv = noises->begin();
229  iApv != noises->end(); ++iApv) {
230  noises_.push_back(iApv->adc());
231  }
232  }
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 220 of file SiStripFEDEmulator.cc.

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

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

Definition at line 34 of file SiStripFEDEmulator.cc.

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

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

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

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

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

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

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

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

Definition at line 277 of file SiStripFEDEmulator.cc.

References i, and medians_.

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

Definition at line 267 of file SiStripFEDEmulator.cc.

References i, and noises_.

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

Definition at line 257 of file SiStripFEDEmulator.cc.

References i, and pedestals_.

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

Definition at line 82 of file SiStripFEDEmulator.cc.

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

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

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

Definition at line 69 of file SiStripFEDEmulator.cc.

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

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

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

Definition at line 179 of file SiStripFEDEmulator.cc.

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

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

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

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

Definition at line 202 of file SiStripFEDEmulator.cc.

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

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

205  {
206  //transform the input digis to a vector of integers
207  std::vector<int16_t> cmSubtrRawDigis;
208  transform(cmSubtrDetSetData.begin(),
209  cmSubtrDetSetData.end(),
210  back_inserter(cmSubtrRawDigis),
211  boost::bind(&SiStripRawDigi::adc ,_1)
212  );
213  algorithms->suppressor->suppress(cmSubtrRawDigis, 0,
214  zsDetSetData);
215 
216  }//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