CMS 3D CMS Logo

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

#include <trackJet/DeepCoreSeedGenerator/plugins/DeepCoreSeedGenerator.cc>

Inheritance diagram for DeepCoreSeedGenerator:
edm::stream::EDProducer< edm::GlobalCache< tensorflow::SessionCache > >

Public Member Functions

 DeepCoreSeedGenerator (const edm::ParameterSet &, const tensorflow::SessionCache *)
 
 ~DeepCoreSeedGenerator () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< tensorflow::SessionCache > >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static void globalEndJob (tensorflow::SessionCache *)
 
static std::unique_ptr< tensorflow::SessionCacheinitializeGlobalCache (const edm::ParameterSet &)
 

Public Attributes

double jetEta_
 
double jetPt_
 
double pitchX_ = 0.01
 
double pitchY_ = 0.015
 

Static Public Attributes

static constexpr int jetDimX = 30
 
static constexpr int jetDimY = 30
 
static constexpr int Nlayer = 4
 
static constexpr int Nover = 3
 
static constexpr int Npar = 5
 

Private Member Functions

const GeomDetDetectorSelector (int, const reco::Candidate &, GlobalVector, const reco::Vertex &, const TrackerTopology *const, const edmNew::DetSetVector< SiPixelCluster > &)
 
void fillPixelMatrix (const SiPixelCluster &, int, Point3DBase< float, LocalTag >, const GeomDet *, tensorflow::NamedTensorList)
 
std::pair< bool, Basic3DVector< float > > findIntersection (const GlobalVector &, const reco::Candidate::Point &, const GeomDet *)
 
std::pair< int, int > local2Pixel (double, double, const GeomDet *)
 
LocalPoint pixel2Local (int, int, const GeomDet *)
 
int pixelFlipper (const GeomDet *)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
std::pair< double[jetDimX][jetDimY][Nover][Npar], double[jetDimX][jetDimY][Nover]> SeedEvaluation (tensorflow::NamedTensorList, std::vector< std::string >)
 
std::vector< GlobalVectorsplittedClusterDirections (const reco::Candidate &, const TrackerTopology *const, const PixelClusterParameterEstimator *, const reco::Vertex &, int, const edmNew::DetSetVector< SiPixelCluster > &)
 

Private Attributes

double centralMIPCharge_
 
double chargeFracMin_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > cores_
 
double deltaR_
 
const GlobalTrackingGeometrygeometry_ = nullptr
 
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordgeometryToken_
 
edm::Handle< edmNew::DetSetVector< SiPixelCluster > > inputPixelClusters_
 
std::vector< std::string > inputTensorName_
 
std::vector< std::string > outputTensorName_
 
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
 
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecordpixelCPEToken_
 
double probThr_
 
std::string propagatorName_
 
double ptMin_
 
const tensorflow::Session * session_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtopoToken_
 
edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
 
std::string weightfilename_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< tensorflow::SessionCache > >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 76 of file DeepCoreSeedGenerator.cc.

Constructor & Destructor Documentation

◆ DeepCoreSeedGenerator()

DeepCoreSeedGenerator::DeepCoreSeedGenerator ( const edm::ParameterSet iConfig,
const tensorflow::SessionCache cache 
)
explicit

Definition at line 158 of file DeepCoreSeedGenerator.cc.

159  : vertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))),
161  consumes<edmNew::DetSetVector<SiPixelCluster>>(iConfig.getParameter<edm::InputTag>("pixelClusters"))),
162  cores_(consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("cores"))),
165  topoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd>()),
166  ptMin_(iConfig.getParameter<double>("ptMin")),
167  deltaR_(iConfig.getParameter<double>("deltaR")),
168  chargeFracMin_(iConfig.getParameter<double>("chargeFractionMin")),
169  centralMIPCharge_(iConfig.getParameter<double>("centralMIPCharge")),
170  weightfilename_(iConfig.getParameter<edm::FileInPath>("weightFile").fullPath()),
171  inputTensorName_(iConfig.getParameter<std::vector<std::string>>("inputTensorName")),
172  outputTensorName_(iConfig.getParameter<std::vector<std::string>>("outputTensorName")),
173  probThr_(iConfig.getParameter<double>("probThr")),
174  session_(cache->getSession())
175 
176 {
177  produces<TrajectorySeedCollection>();
178  produces<reco::TrackCollection>();
179 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
std::string fullPath() const
Definition: FileInPath.cc:161
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > pixelCPEToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
edm::EDGetTokenT< edm::View< reco::Candidate > > cores_
std::vector< std::string > inputTensorName_
std::vector< std::string > outputTensorName_
edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
def cache(function)
Definition: utilities.py:3
const tensorflow::Session * session_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_

◆ ~DeepCoreSeedGenerator()

DeepCoreSeedGenerator::~DeepCoreSeedGenerator ( )
override

Definition at line 181 of file DeepCoreSeedGenerator.cc.

181 {}

Member Function Documentation

◆ DetectorSelector()

const GeomDet * DeepCoreSeedGenerator::DetectorSelector ( int  llay,
const reco::Candidate jet,
GlobalVector  jetDir,
const reco::Vertex jetVertex,
const TrackerTopology * const  tTopo,
const edmNew::DetSetVector< SiPixelCluster > &  clusters 
)
private

Definition at line 475 of file DeepCoreSeedGenerator.cc.

References funct::abs(), bsc_activity_cfg::clusters, findIntersection(), GeomDet::geographicalId(), geometry_, GlobalTrackingGeometry::idToDet(), TrackerTopology::layer(), convertSQLitetoXML_cfg::output, reco::Vertex::position(), GeomDet::specificSurface(), and GloballyPositioned< T >::toLocal().

Referenced by produce().

480  {
481  double minDist = 0.0;
482  GeomDet* output = (GeomDet*)nullptr;
483  for (const auto& detset : clusters) {
484  auto aClusterID = detset.id();
485  if (DetId(aClusterID).subdetId() != 1)
486  continue;
487  const GeomDet* det = geometry_->idToDet(aClusterID);
488  int lay = tTopo->layer(det->geographicalId());
489  if (lay != llay)
490  continue;
491  std::pair<bool, Basic3DVector<float>> interPair =
492  findIntersection(jetDir, (reco::Candidate::Point)jetVertex.position(), det);
493  if (interPair.first == false)
494  continue;
495  Basic3DVector<float> inter = interPair.second;
496  auto localInter = det->specificSurface().toLocal((GlobalPoint)inter);
497  if ((minDist == 0.0 || std::abs(localInter.x()) < minDist) && std::abs(localInter.y()) < 3.35) {
498  minDist = std::abs(localInter.x());
499  output = (GeomDet*)det;
500  }
501  } //detset
502  return output;
503 }
const Point & position() const
position
Definition: Vertex.h:127
LocalPoint toLocal(const GlobalPoint &gp) const
const GeomDet * idToDet(DetId) const override
unsigned int layer(const DetId &id) const
std::pair< bool, Basic3DVector< float > > findIntersection(const GlobalVector &, const reco::Candidate::Point &, const GeomDet *)
const GlobalTrackingGeometry * geometry_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Definition: DetId.h:17
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:40

◆ fillDescriptions()

void DeepCoreSeedGenerator::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 543 of file DeepCoreSeedGenerator.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

543  {
545  desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
546  desc.add<edm::InputTag>("pixelClusters", edm::InputTag("siPixelClustersPreSplitting"));
547  desc.add<edm::InputTag>("cores", edm::InputTag("jetsForCoreTracking"));
548  desc.add<double>("ptMin", 100);
549  desc.add<double>("deltaR", 0.25); // the current training makes use of 0.1
550  desc.add<double>("chargeFractionMin", 18000.0);
551  desc.add<double>("centralMIPCharge", 2);
552  desc.add<std::string>("pixelCPE", "PixelCPEGeneric");
553  desc.add<edm::FileInPath>(
554  "weightFile",
555  edm::FileInPath("RecoTracker/TkSeedGenerator/data/DeepCore/DeepCoreSeedGenerator_TrainedModel_barrel_2017.pb"));
556  desc.add<std::vector<std::string>>("inputTensorName", {"input_1", "input_2", "input_3"});
557  desc.add<std::vector<std::string>>("outputTensorName", {"output_node0", "output_node1"});
558  desc.add<double>("probThr", 0.85);
559  descriptions.add("deepCoreSeedGenerator", desc);
560 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ fillPixelMatrix()

void DeepCoreSeedGenerator::fillPixelMatrix ( const SiPixelCluster cluster,
int  layer,
Point3DBase< float, LocalTag inter,
const GeomDet det,
tensorflow::NamedTensorList  input_tensors 
)
private

Definition at line 424 of file DeepCoreSeedGenerator.cc.

References funct::abs(), SiPixelCluster::Pixel::adc, f, HLT_2023v12_cff::flip, dqmMemoryStats::float, mps_fire::i, jetDimX, jetDimY, pixelTopology::layer, local2Pixel(), SiPixelCluster::pixel(), pixelFlipper(), SiPixelCluster::size(), SiPixelCluster::Pixel::x, PV3DBase< T, PVType, FrameType >::x(), SiPixelCluster::Pixel::y, and PV3DBase< T, PVType, FrameType >::y().

Referenced by produce().

428  {
429  int flip = pixelFlipper(det); // 1=not flip, -1=flip
430 
431  for (int i = 0; i < cluster.size(); i++) {
432  SiPixelCluster::Pixel pix = cluster.pixel(i);
433  std::pair<int, int> pixInter = local2Pixel(inter.x(), inter.y(), det);
434  int nx = pix.x - pixInter.first;
435  int ny = pix.y - pixInter.second;
436  nx = flip * nx;
437 
438  if (abs(nx) < jetDimX / 2 && abs(ny) < jetDimY / 2) {
439  nx = nx + jetDimX / 2;
440  ny = ny + jetDimY / 2;
441  //14000 = normalization of ACD counts used in the NN
442  input_tensors[2].second.tensor<float, 4>()(0, nx, ny, layer - 1) += (pix.adc) / (14000.f);
443  }
444  }
445 }
Pixel pixel(int i) const
int pixelFlipper(const GeomDet *)
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
std::pair< int, int > local2Pixel(double, double, const GeomDet *)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static constexpr int jetDimY
double f[11][100]
int size() const
static constexpr int jetDimX

◆ findIntersection()

std::pair< bool, Basic3DVector< float > > DeepCoreSeedGenerator::findIntersection ( const GlobalVector dir,
const reco::Candidate::Point vertex,
const GeomDet det 
)
private

Definition at line 386 of file DeepCoreSeedGenerator.cc.

References DeadROC_duringRun::dir, StraightLinePlaneCrossing::position(), GeomDet::specificSurface(), and bphysicsOniaDQM_cfi::vertex.

Referenced by DetectorSelector(), and produce().

388  {
390  Basic3DVector<float>(dir.x(), dir.y(), dir.z()));
391 
392  std::pair<bool, Basic3DVector<float>> pos = vertexPlane.position(det->specificSurface());
393 
394  return pos;
395 }
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:40

◆ globalEndJob()

void DeepCoreSeedGenerator::globalEndJob ( tensorflow::SessionCache cache)
static

Definition at line 540 of file DeepCoreSeedGenerator.cc.

540 {}

◆ initializeGlobalCache()

std::unique_ptr< tensorflow::SessionCache > DeepCoreSeedGenerator::initializeGlobalCache ( const edm::ParameterSet iConfig)
static

Definition at line 532 of file DeepCoreSeedGenerator.cc.

References utilities::cache(), contentValuesFiles::fullPath, edm::ParameterSet::getParameter(), HLT_2023v12_cff::graphPath, and AlCaHLTBitMon_QueryRunRegistry::string.

533  {
534  // this method is supposed to create, initialize and return a Tensorflow:SessionCache instance
535  std::string graphPath = iConfig.getParameter<edm::FileInPath>("weightFile").fullPath();
536  std::unique_ptr<tensorflow::SessionCache> cache = std::make_unique<tensorflow::SessionCache>(graphPath);
537  return cache;
538 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
def cache(function)
Definition: utilities.py:3

◆ local2Pixel()

std::pair< int, int > DeepCoreSeedGenerator::local2Pixel ( double  locX,
double  locY,
const GeomDet det 
)
private

Definition at line 397 of file DeepCoreSeedGenerator.cc.

References MillePedeFileConverter_cfg::out.

Referenced by fillPixelMatrix(), and produce().

397  {
398  LocalPoint locXY(locX, locY);
399  float pixX = (dynamic_cast<const PixelGeomDetUnit*>(det))->specificTopology().pixel(locXY).first;
400  float pixY = (dynamic_cast<const PixelGeomDetUnit*>(det))->specificTopology().pixel(locXY).second;
401  std::pair<int, int> out(pixX, pixY);
402  return out;
403 }

◆ pixel2Local()

LocalPoint DeepCoreSeedGenerator::pixel2Local ( int  pixX,
int  pixY,
const GeomDet det 
)
private

Definition at line 405 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

405  {
406  float locX = (dynamic_cast<const PixelGeomDetUnit*>(det))->specificTopology().localX(pixX);
407  float locY = (dynamic_cast<const PixelGeomDetUnit*>(det))->specificTopology().localY(pixY);
408  LocalPoint locXY(locX, locY);
409  return locXY;
410 }

◆ pixelFlipper()

int DeepCoreSeedGenerator::pixelFlipper ( const GeomDet det)
private

Definition at line 412 of file DeepCoreSeedGenerator.cc.

References MillePedeFileConverter_cfg::out, GeomDet::position(), GeomDet::specificSurface(), Surface::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by fillPixelMatrix(), and produce().

412  {
413  int out = 1;
414  LocalVector locZdir(0, 0, 1);
415  GlobalVector globZdir = det->specificSurface().toGlobal(locZdir);
416  const GlobalPoint& globDetCenter = det->position();
417  float direction =
418  globZdir.x() * globDetCenter.x() + globZdir.y() * globDetCenter.y() + globZdir.z() * globDetCenter.z();
419  if (direction < 0)
420  out = -1;
421  return out;
422 }
T z() const
Definition: PV3DBase.h:61
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:40

◆ produce()

void DeepCoreSeedGenerator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 183 of file DeepCoreSeedGenerator.cc.

References funct::abs(), alongMomentum, gpuPixelDoublets::cc, HLT_FULL_cff::cores, cores_, DetectorSelector(), MillePedeFileConverter_cfg::e, PV3DBase< T, PVType, FrameType >::eta(), JetChargeProducer_cfi::exp, fillPixelMatrix(), findIntersection(), dqmdumpme::first, HLT_2023v12_cff::flip, dqmMemoryStats::float, GeomDet::geographicalId(), geometry_, geometryToken_, edm::EventSetup::getData(), mps_fire::i, GlobalTrackingGeometry::idToDet(), GlobalTrackingGeometry::idToDetUnit(), iEvent, inputPixelClusters_, inputTensorName_, createfilelist::int, dqmiolumiharvest::j, metsig::jet, jetDimX, jetDimY, jetEta_, jetPt_, MainPageGenerator::l, TrackerTopology::layer(), local2Pixel(), eostools::move(), Nlayer, Nover, EcalTangentSkim_cfg::o, convertSQLitetoXML_cfg::output, HLT_2023v12_cff::output_names, outputTensorName_, PV3DBase< T, PVType, FrameType >::phi(), pitchX_, pitchY_, pixel2Local(), PixelSubdetector::PixelBarrel, pixelClusters_, HLT_2023v12_cff::pixelCPE, pixelCPEToken_, pixelFlipper(), reco::Vertex::position(), probThr_, DiDispStaMuonMonitor_cfi::pt, ptMin_, mps_fire::result, SeedEvaluation(), funct::sin(), GeomDet::specificSurface(), splittedClusterDirections(), GeomDet::surface(), Surface::toGlobal(), GloballyPositioned< T >::toLocal(), topoToken_, AlignmentTracksFromVertexSelector_cfi::vertices, vertices_, x, PV3DBase< T, PVType, FrameType >::x(), geometryCSVtoXML::xx, y, PV3DBase< T, PVType, FrameType >::y(), geometryCSVtoXML::yy, and PV3DBase< T, PVType, FrameType >::z().

183  {
184  auto result = std::make_unique<TrajectorySeedCollection>();
185  auto resultTracks = std::make_unique<reco::TrackCollection>();
186 
187  const tensorflow::TensorShape input_size_eta({1, 1});
188  const tensorflow::TensorShape input_size_pt({1, 1});
189  const tensorflow::TensorShape input_size_cluster({1, jetDimX, jetDimY, Nlayer});
190  std::vector<std::string> output_names;
191  output_names.push_back(outputTensorName_[0]);
192  output_names.push_back(outputTensorName_[1]);
193 
194  using namespace edm;
195  using namespace reco;
196 
197  geometry_ = &iSetup.getData(geometryToken_);
198 
199  const auto& inputPixelClusters_ = iEvent.get(pixelClusters_);
200  const auto& vertices = iEvent.get(vertices_);
201  const auto& cores = iEvent.get(cores_);
202 
204 
205  const TrackerTopology* const tTopo = &iSetup.getData(topoToken_);
206  auto output = std::make_unique<edmNew::DetSetVector<SiPixelCluster>>();
207 
208  for (const auto& jet : cores) { // jet loop
209 
210  if (jet.pt() > ptMin_) {
211  std::set<unsigned long long int> ids;
212  const reco::Vertex& jetVertex = vertices[0];
213 
214  std::vector<GlobalVector> splitClustDirSet =
216  bool l2off = (splitClustDirSet.empty());
217  if (splitClustDirSet.empty()) { //if layer 1 is broken find direcitons on layer 2
218  splitClustDirSet = splittedClusterDirections(jet, tTopo, pixelCPE, jetVertex, 2, inputPixelClusters_);
219  }
220  splitClustDirSet.emplace_back(GlobalVector(jet.px(), jet.py(), jet.pz()));
221  for (int cc = 0; cc < (int)splitClustDirSet.size(); cc++) {
222  tensorflow::NamedTensorList input_tensors; //TensorFlow tensors init
223  input_tensors.resize(3);
224  input_tensors[0] =
225  tensorflow::NamedTensor(inputTensorName_[0], tensorflow::Tensor(tensorflow::DT_FLOAT, input_size_eta));
226  input_tensors[1] =
227  tensorflow::NamedTensor(inputTensorName_[1], tensorflow::Tensor(tensorflow::DT_FLOAT, input_size_pt));
228  input_tensors[2] = tensorflow::NamedTensor(inputTensorName_[2],
229  tensorflow::Tensor(tensorflow::DT_FLOAT, {input_size_cluster}));
230 
231  //put all the input tensor to 0
232  input_tensors[0].second.matrix<float>()(0, 0) = 0.0;
233  input_tensors[1].second.matrix<float>()(0, 0) = 0.0;
234  for (int x = 0; x < jetDimX; x++) {
235  for (int y = 0; y < jetDimY; y++) {
236  for (int l = 0; l < Nlayer; l++) {
237  input_tensors[2].second.tensor<float, 4>()(0, x, y, l) = 0.0;
238  }
239  }
240  } //end of TensorFlow tensors init
241 
242  GlobalVector bigClustDir = splitClustDirSet[cc];
243 
244  jetEta_ = jet.eta();
245  jetPt_ = jet.pt();
246  input_tensors[0].second.matrix<float>()(0, 0) = jet.eta();
247  input_tensors[1].second.matrix<float>()(0, 0) = jet.pt();
248 
249  const GeomDet* globDet = DetectorSelector(
250  2, jet, bigClustDir, jetVertex, tTopo, inputPixelClusters_); //det. aligned to bigClustDir on L2
251 
252  if (globDet == nullptr) //no intersection between bigClustDir and pixel detector modules found
253  continue;
254 
255  const GeomDet* goodDet1 = DetectorSelector(1, jet, bigClustDir, jetVertex, tTopo, inputPixelClusters_);
256  const GeomDet* goodDet3 = DetectorSelector(3, jet, bigClustDir, jetVertex, tTopo, inputPixelClusters_);
257  const GeomDet* goodDet4 = DetectorSelector(4, jet, bigClustDir, jetVertex, tTopo, inputPixelClusters_);
258 
259  for (const auto& detset : inputPixelClusters_) {
260  const GeomDet* det = geometry_->idToDet(detset.id());
261 
262  for (const auto& aCluster : detset) {
263  det_id_type aClusterID = detset.id();
264  if (DetId(aClusterID).subdetId() != PixelSubdetector::PixelBarrel)
265  continue;
266 
267  int lay = tTopo->layer(det->geographicalId());
268 
269  std::pair<bool, Basic3DVector<float>> interPair =
270  findIntersection(bigClustDir, (reco::Candidate::Point)jetVertex.position(), det);
271  if (interPair.first == false)
272  continue;
273  Basic3DVector<float> inter = interPair.second;
274  auto localInter = det->specificSurface().toLocal((GlobalPoint)inter);
275 
276  GlobalPoint pointVertex(jetVertex.position().x(), jetVertex.position().y(), jetVertex.position().z());
277 
278  LocalPoint clustPos_local =
279  pixelCPE->localParametersV(aCluster, (*geometry_->idToDetUnit(detset.id())))[0].first;
280 
281  if (std::abs(clustPos_local.x() - localInter.x()) / pitchX_ <= jetDimX / 2 &&
282  std::abs(clustPos_local.y() - localInter.y()) / pitchY_ <=
283  jetDimY / 2) { //used the baricenter, better description maybe useful
284 
285  if (det == goodDet1 || det == goodDet3 || det == goodDet4 || det == globDet) {
286  fillPixelMatrix(aCluster, lay, localInter, det, input_tensors);
287  }
288  } //cluster in ROI
289  } //cluster
290  } //detset
291 
292  //here the NN produce the seed from the filled input
293  std::pair<double[jetDimX][jetDimY][Nover][Npar], double[jetDimX][jetDimY][Nover]> seedParamNN =
295 
296  for (int i = 0; i < jetDimX; i++) {
297  for (int j = 0; j < jetDimY; j++) {
298  for (int o = 0; o < Nover; o++) {
299  if (seedParamNN.second[i][j][o] > (probThr_ - o * 0.1 - (l2off ? 0.35 : 0))) {
300  std::pair<bool, Basic3DVector<float>> interPair =
301  findIntersection(bigClustDir, (reco::Candidate::Point)jetVertex.position(), globDet);
302  auto localInter = globDet->specificSurface().toLocal((GlobalPoint)interPair.second);
303 
304  int flip = pixelFlipper(globDet); // 1=not flip, -1=flip
305  int nx = i - jetDimX / 2;
306  int ny = j - jetDimY / 2;
307  nx = flip * nx;
308  std::pair<int, int> pixInter = local2Pixel(localInter.x(), localInter.y(), globDet);
309  nx = nx + pixInter.first;
310  ny = ny + pixInter.second;
311  LocalPoint xyLocal = pixel2Local(nx, ny, globDet);
312 
313  double xx = xyLocal.x() + seedParamNN.first[i][j][o][0] * 0.01; //0.01=internal normalization of NN
314  double yy = xyLocal.y() + seedParamNN.first[i][j][o][1] * 0.01; //0.01=internal normalization of NN
315  LocalPoint localSeedPoint = LocalPoint(xx, yy, 0);
316 
317  double track_eta =
318  seedParamNN.first[i][j][o][2] * 0.01 + bigClustDir.eta(); //pay attention to this 0.01
319  double track_theta = 2 * std::atan(std::exp(-track_eta));
320  double track_phi =
321  seedParamNN.first[i][j][o][3] * 0.01 + bigClustDir.phi(); //pay attention to this 0.01
322 
323  double pt = 1. / seedParamNN.first[i][j][o][4];
324  double normdirR = pt / sin(track_theta);
325 
326  const GlobalVector globSeedDir(
327  GlobalVector::Polar(Geom::Theta<double>(track_theta), Geom::Phi<double>(track_phi), normdirR));
328  LocalVector localSeedDir = globDet->surface().toLocal(globSeedDir);
329  uint64_t seedid = (uint64_t(xx * 200.) << 0) + (uint64_t(yy * 200.) << 16) +
330  (uint64_t(track_eta * 400.) << 32) + (uint64_t(track_phi * 400.) << 48);
331  if (ids.count(seedid) != 0) {
332  continue;
333  }
334  //to disable jetcore iteration comment from here to probability block end--->
335  //seeing iteration skipped, useful to total eff and FakeRate comparison
336  ids.insert(seedid);
337 
338  //Covariance matrix, the hadrcoded variances = NN residuals width
339  //(see https://twiki.cern.ch/twiki/bin/view/CMSPublic/NNJetCoreAtCtD2019)
340  float em[15] = {0,
341  0,
342  0,
343  0,
344  0,
345  0,
346  0,
347  0,
348  0,
349  0,
350  0,
351  0,
352  0,
353  0,
354  0}; // (see LocalTrajectoryError for details), order as follow:
355  em[0] = 0.15 * 0.15; // q/pt
356  em[2] = 0.5e-5; // dxdz
357  em[5] = 0.5e-5; // dydz
358  em[9] = 2e-5; // x
359  em[14] = 2e-5; // y
360  long int detId = globDet->geographicalId();
361  LocalTrajectoryParameters localParam(localSeedPoint, localSeedDir, TrackCharge(1));
362  result->emplace_back(TrajectorySeed(PTrajectoryStateOnDet(localParam, pt, em, detId, /*surfaceSide*/ 0),
365 
366  GlobalPoint globalSeedPoint = globDet->surface().toGlobal(localSeedPoint);
368  resultTracks->emplace_back(
369  reco::Track(1,
370  1,
371  reco::Track::Point(globalSeedPoint.x(), globalSeedPoint.y(), globalSeedPoint.z()),
372  reco::Track::Vector(globSeedDir.x(), globSeedDir.y(), globSeedDir.z()),
373  1,
374  mm));
375  } //probability
376  }
377  }
378  }
379  } //bigcluster
380  } //jet > pt
381  } //jet
382  iEvent.put(std::move(result));
383  iEvent.put(std::move(resultTracks));
384 }
std::pair< double[jetDimX][jetDimY][Nover][Npar], double[jetDimX][jetDimY][Nover]> SeedEvaluation(tensorflow::NamedTensorList, std::vector< std::string >)
std::vector< NamedTensor > NamedTensorList
Definition: TensorFlow.h:29
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
std::vector< GlobalVector > splittedClusterDirections(const reco::Candidate &, const TrackerTopology *const, const PixelClusterParameterEstimator *, const reco::Vertex &, int, const edmNew::DetSetVector< SiPixelCluster > &)
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > pixelCPEToken_
const GeomDet * DetectorSelector(int, const reco::Candidate &, GlobalVector, const reco::Vertex &, const TrackerTopology *const, const edmNew::DetSetVector< SiPixelCluster > &)
T z() const
Definition: PV3DBase.h:61
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
edm::EDGetTokenT< edm::View< reco::Candidate > > cores_
const Point & position() const
position
Definition: Vertex.h:127
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T eta() const
Definition: PV3DBase.h:73
int pixelFlipper(const GeomDet *)
edm::Handle< edmNew::DetSetVector< SiPixelCluster > > inputPixelClusters_
LocalPoint toLocal(const GlobalPoint &gp) const
const GeomDet * idToDet(DetId) const override
void fillPixelMatrix(const SiPixelCluster &, int, Point3DBase< float, LocalTag >, const GeomDet *, tensorflow::NamedTensorList)
unsigned int layer(const DetId &id) const
std::pair< bool, Basic3DVector< float > > findIntersection(const GlobalVector &, const reco::Candidate::Point &, const GeomDet *)
std::pair< std::string, Tensor > NamedTensor
Definition: TensorFlow.h:28
static constexpr int Nlayer
int TrackCharge
Definition: TrackCharge.h:4
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int iEvent
Definition: GenABIO.cc:224
std::vector< std::string > inputTensorName_
std::pair< int, int > local2Pixel(double, double, const GeomDet *)
const GlobalTrackingGeometry * geometry_
LocalPoint pixel2Local(int, int, const GeomDet *)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static constexpr int jetDimY
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
Definition: DetId.h:17
std::vector< std::string > outputTensorName_
uint32_t det_id_type
Definition: DetSet.h:20
edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
unsigned long long uint64_t
Definition: Time.h:13
static constexpr int Nover
static constexpr int jetDimX
fixed size matrix
HLT enums.
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:40
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:77
Definition: Phi.h:52
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
def move(src, dest)
Definition: eostools.py:511
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74
Global3DVector GlobalVector
Definition: GlobalVector.h:10
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.

◆ SeedEvaluation()

std::pair< double[DeepCoreSeedGenerator::jetDimX][DeepCoreSeedGenerator::jetDimY][DeepCoreSeedGenerator::Nover] [DeepCoreSeedGenerator::Npar], double[DeepCoreSeedGenerator::jetDimX][DeepCoreSeedGenerator::jetDimY][DeepCoreSeedGenerator::Nover]> DeepCoreSeedGenerator::SeedEvaluation ( tensorflow::NamedTensorList  input_tensors,
std::vector< std::string >  output_names 
)
private

Definition at line 450 of file DeepCoreSeedGenerator.cc.

References dqmMemoryStats::float, jetDimX, jetDimY, Nover, Npar, HLT_2023v12_cff::output_names, PatBasicFWLiteJetAnalyzer_Selector_cfg::outputs, AlCaHLTBitMon_ParallelJobs::p, tensorflow::run(), session_, x, and y.

Referenced by produce().

451  {
452  std::vector<tensorflow::Tensor> outputs;
453  tensorflow::run(session_, input_tensors, output_names, &outputs);
454  auto matrix_output_par = outputs.at(0).tensor<float, 5>();
455  auto matrix_output_prob = outputs.at(1).tensor<float, 5>();
456 
457  std::pair<double[jetDimX][jetDimY][Nover][Npar], double[jetDimX][jetDimY][Nover]> output_combined;
458 
459  for (int x = 0; x < jetDimX; x++) {
460  for (int y = 0; y < jetDimY; y++) {
461  for (int trk = 0; trk < Nover; trk++) {
462  output_combined.second[x][y][trk] =
463  matrix_output_prob(0, x, y, trk, 0); //outputs.at(1).matrix<double>()(0,x,y,trk);
464 
465  for (int p = 0; p < Npar; p++) {
466  output_combined.first[x][y][trk][p] =
467  matrix_output_par(0, x, y, trk, p); //outputs.at(0).matrix<double>()(0,x,y,trk,p);
468  }
469  }
470  }
471  }
472  return output_combined;
473 }
static constexpr int Npar
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Definition: TensorFlow.cc:222
static constexpr int jetDimY
static constexpr int Nover
static constexpr int jetDimX
const tensorflow::Session * session_

◆ splittedClusterDirections()

std::vector< GlobalVector > DeepCoreSeedGenerator::splittedClusterDirections ( const reco::Candidate jet,
const TrackerTopology * const  tTopo,
const PixelClusterParameterEstimator pixelCPE,
const reco::Vertex jetVertex,
int  layer,
const edmNew::DetSetVector< SiPixelCluster > &  clusters 
)
private

Definition at line 505 of file DeepCoreSeedGenerator.cc.

References bsc_activity_cfg::clusters, PbPb_ZMuSkimMuonDPG_cff::deltaR, deltaR_, GeomDet::geographicalId(), geometry_, GlobalTrackingGeometry::idToDet(), GlobalTrackingGeometry::idToDetUnit(), metsig::jet, pixelTopology::layer, TrackerTopology::layer(), HLT_2023v12_cff::pixelCPE, reco::Vertex::position(), GeomDet::surface(), and Surface::toGlobal().

Referenced by produce().

511  {
512  std::vector<GlobalVector> clustDirs;
513  for (const auto& detset_int : clusters) {
514  const GeomDet* det_int = geometry_->idToDet(detset_int.id());
515  int lay = tTopo->layer(det_int->geographicalId());
516  if (lay != layer)
517  continue; //NB: saved bigClusters on all the layers!!
518  auto detUnit = geometry_->idToDetUnit(detset_int.id());
519  for (const auto& aCluster : detset_int) {
520  GlobalPoint clustPos = det_int->surface().toGlobal(pixelCPE->localParametersV(aCluster, (*detUnit))[0].first);
521  GlobalPoint vertexPos(jetVertex.position().x(), jetVertex.position().y(), jetVertex.position().z());
522  GlobalVector clusterDir = clustPos - vertexPos;
523  GlobalVector jetDir(jet.px(), jet.py(), jet.pz());
524  if (Geom::deltaR(jetDir, clusterDir) < deltaR_) {
525  clustDirs.emplace_back(clusterDir);
526  }
527  }
528  }
529  return clustDirs;
530 }
const Point & position() const
position
Definition: Vertex.h:127
const GeomDet * idToDet(DetId) const override
unsigned int layer(const DetId &id) const
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
const GlobalTrackingGeometry * geometry_
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.

Member Data Documentation

◆ centralMIPCharge_

double DeepCoreSeedGenerator::centralMIPCharge_
private

Definition at line 116 of file DeepCoreSeedGenerator.cc.

◆ chargeFracMin_

double DeepCoreSeedGenerator::chargeFracMin_
private

Definition at line 115 of file DeepCoreSeedGenerator.cc.

◆ cores_

edm::EDGetTokenT<edm::View<reco::Candidate> > DeepCoreSeedGenerator::cores_
private

Definition at line 108 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ deltaR_

double DeepCoreSeedGenerator::deltaR_
private

Definition at line 114 of file DeepCoreSeedGenerator.cc.

Referenced by splittedClusterDirections().

◆ geometry_

const GlobalTrackingGeometry* DeepCoreSeedGenerator::geometry_ = nullptr
private

Definition at line 103 of file DeepCoreSeedGenerator.cc.

Referenced by DetectorSelector(), produce(), and splittedClusterDirections().

◆ geometryToken_

const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> DeepCoreSeedGenerator::geometryToken_
private

Definition at line 109 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ inputPixelClusters_

edm::Handle<edmNew::DetSetVector<SiPixelCluster> > DeepCoreSeedGenerator::inputPixelClusters_
private

Definition at line 107 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ inputTensorName_

std::vector<std::string> DeepCoreSeedGenerator::inputTensorName_
private

Definition at line 118 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ jetDimX

constexpr int DeepCoreSeedGenerator::jetDimX = 30
static

Definition at line 92 of file DeepCoreSeedGenerator.cc.

Referenced by fillPixelMatrix(), produce(), and SeedEvaluation().

◆ jetDimY

constexpr int DeepCoreSeedGenerator::jetDimY = 30
static

Definition at line 93 of file DeepCoreSeedGenerator.cc.

Referenced by fillPixelMatrix(), produce(), and SeedEvaluation().

◆ jetEta_

double DeepCoreSeedGenerator::jetEta_

Definition at line 89 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ jetPt_

double DeepCoreSeedGenerator::jetPt_

Definition at line 88 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ Nlayer

constexpr int DeepCoreSeedGenerator::Nlayer = 4
static

Definition at line 94 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ Nover

constexpr int DeepCoreSeedGenerator::Nover = 3
static

Definition at line 95 of file DeepCoreSeedGenerator.cc.

Referenced by produce(), and SeedEvaluation().

◆ Npar

constexpr int DeepCoreSeedGenerator::Npar = 5
static

Definition at line 96 of file DeepCoreSeedGenerator.cc.

Referenced by SeedEvaluation().

◆ outputTensorName_

std::vector<std::string> DeepCoreSeedGenerator::outputTensorName_
private

Definition at line 119 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ pitchX_

double DeepCoreSeedGenerator::pitchX_ = 0.01

Definition at line 90 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ pitchY_

double DeepCoreSeedGenerator::pitchY_ = 0.015

Definition at line 91 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ pixelClusters_

edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > DeepCoreSeedGenerator::pixelClusters_
private

Definition at line 106 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ pixelCPEToken_

const edm::ESGetToken<PixelClusterParameterEstimator, TkPixelCPERecord> DeepCoreSeedGenerator::pixelCPEToken_
private

Definition at line 110 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ probThr_

double DeepCoreSeedGenerator::probThr_
private

Definition at line 120 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ propagatorName_

std::string DeepCoreSeedGenerator::propagatorName_
private

Definition at line 102 of file DeepCoreSeedGenerator.cc.

◆ ptMin_

double DeepCoreSeedGenerator::ptMin_
private

Definition at line 113 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ session_

const tensorflow::Session* DeepCoreSeedGenerator::session_
private

Definition at line 121 of file DeepCoreSeedGenerator.cc.

Referenced by SeedEvaluation().

◆ topoToken_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> DeepCoreSeedGenerator::topoToken_
private

Definition at line 111 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ vertices_

edm::EDGetTokenT<std::vector<reco::Vertex> > DeepCoreSeedGenerator::vertices_
private

Definition at line 105 of file DeepCoreSeedGenerator.cc.

Referenced by produce().

◆ weightfilename_

std::string DeepCoreSeedGenerator::weightfilename_
private

Definition at line 117 of file DeepCoreSeedGenerator.cc.