Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef _CSCFAKEDBNOISEMATRIX_H
0002 #define _CSCFAKEDBNOISEMATRIX_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/CSCDBNoiseMatrix.h"
0017 #include "CondFormats/DataRecord/interface/CSCDBNoiseMatrixRcd.h"
0018 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
0019 
0020 class CSCFakeDBNoiseMatrix : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0021 public:
0022   CSCFakeDBNoiseMatrix(const edm::ParameterSet &);
0023   ~CSCFakeDBNoiseMatrix() override;
0024 
0025   inline static CSCDBNoiseMatrix *prefillDBNoiseMatrix();
0026 
0027   typedef std::unique_ptr<CSCDBNoiseMatrix> Pointer;
0028 
0029   Pointer produceDBNoiseMatrix(const CSCDBNoiseMatrixRcd &);
0030 
0031 private:
0032   // ----------member data ---------------------------
0033   void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0034                       const edm::IOVSyncValue &,
0035                       edm::ValidityInterval &) override;
0036   Pointer cndbNoiseMatrix;
0037 };
0038 
0039 #include <fstream>
0040 #include <iostream>
0041 #include <vector>
0042 
0043 // to workaround plugin library
0044 inline CSCDBNoiseMatrix *CSCFakeDBNoiseMatrix::prefillDBNoiseMatrix() {
0045   int seed;
0046   const int MAX_SIZE = 252288;  // or 252288 for ME4/2 chambers
0047   const int FACTOR = 1000;
0048 
0049   CSCDBNoiseMatrix *cndbmatrix = new CSCDBNoiseMatrix();
0050   cndbmatrix->matrix.resize(MAX_SIZE);
0051 
0052   seed = 10000;
0053   srand(seed);
0054   cndbmatrix->factor_noise = int(FACTOR);
0055 
0056   for (int i = 0; i < MAX_SIZE; i++) {
0057     cndbmatrix->matrix[i].elem33 = (short int)(10.0 * FACTOR + 0.5);
0058     cndbmatrix->matrix[i].elem34 = (short int)(4.0 * FACTOR + 0.5);
0059     cndbmatrix->matrix[i].elem35 = (short int)(3.0 * FACTOR + 0.5);
0060     cndbmatrix->matrix[i].elem44 = (short int)(10.0 * FACTOR + 0.5);
0061     cndbmatrix->matrix[i].elem45 = (short int)(8.0 * FACTOR + 0.5);
0062     cndbmatrix->matrix[i].elem46 = (short int)(2.0 * FACTOR + 0.5);
0063     cndbmatrix->matrix[i].elem55 = (short int)(10.0 * FACTOR + 0.5);
0064     cndbmatrix->matrix[i].elem56 = (short int)(5.0 * FACTOR + 0.5);
0065     cndbmatrix->matrix[i].elem57 = (short int)(3.0 * FACTOR + 0.5);
0066     cndbmatrix->matrix[i].elem66 = (short int)(10.0 * FACTOR + 0.5);
0067     cndbmatrix->matrix[i].elem67 = (short int)(4.0 * FACTOR + 0.5);
0068     cndbmatrix->matrix[i].elem77 = (short int)(10.0 * FACTOR + 0.5);
0069   }
0070   return cndbmatrix;
0071 }
0072 
0073 #endif