00001 #include "CondTools/SiStrip/plugins/SiStripPerformanceSummaryBuilder.h"
00002 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
00003 #include <iostream>
00004 #include <fstream>
00005
00006 SiStripPerformanceSummaryBuilder::SiStripPerformanceSummaryBuilder(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 void SiStripPerformanceSummaryBuilder::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00011 SiStripPerformanceSummary* psummary = new SiStripPerformanceSummary();
00012
00013
00014 SiStripDetInfoFileReader reader(fp_.fullPath());
00015
00016
00017 for(std::vector<uint32_t>::const_iterator idet = reader.getAllDetIds().begin(); idet != reader.getAllDetIds().end(); ++idet){
00018
00019 float clusterSizeMean = (float) RandGauss::shoot(4.,2.);
00020 float clusterSizeRMS = (float) RandGauss::shoot(2.,1.);
00021 float clusterChargeMean = (float) RandGauss::shoot(70.,10.);
00022 float clusterChargeRMS = (float) RandGauss::shoot(10.,1.);
00023 float occupancyMean = (float) RandGauss::shoot(50.,20.);
00024 float occupancyRMS = (float) RandGauss::shoot(20.,4.);
00025 float noisyStrips = (float) RandGauss::shoot(7.,1.);
00026
00027 psummary->setClusterSize(*idet, clusterSizeMean, clusterSizeRMS);
00028 psummary->setClusterCharge(*idet, clusterChargeMean, clusterChargeRMS);
00029 psummary->setOccupancy(*idet, occupancyMean, occupancyRMS);
00030 psummary->setPercentNoisyStrips(*idet, noisyStrips);
00031 }
00032 clock_t presentTime = clock();
00033 psummary->setTimeValue((unsigned long long)presentTime);
00034 psummary->print();
00035
00036 edm::Service<cond::service::PoolDBOutputService> poolDbService;
00037 if( poolDbService.isAvailable() ){
00038 if ( poolDbService->isNewTagRequest( "SiStripPerformanceSummaryRcd" ) ){
00039 edm::LogInfo("Tag")<<" is new tag request.";
00040 poolDbService->createNewIOV<SiStripPerformanceSummary>( psummary, poolDbService->beginOfTime(),poolDbService->endOfTime(),"SiStripPerformanceSummaryRcd" );
00041 }else{
00042 edm::LogInfo("Tag")<<" tag exists already.";
00043 poolDbService->appendSinceTime<SiStripPerformanceSummary>( psummary, poolDbService->currentTime(),"SiStripPerformanceSummaryRcd" );
00044 }
00045 }else{
00046 edm::LogError("PoolDBOutputService")<<" Service is unavailable"<<std::endl;
00047 }
00048 }
00049