Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-12 00:00:53

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiPixelCalibConfigurationObjectMaker
0004 // Class:      SiPixelCalibConfigurationObjectMaker
0005 //
0006 /**\class SiPixelCalibConfigurationObjectMaker SiPixelCalibConfigurationObjectMaker.cc CalibTracker/SiPixelTools/src/SiPixelCalibConfigurationObjectMaker.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Freya Blekman
0015 //         Created:  Wed Sep 19 13:43:52 CEST 2007
0016 // $Id: SiPixelCalibConfigurationObjectMaker.cc,v 1.5 2009/10/21 15:53:31 heyburn Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0025 
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "CondFormats/SiPixelObjects/interface/SiPixelCalibConfiguration.h"
0030 #include "CalibFormats/SiPixelObjects/interface/PixelCalibConfiguration.h"
0031 
0032 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0033 #include "FWCore/ServiceRegistry/interface/Service.h"
0034 #include <string>
0035 //
0036 // class decleration
0037 //
0038 
0039 class SiPixelCalibConfigurationObjectMaker : public edm::one::EDAnalyzer<> {
0040 public:
0041   explicit SiPixelCalibConfigurationObjectMaker(const edm::ParameterSet&);
0042   ~SiPixelCalibConfigurationObjectMaker() override;
0043   void analyze(const edm::Event&, const edm::EventSetup&) override;
0044 
0045 private:
0046   // ----------member data ---------------------------
0047   std::string inputfilename;
0048 };
0049 
0050 //
0051 // constants, enums and typedefs
0052 //
0053 
0054 //
0055 // static data member definitions
0056 //
0057 
0058 //
0059 // constructors and destructor
0060 //
0061 SiPixelCalibConfigurationObjectMaker::SiPixelCalibConfigurationObjectMaker(const edm::ParameterSet& iConfig)
0062     : inputfilename(iConfig.getUntrackedParameter<std::string>(
0063           "inputFileName", "/afs/cern.ch/cms/Tracker/Pixel/forward/ryd/calib_070106d.dat"))
0064 
0065 {
0066   //now do what ever initialization is needed
0067   ::putenv((char*)"CORAL_AUTH_USER=testuser");
0068   ::putenv((char*)"CORAL_AUTH_PASSWORD=test");
0069 }
0070 
0071 SiPixelCalibConfigurationObjectMaker::~SiPixelCalibConfigurationObjectMaker() = default;
0072 
0073 //
0074 // member functions
0075 //
0076 
0077 void SiPixelCalibConfigurationObjectMaker::analyze(const edm::Event&, const edm::EventSetup&) {
0078   pos::PixelCalibConfiguration fancyCalib(inputfilename);
0079   SiPixelCalibConfiguration myCalib(fancyCalib);
0080 
0081   std::string fixedmode = fancyCalib.mode();
0082   std::string tobereplaced = "WithSLink";
0083   edm::LogPrint("SiPixelCalibConfigurationObjectMaker") << "mode = " << fixedmode << std::endl;
0084   if (fixedmode.find(tobereplaced) != std::string::npos)
0085     fixedmode.erase(fixedmode.find(tobereplaced), tobereplaced.length());
0086   edm::LogPrint("SiPixelCalibConfigurationObjectMaker") << "mode = " << fixedmode << std::endl;
0087   myCalib.setCalibrationMode(fixedmode);
0088 
0089   edm::Service<cond::service::PoolDBOutputService> poolDbService;
0090 
0091   if (poolDbService.isAvailable()) {
0092     if (poolDbService->isNewTagRequest("SiPixelCalibConfigurationRcd")) {
0093       poolDbService->createOneIOV<SiPixelCalibConfiguration>(
0094           myCalib, poolDbService->beginOfTime(), "SiPixelCalibConfigurationRcd");
0095     } else {
0096       poolDbService->appendOneIOV<SiPixelCalibConfiguration>(
0097           myCalib, poolDbService->currentTime(), "SiPixelCalibConfigurationRcd");
0098     }
0099   }
0100 }
0101 
0102 //define this as a plug-in
0103 DEFINE_FWK_MODULE(SiPixelCalibConfigurationObjectMaker);