TrackerAdditionalParametersPerDetESModule

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
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESTransientHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/Records/interface/PTrackerAdditionalParametersPerDetRcd.h"
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
#include "CondFormats/GeometryObjects/interface/PTrackerAdditionalParametersPerDet.h"

#include <memory>

namespace edm {
  class ConfigurationDescriptions;
}
class PTrackerAdditionalParametersPerDet;
class PTrackerAdditionalParametersPerDetRcd;

class TrackerAdditionalParametersPerDetESModule : public edm::ESProducer {
public:
  TrackerAdditionalParametersPerDetESModule(const edm::ParameterSet&);

  using ReturnType = std::unique_ptr<PTrackerAdditionalParametersPerDet>;

  static void fillDescriptions(edm::ConfigurationDescriptions&);

  ReturnType produce(const PTrackerAdditionalParametersPerDetRcd&);

private:
  edm::ESGetToken<GeometricDet, IdealGeometryRecord> geometricDetToken_;
};

TrackerAdditionalParametersPerDetESModule::TrackerAdditionalParametersPerDetESModule(const edm::ParameterSet& ps) {
  auto cc = setWhatProduced(this);
  geometricDetToken_ = cc.consumesFrom<GeometricDet, IdealGeometryRecord>(edm::ESInputTag());
}

void TrackerAdditionalParametersPerDetESModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
  edm::ParameterSetDescription desc;
  descriptions.add("TrackerAdditionalParametersPerDet", desc);
}

TrackerAdditionalParametersPerDetESModule::ReturnType TrackerAdditionalParametersPerDetESModule::produce(
    const PTrackerAdditionalParametersPerDetRcd& iRecord) {
  edm::LogInfo("TrackerAdditionalParametersPerDet")
      << "TrackerAdditionalParametersPerDetESModule::produce(const PTrackerAdditionalParametersPerDetRcd& iRecord)";

  auto ptitp = std::make_unique<PTrackerAdditionalParametersPerDet>();

  edm::ESTransientHandle<GeometricDet> gd = iRecord.getTransientHandle(geometricDetToken_);

  std::vector<const GeometricDet*> comp;
  gd->deepComponents(comp);

  for (auto& i : comp) {
    ptitp->setGeographicalId(i->geographicalId());
    ptitp->setBigPixelsX(i->bigPixelsx());
    ptitp->setBigPixelsY(i->bigPixelsy());
    ptitp->setBigPixelsPitchX(i->bigPixelsPitchx());
    ptitp->setBigPixelsPitchY(i->bigPixelsPitchy());
  }

  return ptitp;
}

DEFINE_FWK_EVENTSETUP_MODULE(TrackerAdditionalParametersPerDetESModule);