CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HybridClusterAlgo.cc
Go to the documentation of this file.
5 #include <iostream>
6 #include <map>
7 #include <vector>
8 #include <set>
10 
11 //The real constructor
13  int step,
14  double ethres,
15  double eseed,
16  double ewing,
17  std::vector<int> v_chstatus,
18  const PositionCalc& posCalculator,
20  bool dynamicEThres,
21  double eThresA,
22  double eThresB,
23  std::vector<int> severityToExclude,
25  int severitySpikeId,
27  bool excludeFromCluster
28  ) :
29 
30  eb_st(eb_str), phiSteps_(step),
31  eThres_(ethres), eThresA_(eThresA), eThresB_(eThresB),
32  Eseed(eseed), Ewing(ewing),
33  dynamicEThres_(dynamicEThres), debugLevel_(debugLevel),
34  v_chstatus_(v_chstatus), v_severitylevel_(severityToExclude),severityRecHitThreshold_(severityRecHitThreshold), severitySpikeThreshold_(severitySpikeThreshold), excludeFromCluster_(excludeFromCluster)
35 
36 
37 {
38  spId_ = EcalSeverityLevelAlgo::SpikeId(severitySpikeId);
39  dynamicPhiRoad_ = false;
40  if ( debugLevel_ == pDEBUG ) {
41  //std::cout << "dynamicEThres: " << dynamicEThres_
42  // << " : A,B " << eThresA_ << ", " << eThresB_ << std::endl;
43  }
44 
45  //if (dynamicPhiRoad_) phiRoadAlgo_ = new BremRecoveryPhiRoadAlgo(bremRecoveryPset);
46  posCalculator_ = posCalculator;
48 
49  std::sort( v_chstatus_.begin(), v_chstatus_.end() );
50 
51 
52 }
53 
54 // Return a vector of clusters from a collection of EcalRecHits:
57  reco::BasicClusterCollection &basicClusters,
58  bool regional,
59  const std::vector<EcalEtaPhiRegion>& regions,
60  const EcalChannelStatus*chStatus
61  )
62 {
63  //clear vector of seeds
64  seeds.clear();
65  //clear flagged crystals
66  excludedCrys_.clear();
67  //clear map of supercluster/basiccluster association
68  clustered_.clear();
69  //clear set of used detids
70  useddetids.clear();
71  //clear vector of seed clusters
72  seedClus_.clear();
73  //Pass in a pointer to the collection.
74  recHits_ = recColl;
75 
76  //
77  // SCShape_ = new SuperClusterShapeAlgo(recHits_, geometry);
78 
79  if ( debugLevel_ == pDEBUG ) {
80  std::cout << "Cleared vectors, starting clusterization..." << std::endl;
81  std::cout << "Purple monkey aardvark." << std::endl;
82  }
83 
84  int nregions=0;
85  if(regional) nregions=regions.size();
86 
87  if(!regional || nregions) {
88 
90 
91  for (it = recHits_->begin(); it != recHits_->end(); it++){
92 
93  //Make the vector of seeds that we're going to use.
94  //One of the few places position is used, needed for ET calculation.
95  const CaloCellGeometry *this_cell = (*geometry).getGeometry(it->id());
96  GlobalPoint position = this_cell->getPosition();
97 
98 
99  // Require that RecHit is within clustering region in case
100  // of regional reconstruction
101  bool withinRegion = false;
102  if (regional) {
103  std::vector<EcalEtaPhiRegion>::const_iterator region;
104  for (region=regions.begin(); region!=regions.end(); region++) {
105  if (region->inRegion(position)) {
106  withinRegion = true;
107  break;
108  }
109  }
110  }
111 
112  if (!regional || withinRegion) {
113 
114  //Must pass seed threshold
115  float ET = it->energy() * sin(position.theta());
116 
117  if (ET > eb_st) {
118  if (debugLevel_==pDEBUG) std::cout << "Seed crystal: " << std::endl;
119  // avoid seeding for anomalous channels (recoFlag based)
120  uint32_t rhFlag = (*it).recoFlag();
121  if (debugLevel_==pDEBUG) std::cout << "rhFlag: " << rhFlag << std::endl;
122  std::vector<int>::const_iterator vit = std::find( v_chstatus_.begin(), v_chstatus_.end(), rhFlag );
123  if ( vit != v_chstatus_.end() ){
125  excludedCrys_.insert(it->id());
126  continue; // the recHit has to be excluded from seeding
127  }
128  int severityFlag = EcalSeverityLevelAlgo::severityLevel( it->id(),
129  (*recHits_),
130  (*chStatus),
132  spId_,
134  std::vector<int>::const_iterator sit = std::find( v_severitylevel_.begin(), v_severitylevel_.end(), severityFlag);
135  if (debugLevel_ == pDEBUG){
136  std::cout << "found flag: " << severityFlag << std::endl;
137  }
138 
139 
140  if (sit!=v_severitylevel_.end()){
142  excludedCrys_.insert(it->id());
143  continue;
144  }
145  seeds.push_back(*it);
146  if ( debugLevel_ == pDEBUG ){
147  std::cout << "Seed ET: " << ET << std::endl;
148  std::cout << "Seed E: " << it->energy() << std::endl;
149  }
150  }
151  }
152  }
153 
154  }
155 
156 
157  //Yay sorting.
158  if ( debugLevel_ == pDEBUG )
159  std::cout << "Built vector of seeds, about to sort them...";
160 
161  //Needs three argument sort with seed comparison operator
162  sort(seeds.begin(), seeds.end(), less_mag());
163 
164  if ( debugLevel_ == pDEBUG )
165  std::cout << "done" << std::endl;
166 
167  //Now to do the work.
168  if ( debugLevel_ ==pDEBUG )
169  std::cout << "About to call mainSearch...";
170  mainSearch(recColl,geometry);
171  if ( debugLevel_ == pDEBUG )
172  std::cout << "done" << std::endl;
173 
174  //Hand the basicclusters back to the producer. It has to
175  //put them in the event. Then we can make superclusters.
176  std::map<int, reco::BasicClusterCollection>::iterator bic;
177  for (bic= clustered_.begin();bic!=clustered_.end();bic++){
178  reco::BasicClusterCollection bl = bic->second;
179  for (int j=0;j<int(bl.size());++j){
180  basicClusters.push_back(bl[j]);
181  }
182  }
183 
184  //Yay more sorting.
185  sort(basicClusters.rbegin(), basicClusters.rend(), ClusterEtLess() );
186  //Done!
187  if ( debugLevel_ == pDEBUG )
188  std::cout << "returning to producer. " << std::endl;
189 }
190 
191 
193 {
194 
195  if ( debugLevel_ ==pDEBUG ) {
196  std::cout << "HybridClusterAlgo Algorithm - looking for clusters" << std::endl;
197  std::cout << "Found the following clusters:" << std::endl;
198  }
199 
200  // Loop over seeds:
201  std::vector<EcalRecHit>::iterator it;
202  int clustercounter=0;
203 
204  for (it = seeds.begin(); it != seeds.end(); it++){
205  std::vector <reco::BasicCluster> thisseedClusters;
206  DetId itID = it->id();
207 
208  // make sure the current seed has not been used/will not be used in the future:
209  std::set<DetId>::iterator seed_in_rechits_it = useddetids.find(itID);
210 
211  if (seed_in_rechits_it != useddetids.end()) continue;
212  //If this seed is already used, then don't use it again.
213 
214  // output some info on the hit:
215  if ( debugLevel_ == pDEBUG ){
216  std::cout << "*****************************************************" << std::endl;
217  std::cout << "Seed of energy E = " << it->energy() << " @ " << EBDetId(itID)
218  << std::endl;
219  std::cout << "*****************************************************" << std::endl;
220  }
221 
222  //Make a navigator, and set it to the seed cell.
223  EcalBarrelNavigator navigator(itID, topo_);
224 
225  //Now use the navigator to start building dominoes.
226 
227  //Walking positive in phi:
228  std::vector <double> dominoEnergyPhiPlus; //Here I will store the results of the domino sums
229  std::vector <std::vector <EcalRecHit> > dominoCellsPhiPlus; //These are the actual EcalRecHit for dominos.
230 
231  //Walking negative in phi
232  std::vector <double> dominoEnergyPhiMinus; //Here I will store the results of the domino sums
233  std::vector <std::vector <EcalRecHit> > dominoCellsPhiMinus; //These are the actual EcalRecHit for dominos.
234 
235  //The two sets together.
236  std::vector <double> dominoEnergy; //Here I will store the results of the domino sums
237  std::vector <std::vector <EcalRecHit> > dominoCells; //These are the actual EcalRecHit for dominos.
238 
239  //First, the domino about the seed:
240  std::vector <EcalRecHit> initialdomino;
241  double e_init = makeDomino(navigator, initialdomino);
242  if (e_init < Eseed) continue;
243 
244  if ( debugLevel_ == pDEBUG )
245  {
246  std::cout << "Made initial domino" << std::endl;
247  }
248 
249  //
250  // compute the phi road length
251  double phiSteps;
252  if (dynamicPhiRoad_ && e_init > 0)
253  {
254  double et5x5 = et25(navigator, hits, geometry);
255  phiSteps = phiRoadAlgo_->barrelPhiRoad(et5x5);
256  navigator.home();
257  } else phiSteps = phiSteps_;
258 
259  //Positive phi steps.
260  for (int i=0;i<phiSteps;++i){
261  //remember, this always increments the current position of the navigator.
262  DetId centerD = navigator.north();
263  if (centerD.null())
264  continue;
265  if ( debugLevel_ == pDEBUG )
266  {
267  std::cout << "Step ++" << i << " @ " << EBDetId(centerD) << std::endl;
268  }
269  EcalBarrelNavigator dominoNav(centerD, topo_);
270 
271  //Go get the new domino.
272  std::vector <EcalRecHit> dcells;
273  double etemp = makeDomino(dominoNav, dcells);
274 
275  //save this information
276  dominoEnergyPhiPlus.push_back(etemp);
277  dominoCellsPhiPlus.push_back(dcells);
278  }
279 
280  if ( debugLevel_ == pDEBUG )
281  std::cout << "Got positive dominos" << std::endl;
282  //return to initial position
283  navigator.home();
284 
285  //Negative phi steps.
286  for (int i=0;i<phiSteps;++i){
287  //remember, this always decrements the current position of the navigator.
288  DetId centerD = navigator.south();
289  if (centerD.null())
290  continue;
291 
292  if ( debugLevel_ == pDEBUG )
293  {
294  std::cout << "Step --" << i << " @ " << EBDetId(centerD) << std::endl;
295  }
296  EcalBarrelNavigator dominoNav(centerD, topo_);
297 
298  //Go get the new domino.
299  std::vector <EcalRecHit> dcells;
300  double etemp = makeDomino(dominoNav, dcells);
301 
302  //save this information
303  dominoEnergyPhiMinus.push_back(etemp);
304  dominoCellsPhiMinus.push_back(dcells);
305  }
306 
307  if ( debugLevel_ == pDEBUG )
308  std::cout << "Got negative dominos: " << std::endl;
309 
310  //Assemble this information:
311  for (int i=int(dominoEnergyPhiMinus.size())-1;i >= 0;--i){
312  dominoEnergy.push_back(dominoEnergyPhiMinus[i]);
313  dominoCells.push_back(dominoCellsPhiMinus[i]);
314  }
315  dominoEnergy.push_back(e_init);
316  dominoCells.push_back(initialdomino);
317  for (int i=0;i<int(dominoEnergyPhiPlus.size());++i){
318  dominoEnergy.push_back(dominoEnergyPhiPlus[i]);
319  dominoCells.push_back(dominoCellsPhiPlus[i]);
320  }
321 
322  //Ok, now I have all I need in order to go ahead and make clusters.
323  if ( debugLevel_ == pDEBUG ){
324  std::cout << "Dumping domino energies: " << std::endl;
325  for (int i=0;i<int(dominoEnergy.size());++i){
326  std::cout << "Domino: " << i << " E: " << dominoEnergy[i] << std::endl;
327  }
328  }
329 
330 
331  //Identify the peaks in this set of dominos:
332  //Peak==a domino whose energy is greater than the two adjacent dominos.
333  //thus a peak in the local sense.
334  std::vector <int> PeakIndex;
335  for (int i=1;i<int(dominoEnergy.size())-1;++i){
336  if (dominoEnergy[i] > dominoEnergy[i-1]
337  && dominoEnergy[i] >= dominoEnergy[i+1]
338  && dominoEnergy[i] > Eseed){
339  PeakIndex.push_back(i);
340  }
341  }
342 
343  if ( debugLevel_ == pDEBUG )
344  std::cout << "Found: " << PeakIndex.size() << " peaks." << std::endl;
345 
346  //Order these peaks by energy:
347  for (int i=0;i<int(PeakIndex.size());++i){
348  for (int j=0;j<int(PeakIndex.size())-1;++j){
349  if (dominoEnergy[PeakIndex[j]] < dominoEnergy[PeakIndex[j+1]]){
350  int ihold = PeakIndex[j+1];
351  PeakIndex[j+1] = PeakIndex[j];
352  PeakIndex[j] = ihold;
353  }
354  }
355  }
356 
357  std::vector<int> OwnerShip;
358  std::vector<double> LumpEnergy;
359  for (int i=0;i<int(dominoEnergy.size());++i) OwnerShip.push_back(-1);
360 
361  //Loop over peaks.
362  double eThres = eThres_;
363  double e5x5 = 0.0;
364  for (int i = 0; i < int(PeakIndex.size()); ++i)
365  {
366 
367  int idxPeak = PeakIndex[i];
368  OwnerShip[idxPeak] = i;
369  double lump = dominoEnergy[idxPeak];
370 
371  // compute eThres for this peak
372  // if set to dynamic (otherwise uncanged from
373  // fixed setting
374  if (dynamicEThres_) {
375 
376  //std::cout << "i : " << i << " idxPeak " << idxPeak << std::endl;
377  //std::cout << " the dominoEnergy.size() = " << dominoEnergy.size() << std::endl;
378  // compute e5x5 for this seed crystal
379  //std::cout << "idxPeak, phiSteps " << idxPeak << ", " << phiSteps << std::endl;
380  e5x5 = lump;
381  //std::cout << "lump " << e5x5 << std::endl;
382  if ((idxPeak + 1) < (int)dominoEnergy.size()) e5x5 += dominoEnergy[idxPeak + 1];
383  //std::cout << "+1 " << e5x5 << std::endl;
384  if ((idxPeak + 2) < (int)dominoEnergy.size()) e5x5 += dominoEnergy[idxPeak + 2];
385  //std::cout << "+2 " << e5x5 << std::endl;
386  if ((idxPeak - 1) > 0) e5x5 += dominoEnergy[idxPeak - 1];
387  //std::cout << "-1 " << e5x5 << std::endl;
388  if ((idxPeak - 2) > 0) e5x5 += dominoEnergy[idxPeak - 2];
389  //std::cout << "-2 " << e5x5 << std::endl;
390  // compute eThres
391  eThres = (eThresA_ * e5x5) + eThresB_;
392  //std::cout << eThres << std::endl;
393  //std::cout << std::endl;
394  }
395 
396  //Loop over adjacent dominos at higher phi
397  for (int j=idxPeak+1;j<int(dominoEnergy.size());++j){
398  if (OwnerShip[j]==-1 &&
399  dominoEnergy[j] > eThres
400  && dominoEnergy[j] <= dominoEnergy[j-1]){
401  OwnerShip[j]= i;
402  lump+=dominoEnergy[j];
403  }
404  else{
405  break;
406  }
407  }
408  //loop over adjacent dominos at lower phi. Sum up energy of lumps.
409  for (int j=idxPeak-1;j>=0;--j){
410  if (OwnerShip[j]==-1 &&
411  dominoEnergy[j] > eThres
412  && dominoEnergy[j] <= dominoEnergy[j+1]){
413  OwnerShip[j]= i;
414  lump+=dominoEnergy[j];
415  }
416  else{
417  break;
418  }
419  }
420  LumpEnergy.push_back(lump);
421  }
422 
423  //Make the basic clusters:
424  for (int i=0;i<int(PeakIndex.size());++i){
425  bool HasSeedCrystal = false;
426  //One cluster for each peak.
427  std::vector<EcalRecHit> recHits;
428  std::vector< std::pair<DetId, float> > dets;
429  int nhits=0;
430  for (int j=0;j<int(dominoEnergy.size());++j){
431  if (OwnerShip[j] == i){
432  std::vector <EcalRecHit> temp = dominoCells[j];
433  for (int k=0;k<int(temp.size());++k){
434  dets.push_back( std::pair<DetId, float>(temp[k].id(), 1.) ); // by default energy fractions are 1
435  if (temp[k].id()==itID)
436  HasSeedCrystal = true;
437  recHits.push_back(temp[k]);
438  nhits++;
439  }
440  }
441  }
442  if ( debugLevel_ == pDEBUG ){
443  std::cout << "Adding a cluster with: " << nhits << std::endl;
444  std::cout << "total E: " << LumpEnergy[i] << std::endl;
445  std::cout << "total dets: " << dets.size() << std::endl;
446  }
447 
448  //Get Calorimeter position
449  Point pos = posCalculator_.Calculate_Location(dets,hits,geometry);
450 
451  //double totChi2=0;
452  //double totE=0;
453  std::vector<std::pair<DetId, float> > usedHits;
454  for (int blarg=0;blarg<int(recHits.size());++blarg){
455  //totChi2 +=0;
456  //totE+=recHits[blarg].energy();
457  usedHits.push_back(std::make_pair<DetId, float>(recHits[blarg].id(), 1.0));
458  useddetids.insert(recHits[blarg].id());
459  }
460 
461  //if (totE>0)
462  //totChi2/=totE;
463 
464  if (HasSeedCrystal) {
465  // note that this "basiccluster" has the seed crystal of the hyrbid, so record it
466  seedClus_.push_back(reco::BasicCluster(LumpEnergy[i], pos,
469  // and also add to the vector of clusters that will be used in constructing
470  // the supercluster
471  thisseedClusters.push_back(reco::BasicCluster(LumpEnergy[i], pos, reco::CaloID(reco::CaloID::DET_ECAL_BARREL),
472  usedHits, reco::CaloCluster::hybrid, itID));
473  }
474  else {
475  // note that if this "basiccluster" is not the one that seeded the hybrid,
476  // the seed crystal is unset in this entry in the vector of clusters that will
477  // be used in constructing the super cluster
478  thisseedClusters.push_back(reco::BasicCluster(LumpEnergy[i], pos, reco::CaloID(reco::CaloID::DET_ECAL_BARREL),
479  usedHits, reco::CaloCluster::hybrid));
480  }
481  }
482 
483 
484  // Make association so that superclusters can be made later.
485  // but only if some BasicClusters have been found...
486  if (thisseedClusters.size() > 0)
487  {
488  clustered_.insert(std::make_pair(clustercounter, thisseedClusters));
489  clustercounter++;
490  }
491  }//Seed loop
492 
493 }
494 
496 {
497  //Here's what we'll return.
499 
500  //Here's our map iterator that gives us the appropriate association.
501  std::map<int, reco::BasicClusterCollection>::iterator mapit;
502  for (mapit = clustered_.begin();mapit!=clustered_.end();mapit++){
503 
505  reco::CaloClusterPtr seed;//This is not really a seed, but I need to tell SuperCluster something.
506  //So I choose the highest energy basiccluster in the SuperCluster.
507 
508  std::vector <reco::BasicCluster> thiscoll = mapit->second; //This is the set of BasicClusters in this
509  //SuperCluster
510 
511  double ClusterE = 0; //Sum of cluster energies for supercluster.
512  //Holders for position of this supercluster.
513  double posX=0;
514  double posY=0;
515  double posZ=0;
516 
517  //Loop over this set of basic clusters, find their references, and add them to the
518  //supercluster. This could be somehow more efficient.
519 
520  for (int i=0;i<int(thiscoll.size());++i){
521  reco::BasicCluster thisclus = thiscoll[i]; //The Cluster in question.
522  for (int j=0;j<int(clustersCollection.size());++j){
523  //Find the appropriate cluster from the list of references
524  reco::BasicCluster cluster_p = *clustersCollection[j];
525  if (thisclus== cluster_p){ //Comparison based on energy right now.
526  thissc.push_back(clustersCollection[j]);
527  bool isSeed = false;
528  for (int qu=0;qu<int(seedClus_.size());++qu){
529  if (cluster_p == seedClus_[qu])
530  isSeed = true;
531  }
532  if (isSeed) seed = clustersCollection[j];
533 
534  ClusterE += cluster_p.energy();
535  posX += cluster_p.energy() * cluster_p.position().X();
536  posY += cluster_p.energy() * cluster_p.position().Y();
537  posZ += cluster_p.energy() * cluster_p.position().Z();
538 
539  }
540  }//End loop over finding references.
541  }//End loop over clusters.
542 
543  posX /= ClusterE;
544  posY /= ClusterE;
545  posZ /= ClusterE;
546 
547  /* //This part is moved to EgammaSCEnergyCorrectionAlgo
548  double preshowerE = 0.;
549  double phiWidth = 0.;
550  double etaWidth = 0.;
551  //Calculate phiWidth & etaWidth for SuperClusters
552  reco::SuperCluster suCl(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, preshowerE, phiWidth, etaWidth);
553  SCShape_->Calculate_Covariances(suCl);
554  phiWidth = SCShape_->phiWidth();
555  etaWidth = SCShape_->etaWidth();
556  //Assign phiWidth & etaWidth to SuperCluster as data members
557  suCl.setPhiWidth(phiWidth);
558  suCl.setEtaWidth(etaWidth);
559  */
560 
561  reco::SuperCluster suCl(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc);
562  SCcoll.push_back(suCl);
563 
564  if ( debugLevel_ == pDEBUG ){
565  std::cout << "Super cluster sum: " << ClusterE << std::endl;
566  std::cout << "Made supercluster with energy E: " << suCl.energy() << std::endl;
567  }
568  }//end loop over map
569  sort(SCcoll.rbegin(), SCcoll.rend(), ClusterEtLess());
570  return SCcoll;
571 }
572 
573 double HybridClusterAlgo::makeDomino(EcalBarrelNavigator &navigator, std::vector <EcalRecHit> &cells)
574 {
575  //At the beginning of this function, the navigator starts at the middle of the domino,
576  //and that's where EcalBarrelNavigator::home() should send it.
577  //Walk one crystal in eta to either side of the initial point. Sum the three cell energies.
578  //If the resultant energy is larger than Ewing, then go an additional cell to either side.
579  //Returns: Total domino energy. Also, stores the cells used to create domino in the vector.
580  cells.clear();
581  double Etot = 0;
582 
583  //Ready? Get the starting cell.
584  DetId center = navigator.pos();
586 
587  if (center_it!=recHits_->end()){
588  EcalRecHit SeedHit = *center_it;
589  if (useddetids.find(center) == useddetids.end() && excludedCrys_.find(center)==excludedCrys_.end()){
590  Etot += SeedHit.energy();
591  cells.push_back(SeedHit);
592  }
593  }
594  //One step upwards in Ieta:
595  DetId ieta1 = navigator.west();
597  if (eta1_it !=recHits_->end()){
598  EcalRecHit UpEta = *eta1_it;
599  if (useddetids.find(ieta1) == useddetids.end() && excludedCrys_.find(ieta1)==excludedCrys_.end()){
600  Etot+=UpEta.energy();
601  cells.push_back(UpEta);
602  }
603  }
604 
605  //Go back to the middle.
606  navigator.home();
607 
608  //One step downwards in Ieta:
609  DetId ieta2 = navigator.east();
611  if (eta2_it !=recHits_->end()){
612  EcalRecHit DownEta = *eta2_it;
613  if (useddetids.find(ieta2)==useddetids.end() && excludedCrys_.find(ieta2)==excludedCrys_.end()){
614  Etot+=DownEta.energy();
615  cells.push_back(DownEta);
616  }
617  }
618 
619  //Now check the energy. If smaller than Ewing, then we're done. If greater than Ewing, we have to
620  //add two additional cells, the 'wings'
621  if (Etot < Ewing) {
622  navigator.home(); //Needed even here!!
623  return Etot; //Done! Not adding 'wings'.
624  }
625 
626  //Add the extra 'wing' cells. Remember, we haven't sent the navigator home,
627  //we're still on the DownEta cell.
628  if (ieta2 != DetId(0)){
629  DetId ieta3 = navigator.east(); //Take another step downward.
631  if (eta3_it != recHits_->end()){
632  EcalRecHit DownEta2 = *eta3_it;
633  if (useddetids.find(ieta3)==useddetids.end() && excludedCrys_.find(ieta3)==excludedCrys_.end()){
634  Etot+=DownEta2.energy();
635  cells.push_back(DownEta2);
636  }
637  }
638  }
639  //Now send the navigator home.
640  navigator.home();
641  navigator.west(); //Now you're on eta1_it
642  if (ieta1 != DetId(0)){
643  DetId ieta4 = navigator.west(); //Take another step upward.
645  if (eta4_it != recHits_->end()){
646  EcalRecHit UpEta2 = *eta4_it;
647  if (useddetids.find(ieta4) == useddetids.end() && excludedCrys_.find(ieta4)==excludedCrys_.end()){
648  Etot+=UpEta2.energy();
649  cells.push_back(UpEta2);
650  }
651  }
652  }
653  navigator.home();
654  return Etot;
655 }
656 
658  const EcalRecHitCollection *hits,
660 {
661 
662  DetId thisDet;
663  std::vector< std::pair<DetId, float> > dets;
664  dets.clear();
666  double energySum = 0.0;
667 
668  for (int dx = -2; dx < 3; ++dx)
669  {
670  for (int dy = -2; dy < 3; ++ dy)
671  {
672  //std::cout << "dx, dy " << dx << ", " << dy << std::endl;
673  thisDet = navigator.offsetBy(dx, dy);
674  navigator.home();
675 
676  if (thisDet != DetId(0))
677  {
678  hit = recHits_->find(thisDet);
679  if (hit != recHits_->end())
680  {
681  dets.push_back( std::pair<DetId, float>(thisDet, 1.) ); // by default hit energy fraction is set to 1
682  energySum += hit->energy();
683  }
684  }
685  }
686  }
687 
688  // convert it to ET
689  //std::cout << "dets.size(), energySum: " << dets.size() << ", " << energySum << std::endl;
690  Point pos = posCalculator_.Calculate_Location(dets, hits, geometry);
691  double et = energySum/cosh(pos.eta());
692  return et;
693 
694 }
695 
int i
Definition: DBlmapReader.cc:9
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:72
void home() const
move the navigator back to the starting point
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:135
double et25(EcalBarrelNavigator &navigator, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
EcalBarrelHardcodedTopology * topo_
void mainSearch(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
std::map< int, std::vector< reco::BasicCluster > > clustered_
virtual T west() const
move the navigator west
Definition: CaloNavigator.h:81
std::vector< T >::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
virtual T north() const
move the navigator north
Definition: CaloNavigator.h:51
T pos() const
get the current position
Definition: CaloNavigator.h:45
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
double makeDomino(EcalBarrelNavigator &navigator, std::vector< EcalRecHit > &cells)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:69
PositionCalc posCalculator_
virtual T east() const
move the navigator east
Definition: CaloNavigator.h:71
std::vector< EcalRecHit > seeds
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
float energy() const
Definition: CaloRecHit.h:19
EcalSeverityLevelAlgo::SpikeId spId_
virtual T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
reco::SuperClusterCollection makeSuperClusters(const reco::CaloClusterPtrVector &)
BremRecoveryPhiRoadAlgo * phiRoadAlgo_
int j
Definition: DBlmapReader.cc:9
double energy() const
cluster energy
Definition: CaloCluster.h:109
std::vector< int > v_chstatus_
std::set< DetId > useddetids
std::set< DetId > excludedCrys_
void makeClusters(const EcalRecHitCollection *, const CaloSubdetectorGeometry *geometry, reco::BasicClusterCollection &basicClusters, bool regional=false, const std::vector< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >(), const EcalChannelStatus *chStatus=new EcalChannelStatus())
int k[5][pyjets_maxn]
const_iterator end() const
math::XYZPoint Point
std::vector< int > v_severitylevel_
Definition: DetId.h:20
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
bool null() const
is this a null id ?
Definition: DetId.h:47
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
ESHandle< TrackerGeometry > geometry
math::XYZPoint Calculate_Location(const std::vector< std::pair< DetId, float > > &iDetIds, const EcalRecHitCollection *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
Definition: PositionCalc.cc:40
iterator find(key_type k)
tuple cout
Definition: gather_cfg.py:41
const EcalRecHitCollection * recHits_
static int severityLevel(const DetId, const EcalRecHitCollection &, const EcalChannelStatus &, float recHitEtThreshold=5., SpikeId spId=kSwissCross, float spIdThreshold=0.95, float recHitEnergyThresholdForTiming=2., float recHitEnergyThresholdForEE=15, float spIdThresholdIEta85=0.999)
#define ET
double energySum(const DataFrame &df, int fs, int ls)
virtual T south() const
move the navigator south
Definition: CaloNavigator.h:61
const GlobalPoint & getPosition() const
std::vector< reco::BasicCluster > seedClus_
const_iterator begin() const