CMS 3D CMS Logo

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

#include <HybridClusterAlgo.h>

Public Member Functions

 HybridClusterAlgo ()
 
 HybridClusterAlgo (double eb_str, int step, double ethres, double eseed, double xi, bool useEtForXi, double ewing, const std::vector< int > &v_chstatus, const PositionCalc &posCalculator, bool dynamicEThres=false, double eThresA=0, double eThresB=0.1, const std::vector< int > &severityToExclude=std::vector< int >().operator=(std::vector< int >(999)), bool excludeFromCluster=false)
 
void mainSearch (const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
 
void makeClusters (const EcalRecHitCollection *, const CaloSubdetectorGeometry *geometry, reco::BasicClusterCollection &basicClusters, const EcalSeverityLevelAlgo *sevLv, bool regional=false, const std::vector< RectangularEtaPhiRegion > &regions=std::vector< RectangularEtaPhiRegion >())
 
double makeDomino (EcalBarrelNavigatorHT &navigator, std::vector< EcalRecHit > &cells)
 
reco::SuperClusterCollection makeSuperClusters (const reco::CaloClusterPtrVector &)
 
void setDynamicPhiRoad (const edm::ParameterSet &bremRecoveryPset)
 
 ~HybridClusterAlgo ()
 

Private Types

typedef math::XYZPoint Point
 

Private Member Functions

double e2Et (EcalBarrelNavigatorHT &navigator, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
 
double et25 (EcalBarrelNavigatorHT &navigator, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
 

Private Attributes

std::map< int, std::vector< reco::BasicCluster > > clustered_
 
bool dynamicEThres_
 
bool dynamicPhiRoad_
 
double eb_st
 
double Eseed
 
double eThres_
 
double eThresA_
 
double eThresB_
 
double Ewing
 
std::set< DetIdexcludedCrys_
 
bool excludeFromCluster_
 
BremRecoveryPhiRoadAlgophiRoadAlgo_
 
int phiSteps_
 
PositionCalc posCalculator_
 
const EcalRecHitCollectionrecHits_
 
std::vector< reco::BasicClusterseedClus_
 
std::vector< EcalRecHitseeds
 
float severityRecHitThreshold_
 
float severitySpikeThreshold_
 
EcalBarrelHardcodedTopologytopo_
 
std::set< DetIduseddetids
 
bool UseEtForXi
 
std::vector< int > v_chstatus_
 
std::vector< int > v_severitylevel_
 
double Xi
 

Detailed Description

Definition at line 27 of file HybridClusterAlgo.h.

Member Typedef Documentation

Definition at line 31 of file HybridClusterAlgo.h.

Constructor & Destructor Documentation

HybridClusterAlgo::HybridClusterAlgo ( )
inline
HybridClusterAlgo::HybridClusterAlgo ( double  eb_str,
int  step,
double  ethres,
double  eseed,
double  xi,
bool  useEtForXi,
double  ewing,
const std::vector< int > &  v_chstatus,
const PositionCalc posCalculator,
bool  dynamicEThres = false,
double  eThresA = 0,
double  eThresB = 0.1,
const std::vector< int > &  severityToExclude = std::vector<int>().operator=(std::vector<int>(999)),
bool  excludeFromCluster = false 
)

Definition at line 16 of file HybridClusterAlgo.cc.

References dynamicEThres_, dynamicPhiRoad_, Eseed, eThresA_, eThresB_, LogTrace, posCalculator_, topo_, UseEtForXi, v_chstatus_, and Xi.

30  :
31 
32  eb_st(eb_str), phiSteps_(step),
33  eThres_(ethres), eThresA_(eThresA), eThresB_(eThresB),
35  dynamicEThres_(dynamicEThres),
36  v_chstatus_(v_chstatus), v_severitylevel_(severityToExclude),
37  //severityRecHitThreshold_(severityRecHitThreshold),
38  //severitySpikeThreshold_(severitySpikeThreshold),
39  excludeFromCluster_(excludeFromCluster)
40 
41 
42 {
43 
44  dynamicPhiRoad_ = false;
45  LogTrace("EcalClusters") << "dynamicEThres: " << dynamicEThres_ << " : A,B " << eThresA_ << ", " << eThresB_;
46  LogTrace("EcalClusters") << "Eseed: " << Eseed << " , Xi: " << Xi << ", UseEtForXi: " << UseEtForXi;
47 
48  //if (dynamicPhiRoad_) phiRoadAlgo_ = new BremRecoveryPhiRoadAlgo(bremRecoveryPset);
49  posCalculator_ = posCalculator;
51 
52  std::sort( v_chstatus_.begin(), v_chstatus_.end() );
53 
54 
55 }
EcalBarrelHardcodedTopology * topo_
PositionCalc posCalculator_
std::vector< int > v_chstatus_
#define LogTrace(id)
std::vector< int > v_severitylevel_
step
Definition: StallMonitor.cc:94
HybridClusterAlgo::~HybridClusterAlgo ( )
inline

Definition at line 141 of file HybridClusterAlgo.h.

References phiRoadAlgo_, and topo_.

142  {
143  if (dynamicPhiRoad_) delete phiRoadAlgo_;
144  delete topo_;
145  // delete SCShape_;
146  }
EcalBarrelHardcodedTopology * topo_
BremRecoveryPhiRoadAlgo * phiRoadAlgo_

Member Function Documentation

double HybridClusterAlgo::e2Et ( EcalBarrelNavigatorHT navigator,
const EcalRecHitCollection hits,
const CaloSubdetectorGeometry geometry 
)
private

Definition at line 667 of file HybridClusterAlgo.cc.

References PositionCalc::Calculate_Location(), PVValHelper::dx, PVValHelper::dy, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), CaloNavigator< T, TOPO >::home(), CaloNavigator< T, TOPO >::offsetBy(), posCalculator_, and recHits_.

Referenced by mainSearch().

670 {
671 
672  DetId thisDet;
673  std::vector< std::pair<DetId, float> > dets;
674  dets.clear();
676 
677  for (int dx = -2; dx < 3; ++dx)
678  {
679  for (int dy = -2; dy < 3; ++ dy)
680  {
681  thisDet = navigator.offsetBy(dx, dy);
682  navigator.home();
683 
684  if (thisDet != DetId(0))
685  {
686  hit = recHits_->find(thisDet);
687  if (hit != recHits_->end())
688  {
689  dets.push_back( std::pair<DetId, float>(thisDet, 1.) ); // by default hit energy fraction is set to 1
690  }
691  }
692  }
693  }
694 
695  // compute coefficient to turn E into Et
696  Point pos = posCalculator_.Calculate_Location(dets, hits, geometry);
697  return 1/cosh(pos.eta());
698 
699 }
std::vector< EcalRecHit >::const_iterator const_iterator
PositionCalc posCalculator_
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
Definition: CaloNavigator.h:80
const_iterator end() const
void home() const
move the navigator back to the starting point
Definition: DetId.h:18
iterator find(key_type k)
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
Definition: PositionCalc.h:68
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:55
const EcalRecHitCollection * recHits_
double HybridClusterAlgo::et25 ( EcalBarrelNavigatorHT navigator,
const EcalRecHitCollection hits,
const CaloSubdetectorGeometry geometry 
)
private

Definition at line 627 of file HybridClusterAlgo.cc.

References PositionCalc::Calculate_Location(), PVValHelper::dx, PVValHelper::dy, edm::SortedCollection< T, SORT >::end(), CastorDataFrameFilter_impl::energySum(), stringResolutionProvider_cfi::et, edm::SortedCollection< T, SORT >::find(), CaloNavigator< T, TOPO >::home(), CaloNavigator< T, TOPO >::offsetBy(), posCalculator_, and recHits_.

Referenced by mainSearch().

630 {
631 
632  DetId thisDet;
633  std::vector< std::pair<DetId, float> > dets;
634  dets.clear();
636  double energySum = 0.0;
637 
638  for (int dx = -2; dx < 3; ++dx)
639  {
640  for (int dy = -2; dy < 3; ++ dy)
641  {
642  //std::cout << "dx, dy " << dx << ", " << dy << std::endl;
643  thisDet = navigator.offsetBy(dx, dy);
644  navigator.home();
645 
646  if (thisDet != DetId(0))
647  {
648  hit = recHits_->find(thisDet);
649  if (hit != recHits_->end())
650  {
651  dets.push_back( std::pair<DetId, float>(thisDet, 1.) ); // by default hit energy fraction is set to 1
652  energySum += hit->energy();
653  }
654  }
655  }
656  }
657 
658  // convert it to ET
659  //std::cout << "dets.size(), energySum: " << dets.size() << ", " << energySum << std::endl;
660  Point pos = posCalculator_.Calculate_Location(dets, hits, geometry);
661  double et = energySum/cosh(pos.eta());
662  return et;
663 
664 }
std::vector< EcalRecHit >::const_iterator const_iterator
PositionCalc posCalculator_
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
Definition: CaloNavigator.h:80
const_iterator end() const
void home() const
move the navigator back to the starting point
Definition: DetId.h:18
et
define resolution functions of each parameter
iterator find(key_type k)
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
Definition: PositionCalc.h:68
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:55
const EcalRecHitCollection * recHits_
double energySum(const DataFrame &df, int fs, int ls)
void HybridClusterAlgo::mainSearch ( const EcalRecHitCollection hits,
const CaloSubdetectorGeometry geometry 
)

Definition at line 182 of file HybridClusterAlgo.cc.

References BremRecoveryPhiRoadAlgo::barrelPhiRoad(), PositionCalc::Calculate_Location(), clustered_, reco::CaloID::DET_ECAL_BARREL, dynamicEThres_, dynamicPhiRoad_, e2Et(), Eseed, et25(), eThres_, eThresA_, eThresB_, CaloNavigator< T, TOPO >::home(), reco::CaloCluster::hybrid, mps_fire::i, createfilelist::int, gen::k, LogTrace, makeDomino(), particleFlowRecHitECAL_cfi::navigator, nhits, CaloNavigator< T, TOPO >::north(), DetId::null(), phiRoadAlgo_, phiSteps_, posCalculator_, seedClus_, seeds, CaloNavigator< T, TOPO >::south(), mathSSE::sqrt(), groupFilesInBlocks::temp, topo_, useddetids, UseEtForXi, and Xi.

Referenced by makeClusters(), and setDynamicPhiRoad().

183 {
184  LogTrace("EcalClusters") << "HybridClusterAlgo Algorithm - looking for clusters" ;
185  LogTrace("EcalClusters") << "Found the following clusters:" ;
186 
187  // Loop over seeds:
188  std::vector<EcalRecHit>::iterator it;
189  int clustercounter=0;
190 
191  for (it = seeds.begin(); it != seeds.end(); it++){
192  std::vector <reco::BasicCluster> thisseedClusters;
193  DetId itID = it->id();
194 
195  // make sure the current seed has not been used/will not be used in the future:
196  std::set<DetId>::iterator seed_in_rechits_it = useddetids.find(itID);
197 
198  if (seed_in_rechits_it != useddetids.end()) continue;
199  //If this seed is already used, then don't use it again.
200 
201  // output some info on the hit:
202  LogTrace("EcalClusters") << "*****************************************************" << "Seed of energy E = " << it->energy() << " @ " << EBDetId(itID) << "*****************************************************" ;
203 
204 
205  //Make a navigator, and set it to the seed cell.
207 
208  //Now use the navigator to start building dominoes.
209 
210  //Walking positive in phi:
211  std::vector <double> dominoEnergyPhiPlus; //Here I will store the results of the domino sums
212  std::vector <std::vector <EcalRecHit> > dominoCellsPhiPlus; //These are the actual EcalRecHit for dominos.
213 
214  //Walking negative in phi
215  std::vector <double> dominoEnergyPhiMinus; //Here I will store the results of the domino sums
216  std::vector <std::vector <EcalRecHit> > dominoCellsPhiMinus; //These are the actual EcalRecHit for dominos.
217 
218  //The two sets together.
219  std::vector <double> dominoEnergy; //Here I will store the results of the domino sums
220  std::vector <std::vector <EcalRecHit> > dominoCells; //These are the actual EcalRecHit for dominos.
221 
222  //First, the domino about the seed:
223  std::vector <EcalRecHit> initialdomino;
224  double e_init = makeDomino(navigator, initialdomino);
225  if (e_init < Eseed) continue;
226 
227  LogTrace("EcalClusters") << "Made initial domino" ;
228 
229  //
230  // compute the phi road length
231  double phiSteps;
232  double et5x5 = et25(navigator, hits, geometry);
233  if (dynamicPhiRoad_ && e_init > 0)
234  {
235  phiSteps = phiRoadAlgo_->barrelPhiRoad(et5x5);
236  navigator.home();
237  } else phiSteps = phiSteps_;
238 
239  //Positive phi steps.
240  for (int i=0;i<phiSteps;++i){
241  //remember, this always increments the current position of the navigator.
242  DetId centerD = navigator.north();
243  if (centerD.null())
244  continue;
245  LogTrace("EcalClusters") << "Step ++" << i << " @ " << EBDetId(centerD) ;
246  EcalBarrelNavigatorHT dominoNav(centerD, topo_);
247 
248  //Go get the new domino.
249  std::vector <EcalRecHit> dcells;
250  double etemp = makeDomino(dominoNav, dcells);
251 
252  //save this information
253  dominoEnergyPhiPlus.push_back(etemp);
254  dominoCellsPhiPlus.push_back(dcells);
255  }
256  LogTrace("EcalClusters") << "Got positive dominos" ;
257  //return to initial position
258  navigator.home();
259 
260  //Negative phi steps.
261  for (int i=0;i<phiSteps;++i){
262  //remember, this always decrements the current position of the navigator.
263  DetId centerD = navigator.south();
264  if (centerD.null())
265  continue;
266 
267  LogTrace("EcalClusters") << "Step --" << i << " @ " << EBDetId(centerD) ;
268  EcalBarrelNavigatorHT dominoNav(centerD, topo_);
269 
270  //Go get the new domino.
271  std::vector <EcalRecHit> dcells;
272  double etemp = makeDomino(dominoNav, dcells);
273 
274  //save this information
275  dominoEnergyPhiMinus.push_back(etemp);
276  dominoCellsPhiMinus.push_back(dcells);
277  }
278 
279  LogTrace("EcalClusters") << "Got negative dominos: " ;
280 
281  //Assemble this information:
282  for (int i=int(dominoEnergyPhiMinus.size())-1;i >= 0;--i){
283  dominoEnergy.push_back(dominoEnergyPhiMinus[i]);
284  dominoCells.push_back(dominoCellsPhiMinus[i]);
285  }
286  dominoEnergy.push_back(e_init);
287  dominoCells.push_back(initialdomino);
288  for (int i=0;i<int(dominoEnergyPhiPlus.size());++i){
289  dominoEnergy.push_back(dominoEnergyPhiPlus[i]);
290  dominoCells.push_back(dominoCellsPhiPlus[i]);
291  }
292 
293  //Ok, now I have all I need in order to go ahead and make clusters.
294  LogTrace("EcalClusters") << "Dumping domino energies: " ;
295 
296 
297  //for (int i=0;i<int(dominoEnergy.size());++i){
298  // LogTrace("EcalClusters") << "Domino: " << i << " E: " << dominoEnergy[i] ;
299  // }
300  //Identify the peaks in this set of dominos:
301  //Peak==a domino whose energy is greater than the two adjacent dominos.
302  //thus a peak in the local sense.
303  double etToE(1.);
304  if(!UseEtForXi){
305  etToE = 1./e2Et(navigator, hits, geometry);
306  }
307  std::vector <int> PeakIndex;
308  for (int i=1;i<int(dominoEnergy.size())-1;++i){
309  if (dominoEnergy[i] > dominoEnergy[i-1]
310  && dominoEnergy[i] >= dominoEnergy[i+1]
311  && dominoEnergy[i] > sqrt( Eseed*Eseed + Xi*Xi*et5x5*et5x5*etToE*etToE) )
312  { // Eseed increases ~proportiaonally to et5x5
313  PeakIndex.push_back(i);
314  }
315  }
316 
317  LogTrace("EcalClusters") << "Found: " << PeakIndex.size() << " peaks." ;
318 
319  //Order these peaks by energy:
320  for (int i=0;i<int(PeakIndex.size());++i){
321  for (int j=0;j<int(PeakIndex.size())-1;++j){
322  if (dominoEnergy[PeakIndex[j]] < dominoEnergy[PeakIndex[j+1]]){
323  int ihold = PeakIndex[j+1];
324  PeakIndex[j+1] = PeakIndex[j];
325  PeakIndex[j] = ihold;
326  }
327  }
328  }
329 
330  std::vector<int> OwnerShip;
331  std::vector<double> LumpEnergy;
332  for (int i=0;i<int(dominoEnergy.size());++i) OwnerShip.push_back(-1);
333 
334  //Loop over peaks.
335  double eThres = eThres_;
336  double e5x5 = 0.0;
337  for (int i = 0; i < int(PeakIndex.size()); ++i)
338  {
339 
340  int idxPeak = PeakIndex[i];
341  OwnerShip[idxPeak] = i;
342  double lump = dominoEnergy[idxPeak];
343 
344  // compute eThres for this peak
345  // if set to dynamic (otherwise uncanged from
346  // fixed setting
347  if (dynamicEThres_) {
348 
349  //std::cout << "i : " << i << " idxPeak " << idxPeak << std::endl;
350  //std::cout << " the dominoEnergy.size() = " << dominoEnergy.size() << std::endl;
351  // compute e5x5 for this seed crystal
352  //std::cout << "idxPeak, phiSteps " << idxPeak << ", " << phiSteps << std::endl;
353  e5x5 = lump;
354  //std::cout << "lump " << e5x5 << std::endl;
355  if ((idxPeak + 1) < (int)dominoEnergy.size()) e5x5 += dominoEnergy[idxPeak + 1];
356  //std::cout << "+1 " << e5x5 << std::endl;
357  if ((idxPeak + 2) < (int)dominoEnergy.size()) e5x5 += dominoEnergy[idxPeak + 2];
358  //std::cout << "+2 " << e5x5 << std::endl;
359  if ((idxPeak - 1) > 0) e5x5 += dominoEnergy[idxPeak - 1];
360  //std::cout << "-1 " << e5x5 << std::endl;
361  if ((idxPeak - 2) > 0) e5x5 += dominoEnergy[idxPeak - 2];
362  //std::cout << "-2 " << e5x5 << std::endl;
363  // compute eThres
364  eThres = (eThresA_ * e5x5) + eThresB_;
365  //std::cout << eThres << std::endl;
366  //std::cout << std::endl;
367  }
368 
369  //Loop over adjacent dominos at higher phi
370  for (int j=idxPeak+1;j<int(dominoEnergy.size());++j){
371  if (OwnerShip[j]==-1 &&
372  dominoEnergy[j] > eThres
373  && dominoEnergy[j] <= dominoEnergy[j-1]){
374  OwnerShip[j]= i;
375  lump+=dominoEnergy[j];
376  }
377  else{
378  break;
379  }
380  }
381  //loop over adjacent dominos at lower phi. Sum up energy of lumps.
382  for (int j=idxPeak-1;j>=0;--j){
383  if (OwnerShip[j]==-1 &&
384  dominoEnergy[j] > eThres
385  && dominoEnergy[j] <= dominoEnergy[j+1]){
386  OwnerShip[j]= i;
387  lump+=dominoEnergy[j];
388  }
389  else{
390  break;
391  }
392  }
393  LumpEnergy.push_back(lump);
394  }
395 
396  //Make the basic clusters:
397  for (int i=0;i<int(PeakIndex.size());++i){
398  bool HasSeedCrystal = false;
399  //One cluster for each peak.
400  std::vector<EcalRecHit> recHits;
401  std::vector< std::pair<DetId, float> > dets;
402  int nhits=0;
403  for (int j=0;j<int(dominoEnergy.size());++j){
404  if (OwnerShip[j] == i){
405  std::vector <EcalRecHit> temp = dominoCells[j];
406  for (int k=0;k<int(temp.size());++k){
407  dets.push_back( std::pair<DetId, float>(temp[k].id(), 1.) ); // by default energy fractions are 1
408  if (temp[k].id()==itID)
409  HasSeedCrystal = true;
410  recHits.push_back(temp[k]);
411  nhits++;
412  }
413  }
414  }
415  LogTrace("EcalClusters") << "Adding a cluster with: " << nhits;
416  LogTrace("EcalClusters") << "total E: " << LumpEnergy[i];
417  LogTrace("EcalClusters") << "total dets: " << dets.size() ;
418 
419  //Get Calorimeter position
420  Point pos = posCalculator_.Calculate_Location(dets,hits,geometry);
421 
422  //double totChi2=0;
423  //double totE=0;
424  std::vector<std::pair<DetId, float> > usedHits;
425  for (int blarg=0;blarg<int(recHits.size());++blarg){
426  //totChi2 +=0;
427  //totE+=recHits[blarg].energy();
428  usedHits.push_back(std::make_pair<DetId, float>(recHits[blarg].id(), 1.0));
429  useddetids.insert(recHits[blarg].id());
430  }
431 
432  //if (totE>0)
433  //totChi2/=totE;
434 
435  if (HasSeedCrystal) {
436  // note that this "basiccluster" has the seed crystal of the hyrbid, so record it
437  seedClus_.push_back(reco::BasicCluster(LumpEnergy[i], pos,
440  // and also add to the vector of clusters that will be used in constructing
441  // the supercluster
442  thisseedClusters.push_back(reco::BasicCluster(LumpEnergy[i], pos, reco::CaloID(reco::CaloID::DET_ECAL_BARREL),
443  usedHits, reco::CaloCluster::hybrid, itID));
444  }
445  else {
446  // note that if this "basiccluster" is not the one that seeded the hybrid,
447  // the seed crystal is unset in this entry in the vector of clusters that will
448  // be used in constructing the super cluster
449  thisseedClusters.push_back(reco::BasicCluster(LumpEnergy[i], pos, reco::CaloID(reco::CaloID::DET_ECAL_BARREL),
450  usedHits, reco::CaloCluster::hybrid));
451  }
452  }
453 
454 
455  // Make association so that superclusters can be made later.
456  // but only if some BasicClusters have been found...
457  if (!thisseedClusters.empty())
458  {
459  clustered_.insert(std::make_pair(clustercounter, thisseedClusters));
460  clustercounter++;
461  }
462  }//Seed loop
463 
464 }// end of mainSearch
constexpr bool null() const
is this a null id ?
Definition: DetId.h:52
EcalBarrelHardcodedTopology * topo_
std::map< int, std::vector< reco::BasicCluster > > clustered_
double e2Et(EcalBarrelNavigatorHT &navigator, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
PositionCalc posCalculator_
std::vector< EcalRecHit > seeds
T sqrt(T t)
Definition: SSEVec.h:18
BremRecoveryPhiRoadAlgo * phiRoadAlgo_
std::set< DetId > useddetids
double et25(EcalBarrelNavigatorHT &navigator, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
#define LogTrace(id)
int k[5][pyjets_maxn]
Definition: DetId.h:18
double makeDomino(EcalBarrelNavigatorHT &navigator, std::vector< EcalRecHit > &cells)
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
Definition: PositionCalc.h:68
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:55
std::vector< reco::BasicCluster > seedClus_
void HybridClusterAlgo::makeClusters ( const EcalRecHitCollection recColl,
const CaloSubdetectorGeometry geometry,
reco::BasicClusterCollection basicClusters,
const EcalSeverityLevelAlgo sevLv,
bool  regional = false,
const std::vector< RectangularEtaPhiRegion > &  regions = std::vector<RectangularEtaPhiRegion>() 
)

Definition at line 58 of file HybridClusterAlgo.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), edm::SortedCollection< T, SORT >::begin(), clustered_, eb_st, edm::SortedCollection< T, SORT >::end(), ET, excludedCrys_, excludeFromCluster_, spr::find(), CaloSubdetectorGeometry::getGeometry(), createfilelist::int, isClusterEtLess(), EcalRecHit::kGood, LogTrace, mainSearch(), Basic3DVector< T >::perp(), position, recHits_, seedClus_, seeds, EcalSeverityLevelAlgo::severityLevel(), Basic3DVector< T >::unit(), useddetids, v_chstatus_, v_severitylevel_, x, and y.

Referenced by EgammaHLTHybridClusterProducer::produce(), HybridClusterProducer::produce(), and setDynamicPhiRoad().

65 {
66  //clear vector of seeds
67  seeds.clear();
68  //clear flagged crystals
69  excludedCrys_.clear();
70  //clear map of supercluster/basiccluster association
71  clustered_.clear();
72  //clear set of used detids
73  useddetids.clear();
74  //clear vector of seed clusters
75  seedClus_.clear();
76  //Pass in a pointer to the collection.
77  recHits_ = recColl;
78 
79  LogTrace("EcalClusters") << "Cleared vectors, starting clusterization..." ;
80  LogTrace("EcalClusters") << " Purple monkey aardvark." ;
81  //
82 
83  int nregions=0;
84  if(regional) nregions=regions.size();
85 
86  if(!regional || nregions) {
87 
89 
90  for (it = recHits_->begin(); it != recHits_->end(); it++){
91 
92  //Make the vector of seeds that we're going to use.
93  //One of the few places position is used, needed for ET calculation.
94  auto this_cell = geometry->getGeometry(it->id());
95  const GlobalPoint& position = this_cell->getPosition();
96 
97 
98  // Require that RecHit is within clustering region in case
99  // of regional reconstruction
100  bool withinRegion = false;
101  if (regional) {
102  std::vector<RectangularEtaPhiRegion>::const_iterator region;
103  for (region=regions.begin(); region!=regions.end(); region++) {
104  if (region->inRegion(this_cell->etaPos(),this_cell->phiPos())) {
105  withinRegion = true;
106  break;
107  }
108  }
109  }
110 
111  if (!regional || withinRegion) {
112 
113  //Must pass seed threshold
114  float ET = it->energy() * position.basicVector().unit().perp();
115 
116  LogTrace("EcalClusters") << "Seed crystal: " ;
117 
118  if (ET > eb_st) {
119 
120 
121  // avoid seeding for anomalous channels
122  if(! it->checkFlag(EcalRecHit::kGood)){ // if rechit is good, no need for further checks
123  if (it->checkFlags( v_chstatus_ )) {
124  if (excludeFromCluster_) excludedCrys_.insert(it->id());
125  continue; // the recHit has to be excluded from seeding
126  }
127  }
128 
129 
130  int severityFlag = sevLv->severityLevel( it->id(), *recHits_);
131  std::vector<int>::const_iterator sit = std::find( v_severitylevel_.begin(), v_severitylevel_.end(), severityFlag);
132  LogTrace("EcalClusters") << "found flag: " << severityFlag ;
133 
134 
135  if (sit!=v_severitylevel_.end()){
137  excludedCrys_.insert(it->id());
138  continue;
139  }
140  seeds.push_back(*it);
141 
142  LogTrace("EcalClusters") << "Seed ET: " << ET ;
143  LogTrace("EcalClsuters") << "Seed E: " << it->energy() ;
144  }
145  }
146  }
147 
148  }
149 
150 
151  //Yay sorting.
152  LogTrace("EcalClusters") << "Built vector of seeds, about to sort them..." ;
153 
154  //Needs three argument sort with seed comparison operator
155  sort(seeds.begin(), seeds.end(), [](auto const& x, auto const& y) { return x.energy() > y.energy() ; });
156 
157  LogTrace("EcalClusters") << "done" ;
158 
159  //Now to do the work.
160  LogTrace("EcalClusters") << "About to call mainSearch...";
161  mainSearch(recColl,geometry);
162  LogTrace("EcalClusters") << "done" ;
163 
164  //Hand the basicclusters back to the producer. It has to
165  //put them in the event. Then we can make superclusters.
166  std::map<int, reco::BasicClusterCollection>::iterator bic;
167  for (bic= clustered_.begin();bic!=clustered_.end();bic++){
168  reco::BasicClusterCollection bl = bic->second;
169  for (int j=0;j<int(bl.size());++j){
170  basicClusters.push_back(bl[j]);
171  }
172  }
173 
174  //Yay more sorting.
175  sort(basicClusters.rbegin(), basicClusters.rend(), isClusterEtLess );
176  //Done!
177  LogTrace("EcalClusters") << "returning to producer. ";
178 
179 }
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
void mainSearch(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
Basic3DVector unit() const
std::map< int, std::vector< reco::BasicCluster > > clustered_
std::vector< EcalRecHit >::const_iterator const_iterator
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< EcalRecHit > seeds
std::vector< int > v_chstatus_
bool isClusterEtLess(const reco::CaloCluster &x, const reco::CaloCluster &y)
Definition: ClusterEtLess.h:7
std::set< DetId > useddetids
T perp() const
Magnitude of transverse component.
#define LogTrace(id)
std::set< DetId > excludedCrys_
const_iterator end() const
std::vector< int > v_severitylevel_
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.
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
static int position[264][3]
Definition: ReadPGInfo.cc:509
const EcalRecHitCollection * recHits_
#define ET
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
std::vector< reco::BasicCluster > seedClus_
const_iterator begin() const
double HybridClusterAlgo::makeDomino ( EcalBarrelNavigatorHT navigator,
std::vector< EcalRecHit > &  cells 
)

Definition at line 543 of file HybridClusterAlgo.cc.

References CaloNavigator< T, TOPO >::east(), edm::SortedCollection< T, SORT >::end(), EcalRecHit::energy(), Ewing, excludedCrys_, edm::SortedCollection< T, SORT >::find(), CaloNavigator< T, TOPO >::home(), CaloNavigator< T, TOPO >::pos(), recHits_, useddetids, and CaloNavigator< T, TOPO >::west().

Referenced by mainSearch(), and setDynamicPhiRoad().

544 {
545  //At the beginning of this function, the navigator starts at the middle of the domino,
546  //and that's where EcalBarrelNavigator::home() should send it.
547  //Walk one crystal in eta to either side of the initial point. Sum the three cell energies.
548  //If the resultant energy is larger than Ewing, then go an additional cell to either side.
549  //Returns: Total domino energy. Also, stores the cells used to create domino in the vector.
550  cells.clear();
551  double Etot = 0;
552 
553  //Ready? Get the starting cell.
554  DetId center = navigator.pos();
556 
557  if (center_it!=recHits_->end()){
558  EcalRecHit SeedHit = *center_it;
559  if (useddetids.find(center) == useddetids.end() && excludedCrys_.find(center)==excludedCrys_.end()){
560  Etot += SeedHit.energy();
561  cells.push_back(SeedHit);
562  }
563  }
564  //One step upwards in Ieta:
565  DetId ieta1 = navigator.west();
567  if (eta1_it !=recHits_->end()){
568  EcalRecHit UpEta = *eta1_it;
569  if (useddetids.find(ieta1) == useddetids.end() && excludedCrys_.find(ieta1)==excludedCrys_.end()){
570  Etot+=UpEta.energy();
571  cells.push_back(UpEta);
572  }
573  }
574 
575  //Go back to the middle.
576  navigator.home();
577 
578  //One step downwards in Ieta:
579  DetId ieta2 = navigator.east();
581  if (eta2_it !=recHits_->end()){
582  EcalRecHit DownEta = *eta2_it;
583  if (useddetids.find(ieta2)==useddetids.end() && excludedCrys_.find(ieta2)==excludedCrys_.end()){
584  Etot+=DownEta.energy();
585  cells.push_back(DownEta);
586  }
587  }
588 
589  //Now check the energy. If smaller than Ewing, then we're done. If greater than Ewing, we have to
590  //add two additional cells, the 'wings'
591  if (Etot < Ewing) {
592  navigator.home(); //Needed even here!!
593  return Etot; //Done! Not adding 'wings'.
594  }
595 
596  //Add the extra 'wing' cells. Remember, we haven't sent the navigator home,
597  //we're still on the DownEta cell.
598  if (ieta2 != DetId(0)){
599  DetId ieta3 = navigator.east(); //Take another step downward.
601  if (eta3_it != recHits_->end()){
602  EcalRecHit DownEta2 = *eta3_it;
603  if (useddetids.find(ieta3)==useddetids.end() && excludedCrys_.find(ieta3)==excludedCrys_.end()){
604  Etot+=DownEta2.energy();
605  cells.push_back(DownEta2);
606  }
607  }
608  }
609  //Now send the navigator home.
610  navigator.home();
611  navigator.west(); //Now you're on eta1_it
612  if (ieta1 != DetId(0)){
613  DetId ieta4 = navigator.west(); //Take another step upward.
615  if (eta4_it != recHits_->end()){
616  EcalRecHit UpEta2 = *eta4_it;
617  if (useddetids.find(ieta4) == useddetids.end() && excludedCrys_.find(ieta4)==excludedCrys_.end()){
618  Etot+=UpEta2.energy();
619  cells.push_back(UpEta2);
620  }
621  }
622  }
623  navigator.home();
624  return Etot;
625 }
std::vector< EcalRecHit >::const_iterator const_iterator
T west() const
move the navigator west
Definition: CaloNavigator.h:59
float energy() const
Definition: EcalRecHit.h:68
std::set< DetId > useddetids
T pos() const
get the current position
Definition: CaloNavigator.h:32
std::set< DetId > excludedCrys_
const_iterator end() const
T east() const
move the navigator east
Definition: CaloNavigator.h:52
void home() const
move the navigator back to the starting point
Definition: DetId.h:18
iterator find(key_type k)
const EcalRecHitCollection * recHits_
reco::SuperClusterCollection HybridClusterAlgo::makeSuperClusters ( const reco::CaloClusterPtrVector clustersCollection)

Definition at line 466 of file HybridClusterAlgo.cc.

References clustered_, reco::CaloCluster::energy(), mps_fire::i, createfilelist::int, isClusterEtLess(), LogTrace, RecoTauValidation_cfi::posX, RecoTauValidation_cfi::posY, edm::PtrVector< T >::push_back(), SurveyInfoScenario_cff::seed, seedClus_, and edm::PtrVectorBase::size().

Referenced by EgammaHLTHybridClusterProducer::produce(), HybridClusterProducer::produce(), and setDynamicPhiRoad().

467 {
468  //Here's what we'll return.
470 
471  //Here's our map iterator that gives us the appropriate association.
472  std::map<int, reco::BasicClusterCollection>::iterator mapit;
473  for (mapit = clustered_.begin();mapit!=clustered_.end();mapit++){
474 
476  reco::CaloClusterPtr seed;//This is not really a seed, but I need to tell SuperCluster something.
477  //So I choose the highest energy basiccluster in the SuperCluster.
478 
479  std::vector <reco::BasicCluster> thiscoll = mapit->second; //This is the set of BasicClusters in this
480  //SuperCluster
481 
482  double ClusterE = 0; //Sum of cluster energies for supercluster.
483  //Holders for position of this supercluster.
484  double posX=0;
485  double posY=0;
486  double posZ=0;
487 
488  //Loop over this set of basic clusters, find their references, and add them to the
489  //supercluster. This could be somehow more efficient.
490 
491  for (int i=0;i<int(thiscoll.size());++i){
492  reco::BasicCluster thisclus = thiscoll[i]; //The Cluster in question.
493  for (int j=0;j<int(clustersCollection.size());++j){
494  //Find the appropriate cluster from the list of references
495  reco::BasicCluster cluster_p = *clustersCollection[j];
496  if (thisclus== cluster_p){ //Comparison based on energy right now.
497  thissc.push_back(clustersCollection[j]);
498  bool isSeed = false;
499  for (int qu=0;qu<int(seedClus_.size());++qu){
500  if (cluster_p == seedClus_[qu])
501  isSeed = true;
502  }
503  if (isSeed) seed = clustersCollection[j];
504 
505  ClusterE += cluster_p.energy();
506  posX += cluster_p.energy() * cluster_p.position().X();
507  posY += cluster_p.energy() * cluster_p.position().Y();
508  posZ += cluster_p.energy() * cluster_p.position().Z();
509 
510  }
511  }//End loop over finding references.
512  }//End loop over clusters.
513 
514  posX /= ClusterE;
515  posY /= ClusterE;
516  posZ /= ClusterE;
517 
518  /* //This part is moved to EgammaSCEnergyCorrectionAlgo
519  double preshowerE = 0.;
520  double phiWidth = 0.;
521  double etaWidth = 0.;
522  //Calculate phiWidth & etaWidth for SuperClusters
523  reco::SuperCluster suCl(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, preshowerE, phiWidth, etaWidth);
524  SCShape_->Calculate_Covariances(suCl);
525  phiWidth = SCShape_->phiWidth();
526  etaWidth = SCShape_->etaWidth();
527  //Assign phiWidth & etaWidth to SuperCluster as data members
528  suCl.setPhiWidth(phiWidth);
529  suCl.setEtaWidth(etaWidth);
530  */
531 
532  reco::SuperCluster suCl(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc);
533  SCcoll.push_back(suCl);
534 
535  LogTrace("EcalClusters") << "Super cluster sum: " << ClusterE ;
536  LogTrace("EcalClusters") << "Made supercluster with energy E: " << suCl.energy() ;
537 
538  }//end loop over map
539  sort(SCcoll.rbegin(), SCcoll.rend(), isClusterEtLess);
540  return SCcoll;
541 }
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:74
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
std::map< int, std::vector< reco::BasicCluster > > clustered_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
bool isClusterEtLess(const reco::CaloCluster &x, const reco::CaloCluster &y)
Definition: ClusterEtLess.h:7
#define LogTrace(id)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< reco::BasicCluster > seedClus_
void HybridClusterAlgo::setDynamicPhiRoad ( const edm::ParameterSet bremRecoveryPset)
inline

Member Data Documentation

std::map<int, std::vector<reco::BasicCluster> > HybridClusterAlgo::clustered_
private

Definition at line 98 of file HybridClusterAlgo.h.

Referenced by mainSearch(), makeClusters(), and makeSuperClusters().

bool HybridClusterAlgo::dynamicEThres_
private

Definition at line 74 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

bool HybridClusterAlgo::dynamicPhiRoad_
private

Definition at line 71 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

double HybridClusterAlgo::eb_st
private

Definition at line 34 of file HybridClusterAlgo.h.

Referenced by makeClusters().

double HybridClusterAlgo::Eseed
private

Definition at line 59 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

double HybridClusterAlgo::eThres_
private

Definition at line 54 of file HybridClusterAlgo.h.

Referenced by mainSearch().

double HybridClusterAlgo::eThresA_
private

Definition at line 55 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

double HybridClusterAlgo::eThresB_
private

Definition at line 56 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

double HybridClusterAlgo::Ewing
private

Definition at line 68 of file HybridClusterAlgo.h.

Referenced by makeDomino().

std::set<DetId> HybridClusterAlgo::excludedCrys_
private

Definition at line 112 of file HybridClusterAlgo.h.

Referenced by makeClusters(), and makeDomino().

bool HybridClusterAlgo::excludeFromCluster_
private

Definition at line 111 of file HybridClusterAlgo.h.

Referenced by makeClusters().

BremRecoveryPhiRoadAlgo* HybridClusterAlgo::phiRoadAlgo_
private

Definition at line 51 of file HybridClusterAlgo.h.

Referenced by mainSearch(), and ~HybridClusterAlgo().

int HybridClusterAlgo::phiSteps_
private

Definition at line 39 of file HybridClusterAlgo.h.

Referenced by mainSearch().

PositionCalc HybridClusterAlgo::posCalculator_
private

Definition at line 101 of file HybridClusterAlgo.h.

Referenced by e2Et(), et25(), HybridClusterAlgo(), and mainSearch().

const EcalRecHitCollection* HybridClusterAlgo::recHits_
private

Definition at line 81 of file HybridClusterAlgo.h.

Referenced by e2Et(), et25(), makeClusters(), and makeDomino().

std::vector<reco::BasicCluster> HybridClusterAlgo::seedClus_
private

Definition at line 95 of file HybridClusterAlgo.h.

Referenced by mainSearch(), makeClusters(), and makeSuperClusters().

std::vector<EcalRecHit> HybridClusterAlgo::seeds
private

Definition at line 92 of file HybridClusterAlgo.h.

Referenced by mainSearch(), and makeClusters().

float HybridClusterAlgo::severityRecHitThreshold_
private

Definition at line 108 of file HybridClusterAlgo.h.

float HybridClusterAlgo::severitySpikeThreshold_
private

Definition at line 109 of file HybridClusterAlgo.h.

EcalBarrelHardcodedTopology* HybridClusterAlgo::topo_
private

Definition at line 84 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), mainSearch(), and ~HybridClusterAlgo().

std::set<DetId> HybridClusterAlgo::useddetids
private

Definition at line 89 of file HybridClusterAlgo.h.

Referenced by mainSearch(), makeClusters(), and makeDomino().

bool HybridClusterAlgo::UseEtForXi
private

Definition at line 65 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

std::vector<int> HybridClusterAlgo::v_chstatus_
private

Definition at line 104 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and makeClusters().

std::vector<int> HybridClusterAlgo::v_severitylevel_
private

Definition at line 107 of file HybridClusterAlgo.h.

Referenced by makeClusters().

double HybridClusterAlgo::Xi
private

Definition at line 62 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().