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 Attributes
GlobalHaloAlgo Class Reference

#include <GlobalHaloAlgo.h>

Public Member Functions

reco::GlobalHaloData Calculate (const CaloGeometry &TheCaloGeometry, const CSCGeometry &TheCSCGeometry, const reco::CaloMET &TheCaloMET, edm::Handle< edm::View< reco::Candidate > > &TheCaloTowers, edm::Handle< CSCSegmentCollection > &TheCSCSegments, edm::Handle< CSCRecHit2DCollection > &TheCSCRecHits, const reco::CSCHaloData &TheCSCHaloData, const reco::EcalHaloData &TheEcalHaloData, const reco::HcalHaloData &TheHcalHaloData)
 
 GlobalHaloAlgo ()
 
void SetCaloTowerEtThreshold (float EtMin)
 
void SetEcalMatchingRadius (float min, float max)
 
void SetHcalMatchingRadius (float min, float max)
 
 ~GlobalHaloAlgo ()
 

Private Attributes

float Ecal_R_Max
 
float Ecal_R_Min
 
float Hcal_R_Max
 
float Hcal_R_Min
 
float TowerEtThreshold
 

Detailed Description

Definition at line 57 of file GlobalHaloAlgo.h.

Constructor & Destructor Documentation

GlobalHaloAlgo::GlobalHaloAlgo ( )

Definition at line 30 of file GlobalHaloAlgo.cc.

31 {
32  // Defaults are "loose"
33  Ecal_R_Min = 110.; // Tight: 200.
34  Ecal_R_Max = 330.; // Tight: 250.
35  Hcal_R_Min = 110.; // Tight: 220.
36  Hcal_R_Max = 490.; // Tight: 350.
37 
38 }
GlobalHaloAlgo::~GlobalHaloAlgo ( )
inline

Definition at line 62 of file GlobalHaloAlgo.h.

62 {}

Member Function Documentation

reco::GlobalHaloData GlobalHaloAlgo::Calculate ( const CaloGeometry TheCaloGeometry,
const CSCGeometry TheCSCGeometry,
const reco::CaloMET TheCaloMET,
edm::Handle< edm::View< reco::Candidate > > &  TheCaloTowers,
edm::Handle< CSCSegmentCollection > &  TheCSCSegments,
edm::Handle< CSCRecHit2DCollection > &  TheCSCRecHits,
const reco::CSCHaloData TheCSCHaloData,
const reco::EcalHaloData TheEcalHaloData,
const reco::HcalHaloData TheHcalHaloData 
)

Definition at line 40 of file GlobalHaloAlgo.cc.

References funct::abs(), Abs(), EnergyCorrector::c, MuonSubdetId::CSC, CaloTower::emEt(), CaloTower::et(), reco::CSCHaloData::GetCSCTrackImpactPositions(), reco::GlobalHaloData::GetMatchedEcalPhiWedges(), reco::GlobalHaloData::GetMatchedHcalPhiWedges(), reco::HcalHaloData::GetPhiWedges(), reco::EcalHaloData::GetPhiWedges(), CaloTower::hadEt(), i, CSCGeometry::idToDetUnit(), CaloTower::ieta(), CaloTower::iphi(), edm::HandleBase::isValid(), DetId::Muon, PV3DBase< T, PVType, FrameType >::phi(), reco::LeafCandidate::phi(), Phi_To_EcaliPhi(), Phi_To_HcaliPhi(), reco::LeafCandidate::pt(), alignCSCRings::r, reco::GlobalHaloData::SetMETCorrections(), reco::GlobalHaloData::SetMETOverSumEt(), reco::PhiWedge::SetOverlappingCSCRecHits(), reco::PhiWedge::SetOverlappingCSCSegments(), reco::MET::sumEt(), GeomDet::surface(), x, PV3DBase< T, PVType, FrameType >::x(), y, and PV3DBase< T, PVType, FrameType >::y().

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

41 {
42 
43  GlobalHaloData TheGlobalHaloData;
44  float METOverSumEt = TheCaloMET.sumEt() ? TheCaloMET.pt() / TheCaloMET.sumEt() : 0 ;
45  TheGlobalHaloData.SetMETOverSumEt(METOverSumEt);
46 
47  //int EcalOverlapping_CSCRecHits[73];
48  //int EcalOverlapping_CSCSegments[73];
49 
50  int EcalOverlapping_CSCRecHits[361];
51  int EcalOverlapping_CSCSegments[361];
52  int HcalOverlapping_CSCRecHits[73];
53  int HcalOverlapping_CSCSegments[73];
54 
55  if( TheCSCSegments.isValid() )
56  {
57  for(CSCSegmentCollection::const_iterator iSegment = TheCSCSegments->begin(); iSegment != TheCSCSegments->end(); iSegment++)
58  {
59  bool EcalOverlap[361];
60  bool HcalOverlap[73];
61  for( int i = 0 ; i < 361 ; i++ )
62  {
63  EcalOverlap[i] = false;
64  if( i < 73 ) HcalOverlap[i] = false;
65  }
66 
67  std::vector<CSCRecHit2D> Hits = iSegment->specificRecHits() ;
68  for(std::vector<CSCRecHit2D>::iterator iHit = Hits.begin() ; iHit != Hits.end(); iHit++ )
69  {
70  DetId TheDetUnitId(iHit->geographicalId());
71  if( TheDetUnitId.det() != DetId::Muon ) continue;
72  if( TheDetUnitId.subdetId() != MuonSubdetId::CSC ) continue;
73 
74  const GeomDetUnit *TheUnit = TheCSCGeometry.idToDetUnit(TheDetUnitId);
75  LocalPoint TheLocalPosition = iHit->localPosition();
76  const BoundPlane& TheSurface = TheUnit->surface();
77  const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
78 
79  int Hcal_iphi = Phi_To_HcaliPhi( TheGlobalPosition.phi() ) ;
80  int Ecal_iphi = Phi_To_EcaliPhi( TheGlobalPosition.phi() ) ;
81  float x = TheGlobalPosition.x();
82  float y = TheGlobalPosition.y();
83 
84  float r = TMath::Sqrt( x*x + y*y);
85 
86  if( r < Ecal_R_Max && r > Ecal_R_Min )
87  EcalOverlap[Ecal_iphi] = true;
88  if( r < Hcal_R_Max && r > Hcal_R_Max )
89  HcalOverlap[Hcal_iphi] = true;
90  }
91  for( int i = 0 ; i < 361 ; i++ )
92  {
93  if( EcalOverlap[i] ) EcalOverlapping_CSCSegments[i]++;
94  if( i < 73 && HcalOverlap[i] )
95  HcalOverlapping_CSCSegments[i]++;
96  }
97  }
98  }
99  if( TheCSCRecHits.isValid() )
100  {
101  for(CSCRecHit2DCollection::const_iterator iCSCRecHit = TheCSCRecHits->begin(); iCSCRecHit != TheCSCRecHits->end(); iCSCRecHit++ )
102  {
103 
104  DetId TheDetUnitId(iCSCRecHit->geographicalId());
105  if( TheDetUnitId.det() != DetId::Muon ) continue;
106  if( TheDetUnitId.subdetId() != MuonSubdetId::CSC ) continue;
107 
108  const GeomDetUnit *TheUnit = TheCSCGeometry.idToDetUnit(TheDetUnitId);
109  LocalPoint TheLocalPosition = iCSCRecHit->localPosition();
110  const BoundPlane& TheSurface = TheUnit->surface();
111  const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
112 
113  int Hcaliphi = Phi_To_HcaliPhi( TheGlobalPosition.phi() ) ;
114  int Ecaliphi = Phi_To_EcaliPhi( TheGlobalPosition.phi() ) ;
115  float x = TheGlobalPosition.x();
116  float y = TheGlobalPosition.y();
117 
118  float r = TMath::Sqrt(x*x + y*y);
119 
120  if( r < Ecal_R_Max && r > Ecal_R_Min )
121  EcalOverlapping_CSCRecHits[Ecaliphi] ++;
122  if( r < Hcal_R_Max && r > Hcal_R_Max )
123  HcalOverlapping_CSCRecHits[Hcaliphi] ++ ;
124  }
125  }
126 
127  // In development....
128  // Get Ecal Wedges
129  std::vector<PhiWedge> EcalWedges = TheEcalHaloData.GetPhiWedges();
130 
131  // Get Hcal Wedges
132  std::vector<PhiWedge> HcalWedges = TheHcalHaloData.GetPhiWedges();
133 
134  //Get Ref to CSC Tracks
135  //edm::RefVector<reco::TrackCollection> TheCSCTracks = TheCSCHaloData.GetTracks();
136  //for(unsigned int i = 0 ; i < TheCSCTracks.size() ; i++ )
137  //edm::Ref<reco::TrackCollection> iTrack( TheCSCTracks, i );
138 
139  // Get global positions of central most rechit of CSC Halo tracks
140  std::vector<GlobalPoint> TheGlobalPositions = TheCSCHaloData.GetCSCTrackImpactPositions();
141 
142  // Container to store Ecal/Hcal iPhi values matched to impact point of CSC tracks
143  std::vector<int> vEcaliPhi, vHcaliPhi;
144 
145  // Keep track of number of calo pointing CSC halo tracks that do not match to Phi wedges
146  int N_Unmatched_Tracks = 0;
147 
148  for( std::vector<GlobalPoint>::iterator Pos = TheGlobalPositions.begin() ; Pos != TheGlobalPositions.end() ; Pos ++ )
149  {
150  // Calculate global phi coordinate for central most rechit in the track
151  float global_phi = Pos->phi();
152  float global_r = TMath::Sqrt(Pos->x()*Pos->x() + Pos->y()*Pos->y());
153 
154  // Convert global phi to iPhi
155  int global_EcaliPhi = Phi_To_EcaliPhi( global_phi );
156  int global_HcaliPhi = Phi_To_HcaliPhi( global_phi );
157  bool MATCHED = false;
158 
159  //Loop over Ecal Phi Wedges
160  for( std::vector<PhiWedge>::iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end() ; iWedge++ )
161  {
162  if( (TMath::Abs( global_EcaliPhi - iWedge->iPhi() ) <= 5 ) && (global_r > Ecal_R_Min && global_r < Ecal_R_Max ) )
163  {
164  bool StoreWedge = true;
165  for( unsigned int i = 0 ; i< vEcaliPhi.size() ; i++ ) if ( vEcaliPhi[i] == iWedge->iPhi() ) StoreWedge = false;
166 
167  if( StoreWedge )
168  {
169  PhiWedge NewWedge(*iWedge);
170  NewWedge.SetOverlappingCSCSegments( EcalOverlapping_CSCSegments[iWedge->iPhi()] );
171  NewWedge.SetOverlappingCSCRecHits( EcalOverlapping_CSCRecHits[iWedge->iPhi()] );
172  vEcaliPhi.push_back( iWedge->iPhi() );
173  TheGlobalHaloData.GetMatchedEcalPhiWedges().push_back( NewWedge );
174  }
175  MATCHED = true;
176  }
177  }
178  //Loop over Hcal Phi Wedges
179  for( std::vector<PhiWedge>::iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end() ; iWedge++ )
180  {
181  if( (TMath::Abs( global_HcaliPhi - iWedge->iPhi() ) <= 2 ) && (global_r > Hcal_R_Min && global_r < Hcal_R_Max ) )
182  {
183  bool StoreWedge = true;
184  for( unsigned int i = 0 ; i < vHcaliPhi.size() ; i++ ) if( vHcaliPhi[i] == iWedge->iPhi() ) StoreWedge = false;
185 
186  if( StoreWedge )
187  {
188  vHcaliPhi.push_back( iWedge->iPhi() ) ;
189  PhiWedge NewWedge(*iWedge);
190  NewWedge.SetOverlappingCSCSegments( HcalOverlapping_CSCSegments[iWedge->iPhi()] );
191  NewWedge.SetOverlappingCSCRecHits( HcalOverlapping_CSCRecHits[iWedge->iPhi()] );
192  PhiWedge wedge(*iWedge);
193  TheGlobalHaloData.GetMatchedHcalPhiWedges().push_back( NewWedge ) ;
194  }
195  MATCHED = true;
196  }
197  }
198  if( !MATCHED ) N_Unmatched_Tracks ++;
199  }
200 
201  // Corrections to MEx, MEy
202  float dMEx = 0.;
203  float dMEy = 0.;
204  // Loop over calotowers and correct the MET for the towers that lie in the trajectory of the CSC Halo Tracks
205  for( edm::View<Candidate>::const_iterator iCandidate = TheCaloTowers->begin() ; iCandidate != TheCaloTowers->end() ; iCandidate++ )
206  {
207  const Candidate* c = &(*iCandidate);
208  if ( c )
209  {
210  const CaloTower* iTower = dynamic_cast<const CaloTower*> (c);
211  if( iTower->et() < TowerEtThreshold ) continue;
212  if( abs(iTower->ieta()) > 24 ) continue; // not in barrel/endcap
213  int iphi = iTower->iphi();
214  for( unsigned int x = 0 ; x < vEcaliPhi.size() ; x++ )
215  {
216  if( iphi == vEcaliPhi[x] )
217  {
218  dMEx += ( TMath::Cos(iTower->phi())*iTower->emEt() );
219  dMEy += ( TMath::Sin(iTower->phi())*iTower->emEt() );
220  }
221  }
222  for( unsigned int x = 0 ; x < vHcaliPhi.size() ; x++ )
223  {
224  if( iphi == vHcaliPhi[x] )
225  {
226  dMEx += ( TMath::Cos(iTower->phi() )*iTower->hadEt() ) ;
227  dMEy += ( TMath::Sin(iTower->phi() )*iTower->hadEt() ) ;
228  }
229  }
230  }
231  }
232 
233  TheGlobalHaloData.SetMETCorrections(dMEx, dMEy);
234  return TheGlobalHaloData;
235 }
int i
Definition: DBlmapReader.cc:9
float TowerEtThreshold
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: EcalHaloData.h:32
int ieta() const
Definition: CaloTower.h:169
double hadEt() const
Definition: CaloTower.h:100
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
void SetMETOverSumEt(float x)
int iphi() const
Definition: CaloTower.h:171
std::vector< PhiWedge > & GetMatchedEcalPhiWedges()
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
virtual double pt() const
transverse momentum
double sumEt() const
Definition: MET.h:56
static const int CSC
Definition: MuonSubdetId.h:13
const_iterator begin() const
int Phi_To_HcaliPhi(float phi)
T Abs(T a)
Definition: MathUtil.h:49
const std::vector< GlobalPoint > & GetCSCTrackImpactPositions() const
Definition: CSCHaloData.h:85
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:75
Definition: DetId.h:18
void SetMETCorrections(float x, float y)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85
std::vector< PhiWedge > & GetMatchedHcalPhiWedges()
int Phi_To_EcaliPhi(float phi)
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: HcalHaloData.h:21
double et(double vtxZ) const
Definition: CaloTower.h:116
const_iterator end() const
virtual const GeomDetUnit * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:93
T x() const
Definition: PV3DBase.h:62
virtual double phi() const
momentum azimuthal angle
double emEt() const
Definition: CaloTower.h:99
void GlobalHaloAlgo::SetCaloTowerEtThreshold ( float  EtMin)
inline
void GlobalHaloAlgo::SetEcalMatchingRadius ( float  min,
float  max 
)
inline

Definition at line 68 of file GlobalHaloAlgo.h.

References Ecal_R_Max, Ecal_R_Min, bookConverter::max, and min().

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

T min(T a, T b)
Definition: MathUtil.h:58
void GlobalHaloAlgo::SetHcalMatchingRadius ( float  min,
float  max 
)
inline

Definition at line 70 of file GlobalHaloAlgo.h.

References Hcal_R_Max, Hcal_R_Min, bookConverter::max, and min().

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

T min(T a, T b)
Definition: MathUtil.h:58

Member Data Documentation

float GlobalHaloAlgo::Ecal_R_Max
private

Definition at line 77 of file GlobalHaloAlgo.h.

Referenced by SetEcalMatchingRadius().

float GlobalHaloAlgo::Ecal_R_Min
private

Definition at line 76 of file GlobalHaloAlgo.h.

Referenced by SetEcalMatchingRadius().

float GlobalHaloAlgo::Hcal_R_Max
private

Definition at line 79 of file GlobalHaloAlgo.h.

Referenced by SetHcalMatchingRadius().

float GlobalHaloAlgo::Hcal_R_Min
private

Definition at line 78 of file GlobalHaloAlgo.h.

Referenced by SetHcalMatchingRadius().

float GlobalHaloAlgo::TowerEtThreshold
private

Definition at line 80 of file GlobalHaloAlgo.h.

Referenced by SetCaloTowerEtThreshold().