File indexing completed on 2024-09-07 04:35:40
0001 #ifndef SiStripDeDx2DBuilder_H
0002 #define SiStripDeDx2DBuilder_H
0003
0004 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0005 #include "CondFormats/PhysicsToolsObjects/interface/Histogram2D.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
0014
0015 #include <iostream>
0016 #include <fstream>
0017
0018
0019
0020 class SiStripDeDx2DBuilder : public edm::one::EDAnalyzer<> {
0021 public:
0022 explicit SiStripDeDx2DBuilder(const edm::ParameterSet& iConfig);
0023
0024 ~SiStripDeDx2DBuilder() {}
0025
0026 virtual void analyze(const edm::Event&, const edm::EventSetup&);
0027
0028 private:
0029
0030 bool printdebug_;
0031 };
0032
0033 SiStripDeDx2DBuilder::SiStripDeDx2DBuilder(const edm::ParameterSet& iConfig) {}
0034
0035
0036
0037 void SiStripDeDx2DBuilder::analyze(const edm::Event& evt, const edm::EventSetup& iSetup) {
0038 unsigned int run = evt.id().run();
0039
0040 edm::LogInfo("SiStripDeDx2DBuilder")
0041 << "... creating dummy PhysicsToolsObjects::Calibration::HistogramD2D Data for Run " << run << "\n " << std::endl;
0042
0043
0044 PhysicsTools::Calibration::VHistogramD2D obj;
0045
0046 for (int ih = 0; ih < 3; ih++) {
0047 PhysicsTools::Calibration::HistogramD2D myhist(300, 0., 3., 1000, 0., 1000.);
0048 for (int ix = 0; ix < 300; ix++) {
0049 for (int iy = 0; iy < 1000; iy++) {
0050 myhist.setBinContent(ix, iy, iy / 999.);
0051 }
0052 }
0053
0054 (obj.vHist).push_back(myhist);
0055 (obj.vValues).push_back(ih);
0056 }
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 edm::Service<cond::service::PoolDBOutputService> mydbservice;
0084
0085 if (mydbservice.isAvailable()) {
0086 if (mydbservice->isNewTagRequest("SiStripDeDxProton_2D_Rcd")) {
0087 mydbservice->createOneIOV<PhysicsTools::Calibration::VHistogramD2D>(
0088 obj, mydbservice->beginOfTime(), "SiStripDeDxProton_2D_Rcd");
0089 } else {
0090 mydbservice->appendOneIOV<PhysicsTools::Calibration::VHistogramD2D>(
0091 obj, mydbservice->currentTime(), "SiStripDeDxProton_2D_Rcd");
0092 }
0093 } else {
0094 edm::LogError("SiStripDeDx2DBuilder") << "Service is unavailable" << std::endl;
0095 }
0096 }
0097
0098 #include "FWCore/PluginManager/interface/ModuleDef.h"
0099 #include "FWCore/Framework/interface/MakerMacros.h"
0100
0101 DEFINE_FWK_MODULE(SiStripDeDx2DBuilder);
0102
0103 #endif