CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalHaloAlgo Class Reference

#include <HcalHaloAlgo.h>

Public Member Functions

reco::HcalHaloData Calculate (const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< CaloTowerCollection > &TheCaloTowers, edm::Handle< EBRecHitCollection > &TheEBRecHits, edm::Handle< EERecHitCollection > &TheEERecHits, const edm::EventSetup &TheSetup)
 
reco::HcalHaloData Calculate (const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< EBRecHitCollection > &TheEBRecHits, edm::Handle< EERecHitCollection > &TheEERecHits, const edm::EventSetup &TheSetup)
 
std::vector< reco::HaloClusterCandidateHCALGetHaloClusterCandidateHB (edm::Handle< EcalRecHitCollection > &ebrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
 
std::vector< reco::HaloClusterCandidateHCALGetHaloClusterCandidateHE (edm::Handle< EcalRecHitCollection > &eerechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
 
float GetHBRecHitEnergyThreshold ()
 
float GetHERecHitEnergyThreshold ()
 
float GetPhiWedgeEnergyThreshold ()
 
int GetPhiWedgeNHitsThreshold ()
 
bool HBClusterShapeandTimeStudy (reco::HaloClusterCandidateHCAL hcand, bool ishlt)
 
 HcalHaloAlgo ()
 
bool HEClusterShapeandTimeStudy (reco::HaloClusterCandidateHCAL hcand, bool ishlt)
 
void SetPhiWedgeEnergyThreshold (float SumE)
 
void SetPhiWedgeNHitsThreshold (int nhits)
 
void SetPhiWedgeThresholds (float SumE, int nhits)
 
void SetRecHitEnergyThresholds (float HB, float HE)
 
 ~HcalHaloAlgo ()
 

Private Member Functions

math::XYZPoint getPosition (const DetId &id, reco::Vertex::Point vtx)
 

Private Attributes

const CaloGeometrygeo_
 
float HBRecHitEnergyThreshold
 
float HERecHitEnergyThreshold
 
const HcalGeometryhgeo_
 
int NHitsThreshold
 
float SumEnergyThreshold
 

Detailed Description

Definition at line 41 of file HcalHaloAlgo.h.

Constructor & Destructor Documentation

HcalHaloAlgo::HcalHaloAlgo ( )

Definition at line 23 of file HcalHaloAlgo.cc.

References HBRecHitEnergyThreshold, HERecHitEnergyThreshold, NHitsThreshold, and SumEnergyThreshold.

23  : geo_(nullptr), hgeo_(nullptr) {
26  SumEnergyThreshold = 0.;
27  NHitsThreshold = 0;
28 }
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:80
const CaloGeometry * geo_
Definition: HcalHaloAlgo.h:86
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:79
const HcalGeometry * hgeo_
Definition: HcalHaloAlgo.h:87
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:83
int NHitsThreshold
Definition: HcalHaloAlgo.h:84
HcalHaloAlgo::~HcalHaloAlgo ( )
inline

Definition at line 46 of file HcalHaloAlgo.h.

References Calculate().

46 {}

Member Function Documentation

HcalHaloData HcalHaloAlgo::Calculate ( const CaloGeometry TheCaloGeometry,
edm::Handle< HBHERecHitCollection > &  TheHBHERecHits,
edm::Handle< CaloTowerCollection > &  TheCaloTowers,
edm::Handle< EBRecHitCollection > &  TheEBRecHits,
edm::Handle< EERecHitCollection > &  TheEERecHits,
const edm::EventSetup TheSetup 
)

Definition at line 35 of file HcalHaloAlgo.cc.

References funct::abs(), CompareTime(), CompareTowers(), CaloTower::emEt(), F(), geo_, edm::EventSetup::get(), GetHaloClusterCandidateHB(), GetHaloClusterCandidateHE(), reco::HcalHaloData::GetPhiWedges(), reco::HcalHaloData::getProblematicStrips(), CaloGeometry::getSubdetectorGeometry(), CaloTower::hadEt(), HBRecHitEnergyThreshold, DetId::Hcal, HcalBarrel, HcalEndcap, HERecHitEnergyThreshold, hgeo_, mps_fire::i, hit::id, CaloTower::id(), HcalDetId::ieta(), CaloTower::ieta(), CaloTower::iphi(), SiStripPI::max, NHitsThreshold, CaloTower::numProblematicHcalCells(), edm::ESHandle< T >::product(), reco::HcalHaloData::setHaloClusterCandidatesHB(), reco::HcalHaloData::setHaloClusterCandidatesHE(), reco::PhiWedge::SetPlusZOriginConfidence(), digitizers_cfi::strip, SumEnergyThreshold, and ntuplemaker::time.

Referenced by Calculate(), reco::HcalHaloDataProducer::produce(), and ~HcalHaloAlgo().

36 {
37 
38  HcalHaloData TheHcalHaloData;
39  // ieta overlap geometrically w/ HB
40  const int iEtaOverlap = 22;
41  const int nPhiMax=73;
42  // Store Energy sum of rechits as a function of iPhi (iPhi goes from 1 to 72)
43  float SumE[nPhiMax];
44  // Store Number of rechits as a function of iPhi
45  int NumHits[nPhiMax];
46  // Store minimum time of rechit as a function of iPhi
47  float MinTimeHits[nPhiMax];
48  // Store maximum time of rechit as a function of iPhi
49  float MaxTimeHits[nPhiMax];
50  for(unsigned int i = 0 ; i < nPhiMax ; i++ )
51  {
52  SumE[i] = 0;
53  NumHits[i]= 0;
54  MinTimeHits[i] = 0.;
55  MaxTimeHits[i] = 0.;
56  }
57 
58  for (const auto & hit : (*TheHBHERecHits)) {
59  HcalDetId id = HcalDetId(hit.id());
60  switch ( id.subdet() ) {
61  case HcalBarrel:
62  if(hit.energy() < HBRecHitEnergyThreshold )continue;
63  break;
64  case HcalEndcap:
65  if(hit.energy() < HERecHitEnergyThreshold ) continue;
66  break;
67  default:
68  continue;
69  }
70 
71  int iEta = id.ieta();
72  int iPhi = id.iphi();
73  if(iPhi < nPhiMax && std::abs(iEta) <= iEtaOverlap) {
74  SumE[iPhi]+= hit.energy();
75  NumHits[iPhi] ++;
76 
77  float time = hit.time();
78  MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
79  MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
80  }
81  }
82 
83  for (int iPhi = 1 ; iPhi < nPhiMax ; iPhi++ ) {
84  if( SumE[iPhi] >= SumEnergyThreshold && NumHits[iPhi] > NHitsThreshold ) {
85  // Build PhiWedge and store to HcalHaloData if energy or #hits pass thresholds
86  PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
87 
88  // Loop over rechits again to calculate direction based on timing info
89  std::vector<const HBHERecHit*> Hits;
90  for (const auto & hit : (*TheHBHERecHits)) {
91  HcalDetId id = HcalDetId(hit.id());
92  if( id.iphi() != iPhi ) continue;
93  if( std::abs(id.ieta() ) > iEtaOverlap ) continue; // has to overlap geometrically w/ HB
94  switch ( id.subdet() ) {
95  case HcalBarrel:
96  if(hit.energy() < HBRecHitEnergyThreshold )continue;
97  break;
98  case HcalEndcap:
99  if(hit.energy() < HERecHitEnergyThreshold ) continue;
100  break;
101  default:
102  continue;
103  }
104  Hits.push_back(&(hit));
105  }
106 
107  std::sort( Hits.begin() , Hits.end() , CompareTime);
108  float MinusToPlus = 0.;
109  float PlusToMinus = 0.;
110  for( unsigned int i = 0 ; i < Hits.size() ; i++ ) {
111  HcalDetId id_i = HcalDetId(Hits[i]->id() );
112  int ieta_i = id_i.ieta();
113  for( unsigned int j = (i+1) ; j < Hits.size() ; j++ ) {
114  HcalDetId id_j = HcalDetId(Hits[j]->id() );
115  int ieta_j = id_j.ieta();
116  if( ieta_i > ieta_j ) PlusToMinus += std::abs(ieta_i - ieta_j ) ;
117  else MinusToPlus += std::abs(ieta_i - ieta_j);
118  }
119  }
120  float PlusZOriginConfidence = (PlusToMinus + MinusToPlus )? PlusToMinus / ( PlusToMinus + MinusToPlus ) : -1. ;
121  wedge.SetPlusZOriginConfidence( PlusZOriginConfidence );
122  TheHcalHaloData.GetPhiWedges().push_back( wedge );
123  }
124  }
125 
126 
127  // Don't use HF.
128  int maxAbsIEta = 29;
129 
130 
131  std::map<int, float> iPhiHadEtMap;
132  std::vector<const CaloTower*> sortedCaloTowers;
133  for (const auto & tower : (*TheCaloTowers)) {
134  if(std::abs(tower.ieta()) > maxAbsIEta) continue;
135 
136  int iPhi = tower.iphi();
137  if(!iPhiHadEtMap.count(iPhi)) iPhiHadEtMap[iPhi] = 0.0;
138  iPhiHadEtMap[iPhi] += tower.hadEt();
139 
140  if(tower.numProblematicHcalCells() > 0) sortedCaloTowers.push_back(&(tower));
141 
142  }
143 
144 
145  // Sort towers such that lowest iphi and ieta are first, highest last, and towers
146  // with same iphi value are consecutive. Then we can do everything else in one loop.
147  std::sort(sortedCaloTowers.begin(), sortedCaloTowers.end(), CompareTowers);
148 
150 
151 
152  int prevIEta = -99, prevIPhi = -99;
153  float prevHadEt = 0.;
154  float prevEmEt = 0.;
155  std::pair<uint8_t, CaloTowerDetId> prevPair, towerPair;
156  bool wasContiguous = true;
157 
158  // Loop through and store a vector of pairs (problematicCells, DetId) for each contiguous strip we find
159  for(unsigned int i = 0; i < sortedCaloTowers.size(); i++) {
160  const CaloTower* tower = sortedCaloTowers[i];
161 
162  towerPair = std::make_pair((uint8_t)tower->numProblematicHcalCells(), tower->id());
163 
164  bool newIPhi = tower->iphi() != prevIPhi;
165  bool isContiguous = tower->ieta() == 1 ? tower->ieta() - 2 == prevIEta : tower->ieta() - 1 == prevIEta;
166 
167  isContiguous = isContiguous || (tower->ieta() == -maxAbsIEta);
168  if(newIPhi) isContiguous = false;
169 
170  if(!wasContiguous && isContiguous) {
171  strip.cellTowerIds.push_back(prevPair);
172  strip.cellTowerIds.push_back(towerPair);
173  strip.hadEt += prevHadEt + tower->hadEt();
174  strip.emEt += prevEmEt + tower->emEt();
175  }
176 
177  if(wasContiguous && isContiguous) {
178  strip.cellTowerIds.push_back(towerPair);
179  strip.hadEt += tower->hadEt();
180  strip.emEt += tower->emEt();
181  }
182 
183  if((wasContiguous && !isContiguous) || i == sortedCaloTowers.size()-1) { //ended the strip, so flush it
184 
185  if(strip.cellTowerIds.size() > 3) {
186 
187  int iPhi = strip.cellTowerIds.at(0).second.iphi();
188  int iPhiLower = (iPhi == 1) ? 72 : iPhi - 1;
189  int iPhiUpper = (iPhi == 72) ? 1 : iPhi + 1;
190 
191  float energyRatio = 0.0;
192  if(iPhiHadEtMap.count(iPhiLower)) energyRatio += iPhiHadEtMap[iPhiLower];
193  if(iPhiHadEtMap.count(iPhiUpper)) energyRatio += iPhiHadEtMap[iPhiUpper];
194  iPhiHadEtMap[iPhi] = std::max(iPhiHadEtMap[iPhi], 0.001F);
195 
196  energyRatio /= iPhiHadEtMap[iPhi];
197  strip.energyRatio = energyRatio;
198 
199  TheHcalHaloData.getProblematicStrips().push_back( strip );
200 
201  }
202  strip = HaloTowerStrip();
203  }
204 
205  wasContiguous = isContiguous;
206  prevPair = towerPair;
207  prevEmEt = tower->emEt();
208  prevIPhi = tower->iphi();
209  prevIEta = tower->ieta();
210  prevHadEt = tower->hadEt();
211  }
212 
214  TheSetup.get<CaloGeometryRecord>().get(pGeo);
215  geo_ = pGeo.product();
216  hgeo_ = dynamic_cast<const HcalGeometry*>(geo_->getSubdetectorGeometry(DetId::Hcal, 1));
217 
218  //Halo cluster building:
219  //Various clusters are built, depending on the subdetector.
220  //In barrel, one looks for deposits narrow in phi.
221  //In endcaps, one looks for localized deposits (dr condition in EE where r =sqrt(dphi*dphi+deta*deta)
222  //E/H condition is also applied.
223  //The halo cluster building step targets a large efficiency (ideally >99%) for beam halo deposits.
224  //These clusters are used as input for the halo pattern finding methods in HcalHaloAlgo and for the CSC-calo matching methods in GlobalHaloAlgo.
225 
226  //Et threshold hardcoded for now. Might one to get it from config
227 
228  std::vector<HaloClusterCandidateHCAL> haloclustercands_HB;
229  haloclustercands_HB= GetHaloClusterCandidateHB(TheEBRecHits , TheHBHERecHits, 5);
230 
231  std::vector<HaloClusterCandidateHCAL> haloclustercands_HE;
232  haloclustercands_HE= GetHaloClusterCandidateHE(TheEERecHits , TheHBHERecHits, 10);
233 
234  TheHcalHaloData.setHaloClusterCandidatesHB(haloclustercands_HB);
235  TheHcalHaloData.setHaloClusterCandidatesHE(haloclustercands_HE);
236 
237 
238  return TheHcalHaloData;
239 
240 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:80
void setHaloClusterCandidatesHB(const std::vector< HaloClusterCandidateHCAL > &x)
Definition: HcalHaloData.h:61
int ieta() const
Definition: CaloTower.h:185
double hadEt() const
Definition: CaloTower.h:116
int iphi() const
Definition: CaloTower.h:187
std::vector< reco::HaloClusterCandidateHCAL > GetHaloClusterCandidateHE(edm::Handle< EcalRecHitCollection > &eerechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
const CaloGeometry * geo_
Definition: HcalHaloAlgo.h:86
int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
void setHaloClusterCandidatesHE(const std::vector< HaloClusterCandidateHCAL > &x)
Definition: HcalHaloData.h:62
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool CompareTime(const HBHERecHit *x, const HBHERecHit *y)
Definition: HcalHaloAlgo.cc:18
unsigned int id
CaloTowerDetId id() const
Definition: CaloTower.h:103
unsigned int numProblematicHcalCells() const
Definition: CaloTower.h:202
bool CompareTowers(const CaloTower *x, const CaloTower *y)
Definition: HcalHaloAlgo.cc:19
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:79
const HcalGeometry * hgeo_
Definition: HcalHaloAlgo.h:87
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:83
const std::vector< HaloTowerStrip > & getProblematicStrips() const
Definition: HcalHaloData.h:52
T get() const
Definition: EventSetup.h:63
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: HcalHaloData.h:48
int NHitsThreshold
Definition: HcalHaloAlgo.h:84
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
T const * product() const
Definition: ESHandle.h:86
double emEt() const
Definition: CaloTower.h:115
std::vector< reco::HaloClusterCandidateHCAL > GetHaloClusterCandidateHB(edm::Handle< EcalRecHitCollection > &ebrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
HcalHaloData HcalHaloAlgo::Calculate ( const CaloGeometry TheCaloGeometry,
edm::Handle< HBHERecHitCollection > &  TheHBHERecHits,
edm::Handle< EBRecHitCollection > &  TheEBRecHits,
edm::Handle< EERecHitCollection > &  TheEERecHits,
const edm::EventSetup TheSetup 
)

Definition at line 30 of file HcalHaloAlgo.cc.

References Calculate().

30  {
32  return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers,TheEBRecHits,TheEERecHits,TheSetup);
33 }
reco::HcalHaloData Calculate(const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< CaloTowerCollection > &TheCaloTowers, edm::Handle< EBRecHitCollection > &TheEBRecHits, edm::Handle< EERecHitCollection > &TheEERecHits, const edm::EventSetup &TheSetup)
Definition: HcalHaloAlgo.cc:35
std::vector< HaloClusterCandidateHCAL > HcalHaloAlgo::GetHaloClusterCandidateHB ( edm::Handle< EcalRecHitCollection > &  ebrechitcoll,
edm::Handle< HBHERecHitCollection > &  hbherechitcoll,
float  et_thresh_seedrh 
)

Definition at line 249 of file HcalHaloAlgo.cc.

References funct::abs(), hiPixelPairStep_cff::deltaPhi, CaloRecHit::energy(), EcalRecHit::energy(), PVValHelper::eta, getPosition(), HBClusterShapeandTimeStudy(), HBHERecHit::id(), EcalRecHit::id(), phi, edm::RefVector< C, T, F >::push_back(), reco::HaloClusterCandidateHCAL::setBeamHaloRecHitsCandidates(), reco::HaloClusterCandidateHCAL::setClusterEt(), reco::HaloClusterCandidateHCAL::setEoverH(), reco::HaloClusterCandidateHCAL::setEtStripPhiSeedMinus1(), reco::HaloClusterCandidateHCAL::setEtStripPhiSeedPlus1(), reco::HaloClusterCandidateHCAL::setIsHaloFromPattern(), reco::HaloClusterCandidateHCAL::setIsHaloFromPattern_HLT(), reco::HaloClusterCandidateHCAL::setNbTowersInEta(), reco::HaloClusterCandidateHCAL::setSeedEt(), reco::HaloClusterCandidateHCAL::setSeedEta(), reco::HaloClusterCandidateHCAL::setSeedPhi(), reco::HaloClusterCandidateHCAL::setSeedR(), reco::HaloClusterCandidateHCAL::setSeedTime(), reco::HaloClusterCandidateHCAL::setSeedZ(), reco::HaloClusterCandidateHCAL::setTimeDiscriminatorITBH(), reco::HaloClusterCandidateHCAL::setTimeDiscriminatorOTBH(), edm::SortedCollection< T, SORT >::size(), mathSSE::sqrt(), CaloRecHit::time(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by Calculate(), and GetPhiWedgeNHitsThreshold().

249  {
250 
251  std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHB;
252 
253  reco::Vertex::Point vtx(0,0,0);
254 
255  for(size_t ihit = 0; ihit<hbherechitcoll->size(); ++ ihit){
256  HaloClusterCandidateHCAL clustercand;
257 
258  const HBHERecHit & rechit = (*hbherechitcoll)[ ihit ];
259  math::XYZPoint rhpos = getPosition(rechit.id(),vtx);
260  //Et condition
261  double rhet = rechit.energy()* sqrt(rhpos.perp2()/rhpos.mag2());
262  if(rhet<et_thresh_seedrh) continue;
263  if(std::abs(rhpos.z())>zseparation_HBHE) continue;
264  double eta = rhpos.eta();
265  double phi = rhpos.phi();
266 
267  bool isiso = true;
268  double etcluster(0);
269  int nbtowerssameeta(0);
270  double timediscriminatorITBH(0),timediscriminatorOTBH(0);
271  double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
272 
273  //Building the cluster
275  for(size_t jhit = 0; jhit<hbherechitcoll->size(); ++ jhit){
276  const HBHERecHit & rechitj = (*hbherechitcoll)[ jhit ];
277  HBHERecHitRef rhRef(hbherechitcoll,jhit);
278  math::XYZPoint rhposj = getPosition(rechitj.id(),vtx);
279  double rhetj = rechitj.energy()* sqrt(rhposj.perp2()/rhposj.mag2());
280  if(rhetj<2) continue;
281  if(std::abs(rhposj.z())>zseparation_HBHE) continue;
282  double etaj = rhposj.eta();
283  double phij = rhposj.phi();
284  double deta = eta - etaj;
285  double dphi = deltaPhi(phi,phij);
286  if(std::abs(deta)>0.4) continue;//This means +/-4 towers in eta
287  if(std::abs(dphi)>0.2) continue;//This means +/-2 towers in phi
288  if(std::abs(dphi)>0.1&&std::abs(deta)<0.2){isiso=false;break;}//The strip should be isolated
289  if(std::abs(dphi)>0.1)continue;
290  if(std::abs(dphi)<0.05) nbtowerssameeta++;
291  if(dphi>0.05) etstrip_phiseedplus1+=rhetj;
292  if(dphi<-0.05) etstrip_phiseedminus1+=rhetj;
293 
294  etcluster+=rhetj;
295  //Timing discriminator
296  //We assign a weight to the rechit defined as:
297  //Log10(Et)*f(T,R,Z)
298  //where f(T,R,Z) is the separation curve between halo-like and IP-like times.
299  //The time difference between a deposit from a outgoing IT halo and a deposit coming from a particle emitted at the IP is given by:
300  //dt= ( - sqrt(R^2+z^2) + |z| )/c
301  // For OT beam halo, the time difference is:
302  //dt= ( 25 + sqrt(R^2+z^2) + |z| )/c
303  //only consider the central part of HB as things get hard at large z.
304  //The best fitted value for R leads to 240 cm (IT) and 330 cm (OT)
305  double rhtj = rechitj.time();
306  timediscriminatorITBH+= std::log10( rhetj )* ( rhtj +0.5*(sqrt(240.*240.+rhposj.z()*rhposj.z()) -std::abs(rhposj.z()))/c_cm_per_ns);
307  if(std::abs(rhposj.z())<300) timediscriminatorOTBH+= std::log10( rhetj )* ( rhtj -0.5*(25-(sqrt(330.*330.+rhposj.z()*rhposj.z()) +std::abs(rhposj.z()))/c_cm_per_ns) );
308  bhrhcandidates.push_back(rhRef);
309  }
310  //Isolation conditions
311  if(!isiso) continue;
312  if(etstrip_phiseedplus1/etcluster>0.2&& etstrip_phiseedminus1/etcluster>0.2) continue;
313 
314  //Calculate E/H
315  double eoh(0);
316  for(size_t jhit = 0; jhit<ecalrechitcoll->size(); ++ jhit){
317  const EcalRecHit & rechitj = (*ecalrechitcoll)[ jhit ];
318  math::XYZPoint rhposj = getPosition(rechitj.id(),vtx);
319  double rhetj = rechitj.energy()* sqrt(rhposj.perp2()/rhposj.mag2());
320  if(rhetj<2) continue;
321  double etaj = rhposj.eta();
322  double phij = rhposj.phi();
323  if(std::abs(eta-etaj)>0.2) continue;
324  if(std::abs(deltaPhi(phi,phij))>0.2) continue;
325  eoh+=rhetj/etcluster;
326  }
327  //E/H condition
328  if(eoh>0.1) continue;
329 
330 
331  clustercand.setClusterEt(etcluster);
332  clustercand.setSeedEt(rhet);
333  clustercand.setSeedEta(eta);
334  clustercand.setSeedPhi(phi);
335  clustercand.setSeedZ(rhpos.Z());
336  clustercand.setSeedR(sqrt(rhpos.perp2()));
337  clustercand.setSeedTime(rechit.time());
338  clustercand.setEoverH(eoh);
339  clustercand.setNbTowersInEta(nbtowerssameeta);
340  clustercand.setEtStripPhiSeedPlus1(etstrip_phiseedplus1);
341  clustercand.setEtStripPhiSeedMinus1(etstrip_phiseedminus1);
342  clustercand.setTimeDiscriminatorITBH(timediscriminatorITBH);
343  clustercand.setTimeDiscriminatorOTBH(timediscriminatorOTBH);
344  clustercand.setBeamHaloRecHitsCandidates(bhrhcandidates);
345 
346  bool isbeamhalofrompattern = HBClusterShapeandTimeStudy(clustercand,false);
347  clustercand.setIsHaloFromPattern(isbeamhalofrompattern);
348  bool isbeamhalofrompattern_hlt = HBClusterShapeandTimeStudy(clustercand,true);
349  clustercand.setIsHaloFromPattern_HLT(isbeamhalofrompattern_hlt);
350 
351 
352  TheHaloClusterCandsHB.push_back(clustercand);
353  }
354 
355  return TheHaloClusterCandsHB;
356 }
constexpr float energy() const
Definition: CaloRecHit.h:31
HcalDetId id() const
get the id
Definition: HBHERecHit.h:42
bool HBClusterShapeandTimeStudy(reco::HaloClusterCandidateHCAL hcand, bool ishlt)
T sqrt(T t)
Definition: SSEVec.h:18
constexpr float time() const
Definition: CaloRecHit.h:33
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float energy() const
Definition: EcalRecHit.h:68
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
DetId id() const
get the id
Definition: EcalRecHit.h:77
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
size_type size() const
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
void setBeamHaloRecHitsCandidates(edm::RefVector< HBHERecHitCollection > x)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
std::vector< HaloClusterCandidateHCAL > HcalHaloAlgo::GetHaloClusterCandidateHE ( edm::Handle< EcalRecHitCollection > &  eerechitcoll,
edm::Handle< HBHERecHitCollection > &  hbherechitcoll,
float  et_thresh_seedrh 
)

Definition at line 359 of file HcalHaloAlgo.cc.

References funct::abs(), hiPixelPairStep_cff::deltaPhi, runTauDisplay::dr, CaloRecHit::energy(), EcalRecHit::energy(), PVValHelper::eta, getPosition(), HEClusterShapeandTimeStudy(), HBHERecHit::id(), EcalRecHit::id(), phi, edm::RefVector< C, T, F >::push_back(), reco::HaloClusterCandidateHCAL::setBeamHaloRecHitsCandidates(), reco::HaloClusterCandidateHCAL::setClusterEt(), reco::HaloClusterCandidateHCAL::setClusterSize(), reco::HaloClusterCandidateHCAL::setEoverH(), reco::HaloClusterCandidateHCAL::setEtStripPhiSeedMinus1(), reco::HaloClusterCandidateHCAL::setEtStripPhiSeedPlus1(), reco::HaloClusterCandidateHCAL::setH1overH123(), reco::HaloClusterCandidateHCAL::setIsHaloFromPattern(), reco::HaloClusterCandidateHCAL::setIsHaloFromPattern_HLT(), reco::HaloClusterCandidateHCAL::setSeedEt(), reco::HaloClusterCandidateHCAL::setSeedEta(), reco::HaloClusterCandidateHCAL::setSeedPhi(), reco::HaloClusterCandidateHCAL::setSeedR(), reco::HaloClusterCandidateHCAL::setSeedTime(), reco::HaloClusterCandidateHCAL::setSeedZ(), reco::HaloClusterCandidateHCAL::setTimeDiscriminator(), edm::SortedCollection< T, SORT >::size(), mathSSE::sqrt(), CaloRecHit::time(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by Calculate(), and GetPhiWedgeNHitsThreshold().

359  {
360 
361  std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHE;
362 
363  reco::Vertex::Point vtx(0,0,0);
364 
365  for(size_t ihit = 0; ihit<hbherechitcoll->size(); ++ ihit){
366  HaloClusterCandidateHCAL clustercand;
367 
368  const HBHERecHit & rechit = (*hbherechitcoll)[ ihit ];
369  math::XYZPoint rhpos = getPosition(rechit.id(),vtx);
370  //Et condition
371  double rhet = rechit.energy()* sqrt(rhpos.perp2()/rhpos.mag2());
372  if(rhet<et_thresh_seedrh) continue;
373  if(std::abs(rhpos.z())<zseparation_HBHE) continue;
374  double eta = rhpos.eta();
375  double phi = rhpos.phi();
376  double rhr = sqrt(rhpos.perp2());
377  bool isiso = true;
378  double etcluster(0),hdepth1(0);
379  int clustersize(0);
380  double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
381 
382  //Building the cluster
384  for(size_t jhit = 0; jhit<hbherechitcoll->size(); ++ jhit){
385  const HBHERecHit & rechitj = (*hbherechitcoll)[ jhit ];
386  HBHERecHitRef rhRef(hbherechitcoll,jhit);
387  math::XYZPoint rhposj = getPosition(rechitj.id(),vtx);
388  double rhetj = rechitj.energy()* sqrt(rhposj.perp2()/rhposj.mag2());
389  if(rhetj<2) continue;
390  if(std::abs(rhposj.z())<zseparation_HBHE) continue;
391  if(rhpos.z()*rhposj.z()<0) continue;
392  double phij = rhposj.phi();
393  double dphi = deltaPhi(phi,phij);
394  if(std::abs(dphi)>0.4) continue;
395  double rhrj = sqrt(rhposj.perp2());
396  if(std::abs( rhr-rhrj )>50) continue;
397  if(std::abs(dphi)>0.2 ||std::abs( rhr-rhrj )>20 ){isiso=false;break;}//The deposit should be isolated
398  if(dphi>0.05) etstrip_phiseedplus1+=rhetj;
399  if(dphi<-0.05) etstrip_phiseedminus1+=rhetj;
400  clustersize++;
401  etcluster+=rhetj;
402  if(std::abs( rhposj.z())<405 )hdepth1+=rhetj;
403  //No timing condition for now in HE
404  bhrhcandidates.push_back(rhRef);
405  }
406  //Isolation conditions
407  if(!isiso) continue;
408  if(etstrip_phiseedplus1/etcluster>0.1&& etstrip_phiseedminus1/etcluster>0.1) continue;
409 
410  //Calculate E/H
411  double eoh(0);
412  for(size_t jhit = 0; jhit<ecalrechitcoll->size(); ++ jhit){
413  const EcalRecHit & rechitj = (*ecalrechitcoll)[ jhit ];
414  math::XYZPoint rhposj = getPosition(rechitj.id(),vtx);
415  double rhetj = rechitj.energy()* sqrt(rhposj.perp2()/rhposj.mag2());
416  if(rhetj<2) continue;
417  if(rhpos.z()*rhposj.z()<0) continue;
418  double etaj = rhposj.eta();
419  double phij = rhposj.phi();
420  double dr = sqrt( (eta-etaj)*(eta-etaj)+deltaPhi(phi,phij)*deltaPhi(phi,phij));
421  if(dr>0.3) continue;
422 
423  eoh+=rhetj/etcluster;
424  }
425  //E/H condition
426  if(eoh>0.1) continue;
427 
428 
429  clustercand.setClusterEt(etcluster);
430  clustercand.setSeedEt(rhet);
431  clustercand.setSeedEta(eta);
432  clustercand.setSeedPhi(phi);
433  clustercand.setSeedZ(rhpos.Z());
434  clustercand.setSeedR(sqrt(rhpos.perp2()));
435  clustercand.setSeedTime(rechit.time());
436  clustercand.setEoverH(eoh);
437  clustercand.setH1overH123(hdepth1/etcluster);
438  clustercand.setClusterSize(clustersize);
439  clustercand.setEtStripPhiSeedPlus1(etstrip_phiseedplus1);
440  clustercand.setEtStripPhiSeedMinus1(etstrip_phiseedminus1);
441  clustercand.setTimeDiscriminator(0);
442  clustercand.setBeamHaloRecHitsCandidates(bhrhcandidates);
443 
444  bool isbeamhalofrompattern = HEClusterShapeandTimeStudy(clustercand,false);
445  clustercand.setIsHaloFromPattern(isbeamhalofrompattern);
446  bool isbeamhalofrompattern_hlt = HEClusterShapeandTimeStudy(clustercand,true);
447  clustercand.setIsHaloFromPattern_HLT(isbeamhalofrompattern_hlt);
448 
449 
450  TheHaloClusterCandsHE.push_back(clustercand);
451  }
452 
453  return TheHaloClusterCandsHE;
454 }
constexpr float energy() const
Definition: CaloRecHit.h:31
HcalDetId id() const
get the id
Definition: HBHERecHit.h:42
T sqrt(T t)
Definition: SSEVec.h:18
constexpr float time() const
Definition: CaloRecHit.h:33
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float energy() const
Definition: EcalRecHit.h:68
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
DetId id() const
get the id
Definition: EcalRecHit.h:77
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
size_type size() const
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
void setBeamHaloRecHitsCandidates(edm::RefVector< HBHERecHitCollection > x)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
bool HEClusterShapeandTimeStudy(reco::HaloClusterCandidateHCAL hcand, bool ishlt)
float HcalHaloAlgo::GetHBRecHitEnergyThreshold ( )
inline

Definition at line 62 of file HcalHaloAlgo.h.

References HBRecHitEnergyThreshold.

62 { return HBRecHitEnergyThreshold;}
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:79
float HcalHaloAlgo::GetHERecHitEnergyThreshold ( )
inline

Definition at line 63 of file HcalHaloAlgo.h.

References HERecHitEnergyThreshold.

63 { return HERecHitEnergyThreshold;}
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:80
float HcalHaloAlgo::GetPhiWedgeEnergyThreshold ( )
inline

Definition at line 66 of file HcalHaloAlgo.h.

References SumEnergyThreshold.

66 { return SumEnergyThreshold;}
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:83
int HcalHaloAlgo::GetPhiWedgeNHitsThreshold ( )
inline
math::XYZPoint HcalHaloAlgo::getPosition ( const DetId id,
reco::Vertex::Point  vtx 
)
private

Definition at line 507 of file HcalHaloAlgo.cc.

References geo_, CaloGeometry::getPosition(), HcalGeometry::getPosition(), DetId::Hcal, hgeo_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by GetHaloClusterCandidateHB(), and GetHaloClusterCandidateHE().

507  {
508 
509  const GlobalPoint pos = ((id.det() == DetId::Hcal) ? hgeo_->getPosition(id) :
511  math::XYZPoint posV(pos.x() - vtx.x(),pos.y() - vtx.y(),pos.z() - vtx.z());
512  return posV;
513 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
const CaloGeometry * geo_
Definition: HcalHaloAlgo.h:86
T z() const
Definition: PV3DBase.h:64
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:74
GlobalPoint getPosition(const DetId &id) const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const HcalGeometry * hgeo_
Definition: HcalHaloAlgo.h:87
T x() const
Definition: PV3DBase.h:62
bool HcalHaloAlgo::HBClusterShapeandTimeStudy ( reco::HaloClusterCandidateHCAL  hcand,
bool  ishlt 
)

Definition at line 458 of file HcalHaloAlgo.cc.

References reco::HaloClusterCandidateHCAL::getEtStripPhiSeedMinus1(), reco::HaloClusterCandidateHCAL::getEtStripPhiSeedPlus1(), reco::HaloClusterCandidateHCAL::getNbTowersInEta(), reco::HaloClusterCandidateHCAL::getSeedEt(), reco::HaloClusterCandidateHCAL::getTimeDiscriminatorITBH(), reco::HaloClusterCandidateHCAL::getTimeDiscriminatorOTBH(), and reco::HaloClusterCandidateHCAL::setIsHaloFromPattern().

Referenced by GetHaloClusterCandidateHB(), and GetPhiWedgeNHitsThreshold().

458  {
459  //Conditions on the central strip size in eta.
460  //For low size, extra conditions on seed et, isolation and cluster timing
461  //Here we target both IT and OT beam halo. Two separate discriminators were built for the two cases.
462 
463  if(hcand.getSeedEt()<10)return false;
464 
465  if(hcand.getNbTowersInEta()<3) return false;
466  //Isolation criteria for very short eta strips
467  if(hcand.getNbTowersInEta()==3 && (hcand.getEtStripPhiSeedPlus1()>0.1 || hcand.getEtStripPhiSeedMinus1()>0.1) ) return false;
468  if(hcand.getNbTowersInEta()<=5 && (hcand.getEtStripPhiSeedPlus1()>0.1 && hcand.getEtStripPhiSeedMinus1()>0.1) ) return false;
469 
470  //Timing conditions for short eta strips
471  if(hcand.getNbTowersInEta()==3 && hcand.getTimeDiscriminatorITBH()>=0.) return false;
472  if(hcand.getNbTowersInEta()<=6 && hcand.getTimeDiscriminatorITBH()>=5. &&hcand.getTimeDiscriminatorOTBH()<0.) return false;
473 
474  //For HLT, only use conditions without timing
475  if(ishlt && hcand.getNbTowersInEta()<7) return false;
476 
477  hcand.setIsHaloFromPattern(true);
478 
479  return true;
480 }
bool HcalHaloAlgo::HEClusterShapeandTimeStudy ( reco::HaloClusterCandidateHCAL  hcand,
bool  ishlt 
)

Definition at line 484 of file HcalHaloAlgo.cc.

References reco::HaloClusterCandidateHCAL::getH1overH123(), reco::HaloClusterCandidateHCAL::getSeedEt(), reco::HaloClusterCandidateHCAL::getSeedR(), and reco::HaloClusterCandidateHCAL::setIsHaloFromPattern().

Referenced by GetHaloClusterCandidateHE(), and GetPhiWedgeNHitsThreshold().

484  {
485  //Conditions on H1/H123 to spot halo interacting only in one HCAL layer.
486  //For R> about 170cm, HE has only one layer and this condition cannot be applied
487  //Note that for R>170 cm, the halo is in CSC acceptance and will most likely be spotted by the CSC-calo matching method
488  //A method to identify halos interacting in both H1 and H2/H3 at low R is still missing.
489 
490  if(hcand.getSeedEt()<20)return false;
491  if(hcand.getSeedR()>170) return false;
492 
493  if(hcand.getH1overH123()>0.02 &&hcand.getH1overH123()<0.98) return false;
494 
495  //This method is one of the ones with the highest fake rate: in JetHT dataset, it happens in around 0.1% of the cases that a low pt jet (pt= 20) leaves all of its energy in only one HCAL layer.
496  //At HLT, one only cares about large deposits from BH that would lead to a MET/SinglePhoton trigger to be fired.
497  //Rising the seed Et threshold at HLT has therefore little impact on the HLT performances but ensures that possible controversial events are still recorded.
498  if(ishlt && hcand.getSeedEt()<50)return false;
499 
500  hcand.setIsHaloFromPattern(true);
501 
502  return true;
503 
504 }
void HcalHaloAlgo::SetPhiWedgeEnergyThreshold ( float  SumE)
inline

Definition at line 57 of file HcalHaloAlgo.h.

References SumEnergyThreshold.

57 { SumEnergyThreshold = SumE ;}
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:83
void HcalHaloAlgo::SetPhiWedgeNHitsThreshold ( int  nhits)
inline

Definition at line 58 of file HcalHaloAlgo.h.

References nhits, and NHitsThreshold.

void HcalHaloAlgo::SetPhiWedgeThresholds ( float  SumE,
int  nhits 
)
inline

Definition at line 59 of file HcalHaloAlgo.h.

References nhits, NHitsThreshold, and SumEnergyThreshold.

Referenced by reco::HcalHaloDataProducer::produce().

void HcalHaloAlgo::SetRecHitEnergyThresholds ( float  HB,
float  HE 
)
inline

Member Data Documentation

const CaloGeometry* HcalHaloAlgo::geo_
private

Definition at line 86 of file HcalHaloAlgo.h.

Referenced by Calculate(), and getPosition().

float HcalHaloAlgo::HBRecHitEnergyThreshold
private
float HcalHaloAlgo::HERecHitEnergyThreshold
private
const HcalGeometry* HcalHaloAlgo::hgeo_
private

Definition at line 87 of file HcalHaloAlgo.h.

Referenced by Calculate(), and getPosition().

int HcalHaloAlgo::NHitsThreshold
private
float HcalHaloAlgo::SumEnergyThreshold
private