Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:33

0001 #ifndef _CSCFAKEDBPEDESTALS_H
0002 #define _CSCFAKEDBPEDESTALS_H
0003 
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/Framework/interface/ESProducer.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0009 #include "FWCore/Framework/interface/Frameworkfwd.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/Framework/interface/SourceFactory.h"
0012 #include <memory>
0013 
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 
0016 #include "CondFormats/CSCObjects/interface/CSCDBPedestals.h"
0017 #include "CondFormats/DataRecord/interface/CSCDBPedestalsRcd.h"
0018 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
0019 
0020 class CSCFakeDBPedestals : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0021 public:
0022   CSCFakeDBPedestals(const edm::ParameterSet &);
0023   ~CSCFakeDBPedestals() override;
0024 
0025   inline static CSCDBPedestals *prefillDBPedestals();
0026 
0027   typedef std::unique_ptr<CSCDBPedestals> Pointer;
0028 
0029   Pointer produceDBPedestals(const CSCDBPedestalsRcd &);
0030 
0031 private:
0032   // ----------member data ---------------------------
0033   void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0034                       const edm::IOVSyncValue &,
0035                       edm::ValidityInterval &) override;
0036 };
0037 
0038 #include <fstream>
0039 #include <iostream>
0040 #include <vector>
0041 
0042 // to workaround plugin library
0043 inline CSCDBPedestals *CSCFakeDBPedestals::prefillDBPedestals() {
0044   int seed;
0045   float meanped, meanrms;
0046   const int MAX_SIZE = 217728;  // or 252288 for ME4/2 chambers
0047   const int PED_FACTOR = 10;
0048   const int RMS_FACTOR = 1000;
0049 
0050   CSCDBPedestals *cndbpedestals = new CSCDBPedestals();
0051   cndbpedestals->pedestals.resize(MAX_SIZE);
0052 
0053   seed = 10000;
0054   srand(seed);
0055   meanped = 600.0, meanrms = 1.5;
0056   cndbpedestals->factor_ped = int(PED_FACTOR);
0057   cndbpedestals->factor_rms = int(RMS_FACTOR);
0058 
0059   for (int i = 0; i < MAX_SIZE; i++) {
0060     cndbpedestals->pedestals[i].ped =
0061         (short int)(((double)rand() / ((double)(RAND_MAX) + (double)(1))) * 100 + meanped * PED_FACTOR + 0.5);
0062     cndbpedestals->pedestals[i].rms =
0063         (short int)(((double)rand() / ((double)(RAND_MAX) + (double)(1))) + meanrms * RMS_FACTOR + 0.5);
0064   }
0065   return cndbpedestals;
0066 }
0067 
0068 #endif