00001 #include "CondTools/SiStrip/plugins/SiStripNoisesBuilder.h"
00002 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
00003 #include <iostream>
00004 #include <fstream>
00005
00006 SiStripNoisesBuilder::SiStripNoisesBuilder( const edm::ParameterSet& iConfig ):
00007 fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
00008 printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug",1)){}
00009
00010
00011 void SiStripNoisesBuilder::analyze(const edm::Event& evt, const edm::EventSetup& iSetup){
00012
00013 unsigned int run=evt.id().run();
00014
00015 edm::LogInfo("SiStripNoisesBuilder") << "... creating dummy SiStripNoises Data for Run " << run << "\n " << std::endl;
00016
00017 SiStripNoises* obj = new SiStripNoises();
00018
00019 SiStripDetInfoFileReader reader(fp_.fullPath());
00020
00021 const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos = reader.getAllData();
00022
00023 int count=-1;
00024 for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); it++){
00025 count++;
00026
00027 SiStripNoises::InputVector theSiStripVector;
00028 for(int strip=0; strip<128*it->second.nApvs; ++strip){
00029
00030 float MeanNoise = 5;
00031 float RmsNoise = 1;
00032
00033 float noise = RandGauss::shoot(MeanNoise,RmsNoise);
00034
00035
00036
00037
00038 obj->setData(noise,theSiStripVector);
00039 if (count<printdebug_)
00040 edm::LogInfo("SiStripNoisesBuilder") << "detid " << it->first << " \t"
00041 << " strip " << strip << " \t"
00042 << noise << " \t"
00043 << theSiStripVector.back()/10 << " \t"
00044 << std::endl;
00045 }
00046
00047 if ( ! obj->put(it->first,theSiStripVector) )
00048 edm::LogError("SiStripNoisesBuilder")<<"[SiStripNoisesBuilder::analyze] detid already exists"<<std::endl;
00049 }
00050
00051
00052
00053 edm::Service<cond::service::PoolDBOutputService> mydbservice;
00054
00055 if( mydbservice.isAvailable() ){
00056 if ( mydbservice->isNewTagRequest("SiStripNoisesRcd") ){
00057 mydbservice->createNewIOV<SiStripNoises>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripNoisesRcd");
00058 } else {
00059
00060 mydbservice->appendSinceTime<SiStripNoises>(obj,mydbservice->currentTime(),"SiStripNoisesRcd");
00061 }
00062 }else{
00063 edm::LogError("SiStripNoisesBuilder")<<"Service is unavailable"<<std::endl;
00064 }
00065 }
00066