CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFHFRecHitCreator.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFHFRecHitCreator_h
2 #define RecoParticleFlow_PFClusterProducer_PFHFRecHitCreator_h
3 
5 
11 
17 
19 
21 
22  public:
24  PFRecHitCreatorBase(iConfig,iC)
25  {
27  EM_Depth_ = iConfig.getParameter<double>("EMDepthCorrection");
28  HAD_Depth_ = iConfig.getParameter<double>("HADDepthCorrection");
29  shortFibre_Cut = iConfig.getParameter<double>("ShortFibre_Cut");
30  longFibre_Fraction = iConfig.getParameter<double>("LongFibre_Fraction");
31  longFibre_Cut = iConfig.getParameter<double>("LongFibre_Cut");
32  shortFibre_Fraction = iConfig.getParameter<double>("ShortFibre_Fraction");
33  thresh_HF_ = iConfig.getParameter<double>("thresh_HF");
34  HFCalib_ = iConfig.getParameter<double>("HFCalib29");
35 
36  }
37 
38 
39 
40  void importRecHits(std::auto_ptr<reco::PFRecHitCollection>&out,std::auto_ptr<reco::PFRecHitCollection>& cleaned ,const edm::Event& iEvent,const edm::EventSetup& iSetup) {
41 
42 
44 
45  beginEvent(iEvent,iSetup);
46 
48 
50  iSetup.get<CaloGeometryRecord>().get(geoHandle);
51 
52  // get the ecal geometry
53  const CaloSubdetectorGeometry *hcalGeo =
54  geoHandle->getSubdetectorGeometry(DetId::Hcal, HcalForward);
55 
56  iEvent.getByToken(recHitToken_,recHitHandle);
57  for( const auto& erh : *recHitHandle ) {
58  const HcalDetId& detid = (HcalDetId)erh.detid();
59  int depth = detid.depth();
60 
61  double energy = erh.energy();
62  double time = erh.time();
63 
65  math::XYZVector axis;
66 
67  const CaloCellGeometry *thisCell;
68  thisCell= hcalGeo->getGeometry(detid);
69 
70  // find rechit geometry
71  if(!thisCell) {
72  edm::LogError("PFHFRecHitCreator")
73  <<"warning detid "<<detid.rawId()
74  <<" not found in geometry"<<std::endl;
75  continue;
76  }
77 
78  auto const point = thisCell->getPosition();
79 
80 
81  PFLayer::Layer layer;
82  double depth_correction;
83  if (depth==1) {
84  layer = PFLayer::HF_EM;
85  depth_correction = point.z() > 0. ? EM_Depth_ : -EM_Depth_;
86  }
87  else {
88  layer = PFLayer::HF_HAD;
89  depth_correction = point.z() > 0. ? HAD_Depth_ : -HAD_Depth_;
90  }
91 
92 
93  position.SetCoordinates ( point.x(),
94  point.y(),
95  point.z()+depth_correction );
96 
97 
98  reco::PFRecHit rh( detid.rawId(),layer,
99  energy,
100  position.x(), position.y(), position.z(),
101  0,0,0);
102  rh.setTime(time);
103  rh.setDepth(depth);
104 
105  const CaloCellGeometry::CornersVec& corners = thisCell->getCorners();
106  assert( corners.size() == 8 );
107 
108  rh.setNECorner( corners[0].x(), corners[0].y(), corners[0].z()+depth_correction);
109  rh.setSECorner( corners[1].x(), corners[1].y(), corners[1].z()+depth_correction);
110  rh.setSWCorner( corners[2].x(), corners[2].y(), corners[2].z()+depth_correction);
111  rh.setNWCorner( corners[3].x(), corners[3].y(), corners[3].z()+depth_correction);
112 
113 
114  bool rcleaned = false;
115  bool keep=true;
116 
117  //Apply Q tests
118  for( const auto& qtest : qualityTests_ ) {
119  if (!qtest->test(rh,erh,rcleaned)) {
120  keep = false;
121 
122  }
123  }
124 
125  if(keep) {
126  tmpOut.push_back(rh);
127  }
128  else if (rcleaned)
129  cleaned->push_back(rh);
130  }
131  //Sort by DetID the collection
133  if (tmpOut.size()>0)
134  std::sort(tmpOut.begin(),tmpOut.end(),sorter);
135 
136 
138 
139  double lONG=0.;
140  double sHORT=0.;
141 
142  for (auto& hit : tmpOut) {
143  lONG=0.0;
144  sHORT=0.0;
145 
146  reco::PFRecHit newHit = hit;
147  const HcalDetId& detid = (HcalDetId)hit.detId();
148  if (detid.depth()==1) {
149  lONG=hit.energy();
150  //find the short hit
151  HcalDetId shortID (HcalForward, detid.ieta(), detid.iphi(), 2);
152  const reco::PFRecHit temp(shortID,PFLayer::NONE,0.0,math::XYZPoint(0,0,0),math::XYZVector(0,0,0),std::vector<math::XYZPoint>());
153  auto found_hit = std::lower_bound(tmpOut.begin(),tmpOut.end(),
154  temp,
155  [](const reco::PFRecHit& a,
156  const reco::PFRecHit& b){
157  return a.detId() < b.detId();
158  });
159  if( found_hit != tmpOut.end() && found_hit->detId() == shortID.rawId() ) {
160  sHORT = found_hit->energy();
161  //Ask for fraction
162  double energy = lONG-sHORT;
163 
164  if (abs(detid.ieta())<=32)
165  energy*=HFCalib_;
166  newHit.setEnergy(energy);
167  if (!( lONG > longFibre_Cut &&
168  ( sHORT/lONG < shortFibre_Fraction)))
169  if (energy>thresh_HF_)
170  out->push_back(newHit);
171  }
172  else
173  {
174  //make only long hit
175  double energy = lONG;
176  if (abs(detid.ieta())<=32)
177  energy*=HFCalib_;
178  newHit.setEnergy(energy);
179 
180  if (energy>thresh_HF_)
181  out->push_back(newHit);
182 
183  }
184 
185  }
186  else {
187  sHORT=hit.energy();
188  HcalDetId longID (HcalForward, detid.ieta(), detid.iphi(), 1);
189  const reco::PFRecHit temp(longID,PFLayer::NONE,0.0,math::XYZPoint(0,0,0),math::XYZVector(0,0,0),std::vector<math::XYZPoint>());
190  auto found_hit = std::lower_bound(tmpOut.begin(),tmpOut.end(),
191  temp,
192  [](const reco::PFRecHit& a,
193  const reco::PFRecHit& b){
194  return a.detId() < b.detId();
195  });
196  double energy = 2*sHORT;
197  if( found_hit != tmpOut.end() && found_hit->detId() == longID.rawId() ) {
198  lONG = found_hit->energy();
199  //Ask for fraction
200 
201  //If in this case lONG-sHORT<0 add the energy to the sHORT
202  if ((lONG-sHORT)<thresh_HF_)
203  energy = lONG+sHORT;
204 
205  if (abs(detid.ieta())<=32)
206  energy*=HFCalib_;
207 
208  newHit.setEnergy(energy);
209  if (!( sHORT > shortFibre_Cut &&
210  ( lONG/sHORT < longFibre_Fraction)))
211  if (energy>thresh_HF_)
212  out->push_back(newHit);
213 
214  }
215  else {
216  //only short hit!
217  if (abs(detid.ieta())<=32)
218  energy*=HFCalib_;
219  newHit.setEnergy(energy);
220  if (energy>thresh_HF_)
221  out->push_back(newHit);
222  }
223  }
224 
225 
226  }
227 
228  }
229 
230 
231 
232  protected:
234  double EM_Depth_;
235  double HAD_Depth_;
236  // Don't allow large energy in short fibres if there is no energy in long fibres
237  double shortFibre_Cut;
239 
240  // Don't allow large energy in long fibres if there is no energy in short fibres
241  double longFibre_Cut;
243  double thresh_HF_;
244  double HFCalib_;
245 
246  class DetIDSorter {
247  public:
250 
252  const reco::PFRecHit& b) {
253  return a.detId() < b.detId();
254  }
255 
256  };
257 
258 
259 };
260 #endif
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
PFHFRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
unsigned detId() const
rechit detId
Definition: PFRecHit.h:106
assert(m_qm.get())
edm::EDGetTokenT< edm::SortedCollection< HFRecHit > > recHitToken_
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
bool operator()(const reco::PFRecHit &a, const reco::PFRecHit &b)
float float float z
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
void setEnergy(double energy)
Definition: PFRecHit.h:72
const int keep
int depth() const
get the tower depth
Definition: HcalDetId.h:40
int iEvent
Definition: GenABIO.cc:230
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:35
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
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:78
tuple out
Definition: dbtoconf.py:99
Layer
layer definition
Definition: PFLayer.h:31
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
size_type size() const
Definition: EZArrayFL.h:81
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const T & get() const
Definition: EventSetup.h:55
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
static int position[264][3]
Definition: ReadPGInfo.cc:509
Definition: DDAxes.h:10
void importRecHits(std::auto_ptr< reco::PFRecHitCollection > &out, std::auto_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup)
const CornersVec & getCorners() const
Returns the corner points of this cell&#39;s volume.
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5