CMS 3D CMS Logo

SiStripPedestalsBuilder.cc

Go to the documentation of this file.
00001 #include "CondTools/SiStrip/plugins/SiStripPedestalsBuilder.h"
00002 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
00003 #include <iostream>
00004 #include <fstream>
00005 
00006 SiStripPedestalsBuilder::SiStripPedestalsBuilder( 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 SiStripPedestalsBuilder::analyze(const edm::Event& evt, const edm::EventSetup& iSetup){
00012 
00013   unsigned int run=evt.id().run();
00014 
00015   edm::LogInfo("SiStripPedestalsBuilder") << "... creating dummy SiStripPedestals Data for Run " << run << "\n " << std::endl;
00016 
00017   SiStripPedestals* obj = new SiStripPedestals();
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     //Generate Pedestal for det detid
00027     SiStripPedestals::InputVector theSiStripVector;   
00028     for(int strip=0; strip<128*it->second.nApvs;++strip){
00029 
00030       float MeanPed   = 100;
00031       float RmsPed    = 5;
00032 
00033       float ped = RandGauss::shoot(MeanPed,RmsPed);
00034 
00035       if ( count<printdebug_)
00036         edm::LogInfo("SiStripPedestalsBuilder") << "detid "  << it->first << " \t"
00037                                                 << " strip " << strip << " \t"
00038                                                 << ped       << " \t" 
00039                                                 << std::endl;       
00040       obj->setData(ped,theSiStripVector);
00041     }
00042 
00043     //SiStripPedestals::Range range(theSiStripVector.begin(),theSiStripVector.end());
00044     if ( ! obj->put(it->first,theSiStripVector) )
00045       edm::LogError("SiStripPedestalsBuilder")<<"[SiStripPedestalsBuilder::analyze] detid already exists"<<std::endl;
00046   }
00047 
00048 
00049   //End now write sistrippedestals data in DB
00050   edm::Service<cond::service::PoolDBOutputService> mydbservice;
00051 
00052   if( mydbservice.isAvailable() ){
00053     if ( mydbservice->isNewTagRequest("SiStripPedestalsRcd") ){
00054       mydbservice->createNewIOV<SiStripPedestals>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripPedestalsRcd");
00055     } else {
00056       //mydbservice->createNewIOV<SiStripPedestals>(obj,mydbservice->currentTime(),"SiStripPedestalsRcd");      
00057       mydbservice->appendSinceTime<SiStripPedestals>(obj,mydbservice->currentTime(),"SiStripPedestalsRcd");      
00058     }
00059   }else{
00060     edm::LogError("SiStripPedestalsBuilder")<<"Service is unavailable"<<std::endl;
00061   }
00062 }
00063 

Generated on Tue Jun 9 17:26:58 2009 for CMSSW by  doxygen 1.5.4