test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Protected Attributes
PFHFRecHitCreator Class Referencefinal

#include <PFHFRecHitCreator.h>

Inheritance diagram for PFHFRecHitCreator:
PFRecHitCreatorBase

Classes

class  DetIDSorter
 

Public Member Functions

void importRecHits (std::auto_ptr< reco::PFRecHitCollection > &out, std::auto_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 PFHFRecHitCreator (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
- Public Member Functions inherited from PFRecHitCreatorBase
 PFRecHitCreatorBase ()
 
 PFRecHitCreatorBase (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 

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_
 

Additional Inherited Members

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

Detailed Description

Definition at line 22 of file PFHFRecHitCreator.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file PFHFRecHitCreator.h.

References edm::ConsumesCollector::consumes(), EM_Depth_, edm::ParameterSet::getParameter(), HAD_Depth_, HFCalib_, longFibre_Cut, longFibre_Fraction, recHitToken_, shortFibre_Cut, shortFibre_Fraction, and thresh_HF_.

25  :
26  PFRecHitCreatorBase(iConfig,iC)
27  {
29  EM_Depth_ = iConfig.getParameter<double>("EMDepthCorrection");
30  HAD_Depth_ = iConfig.getParameter<double>("HADDepthCorrection");
31  shortFibre_Cut = iConfig.getParameter<double>("ShortFibre_Cut");
32  longFibre_Fraction = iConfig.getParameter<double>("LongFibre_Fraction");
33  longFibre_Cut = iConfig.getParameter<double>("LongFibre_Cut");
34  shortFibre_Fraction = iConfig.getParameter<double>("ShortFibre_Fraction");
35  thresh_HF_ = iConfig.getParameter<double>("thresh_HF");
36  HFCalib_ = iConfig.getParameter<double>("HFCalib29");
37 
38  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::SortedCollection< HFRecHit > > recHitToken_

Member Function Documentation

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

Implements PFRecHitCreatorBase.

Definition at line 42 of file PFHFRecHitCreator.h.

References a, funct::abs(), assert(), b, PFRecHitCreatorBase::beginEvent(), compareJSON::const, HcalDetId::depth(), HLT_25ns10e33_v2_cff::depth, relval_parameters_module::energy, edm::EventSetup::get(), edm::Event::getByToken(), CaloSubdetectorGeometry::getGeometry(), DetId::Hcal, HcalForward, PFLayer::HF_EM, PFLayer::HF_HAD, HFCalib_, HcalDetId::ieta(), HcalDetId::iphi(), keep, longFibre_Cut, longFibre_Fraction, eostools::move(), PFRecHitCreatorBase::qualityTests_, DetId::rawId(), recHitToken_, reco::PFRecHit::setEnergy(), reco::PFRecHit::setTime(), shortFibre_Cut, shortFibre_Fraction, MCScenario_CRAFT1_22X::sorter(), and thresh_HF_.

42  {
43 
44 
46 
47  beginEvent(iEvent,iSetup);
48 
50 
52  iSetup.get<CaloGeometryRecord>().get(geoHandle);
53 
54  // get the ecal geometry
55  const CaloSubdetectorGeometry *hcalGeo =
56  geoHandle->getSubdetectorGeometry(DetId::Hcal, HcalForward);
57 
58  iEvent.getByToken(recHitToken_,recHitHandle);
59  for( const auto& erh : *recHitHandle ) {
60  const HcalDetId& detid = (HcalDetId)erh.detid();
61  auto depth = detid.depth();
62 
63  auto energy = erh.energy();
64  auto time = erh.time();
65 
66  const CaloCellGeometry * thisCell= hcalGeo->getGeometry(detid);
67  auto zp = dynamic_cast<IdealZPrism const*>(thisCell);
68  assert(zp);
69  thisCell = zp->forPF();
70 
71  // find rechit geometry
72  if(!thisCell) {
73  edm::LogError("PFHFRecHitCreator")
74  <<"warning detid "<<detid.rawId()
75  <<" not found in geometry"<<std::endl;
76  continue;
77  }
78 
80 
81 
82  reco::PFRecHit rh(thisCell, detid.rawId(),layer,energy);
83  rh.setTime(time);
84  rh.setDepth(depth);
85 
86  bool rcleaned = false;
87  bool keep=true;
88 
89  //Apply Q tests
90  for( const auto& qtest : qualityTests_ ) {
91  if (!qtest->test(rh,erh,rcleaned)) {
92  keep = false;
93 
94  }
95  }
96 
97  if(keep) {
98  tmpOut.push_back(std::move(rh));
99  }
100  else if (rcleaned)
101  cleaned->push_back(std::move(rh));
102  }
103  //Sort by DetID the collection
104  DetIDSorter sorter;
105  if (tmpOut.size()>0)
106  std::sort(tmpOut.begin(),tmpOut.end(),sorter);
107 
108 
110 
111  double lONG=0.;
112  double sHORT=0.;
113 
114  for (auto& hit : tmpOut) {
115  lONG=0.0;
116  sHORT=0.0;
117 
118  reco::PFRecHit newHit = hit;
119  const HcalDetId& detid = (HcalDetId)hit.detId();
120  if (detid.depth()==1) {
121  lONG=hit.energy();
122  //find the short hit
123  HcalDetId shortID (HcalForward, detid.ieta(), detid.iphi(), 2);
124  auto found_hit = std::lower_bound(tmpOut.begin(),tmpOut.end(),
125  shortID,
126  [](const reco::PFRecHit& a,
127  HcalDetId b){
128  return a.detId() < b.rawId();
129  });
130  if( found_hit != tmpOut.end() && found_hit->detId() == shortID.rawId() ) {
131  sHORT = found_hit->energy();
132  //Ask for fraction
133  double energy = lONG-sHORT;
134 
135  if (abs(detid.ieta())<=32)
136  energy*=HFCalib_;
137  newHit.setEnergy(energy);
138  if (!( lONG > longFibre_Cut &&
139  ( sHORT/lONG < shortFibre_Fraction)))
140  if (energy>thresh_HF_)
141  out->push_back(newHit);
142  }
143  else
144  {
145  //make only long hit
146  double energy = lONG;
147  if (abs(detid.ieta())<=32)
148  energy*=HFCalib_;
149  newHit.setEnergy(energy);
150 
151  if (energy>thresh_HF_)
152  out->push_back(newHit);
153 
154  }
155 
156  }
157  else {
158  sHORT=hit.energy();
159  HcalDetId longID (HcalForward, detid.ieta(), detid.iphi(), 1);
160  auto found_hit = std::lower_bound(tmpOut.begin(),tmpOut.end(),
161  longID,
162  [](const reco::PFRecHit& a,
163  HcalDetId b){
164  return a.detId() < b.rawId();
165  });
166  double energy = 2*sHORT;
167  if( found_hit != tmpOut.end() && found_hit->detId() == longID.rawId() ) {
168  lONG = found_hit->energy();
169  //Ask for fraction
170 
171  //If in this case lONG-sHORT<0 add the energy to the sHORT
172  if ((lONG-sHORT)<thresh_HF_)
173  energy = lONG+sHORT;
174 
175  if (abs(detid.ieta())<=32)
176  energy*=HFCalib_;
177 
178  newHit.setEnergy(energy);
179  if (!( sHORT > shortFibre_Cut &&
180  ( lONG/sHORT < longFibre_Fraction)))
181  if (energy>thresh_HF_)
182  out->push_back(newHit);
183 
184  }
185  else {
186  //only short hit!
187  if (abs(detid.ieta())<=32)
188  energy*=HFCalib_;
189  newHit.setEnergy(energy);
190  if (energy>thresh_HF_)
191  out->push_back(newHit);
192  }
193  }
194 
195 
196  }
197 
198  }
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
assert(m_qm.get())
edm::EDGetTokenT< edm::SortedCollection< HFRecHit > > recHitToken_
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const int keep
int depth() const
get the tower depth
Definition: HcalDetId.cc:106
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
def move
Definition: eostools.py:510
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void beginEvent(const edm::Event &event, const edm::EventSetup &setup)
void setTime(double time)
Definition: PFRecHit.h:79
Layer
layer definition
Definition: PFLayer.h:31
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:101
const T & get() const
Definition: EventSetup.h:56
double b
Definition: hdecay.h:120
string const
Definition: compareJSON.py:14
double a
Definition: hdecay.h:121
void setEnergy(float energy)
Definition: PFRecHit.h:74

Member Data Documentation

double PFHFRecHitCreator::EM_Depth_
protected

Definition at line 204 of file PFHFRecHitCreator.h.

Referenced by PFHFRecHitCreator().

double PFHFRecHitCreator::HAD_Depth_
protected

Definition at line 205 of file PFHFRecHitCreator.h.

Referenced by PFHFRecHitCreator().

double PFHFRecHitCreator::HFCalib_
protected

Definition at line 214 of file PFHFRecHitCreator.h.

Referenced by importRecHits(), and PFHFRecHitCreator().

double PFHFRecHitCreator::longFibre_Cut
protected

Definition at line 211 of file PFHFRecHitCreator.h.

Referenced by importRecHits(), and PFHFRecHitCreator().

double PFHFRecHitCreator::longFibre_Fraction
protected

Definition at line 208 of file PFHFRecHitCreator.h.

Referenced by importRecHits(), and PFHFRecHitCreator().

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

Definition at line 203 of file PFHFRecHitCreator.h.

Referenced by importRecHits(), and PFHFRecHitCreator().

double PFHFRecHitCreator::shortFibre_Cut
protected

Definition at line 207 of file PFHFRecHitCreator.h.

Referenced by importRecHits(), and PFHFRecHitCreator().

double PFHFRecHitCreator::shortFibre_Fraction
protected

Definition at line 212 of file PFHFRecHitCreator.h.

Referenced by importRecHits(), and PFHFRecHitCreator().

double PFHFRecHitCreator::thresh_HF_
protected

Definition at line 213 of file PFHFRecHitCreator.h.

Referenced by importRecHits(), and PFHFRecHitCreator().