Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-07 23:57:52

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