SiStripNoiseNormalizedWithApvGainBuilder

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
#ifndef SiStripNoiseNormalizedWithApvGainBuilder_H
#define SiStripNoiseNormalizedWithApvGainBuilder_H

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"

#include "CondFormats/SiStripObjects/interface/SiStripApvGain.h"
#include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
#include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"

#include "CLHEP/Random/RandFlat.h"
#include "CLHEP/Random/RandGauss.h"

class TrackerTopology;
class TrackerGeometry;
/**
 * Produces a noise tag using the same settings as the service used in the DummyDBWriter, but
 * it receives a SiStripApvGain tag from the EventSetup and uses the gain values (per apv) to
 * rescale the noise (per strip).
 */

class SiStripNoiseNormalizedWithApvGainBuilder : public edm::one::EDAnalyzer<> {
public:
  explicit SiStripNoiseNormalizedWithApvGainBuilder(const edm::ParameterSet& iConfig);

  ~SiStripNoiseNormalizedWithApvGainBuilder() override {}

  void analyze(const edm::Event&, const edm::EventSetup&) override;

private:
  /// Fills the parameters read from cfg and matching the name in the given map
  void fillParameters(std::map<int, std::vector<double> >& mapToFill, const std::string& parameterName) const;
  /**
   * Fills the map with the paramters for the given subdetector. <br>
   * Each vector "v" holds the parameters for the layers/rings, if the vector has only one parameter
   * all the layers/rings get that parameter. <br>
   * The only other possibility is that the number of parameters equals the number of layers, otherwise
   * an exception of type "Configuration" will be thrown.
   */
  void fillSubDetParameter(std::map<int, std::vector<double> >& mapToFill,
                           const std::vector<double>& v,
                           const int subDet,
                           const unsigned short layers) const;

  inline void printLog(const uint32_t detId, const unsigned short strip, const double& noise) const {
    edm::LogInfo("SiStripNoisesDummyCalculator")
        << "detid: " << detId << " strip: " << strip << " noise: " << noise << " \t" << std::endl;
  }

  edm::FileInPath fp_;
  bool printdebug_;
  edm::ParameterSet pset_;

  double electronsPerADC_;
  double minimumPosValue_;
  bool stripLengthMode_;
  uint32_t printDebug_;

  edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
  edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken_;
  edm::ESGetToken<SiStripApvGain, SiStripApvGainRcd> inputApvGainToken_;
};

#endif