CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFRecHitCaloNavigatorWithTime.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFRecHitCaloNavigatorWithTime_h
2 #define RecoParticleFlow_PFClusterProducer_PFRecHitCaloNavigatorWithTime_h
3 
4 
8 
14 
19 
22 
24 
25 template <typename D,typename T,bool ownsTopo=true>
27  public:
29  noiseLevel2_ = pow(iConfig.getParameter<double>("noiseLevel"), 2);
30  noiseTerm2_ = pow(iConfig.getParameter<double>("noiseTerm"), 2);
31  constantTerm2_ = pow(iConfig.getParameter<double>("constantTerm"), 2);
32  sigmaCut2_ = pow(iConfig.getParameter<double>("sigmaCut"), 2);
33 
35  if( iConfig.exists("timeResolutionCalc") ) {
36  const edm::ParameterSet& timeResConf =
37  iConfig.getParameterSet("timeResolutionCalc");
38  _timeResolutionCalc.reset(new ECALRecHitResolutionProvider(timeResConf));
39  }
40  }
41 
42  virtual ~PFRecHitCaloNavigatorWithTime() { if(!ownsTopo) { topology_.release(); } }
43 
44 
45  void associateNeighbours(reco::PFRecHit& hit,std::auto_ptr<reco::PFRecHitCollection>& hits,edm::RefProd<reco::PFRecHitCollection>& refProd) {
46  DetId detid( hit.detId() );
47 
48  CaloNavigator<D> navigator(detid, topology_.get());
49 
50  DetId N(0);
51  DetId E(0);
52  DetId S(0);
53  DetId W(0);
54  DetId NW(0);
55  DetId NE(0);
56  DetId SW(0);
57  DetId SE(0);
58 
59 
60  N=navigator.north();
61  associateNeighbour(N,hit,hits,refProd,0,1);
62 
63 
64  if (N !=DetId(0)) {
65  NE=navigator.east();
66  }
67  else
68  {
69  navigator.home();
70  E=navigator.east();
71  NE=navigator.north();
72  }
73  associateNeighbour(NE,hit,hits,refProd,1,1);
74  navigator.home();
75 
76  S = navigator.south();
77  associateNeighbour(S,hit,hits,refProd,0,-1);
78 
79  if (S !=DetId(0)) {
80  SW = navigator.west();
81  } else {
82  navigator.home();
83  W=navigator.west();
84  SW=navigator.south();
85  }
86  associateNeighbour(SW,hit,hits,refProd,-1,-1);
87  navigator.home();
88 
89  E = navigator.east();
90  associateNeighbour(E,hit,hits,refProd,1,0);
91 
92  if (E !=DetId(0)) {
93  SE = navigator.south();
94  } else {
95  navigator.home();
96  S=navigator.south();
97  SE=navigator.east();
98  }
99  associateNeighbour(SE,hit,hits,refProd,1,-1);
100  navigator.home();
101 
102 
103  W = navigator.west();
104  associateNeighbour(W,hit,hits,refProd,-1,0);
105 
106  if (W !=DetId(0)) {
107  NW = navigator.north();
108  } else {
109  navigator.home();
110  N=navigator.north();
111  NW=navigator.west();
112  }
113  associateNeighbour(NW,hit,hits,refProd,-1,1);
114  }
115 
116 
117 
118  protected:
119 
120 
121  void associateNeighbour(const DetId& id, reco::PFRecHit& hit,std::auto_ptr<reco::PFRecHitCollection>& hits,edm::RefProd<reco::PFRecHitCollection>& refProd,short eta, short phi) {
122  double sigma2=10000.0;
123 
124  const reco::PFRecHit temp(id,PFLayer::NONE,0.0,math::XYZPoint(0,0,0),math::XYZVector(0,0,0),std::vector<math::XYZPoint>());
125  auto found_hit = std::lower_bound(hits->begin(),hits->end(),
126  temp,
127  [](const reco::PFRecHit& a,
128  const reco::PFRecHit& b){
129  return a.detId() < b.detId();
130  });
131  if( found_hit != hits->end() && found_hit->detId() == id.rawId() ) {
132  if (_timeResolutionCalc) {
133  sigma2 = _timeResolutionCalc->timeResolution2(hit.energy()) + _timeResolutionCalc->timeResolution2(found_hit->energy());
134  }
135  else {
136  const double hitEnergy = hit.energy();
137  const double hitEnergy2 = hitEnergy*hitEnergy;
138  const double fhEnergy = found_hit->energy();
139  const double fhEnergy2 = fhEnergy*fhEnergy;
140  sigma2 = noiseTerm2_*noiseLevel2_*(hitEnergy2+fhEnergy2)/(hitEnergy2*fhEnergy2) + 2*constantTerm2_;
141  }
142  const double deltaTime = hit.time()-found_hit->time();
143  if(deltaTime*deltaTime/sigma2<sigmaCut2_) {
144  hit.addNeighbour(eta,phi,0,reco::PFRecHitRef(refProd,std::distance(hits->begin(),found_hit)));
145  }
146  }
147  }
148 
149  std::unique_ptr<const T> topology_;
150  double noiseLevel2_;
151  double noiseTerm2_;
153  double sigmaCut2_;
154 
155  std::unique_ptr<ECALRecHitResolutionProvider> _timeResolutionCalc;
156 
157 
158 
159 };
160 
161 #endif
162 
163 
std::unique_ptr< ECALRecHitResolutionProvider > _timeResolutionCalc
T getParameter(std::string const &) const
unsigned detId() const
rechit detId
Definition: PFRecHit.h:101
void addNeighbour(short x, short y, short z, const PFRecHitRef &)
Definition: PFRecHit.cc:129
bool exists(std::string const &parameterName) const
checks if a parameter exists
#define NULL
Definition: scimark2.h:8
T eta() const
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:35
Definition: DetId.h:18
#define N
Definition: blowfish.cc:9
ParameterSet const & getParameterSet(std::string const &) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double b
Definition: hdecay.h:120
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
double energy() const
rechit energy
Definition: PFRecHit.h:107
double a
Definition: hdecay.h:121
PFRecHitCaloNavigatorWithTime(const edm::ParameterSet &iConfig)
double time() const
timing for cleaned hits
Definition: PFRecHit.h:111
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void associateNeighbours(reco::PFRecHit &hit, std::auto_ptr< reco::PFRecHitCollection > &hits, edm::RefProd< reco::PFRecHitCollection > &refProd)
void associateNeighbour(const DetId &id, reco::PFRecHit &hit, std::auto_ptr< reco::PFRecHitCollection > &hits, edm::RefProd< reco::PFRecHitCollection > &refProd, short eta, short phi)
Definition: DDAxes.h:10