CMS 3D CMS Logo

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

#include <EcalHaloAlgo.h>

Public Member Functions

reco::EcalHaloData Calculate (const CaloGeometry &TheCaloGeometry, edm::Handle< reco::PhotonCollection > &ThePhotons, edm::Handle< reco::SuperClusterCollection > &TheSuperClusters, edm::Handle< EBRecHitCollection > &TheEBRecHits, edm::Handle< EERecHitCollection > &TheEERecHits, edm::Handle< ESRecHitCollection > &TheESRecHits, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, const edm::EventSetup &TheSetup)
 
bool EBClusterShapeandTimeStudy (reco::HaloClusterCandidateECAL hcand, bool ishlt)
 
 EcalHaloAlgo ()
 
bool EEClusterShapeandTimeStudy_ITBH (reco::HaloClusterCandidateECAL hcand, bool ishlt)
 
bool EEClusterShapeandTimeStudy_OTBH (reco::HaloClusterCandidateECAL hcand, bool ishlt)
 
float GetAngleCut ()
 
float GetEBRecHitEnergyThreshold ()
 
float GetEERecHitEnergyThreshold ()
 
float GetESRecHitEnergyThreshold ()
 
std::vector< reco::HaloClusterCandidateECALGetHaloClusterCandidateEB (edm::Handle< EcalRecHitCollection > &ecalrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
 
std::vector< reco::HaloClusterCandidateECALGetHaloClusterCandidateEE (edm::Handle< EcalRecHitCollection > &ecalrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
 
float GetPhiWedgeEnergyThreshold ()
 
int GetPhiWedgeNHitsThreshold ()
 
float GetRoundnessCut ()
 
void SetAngleCut (float a=4.)
 
void SetPhiWedgeEnergyThreshold (float SumE)
 
void SetPhiWedgeNHitsThreshold (int nhits)
 
void SetPhiWedgeThresholds (float SumE, int nhits)
 
void SetRecHitEnergyThresholds (float EB, float EE, float ES)
 
void SetRoundnessCut (float r=100.)
 
 ~EcalHaloAlgo ()
 

Private Member Functions

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

Private Attributes

float AngleCut
 
float EBRecHitEnergyThreshold
 
float EERecHitEnergyThreshold
 
float ESRecHitEnergyThreshold
 
const CaloGeometrygeo
 
int NHitsThreshold
 
float RoundnessCut
 
float SumEnergyThreshold
 

Detailed Description

Definition at line 44 of file EcalHaloAlgo.h.

Constructor & Destructor Documentation

EcalHaloAlgo::EcalHaloAlgo ( )

Definition at line 19 of file EcalHaloAlgo.cc.

20 {
21  RoundnessCut = 0 ;
22  AngleCut = 0 ;
26  SumEnergyThreshold = 0.;
27  NHitsThreshold =0;
28 
29  geo = nullptr;
30 }
float ESRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:100
float SumEnergyThreshold
Definition: EcalHaloAlgo.h:103
float EERecHitEnergyThreshold
Definition: EcalHaloAlgo.h:99
float EBRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:98
float AngleCut
Definition: EcalHaloAlgo.h:95
float RoundnessCut
Definition: EcalHaloAlgo.h:93
const CaloGeometry * geo
Definition: EcalHaloAlgo.h:106
EcalHaloAlgo::~EcalHaloAlgo ( )
inline

Definition at line 50 of file EcalHaloAlgo.h.

References Calculate().

50 {}

Member Function Documentation

EcalHaloData EcalHaloAlgo::Calculate ( const CaloGeometry TheCaloGeometry,
edm::Handle< reco::PhotonCollection > &  ThePhotons,
edm::Handle< reco::SuperClusterCollection > &  TheSuperClusters,
edm::Handle< EBRecHitCollection > &  TheEBRecHits,
edm::Handle< EERecHitCollection > &  TheEERecHits,
edm::Handle< ESRecHitCollection > &  TheESRecHits,
edm::Handle< HBHERecHitCollection > &  TheHBHERecHits,
const edm::EventSetup TheSetup 
)

Definition at line 32 of file EcalHaloAlgo.cc.

References funct::abs(), Abs(), angle(), edm::SortedCollection< T, SORT >::begin(), CompareTime(), DetId::Ecal, edm::SortedCollection< T, SORT >::end(), edm::EventSetup::get(), reco::EcalHaloData::GetPhiWedges(), reco::EcalHaloData::GetShowerShapesAngle(), reco::EcalHaloData::GetShowerShapesRoundness(), CaloGeometry::getSubdetectorGeometry(), reco::EcalHaloData::GetSuperClusters(), mps_fire::i, hit::id, EBDetId::ieta(), edm::helper::Filler< Map >::insert(), EBDetId::iphi(), edm::HandleBase::isValid(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::RefVector< C, T, F >::push_back(), DetId::rawId(), reco::EcalHaloData::setHaloClusterCandidatesEB(), reco::EcalHaloData::setHaloClusterCandidatesEE(), reco::PhiWedge::SetPlusZOriginConfidence(), and ntuplemaker::time.

Referenced by reco::EcalHaloDataProducer::produce(), and ~EcalHaloAlgo().

33 {
34 
35  EcalHaloData TheEcalHaloData;
36 
37  // Store energy sum of rechits as a function of iPhi (iphi goes from 1 to 72)
38  float SumE[361];
39  // Store number of rechits as a function of iPhi
40  int NumHits[361];
41  // Store minimum time of rechit as a function of iPhi
42  float MinTimeHits[361];
43  // Store maximum time of rechit as a function of iPhi
44  float MaxTimeHits[361];
45 
46  // initialize
47  for(int i = 0 ; i < 361 ; i++ )
48  {
49  SumE[i] = 0.;
50  NumHits[i] = 0 ;
51  MinTimeHits[i] = 9999.;
52  MaxTimeHits[i] = -9999.;
53  }
54 
55  // Loop over EB RecHits
56  for(EBRecHitCollection::const_iterator hit = TheEBRecHits->begin() ; hit != TheEBRecHits->end() ; hit++ )
57  {
58  // Arbitrary threshold to kill noise (needs to be optimized with data)
59  if (hit->energy() < EBRecHitEnergyThreshold ) continue;
60 
61  // Get Det Id of the rechit
62  DetId id = DetId(hit->id());
63 
64  // Get EB geometry
65  const CaloSubdetectorGeometry* TheSubGeometry = TheCaloGeometry.getSubdetectorGeometry(DetId::Ecal, 1);
66  EBDetId EcalID(id.rawId());
67  auto cell = (TheSubGeometry) ? (TheSubGeometry->getGeometry(id)) : nullptr;
68 
69  if(cell)
70  {
71  // GlobalPoint globalpos = cell->getPosition();
72  // float r = TMath::Sqrt ( globalpos.y()*globalpos.y() + globalpos.x()*globalpos.x());
73  int iPhi = EcalID.iphi();
74 
75  if( iPhi < 361 ) // just to be safe
76  {
77  //iPhi = (iPhi-1)/5 +1; // convert ecal iphi to phiwedge iphi (e.g. there are 5 crystal per phi wedge, as in calotowers )
78  SumE[iPhi] += hit->energy();
79  NumHits[iPhi] ++;
80 
81  float time = hit->time();
82  MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
83  MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
84  }
85  }
86  }
87 
88  //for( int iPhi = 1 ; iPhi < 73; iPhi++ )
89  for( int iPhi = 1 ; iPhi < 361; iPhi++ )
90  {
91  if( SumE[iPhi] >= SumEnergyThreshold && NumHits[iPhi] > NHitsThreshold )
92  {
93  // Build PhiWedge and store to EcalHaloData if energy or #hits pass thresholds
94  PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
95 
96  // Loop over rechits again to calculate direction based on timing info
97 
98  // Loop over EB RecHits
99  std::vector<const EcalRecHit*> Hits;
100  for(EBRecHitCollection::const_iterator hit = TheEBRecHits->begin() ; hit != TheEBRecHits->end() ; hit++ )
101  {
102  if (hit->energy() < EBRecHitEnergyThreshold ) continue;
103 
104  // Get Det Id of the rechit
105  DetId id = DetId(hit->id());
106  EBDetId EcalID(id.rawId());
107  int Hit_iPhi = EcalID.iphi();
108  //Hit_iPhi = (Hit_iPhi-1)/5 +1; // convert ecal iphi to phiwedge iphi
109  if( Hit_iPhi != iPhi ) continue;
110  Hits.push_back( &(*hit) );
111 
112  }
113  std::sort( Hits.begin() , Hits.end(), CompareTime);
114  float MinusToPlus = 0.;
115  float PlusToMinus = 0.;
116  for( unsigned int i = 0 ; i < Hits.size() ; i++ )
117  {
118  DetId id_i = DetId(Hits[i]->id());
119  EBDetId EcalID_i(id_i.rawId());
120  int ieta_i = EcalID_i.ieta();
121  for( unsigned int j = (i+1) ; j < Hits.size() ; j++ )
122  {
123  DetId id_j = DetId(Hits[j]->id() );
124  EBDetId EcalID_j(id_j.rawId());
125  int ieta_j = EcalID_j.ieta();
126  if( ieta_i > ieta_j ) PlusToMinus += TMath::Abs(ieta_j - ieta_i );
127  else MinusToPlus += TMath::Abs(ieta_j -ieta_i) ;
128  }
129  }
130 
131  float PlusZOriginConfidence = (PlusToMinus+MinusToPlus) ? PlusToMinus / (PlusToMinus+MinusToPlus) : -1.;
132  wedge.SetPlusZOriginConfidence(PlusZOriginConfidence);
133  TheEcalHaloData.GetPhiWedges().push_back(wedge);
134  }
135  }
136 
137  std::vector<float> vShowerShapes_Roundness;
138  std::vector<float> vShowerShapes_Angle ;
139  if(TheSuperClusters.isValid()){
140  for(reco::SuperClusterCollection::const_iterator cluster = TheSuperClusters->begin() ; cluster != TheSuperClusters->end() ; cluster++ )
141  {
142  if( abs(cluster->eta()) <= 1.48 )
143  {
144  vector<float> shapes = EcalClusterTools::roundnessBarrelSuperClusters( *cluster, (*TheEBRecHits.product()));
145  float roundness = shapes[0];
146  float angle = shapes[1];
147 
148  // Check if supercluster belongs to photon and passes the cuts on roundness and angle, if so store the reference to it
149  if( (roundness >=0 && roundness < GetRoundnessCut()) && angle >= 0 && angle < GetAngleCut() )
150  {
151  edm::Ref<SuperClusterCollection> TheClusterRef( TheSuperClusters, cluster - TheSuperClusters->begin());
152  bool BelongsToPhoton = false;
153  if( ThePhotons.isValid() )
154  {
155  for(reco::PhotonCollection::const_iterator iPhoton = ThePhotons->begin() ; iPhoton != ThePhotons->end() ; iPhoton++ )
156  {
157  if(iPhoton->isEB())
158  if ( TheClusterRef == iPhoton->superCluster() )
159  {
160  BelongsToPhoton = true;
161  break;
162  }
163  }
164  }
165  //Only store refs to suspicious EB SuperClusters which belong to Photons
166  //Showershape variables are more discriminating for these cases
167  if( BelongsToPhoton )
168  {
169  TheEcalHaloData.GetSuperClusters().push_back( TheClusterRef ) ;
170  }
171  }
172  vShowerShapes_Roundness.push_back(shapes[0]);
173  vShowerShapes_Angle.push_back(shapes[1]);
174  }
175  else
176  {
177  vShowerShapes_Roundness.push_back(-1.);
178  vShowerShapes_Angle.push_back(-1.);
179  }
180  }
181 
182 
183  edm::ValueMap<float>::Filler TheRoundnessFiller( TheEcalHaloData.GetShowerShapesRoundness() );
184  TheRoundnessFiller.insert( TheSuperClusters, vShowerShapes_Roundness.begin(), vShowerShapes_Roundness.end() );
185  TheRoundnessFiller.fill();
186 
187  edm::ValueMap<float>::Filler TheAngleFiller( TheEcalHaloData.GetShowerShapesAngle() );
188  TheAngleFiller.insert( TheSuperClusters, vShowerShapes_Angle.begin() , vShowerShapes_Angle.end() );
189  TheAngleFiller.fill();
190  }
191 
193  TheSetup.get<CaloGeometryRecord>().get(pGeo);
194  geo = pGeo.product();
195 
196  //Halo cluster building:
197  //Various clusters are built, depending on the subdetector.
198  //In barrel, one looks for deposits narrow in phi.
199  //In endcaps, one looks for localized deposits (dr condition in EE where r =sqrt(dphi*dphi+deta*deta)
200  //H/E condition is also applied in EB.
201  //The halo cluster building step targets a large efficiency (ideally >99%) for beam halo deposits.
202  //These clusters are used as input for the halo pattern finding methods in EcalHaloAlgo and for the CSC-calo matching methods in GlobalHaloAlgo.
203 
204  //Et threshold hardcoded for now. Might one to get it from config
205  std::vector<HaloClusterCandidateECAL> haloclustercands_EB;
206  haloclustercands_EB= GetHaloClusterCandidateEB(TheEBRecHits , TheHBHERecHits, 5);
207 
208  std::vector<HaloClusterCandidateECAL> haloclustercands_EE;
209  haloclustercands_EE= GetHaloClusterCandidateEE(TheEERecHits , TheHBHERecHits, 10);
210 
211  TheEcalHaloData.setHaloClusterCandidatesEB(haloclustercands_EB);
212  TheEcalHaloData.setHaloClusterCandidatesEE(haloclustercands_EE);
213 
214  return TheEcalHaloData;
215 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
edm::ValueMap< float > & GetShowerShapesRoundness()
Definition: EcalHaloData.h:43
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: EcalHaloData.h:34
edm::RefVector< reco::SuperClusterCollection > & GetSuperClusters()
Definition: EcalHaloData.h:38
edm::ValueMap< float > & GetShowerShapesAngle()
Definition: EcalHaloData.h:46
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
std::vector< EcalRecHit >::const_iterator const_iterator
float SumEnergyThreshold
Definition: EcalHaloAlgo.h:103
float GetRoundnessCut()
Definition: EcalHaloAlgo.h:76
T Abs(T a)
Definition: MathUtil.h:49
void setHaloClusterCandidatesEE(const std::vector< HaloClusterCandidateECAL > &x)
Definition: EcalHaloData.h:56
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setHaloClusterCandidatesEB(const std::vector< HaloClusterCandidateECAL > &x)
Definition: EcalHaloData.h:55
std::vector< reco::HaloClusterCandidateECAL > GetHaloClusterCandidateEB(edm::Handle< EcalRecHitCollection > &ecalrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
bool isValid() const
Definition: HandleBase.h:74
float GetAngleCut()
Definition: EcalHaloAlgo.h:78
unsigned int id
const_iterator end() const
std::vector< reco::HaloClusterCandidateECAL > GetHaloClusterCandidateEE(edm::Handle< EcalRecHitCollection > &ecalrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:81
float EBRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:98
T get() const
Definition: EventSetup.h:68
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
bool CompareTime(const EcalRecHit *x, const EcalRecHit *y)
Definition: EcalHaloAlgo.cc:17
T const * product() const
Definition: ESHandle.h:84
const CaloGeometry * geo
Definition: EcalHaloAlgo.h:106
const_iterator begin() const
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
bool EcalHaloAlgo::EBClusterShapeandTimeStudy ( reco::HaloClusterCandidateECAL  hcand,
bool  ishlt 
)

Definition at line 467 of file EcalHaloAlgo.cc.

References reco::HaloClusterCandidateECAL::getEtStripIPhiSeedMinus1(), reco::HaloClusterCandidateECAL::getEtStripIPhiSeedPlus1(), reco::HaloClusterCandidateECAL::getNbofCrystalsInEta(), reco::HaloClusterCandidateECAL::getSeedEt(), reco::HaloClusterCandidateECAL::getTimeDiscriminator(), and reco::HaloClusterCandidateECAL::setIsHaloFromPattern().

Referenced by SetPhiWedgeThresholds().

467  {
468  //Conditions on the central strip size in eta.
469  //For low size, extra conditions on seed et, isolation and cluster timing
470  //The time condition only targets IT beam halo.
471  //EB rechits from OT beam halos are typically too late (around 5 ns or more) and seem therefore already cleaned by the reconstruction.
472 
473  if(hcand.getSeedEt()<5)return false;
474  if(hcand.getNbofCrystalsInEta()<4) return false;
475  if(hcand.getNbofCrystalsInEta()==4&&hcand.getSeedEt()<10) return false;
476  if(hcand.getNbofCrystalsInEta()==4 && hcand.getEtStripIPhiSeedPlus1()>0.1 &&hcand.getEtStripIPhiSeedMinus1()>0.1 ) return false;
477  if(hcand.getNbofCrystalsInEta()<=5 && hcand.getTimeDiscriminator()>=0.)return false;
478 
479  //For HLT, only use conditions without timing and tighten seed et condition
480  if(ishlt &&hcand.getNbofCrystalsInEta()<=5)return false;
481  if(ishlt && hcand.getSeedEt()<10)return false;
482 
483  hcand.setIsHaloFromPattern(true);
484 
485  return true;
486 }
bool EcalHaloAlgo::EEClusterShapeandTimeStudy_ITBH ( reco::HaloClusterCandidateECAL  hcand,
bool  ishlt 
)

Definition at line 505 of file EcalHaloAlgo.cc.

References reco::HaloClusterCandidateECAL::getClusterSize(), reco::HaloClusterCandidateECAL::getSeedEt(), reco::HaloClusterCandidateECAL::getSeedR(), reco::HaloClusterCandidateECAL::getTimeDiscriminator(), and reco::HaloClusterCandidateECAL::setIsHaloFromPattern().

Referenced by SetPhiWedgeThresholds().

505  {
506  //Separate conditions targeting IT and OT beam halos
507  //For IT beam halos, fakes from collisions are higher => require the cluster size to be small.
508  //Only halos with R>100 cm are considered here.
509  //For lower values, the time difference with particles from collisions is too small
510  //IT outgoing beam halos that interact in EE at low R is probably the most difficult category to deal with:
511  //Their signature is very close to the one of photon from collisions (similar cluster shape and timing)
512  if(hcand.getSeedEt()<20)return false;
513  if(hcand.getSeedR()<100)return false;
514  if(hcand.getTimeDiscriminator()<1) return false;
515  if(hcand.getClusterSize()<2) return false;
516  if(hcand.getClusterSize()>4) return false;
517 
518  //The use of time information does not allow this method to work at HLT
519  if(ishlt)return false;
520 
521  hcand.setIsHaloFromPattern(true);
522 
523  return true;
524 }
bool EcalHaloAlgo::EEClusterShapeandTimeStudy_OTBH ( reco::HaloClusterCandidateECAL  hcand,
bool  ishlt 
)

Definition at line 490 of file EcalHaloAlgo.cc.

References reco::HaloClusterCandidateECAL::getNbEarlyCrystals(), reco::HaloClusterCandidateECAL::getNbLateCrystals(), reco::HaloClusterCandidateECAL::getSeedEt(), reco::HaloClusterCandidateECAL::getSeedTime(), and reco::HaloClusterCandidateECAL::setIsHaloFromPattern().

Referenced by SetPhiWedgeThresholds().

490  {
491  //Separate conditions targeting IT and OT beam halos
492  //For OT beam halos, just require enough crystals with large T
493  if(hcand.getSeedEt()<20)return false;
494  if(hcand.getSeedTime()<0.5)return false;
495  if(hcand.getNbLateCrystals()-hcand.getNbEarlyCrystals() <2)return false;
496 
497  //The use of time information does not allow this method to work at HLT
498  if(ishlt)return false;
499 
500  hcand.setIsHaloFromPattern(true);
501 
502  return true;
503 }
float EcalHaloAlgo::GetAngleCut ( )
inline

Definition at line 78 of file EcalHaloAlgo.h.

References AngleCut.

78 {return AngleCut ;}
float AngleCut
Definition: EcalHaloAlgo.h:95
float EcalHaloAlgo::GetEBRecHitEnergyThreshold ( )
inline

Definition at line 81 of file EcalHaloAlgo.h.

References EBRecHitEnergyThreshold.

81 { return EBRecHitEnergyThreshold;}
float EBRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:98
float EcalHaloAlgo::GetEERecHitEnergyThreshold ( )
inline

Definition at line 82 of file EcalHaloAlgo.h.

References EERecHitEnergyThreshold.

82 { return EERecHitEnergyThreshold;}
float EERecHitEnergyThreshold
Definition: EcalHaloAlgo.h:99
float EcalHaloAlgo::GetESRecHitEnergyThreshold ( )
inline

Definition at line 83 of file EcalHaloAlgo.h.

References ESRecHitEnergyThreshold.

83 { return ESRecHitEnergyThreshold;}
float ESRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:100
std::vector< HaloClusterCandidateECAL > EcalHaloAlgo::GetHaloClusterCandidateEB ( edm::Handle< EcalRecHitCollection > &  ecalrechitcoll,
edm::Handle< HBHERecHitCollection > &  hbherechitcoll,
float  et_thresh_seedrh 
)

Definition at line 220 of file EcalHaloAlgo.cc.

References funct::abs(), hiPixelPairStep_cff::deltaPhi, CaloRecHit::energy(), EcalRecHit::energy(), PVValHelper::eta, electrons_cff::hoe, HBHERecHit::id(), EcalRecHit::id(), EBDetId::ieta(), edm::RefVector< C, T, F >::push_back(), reco::HaloClusterCandidateECAL::setBeamHaloRecHitsCandidates(), reco::HaloClusterCandidateECAL::setClusterEt(), reco::HaloClusterCandidateECAL::setEtStripIPhiSeedMinus1(), reco::HaloClusterCandidateECAL::setEtStripIPhiSeedPlus1(), reco::HaloClusterCandidateECAL::setHoverE(), reco::HaloClusterCandidateECAL::setIsHaloFromPattern(), reco::HaloClusterCandidateECAL::setIsHaloFromPattern_HLT(), reco::HaloClusterCandidateECAL::setNbofCrystalsInEta(), reco::HaloClusterCandidateECAL::setSeedEt(), reco::HaloClusterCandidateECAL::setSeedEta(), reco::HaloClusterCandidateECAL::setSeedPhi(), reco::HaloClusterCandidateECAL::setSeedR(), reco::HaloClusterCandidateECAL::setSeedTime(), reco::HaloClusterCandidateECAL::setSeedZ(), reco::HaloClusterCandidateECAL::setTimeDiscriminator(), edm::SortedCollection< T, SORT >::size(), mathSSE::sqrt(), EcalRecHit::time(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by SetPhiWedgeThresholds().

220  {
221 
222  std::vector<HaloClusterCandidateECAL> TheHaloClusterCandsEB;
223  reco::Vertex::Point vtx(0,0,0);
224 
225  for(size_t ihit = 0; ihit<ecalrechitcoll->size(); ++ ihit){
226  HaloClusterCandidateECAL clustercand;
227 
228  const EcalRecHit & rechit = (*ecalrechitcoll)[ ihit ];
229  math::XYZPoint rhpos = getPosition(rechit.id(),vtx);
230  //Et condition
231 
232  double rhet = rechit.energy() * sqrt(rhpos.perp2()/rhpos.mag2());
233  if(rhet<et_thresh_seedrh) continue;
234  double eta = rhpos.eta();
235  double phi = rhpos.phi();
236 
237  bool isiso = true;
238  double etcluster(0);
239  int nbcrystalsameeta(0);
240  double timediscriminator(0);
241  double etstrip_iphiseedplus1(0), etstrip_iphiseedminus1(0);
242 
243  //Building the cluster
245  for(size_t jhit = 0; jhit<ecalrechitcoll->size(); ++ jhit){
246  const EcalRecHit & rechitj = (*ecalrechitcoll)[ jhit ];
247  EcalRecHitRef rhRef(ecalrechitcoll,jhit);
248  math::XYZPoint rhposj = getPosition(rechitj.id(),vtx);
249 
250  double etaj = rhposj.eta();
251  double phij = rhposj.phi();
252 
253  double deta = eta - etaj;
254  double dphi = deltaPhi(phi,phij);
255  if(std::abs(deta)>0.2) continue;//This means +/-11 crystals in eta
256  if(std::abs(dphi)>0.08) continue;//This means +/-4 crystals in phi
257 
258  double rhetj = rechitj.energy()* sqrt(rhposj.perp2()/rhposj.mag2());
259  //Rechits with et between 1 and 2 GeV are saved in the rh list but not used in the calculation of the halocluster variables
260  if(rhetj<1) continue;
261  bhrhcandidates.push_back(rhRef);
262  if(rhetj<2) continue;
263 
264  if(std::abs(dphi)>0.03){isiso=false;break;}//The strip should be isolated
265  if(std::abs(dphi)<0.01) nbcrystalsameeta++;
266  if(dphi>0.01) etstrip_iphiseedplus1+=rhetj;
267  if(dphi<-0.01) etstrip_iphiseedminus1+=rhetj;
268  etcluster+=rhetj;
269  //Timing discriminator
270  //We assign a weight to the rechit defined as:
271  //Log10(Et)*f(T,R,Z)
272  //where f(T,R,Z) is the separation curve between halo-like and IP-like times.
273  //The time difference between a deposit from a outgoing IT halo and a deposit coming from a particle emitted at the IP is given by:
274  //dt= ( - sqrt(R^2+z^2) + |z| )/c
275  //Here we take R to be 130 cm.
276  //For EB, the function was parametrized as a function of ieta instead of Z.
277  double rhtj = rechitj.time();
278  EBDetId detj = rechitj.id();
279  int rhietaj= detj.ieta();
280  timediscriminator+= std::log10( rhetj )* ( rhtj +0.5*(sqrt(16900+9*rhietaj*rhietaj)-3*std::abs(rhietaj))/c_cm_per_ns );
281 
282  }
283  //Isolation condition
284  if(!isiso) continue;
285 
286  //Calculate H/E
287  double hoe(0);
288  for(size_t jhit = 0; jhit<hbherechitcoll->size(); ++ jhit){
289  const HBHERecHit & rechitj = (*hbherechitcoll)[ jhit ];
290  math::XYZPoint rhposj = getPosition(rechitj.id(),vtx);
291  double rhetj = rechitj.energy()* sqrt(rhposj.perp2()/rhposj.mag2());
292  if(rhetj<2) continue;
293  double etaj = rhposj.eta();
294  double phij = rhposj.phi();
295  double deta = eta - etaj;
296  double dphi = deltaPhi(phi,phij);
297  if(std::abs(deta)>0.2) continue;
298  if(std::abs(dphi)>0.2) continue;
299  hoe+=rhetj/etcluster;
300  }
301  //H/E condition
302  if(hoe>0.1) continue;
303 
304 
305  clustercand.setClusterEt(etcluster);
306  clustercand.setSeedEt(rhet);
307  clustercand.setSeedEta(eta);
308  clustercand.setSeedPhi(phi);
309  clustercand.setSeedZ(rhpos.Z());
310  clustercand.setSeedR(sqrt(rhpos.perp2()));
311  clustercand.setSeedTime(rechit.time());
312  clustercand.setHoverE(hoe);
313  clustercand.setNbofCrystalsInEta(nbcrystalsameeta);
314  clustercand.setEtStripIPhiSeedPlus1(etstrip_iphiseedplus1);
315  clustercand.setEtStripIPhiSeedMinus1(etstrip_iphiseedminus1);
316  clustercand.setTimeDiscriminator(timediscriminator);
317  clustercand.setBeamHaloRecHitsCandidates(bhrhcandidates);
318 
319 
320  bool isbeamhalofrompattern = EBClusterShapeandTimeStudy(clustercand,false);
321  clustercand.setIsHaloFromPattern(isbeamhalofrompattern);
322 
323  bool isbeamhalofrompattern_hlt = EBClusterShapeandTimeStudy(clustercand,true);
324  clustercand.setIsHaloFromPattern_HLT(isbeamhalofrompattern_hlt);
325 
326 
327  TheHaloClusterCandsEB.push_back(clustercand);
328  }
329 
330  return TheHaloClusterCandsEB;
331 }
constexpr float energy() const
Definition: CaloRecHit.h:31
HcalDetId id() const
get the id
Definition: HBHERecHit.h:42
float time() const
Definition: EcalRecHit.h:70
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float energy() const
Definition: EcalRecHit.h:68
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
DetId id() const
get the id
Definition: EcalRecHit.h:77
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
size_type size() const
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
void setBeamHaloRecHitsCandidates(edm::RefVector< EcalRecHitCollection > x)
bool EBClusterShapeandTimeStudy(reco::HaloClusterCandidateECAL hcand, bool ishlt)
std::vector< HaloClusterCandidateECAL > EcalHaloAlgo::GetHaloClusterCandidateEE ( edm::Handle< EcalRecHitCollection > &  ecalrechitcoll,
edm::Handle< HBHERecHitCollection > &  hbherechitcoll,
float  et_thresh_seedrh 
)

Definition at line 336 of file EcalHaloAlgo.cc.

References funct::abs(), hiPixelPairStep_cff::deltaPhi, runTauDisplay::dr, CaloRecHit::energy(), EcalRecHit::energy(), PVValHelper::eta, HBHERecHit::id(), EcalRecHit::id(), funct::pow(), edm::RefVector< C, T, F >::push_back(), reco::HaloClusterCandidateECAL::setBeamHaloRecHitsCandidates(), reco::HaloClusterCandidateECAL::setClusterEt(), reco::HaloClusterCandidateECAL::setClusterSize(), reco::HaloClusterCandidateECAL::setH2overE(), reco::HaloClusterCandidateECAL::setIsHaloFromPattern(), reco::HaloClusterCandidateECAL::setIsHaloFromPattern_HLT(), reco::HaloClusterCandidateECAL::setNbEarlyCrystals(), reco::HaloClusterCandidateECAL::setNbLateCrystals(), reco::HaloClusterCandidateECAL::setSeedEt(), reco::HaloClusterCandidateECAL::setSeedEta(), reco::HaloClusterCandidateECAL::setSeedPhi(), reco::HaloClusterCandidateECAL::setSeedR(), reco::HaloClusterCandidateECAL::setSeedTime(), reco::HaloClusterCandidateECAL::setSeedZ(), reco::HaloClusterCandidateECAL::setTimeDiscriminator(), edm::SortedCollection< T, SORT >::size(), mathSSE::sqrt(), EcalRecHit::time(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by SetPhiWedgeThresholds().

336  {
337 
338  std::vector<HaloClusterCandidateECAL> TheHaloClusterCandsEE;
339 
340  reco::Vertex::Point vtx(0,0,0);
341 
342  for(size_t ihit = 0; ihit<ecalrechitcoll->size(); ++ ihit){
343  HaloClusterCandidateECAL clustercand;
344 
345  const EcalRecHit & rechit = (*ecalrechitcoll)[ ihit ];
346  math::XYZPoint rhpos = getPosition(rechit.id(),vtx);
347  //Et condition
348  double rhet = rechit.energy()* sqrt(rhpos.perp2()/rhpos.mag2());
349  if(rhet<et_thresh_seedrh) continue;
350  double eta = rhpos.eta();
351  double phi = rhpos.phi();
352  double rhr = sqrt(rhpos.perp2());
353 
354  bool isiso = true;
355  double etcluster(0);
356  double timediscriminator(0);
357  int clustersize(0);
358  int nbcrystalssmallt(0);
359  int nbcrystalshight(0);
360  //Building the cluster
362  for(size_t jhit = 0; jhit<ecalrechitcoll->size(); ++ jhit){
363  const EcalRecHit & rechitj = (*ecalrechitcoll)[ jhit ];
364  EcalRecHitRef rhRef(ecalrechitcoll,jhit);
365  math::XYZPoint rhposj = getPosition(rechitj.id(),vtx);
366 
367  //Ask the hits to be in the same endcap
368  if(rhposj.z()*rhpos.z()<0)continue;
369 
370  double etaj = rhposj.eta();
371  double phij = rhposj.phi();
372  double dr = sqrt((eta-etaj)*(eta-etaj)+deltaPhi(phi,phij)*deltaPhi(phi,phij));
373 
374  //Outer cone
375  if(dr>0.3) continue;
376 
377  double rhetj = rechitj.energy()* sqrt(rhposj.perp2()/rhposj.mag2());
378  //Rechits with et between 1 and 2 GeV are saved in the rh list but not used in the calculation of the halocluster variables
379  if(rhetj<1) continue;
380  bhrhcandidates.push_back(rhRef);
381  if(rhetj<2) continue;
382 
383  //Isolation between outer and inner cone
384  if(dr>0.05){isiso=false;break;}//The deposit should be isolated
385 
386  etcluster+=rhetj;
387 
388  //Timing infos:
389  //Here we target both IT and OT beam halo
390  double rhtj=rechitj.time();
391 
392  //Discriminating variables for OT beam halo:
393  if(rhtj>1) nbcrystalshight++;
394  if(rhtj<0) nbcrystalssmallt++;
395  //Timing test (likelihood ratio), only for seeds with large R (100 cm) and for crystals with et>5,
396  //This targets IT beam halo (t around - 1ns)
397  if(rhtj>5){
398  double corrt_j = rhtj + sqrt(rhposj.x()*rhposj.x()+rhposj.y()*rhposj.y() + 320.*320.)/c_cm_per_ns - 320./c_cm_per_ns;
399  //BH is modeled by a Gaussian peaking at 0.
400  //Collisions is modeled by a Gaussian peaking at 0.3
401  //The width is similar and taken to be 0.4
402  timediscriminator+= 0.5*(pow( (corrt_j-0.3)/0.4,2)-pow( (corrt_j-0.)/0.4,2));
403  clustersize++;
404  }
405 
406  }
407  //Isolation condition
408  if(!isiso) continue;
409 
410  //Calculate H2/E
411  //Only second hcal layer is considered as it can happen that a shower initiated in EE reaches HCAL first layer
412  double h2oe(0);
413  for(size_t jhit = 0; jhit<hbherechitcoll->size(); ++ jhit){
414  const HBHERecHit & rechitj = (*hbherechitcoll)[ jhit ];
415  math::XYZPoint rhposj = getPosition(rechitj.id(),vtx);
416 
417  //Ask the hits to be in the same endcap
418  if(rhposj.z()*rhpos.z()<0)continue;
419  //Selects only second HCAL layer
420  if(std::abs(rhposj.z())<425) continue;
421 
422  double rhetj = rechitj.energy()* sqrt(rhposj.perp2()/rhposj.mag2());
423  if(rhetj<2) continue;
424 
425  double phij = rhposj.phi();
426  if(std::abs(deltaPhi(phi,phij))>0.4 ) continue;
427 
428  double rhrj = sqrt(rhposj.perp2());
429  if(std::abs(rhr-rhrj)>50) continue;
430 
431  h2oe+=rhetj/etcluster;
432  }
433  //H/E condition
434  if(h2oe>0.1) continue;
435 
436 
437  clustercand.setClusterEt(etcluster);
438  clustercand.setSeedEt(rhet);
439  clustercand.setSeedEta(eta);
440  clustercand.setSeedPhi(phi);
441  clustercand.setSeedZ(rhpos.Z());
442  clustercand.setSeedR(sqrt(rhpos.perp2()));
443  clustercand.setSeedTime(rechit.time());
444  clustercand.setH2overE(h2oe);
445  clustercand.setNbEarlyCrystals(nbcrystalssmallt);
446  clustercand.setNbLateCrystals(nbcrystalshight);
447  clustercand.setClusterSize(clustersize);
448  clustercand.setTimeDiscriminator(timediscriminator);
449  clustercand.setBeamHaloRecHitsCandidates(bhrhcandidates);
450 
451  bool isbeamhalofrompattern = EEClusterShapeandTimeStudy_ITBH(clustercand,false) || EEClusterShapeandTimeStudy_OTBH(clustercand,false);
452  clustercand.setIsHaloFromPattern(isbeamhalofrompattern);
453 
454  bool isbeamhalofrompattern_hlt = EEClusterShapeandTimeStudy_ITBH(clustercand,true) || EEClusterShapeandTimeStudy_OTBH(clustercand,true);
455  clustercand.setIsHaloFromPattern_HLT(isbeamhalofrompattern_hlt);
456 
457  TheHaloClusterCandsEE.push_back(clustercand);
458  }
459 
460  return TheHaloClusterCandsEE;
461 }
constexpr float energy() const
Definition: CaloRecHit.h:31
HcalDetId id() const
get the id
Definition: HBHERecHit.h:42
float time() const
Definition: EcalRecHit.h:70
bool EEClusterShapeandTimeStudy_OTBH(reco::HaloClusterCandidateECAL hcand, bool ishlt)
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float energy() const
Definition: EcalRecHit.h:68
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
DetId id() const
get the id
Definition: EcalRecHit.h:77
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool EEClusterShapeandTimeStudy_ITBH(reco::HaloClusterCandidateECAL hcand, bool ishlt)
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
size_type size() const
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
void setBeamHaloRecHitsCandidates(edm::RefVector< EcalRecHitCollection > x)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
float EcalHaloAlgo::GetPhiWedgeEnergyThreshold ( )
inline

Definition at line 86 of file EcalHaloAlgo.h.

References SumEnergyThreshold.

86 { return SumEnergyThreshold;}
float SumEnergyThreshold
Definition: EcalHaloAlgo.h:103
int EcalHaloAlgo::GetPhiWedgeNHitsThreshold ( )
inline

Definition at line 87 of file EcalHaloAlgo.h.

References NHitsThreshold.

87 { return NHitsThreshold;}
math::XYZPoint EcalHaloAlgo::getPosition ( const DetId id,
reco::Vertex::Point  vtx 
)
private

Definition at line 527 of file EcalHaloAlgo.cc.

References PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

527  {
528 
529  const GlobalPoint& pos=geo->getPosition(id);
530  math::XYZPoint posV(pos.x() - vtx.x(),pos.y() - vtx.y(),pos.z() - vtx.z());
531  return posV;
532 }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:74
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:62
const CaloGeometry * geo
Definition: EcalHaloAlgo.h:106
float EcalHaloAlgo::GetRoundnessCut ( )
inline

Definition at line 76 of file EcalHaloAlgo.h.

References RoundnessCut.

76 {return RoundnessCut ;}
float RoundnessCut
Definition: EcalHaloAlgo.h:93
void EcalHaloAlgo::SetAngleCut ( float  a = 4.)
inline

Definition at line 57 of file EcalHaloAlgo.h.

References a, and AngleCut.

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

57 { AngleCut =a;}
double a
Definition: hdecay.h:121
float AngleCut
Definition: EcalHaloAlgo.h:95
void EcalHaloAlgo::SetPhiWedgeEnergyThreshold ( float  SumE)
inline

Definition at line 62 of file EcalHaloAlgo.h.

References SumEnergyThreshold.

62 { SumEnergyThreshold = SumE ;}
float SumEnergyThreshold
Definition: EcalHaloAlgo.h:103
void EcalHaloAlgo::SetPhiWedgeNHitsThreshold ( int  nhits)
inline

Definition at line 63 of file EcalHaloAlgo.h.

References nhits, and NHitsThreshold.

void EcalHaloAlgo::SetPhiWedgeThresholds ( float  SumE,
int  nhits 
)
inline
void EcalHaloAlgo::SetRecHitEnergyThresholds ( float  EB,
float  EE,
float  ES 
)
inline
void EcalHaloAlgo::SetRoundnessCut ( float  r = 100.)
inline

Definition at line 55 of file EcalHaloAlgo.h.

References alignCSCRings::r, and RoundnessCut.

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

Member Data Documentation

float EcalHaloAlgo::AngleCut
private

Definition at line 95 of file EcalHaloAlgo.h.

Referenced by GetAngleCut(), and SetAngleCut().

float EcalHaloAlgo::EBRecHitEnergyThreshold
private

Definition at line 98 of file EcalHaloAlgo.h.

Referenced by GetEBRecHitEnergyThreshold(), and SetRecHitEnergyThresholds().

float EcalHaloAlgo::EERecHitEnergyThreshold
private

Definition at line 99 of file EcalHaloAlgo.h.

Referenced by GetEERecHitEnergyThreshold(), and SetRecHitEnergyThresholds().

float EcalHaloAlgo::ESRecHitEnergyThreshold
private

Definition at line 100 of file EcalHaloAlgo.h.

Referenced by GetESRecHitEnergyThreshold(), and SetRecHitEnergyThresholds().

const CaloGeometry* EcalHaloAlgo::geo
private

Definition at line 106 of file EcalHaloAlgo.h.

int EcalHaloAlgo::NHitsThreshold
private
float EcalHaloAlgo::RoundnessCut
private

Definition at line 93 of file EcalHaloAlgo.h.

Referenced by GetRoundnessCut(), and SetRoundnessCut().

float EcalHaloAlgo::SumEnergyThreshold
private