#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" |
Definition at line 35 of file SiStripFEDEmulator.h.
sistrip::FEDEmulator::FEDEmulator | ( | ) |
sistrip::FEDEmulator::~FEDEmulator | ( | ) |
Definition at line 30 of file SiStripFEDEmulator.cc.
{ }
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 | ) |
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_.
{ for (edm::DetSet<SiStripProcessedRawDigi>::const_iterator iApv = noises->begin(); iApv != noises->end(); ++iApv) { noises_.push_back(iApv->adc()); } }
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_.
{ for (edm::DetSet<SiStripRawDigi>::const_iterator iApv = peds->begin(); iApv != peds->end(); ++iApv) { pedestals_.push_back(iApv->adc()); } }
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().
{ byModule_ = byModule; pedestals_.clear(); noises_.clear(); medians_.clear(); }
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().
{ detId_ = aDetId; nPairs_ = aNPairs; pair_ = aPair; minStrip_ = 0; maxStrip_ = nPairs_*sistrip::STRIPS_PER_FEDCH; if (!byModule_) { minStrip_ = sistrip::STRIPS_PER_FEDCH*pair_; maxStrip_ = sistrip::STRIPS_PER_FEDCH*(pair_+1); } //need resize because it will not be filled by push_back... pedestals_.clear(); pedestals_.resize(nPairs_*sistrip::STRIPS_PER_FEDCH); noises_.clear(); noises_.resize(nPairs_*sistrip::STRIPS_PER_FEDCH); medians_.clear(); medians_.reserve(nPairs_*2); }
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_.
{ aOs << "===============================" << std::endl << " ===== FEDEmulator::print =====" << std::endl << " === byModule = " << byModule_ << std::endl << " === minStrip = " << minStrip_ << std::endl << " === maxStrip = " << maxStrip_ << std::endl << " === size of pedestals = " << pedestals_.size() << std::endl << " === size of noises = " << noises_.size() << std::endl << " === size of medians = " << medians_.size() << std::endl << " === detId = " << detId_ << std::endl << " === nPairs = " << nPairs_ << std::endl << " === pair = " << pair_ << std::endl << "===============================" << std::endl; }
void sistrip::FEDEmulator::printMeds | ( | std::ostream & | aOs | ) |
Definition at line 277 of file SiStripFEDEmulator.cc.
{ aOs << "=========================================" << std::endl << " ===== FEDEmulator::printMedians =====" << std::endl; for (unsigned int i(0); i<medians_.size(); i++){ if (i%32 == 0) aOs << std::endl; aOs << medians_[i] << " " ; } aOs << "=========================================" << std::endl; }
void sistrip::FEDEmulator::printNoises | ( | std::ostream & | aOs | ) |
Definition at line 267 of file SiStripFEDEmulator.cc.
void sistrip::FEDEmulator::printPeds | ( | std::ostream & | aOs | ) |
Definition at line 257 of file SiStripFEDEmulator.cc.
References i, and pedestals_.
{ aOs << "=========================================" << std::endl << " ===== FEDEmulator::printPedestals =====" << std::endl; for (unsigned int i(0); i<pedestals_.size(); i++){ if (i%32 == 0) aOs << std::endl; aOs << pedestals_[i] << " " ; } aOs << "=========================================" << std::endl; }
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().
{ try { SiStripNoises::Range noisesRange = aHandle->getRange(detId_); aHandle->allNoises(noises_,noisesRange); } catch(const cms::Exception& e) { LogError(messageLabel_) << " Something wrong whilst getting noises: size = " << noises_.size() << " detId = " << detId_ << std::endl << e.what(); //throw cms::Exception("ProductNotFound") << "Problem with noises..." ; } }//end of retrieveNoises method.
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().
{ try { SiStripPedestals::Range pedestalsRange = aHandle->getRange(detId_); aHandle->allPeds(pedestals_,pedestalsRange); } catch(const cms::Exception& e) { LogError(messageLabel_) << " Something wrong whilst getting pedestals: size = " << pedestals_.size() << " detId = " << detId_ << std::endl << e.what(); //throw cms::Exception("ProductNotFound") << "Problem with pedestals..." ; } }//end of retrievePedestals method.
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().
{ //subtract Medians std::vector<SiStripRawDigi>::const_iterator lDigi = pedSubtrDetSetData.begin(); uint32_t lCount = 0; for (uint32_t st = minStrip_; st < maxStrip_; st++) { uint32_t lApvNum = static_cast<uint32_t>(lCount*1./sistrip::STRIPS_PER_APV); int value = lDigi->adc() - medians_.at(lApvNum); if (value < 0) { //FED doesn't handle negative values value = 0; } cmSubtrDetSetData.push_back(SiStripRawDigi(static_cast<uint16_t>(value))); ++lDigi; lCount++; } }
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().
{ edm::DetSet<SiStripRawDigi>::const_iterator digi_it = inputChannel->begin(); uint32_t lCount = 0; std::vector<std::vector<uint16_t> > apvs; apvs.reserve(nPairs_*2); //subtract pedestals and fill apv vector //for median calculation //in a module, 256*nPairs, but here we are dealing //channel by channel, so 256 values at a time in the pedestal object. //reordered = 0-127 APV0 128-255 APV1 std::vector<uint16_t> apvVec;; apvVec.reserve(sistrip::STRIPS_PER_APV); for (uint32_t st = minStrip_; st < maxStrip_; st++) { uint16_t ped = static_cast<uint16_t>(pedestals_[st]); pedsDetSetData.push_back(SiStripRawDigi(ped)); float noise = noises_[st]; noiseDetSetData.push_back(SiStripProcessedRawDigi(noise)); if (digi_it == inputChannel->end()) { LogError(messageLabel_) << " Error, end of inputchannel reached for detid " << detId_ << "! Processed " << lCount << " strips." << std::endl; break; } int lVal = digi_it->adc() - ped; if (lVal < 0) { if (digi_it->adc()>0) LogDebug(messageLabel_) << " Negative value after pedestal subtraction ! Detid = " << detId_ << ", strip " << st << ", digi = " << digi_it->adc() << ", ped = " << ped << std::endl; lVal = 0; } pedSubtrDetSetData.push_back( SiStripRawDigi(static_cast<uint16_t>(lVal)) ); if (fillApvsForCM) { apvVec.push_back( static_cast<uint16_t>(lVal) ); } lCount++; ++digi_it; if (lCount%sistrip::STRIPS_PER_APV == 0 && fillApvsForCM) { if (apvVec.size()) apvs.push_back(apvVec); apvVec.clear(); apvVec.reserve(sistrip::STRIPS_PER_APV); } }//end of loop over strips if (fillApvsForCM){ if (apvs.size() != nPairs_*2) { LogError(messageLabel_) << " Error, wrong output size for median calculation for detid " << detId_ << "! Processed " << apvs.size() << " APVs." << std::endl; } //calculate common mode values for (uint32_t iapv(0); iapv<apvs.size(); iapv++){ std::vector<uint16_t> lVec = apvs[iapv]; std::vector<uint16_t>::iterator mid = lVec.begin() + (lVec.size()/2 - 1); std::nth_element(lVec.begin(), mid, lVec.end()); //std::sort(lVec.begin(),lVec.end()); //get the 64th element //if (*mid != lVec.at(63)) exit(0); //medians_.push_back(lVec.at(63)); //medsDetSetData.push_back(lVec.at(63)); medians_.push_back(*mid); medsDetSetData.push_back(*mid); } } }//end of FEDEmulator::subtractPedestals method.
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_pileup_plots::transform.
Referenced by sistrip::FEDEmulatorModule::produce().
{ //transform the input digis to a vector of integers std::vector<int16_t> cmSubtrRawDigis; transform(cmSubtrDetSetData.begin(), cmSubtrDetSetData.end(), back_inserter(cmSubtrRawDigis), boost::bind(&SiStripRawDigi::adc ,_1) ); algorithms->suppressor->suppress(cmSubtrRawDigis, 0, zsDetSetData); }//end of FEDEmulator::zeroSuppress method.
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] |
Definition at line 82 of file SiStripFEDEmulator.h.
Referenced by FEDEmulator(), initialiseModule(), print(), retrieveNoises(), retrievePedestals(), and subtractPedestals().
uint32_t sistrip::FEDEmulator::maxStrip_ [private] |
Definition at line 87 of file SiStripFEDEmulator.h.
Referenced by FEDEmulator(), initialiseModule(), print(), subtractCM(), and subtractPedestals().
std::vector<uint32_t> sistrip::FEDEmulator::medians_ [private] |
Definition at line 91 of file SiStripFEDEmulator.h.
Referenced by FEDEmulator(), fillMedians(), initialise(), initialiseModule(), print(), printMeds(), subtractCM(), and subtractPedestals().
const char * sistrip::FEDEmulator::messageLabel_ = "SiStripFEDEmulator" [static, private] |
Definition at line 78 of file SiStripFEDEmulator.h.
Referenced by retrieveNoises(), retrievePedestals(), and subtractPedestals().
uint32_t sistrip::FEDEmulator::minStrip_ [private] |
Definition at line 86 of file SiStripFEDEmulator.h.
Referenced by FEDEmulator(), initialiseModule(), print(), subtractCM(), and subtractPedestals().
std::vector<float> sistrip::FEDEmulator::noises_ [private] |
Definition at line 90 of file SiStripFEDEmulator.h.
Referenced by FEDEmulator(), fillNoises(), initialise(), initialiseModule(), print(), printNoises(), retrieveNoises(), and subtractPedestals().
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] |
Definition at line 89 of file SiStripFEDEmulator.h.
Referenced by FEDEmulator(), fillPeds(), initialise(), initialiseModule(), print(), printPeds(), retrievePedestals(), and subtractPedestals().