Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/PhysicsToolsObjects/test/SiStripDeDxMipBuilder.h"
0002 #include "CondFormats/PhysicsToolsObjects/interface/Histogram2D.h"
0003 //#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
0004 
0005 #include <iostream>
0006 #include <fstream>
0007 
0008 SiStripDeDxMipBuilder::SiStripDeDxMipBuilder(const edm::ParameterSet& iConfig) {}
0009 //  fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
0010 //  printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug",1)){}
0011 
0012 void SiStripDeDxMipBuilder::analyze(const edm::Event& evt, const edm::EventSetup& iSetup) {
0013   unsigned int run = evt.id().run();
0014 
0015   edm::LogInfo("SiStripDeDxMipBuilder")
0016       << "... creating dummy PhysicsToolsObjects::Calibration::HistogramD2D Data for Run " << run << "\n " << std::endl;
0017 
0018   //  PhysicsToolsObjects::Calibration::HistogramD2D* obj = new PhysicsTools::Calibration::HistogramD2D(300, 0., 3., 1000,0.,1000.);
0019   PhysicsTools::Calibration::HistogramD2D obj(300, 0., 3., 1000, 0., 1000.);
0020 
0021   for (int ix = 0; ix < 300; ix++) {
0022     for (int iy = 0; iy < 1000; iy++) {
0023       obj.setBinContent(ix, iy, iy / 999.);
0024     }
0025   }
0026 
0027   //  SiStripDetInfoFileReader reader(fp_.fullPath());
0028   //  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos  = reader.getAllData();
0029 
0030   //  int count=-1;
0031   //  for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); it++){
0032   //   count++;
0033   //Generate Gain for det detid
0034   //  std::vector<float> theSiStripVector;
0035   //  for(unsigned short j=0; j<it->second.nApvs; j++){
0036   //   float gain= (j+1)*1000+ (RandFlat::shoot(1.)*100);
0037   //   if (count<printdebug_)
0038   //    edm::LogInfo("PhysicsToolsObjects::Calibration::HistogramD2DBuilder") << "detid " << it->first << " \t"
0039   //                          << " apv " << j << " \t"
0040   //                          << gain    << " \t"
0041   //                          << std::endl;
0042   //       theSiStripVector.push_back(gain);
0043   //     }
0044 
0045   //     PhysicsToolsObjects::Calibration::HistogramD2D::Range range(theSiStripVector.begin(),theSiStripVector.end());
0046   //     if ( ! obj.put(it->first,range) )
0047 
0048   //      edm::LogError("PhysicsToolsObjects::Calibration::HistogramD2DBuilder")<<"[PhysicsToolsObjects::Calibration::HistogramD2DBuilder::analyze] detid already exists"<<std::endl;
0049   //  }
0050 
0051   //End now write sistripnoises data in DB
0052   edm::Service<cond::service::PoolDBOutputService> mydbservice;
0053 
0054   if (mydbservice.isAvailable()) {
0055     if (mydbservice->isNewTagRequest("SiStripDeDxMipRcd")) {
0056       mydbservice->createOneIOV<PhysicsTools::Calibration::HistogramD2D>(
0057           obj, mydbservice->beginOfTime(), "SiStripDeDxMipRcd");
0058     } else {
0059       mydbservice->appendOneIOV<PhysicsTools::Calibration::HistogramD2D>(
0060           obj, mydbservice->currentTime(), "SiStripDeDxMipRcd");
0061     }
0062   } else {
0063     edm::LogError("SiStripDeDxMipBuilder") << "Service is unavailable" << std::endl;
0064   }
0065 }
0066 
0067 #include "FWCore/PluginManager/interface/ModuleDef.h"
0068 #include "FWCore/Framework/interface/MakerMacros.h"
0069 
0070 DEFINE_FWK_MODULE(SiStripDeDxMipBuilder);