#include <CalibMuon/CSCCalibration/interface/CSCPedestalsDBConditions.h>
Public Types | |
typedef const CSCDBPedestals * | ReturnType |
Public Member Functions | |
CSCPedestalsDBConditions (const edm::ParameterSet &) | |
ReturnType | produceDBPedestals (const CSCDBPedestalsRcd &) |
~CSCPedestalsDBConditions () | |
Static Public Member Functions | |
static CSCDBPedestals * | prefillDBPedestals () |
Private Member Functions | |
void | setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) |
Private Attributes | |
CSCDBPedestals * | cndbPedestals |
Definition at line 20 of file CSCPedestalsDBConditions.h.
typedef const CSCDBPedestals* CSCPedestalsDBConditions::ReturnType |
Definition at line 27 of file CSCPedestalsDBConditions.h.
CSCPedestalsDBConditions::CSCPedestalsDBConditions | ( | const edm::ParameterSet & | iConfig | ) |
Definition at line 10 of file CSCPedestalsDBConditions.cc.
References cndbPedestals, prefillDBPedestals(), produceDBPedestals(), and edm::ESProducer::setWhatProduced().
00011 { 00012 //the following line is needed to tell the framework what 00013 // data is being produced 00014 cndbPedestals = prefillDBPedestals(); 00015 // added by Zhen (changed since 1_2_0) 00016 setWhatProduced(this,&CSCPedestalsDBConditions::produceDBPedestals); 00017 findingRecord<CSCDBPedestalsRcd>(); 00018 //now do what ever other initialization is needed 00019 }
CSCPedestalsDBConditions::~CSCPedestalsDBConditions | ( | ) |
Definition at line 22 of file CSCPedestalsDBConditions.cc.
References cndbPedestals.
00023 { 00024 00025 // do anything here that needs to be done at desctruction time 00026 // (e.g. close files, deallocate resources etc.) 00027 delete cndbPedestals; 00028 }
CSCDBPedestals * CSCPedestalsDBConditions::prefillDBPedestals | ( | ) | [inline, static] |
Definition at line 47 of file CSCPedestalsDBConditions.h.
References TestMuL1L2Filter_cff::cerr, counter(), lat::endl(), cmsRelvalreport::exit, CSCDBPedestals::factor_ped, CSCDBPedestals::factor_rms, i, in, int, k, and CSCDBPedestals::pedestals.
Referenced by CSCPedestalsDBConditions().
00048 { 00049 const int PED_FACTOR=10; 00050 const int RMS_FACTOR=1000; 00051 const int MAX_SIZE = 217728; 00052 const int MAX_SHORT= 32767; 00053 CSCDBPedestals * cndbpedestals = new CSCDBPedestals(); 00054 00055 int db_index; 00056 float db_ped, db_rms; 00057 std::vector<int> db_index_id; 00058 std::vector<float> db_peds; 00059 std::vector<float> db_pedrms; 00060 int new_index; 00061 float new_ped,new_rms; 00062 std::vector<int> new_index_id; 00063 std::vector<float> new_peds; 00064 std::vector<float> new_pedrms; 00065 00066 int counter; 00067 int db_nrlines=0; 00068 int new_nrlines=0; 00069 00070 std::ifstream dbdata; 00071 dbdata.open("old_dbpeds.dat",std::ios::in); 00072 if(!dbdata) { 00073 std::cerr <<"Error: old_dbpeds.dat -> no such file!"<< std::endl; 00074 exit(1); 00075 } 00076 00077 while (!dbdata.eof() ) { 00078 dbdata >> db_index >> db_ped >> db_rms ; 00079 db_index_id.push_back(db_index); 00080 db_peds.push_back(db_ped); 00081 db_pedrms.push_back(db_rms); 00082 db_nrlines++; 00083 } 00084 dbdata.close(); 00085 00086 std::ifstream newdata; 00087 newdata.open("peds.dat",std::ios::in); 00088 if(!newdata) { 00089 std::cerr <<"Error: peds.dat -> no such file!"<< std::endl; 00090 exit(1); 00091 } 00092 00093 while (!newdata.eof() ) { 00094 newdata >> new_index >> new_ped >> new_rms ; 00095 new_index_id.push_back(new_index); 00096 new_peds.push_back(new_ped); 00097 new_pedrms.push_back(new_rms); 00098 new_nrlines++; 00099 } 00100 newdata.close(); 00101 00102 CSCDBPedestals::PedestalContainer & itemvector = cndbpedestals->pedestals; 00103 itemvector.resize(MAX_SIZE); 00104 cndbpedestals->factor_ped= int (PED_FACTOR); 00105 cndbpedestals->factor_rms= int (RMS_FACTOR); 00106 00107 for(int i=0; i<MAX_SIZE;++i){ 00108 itemvector[i].ped= (short int) (db_peds[i]*PED_FACTOR+0.5); 00109 itemvector[i].rms= (short int) (db_pedrms[i]*RMS_FACTOR+0.5); 00110 } 00111 00112 for(int i=0; i<MAX_SIZE;++i){ 00113 counter=db_index_id[i]; 00114 for (unsigned int k=0;k<new_index_id.size()-1;k++){ 00115 if(counter==new_index_id[k]){ 00116 if((short int) (fabs(new_peds[k]*PED_FACTOR+0.5))<MAX_SHORT) itemvector[counter].ped= int (new_peds[k]*PED_FACTOR+0.5); 00117 if((short int) (fabs(new_pedrms[k]*RMS_FACTOR+0.5))<MAX_SHORT) itemvector[counter].rms= int (new_pedrms[k]*RMS_FACTOR+0.5); 00118 itemvector[i] = itemvector[counter]; 00119 //std::cout<<"counter "<<counter<<" new_index_id[k] "<<new_index_id[k]<<" new_slope[k] "<<new_slope[k]<<" db_slope[k] "<<db_slope[k]<<std::endl; 00120 } 00121 } 00122 } 00123 return cndbpedestals; 00124 }
CSCPedestalsDBConditions::ReturnType CSCPedestalsDBConditions::produceDBPedestals | ( | const CSCDBPedestalsRcd & | iRecord | ) |
Definition at line 37 of file CSCPedestalsDBConditions.cc.
References cndbPedestals.
Referenced by CSCPedestalsDBConditions().
00038 { 00039 //need a new object so to not be deleted at exit 00040 CSCDBPedestals* mydata=new CSCDBPedestals( *cndbPedestals ); 00041 return mydata; 00042 00043 }
void CSCPedestalsDBConditions::setIntervalFor | ( | const edm::eventsetup::EventSetupRecordKey & | , | |
const edm::IOVSyncValue & | , | |||
edm::ValidityInterval & | oValidity | |||
) | [private, virtual] |
Implements edm::EventSetupRecordIntervalFinder.
Definition at line 45 of file CSCPedestalsDBConditions.cc.
References edm::IOVSyncValue::beginOfTime(), and edm::IOVSyncValue::endOfTime().
00047 { 00048 oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(),edm::IOVSyncValue::endOfTime()); 00049 00050 }
Definition at line 34 of file CSCPedestalsDBConditions.h.
Referenced by CSCPedestalsDBConditions(), produceDBPedestals(), and ~CSCPedestalsDBConditions().