#include <CalibTracker/SiPixelGainCalibration/src/SiPixelCalibDigiProducer.cc>
Public Member Functions | |
SiPixelCalibDigiProducer (const edm::ParameterSet &iConfig) | |
~SiPixelCalibDigiProducer () | |
Private Types | |
typedef std::pair< uint32_t, std::pair< short, short > > | pixelstruct |
Private Member Functions | |
virtual void | beginJob () |
virtual void | beginRun (const edm::Run &, const edm::EventSetup &) |
virtual bool | checkFED (uint32_t detid) |
virtual bool | checkPixel (uint32_t detid, short row, short col) |
virtual void | clear () |
virtual void | endJob () |
virtual void | fill (edm::Event &iEvent, const edm::EventSetup &iSetup) |
virtual void | fillPixel (uint32_t detid, short row, short col, short ipoint, short adc) |
virtual void | produce (edm::Event &iEvent, const edm::EventSetup &iSetup) |
virtual void | setPattern () |
virtual bool | store () |
Private Attributes | |
edm::ESHandle < SiPixelCalibConfiguration > | calib_ |
edm::ParameterSet | conf_ |
bool | control_pattern_size_ |
std::pair< short, short > | currentpair_ |
std::vector< std::pair< short, short > > | currentpattern_ |
std::map< uint32_t, uint32_t > | detid_to_fedid_ |
std::vector< pixelstruct > | detPixelMap_ |
std::map< pixelstruct, SiPixelCalibDigiError > | error_data_ |
int | errorType |
uint32_t | iEventCounter_ |
bool | ignore_non_pattern_ |
bool | includeErrors_ |
std::string | instance_ |
std::map< pixelstruct, SiPixelCalibDigi > | intermediate_data_ |
std::string | label_ |
uint32_t | number_of_pixels_per_pattern_ |
uint32_t | pattern_repeat_ |
edm::InputTag | src_ |
edm::ESHandle < SiPixelFedCablingMap > | theCablingMap_ |
edm::ESHandle< TrackerGeometry > | theGeometry_ |
bool | use_realeventnumber_ |
Description: <one line="" class="" summary>="">
Implementation: <Notes on="" implementation>="">
Definition at line 56 of file SiPixelCalibDigiProducer.h.
typedef std::pair<uint32_t,std::pair<short,short> > SiPixelCalibDigiProducer::pixelstruct [private] |
Definition at line 74 of file SiPixelCalibDigiProducer.h.
SiPixelCalibDigiProducer::SiPixelCalibDigiProducer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 55 of file SiPixelCalibDigiProducer.cc.
References includeErrors_.
: src_(iConfig.getParameter<edm::InputTag>("src")), iEventCounter_(0), ignore_non_pattern_(iConfig.getParameter<bool>("ignoreNonPattern")), control_pattern_size_(iConfig.getParameter<bool>("checkPatternEachEvent")), includeErrors_(iConfig.getUntrackedParameter<bool>("includeErrors",false)), errorType(iConfig.getUntrackedParameter<int>("errorTypeNumber",1)), conf_(iConfig), number_of_pixels_per_pattern_(0), use_realeventnumber_(iConfig.getParameter<bool>("useRealEventNumber")) { //register your products produces< edm::DetSetVector<SiPixelCalibDigi> >(); if(includeErrors_) produces< edm::DetSetVector<SiPixelCalibDigiError> > (); }
SiPixelCalibDigiProducer::~SiPixelCalibDigiProducer | ( | ) |
Definition at line 75 of file SiPixelCalibDigiProducer.cc.
{ // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) }
virtual void SiPixelCalibDigiProducer::beginJob | ( | void | ) | [inline, private, virtual] |
void SiPixelCalibDigiProducer::beginRun | ( | const edm::Run & | iRun, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Definition at line 392 of file SiPixelCalibDigiProducer.cc.
{ }
bool SiPixelCalibDigiProducer::checkFED | ( | uint32_t | detid | ) | [private, virtual] |
Definition at line 134 of file SiPixelCalibDigiProducer.cc.
References cond::rpcobgas::detid, detid_to_fedid_, edm::ESHandle< T >::product(), and theCablingMap_.
Referenced by fillPixel().
{ // edm::LogInfo("SiPixelCalibProducer") << "in checkFED" << std::endl; if(detid_to_fedid_[detid]) return true; for(int fedid=0; fedid<=40; ++fedid){ // edm::LogInfo("SiPixelCalibProducer") << " looking at fedid " << fedid << std::endl; SiPixelFrameConverter converter(theCablingMap_.product(),fedid); if(converter.hasDetUnit(detid)){ detid_to_fedid_[detid]=fedid; edm::LogInfo("SiPixelCalibDigiProducer") << "matched detid " << detid << " to fed " << detid_to_fedid_[detid] << std::endl; return true; } } return false; }
bool SiPixelCalibDigiProducer::checkPixel | ( | uint32_t | detid, |
short | row, | ||
short | col | ||
) | [private, virtual] |
Definition at line 325 of file SiPixelCalibDigiProducer.cc.
References control_pattern_size_, currentpair_, currentpattern_, sipixelobjects::ElectronicIndex::dcol, sipixelobjects::LocalPixel::DcolPxid::dcol, ExpressReco_HICollisions_FallBack::detector, cond::rpcobgas::detid, detid_to_fedid_, error_data_, i, iEventCounter_, ignore_non_pattern_, includeErrors_, edm::ESHandle< T >::product(), sipixelobjects::ElectronicIndex::pxid, sipixelobjects::LocalPixel::DcolPxid::pxid, sipixelobjects::LocalPixel::rocCol(), sipixelobjects::LocalPixel::rocRow(), setPattern(), store(), and theCablingMap_.
Referenced by fillPixel(), and produce().
{ if(!control_pattern_size_ && !store()) return true; if( !ignore_non_pattern_ ) return true; edm::LogInfo("SiPixelCalibDigiProducer") << "Event" << iEventCounter_ << ",now in checkpixel() " << std::endl; if(currentpattern_.size()==0) setPattern(); // uint32_t iroc; uint32_t fedid = detid_to_fedid_[detid]; SiPixelFrameConverter formatter(theCablingMap_.product(),fedid); sipixelobjects::DetectorIndex detector ={detid, row, col}; sipixelobjects::ElectronicIndex cabling; formatter.toCabling(cabling,detector); // cabling should now contain cabling.roc and cabling.dcol and cabling.pxid // however, the coordinates now need to be converted from dcl, pxid to the row,col coordinates used in the calibration info sipixelobjects::LocalPixel::DcolPxid loc; loc.dcol = cabling.dcol; loc.pxid = cabling.pxid; sipixelobjects::LocalPixel locpixel(loc); currentpair_.first = locpixel.rocRow(); currentpair_.second = locpixel.rocCol(); for(uint32_t i=0; i<currentpattern_.size(); ++i){ // edm::LogInfo("SiPixelCalibDigiProducer") << "found pair " << currentpair_.first << "," << currentpair_.second << " calib " << currentpattern_[i].first << ","<< currentpattern_[i].second << " input " << row << "," << col << std::endl; if(currentpair_==currentpattern_[i]){ return true; } } std::ostringstream errorlog; errorlog << "DETID "<<detid<<", row, col (offline)="<<row<<","<<col<<" row, col (ROC) ="<<currentpair_.first<<","<< currentpair_.second<< " found no match in list of patterns: " ; for(uint32_t i=0; i<currentpattern_.size(); ++i){ if(i!=0 && i!=currentpattern_.size()-1) errorlog<<" "; errorlog<<"("; errorlog<<currentpattern_[i].first; errorlog<<","; errorlog<<currentpattern_[i].second; errorlog<<")"; } edm::LogError("ERROR") << errorlog.str() << std::endl; if(includeErrors_){// book the error pixelstruct temppixelworker; temppixelworker.first=detid; temppixelworker.second.first=row; temppixelworker.second.second=col; std::map<pixelstruct,SiPixelCalibDigiError>::const_iterator ierr = error_data_.find(temppixelworker); if(ierr== error_data_.end()){ SiPixelCalibDigiError temperr(row,col,1); error_data_[temppixelworker]=temperr; } } return false; }
void SiPixelCalibDigiProducer::clear | ( | void | ) | [private, virtual] |
Definition at line 187 of file SiPixelCalibDigiProducer.cc.
References error_data_, intermediate_data_, and number_of_pixels_per_pattern_.
Referenced by produce().
{ // edm::LogInfo("SiPixelCalibProducer") << "in clear() " << std::endl; // this is where we empty the containers so they can be re-filled // the idea: the detPixelMap_ container shrinks/expands as a function // of the number of pixels looked at at one particular time... // unlike the intermediate_data_ container which only expands when // detPixelMap_ becomes bigger than intermedate_data_ // shrink the detPixelMap_ uint32_t tempsize = intermediate_data_.size(); if(tempsize>number_of_pixels_per_pattern_){ edm::LogError("SiPixelCalibDigiProducer") << "Number of pixels in pattern is now: " << tempsize<< ", size is was " << number_of_pixels_per_pattern_ << std::endl; number_of_pixels_per_pattern_=tempsize; } intermediate_data_.erase(intermediate_data_.begin(),intermediate_data_.end()); intermediate_data_.clear(); // and erase the error bits error_data_.erase(error_data_.begin(), error_data_.end()); error_data_.clear(); }
void SiPixelCalibDigiProducer::endJob | ( | void | ) | [private, virtual] |
void SiPixelCalibDigiProducer::fill | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Definition at line 109 of file SiPixelCalibDigiProducer.cc.
References edm::DetSetVector< T >::begin(), calib_, cond::rpcobgas::detid, edm::DetSetVector< T >::end(), fillPixel(), edm::Event::getByLabel(), iEventCounter_, and src_.
Referenced by produce().
{ // figure out which calibration point we're on now.. short icalibpoint = calib_->vcalIndexForEvent(iEventCounter_); edm::Handle< edm::DetSetVector<PixelDigi> > pixelDigis; iEvent.getByLabel( src_, pixelDigis ); edm::LogInfo("SiPixelCalibProducer") << "in fill(), calibpoint " << icalibpoint <<" ndigis " << pixelDigis->size() << std::endl; // loop over the data and store things edm::DetSetVector<PixelDigi>::const_iterator digiIter; for(digiIter=pixelDigis->begin(); digiIter!=pixelDigis->end(); ++digiIter){// ITERATOR OVER DET IDs uint32_t detid = digiIter->id; edm::DetSet<PixelDigi>::const_iterator ipix; // ITERATOR OVER DIGI DATA for(ipix = digiIter->data.begin(); ipix!=digiIter->end(); ++ipix){ // fill in the appropriate location of the temporary data container fillPixel(detid,ipix->row(),ipix->column(),icalibpoint,ipix->adc()); } } }
void SiPixelCalibDigiProducer::fillPixel | ( | uint32_t | detid, |
short | row, | ||
short | col, | ||
short | ipoint, | ||
short | adc | ||
) | [private, virtual] |
Definition at line 154 of file SiPixelCalibDigiProducer.cc.
References calib_, checkFED(), checkPixel(), cond::rpcobgas::detid, intermediate_data_, and SiPixelCalibDigi::setrowcol().
Referenced by fill().
{ // edm::LogInfo("SiPixelCalibProducer") << " in fillpixel()" << std::endl; // edm::LogInfo("SiPixelCalibProducer") << "in fillPixel " << detid << " " << row << " " << col << " " << ipoint << " " << adc << std::endl; if(!checkFED(detid)){ edm::LogError("SiPixelCalibDigiProducer") << " was unable to match detid " << detid << " to a FED!" << std::endl; return; } if(!checkPixel(detid,row,col)){ return; } // now the check if the pixel exists and fill // pixelstruct temppixelworker; temppixelworker.first=detid; temppixelworker.second.first=row; temppixelworker.second.second=col; std::map<pixelstruct,SiPixelCalibDigi>::const_iterator ipix = intermediate_data_.find(temppixelworker); if(ipix == intermediate_data_.end()){ SiPixelCalibDigi tempdigi(calib_->nVCal()); tempdigi.setrowcol(row,col); intermediate_data_[temppixelworker]=tempdigi; } intermediate_data_[temppixelworker].fill(ipoint,adc); return; }
void SiPixelCalibDigiProducer::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 271 of file SiPixelCalibDigiProducer.cc.
References calib_, checkPixel(), clear(), control_pattern_size_, edm::DetSet< T >::data, cond::rpcobgas::detid, error_data_, edm::EventID::event(), fill(), edm::EventSetup::get(), edm::EventBase::id(), iEventCounter_, includeErrors_, intermediate_data_, pattern_repeat_, edm::Event::put(), setPattern(), store(), theCablingMap_, theGeometry_, and use_realeventnumber_.
{ // edm::LogInfo("SiPixelCalibDigiProducer") <<"in produce() " << std::endl; using namespace edm; iSetup.get<SiPixelCalibConfigurationRcd>().get(calib_); iSetup.get<TrackerDigiGeometryRecord>().get( theGeometry_ ); iSetup.get<SiPixelFedCablingMapRcd>().get(theCablingMap_); pattern_repeat_=calib_->getNTriggers()*calib_->nVCal(); if(use_realeventnumber_){ iEventCounter_= iEvent.id().event()-1; } else iEventCounter_++; if(iEventCounter_%pattern_repeat_==1) setPattern(); // edm::LogInfo("SiPixelCalibDigiProducer") << "now starting fill..." << std::endl; fill(iEvent,iSetup); // fill method where the actual looping over the digis is done. // edm::LogInfo("SiPixelCalibDigiProducer") << "done filling..." << std::endl; std::auto_ptr<edm::DetSetVector<SiPixelCalibDigi> > pOut(new edm::DetSetVector<SiPixelCalibDigi>); std::auto_ptr<edm::DetSetVector<SiPixelCalibDigiError> > pErr (new edm::DetSetVector<SiPixelCalibDigiError> ); // copy things over into pOut if necessary (this is only once per pattern) if(store()){ // edm::LogInfo("SiPixelCalibDigiProducer") << "in loop" << std::endl; for(std::map<pixelstruct,SiPixelCalibDigi>::const_iterator idet=intermediate_data_.begin(); idet!=intermediate_data_.end();++idet){ uint32_t detid=idet->first.first; if(!control_pattern_size_){ if(! checkPixel(idet->first.first,idet->first.second.first,idet->first.second.second)) continue; } SiPixelCalibDigi tempdigi=idet->second; edm::DetSet<SiPixelCalibDigi> & detSet = pOut->find_or_insert(detid); detSet.data.push_back(tempdigi); } if(includeErrors_){ for(std::map<pixelstruct,SiPixelCalibDigiError>::const_iterator ierr=error_data_.begin(); ierr!=error_data_.end();++ierr){ uint32_t detid=ierr->first.first; SiPixelCalibDigiError temperror = ierr->second; edm::DetSet<SiPixelCalibDigiError> & errSet = pErr->find_or_insert(detid); errSet.data.push_back(temperror); } } edm::LogInfo("INFO") << "now filling event " << iEventCounter_ << " as pixel pattern changes every " << pattern_repeat_ << " events..." << std::endl; clear(); } iEvent.put(pOut); if(includeErrors_) iEvent.put(pErr); }
void SiPixelCalibDigiProducer::setPattern | ( | ) | [private, virtual] |
Definition at line 214 of file SiPixelCalibDigiProducer.cc.
References abs, calib_, currentpattern_, iEventCounter_, listBenchmarks::pattern, and pattern_repeat_.
Referenced by checkPixel(), and produce().
{ // edm::LogInfo("SiPixelCalibProducer") << "in setPattern()" << std::endl; uint32_t patternnumber = abs(iEventCounter_-1)/pattern_repeat_; uint32_t rowpatternnumber = patternnumber/calib_->nColumnPatterns(); uint32_t colpatternnumber = patternnumber%calib_->nColumnPatterns(); edm::LogInfo("SiPixelCalibDigiProducer") << " rowpatternnumbers = " << rowpatternnumber << " " << colpatternnumber << " " << patternnumber << std::endl; // update currentpattern_ std::vector<short> calibcols = calib_->getColumnPattern(); std::vector<short> calibrows = calib_->getRowPattern(); std::vector<short> temprowvals(0); std::vector<short> tempcolvals(0); uint32_t nminuscol=0; uint32_t nminusrow=0; uint32_t npatterns=0; for(uint32_t icol=0; icol<calibcols.size(); icol++){ if(calibcols[icol]==-1){ nminuscol++; } else if(nminuscol==colpatternnumber){ //edm::LogInfo("SiPixelCalibProducer") << "col " << calibcols[icol] << std::endl; short val=calibcols[icol]; tempcolvals.push_back(val); } else if (nminuscol> colpatternnumber) break; } for(uint32_t irow=0; irow<calibrows.size(); irow++){ // edm::LogInfo("SiPixelCalibProducer") << "row " << irow <<" "<< nminusrow<<" " << calibrows[irow] << std::endl; if(calibrows[irow]==-1) nminusrow++; else if(nminusrow==rowpatternnumber){ short val=calibrows[irow]; temprowvals.push_back(val); } else if(nminusrow>rowpatternnumber) break; } //now clean up the currentpattern_; while(currentpattern_.size()>temprowvals.size()*tempcolvals.size()){ currentpattern_.erase(currentpattern_.end()); } for(uint32_t irow=0; irow<temprowvals.size(); irow++){ for(uint32_t icol=0; icol<tempcolvals.size(); icol++){ std::pair<short,short> pattern(temprowvals[irow],tempcolvals[icol]); npatterns++; if(npatterns>currentpattern_.size()) currentpattern_.push_back(pattern); else currentpattern_[npatterns-1]=pattern; } } }
bool SiPixelCalibDigiProducer::store | ( | ) | [private, virtual] |
Definition at line 92 of file SiPixelCalibDigiProducer.cc.
References calib_, iEventCounter_, and pattern_repeat_.
Referenced by checkPixel(), and produce().
{ // std::cout << "in store() " << std::endl; if(iEventCounter_%pattern_repeat_==0){ // std::cout << "now at event " << iEventCounter_ <<" where we save the calibration information into the CMSSW digi"; return 1; } else if(iEventCounter_==calib_->expectedTotalEvents()) return 1; else return 0; return 1; }
Definition at line 89 of file SiPixelCalibDigiProducer.h.
Referenced by fill(), fillPixel(), produce(), setPattern(), and store().
Definition at line 83 of file SiPixelCalibDigiProducer.h.
bool SiPixelCalibDigiProducer::control_pattern_size_ [private] |
Definition at line 80 of file SiPixelCalibDigiProducer.h.
Referenced by checkPixel(), and produce().
std::pair<short,short> SiPixelCalibDigiProducer::currentpair_ [private] |
Definition at line 102 of file SiPixelCalibDigiProducer.h.
Referenced by checkPixel().
std::vector<std::pair<short,short> > SiPixelCalibDigiProducer::currentpattern_ [private] |
Definition at line 101 of file SiPixelCalibDigiProducer.h.
Referenced by checkPixel(), and setPattern().
std::map<uint32_t,uint32_t> SiPixelCalibDigiProducer::detid_to_fedid_ [private] |
Definition at line 99 of file SiPixelCalibDigiProducer.h.
Referenced by checkFED(), and checkPixel().
std::vector<pixelstruct> SiPixelCalibDigiProducer::detPixelMap_ [private] |
Definition at line 97 of file SiPixelCalibDigiProducer.h.
std::map<pixelstruct,SiPixelCalibDigiError> SiPixelCalibDigiProducer::error_data_ [private] |
Definition at line 95 of file SiPixelCalibDigiProducer.h.
Referenced by checkPixel(), clear(), and produce().
int SiPixelCalibDigiProducer::errorType [private] |
Definition at line 82 of file SiPixelCalibDigiProducer.h.
uint32_t SiPixelCalibDigiProducer::iEventCounter_ [private] |
Definition at line 77 of file SiPixelCalibDigiProducer.h.
Referenced by checkPixel(), fill(), produce(), setPattern(), and store().
bool SiPixelCalibDigiProducer::ignore_non_pattern_ [private] |
Definition at line 79 of file SiPixelCalibDigiProducer.h.
Referenced by checkPixel().
bool SiPixelCalibDigiProducer::includeErrors_ [private] |
Definition at line 81 of file SiPixelCalibDigiProducer.h.
Referenced by checkPixel(), produce(), and SiPixelCalibDigiProducer().
std::string SiPixelCalibDigiProducer::instance_ [private] |
Definition at line 85 of file SiPixelCalibDigiProducer.h.
std::map<pixelstruct,SiPixelCalibDigi> SiPixelCalibDigiProducer::intermediate_data_ [private] |
Definition at line 94 of file SiPixelCalibDigiProducer.h.
Referenced by clear(), fillPixel(), and produce().
std::string SiPixelCalibDigiProducer::label_ [private] |
Definition at line 84 of file SiPixelCalibDigiProducer.h.
uint32_t SiPixelCalibDigiProducer::number_of_pixels_per_pattern_ [private] |
Definition at line 86 of file SiPixelCalibDigiProducer.h.
Referenced by clear().
uint32_t SiPixelCalibDigiProducer::pattern_repeat_ [private] |
Definition at line 98 of file SiPixelCalibDigiProducer.h.
Referenced by produce(), setPattern(), and store().
edm::InputTag SiPixelCalibDigiProducer::src_ [private] |
Definition at line 76 of file SiPixelCalibDigiProducer.h.
Referenced by fill().
Definition at line 91 of file SiPixelCalibDigiProducer.h.
Referenced by checkFED(), checkPixel(), and produce().
Definition at line 90 of file SiPixelCalibDigiProducer.h.
Referenced by produce().
bool SiPixelCalibDigiProducer::use_realeventnumber_ [private] |
Definition at line 87 of file SiPixelCalibDigiProducer.h.
Referenced by produce().