CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/CondTools/SiStrip/plugins/SiStripFedCablingBuilder.cc

Go to the documentation of this file.
00001 #include "CondTools/SiStrip/plugins/SiStripFedCablingBuilder.h"
00002 #include "CalibFormats/SiStripObjects/interface/SiStripFecCabling.h"
00003 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00004 #include "CalibFormats/SiStripObjects/interface/SiStripRegionCabling.h"
00005 #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
00006 #include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h"
00007 #include "CalibTracker/Records/interface/SiStripFecCablingRcd.h"
00008 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
00009 #include "CalibTracker/Records/interface/SiStripRegionCablingRcd.h"
00010 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 #include "FWCore/Framework/interface/Run.h"
00013 #include <iostream>
00014 #include <fstream>
00015 #include <sstream>
00016 
00017 // -----------------------------------------------------------------------------
00018 // 
00019 SiStripFedCablingBuilder::SiStripFedCablingBuilder( const edm::ParameterSet& pset ) :
00020   printFecCabling_( pset.getUntrackedParameter<bool>("PrintFecCabling",false) ),
00021   printDetCabling_( pset.getUntrackedParameter<bool>("PrintDetCabling",false) ),
00022   printRegionCabling_( pset.getUntrackedParameter<bool>("PrintRegionCabling",false) )
00023 {;}
00024 
00025 // -----------------------------------------------------------------------------
00026 // 
00027 void SiStripFedCablingBuilder::beginRun( const edm::Run& run, 
00028                                          const edm::EventSetup& setup ) {
00029 
00030   edm::LogInfo("SiStripFedCablingBuilder") << "... creating dummy SiStripFedCabling Data for Run " << run.run() << "\n " << std::endl;
00031 
00032   edm::LogVerbatim("SiStripFedCablingBuilder") 
00033     << "[SiStripFedCablingBuilder::" << __func__ << "]"
00034     << " Retrieving FED cabling...";
00035   edm::ESHandle<SiStripFedCabling> fed;
00036   setup.get<SiStripFedCablingRcd>().get( fed ); 
00037 
00038   edm::LogVerbatim("SiStripFedCablingBuilder") 
00039     << "[SiStripFedCablingBuilder::" << __func__ << "]"
00040     << " Retrieving FEC cabling...";
00041   edm::ESHandle<SiStripFecCabling> fec;
00042   setup.get<SiStripFecCablingRcd>().get( fec ); 
00043 
00044   edm::LogVerbatim("SiStripFedCablingBuilder") 
00045     << "[SiStripFedCablingBuilder::" << __func__ << "]"
00046     << " Retrieving DET cabling...";
00047   edm::ESHandle<SiStripDetCabling> det;
00048   setup.get<SiStripDetCablingRcd>().get( det ); 
00049 
00050   edm::LogVerbatim("SiStripFedCablingBuilder") 
00051     << "[SiStripFedCablingBuilder::" << __func__ << "]"
00052     << " Retrieving REGION cabling...";
00053   edm::ESHandle<SiStripRegionCabling> region;
00054   setup.get<SiStripRegionCablingRcd>().get( region ); 
00055 
00056   if ( !fed.isValid() ) {
00057     edm::LogError("SiStripFedCablingBuilder") 
00058       << " Invalid handle to FED cabling object: ";
00059     return;
00060   }
00061   
00062   {
00063     std::stringstream ss;
00064     ss << "[SiStripFedCablingBuilder::" << __func__ << "]"
00065        << " VERBOSE DEBUG" << std::endl;
00066     fed->print( ss );
00067     ss << std::endl;
00068     if ( printFecCabling_ && fec.isValid() ) { fec->print( ss ); }
00069     ss << std::endl;
00070     if ( printDetCabling_ && det.isValid() ) { det->print( ss ); }
00071     ss << std::endl;
00072     if ( printRegionCabling_ && region.isValid() ) { region->print( ss ); }
00073     ss << std::endl;
00074     edm::LogVerbatim("SiStripFedCablingBuilder") << ss.str();
00075   }
00076   
00077   {
00078     std::stringstream ss;
00079     ss << "[SiStripFedCablingBuilder::" << __func__ << "]"
00080        << " TERSE DEBUG" << std::endl;
00081     fed->terse( ss );
00082     ss << std::endl;
00083     edm::LogVerbatim("SiStripFedCablingBuilder") << ss.str();
00084   }
00085   
00086   {
00087     std::stringstream ss;
00088     ss << "[SiStripFedCablingBuilder::" << __func__ << "]"
00089        << " SUMMARY DEBUG" << std::endl;
00090     fed->summary( ss );
00091     ss << std::endl;
00092     edm::LogVerbatim("SiStripFedCablingBuilder") << ss.str();
00093   }
00094   
00095   edm::LogVerbatim("SiStripFedCablingBuilder") 
00096     << "[SiStripFedCablingBuilder::" << __func__ << "]"
00097     << " Copying FED cabling...";
00098   SiStripFedCabling* obj = new SiStripFedCabling( *( fed.product() ) );
00099   
00100   //End now write sistripnoises data in DB
00101   edm::Service<cond::service::PoolDBOutputService> mydbservice;
00102 
00103   if( mydbservice.isAvailable() ){
00104     if ( mydbservice->isNewTagRequest("SiStripFedCablingRcd") ){
00105       mydbservice->createNewIOV<SiStripFedCabling>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripFedCablingRcd");
00106     } else {  
00107       mydbservice->appendSinceTime<SiStripFedCabling>(obj,mydbservice->currentTime(),"SiStripFedCablingRcd");      
00108     }
00109   }else{
00110     edm::LogError("SiStripFedCablingBuilder")<<"Service is unavailable"<<std::endl;
00111   }
00112 }
00113