CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Protected Attributes | Private Attributes
PFHFRecHitCreator Class Referencefinal

#include <PFHFRecHitCreator.h>

Inheritance diagram for PFHFRecHitCreator:
PFRecHitCreatorBase

Classes

class  DetIDSorter
 

Public Member Functions

void importRecHits (std::unique_ptr< reco::PFRecHitCollection > &out, std::unique_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 PFHFRecHitCreator (const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
 
- Public Member Functions inherited from PFRecHitCreatorBase
virtual void init (const edm::EventSetup &es)
 
 PFRecHitCreatorBase ()
 
 PFRecHitCreatorBase (const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
 
virtual ~PFRecHitCreatorBase ()=default
 

Protected Attributes

double EM_Depth_
 
double HAD_Depth_
 
double HFCalib_
 
double longFibre_Cut
 
double longFibre_Fraction
 
edm::EDGetTokenT< edm::SortedCollection< HFRecHit > > recHitToken_
 
double shortFibre_Cut
 
double shortFibre_Fraction
 
double thresh_HF_
 
- Protected Attributes inherited from PFRecHitCreatorBase
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
 

Private Attributes

edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeomToken_
 

Additional Inherited Members

- Protected Member Functions inherited from PFRecHitCreatorBase
void beginEvent (const edm::Event &event, const edm::EventSetup &setup)
 

Detailed Description

Definition at line 21 of file PFHFRecHitCreator.h.

Constructor & Destructor Documentation

◆ PFHFRecHitCreator()

PFHFRecHitCreator::PFHFRecHitCreator ( const edm::ParameterSet iConfig,
edm::ConsumesCollector cc 
)
inline

Definition at line 23 of file PFHFRecHitCreator.h.

24  : PFRecHitCreatorBase(iConfig, cc),
26  EM_Depth_(iConfig.getParameter<double>("EMDepthCorrection")),
27  HAD_Depth_(iConfig.getParameter<double>("HADDepthCorrection")),
28  shortFibre_Cut(iConfig.getParameter<double>("ShortFibre_Cut")),
29  longFibre_Fraction(iConfig.getParameter<double>("LongFibre_Fraction")),
30  longFibre_Cut(iConfig.getParameter<double>("LongFibre_Cut")),
31  shortFibre_Fraction(iConfig.getParameter<double>("ShortFibre_Fraction")),
32  thresh_HF_(iConfig.getParameter<double>("thresh_HF")),
33  HFCalib_(iConfig.getParameter<double>("HFCalib29")),
34  geomToken_(cc.esConsumes()) {}
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::SortedCollection< HFRecHit > > recHitToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_

Member Function Documentation

◆ importRecHits()

void PFHFRecHitCreator::importRecHits ( std::unique_ptr< reco::PFRecHitCollection > &  out,
std::unique_ptr< reco::PFRecHitCollection > &  cleaned,
const edm::Event iEvent,
const edm::EventSetup iSetup 
)
inlineoverridevirtual

Implements PFRecHitCreatorBase.

Definition at line 36 of file PFHFRecHitCreator.h.

References a, funct::abs(), cms::cuda::assert(), b, PFRecHitCreatorBase::beginEvent(), runTheMatrix::const, LEDCalibrationChannels::depth, HcalDetId::depth(), HCALHighEnergyHPDFilter_cfi::energy, geomToken_, CaloSubdetectorGeometry::getGeometry(), edm::EventSetup::getHandle(), CaloGeometry::getSubdetectorGeometry(), DetId::Hcal, HcalForward, PFLayer::HF_EM, PFLayer::HF_HAD, HFCalib_, HcalDetId::ieta(), iEvent, HcalDetId::iphi(), runTheMatrix::keep, phase1PixelTopology::layer, longFibre_Cut, longFibre_Fraction, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, eostools::move(), MillePedeFileConverter_cfg::out, PFRecHitCreatorBase::qualityTests_, DetId::rawId(), recHitToken_, reco::PFRecHit::setEnergy(), reco::PFRecHit::setTime(), shortFibre_Cut, shortFibre_Fraction, jetsAK4_CHS_cff::sort, l1ctLayer2EG_cff::sorter, thresh_HF_, and protons_cff::time.

39  {
41 
42  beginEvent(iEvent, iSetup);
43 
45 
47 
48  // get the ecal geometry
50 
51  iEvent.getByToken(recHitToken_, recHitHandle);
52  for (const auto& erh : *recHitHandle) {
53  const HcalDetId& detid = (HcalDetId)erh.detid();
54  auto depth = detid.depth();
55 
56  // ATTN: skip dual anode in HF for now (should be fixed in upstream changes)
57  if (depth > 2)
58  continue;
59 
60  auto energy = erh.energy();
61  auto time = erh.time();
62 
63  std::shared_ptr<const CaloCellGeometry> thisCell = hcalGeo->getGeometry(detid);
64  auto zp = dynamic_cast<IdealZPrism const*>(thisCell.get());
65  assert(zp);
66  thisCell = zp->forPF();
67 
68  // find rechit geometry
69  if (!thisCell) {
70  edm::LogError("PFHFRecHitCreator")
71  << "warning detid " << detid.rawId() << " not found in geometry" << std::endl;
72  continue;
73  }
74 
76 
77  reco::PFRecHit rh(thisCell, detid.rawId(), layer, energy);
78  rh.setTime(time);
79  rh.setDepth(depth);
80 
81  bool rcleaned = false;
82  bool keep = true;
83 
84  //Apply Q tests
85  for (const auto& qtest : qualityTests_) {
86  if (!qtest->test(rh, erh, rcleaned)) {
87  keep = false;
88  }
89  }
90 
91  if (keep) {
92  tmpOut.push_back(std::move(rh));
93  } else if (rcleaned)
94  cleaned->push_back(std::move(rh));
95  }
96  //Sort by DetID the collection
97  DetIDSorter sorter;
98  if (!tmpOut.empty())
99  std::sort(tmpOut.begin(), tmpOut.end(), sorter);
100 
102 
103  for (auto& hit : tmpOut) {
104  reco::PFRecHit newHit = hit;
105  const HcalDetId& detid = (HcalDetId)hit.detId();
106  if (detid.depth() == 1) {
107  double lONG = hit.energy();
108  //find the short hit
109  HcalDetId shortID(HcalForward, detid.ieta(), detid.iphi(), 2);
110  auto found_hit =
111  std::lower_bound(tmpOut.begin(), tmpOut.end(), shortID, [](const reco::PFRecHit& a, HcalDetId b) {
112  return a.detId() < b.rawId();
113  });
114  if (found_hit != tmpOut.end() && found_hit->detId() == shortID.rawId()) {
115  double sHORT = found_hit->energy();
116  //Ask for fraction
117  double energy = lONG - sHORT;
118 
119  if (abs(detid.ieta()) <= 32)
120  energy *= HFCalib_;
121  newHit.setEnergy(energy);
122  if (!(lONG > longFibre_Cut && (sHORT / lONG < shortFibre_Fraction)))
123  if (energy > thresh_HF_)
124  out->push_back(newHit);
125  } else {
126  //make only long hit
127  double energy = lONG;
128  if (abs(detid.ieta()) <= 32)
129  energy *= HFCalib_;
130  newHit.setEnergy(energy);
131 
132  if (energy > thresh_HF_)
133  out->push_back(newHit);
134  }
135 
136  } else {
137  double sHORT = hit.energy();
138  HcalDetId longID(HcalForward, detid.ieta(), detid.iphi(), 1);
139  auto found_hit =
140  std::lower_bound(tmpOut.begin(), tmpOut.end(), longID, [](const reco::PFRecHit& a, HcalDetId b) {
141  return a.detId() < b.rawId();
142  });
143  double energy = sHORT;
144  if (found_hit != tmpOut.end() && found_hit->detId() == longID.rawId()) {
145  double lONG = found_hit->energy();
146  //Ask for fraction
147 
148  //If in this case lONG-sHORT<0 add the energy to the sHORT
149  if ((lONG - sHORT) < thresh_HF_)
150  energy += lONG;
151  else
152  energy += sHORT;
153 
154  if (abs(detid.ieta()) <= 32)
155  energy *= HFCalib_;
156 
157  newHit.setEnergy(energy);
158  if (!(sHORT > shortFibre_Cut && (lONG / sHORT < longFibre_Fraction)))
159  if (energy > thresh_HF_)
160  out->push_back(newHit);
161 
162  } else {
163  //only short hit!
164  if (abs(detid.ieta()) <= 32)
165  energy *= HFCalib_;
166  newHit.setEnergy(energy);
167  if (energy > thresh_HF_)
168  out->push_back(newHit);
169  }
170  }
171  }
172  }
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
edm::EDGetTokenT< edm::SortedCollection< HFRecHit > > recHitToken_
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
Log< level::Error, false > LogError
assert(be >=bs)
constexpr std::array< uint8_t, layerIndexSize > layer
int iEvent
Definition: GenABIO.cc:224
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void beginEvent(const edm::Event &event, const edm::EventSetup &setup)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
void setTime(double time)
Definition: PFRecHit.h:73
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Layer
layer definition
Definition: PFLayer.h:29
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
void setEnergy(float energy)
Definition: PFRecHit.h:69
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
def move(src, dest)
Definition: eostools.py:511
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164

Member Data Documentation

◆ EM_Depth_

double PFHFRecHitCreator::EM_Depth_
protected

Definition at line 176 of file PFHFRecHitCreator.h.

◆ geomToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> PFHFRecHitCreator::geomToken_
private

Definition at line 202 of file PFHFRecHitCreator.h.

Referenced by importRecHits().

◆ HAD_Depth_

double PFHFRecHitCreator::HAD_Depth_
protected

Definition at line 177 of file PFHFRecHitCreator.h.

◆ HFCalib_

double PFHFRecHitCreator::HFCalib_
protected

Definition at line 186 of file PFHFRecHitCreator.h.

Referenced by importRecHits().

◆ longFibre_Cut

double PFHFRecHitCreator::longFibre_Cut
protected

Definition at line 183 of file PFHFRecHitCreator.h.

Referenced by importRecHits().

◆ longFibre_Fraction

double PFHFRecHitCreator::longFibre_Fraction
protected

Definition at line 180 of file PFHFRecHitCreator.h.

Referenced by importRecHits().

◆ recHitToken_

edm::EDGetTokenT<edm::SortedCollection<HFRecHit> > PFHFRecHitCreator::recHitToken_
protected

Definition at line 175 of file PFHFRecHitCreator.h.

Referenced by importRecHits().

◆ shortFibre_Cut

double PFHFRecHitCreator::shortFibre_Cut
protected

Definition at line 179 of file PFHFRecHitCreator.h.

Referenced by importRecHits().

◆ shortFibre_Fraction

double PFHFRecHitCreator::shortFibre_Fraction
protected

Definition at line 184 of file PFHFRecHitCreator.h.

Referenced by importRecHits().

◆ thresh_HF_

double PFHFRecHitCreator::thresh_HF_
protected

Definition at line 185 of file PFHFRecHitCreator.h.

Referenced by importRecHits().