CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
SCEnergyCorrectorDRN Class Reference

#include <SCEnergyCorrectorDRN.h>

Public Member Functions

TritonOutput< float > getOutput (const TritonOutputMap &iOutput)
 
void makeInput (const edm::Event &iEvent, TritonInputMap &iInput, const reco::SuperClusterCollection &inputSCs) const
 
 SCEnergyCorrectorDRN ()
 
 SCEnergyCorrectorDRN (const edm::ParameterSet &iConfig, edm::ConsumesCollector cc)
 
void setEvent (const edm::Event &e)
 
void setEventSetup (const edm::EventSetup &es)
 
template<edm::Transition tr = edm::Transition::BeginLuminosityBlock>
void setTokens (const edm::ParameterSet &iConfig, edm::ConsumesCollector cc)
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 
static edm::ParameterSetDescription makePSetDescription ()
 

Private Attributes

const CaloGeometrycaloGeom_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeomToken_
 
const CaloTopologycaloTopo_
 
edm::ESGetToken< CaloTopology, CaloTopologyRecordcaloTopoToken_
 
edm::Handle< EcalRecHitCollectionrecHitsEB_
 
edm::Handle< EcalRecHitCollectionrecHitsEE_
 
edm::Handle< double > rhoHandle_
 
edm::EDGetTokenT< double > rhoToken_
 
edm::EDGetTokenT< EcalRecHitCollectiontokenEBRecHits_
 
edm::EDGetTokenT< EcalRecHitCollectiontokenEERecHits_
 

Detailed Description

Definition at line 47 of file SCEnergyCorrectorDRN.h.

Constructor & Destructor Documentation

◆ SCEnergyCorrectorDRN() [1/2]

SCEnergyCorrectorDRN::SCEnergyCorrectorDRN ( )

Definition at line 23 of file SCEnergyCorrectorDRN.cc.

23 : caloTopo_(nullptr), caloGeom_(nullptr) {}
const CaloGeometry * caloGeom_
const CaloTopology * caloTopo_

◆ SCEnergyCorrectorDRN() [2/2]

SCEnergyCorrectorDRN::SCEnergyCorrectorDRN ( const edm::ParameterSet iConfig,
edm::ConsumesCollector  cc 
)

Definition at line 25 of file SCEnergyCorrectorDRN.cc.

References gpuPixelDoublets::cc, and setTokens().

27  setTokens(iConfig, cc);
28 }
void setTokens(const edm::ParameterSet &iConfig, edm::ConsumesCollector cc)
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49

Member Function Documentation

◆ fillPSetDescription()

void SCEnergyCorrectorDRN::fillPSetDescription ( edm::ParameterSetDescription desc)
static

Definition at line 30 of file SCEnergyCorrectorDRN.cc.

References submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

Referenced by makePSetDescription().

30  {
31  desc.add<edm::InputTag>("ecalRecHitsEE", edm::InputTag("ecalRecHit", "reducedEcalRecHitsEE"));
32  desc.add<edm::InputTag>("ecalRecHitsEB", edm::InputTag("ecalRecHit", "reducedEcalRecHitsEB"));
33  desc.add<edm::InputTag>("rhoFastJet", edm::InputTag("fixedGridRhoAll"));
34 }

◆ getOutput()

TritonOutput< float > SCEnergyCorrectorDRN::getOutput ( const TritonOutputMap iOutput)

Definition at line 115 of file SCEnergyCorrectorDRN.cc.

References skim900GeV_StreamA_MinBiasPD_cfg::output1.

Referenced by SCEnergyCorrectorDRNProducer::produce().

115  {
116  //check the results
117  const auto& output1 = iOutput.begin()->second;
118  // convert from server format
119  const auto& serverout = output1.fromServer<float>();
120 
121  return serverout;
122 }

◆ makeInput()

void SCEnergyCorrectorDRN::makeInput ( const edm::Event iEvent,
TritonInputMap iInput,
const reco::SuperClusterCollection inputSCs 
) const

Definition at line 53 of file SCEnergyCorrectorDRN.cc.

References caloGeom_, E_RANGE, EcalBarrel, DivergingColor::frac, CaloGeometry::getGeometry(), hfClusterShapes_cfi::hits, input1, input2, SCEnergyCorrectorDRNProducer_cfi::inputSCs, dqmiodumpmetadata::n, nHits, position, recHitsEB_, recHitsEE_, RHO_MAX, rhoHandle_, x, X_MAX, X_RANGE, y, Y_MAX, Y_RANGE, z, Z_MAX, and Z_RANGE.

Referenced by SCEnergyCorrectorDRNProducer::acquire().

55  {
56  std::vector<unsigned> nHits;
57  nHits.reserve(inputSCs.size());
58  unsigned totalHits = 0;
59  unsigned n;
60  for (const auto& inputSC : inputSCs) {
61  n = inputSC.hitsAndFractions().size();
62  totalHits += n;
63  nHits.push_back(n);
64  }
65 
66  //set shapes
67  auto& input1 = iInput.at("x__0");
68  input1.setShape(0, totalHits);
69  auto data1 = input1.allocate<float>();
70  auto& vdata1 = (*data1)[0];
71 
72  auto& input2 = iInput.at("batch__1");
73  input2.setShape(0, totalHits);
74  auto data2 = input2.allocate<int64_t>();
75  auto& vdata2 = (*data2)[0];
76 
77  auto& input3 = iInput.at("graphx__2");
78  input3.setShape(0, 2 * nHits.size());
79  auto data3 = input3.allocate<float>();
80  auto& vdata3 = (*data3)[0];
81 
82  //fill
83  unsigned batchNum = 0;
84  float En, frac, x, y, z;
85  for (const auto& inputSC : inputSCs) {
86  const auto& hits = inputSC.hitsAndFractions();
87  const bool isEB = hits[0].first.subdetId() == EcalBarrel;
88  const auto& recHitsProduct = isEB ? recHitsEB_.product() : recHitsEE_.product();
89  for (const auto& hit : hits) {
90  En = EcalClusterTools::recHitEnergy(hit.first, recHitsProduct);
91  frac = hit.second;
92  GlobalPoint position = caloGeom_->getGeometry(hit.first)->getPosition();
93  x = (position.x() + X_MAX) / X_RANGE;
94  y = (position.y() + Y_MAX) / Y_RANGE;
95  z = (position.z() + Z_MAX) / Z_RANGE;
96  vdata1.push_back(x);
97  vdata1.push_back(y);
98  vdata1.push_back(z);
99  vdata1.push_back(En * frac / E_RANGE);
100  //Triton does not currently support batching for pytorch GNNs
101  //We pass batch indices explicitely
102  vdata2.push_back(batchNum);
103  }
104  vdata3.push_back(*rhoHandle_ / RHO_MAX);
105  vdata3.push_back(0.0);
106  ++batchNum;
107  }
108 
109  // convert to server format
110  input1.toServer(data1);
111  input2.toServer(data2);
112  input3.toServer(data3);
113 }
static const float RHO_MAX
edm::Handle< EcalRecHitCollection > recHitsEB_
edm::Handle< double > rhoHandle_
static const float X_MAX
edm::Handle< EcalRecHitCollection > recHitsEE_
#define input2
Definition: AMPTWrapper.h:159
static const float Y_MAX
static const float Z_MAX
static const float Y_RANGE
static const float X_RANGE
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:60
#define input1
Definition: AMPTWrapper.h:139
static const float Z_RANGE
const CaloGeometry * caloGeom_
static int position[264][3]
Definition: ReadPGInfo.cc:289
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
static const float E_RANGE

◆ makePSetDescription()

edm::ParameterSetDescription SCEnergyCorrectorDRN::makePSetDescription ( )
static

◆ setEvent()

void SCEnergyCorrectorDRN::setEvent ( const edm::Event e)

Definition at line 47 of file SCEnergyCorrectorDRN.cc.

References recHitsEB_, recHitsEE_, rhoHandle_, rhoToken_, tokenEBRecHits_, and tokenEERecHits_.

Referenced by SCEnergyCorrectorDRNProducer::acquire().

47  {
48  event.getByToken(tokenEBRecHits_, recHitsEB_);
49  event.getByToken(tokenEERecHits_, recHitsEE_);
50  event.getByToken(rhoToken_, rhoHandle_);
51 }
edm::Handle< EcalRecHitCollection > recHitsEB_
edm::Handle< double > rhoHandle_
edm::Handle< EcalRecHitCollection > recHitsEE_
edm::EDGetTokenT< EcalRecHitCollection > tokenEBRecHits_
edm::EDGetTokenT< EcalRecHitCollection > tokenEERecHits_
edm::EDGetTokenT< double > rhoToken_

◆ setEventSetup()

void SCEnergyCorrectorDRN::setEventSetup ( const edm::EventSetup es)

Definition at line 42 of file SCEnergyCorrectorDRN.cc.

References caloGeom_, caloGeomToken_, caloTopo_, caloTopoToken_, and edm::EventSetup::getData().

Referenced by SCEnergyCorrectorDRNProducer::beginLuminosityBlock().

42  {
45 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopoToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
const CaloGeometry * caloGeom_
const CaloTopology * caloTopo_

◆ setTokens()

template<edm::Transition esTransition>
void SCEnergyCorrectorDRN::setTokens ( const edm::ParameterSet iConfig,
edm::ConsumesCollector  cc 
)

Definition at line 83 of file SCEnergyCorrectorDRN.h.

References caloGeomToken_, caloTopoToken_, gpuPixelDoublets::cc, edm::ParameterSet::getParameter(), rhoToken_, tokenEBRecHits_, and tokenEERecHits_.

Referenced by SCEnergyCorrectorDRN().

83  {
84  tokenEBRecHits_ = cc.consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("ecalRecHitsEB"));
85  tokenEERecHits_ = cc.consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("ecalRecHitsEE"));
86  caloGeomToken_ = cc.esConsumes<CaloGeometry, CaloGeometryRecord, esTransition>();
87  caloTopoToken_ = cc.esConsumes<CaloTopology, CaloTopologyRecord, esTransition>();
88  rhoToken_ = cc.consumes<double>(iConfig.getParameter<edm::InputTag>("rhoFastJet"));
89 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopoToken_
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
edm::EDGetTokenT< EcalRecHitCollection > tokenEBRecHits_
edm::EDGetTokenT< EcalRecHitCollection > tokenEERecHits_
edm::EDGetTokenT< double > rhoToken_

Member Data Documentation

◆ caloGeom_

const CaloGeometry* SCEnergyCorrectorDRN::caloGeom_
private

Definition at line 68 of file SCEnergyCorrectorDRN.h.

Referenced by makeInput(), and setEventSetup().

◆ caloGeomToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> SCEnergyCorrectorDRN::caloGeomToken_
private

Definition at line 70 of file SCEnergyCorrectorDRN.h.

Referenced by setEventSetup(), and setTokens().

◆ caloTopo_

const CaloTopology* SCEnergyCorrectorDRN::caloTopo_
private

Definition at line 67 of file SCEnergyCorrectorDRN.h.

Referenced by setEventSetup().

◆ caloTopoToken_

edm::ESGetToken<CaloTopology, CaloTopologyRecord> SCEnergyCorrectorDRN::caloTopoToken_
private

Definition at line 69 of file SCEnergyCorrectorDRN.h.

Referenced by setEventSetup(), and setTokens().

◆ recHitsEB_

edm::Handle<EcalRecHitCollection> SCEnergyCorrectorDRN::recHitsEB_
private

Definition at line 76 of file SCEnergyCorrectorDRN.h.

Referenced by makeInput(), and setEvent().

◆ recHitsEE_

edm::Handle<EcalRecHitCollection> SCEnergyCorrectorDRN::recHitsEE_
private

Definition at line 77 of file SCEnergyCorrectorDRN.h.

Referenced by makeInput(), and setEvent().

◆ rhoHandle_

edm::Handle<double> SCEnergyCorrectorDRN::rhoHandle_
private

Definition at line 79 of file SCEnergyCorrectorDRN.h.

Referenced by makeInput(), and setEvent().

◆ rhoToken_

edm::EDGetTokenT<double> SCEnergyCorrectorDRN::rhoToken_
private

Definition at line 74 of file SCEnergyCorrectorDRN.h.

Referenced by setEvent(), and setTokens().

◆ tokenEBRecHits_

edm::EDGetTokenT<EcalRecHitCollection> SCEnergyCorrectorDRN::tokenEBRecHits_
private

Definition at line 72 of file SCEnergyCorrectorDRN.h.

Referenced by setEvent(), and setTokens().

◆ tokenEERecHits_

edm::EDGetTokenT<EcalRecHitCollection> SCEnergyCorrectorDRN::tokenEERecHits_
private

Definition at line 73 of file SCEnergyCorrectorDRN.h.

Referenced by setEvent(), and setTokens().