Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-15 04:15:22

0001 #include "CalibMuon/CSCCalibration/interface/CSCConditions.h"
0002 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0006 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
0007 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0008 #include "SimMuon/CSCDigitizer/src/CSCDbStripConditions.h"
0009 
0010 #include "FWCore/ServiceRegistry/interface/Service.h"
0011 #include "FWCore/Utilities/interface/EDMException.h"
0012 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0013 
0014 class CSCNoiseMatrixTest : public edm::one::EDAnalyzer<> {
0015 public:
0016   CSCNoiseMatrixTest(const edm::ParameterSet &pset)
0017       : theDbConditions(pset, consumesCollector()), tokGeo_{esConsumes(edm::ESInputTag("", "idealForDigi"))} {
0018     edm::Service<edm::RandomNumberGenerator> rng;
0019     if (!rng.isAvailable()) {
0020       throw cms::Exception("Configuration") << "CSCNoiseMatrixTest requires the RandomNumberGeneratorService\n"
0021                                                "which is not present in the configuration file.  You must add "
0022                                                "the service\n"
0023                                                "in the configuration file or remove the modules that require it.";
0024     }
0025   }
0026 
0027   ~CSCNoiseMatrixTest() override {}
0028   // virtual void beginRun(edm::Run const& run, edm::EventSetup const&
0029   // eventSetup)
0030   void analyze(const edm::Event &e, const edm::EventSetup &eventSetup) override {
0031     edm::Service<edm::RandomNumberGenerator> rng;
0032     CLHEP::HepRandomEngine *engine = &rng->getEngine(e.streamID());
0033 
0034     theDbConditions.initializeEvent(eventSetup);
0035     // fake signal is going to get noisified 200000 times!
0036     const int nScaBins = 8;
0037     const float scaBinSize = 50.;
0038     std::vector<float> binValues(nScaBins, 0.);
0039 
0040     // find the geometry & conditions for this event
0041     const CSCGeometry *pGeom = &eventSetup.getData(tokGeo_);
0042 
0043     // try making a noisifier and using it
0044     const CSCGeometry::LayerContainer &layers = pGeom->layers();
0045     for (auto layerItr = layers.begin(); layerItr != layers.end(); ++layerItr) {
0046       unsigned nstrips = (**layerItr).geometry()->numberOfStrips();
0047       for (unsigned istrip = 1; istrip != nstrips; ++istrip) {
0048         CSCAnalogSignal signal(istrip, scaBinSize, binValues, 0., 0.);
0049         // theDbConditions.fetchNoisifier((**layerItr).id(),istrip);
0050         try {
0051           theDbConditions.noisify((**layerItr).id(), signal, engine);
0052         } catch (cms::Exception &e) {
0053           std::cerr << "Bad Noise Matrix for " << (**layerItr).id() << "strip " << istrip << "\n";
0054           std::cerr << e.what() << std::endl;
0055         }
0056       }
0057     }
0058   }
0059 
0060   // virtual void analyze(const edm::Event&, const edm::EventSetup&) {}
0061 
0062 private:
0063   CSCDbStripConditions theDbConditions;
0064   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> tokGeo_;
0065 };
0066 
0067 DEFINE_FWK_MODULE(CSCNoiseMatrixTest);