CMS 3D CMS Logo

PxCPEdbUploader.cc

Go to the documentation of this file.
00001 // Package:    SiPixelErrorEstimation
00002 // Class:      PxCPEdbUploader
00003 // 
00011 //
00012 // Original Author:  "David Fehling"
00013 //         Created:  Fri Aug  17 8:34:48 CDT 2007
00014 
00015 
00016 // user include files
00017 #include <iostream>
00018 #include <fstream>
00019 
00020 #include "CalibTracker/SiPixelErrorEstimation/interface/PxCPEdbUploader.h"
00021 
00022 #include "CondFormats/SiPixelObjects/interface/SiPixelCPEParmErrors.h"
00023 
00024 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00025 #include "FWCore/ServiceRegistry/interface/Service.h"
00026 
00027 
00028 PxCPEdbUploader::PxCPEdbUploader(const edm::ParameterSet& iConfig):
00029         theFileName( iConfig.getParameter<std::string>("fileName") )
00030 {
00031 }
00032 
00033 
00034 PxCPEdbUploader::~PxCPEdbUploader()
00035 {
00036 }
00037 
00038 void
00039 PxCPEdbUploader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00040 {
00041 }
00042 
00043 void 
00044 PxCPEdbUploader::beginJob(const edm::EventSetup&)
00045 {
00046 }
00047 
00048 void 
00049 PxCPEdbUploader::endJob()
00050 {
00051   //--- Make the POOL-ORA thingy to store the vector of error structs (DbEntry)
00052   SiPixelCPEParmErrors* pErrors = new SiPixelCPEParmErrors();
00053   pErrors->reserve();   // Default 1000 elements.  Optimize?  &&&
00054 
00055   //--- Open the file
00056   std::ifstream in;
00057   in.open(theFileName.c_str());
00058 
00059         int part;
00060         float version = 1.3;
00061         
00062   SiPixelCPEParmErrors::DbEntry Entry;
00063   in >> part >> Entry.bias >> Entry.pix_height >> Entry.ave_Qclus >> Entry.sigma >> Entry.rms;
00064 
00065   while(!in.eof()) {
00066     pErrors->push_back( Entry );
00067 
00068     in >> part            >> Entry.bias  >> Entry.pix_height
00069                          >> Entry.ave_Qclus >> Entry.sigma >> Entry.rms;
00070   }
00071   //--- Finished parsing the file, we're done.
00072   in.close();
00073 
00074         //--- Specify the current binning sizes to use
00075         SiPixelCPEParmErrors::DbEntryBinSize ErrorsBinSize;
00076         //--- Part = 1 By
00077         ErrorsBinSize.partBin_size  =   0;
00078         ErrorsBinSize.sizeBin_size  =  40;
00079         ErrorsBinSize.alphaBin_size =  10;
00080         ErrorsBinSize.betaBin_size  =   1;
00081         pErrors->push_back_bin(ErrorsBinSize);
00082   //--- Part = 2 Bx
00083         ErrorsBinSize.partBin_size  = 240;
00084         ErrorsBinSize.alphaBin_size =   1;
00085         ErrorsBinSize.betaBin_size  =  10;
00086         pErrors->push_back_bin(ErrorsBinSize);
00087         //--- Part = 3 Fy
00088         ErrorsBinSize.partBin_size  = 360;
00089         ErrorsBinSize.alphaBin_size =  10;
00090         ErrorsBinSize.betaBin_size  =   1;
00091         pErrors->push_back_bin(ErrorsBinSize);
00092         //--- Part = 4 Fx
00093         ErrorsBinSize.partBin_size  = 400;
00094         ErrorsBinSize.alphaBin_size =   1;
00095         ErrorsBinSize.betaBin_size  =  10;
00096         pErrors->push_back_bin(ErrorsBinSize);
00097 
00098         //--- Specify the Version
00099         pErrors->set_version(version);
00100 
00101 
00102   //--- Create a new IOV
00103   edm::Service<cond::service::PoolDBOutputService> poolDbService;
00104 
00105   if( poolDbService.isAvailable() ) {
00106     if ( poolDbService->isNewTagRequest("SiPixelCPEParmErrorsRcd") )
00107       poolDbService->
00108         createNewIOV<SiPixelCPEParmErrors>( pErrors,
00109                                             poolDbService->beginOfTime(),
00110                                             poolDbService->endOfTime(),
00111                                             "SiPixelCPEParmErrorsRcd"  );
00112     else
00113       poolDbService->
00114         appendSinceTime<SiPixelCPEParmErrors>( pErrors, 
00115                                                poolDbService->currentTime(),
00116                                                "SiPixelCPEParmErrorsRcd" );
00117   }
00118   else {
00119     std::cout << "Pool Service Unavailable" << std::endl;
00120     // &&& throw an exception???
00121   }
00122 }
00123 

Generated on Tue Jun 9 17:25:45 2009 for CMSSW by  doxygen 1.5.4