test
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 
18 
19 
21 
22 class PFHFRecHitCreator final : public PFRecHitCreatorBase {
23 
24  public:
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  }
39 
40 
41 
42  void importRecHits(std::auto_ptr<reco::PFRecHitCollection>&out,std::auto_ptr<reco::PFRecHitCollection>& cleaned ,const edm::Event& iEvent,const edm::EventSetup& iSetup) {
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
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  }
199 
200 
201 
202  protected:
204  double EM_Depth_;
205  double HAD_Depth_;
206  // Don't allow large energy in short fibres if there is no energy in long fibres
207  double shortFibre_Cut;
209 
210  // Don't allow large energy in long fibres if there is no energy in short fibres
211  double longFibre_Cut;
213  double thresh_HF_;
214  double HFCalib_;
215 
216  class DetIDSorter {
217  public:
220 
222  const reco::PFRecHit& b) {
223  if (DetId(a.detId()).det() == DetId::Hcal || DetId(b.detId()).det() == DetId::Hcal) return (HcalDetId)(a.detId()) < (HcalDetId)(b.detId());
224  else return a.detId() < b.detId();
225  }
226 
227  };
228 
229 
230 };
231 #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:462
unsigned detId() const
rechit detId
Definition: PFRecHit.h:108
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)
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
int iEvent
Definition: GenABIO.cc:230
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
Definition: DetId.h:18
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
void importRecHits(std::auto_ptr< reco::PFRecHitCollection > &out, std::auto_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup)