#include <CalibTracker/SiStripPedestals/interface/SiStripPedDB.h>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob (edm::EventSetup const &) |
virtual void | endJob () |
SiStripPedDB (const edm::ParameterSet &) | |
~SiStripPedDB () | |
Private Attributes | |
ApvAnalysisFactory * | apvFactory_ |
edm::ParameterSet | conf_ |
DaqMonitorBEInterface * | dbe_ |
SiStripFedCabling * | fedCabling_ |
std::vector< std::pair < uint32_t, SiStripPedestals::InputVector > > | mSiStripPedestals |
int | nEvTot_ |
int | NumCMstripsInGroup_ |
std::string | outPutFileName |
edm::ParameterSet | pedsPSet_ |
std::vector< uint32_t > | SelectedDetIds |
SiStripPedestals * | SiStripPedestals_ |
int | theEventInitNumber_ |
int | theEventIterNumber_ |
Usage: <usage>
Definition at line 69 of file SiStripPedDB.h.
SiStripPedDB::SiStripPedDB | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 20 of file SiStripPedDB.cc.
References apvFactory_, conf_, edm::ParameterSet::getParameter(), nEvTot_, NumCMstripsInGroup_, pedsPSet_, theEventInitNumber_, and theEventIterNumber_.
00021 { 00022 conf_ = iConfig; 00023 pedsPSet_ = conf_.getParameter<edm::ParameterSet>("PedestalsPSet"); 00024 nEvTot_=0; 00025 apvFactory_=0; 00026 theEventInitNumber_ = pedsPSet_.getParameter<int>("NumberOfEventsForInit"); 00027 theEventIterNumber_ = pedsPSet_.getParameter<int>("NumberOfEventsForIteration"); 00028 NumCMstripsInGroup_ = pedsPSet_.getParameter<int>("NumCMstripsInGroup"); 00029 00030 }
SiStripPedDB::~SiStripPedDB | ( | ) |
Definition at line 33 of file SiStripPedDB.cc.
References apvFactory_.
00034 { 00035 if (apvFactory_) {delete apvFactory_;} 00036 }
void SiStripPedDB::analyze | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 82 of file SiStripPedDB.cc.
References apvFactory_, conf_, reco_application_tbsim_simpleTBanalysis_cfg::digiProducer, edm::Event::getByLabel(), edm::ParameterSet::getParameter(), ApvAnalysisFactory::getPedestal(), mSiStripPedestals, nEvTot_, SelectedDetIds, SiStripPedestals::setData(), SiStripPedestals_, theEventInitNumber_, theEventIterNumber_, tmp, and ApvAnalysisFactory::update().
00083 { 00084 nEvTot_++; 00085 //Increment # of Events 00086 using namespace edm; 00087 // retrieve producer name of input StripDigiCollection 00088 std::string digiProducer = conf_.getParameter<std::string>("DigiProducer"); 00089 // get DigiCollection object from Event 00090 edm::Handle< edm::DetSetVector<SiStripRawDigi> > digi_collection; 00091 std::string digiType = "VirginRaw"; 00092 //you have a collection as there are all the digis for the event for every detector 00093 iEvent.getByLabel(digiProducer, digiType, digi_collection); 00094 00095 // loop over all DetIds to be implement 00096 for(vector<uint32_t>::const_iterator myDet = SelectedDetIds.begin();myDet!=SelectedDetIds.end();myDet++) 00097 { 00098 uint32_t detid = *myDet; 00099 vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = digi_collection->find( detid ); 00100 if ( digis->data.empty() ) { 00101 edm::LogError("MonitorDigi_tmp") << "[SiStripRawDigiToRaw::createFedBuffers] Zero digis found!"; 00102 } 00103 //cout <<"Data size "<<digis->data.size()<<endl; 00104 apvFactory_->update(detid, (*digis)); 00105 //asking for the status 00106 if((nEvTot_ - theEventInitNumber_)%theEventIterNumber_ == 1) 00107 { 00108 mSiStripPedestals.clear(); 00109 //Generate Pedestal for det detid 00110 SiStripPedestals::InputVector theSiStripVector; 00111 vector<float> tmp_ped; 00112 tmp_ped.clear(); 00113 apvFactory_->getPedestal(detid, tmp_ped); 00114 int ibin=0; 00115 for (vector<float>::const_iterator iped=tmp_ped.begin(); iped!=tmp_ped.end();iped++) { 00116 float ped = *iped; 00117 float lTh = 0.5* 12.6; 00118 float hTh = 0.5* 12.6; 00119 if (hTh < lTh){ 00120 float tmp = hTh; 00121 hTh = lTh; 00122 lTh = tmp; 00123 } 00124 SiStripPedestals_->setData(ped,theSiStripVector); 00125 ibin++; 00126 } 00127 mSiStripPedestals.push_back(make_pair(detid,theSiStripVector)); 00128 } 00129 } 00130 }
void SiStripPedDB::beginJob | ( | edm::EventSetup const & | es | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 39 of file SiStripPedDB.cc.
References apvFactory_, SiStripFedCabling::connection(), FedChannelConnection::detId(), fedCabling_, SiStripFedCabling::feds(), edm::EventSetup::get(), ApvAnalysisFactory::instantiateApvs(), FedChannelConnection::nApvPairs(), pedsPSet_, edm::ESHandle< T >::product(), SelectedDetIds, and SiStripPedestals_.
00039 { 00040 // retrieve parameters from configuration file 00041 using namespace edm; 00042 SelectedDetIds.clear(); 00043 00044 //Pedestals object ... 00045 SiStripPedestals_ = new SiStripPedestals(); 00046 00047 //ApvAnalysisFactory 00048 apvFactory_ = new ApvAnalysisFactory(pedsPSet_); 00049 00050 //getting det id from the fed cabling 00051 edm::ESHandle<SiStripFedCabling> cabling; 00052 es.get<SiStripFedCablingRcd>().get( cabling ); 00053 fedCabling_ = const_cast<SiStripFedCabling*>( cabling.product() ); 00054 00055 00056 map<uint32_t, int> detIdApv; 00057 detIdApv.clear(); 00058 //To do so I need to access cabling from FED and so on ... see rob's code 00059 // Retrieve FED ids from cabling map and iterate through 00060 const vector<uint16_t>& fed_ids = fedCabling_->feds(); 00061 vector<uint16_t>::const_iterator ifed; 00062 for ( ifed = fed_ids.begin(); ifed != fed_ids.end(); ifed++ ) { 00063 for ( uint16_t channel = 0; channel < 96; channel++ ) { 00064 const FedChannelConnection& conn = fedCabling_->connection( *ifed, channel ); 00065 uint32_t key_id = conn.detId(); 00066 int napvs = (conn.nApvPairs())*2; 00067 if(key_id > 0 && napvs >0) { 00068 00069 // cout <<"DetId before the map "<<key_id<< " "<<conn.nApvPairs()<<endl; 00070 bool newDetId = apvFactory_->instantiateApvs(key_id,napvs); 00071 if(newDetId) 00072 SelectedDetIds.push_back(key_id); 00073 } 00074 } 00075 00076 } 00077 00078 }
Reimplemented from edm::EDAnalyzer.
Definition at line 132 of file SiStripPedDB.cc.
References lat::endl(), exception, edm::Service< T >::isAvailable(), iter, mSiStripPedestals, SiStripPedestals::put(), SiStripPedestals_, and cms::Exception::what().
00132 { 00133 edm::LogInfo("SiStripPedDB") << "... now write sistrippedestals data in DB" << std::endl; 00134 00135 for (std::vector< std::pair<uint32_t, SiStripPedestals::InputVector > >::iterator iter=mSiStripPedestals.begin(); iter!=mSiStripPedestals.end();iter++) 00136 { 00137 edm::LogInfo("SiStripPedDB")<<"uploading detid "<< iter->first << " vector size " << iter->second.size() <<std::endl; 00138 if ( ! SiStripPedestals_->put(iter->first,iter->second) ) 00139 edm::LogError("SiStripPedDB") <<"[SiStripPedDB::analyze] detid " << iter->first << "already exists"<<endl; 00140 } 00141 00142 edm::Service<cond::service::PoolDBOutputService> mydbservice; 00143 00144 if( mydbservice.isAvailable() ){ 00145 try{ 00146 mydbservice->createNewIOV<SiStripPedestals>(SiStripPedestals_,mydbservice->beginOfTime(),mydbservice->endOfTime(), "SiStripPedestalsRcd"); 00147 }catch(const cond::Exception& er){ 00148 edm::LogError("SiStripPedDB")<<er.what()<<std::endl; 00149 }catch(const std::exception& er){ 00150 edm::LogError("SiStripPedDB")<<"caught std::exception "<<er.what()<<std::endl; 00151 }catch(...){ 00152 edm::LogError("SiStripPedDB")<<"Funny error"<<std::endl; 00153 } 00154 }else{ 00155 edm::LogError("SiStripPedDB")<<"Service is unavailable"<<std::endl; 00156 } 00157 }
ApvAnalysisFactory* SiStripPedDB::apvFactory_ [private] |
Definition at line 89 of file SiStripPedDB.h.
Referenced by analyze(), beginJob(), SiStripPedDB(), and ~SiStripPedDB().
edm::ParameterSet SiStripPedDB::conf_ [private] |
DaqMonitorBEInterface* SiStripPedDB::dbe_ [private] |
Definition at line 80 of file SiStripPedDB.h.
SiStripFedCabling* SiStripPedDB::fedCabling_ [private] |
std::vector< std::pair<uint32_t,SiStripPedestals::InputVector > > SiStripPedDB::mSiStripPedestals [private] |
int SiStripPedDB::nEvTot_ [private] |
int SiStripPedDB::NumCMstripsInGroup_ [private] |
std::string SiStripPedDB::outPutFileName [private] |
Definition at line 95 of file SiStripPedDB.h.
edm::ParameterSet SiStripPedDB::pedsPSet_ [private] |
std::vector<uint32_t> SiStripPedDB::SelectedDetIds [private] |
SiStripPedestals* SiStripPedDB::SiStripPedestals_ [private] |
int SiStripPedDB::theEventInitNumber_ [private] |
int SiStripPedDB::theEventIterNumber_ [private] |