CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >())
 
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 33 of file HybridClusterAlgo.h.

Member Typedef Documentation

Definition at line 37 of file HybridClusterAlgo.h.

Constructor & Destructor Documentation

HybridClusterAlgo::HybridClusterAlgo ( )
inline

Definition at line 123 of file HybridClusterAlgo.h.

123 { }
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 15 of file HybridClusterAlgo.cc.

References dynamicEThres_, dynamicPhiRoad_, Eseed, eThresA_, eThresB_, LogTrace, posCalculator_, python.multivaluedict::sort(), topo_, UseEtForXi, v_chstatus_, and Xi.

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

Definition at line 147 of file HybridClusterAlgo.h.

References dynamicPhiRoad_, phiRoadAlgo_, and topo_.

148  {
149  if (dynamicPhiRoad_) delete phiRoadAlgo_;
150  delete topo_;
151  // delete SCShape_;
152  }
EcalBarrelHardcodedTopology * topo_
BremRecoveryPhiRoadAlgo * phiRoadAlgo_

Member Function Documentation

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

Definition at line 666 of file HybridClusterAlgo.cc.

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

Referenced by mainSearch().

669 {
670 
671  DetId thisDet;
672  std::vector< std::pair<DetId, float> > dets;
673  dets.clear();
675 
676  for (int dx = -2; dx < 3; ++dx)
677  {
678  for (int dy = -2; dy < 3; ++ dy)
679  {
680  thisDet = navigator.offsetBy(dx, dy);
681  navigator.home();
682 
683  if (thisDet != DetId(0))
684  {
685  hit = recHits_->find(thisDet);
686  if (hit != recHits_->end())
687  {
688  dets.push_back( std::pair<DetId, float>(thisDet, 1.) ); // by default hit energy fraction is set to 1
689  }
690  }
691  }
692  }
693 
694  // compute coefficient to turn E into Et
695  Point pos = posCalculator_.Calculate_Location(dets, hits, geometry);
696  return 1/cosh(pos.eta());
697 
698 }
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
math::XYZPoint Point
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
const EcalRecHitCollection * recHits_
double HybridClusterAlgo::et25 ( EcalBarrelNavigatorHT navigator,
const EcalRecHitCollection hits,
const CaloSubdetectorGeometry geometry 
)
private

Definition at line 626 of file HybridClusterAlgo.cc.

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

Referenced by mainSearch().

629 {
630 
631  DetId thisDet;
632  std::vector< std::pair<DetId, float> > dets;
633  dets.clear();
635  double energySum = 0.0;
636 
637  for (int dx = -2; dx < 3; ++dx)
638  {
639  for (int dy = -2; dy < 3; ++ dy)
640  {
641  //std::cout << "dx, dy " << dx << ", " << dy << std::endl;
642  thisDet = navigator.offsetBy(dx, dy);
643  navigator.home();
644 
645  if (thisDet != DetId(0))
646  {
647  hit = recHits_->find(thisDet);
648  if (hit != recHits_->end())
649  {
650  dets.push_back( std::pair<DetId, float>(thisDet, 1.) ); // by default hit energy fraction is set to 1
651  energySum += hit->energy();
652  }
653  }
654  }
655  }
656 
657  // convert it to ET
658  //std::cout << "dets.size(), energySum: " << dets.size() << ", " << energySum << std::endl;
659  Point pos = posCalculator_.Calculate_Location(dets, hits, geometry);
660  double et = energySum/cosh(pos.eta());
661  return et;
662 
663 }
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
math::XYZPoint Point
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
const EcalRecHitCollection * recHits_
double energySum(const DataFrame &df, int fs, int ls)
void HybridClusterAlgo::mainSearch ( const EcalRecHitCollection hits,
const CaloSubdetectorGeometry geometry 
)

Definition at line 181 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, i, j, relval_steps::k, LogTrace, makeDomino(), HLT_25ns14e33_v1_cff::navigator, nhits, CaloNavigator< T, TOPO >::north(), DetId::null(), phiRoadAlgo_, phiSteps_, posCalculator_, HLT_25ns14e33_v3_cff::recHits, seedClus_, seeds, CaloNavigator< T, TOPO >::south(), mathSSE::sqrt(), groupFilesInBlocks::temp, topo_, useddetids, UseEtForXi, and Xi.

Referenced by makeClusters().

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

Definition at line 57 of file HybridClusterAlgo.cc.

References edm::SortedCollection< T, SORT >::begin(), clustered_, eb_st, edm::SortedCollection< T, SORT >::end(), ET, excludedCrys_, excludeFromCluster_, spr::find(), CaloCellGeometry::getPosition(), j, EcalRecHit::kGood, LogTrace, mainSearch(), position, recHits_, HLT_25ns14e33_v3_cff::region, seedClus_, seeds, EcalSeverityLevelAlgo::severityLevel(), funct::sin(), python.multivaluedict::sort(), PV3DBase< T, PVType, FrameType >::theta(), useddetids, v_chstatus_, and v_severitylevel_.

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

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

Definition at line 542 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().

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

References clustered_, reco::CaloCluster::energy(), i, j, LogTrace, edm::PtrVector< T >::push_back(), fileCollector::seed, seedClus_, edm::PtrVectorBase::size(), and python.multivaluedict::sort().

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

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

Definition at line 154 of file HybridClusterAlgo.h.

References dynamicPhiRoad_, and phiRoadAlgo_.

155  {
156  dynamicPhiRoad_ = true;
157  phiRoadAlgo_ = new BremRecoveryPhiRoadAlgo(bremRecoveryPset);
158  }
BremRecoveryPhiRoadAlgo * phiRoadAlgo_

Member Data Documentation

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

Definition at line 104 of file HybridClusterAlgo.h.

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

bool HybridClusterAlgo::dynamicEThres_
private

Definition at line 80 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

bool HybridClusterAlgo::dynamicPhiRoad_
private
double HybridClusterAlgo::eb_st
private

Definition at line 40 of file HybridClusterAlgo.h.

Referenced by makeClusters().

double HybridClusterAlgo::Eseed
private

Definition at line 65 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

double HybridClusterAlgo::eThres_
private

Definition at line 60 of file HybridClusterAlgo.h.

Referenced by mainSearch().

double HybridClusterAlgo::eThresA_
private

Definition at line 61 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

double HybridClusterAlgo::eThresB_
private

Definition at line 62 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

double HybridClusterAlgo::Ewing
private

Definition at line 74 of file HybridClusterAlgo.h.

Referenced by makeDomino().

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

Definition at line 118 of file HybridClusterAlgo.h.

Referenced by makeClusters(), and makeDomino().

bool HybridClusterAlgo::excludeFromCluster_
private

Definition at line 117 of file HybridClusterAlgo.h.

Referenced by makeClusters().

BremRecoveryPhiRoadAlgo* HybridClusterAlgo::phiRoadAlgo_
private

Definition at line 57 of file HybridClusterAlgo.h.

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

int HybridClusterAlgo::phiSteps_
private

Definition at line 45 of file HybridClusterAlgo.h.

Referenced by mainSearch().

PositionCalc HybridClusterAlgo::posCalculator_
private

Definition at line 107 of file HybridClusterAlgo.h.

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

const EcalRecHitCollection* HybridClusterAlgo::recHits_
private

Definition at line 87 of file HybridClusterAlgo.h.

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

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

Definition at line 101 of file HybridClusterAlgo.h.

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

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

Definition at line 98 of file HybridClusterAlgo.h.

Referenced by mainSearch(), and makeClusters().

float HybridClusterAlgo::severityRecHitThreshold_
private

Definition at line 114 of file HybridClusterAlgo.h.

float HybridClusterAlgo::severitySpikeThreshold_
private

Definition at line 115 of file HybridClusterAlgo.h.

EcalBarrelHardcodedTopology* HybridClusterAlgo::topo_
private

Definition at line 90 of file HybridClusterAlgo.h.

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

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

Definition at line 95 of file HybridClusterAlgo.h.

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

bool HybridClusterAlgo::UseEtForXi
private

Definition at line 71 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().

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

Definition at line 110 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and makeClusters().

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

Definition at line 113 of file HybridClusterAlgo.h.

Referenced by makeClusters().

double HybridClusterAlgo::Xi
private

Definition at line 68 of file HybridClusterAlgo.h.

Referenced by HybridClusterAlgo(), and mainSearch().