CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
JetCoreClusterSplitter Class Reference
Inheritance diagram for JetCoreClusterSplitter:
edm::stream::EDProducer<>

Public Member Functions

 JetCoreClusterSplitter (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~JetCoreClusterSplitter () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 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)
 

Private Member Functions

std::pair< float, float > closestClusters (const std::vector< float > &distanceMap)
 
std::multimap< float, int > distScore (const std::vector< std::vector< float >> &distanceMap)
 
std::vector< SiPixelClusterfittingSplit (const SiPixelCluster &aCluster, float expectedADC, int sizeY, int sizeX, float jetZOverRho, unsigned int nSplitted)
 
std::multimap< float, int > secondDistDiffScore (const std::vector< std::vector< float >> &distanceMap)
 
std::multimap< float, int > secondDistScore (const std::vector< std::vector< float >> &distanceMap)
 
bool split (const SiPixelCluster &aCluster, edmNew::DetSetVector< SiPixelCluster >::FastFiller &filler, float expectedADC, int sizeY, int sizeX, float jetZOverRho)
 

Private Attributes

double centralMIPCharge_
 
double chargeFracMin_
 
double chargePerUnit_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > cores_
 
double deltaR_
 
float expSizeXAtLorentzAngleIncidence_
 
float expSizeXDeltaPerTanAlpha_
 
float expSizeYAtNormalIncidence_
 
double forceXError_
 
double forceYError_
 
double fractionalWidth_
 
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
 
double ptMin_
 
float tanLorentzAngle_
 
float tanLorentzAngleBarrelLayer1_
 
edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > const tCPE_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > const tTrackerTopo_
 
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > const tTrackingGeom_
 
bool verbose
 
edm::EDGetTokenT< reco::VertexCollectionvertices_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
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

Definition at line 31 of file JetCoreClusterSplitter.cc.

Constructor & Destructor Documentation

◆ JetCoreClusterSplitter()

JetCoreClusterSplitter::JetCoreClusterSplitter ( const edm::ParameterSet iConfig)

Definition at line 105 of file JetCoreClusterSplitter.cc.

107  tCPE_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("pixelCPE")))),
109  verbose(iConfig.getParameter<bool>("verbose")),
110  ptMin_(iConfig.getParameter<double>("ptMin")),
111  deltaR_(iConfig.getParameter<double>("deltaRmax")),
112  chargeFracMin_(iConfig.getParameter<double>("chargeFractionMin")),
113  expSizeXAtLorentzAngleIncidence_(iConfig.getParameter<double>("expSizeXAtLorentzAngleIncidence")),
114  expSizeXDeltaPerTanAlpha_(iConfig.getParameter<double>("expSizeXDeltaPerTanAlpha")),
115  expSizeYAtNormalIncidence_(iConfig.getParameter<double>("expSizeYAtNormalIncidence")),
116  tanLorentzAngle_(iConfig.getParameter<double>("tanLorentzAngle")),
117  tanLorentzAngleBarrelLayer1_(iConfig.getParameter<double>("tanLorentzAngleBarrelLayer1")),
119  consumes<edmNew::DetSetVector<SiPixelCluster>>(iConfig.getParameter<edm::InputTag>("pixelClusters"))),
120  vertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))),
121  cores_(consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("cores"))),
122  forceXError_(iConfig.getParameter<double>("forceXError")),
123  forceYError_(iConfig.getParameter<double>("forceYError")),
124  fractionalWidth_(iConfig.getParameter<double>("fractionalWidth")),
125  chargePerUnit_(iConfig.getParameter<double>("chargePerUnit")),
126  centralMIPCharge_(iConfig.getParameter<double>("centralMIPCharge"))
127 
128 {
129  produces<edmNew::DetSetVector<SiPixelCluster>>();
130 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
edm::EDGetTokenT< reco::VertexCollection > vertices_
edm::EDGetTokenT< edm::View< reco::Candidate > > cores_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > const tTrackerTopo_
edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > const tCPE_
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > const tTrackingGeom_

◆ ~JetCoreClusterSplitter()

JetCoreClusterSplitter::~JetCoreClusterSplitter ( )
override

Definition at line 132 of file JetCoreClusterSplitter.cc.

132 {}

Member Function Documentation

◆ closestClusters()

std::pair< float, float > JetCoreClusterSplitter::closestClusters ( const std::vector< float > &  distanceMap)
private

Definition at line 261 of file JetCoreClusterSplitter.cc.

References mps_fire::i, and WZElectronSkims53X_cff::max.

Referenced by distScore(), secondDistDiffScore(), and secondDistScore().

261  {
262  float minDist = std::numeric_limits<float>::max();
263  float secondMinDist = std::numeric_limits<float>::max();
264  for (unsigned int i = 0; i < distanceMap.size(); i++) {
265  float dist = distanceMap[i];
266  if (dist < minDist) {
267  secondMinDist = minDist;
268  minDist = dist;
269  } else if (dist < secondMinDist) {
270  secondMinDist = dist;
271  }
272  }
273  return std::pair<float, float>(minDist, secondMinDist);
274 }

◆ distScore()

std::multimap< float, int > JetCoreClusterSplitter::distScore ( const std::vector< std::vector< float >> &  distanceMap)
private

Definition at line 295 of file JetCoreClusterSplitter.cc.

References closestClusters(), ztail::d, and dqmiolumiharvest::j.

295  {
296  std::multimap<float, int> scores;
297  for (unsigned int j = 0; j < distanceMap.size(); j++) {
298  std::pair<float, float> d = closestClusters(distanceMap[j]);
299  scores.insert(std::pair<float, int>(-d.first, j));
300  }
301  return scores;
302 }
d
Definition: ztail.py:151
std::pair< float, float > closestClusters(const std::vector< float > &distanceMap)

◆ fillDescriptions()

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

Definition at line 79 of file JetCoreClusterSplitter.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, SiPixelPhase1Clusters_cfi::e3, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

79  {
81 
82  desc.add<std::string>("pixelCPE", "PixelCPEGeneric");
83  desc.add<bool>("verbose", false);
84  desc.add<double>("ptMin", 200.0);
85  desc.add<double>("deltaRmax", 0.05);
86  desc.add<double>("chargeFractionMin", 2.0);
87  desc.add<edm::InputTag>("pixelClusters", edm::InputTag("siPixelCluster"));
88  desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
89  desc.add<edm::InputTag>("cores", edm::InputTag("ak5CaloJets"));
90  desc.add<double>("forceXError", 100.0);
91  desc.add<double>("forceYError", 150.0);
92  desc.add<double>("fractionalWidth", 0.4);
93  desc.add<double>("chargePerUnit", 2000.0);
94  desc.add<double>("centralMIPCharge", 26e3);
95 
96  desc.add<double>("expSizeXAtLorentzAngleIncidence", 1.5);
97  desc.add<double>("expSizeXDeltaPerTanAlpha", 0.0);
98  desc.add<double>("expSizeYAtNormalIncidence", 1.3);
99  desc.add<double>("tanLorentzAngle", 0.0);
100  desc.add<double>("tanLorentzAngleBarrelLayer1", 0.0);
101 
102  descriptions.addWithDefaultLabel(desc);
103 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ fittingSplit()

std::vector< SiPixelCluster > JetCoreClusterSplitter::fittingSplit ( const SiPixelCluster aCluster,
float  expectedADC,
int  sizeY,
int  sizeX,
float  jetZOverRho,
unsigned int  nSplitted 
)
private

Definition at line 304 of file JetCoreClusterSplitter.cc.

References funct::abs(), gpuClustering::adc, centralMIPCharge_, chargePerUnit_, haddnano::cl, gather_cfg::cout, MillePedeFileConverter_cfg::e, relativeConstraints::empty, JetChargeProducer_cfi::exp, f, forceXError_, forceYError_, fractionalWidth_, mps_fire::i, createfilelist::int, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, isotrackApplyRegressor::k, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, SiPixelCluster::pixels(), Hcal_Conditions_forGlobalTag_cff::pixels, edm::second(), secondDistScore(), RecoTauValidation_cfi::sizeX, RecoTauValidation_cfi::sizeY, mathSSE::sqrt(), isotrackNtupler::stop, verbose, x, and y.

Referenced by split().

309  {
310  std::vector<SiPixelCluster> output;
311 
312  unsigned int meanExp = nSplitted;
313  if (meanExp <= 1) {
314  output.push_back(aCluster);
315  return output;
316  }
317 
318  std::vector<float> clx(meanExp);
319  std::vector<float> cly(meanExp);
320  std::vector<float> cls(meanExp);
321  std::vector<float> oldclx(meanExp);
322  std::vector<float> oldcly(meanExp);
323  std::vector<SiPixelCluster::Pixel> originalpixels = aCluster.pixels();
324  std::vector<std::pair<int, SiPixelCluster::Pixel>> pixels;
325  for (unsigned int j = 0; j < originalpixels.size(); j++) {
326  int sub = originalpixels[j].adc / chargePerUnit_ * expectedADC / centralMIPCharge_;
327  if (sub < 1)
328  sub = 1;
329  int perDiv = originalpixels[j].adc / sub;
330  if (verbose)
331  std::cout << "Splitting " << j << " in [ " << pixels.size() << " , " << pixels.size() + sub
332  << " ], expected numb of clusters: " << meanExp << " original pixel (x,y) " << originalpixels[j].x
333  << " " << originalpixels[j].y << " sub " << sub << std::endl;
334  for (int k = 0; k < sub; k++) {
335  if (k == sub - 1)
336  perDiv = originalpixels[j].adc - perDiv * k;
337  pixels.push_back(std::make_pair(j, SiPixelCluster::Pixel(originalpixels[j].x, originalpixels[j].y, perDiv)));
338  }
339  }
340  std::vector<int> clusterForPixel(pixels.size());
341  // initial values
342  for (unsigned int j = 0; j < meanExp; j++) {
343  oldclx[j] = -999;
344  oldcly[j] = -999;
345  clx[j] = originalpixels[0].x + j;
346  cly[j] = originalpixels[0].y + j;
347  cls[j] = 0;
348  }
349  bool stop = false;
350  int remainingSteps = 100;
351  while (!stop && remainingSteps > 0) {
352  remainingSteps--;
353  // Compute all distances
354  std::vector<std::vector<float>> distanceMapX(originalpixels.size(), std::vector<float>(meanExp));
355  std::vector<std::vector<float>> distanceMapY(originalpixels.size(), std::vector<float>(meanExp));
356  std::vector<std::vector<float>> distanceMap(originalpixels.size(), std::vector<float>(meanExp));
357  for (unsigned int j = 0; j < originalpixels.size(); j++) {
358  if (verbose)
359  std::cout << "Original Pixel pos " << j << " " << pixels[j].second.x << " " << pixels[j].second.y << std::endl;
360  for (unsigned int i = 0; i < meanExp; i++) {
361  distanceMapX[j][i] = 1.f * originalpixels[j].x - clx[i];
362  distanceMapY[j][i] = 1.f * originalpixels[j].y - cly[i];
363  float dist = 0;
364  // float sizeX=2;
365  if (std::abs(distanceMapX[j][i]) > sizeX / 2.f) {
366  dist +=
367  (std::abs(distanceMapX[j][i]) - sizeX / 2.f + 1.f) * (std::abs(distanceMapX[j][i]) - sizeX / 2.f + 1.f);
368  } else {
369  dist += (2.f * distanceMapX[j][i] / sizeX) * (2.f * distanceMapX[j][i] / sizeX);
370  }
371 
372  if (std::abs(distanceMapY[j][i]) > sizeY / 2.f) {
373  dist += 1.f * (std::abs(distanceMapY[j][i]) - sizeY / 2.f + 1.f) *
374  (std::abs(distanceMapY[j][i]) - sizeY / 2.f + 1.f);
375  } else {
376  dist += 1.f * (2.f * distanceMapY[j][i] / sizeY) * (2.f * distanceMapY[j][i] / sizeY);
377  }
378  distanceMap[j][i] = sqrt(dist);
379  if (verbose)
380  std::cout << "Cluster " << i << " Original Pixel " << j << " distances: " << distanceMapX[j][i] << " "
381  << distanceMapY[j][i] << " " << distanceMap[j][i] << std::endl;
382  }
383  }
384  // Compute scores for sequential addition. The first index is the
385  // distance, in whatever metrics we use, while the second is the
386  // pixel index w.r.t which the distance is computed.
387  std::multimap<float, int> scores;
388 
389  // Using different rankings to improve convergence (as Giulio proposed)
390  scores = secondDistScore(distanceMap);
391 
392  // Iterate starting from the ones with furthest second best clusters, i.e.
393  // easy choices
394  std::vector<float> weightOfPixel(pixels.size());
395  for (std::multimap<float, int>::iterator it = scores.begin(); it != scores.end(); it++) {
396  int pixel_index = it->second;
397  if (verbose)
398  std::cout << "Original Pixel " << pixel_index << " with score " << it->first << std::endl;
399  // find cluster that is both close and has some charge still to assign
400  int subpixel_counter = 0;
401  for (auto subpixel = pixels.begin(); subpixel != pixels.end(); ++subpixel, ++subpixel_counter) {
402  if (subpixel->first > pixel_index) {
403  break;
404  } else if (subpixel->first != pixel_index) {
405  continue;
406  } else {
407  float maxEst = 0;
408  int cl = -1;
409  for (unsigned int subcluster_index = 0; subcluster_index < meanExp; subcluster_index++) {
410  float nsig = (cls[subcluster_index] - expectedADC) /
411  (expectedADC * fractionalWidth_); // 20% uncertainty? realistic from Landau?
412  float clQest = 1.f / (1.f + std::exp(nsig)) + 1e-6f; // 1./(1.+exp(x*x-3*3))
413  float clDest = 1.f / (distanceMap[pixel_index][subcluster_index] + 0.05f);
414 
415  if (verbose)
416  std::cout << " Q: " << clQest << " D: " << clDest << " " << distanceMap[pixel_index][subcluster_index]
417  << std::endl;
418  float est = clQest * clDest;
419  if (est > maxEst) {
420  cl = subcluster_index;
421  maxEst = est;
422  }
423  }
424  cls[cl] += subpixel->second.adc;
425  clusterForPixel[subpixel_counter] = cl;
426  weightOfPixel[subpixel_counter] = maxEst;
427  if (verbose)
428  std::cout << "Pixel weight j cl " << weightOfPixel[subpixel_counter] << " " << subpixel_counter << " " << cl
429  << std::endl;
430  }
431  }
432  }
433  // Recompute cluster centers
434  stop = true;
435  for (unsigned int subcluster_index = 0; subcluster_index < meanExp; subcluster_index++) {
436  if (std::abs(clx[subcluster_index] - oldclx[subcluster_index]) > 0.01f)
437  stop = false; // still moving
438  if (std::abs(cly[subcluster_index] - oldcly[subcluster_index]) > 0.01f)
439  stop = false;
440  oldclx[subcluster_index] = clx[subcluster_index];
441  oldcly[subcluster_index] = cly[subcluster_index];
442  clx[subcluster_index] = 0;
443  cly[subcluster_index] = 0;
444  cls[subcluster_index] = 1e-99;
445  }
446  for (unsigned int pixel_index = 0; pixel_index < pixels.size(); pixel_index++) {
447  if (clusterForPixel[pixel_index] < 0)
448  continue;
449  if (verbose)
450  std::cout << "j " << pixel_index << " x " << pixels[pixel_index].second.x << " * y "
451  << pixels[pixel_index].second.y << " * ADC " << pixels[pixel_index].second.adc << " * W "
452  << weightOfPixel[pixel_index] << std::endl;
453  clx[clusterForPixel[pixel_index]] += pixels[pixel_index].second.x * pixels[pixel_index].second.adc;
454  cly[clusterForPixel[pixel_index]] += pixels[pixel_index].second.y * pixels[pixel_index].second.adc;
455  cls[clusterForPixel[pixel_index]] += pixels[pixel_index].second.adc;
456  }
457  for (unsigned int subcluster_index = 0; subcluster_index < meanExp; subcluster_index++) {
458  if (cls[subcluster_index] != 0) {
459  clx[subcluster_index] /= cls[subcluster_index];
460  cly[subcluster_index] /= cls[subcluster_index];
461  }
462  if (verbose)
463  std::cout << "Center for cluster " << subcluster_index << " x,y " << clx[subcluster_index] << " "
464  << cly[subcluster_index] << std::endl;
465  cls[subcluster_index] = 0;
466  }
467  }
468  if (verbose)
469  std::cout << "maxstep " << remainingSteps << std::endl;
470  // accumulate pixel with same cl
471  std::vector<std::vector<SiPixelCluster::Pixel>> pixelsForCl(meanExp);
472  for (int cl = 0; cl < (int)meanExp; cl++) {
473  for (unsigned int j = 0; j < pixels.size(); j++) {
474  if (clusterForPixel[j] == cl and pixels[j].second.adc != 0) { // for each pixel of cluster
475  // cl find the other pixels
476  // with same x,y and
477  // accumulate+reset their adc
478  for (unsigned int k = j + 1; k < pixels.size(); k++) {
479  if (pixels[k].second.adc != 0 and pixels[k].second.x == pixels[j].second.x and
480  pixels[k].second.y == pixels[j].second.y and clusterForPixel[k] == cl) {
481  if (verbose)
482  std::cout << "Resetting all sub-pixel for location " << pixels[k].second.x << ", " << pixels[k].second.y
483  << " at index " << k << " associated to cl " << clusterForPixel[k] << std::endl;
484  pixels[j].second.adc += pixels[k].second.adc;
485  pixels[k].second.adc = 0;
486  }
487  }
488  for (unsigned int p = 0; p < pixels.size(); ++p)
489  if (verbose)
490  std::cout << "index, x, y, ADC: " << p << ", " << pixels[p].second.x << ", " << pixels[p].second.y << ", "
491  << pixels[p].second.adc << " associated to cl " << clusterForPixel[p] << std::endl
492  << "Adding pixel " << pixels[j].second.x << ", " << pixels[j].second.y << " to cluster " << cl
493  << std::endl;
494  pixelsForCl[cl].push_back(pixels[j].second);
495  }
496  }
497  }
498 
499  // std::vector<std::vector<std::vector<SiPixelCluster::PixelPos *> > >
500  //pixelMap(meanExp,std::vector<std::vector<SiPixelCluster::PixelPos *>
501  //>(512,std::vector<SiPixelCluster::Pixel *>(512,0)));
502 
503  for (int cl = 0; cl < (int)meanExp; cl++) {
504  if (verbose)
505  std::cout << "Pixels of cl " << cl << " ";
506  for (unsigned int j = 0; j < pixelsForCl[cl].size(); j++) {
507  SiPixelCluster::PixelPos newpix(pixelsForCl[cl][j].x, pixelsForCl[cl][j].y);
508  if (verbose)
509  std::cout << pixelsForCl[cl][j].x << "," << pixelsForCl[cl][j].y << "|";
510  if (j == 0) {
511  output.emplace_back(newpix, pixelsForCl[cl][j].adc);
512  } else {
513  output.back().add(newpix, pixelsForCl[cl][j].adc);
514  }
515  }
516  if (verbose)
517  std::cout << std::endl;
518  if (!pixelsForCl[cl].empty()) {
519  if (forceXError_ > 0)
520  output.back().setSplitClusterErrorX(forceXError_);
521  if (forceYError_ > 0)
522  output.back().setSplitClusterErrorY(forceYError_);
523  }
524  }
525  // if(verbose) std::cout << "Weights" << std::endl;
526  // if(verbose) print(theWeights,aCluster,1);
527  // if(verbose) std::cout << "Unused charge" << std::endl;
528  // if(verbose) print(theBufferResidual,aCluster);
529 
530  return output;
531 }
std::multimap< float, int > secondDistScore(const std::vector< std::vector< float >> &distanceMap)
U second(std::pair< T, U > const &p)
const std::vector< Pixel > pixels() const
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
Definition: output.py:1
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ produce()

void JetCoreClusterSplitter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 136 of file JetCoreClusterSplitter.cc.

References funct::abs(), edmNew::DetSetVector< T >::begin(), Surface::bounds(), DummyCfis::c, centralMIPCharge_, SiPixelCluster::charge(), chargeFracMin_, GetRecoTauVFromDQM_MC_cff::cl2, HLT_FULL_cff::cores, cores_, gather_cfg::cout, eleIsoSequence_cff::deltaR, deltaR_, vertexPlots::e4, edmNew::DetSetVector< T >::end(), expSizeXAtLorentzAngleIncidence_, expSizeXDeltaPerTanAlpha_, expSizeYAtNormalIncidence_, f, trigObjTnPSource_cfi::filler, dqmdumpme::first, edm::EventSetup::getData(), edmNew::DetSetVector< T >::id(), iEvent, metsig::jet, SiPixelCluster::minPixelRow(), eostools::move(), pixelClusters_, createTree::pp, ptMin_, SiPixelCluster::sizeX(), SiPixelCluster::sizeY(), split(), mathSSE::sqrt(), GeomDet::surface(), jetCoreClusterSplitter_cfi::tanLorentzAngle, tanLorentzAngle_, tanLorentzAngleBarrelLayer1_, tCPE_, ppsPixelTopologyESSourceRun2_cfi::thickness, Bounds::thickness(), Surface::toGlobal(), GloballyPositioned< T >::toLocal(), GeomDet::topology(), HLT_2024v14_cff::topology, tTrackerTopo_, tTrackingGeom_, verbose, AlignmentTracksFromVertexSelector_cfi::vertices, vertices_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

136  {
137  using namespace edm;
138  const auto& geometry = &iSetup.getData(tTrackingGeom_);
139  const auto& topology = &iSetup.getData(tTrackerTopo_);
140 
142  iEvent.getByToken(pixelClusters_, inputPixelClusters);
143 
145  iEvent.getByToken(vertices_, vertices);
146  const reco::Vertex& pv = (*vertices)[0];
147 
149  iEvent.getByToken(cores_, cores);
150 
152  auto output = std::make_unique<edmNew::DetSetVector<SiPixelCluster>>();
153 
154  edmNew::DetSetVector<SiPixelCluster>::const_iterator detIt = inputPixelClusters->begin();
155  for (; detIt != inputPixelClusters->end(); detIt++) {
157  const edmNew::DetSet<SiPixelCluster>& detset = *detIt;
158  const GeomDet* det = geometry->idToDet(detset.id());
159  float pitchX, pitchY;
160  std::tie(pitchX, pitchY) = static_cast<const PixelTopology&>(det->topology()).pitch();
161  float thickness = det->surface().bounds().thickness();
163  if (DetId(detset.id()).subdetId() == 1 /* px barrel */ && topology->pxbLayer(detset.id()) == 1) {
165  }
166  for (auto cluster = detset.begin(); cluster != detset.end(); cluster++) {
167  const SiPixelCluster& aCluster = *cluster;
168  bool hasBeenSplit = false;
169  bool shouldBeSplit = false;
170  GlobalPoint cPos =
171  det->surface().toGlobal(pp->localParametersV(aCluster, (*geometry->idToDetUnit(detIt->id())))[0].first);
172  GlobalPoint ppv(pv.position().x(), pv.position().y(), pv.position().z());
173  GlobalVector clusterDir = cPos - ppv;
174  for (unsigned int ji = 0; ji < cores->size(); ji++) {
175  if ((*cores)[ji].pt() > ptMin_) {
176  const reco::Candidate& jet = (*cores)[ji];
177  GlobalVector jetDir(jet.px(), jet.py(), jet.pz());
178  if (Geom::deltaR(jetDir, clusterDir) < deltaR_) {
179  // check if the cluster has to be splitted
180 
181  LocalVector jetDirLocal = det->surface().toLocal(jetDir);
182  float jetTanAlpha = jetDirLocal.x() / jetDirLocal.z();
183  float jetTanBeta = jetDirLocal.y() / jetDirLocal.z();
184  float jetZOverRho = std::sqrt(jetTanAlpha * jetTanAlpha + jetTanBeta * jetTanBeta);
185  float expSizeX = expSizeXAtLorentzAngleIncidence_ +
188  thickness * thickness / (pitchY * pitchY) * jetTanBeta * jetTanBeta);
189  if (expSizeX < 1.f)
190  expSizeX = 1.f;
191  if (expSizeY < 1.f)
192  expSizeY = 1.f;
193  float expCharge = std::sqrt(1.08f + jetZOverRho * jetZOverRho) * centralMIPCharge_;
194 
195  if (aCluster.charge() > expCharge * chargeFracMin_ &&
196  (aCluster.sizeX() > expSizeX + 1 || aCluster.sizeY() > expSizeY + 1)) {
197  shouldBeSplit = true;
198  if (verbose)
199  std::cout << "Trying to split: charge and deltaR " << aCluster.charge() << " "
200  << Geom::deltaR(jetDir, clusterDir) << " size x y " << aCluster.sizeX() << " "
201  << aCluster.sizeY() << " exp. size (x,y) " << expSizeX << " " << expSizeY << " detid "
202  << detIt->id() << std::endl;
203  if (verbose)
204  std::cout << "jetZOverRho=" << jetZOverRho << std::endl;
205 
206  if (split(aCluster, filler, expCharge, expSizeY, expSizeX, jetZOverRho)) {
207  hasBeenSplit = true;
208  }
209  }
210  }
211  }
212  }
213  if (!hasBeenSplit) {
214  SiPixelCluster c = aCluster;
215  if (shouldBeSplit) {
216  // blowup the error if we failed to split a splittable cluster (does
217  // it ever happen)
218  const float fromCentiToMicro = 1e4;
219  c.setSplitClusterErrorX(c.sizeX() *
220  (pitchX * fromCentiToMicro / 3.f)); // this is not really blowing up .. TODO: tune
221  c.setSplitClusterErrorY(c.sizeY() * (pitchY * fromCentiToMicro / 3.f));
222  }
223  filler.push_back(c);
224  std::push_heap(filler.begin(), filler.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
225  return cl1.minPixelRow() < cl2.minPixelRow();
226  });
227  }
228  } // loop over clusters
229  std::sort_heap(filler.begin(), filler.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
230  return cl1.minPixelRow() < cl2.minPixelRow();
231  });
232 
233  } // loop over det
234  iEvent.put(std::move(output));
235 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
T z() const
Definition: PV3DBase.h:61
virtual const Topology & topology() const
Definition: GeomDet.cc:67
bool split(const SiPixelCluster &aCluster, edmNew::DetSetVector< SiPixelCluster >::FastFiller &filler, float expectedADC, int sizeY, int sizeX, float jetZOverRho)
int sizeY() const
edm::EDGetTokenT< reco::VertexCollection > vertices_
LocalPoint toLocal(const GlobalPoint &gp) const
edm::EDGetTokenT< edm::View< reco::Candidate > > cores_
const_iterator end(bool update=false) const
int minPixelRow() const
int charge() const
virtual float thickness() const =0
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int iEvent
Definition: GenABIO.cc:224
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > const tTrackerTopo_
edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > const tCPE_
T sqrt(T t)
Definition: SSEVec.h:23
int sizeX() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > const tTrackingGeom_
id_type id(size_t cell) const
double f[11][100]
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetId.h:17
const_iterator begin(bool update=false) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
Pixel cluster – collection of neighboring pixels above threshold.
HLT enums.
Definition: output.py:1
def move(src, dest)
Definition: eostools.py:511
const Bounds & bounds() const
Definition: Surface.h:87

◆ secondDistDiffScore()

std::multimap< float, int > JetCoreClusterSplitter::secondDistDiffScore ( const std::vector< std::vector< float >> &  distanceMap)
private

Definition at line 276 of file JetCoreClusterSplitter.cc.

References closestClusters(), ztail::d, and dqmiolumiharvest::j.

277  {
278  std::multimap<float, int> scores;
279  for (unsigned int j = 0; j < distanceMap.size(); j++) {
280  std::pair<float, float> d = closestClusters(distanceMap[j]);
281  scores.insert(std::pair<float, int>(d.second - d.first, j));
282  }
283  return scores;
284 }
d
Definition: ztail.py:151
std::pair< float, float > closestClusters(const std::vector< float > &distanceMap)

◆ secondDistScore()

std::multimap< float, int > JetCoreClusterSplitter::secondDistScore ( const std::vector< std::vector< float >> &  distanceMap)
private

Definition at line 286 of file JetCoreClusterSplitter.cc.

References closestClusters(), ztail::d, and dqmiolumiharvest::j.

Referenced by fittingSplit().

286  {
287  std::multimap<float, int> scores;
288  for (unsigned int j = 0; j < distanceMap.size(); j++) {
289  std::pair<float, float> d = closestClusters(distanceMap[j]);
290  scores.insert(std::pair<float, int>(-d.second, j));
291  }
292  return scores;
293 }
d
Definition: ztail.py:151
std::pair< float, float > closestClusters(const std::vector< float > &distanceMap)

◆ split()

bool JetCoreClusterSplitter::split ( const SiPixelCluster aCluster,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  filler,
float  expectedADC,
int  sizeY,
int  sizeX,
float  jetZOverRho 
)
private

Definition at line 237 of file JetCoreClusterSplitter.cc.

References SiPixelCluster::charge(), GetRecoTauVFromDQM_MC_cff::cl2, trigObjTnPSource_cfi::filler, fittingSplit(), mps_fire::i, SiPixelCluster::minPixelRow(), RecoTauValidation_cfi::sizeX, and RecoTauValidation_cfi::sizeY.

Referenced by produce().

242  {
243  // This function should test several configuration of splitting, and then
244  // return the one with best chi2
245 
246  std::vector<SiPixelCluster> sp = fittingSplit(
247  aCluster, expectedADC, sizeY, sizeX, jetZOverRho, std::floor(aCluster.charge() / expectedADC + 0.5f));
248 
249  // for the config with best chi2
250  for (unsigned int i = 0; i < sp.size(); i++) {
251  filler.push_back(sp[i]);
252  std::push_heap(filler.begin(), filler.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
253  return cl1.minPixelRow() < cl2.minPixelRow();
254  });
255  }
256 
257  return (!sp.empty());
258 }
int minPixelRow() const
int charge() const
std::vector< SiPixelCluster > fittingSplit(const SiPixelCluster &aCluster, float expectedADC, int sizeY, int sizeX, float jetZOverRho, unsigned int nSplitted)
Pixel cluster – collection of neighboring pixels above threshold.

Member Data Documentation

◆ centralMIPCharge_

double JetCoreClusterSplitter::centralMIPCharge_
private

Definition at line 76 of file JetCoreClusterSplitter.cc.

Referenced by fittingSplit(), and produce().

◆ chargeFracMin_

double JetCoreClusterSplitter::chargeFracMin_
private

Definition at line 63 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ chargePerUnit_

double JetCoreClusterSplitter::chargePerUnit_
private

Definition at line 75 of file JetCoreClusterSplitter.cc.

Referenced by fittingSplit().

◆ cores_

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

Definition at line 71 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ deltaR_

double JetCoreClusterSplitter::deltaR_
private

Definition at line 62 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ expSizeXAtLorentzAngleIncidence_

float JetCoreClusterSplitter::expSizeXAtLorentzAngleIncidence_
private

Definition at line 64 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ expSizeXDeltaPerTanAlpha_

float JetCoreClusterSplitter::expSizeXDeltaPerTanAlpha_
private

Definition at line 65 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ expSizeYAtNormalIncidence_

float JetCoreClusterSplitter::expSizeYAtNormalIncidence_
private

Definition at line 66 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ forceXError_

double JetCoreClusterSplitter::forceXError_
private

Definition at line 72 of file JetCoreClusterSplitter.cc.

Referenced by fittingSplit().

◆ forceYError_

double JetCoreClusterSplitter::forceYError_
private

Definition at line 73 of file JetCoreClusterSplitter.cc.

Referenced by fittingSplit().

◆ fractionalWidth_

double JetCoreClusterSplitter::fractionalWidth_
private

Definition at line 74 of file JetCoreClusterSplitter.cc.

Referenced by fittingSplit().

◆ pixelClusters_

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

Definition at line 69 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ ptMin_

double JetCoreClusterSplitter::ptMin_
private

Definition at line 61 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ tanLorentzAngle_

float JetCoreClusterSplitter::tanLorentzAngle_
private

Definition at line 67 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ tanLorentzAngleBarrelLayer1_

float JetCoreClusterSplitter::tanLorentzAngleBarrelLayer1_
private

Definition at line 68 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ tCPE_

edm::ESGetToken<PixelClusterParameterEstimator, TkPixelCPERecord> const JetCoreClusterSplitter::tCPE_
private

Definition at line 57 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ tTrackerTopo_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> const JetCoreClusterSplitter::tTrackerTopo_
private

Definition at line 58 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ tTrackingGeom_

edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> const JetCoreClusterSplitter::tTrackingGeom_
private

Definition at line 56 of file JetCoreClusterSplitter.cc.

Referenced by produce().

◆ verbose

bool JetCoreClusterSplitter::verbose
private

Definition at line 60 of file JetCoreClusterSplitter.cc.

Referenced by fittingSplit(), and produce().

◆ vertices_

edm::EDGetTokenT<reco::VertexCollection> JetCoreClusterSplitter::vertices_
private

Definition at line 70 of file JetCoreClusterSplitter.cc.

Referenced by produce().