/
BarrelMeasurementEstimator.cc
149 lines (116 loc) · 4.56 KB
/
BarrelMeasurementEstimator.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// -*- C++ -*-
//
// Package: EgammaElectronAlgos
// Class: BarrelMeasurementEstimator
//
/**\class ElectronSeedProducer EgammaElectronAlgos/BarrelMeasurementEstimator
Description: MeasurementEstimator for Pixel Barrel, ported from ORCA
Implementation:
<Notes on implementation>
*/
//
// Original Author: Ursula Berthon, Claude Charlot
// Created: Mon Mar 27 13:22:06 CEST 2006
//
//
#include "RecoEgamma/EgammaElectronAlgos/interface/BarrelMeasurementEstimator.h"
#include "RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h"
#include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
#include "TrackingTools/DetLayers/interface/rangesIntersect.h"
#include "TrackingTools/DetLayers/interface/PhiLess.h"
// zero value indicates incompatible ts - hit pair
std::pair<bool,double> BarrelMeasurementEstimator::estimate( const TrajectoryStateOnSurface& ts,
const TrackingRecHit& hit) const {
LocalPoint lp = hit.localPosition();
GlobalPoint gp = hit.det()->surface().toGlobal( lp);
return this->estimate(ts,gp);
}
//usable in case we have no TransientTrackingRecHit
std::pair<bool,double> BarrelMeasurementEstimator::estimate( const TrajectoryStateOnSurface& ts,
const GlobalPoint &gp) const {
float myZ = gp.z();
float myR = gp.perp();
float zDiff = ts.globalParameters().position().z() - myZ;
float myZmax = theZMax;
float myZmin = theZMin;
if(std::abs(myZ)<30. && myR>8.) {
myZmax = 0.09;
myZmin = -0.09;
}
if( zDiff >= myZmax || zDiff <= myZmin ) return std::pair<bool,double>(false,0.);
float tsPhi = ts.globalParameters().position().phi();
float rhPhi = gp.phi();
float phiDiff = tsPhi - rhPhi;
if (phiDiff > pi) phiDiff -= twopi;
if (phiDiff < -pi) phiDiff += twopi;
if ( phiDiff < thePhiMax && phiDiff > thePhiMin ) {
return std::pair<bool,double>(true,1.);
} else {
return std::pair<bool,double>(false,0.);
}
}
std::pair<bool,double> BarrelMeasurementEstimator::estimate
( const GlobalPoint & vprim,
const TrajectoryStateOnSurface & absolute_ts,
const GlobalPoint& absolute_gp ) const
{
GlobalVector ts = absolute_ts.globalParameters().position() - vprim ;
GlobalVector gp = absolute_gp - vprim ;
float myR = gp.perp();
float myZ = gp.z();
float zDiff = myZ -ts.z() ;
float myZmax = theZMax;
float myZmin = theZMin;
if( (std::abs(myZ)<30.f) & (myR>8.f) )
{
myZmax = 0.09f;
myZmin = -0.09f;
}
if( zDiff >= myZmax || zDiff <= myZmin ) return std::pair<bool,double>(false,0.);
float rhPhi = gp.barePhi() ;
float tsPhi = ts.barePhi();
float phiDiff = normalized_phi(rhPhi-tsPhi) ;
if ( (phiDiff < thePhiMax) & (phiDiff > thePhiMin) )
{ return std::pair<bool,double>(true,1.) ; }
else
{ return std::pair<bool,double>(false,0.) ; }
}
bool BarrelMeasurementEstimator::estimate
( const TrajectoryStateOnSurface & ts,
const BoundPlane& plane) const
{
typedef std::pair<float,float> Range;
GlobalPoint trajPos(ts.globalParameters().position());
Range trajZRange(trajPos.z() - std::abs(theZMin), trajPos.z() + std::abs(theZMax));
Range trajPhiRange(trajPos.phi() - std::abs(thePhiMin), trajPos.phi() + std::abs(thePhiMax));
if(rangesIntersect(trajZRange, plane.zSpan()) &&
rangesIntersect(trajPhiRange, plane.phiSpan(), PhiLess()))
{
return true;
}
else
{
// cout <<cout<<" barrel boundpl est returns false!!"<<endl;
// cout<<"BarrelMeasurementEstimator(estimate) :thePhiMin,thePhiMax, theZMin,theZMax "<<thePhiMin<<" "<<thePhiMax<<" "<< theZMin<<" "<<theZMax<<endl;
// cout<<" trajZRange "<<trajZRange.first<<" "<<trajZRange.second<<endl;
// cout<<" trajPhiRange "<<trajPhiRange.first<<" "<<trajPhiRange.second<<endl;
// cout<<" detZRange "<<detRange.zRange().first<<" "<<detRange.zRange().second<<endl;
// cout<<" detPhiRange "<<detRange.phiRange().first<<" "<<detRange.phiRange().second<<endl;
// cout<<" intersect z: "<<rangesIntersect(trajZRange, detRange.zRange())<<endl;
// cout<<" intersect phi: "<<rangesIntersect(trajPhiRange, detRange.phiRange(), PhiLess())<<endl;
return false ;
}
}
MeasurementEstimator::Local2DVector
BarrelMeasurementEstimator::maximalLocalDisplacement
( const TrajectoryStateOnSurface & ts,
const BoundPlane & plane) const
{
float nSigmaCut = 3. ;
if ( ts.hasError())
{
LocalError le = ts.localError().positionError() ;
return Local2DVector( std::sqrt(le.xx())*nSigmaCut, std::sqrt(le.yy())*nSigmaCut) ;
}
else return Local2DVector(99999,99999) ;
}