CMS 3D CMS Logo

Typedefs | Functions
deDxTools Namespace Reference

Typedefs

using ESGetTokenH3DDVariant = std::variant< edm::ESGetToken< H3DD, SiStripDeDxMip_3D_Rcd >, edm::ESGetToken< H3DD, SiStripDeDxPion_3D_Rcd >, edm::ESGetToken< H3DD, SiStripDeDxKaon_3D_Rcd >, edm::ESGetToken< H3DD, SiStripDeDxProton_3D_Rcd >, edm::ESGetToken< H3DD, SiStripDeDxElectron_3D_Rcd > >
 
using H3DD = PhysicsTools::Calibration::HistogramD3D
 

Functions

void buildDiscrimMap (PhysicsTools::Calibration::HistogramD3D const &, std::string const &ProbabilityMode, TH3F *&Prob_ChargePath)
 
ESGetTokenH3DDVariant esConsumes (std::string const &Record, edm::ConsumesCollector &)
 
int getCharge (const SiStripCluster *cluster, int &nSatStrip, const GeomDetUnit &detUnit, const std::vector< std::vector< float >> &calibGains, const unsigned int &m_off)
 
int getCharge (const SiStripCluster *cluster, int &nSatStrip, const GeomDetUnit &detUnit, const std::vector< std::vector< float > > &calibGains, const unsigned int &offsetDU_)
 
PhysicsTools::Calibration::HistogramD3D const & getHistogramD3D (edm::EventSetup const &, ESGetTokenH3DDVariant const &)
 
bool isFarFromBorder (const TrajectoryStateOnSurface &trajState, const GeomDetUnit *it)
 
bool isSpanningOver2APV (unsigned int FirstStrip, unsigned int ClusterSize)
 
void makeCalibrationMap (const std::string &m_calibrationPath, const TrackerGeometry &tkGeom, std::vector< std::vector< float >> &calibGains, const unsigned int &m_off)
 
void makeCalibrationMap (const std::string &m_calibrationPath, const TrackerGeometry &tkGeom, std::vector< std::vector< float > > &calibGains, const unsigned int &offsetDU_)
 
bool shapeSelection (const SiStripCluster &ampls)
 

Typedef Documentation

◆ ESGetTokenH3DDVariant

Definition at line 58 of file DeDxTools.h.

◆ H3DD

Definition at line 53 of file DeDxTools.h.

Function Documentation

◆ buildDiscrimMap()

void deDxTools::buildDiscrimMap ( PhysicsTools::Calibration::HistogramD3D const &  deDxMap,
std::string const &  ProbabilityMode,
TH3F *&  Prob_ChargePath 
)

Definition at line 319 of file DeDxTools.cc.

References PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >::binContent(), Exception, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, MainPageGenerator::l, PhysicsTools::Calibration::Range< Axis_t >::max, PhysicsTools::Calibration::Range< Axis_t >::min, PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >::numberOfBinsX(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >::numberOfBinsY(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >::numberOfBinsZ(), HLT_2024v10_cff::ProbabilityMode, PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >::rangeX(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >::rangeY(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >::rangeZ(), createJobs::tmp, TrackerOfflineValidation_Dqm_cff::xmax, TrackerOfflineValidation_Dqm_cff::xmin, L1TOccupancyClient_cfi::ymax, L1TOccupancyClient_cfi::ymin, SiStripMonitorCluster_cfi::zmax, and SiStripMonitorCluster_cfi::zmin.

Referenced by ASmirnovDeDxDiscriminator::beginRun(), SmirnovDeDxDiscriminator::beginRun(), ProductDeDxDiscriminator::beginRun(), and BTagLikeDeDxDiscriminator::beginRun().

321  {
322  float xmin = deDxMap.rangeX().min;
323  float xmax = deDxMap.rangeX().max;
324  float ymin = deDxMap.rangeY().min;
325  float ymax = deDxMap.rangeY().max;
326  float zmin = deDxMap.rangeZ().min;
327  float zmax = deDxMap.rangeZ().max;
328 
329  if (Prob_ChargePath)
330  delete Prob_ChargePath;
331  Prob_ChargePath = new TH3F("Prob_ChargePath",
332  "Prob_ChargePath",
333  deDxMap.numberOfBinsX(),
334  xmin,
335  xmax,
336  deDxMap.numberOfBinsY(),
337  ymin,
338  ymax,
339  deDxMap.numberOfBinsZ(),
340  zmin,
341  zmax);
342 
343  if (strcmp(ProbabilityMode.c_str(), "Accumulation") == 0) {
344  for (int i = 0; i <= Prob_ChargePath->GetXaxis()->GetNbins() + 1; i++) {
345  for (int j = 0; j <= Prob_ChargePath->GetYaxis()->GetNbins() + 1; j++) {
346  float Ni = 0;
347  for (int k = 0; k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1; k++) {
348  Ni += deDxMap.binContent(i, j, k);
349  }
350  for (int k = 0; k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1; k++) {
351  float tmp = 0;
352  for (int l = 0; l <= k; l++) {
353  tmp += deDxMap.binContent(i, j, l);
354  }
355  if (Ni > 0) {
356  Prob_ChargePath->SetBinContent(i, j, k, tmp / Ni);
357  } else {
358  Prob_ChargePath->SetBinContent(i, j, k, 0);
359  }
360  }
361  }
362  }
363  } else if (strcmp(ProbabilityMode.c_str(), "Integral") == 0) {
364  for (int i = 0; i <= Prob_ChargePath->GetXaxis()->GetNbins() + 1; i++) {
365  for (int j = 0; j <= Prob_ChargePath->GetYaxis()->GetNbins() + 1; j++) {
366  float Ni = 0;
367  for (int k = 0; k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1; k++) {
368  Ni += deDxMap.binContent(i, j, k);
369  }
370  for (int k = 0; k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1; k++) {
371  float tmp = deDxMap.binContent(i, j, k);
372  if (Ni > 0) {
373  Prob_ChargePath->SetBinContent(i, j, k, tmp / Ni);
374  } else {
375  Prob_ChargePath->SetBinContent(i, j, k, 0);
376  }
377  }
378  }
379  }
380  } else {
381  throw cms::Exception("WrongConfig for dEdx") << "The ProbabilityMode: " << ProbabilityMode << "is unknown\n";
382  }
383  }
tmp
align.sh
Definition: createJobs.py:716

◆ esConsumes()

ESGetTokenH3DDVariant deDxTools::esConsumes ( std::string const &  Record,
edm::ConsumesCollector iCC 
)

Definition at line 283 of file DeDxTools.cc.

References edm::BeginRun, edm::ConsumesCollector::esConsumes(), and Exception.

Referenced by BDHadronTrackMonitoringAnalyzer::BDHadronTrackMonitoringAnalyzer(), BeamHaloAnalyzer::BeamHaloAnalyzer(), CalibratedElectronProducerRun2T< T >::CalibratedElectronProducerRun2T(), cms::ClusterMTCCFilter::ClusterMTCCFilter(), ConversionTrackProducer::ConversionTrackProducer(), DAFTrackProducer::DAFTrackProducer(), DQMSourcePi0::DQMSourcePi0(), DTClusterer::DTClusterer(), DTRunConditionVar::DTRunConditionVar(), DTTTrigCalibration::DTTTrigCalibration(), EgammaHLTNxNClusterProducer::EgammaHLTNxNClusterProducer(), EgammaSCCorrectionMaker::EgammaSCCorrectionMaker(), ElectronHEEPIDValueMapProducer::ElectronHEEPIDValueMapProducer(), ESTimingTask::ESTimingTask(), HLTRechitInRegionsProducer< T1 >::eventSetupConsumes(), EvtPlaneProducer::EvtPlaneProducer(), ExoticaDQM::ExoticaDQM(), FastSimProducer::FastSimProducer(), FFTJetProducer::FFTJetProducer(), FixedGridRhoProducerFastjetFromRecHit::FixedGridRhoProducerFastjetFromRecHit(), pat::GenPlusSimParticleProducer::GenPlusSimParticleProducer(), GlobalDigisAnalyzer::GlobalDigisAnalyzer(), GsfTrackRefitter::GsfTrackRefitter(), HBHEIsolatedNoiseReflagger::HBHEIsolatedNoiseReflagger(), HcalRawToDigiGPU::HcalRawToDigiGPU(), HFEMClusterProducer::HFEMClusterProducer(), HiEvtPlaneFlatProducer::HiEvtPlaneFlatProducer(), HIMultiTrackSelector::HIMultiTrackSelector(), HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >::HLTCaloObjInRegionsProducer(), HLTRecHitInAllL1RegionsProducer< RecHitType >::HLTRecHitInAllL1RegionsProducer(), pat::JetCorrFactorsProducer::JetCorrFactorsProducer(), JetSignalVertexCompatibility::JetSignalVertexCompatibility(), L1TMuonBarrelKalmanParamsViewer::L1TMuonBarrelKalmanParamsViewer(), L1TMuonBarrelParamsViewer::L1TMuonBarrelParamsViewer(), L1TMuonEndCapParamsViewer::L1TMuonEndCapParamsViewer(), L1TMuonGlobalParamsViewer::L1TMuonGlobalParamsViewer(), L1TMuonLegacyConverter::L1TMuonLegacyConverter(), L1TMuonOverlapParamsViewer::L1TMuonOverlapParamsViewer(), L1TRPCTPG::L1TRPCTPG(), L1TTauOffline::L1TTauOffline(), MeasurementTrackerEventProducer::MeasurementTrackerEventProducer(), cms::METSignificanceProducer::METSignificanceProducer(), MuonIdProducer::MuonIdProducer(), MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::MuRecObjBaseProducer(), NuclearTrackCorrector::NuclearTrackCorrector(), pat::PATMETProducer::PATMETProducer(), pat::PATMuonProducer::PATMuonProducer(), reco::tau::PATTauDiscriminationByMVAIsolationRun2::PATTauDiscriminationByMVAIsolationRun2(), pat::PATTriggerEventProducer::PATTriggerEventProducer(), pat::PATTriggerProducer::PATTriggerProducer(), cms::PFMETProducer::PFMETProducer(), ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitSoAProducer< CAL >::PFRecHitSoAProducer(), PFRecoTauDiscriminationByIsolationMVA2::PFRecoTauDiscriminationByIsolationMVA2(), reco::tau::PFRecoTauDiscriminationByMVAIsolationRun2::PFRecoTauDiscriminationByMVAIsolationRun2(), PFSimParticleProducer::PFSimParticleProducer(), PhysicsObjectsMonitor::PhysicsObjectsMonitor(), PileupJetIdProducer::PileupJetIdProducer(), PiZeroAnalyzer::PiZeroAnalyzer(), RegressionEnergyPatElectronProducer::RegressionEnergyPatElectronProducer(), RPCChamberMasker::RPCChamberMasker(), RPCDigiValid::RPCDigiValid(), RPCPointVsRecHit::RPCPointVsRecHit(), RPCRecHitValid::RPCRecHitValid(), RPDigiProducer::RPDigiProducer(), ShiftedJetProducerT< T, Textractor >::ShiftedJetProducerT(), ShiftedPFCandidateProducerForNoPileUpPFMEt::ShiftedPFCandidateProducerForNoPileUpPFMEt(), ShiftedPFCandidateProducerForPFNoPUMEt::ShiftedPFCandidateProducerForPFNoPUMEt(), SiStripClusters2ApproxClusters::SiStripClusters2ApproxClusters(), SiStripClusterToDigiProducer::SiStripClusterToDigiProducer(), SiStripMonitorApproximateCluster::SiStripMonitorApproximateCluster(), SmearedJetProducerT< T >::SmearedJetProducerT(), TauDiscriminantCutMultiplexerT< TauType, TauTypeRef, ParentClass >::TauDiscriminantCutMultiplexerT(), pat::TauJetCorrFactorsProducer::TauJetCorrFactorsProducer(), TSGFromL2Muon::TSGFromL2Muon(), TTClusterAssociator< T >::TTClusterAssociator(), TTClusterBuilder< T >::TTClusterBuilder(), TTStubAssociator< T >::TTStubAssociator(), and VirtualJetProducer::VirtualJetProducer().

283  {
284  if (Record == "SiStripDeDxMip_3D_Rcd") {
286  }
287  if (Record == "SiStripDeDxPion_3D_Rcd") {
289  }
290  if (Record == "SiStripDeDxKaon_3D_Rcd") {
292  }
293  if (Record == "SiStripDeDxProton_3D_Rcd") {
295  }
296  if (Record == "SiStripDeDxElectron_3D_Rcd") {
298  }
299  throw cms::Exception("WrongRecord for dEdx") << "The record : " << Record << "is unknown\n";
300  }
PhysicsTools::Calibration::HistogramD3D H3DD
Definition: DeDxTools.h:53

◆ getCharge() [1/2]

int deDxTools::getCharge ( const SiStripCluster cluster,
int &  nSatStrip,
const GeomDetUnit detUnit,
const std::vector< std::vector< float >> &  calibGains,
const unsigned int &  m_off 
)

◆ getCharge() [2/2]

int deDxTools::getCharge ( const SiStripCluster cluster,
int &  nSatStrip,
const GeomDetUnit detUnit,
const std::vector< std::vector< float > > &  calibGains,
const unsigned int &  offsetDU_ 
)

Definition at line 217 of file DeDxTools.cc.

References SiStripCluster::amplitudes(), ALCARECOTkAlJpsiMuMu_cff::charge, SiStripCluster::firstStrip(), ecalph2::gains, mps_fire::i, GeomDet::index(), and createfilelist::int.

221  {
222  const auto& Ampls = cluster->amplitudes();
223 
224  nSatStrip = 0;
225  int charge = 0;
226 
227  if (calibGains.empty()) {
228  for (unsigned int i = 0; i < Ampls.size(); i++) {
229  int calibratedCharge = Ampls[i];
230  charge += calibratedCharge;
231  if (calibratedCharge >= 254)
232  nSatStrip++;
233  }
234  } else {
235  for (unsigned int i = 0; i < Ampls.size(); i++) {
236  int calibratedCharge = Ampls[i];
237 
238  auto& gains = calibGains[detUnit.index() - offsetDU_];
239  calibratedCharge = (int)(calibratedCharge / gains[(cluster->firstStrip() + i) / 128]);
240  if (calibratedCharge >= 255) {
241  if (calibratedCharge >= 1025)
242  calibratedCharge = 255;
243  else
244  calibratedCharge = 254;
245  }
246 
247  charge += calibratedCharge;
248  if (calibratedCharge >= 254)
249  nSatStrip++;
250  }
251  }
252  return charge;
253  }
uint16_t firstStrip() const
int index() const
Definition: GeomDet.h:83
SiStripCluster const & amplitudes() const
constexpr float gains[NGAINS]
Definition: EcalConstants.h:20

◆ getHistogramD3D()

PhysicsTools::Calibration::HistogramD3D const & deDxTools::getHistogramD3D ( edm::EventSetup const &  iES,
ESGetTokenH3DDVariant const &  iToken 
)

Definition at line 302 of file DeDxTools.cc.

References Exception, and edm::EventSetup::getData().

Referenced by ASmirnovDeDxDiscriminator::beginRun(), SmirnovDeDxDiscriminator::beginRun(), ProductDeDxDiscriminator::beginRun(), and BTagLikeDeDxDiscriminator::beginRun().

303  {
304  switch (iToken.index()) {
305  case 0:
306  return iES.getData(std::get<0>(iToken));
307  case 1:
308  return iES.getData(std::get<1>(iToken));
309  case 2:
310  return iES.getData(std::get<2>(iToken));
311  case 3:
312  return iES.getData(std::get<3>(iToken));
313  case 4:
314  return iES.getData(std::get<4>(iToken));
315  }
316  throw cms::Exception("HistogramD3DTokenUnset");
317  }

◆ isFarFromBorder()

bool deDxTools::isFarFromBorder ( const TrajectoryStateOnSurface trajState,
const GeomDetUnit it 
)

Definition at line 426 of file DeDxTools.cc.

References ProducerSetup_cfi::HalfLength, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localPosition(), LocalTrajectoryError::positionError(), and LocalError::yy().

Referenced by SiStripGainsPCLWorker::dqmAnalyze(), SiStripGainCalibTableProducer::fillTable(), and DeDxDiscriminatorLearner::processHit().

426  {
427  if (dynamic_cast<const StripGeomDetUnit*>(it) == nullptr && dynamic_cast<const PixelGeomDetUnit*>(it) == nullptr) {
428  edm::LogInfo("deDxTools") << "this detID doesn't seem to belong to the Tracker" << std::endl;
429  return false;
430  }
431 
432  LocalPoint HitLocalPos = trajState.localPosition();
433  LocalError HitLocalError = trajState.localError().positionError();
434 
435  const BoundPlane plane = it->surface();
436  const TrapezoidalPlaneBounds* trapezoidalBounds(dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
437  const RectangularPlaneBounds* rectangularBounds(dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
438 
439  if (!trapezoidalBounds && !rectangularBounds)
440  return false;
441 
442  double DistFromBorder = 1.0;
443  double HalfLength =
444  trapezoidalBounds ? (*trapezoidalBounds).parameters()[3] : it->surface().bounds().length() / 2.0;
445 
446  if (fabs(HitLocalPos.y()) + HitLocalError.yy() >= (HalfLength - DistFromBorder))
447  return false;
448 
449  return true;
450  }
const LocalTrajectoryError & localError() const
LocalError positionError() const
float yy() const
Definition: LocalError.h:24
T y() const
Definition: PV3DBase.h:60
Log< level::Info, false > LogInfo

◆ isSpanningOver2APV()

bool deDxTools::isSpanningOver2APV ( unsigned int  FirstStrip,
unsigned int  ClusterSize 
)

Definition at line 385 of file DeDxTools.cc.

References PixelTestBeamValidation_cfi::ClusterSize.

Referenced by DeDxDiscriminatorLearner::processHit().

385  {
386  if (FirstStrip == 0)
387  return true;
388  if (FirstStrip == 128)
389  return true;
390  if (FirstStrip == 256)
391  return true;
392  if (FirstStrip == 384)
393  return true;
394  if (FirstStrip == 512)
395  return true;
396  if (FirstStrip == 640)
397  return true;
398 
399  if (FirstStrip <= 127 && FirstStrip + ClusterSize > 127)
400  return true;
401  if (FirstStrip <= 255 && FirstStrip + ClusterSize > 255)
402  return true;
403  if (FirstStrip <= 383 && FirstStrip + ClusterSize > 383)
404  return true;
405  if (FirstStrip <= 511 && FirstStrip + ClusterSize > 511)
406  return true;
407  if (FirstStrip <= 639 && FirstStrip + ClusterSize > 639)
408  return true;
409 
410  if (FirstStrip + ClusterSize == 127)
411  return true;
412  if (FirstStrip + ClusterSize == 255)
413  return true;
414  if (FirstStrip + ClusterSize == 383)
415  return true;
416  if (FirstStrip + ClusterSize == 511)
417  return true;
418  if (FirstStrip + ClusterSize == 639)
419  return true;
420  if (FirstStrip + ClusterSize == 767)
421  return true;
422 
423  return false;
424  }

◆ makeCalibrationMap() [1/2]

void deDxTools::makeCalibrationMap ( const std::string &  m_calibrationPath,
const TrackerGeometry tkGeom,
std::vector< std::vector< float >> &  calibGains,
const unsigned int &  m_off 
)

◆ makeCalibrationMap() [2/2]

void deDxTools::makeCalibrationMap ( const std::string &  m_calibrationPath,
const TrackerGeometry tkGeom,
std::vector< std::vector< float > > &  calibGains,
const unsigned int &  offsetDU_ 
)

Definition at line 255 of file DeDxTools.cc.

References TrackerGeometry::detUnits(), ecalph2::gains, TrackerGeometry::idToDetUnit(), GeomDet::index(), and RandomServiceHelper::t1.

258  {
259  auto const& dus = tkGeom.detUnits();
260  calibGains.resize(dus.size() - offsetDU_);
261 
262  TChain* t1 = new TChain("SiStripCalib/APVGain");
263  t1->Add(m_calibrationPath.c_str());
264 
265  unsigned int tree_DetId;
266  unsigned char tree_APVId;
267  double tree_Gain;
268  t1->SetBranchAddress("DetId", &tree_DetId);
269  t1->SetBranchAddress("APVId", &tree_APVId);
270  t1->SetBranchAddress("Gain", &tree_Gain);
271 
272  for (unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
273  t1->GetEntry(ientry);
274  auto& gains = calibGains[tkGeom.idToDetUnit(DetId(tree_DetId))->index() - offsetDU_];
275  if (gains.size() < (size_t)(tree_APVId + 1)) {
276  gains.resize(tree_APVId + 1);
277  }
278  gains[tree_APVId] = tree_Gain;
279  }
280  t1->Delete();
281  }
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
int index() const
Definition: GeomDet.h:83
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
constexpr float gains[NGAINS]
Definition: EcalConstants.h:20
Definition: DetId.h:17

◆ shapeSelection()

bool deDxTools::shapeSelection ( const SiStripCluster ampls)

Definition at line 13 of file DeDxTools.cc.

References SiStripCluster::amplitudes(), mps_fire::i, createfilelist::int, hgchebackDigitizer_cfi::noise, and mitigatedMETSequence_cff::U.

Referenced by pat::PATIsolatedTrackProducer::getDeDx(), DeDxDiscriminatorLearner::processHit(), DeDxEstimatorProducer::processHit(), and DeDxHitInfoProducer::produce().

13  {
14  // ---------------- Counting the number of maxima --------------------------
15  //----------------------------------------------------------------------------
16  auto const& ampls = clus.amplitudes();
17  Int_t NofMax = 0;
18  Int_t recur255 = 1;
19  Int_t recur254 = 1;
20  bool MaxOnStart = false;
21  bool MaxInMiddle = false, MaxOnEnd = false;
22  Int_t MaxPos = 0;
23 
24  // Start with max
25  if (ampls.size() != 1 &&
26  ((ampls[0] > ampls[1]) ||
27  (ampls.size() > 2 && ampls[0] == ampls[1] && ampls[1] > ampls[2] && ampls[0] != 254 && ampls[0] != 255) ||
28  (ampls.size() == 2 && ampls[0] == ampls[1] && ampls[0] != 254 && ampls[0] != 255))) {
29  NofMax = NofMax + 1;
30  MaxOnStart = true;
31  }
32 
33  // Maximum reached
34  if (ampls.size() > 2) {
35  for (unsigned int i = 1; i < ampls.size() - 1U; i++) {
36  if ((ampls[i] > ampls[i - 1] && ampls[i] > ampls[i + 1]) ||
37  (ampls.size() > 3 && i > 0 && i < ampls.size() - 2U && ampls[i] == ampls[i + 1] &&
38  ampls[i] > ampls[i - 1] && ampls[i] > ampls[i + 2] && ampls[i] != 254 && ampls[i] != 255)) {
39  NofMax = NofMax + 1;
40  MaxInMiddle = true;
41  MaxPos = i;
42  }
43  if (ampls[i] == 255 && ampls[i] == ampls[i - 1]) {
44  recur255 = recur255 + 1;
45  MaxPos = i - (recur255 / 2);
46  if (ampls[i] > ampls[i + 1]) {
47  NofMax = NofMax + 1;
48  MaxInMiddle = true;
49  }
50  }
51  if (ampls[i] == 254 && ampls[i] == ampls[i - 1]) {
52  recur254 = recur254 + 1;
53  MaxPos = i - (recur254 / 2);
54  if (ampls[i] > ampls[i + 1]) {
55  NofMax = NofMax + 1;
56  MaxInMiddle = true;
57  }
58  }
59  }
60  }
61 
62  // End with a max
63  if (ampls.size() > 1) {
64  if (ampls[ampls.size() - 1] > ampls[ampls.size() - 2] ||
65  (ampls.size() > 2 && ampls[ampls.size() - 1] == ampls[ampls.size() - 2] &&
66  ampls[ampls.size() - 2] > ampls[ampls.size() - 3]) ||
67  ampls[ampls.size() - 1] == 255) {
68  NofMax = NofMax + 1;
69  MaxOnEnd = true;
70  }
71  }
72 
73  // If only one strip touched
74  if (ampls.size() == 1) {
75  NofMax = 1;
76  }
77 
78  // -------------- SHAPE-BASED SELECTION FOR UNIQUE MAXIMAS --------------
79  //------------------------------------------------------------------------
80  /*
81  ____
82  | |____
83  ____| | |
84  | | | |____
85  ____| | | | |
86  | | | | | |____
87  __|____|____|____|____|____|____|__
88  C_Mnn C_Mn C_M C_D C_Dn C_Dnn
89  */
90  bool shapecdtn = false;
91 
92  Float_t C_M = 0.0;
93  Float_t C_D = 0.0;
94  Float_t C_Mn = 10000;
95  Float_t C_Dn = 10000;
96  Float_t C_Mnn = 10000;
97  Float_t C_Dnn = 10000;
98  Int_t CDPos;
99  Float_t coeff1 = 1.7;
100  Float_t coeff2 = 2.0;
101  Float_t coeffn = 0.10;
102  Float_t coeffnn = 0.02;
103  Float_t noise = 4.0;
104 
105  if (NofMax == 1) {
106  if (MaxOnStart == true) {
107  C_M = (Float_t)ampls[0];
108  C_D = (Float_t)ampls[1];
109  if (ampls.size() < 3)
110  shapecdtn = true;
111  else if (ampls.size() == 3) {
112  C_Dn = (Float_t)ampls[2];
113  if (C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 * noise || C_D == 255)
114  shapecdtn = true;
115  } else if (ampls.size() > 3) {
116  C_Dn = (Float_t)ampls[2];
117  C_Dnn = (Float_t)ampls[3];
118  if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 * noise || C_D == 255) &&
119  C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 * noise) {
120  shapecdtn = true;
121  }
122  }
123  }
124 
125  if (MaxOnEnd == true) {
126  C_M = (Float_t)ampls[ampls.size() - 1];
127  C_D = (Float_t)ampls[ampls.size() - 2];
128  if (ampls.size() < 3)
129  shapecdtn = true;
130  else if (ampls.size() == 3) {
131  C_Dn = (Float_t)ampls[0];
132  if (C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 * noise || C_D == 255)
133  shapecdtn = true;
134  } else if (ampls.size() > 3) {
135  C_Dn = (Float_t)ampls[ampls.size() - 3];
136  C_Dnn = (Float_t)ampls[ampls.size() - 4];
137  if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 * noise || C_D == 255) &&
138  C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 * noise) {
139  shapecdtn = true;
140  }
141  }
142  }
143 
144  if (MaxInMiddle == true) {
145  C_M = (Float_t)ampls[MaxPos];
146  int LeftOfMaxPos = MaxPos - 1;
147  if (LeftOfMaxPos <= 0)
148  LeftOfMaxPos = 0;
149  int RightOfMaxPos = MaxPos + 1;
150  if (RightOfMaxPos >= (int)ampls.size())
151  RightOfMaxPos = ampls.size() - 1;
152  if (ampls[LeftOfMaxPos] < ampls[RightOfMaxPos]) {
153  C_D = (Float_t)ampls[RightOfMaxPos];
154  C_Mn = (Float_t)ampls[LeftOfMaxPos];
155  CDPos = RightOfMaxPos;
156  } else {
157  C_D = (Float_t)ampls[LeftOfMaxPos];
158  C_Mn = (Float_t)ampls[RightOfMaxPos];
159  CDPos = LeftOfMaxPos;
160  }
161  if (C_Mn < coeff1 * coeffn * C_M + coeff2 * coeffnn * C_D + 2 * noise || C_M == 255) {
162  if (ampls.size() == 3)
163  shapecdtn = true;
164  else if (ampls.size() > 3) {
165  if (CDPos > MaxPos) {
166  if (ampls.size() - CDPos - 1 == 0) {
167  C_Dn = 0;
168  C_Dnn = 0;
169  }
170  if (ampls.size() - CDPos - 1 == 1) {
171  C_Dn = (Float_t)ampls[CDPos + 1];
172  C_Dnn = 0;
173  }
174  if (ampls.size() - CDPos - 1 > 1) {
175  C_Dn = (Float_t)ampls[CDPos + 1];
176  C_Dnn = (Float_t)ampls[CDPos + 2];
177  }
178  if (MaxPos >= 2) {
179  C_Mnn = (Float_t)ampls[MaxPos - 2];
180  } else if (MaxPos < 2)
181  C_Mnn = 0;
182  }
183  if (CDPos < MaxPos) {
184  if (CDPos == 0) {
185  C_Dn = 0;
186  C_Dnn = 0;
187  }
188  if (CDPos == 1) {
189  C_Dn = (Float_t)ampls[0];
190  C_Dnn = 0;
191  }
192  if (CDPos > 1) {
193  C_Dn = (Float_t)ampls[CDPos - 1];
194  C_Dnn = (Float_t)ampls[CDPos - 2];
195  }
196  if (ampls.size() - LeftOfMaxPos > 1 && MaxPos + 2 < (int)(ampls.size()) - 1) {
197  C_Mnn = (Float_t)ampls[MaxPos + 2];
198  } else
199  C_Mnn = 0;
200  }
201  if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 * noise || C_D == 255) &&
202  C_Mnn <= coeff1 * coeffn * C_Mn + coeff2 * coeffnn * C_M + 2 * noise &&
203  C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 * noise) {
204  shapecdtn = true;
205  }
206  }
207  }
208  }
209  }
210  if (ampls.size() == 1) {
211  shapecdtn = true;
212  }
213 
214  return shapecdtn;
215  }
SiStripCluster const & amplitudes() const
auto size() const