Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:37:21

0001 #ifndef SiStripDeDx3DBuilder_H
0002 #define SiStripDeDx3DBuilder_H
0003 
0004 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0005 #include "CondFormats/PhysicsToolsObjects/interface/Histogram3D.h"
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/ServiceRegistry/interface/Service.h"
0012 #include "FWCore/Utilities/interface/Exception.h"
0013 //#include "FWCore/Utilities/interface/FileInPath.h"
0014 
0015 #include <iostream>
0016 #include <fstream>
0017 //#include "CLHEP/Random/RandFlat.h"
0018 //#include "CLHEP/Random/RandGauss.h"
0019 
0020 class SiStripDeDx3DBuilder : public edm::one::EDAnalyzer<> {
0021 public:
0022   explicit SiStripDeDx3DBuilder(const edm::ParameterSet& iConfig);
0023 
0024   ~SiStripDeDx3DBuilder(){};
0025 
0026   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0027 
0028 private:
0029   //edm::FileInPath fp_;
0030   bool printdebug_;
0031 };
0032 
0033 SiStripDeDx3DBuilder::SiStripDeDx3DBuilder(const edm::ParameterSet& iConfig) {}
0034 //  fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
0035 //  printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug",1)){}
0036 
0037 void SiStripDeDx3DBuilder::analyze(const edm::Event& evt, const edm::EventSetup& iSetup) {
0038   unsigned int run = evt.id().run();
0039 
0040   edm::LogInfo("SiStripDeDx3DBuilder")
0041       << "... creating dummy PhysicsToolsObjects::Calibration::HistogramD3D Data for Run " << run << "\n " << std::endl;
0042 
0043   //  PhysicsToolsObjects::Calibration::HistogramD2D* obj = new PhysicsTools::Calibration::HistogramD2D(300, 0., 3., 1000,0.,1000.);
0044   PhysicsTools::Calibration::HistogramD3D obj(5, 0, 5, 100, 0., 3., 100, 0., 1000.);
0045 
0046   for (int ix = 0; ix < 5; ix++) {
0047     for (int iy = 0; iy < 100; iy++) {
0048       for (int iz = 0; iz < 100; iz++) {
0049         //        edm::LogInfo("SiStripDeDx3DBuilder") << "X = " << ix << " Y = " << iy << " Z = " << iz << std::endl;
0050         obj.setBinContent(ix, iy, iz, ix + 2 * iy + 3 * iz);
0051       }
0052     }
0053   }
0054   edm::LogInfo("SiStripDeDx3DBuilder") << "HISTO HAS BEEN FILLED" << std::endl;
0055 
0056   //End now write sistripnoises data in DB
0057   edm::Service<cond::service::PoolDBOutputService> mydbservice;
0058 
0059   if (mydbservice.isAvailable()) {
0060     if (mydbservice->isNewTagRequest("SiStripDeDxProton_3D_Rcd")) {
0061       mydbservice->createOneIOV<PhysicsTools::Calibration::HistogramD3D>(
0062           obj, mydbservice->beginOfTime(), "SiStripDeDxProton_3D_Rcd");
0063     } else {
0064       mydbservice->appendOneIOV<PhysicsTools::Calibration::HistogramD3D>(
0065           obj, mydbservice->currentTime(), "SiStripDeDxProton_3D_Rcd");
0066     }
0067   } else {
0068     edm::LogError("SiStripDeDx3DBuilder") << "Service is unavailable" << std::endl;
0069   }
0070 }
0071 
0072 #include "FWCore/PluginManager/interface/ModuleDef.h"
0073 #include "FWCore/Framework/interface/MakerMacros.h"
0074 
0075 DEFINE_FWK_MODULE(SiStripDeDx3DBuilder);
0076 
0077 #endif