Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:20

0001 #ifndef _CSCFAKEDBGAINS_H
0002 #define _CSCFAKEDBGAINS_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/CSCDBGains.h"
0017 #include "CondFormats/DataRecord/interface/CSCDBGainsRcd.h"
0018 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
0019 
0020 class CSCFakeDBGains : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0021 public:
0022   CSCFakeDBGains(const edm::ParameterSet &);
0023   ~CSCFakeDBGains() override;
0024 
0025   inline static CSCDBGains *prefillDBGains();
0026 
0027   typedef std::unique_ptr<CSCDBGains> Pointer;
0028   Pointer produceDBGains(const CSCDBGainsRcd &);
0029 
0030 private:
0031   void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0032                       const edm::IOVSyncValue &,
0033                       edm::ValidityInterval &) override;
0034 
0035   // member data
0036   Pointer cndbGains;
0037 };
0038 
0039 #include <fstream>
0040 #include <iostream>
0041 #include <vector>
0042 
0043 // to workaround plugin library
0044 inline CSCDBGains *CSCFakeDBGains::prefillDBGains() {
0045   int seed;
0046   float mean;
0047   const int MAX_SIZE = 217728;  // or 252288 for ME4/2 chambers
0048   const int FACTOR = 1000;
0049 
0050   CSCDBGains *cndbgains = new CSCDBGains();
0051   cndbgains->gains.resize(MAX_SIZE);
0052 
0053   seed = 10000;
0054   srand(seed);
0055   mean = 6.8;
0056   cndbgains->factor_gain = int(FACTOR);
0057 
0058   for (int i = 0; i < MAX_SIZE; i++) {
0059     cndbgains->gains[i].gain_slope =
0060         (short int)(((double)rand() / ((double)(RAND_MAX) + (double)(1))) + mean * FACTOR + 0.5);
0061   }
0062   return cndbgains;
0063 }
0064 
0065 #endif