#include <CalibTracker/SiStripPedestals/interface/SiStripOfflinePedNoiseToDb.h>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob (edm::EventSetup const &) |
virtual void | endJob () |
SiStripOfflinePedNoiseToDb (const edm::ParameterSet &) | |
~SiStripOfflinePedNoiseToDb () | |
Private Attributes | |
bool | appendMode_ |
ApvAnalysisFactory * | apvFactory_ |
edm::ParameterSet | conf_ |
DaqMonitorBEInterface * | dbe_ |
int | nEvTot_ |
int | NumCMstripsInGroup_ |
edm::ParameterSet | pedsPSet_ |
std::vector< uint32_t > | SelectedDetIds_ |
SiStripNoises * | SiStripNoises_ |
SiStripPedestals * | SiStripPedestals_ |
int | theEventInitNumber_ |
int | theEventIterNumber_ |
Definition at line 37 of file SiStripOfflinePedNoiseToDb.h.
cms::SiStripOfflinePedNoiseToDb::SiStripOfflinePedNoiseToDb | ( | const edm::ParameterSet & | conf | ) | [explicit] |
Definition at line 28 of file SiStripOfflinePedNoiseToDb.cc.
References edm::ParameterSet::getParameter(), NumCMstripsInGroup_, p, theEventInitNumber_, and theEventIterNumber_.
00028 : 00029 conf_(conf), 00030 apvFactory_(0), 00031 nEvTot_(0), 00032 appendMode_(conf.getUntrackedParameter<bool>("appendMode",true)){ 00033 edm::ParameterSet p = conf.getParameter<edm::ParameterSet>("PedestalsPSet"); 00034 theEventInitNumber_ = p.getParameter<int>("NumberOfEventsForInit"); 00035 theEventIterNumber_ = p.getParameter<int>("NumberOfEventsForIteration"); 00036 NumCMstripsInGroup_ = p.getParameter<int>("NumCMstripsInGroup"); 00037 }
cms::SiStripOfflinePedNoiseToDb::~SiStripOfflinePedNoiseToDb | ( | ) |
Definition at line 40 of file SiStripOfflinePedNoiseToDb.cc.
References apvFactory_.
00041 { 00042 if (apvFactory_) {delete apvFactory_;} 00043 }
void cms::SiStripOfflinePedNoiseToDb::analyze | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 78 of file SiStripOfflinePedNoiseToDb.cc.
References appendMode_, apvFactory_, conf_, reco_application_tbsim_simpleTBanalysis_cfg::digiProducer, lat::endl(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::ParameterSet::getParameter(), SelectedDetIds_, and ApvAnalysisFactory::update().
00079 { 00080 if ( appendMode_ ){ 00081 edm::ESHandle<SiStripPedestals> peds; 00082 iSetup.get<SiStripPedestalsRcd>().get(peds); 00083 00084 edm::ESHandle<SiStripNoises> noises; 00085 iSetup.get<SiStripNoisesRcd>().get(noises); 00086 } 00087 00088 // retrieve producer name of input StripDigiCollection 00089 std::string digiProducer = conf_.getParameter<std::string>("DigiProducer"); 00090 std::string digiType = conf_.getParameter<std::string>("DigiType"); 00091 00092 // get DigiCollection object from Event 00093 edm::Handle< edm::DetSetVector<SiStripRawDigi> > digi_collection; 00094 //you have a collection as there are all the digis for the event for every detector 00095 iEvent.getByLabel(digiProducer, digiType, digi_collection); 00096 00097 // loop over all DetIds to be implement 00098 for(std::vector<uint32_t>::const_iterator myDet = SelectedDetIds_.begin();myDet!=SelectedDetIds_.end();myDet++) 00099 { 00100 uint32_t detid = *myDet; 00101 if (detid < 1) 00102 continue; 00103 00104 std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = digi_collection->find( detid ); 00105 if ( digis->data.empty() ) { 00106 edm::LogError("SiStripOfflinePedNoiseToDb") << "[" << __PRETTY_FUNCTION__ <<"] Zero digis found for DetId " << detid << std::endl; 00107 }else{ 00108 apvFactory_->update(detid, (*digis)); 00109 } 00110 } 00111 }
void cms::SiStripOfflinePedNoiseToDb::beginJob | ( | edm::EventSetup const & | es | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 45 of file SiStripOfflinePedNoiseToDb.cc.
References apvFactory_, conf_, lat::endl(), edm::EventSetup::get(), edm::ParameterSet::getParameter(), ApvAnalysisFactory::instantiateApvs(), SelectedDetIds_, SiStripNoises_, and SiStripPedestals_.
00045 { 00046 //ApvAnalysisFactory 00047 apvFactory_ = new ApvAnalysisFactory(conf_.getParameter<edm::ParameterSet>("PedestalsPSet")); 00048 00049 //Pedestal and Noise objects ... 00050 SiStripPedestals_ = new SiStripPedestals(); 00051 SiStripNoises_ = new SiStripNoises(); 00052 00053 //Get SiStripDetCabling 00054 edm::ESHandle<SiStripDetCabling> SiStripDetCabling_; 00055 es.get<SiStripDetCablingRcd>().get( SiStripDetCabling_ ); 00056 00057 // get list of active detectors from SiStripDetCabling - this will change and be taken from a SiStripDetControl object 00058 SelectedDetIds_.clear(); 00059 SiStripDetCabling_->addActiveDetectorsRawIds(SelectedDetIds_); 00060 00061 00062 edm::LogInfo("SiStripOfflinePedNoiseToDb") << "Number of detid detected " << SelectedDetIds_.size() << std::endl; 00063 for (std::vector<uint32_t>::const_iterator detid_iter=SelectedDetIds_.begin();detid_iter!=SelectedDetIds_.end();detid_iter++){ 00064 00065 uint32_t detid = *detid_iter; 00066 00067 if (detid < 1){ 00068 edm::LogError("SiStripOfflinePedNoiseToDb") << "[" << __PRETTY_FUNCTION__ <<"] invalid detid " << detid << std::endl; 00069 continue; 00070 } 00071 uint16_t nApvPairs = SiStripDetCabling_->getConnections(detid).begin()->nApvPairs(); 00072 edm::LogInfo("SiStripOfflinePedNoiseToDb") << " Instantiating apvFactory for detid " << detid << " with " << nApvPairs << " apvPairs" << std::endl; 00073 apvFactory_->instantiateApvs(detid,2*nApvPairs); 00074 } 00075 }
Reimplemented from edm::EDAnalyzer.
Definition at line 113 of file SiStripOfflinePedNoiseToDb.cc.
References appendMode_, apvFactory_, conf_, lat::endl(), exception, Exception, ApvAnalysisFactory::getMask(), ApvAnalysisFactory::getNoise(), ApvAnalysisFactory::getPedestal(), edm::ParameterSet::getUntrackedParameter(), edm::Service< T >::isAvailable(), LogDebug, SiStripPedestals::put(), SiStripNoises::put(), SelectedDetIds_, SiStripPedestals::setData(), SiStripNoises::setData(), SiStripNoises_, SiStripPedestals_, ss, and cms::Exception::what().
00113 { 00114 00115 // loop over all DetIds to be implement 00116 for(std::vector<uint32_t>::const_iterator myDet = SelectedDetIds_.begin();myDet!=SelectedDetIds_.end();myDet++){ 00117 uint32_t detid = *myDet; 00118 if (detid < 1) 00119 continue; 00120 00121 //Get Pedestal and Noise for detid 00122 SiStripPedestals::InputVector theSiStripPedVector; 00123 SiStripNoises::InputVector theSiStripNoiseVector; 00124 00125 std::vector<float> tmp_ped; 00126 std::vector<float> tmp_noi; 00127 TkApvMask::MaskType tmp_bad; 00128 tmp_ped.clear(); 00129 tmp_noi.clear(); 00130 apvFactory_->getPedestal(detid, tmp_ped); 00131 apvFactory_->getNoise(detid, tmp_noi); 00132 apvFactory_->getMask(detid, tmp_bad); 00133 00134 if (tmp_ped.size()!=tmp_noi.size()){ 00135 std::stringstream ss; 00136 ss << "[" << __PRETTY_FUNCTION__ <<"] pedestal and noise container have different size!!" << detid << std::endl; 00137 edm::LogError("SiStripOfflinePedNoiseToDb") << ss.str(); 00138 throw cms::Exception("") << ss.str(); 00139 } 00140 00141 size_t istop=tmp_ped.size(); 00142 for (size_t ibin=0; ibin<istop; ibin++){ 00143 float ped = tmp_ped[ibin]; 00144 float lTh = 2.; 00145 float hTh = 5.; 00146 float noise = tmp_noi[ibin]; 00147 bool disable = (tmp_bad[ibin] == 0) ? false : true; 00148 00149 LogDebug("SiStripOfflinePedNoiseToDb") <<"DetId " << detid << " Ped Noise lth hth disable " << ped << " " << noise << " " << lTh << " " << hTh << " " << disable << std::endl; 00150 SiStripPedestals_->setData(ped,theSiStripPedVector); 00151 SiStripNoises_->setData(noise,theSiStripNoiseVector); 00152 } 00153 00154 { 00155 edm::LogInfo("SiStripOfflinePedNoiseToDb") <<"uploading Ped for detid "<< detid << " vector size " << theSiStripPedVector.size() <<std::endl; 00156 if ( ! SiStripPedestals_->put(detid,theSiStripPedVector) ) 00157 edm::LogError("SiStripOfflinePedNoiseToDb") <<"[SiStripOfflinePedNoiseToDb::analyze] detid " << detid << "already exists"<<std::endl; 00158 } 00159 { 00160 edm::LogInfo("SiStripOfflinePedNoiseToDb") <<"uploading Noise for detid "<< detid << " vector size " << theSiStripNoiseVector.size() <<std::endl; 00161 if ( ! SiStripNoises_->put(detid,theSiStripNoiseVector) ) 00162 edm::LogError("SiStripNoiseDB") << "[SiStripNoiseDB::analyze] detid " << detid << "already exists"<<std::endl; 00163 } 00164 } 00165 edm::LogInfo("SiStripOfflinePedNoiseToDb") << "... now write SiStrip Ped Noise data in DB" << std::endl; 00166 00167 edm::Service<cond::service::PoolDBOutputService> mydbservice; 00168 if( mydbservice.isAvailable() ){ 00169 try{ 00170 uint32_t callbackToken; 00171 unsigned long long tillTime; 00172 if ( appendMode_){ 00173 tillTime = conf_.getUntrackedParameter<uint32_t>("StartIOV",0); 00174 if (tillTime == 0) 00175 tillTime = mydbservice->currentTime()-1; //the -1 allows to start the new IOV from the pedestal run under analysis 00176 else 00177 tillTime--; //the -1 allows to start the new IOV from the pedestal run under analysis 00178 } 00179 else 00180 tillTime = mydbservice->endOfTime(); 00181 00182 edm::LogInfo("SiStripOfflinePedNoiseToDb")<<" tillTime = " << tillTime << std::endl; 00183 00184 if (conf_.getUntrackedParameter<bool>("doPedNoiseTansfer",false)){ 00185 mydbservice->createNewIOV<SiStripPedestals>(SiStripPedestals_,mydbservice->beginOfTime(),tillTime,"SiStripPedestalsRcd"); 00186 mydbservice->createNewIOV<SiStripNoises>(SiStripNoises_,mydbservice->beginOfTime(),tillTime,"SiStripNoisesRcd"); 00187 } 00188 }catch(const cond::Exception& er){ 00189 edm::LogError("SiStripOfflinePedNoiseToDb")<<er.what()<<std::endl; 00190 }catch(const std::exception& er){ 00191 edm::LogError("SiStripOfflinePedNoiseToDb")<<"caught std::exception "<<er.what()<<std::endl; 00192 }catch(...){ 00193 edm::LogError("SiStripOfflinePedNoiseToDb")<<"Funny error"<<std::endl; 00194 } 00195 }else{ 00196 edm::LogError("SiStripOfflinePedNoiseToDb")<<"Service is unavailable"<<std::endl; 00197 } 00198 }
Definition at line 52 of file SiStripOfflinePedNoiseToDb.h.
Referenced by analyze(), beginJob(), endJob(), and ~SiStripOfflinePedNoiseToDb().
Definition at line 48 of file SiStripOfflinePedNoiseToDb.h.
Referenced by analyze(), beginJob(), and endJob().
DaqMonitorBEInterface* cms::SiStripOfflinePedNoiseToDb::dbe_ [private] |
Definition at line 51 of file SiStripOfflinePedNoiseToDb.h.
int cms::SiStripOfflinePedNoiseToDb::nEvTot_ [private] |
Definition at line 59 of file SiStripOfflinePedNoiseToDb.h.
Definition at line 62 of file SiStripOfflinePedNoiseToDb.h.
Referenced by SiStripOfflinePedNoiseToDb().
Definition at line 49 of file SiStripOfflinePedNoiseToDb.h.
std::vector<uint32_t> cms::SiStripOfflinePedNoiseToDb::SelectedDetIds_ [private] |
Definition at line 54 of file SiStripOfflinePedNoiseToDb.h.
Referenced by analyze(), beginJob(), and endJob().
Definition at line 60 of file SiStripOfflinePedNoiseToDb.h.
Referenced by SiStripOfflinePedNoiseToDb().
Definition at line 61 of file SiStripOfflinePedNoiseToDb.h.
Referenced by SiStripOfflinePedNoiseToDb().