CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalClusterLazyTools.h
Go to the documentation of this file.
1 #ifndef RecoEcal_EgammaCoreTools_EcalClusterLazyTools_h
2 #define RecoEcal_EgammaCoreTools_EcalClusterLazyTools_h
3 
18 
20 
28 
39 #include <optional>
40 
41 class CaloTopology;
42 class CaloGeometry;
44 
46 public:
47  struct ESData {
53  };
54 
55  class ESGetTokens {
56  public:
59  caloTopologyToken_{cc.esConsumes()},
60  ecalIntercalibConstantsToken_{cc.esConsumes()},
61  ecalADCToGeVConstantToken_{cc.esConsumes()},
62  ecalLaserDbServiceToken_{cc.esConsumes()} {}
63 
64  ESData get(edm::EventSetup const &eventSetup) const {
65  return {.caloGeometry = eventSetup.getData(caloGeometryToken_),
66  .caloTopology = eventSetup.getData(caloTopologyToken_),
67  .ecalIntercalibConstants = eventSetup.getData(ecalIntercalibConstantsToken_),
68  .ecalADCToGeV = eventSetup.getData(ecalADCToGeVConstantToken_),
69  .ecalLaserDbService = eventSetup.getData(ecalLaserDbServiceToken_)};
70  }
71 
72  private:
78  };
79 
81  ESData const &esData,
85 
86  // get time of basic cluster seed crystal
87  float BasicClusterSeedTime(const reco::BasicCluster &cluster);
88  // error-weighted average of time from constituents of basic cluster
89  float BasicClusterTime(const reco::BasicCluster &cluster, const edm::Event &ev);
90  // get BasicClusterSeedTime of the seed basic cluser of the supercluster
91  float SuperClusterSeedTime(const reco::SuperCluster &cluster);
92  // get BasicClusterTime of the seed basic cluser of the supercluster
93  inline float SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev) {
94  return BasicClusterTime((*cluster.seed()), ev);
95  }
96 
97  // mapping for preshower rechits
98  std::map<DetId, EcalRecHit> rechits_map_;
99  // get Preshower hit array
100  std::vector<float> getESHits(double X,
101  double Y,
102  double Z,
103  const std::map<DetId, EcalRecHit> &rechits_map,
104  const CaloGeometry *geometry,
105  CaloSubdetectorTopology const *topology_p,
106  int row = 0,
107  int plane = 1);
108  // get Preshower hit shape
109  float getESShape(const std::vector<float> &ESHits0);
110  // get Preshower effective sigmaRR
111  float eseffsirir(const reco::SuperCluster &cluster);
112  float eseffsixix(const reco::SuperCluster &cluster);
113  float eseffsiyiy(const reco::SuperCluster &cluster);
114 
115 protected:
117 
123 
124  std::unique_ptr<CaloSubdetectorTopology const> ecalPS_topology_ = nullptr;
125 
126  EcalIntercalibConstants const *ical = nullptr;
128  EcalADCToGeVConstant const *agc = nullptr;
129  EcalLaserDbService const *laser = nullptr;
130 
131 private:
132  void getESRecHits(const edm::Event &ev, edm::EDGetTokenT<EcalRecHitCollection> const &esRecHitsToken);
133 
134 }; // class EcalClusterLazyToolsBase
135 
136 template <class ClusterTools>
138 public:
140  ESData const &esData,
143  : EcalClusterLazyToolsBase(ev, esData, token1, token2, std::nullopt) {}
144 
146  ESData const &esData,
150  : EcalClusterLazyToolsBase(ev, esData, token1, token2, token3) {}
151 
152  // Get the rec hit energies in a rectangle matrix around the seed.
153  std::vector<float> energyMatrix(reco::BasicCluster const &cluster, int size) const {
154  auto recHits = getEcalRecHitCollection(cluster);
155  DetId maxId = ClusterTools::getMaximum(cluster, recHits).first;
156 
157  std::vector<float> energies;
158  for (auto const &detId : CaloRectangleRange(size, maxId, *topology_)) {
159  energies.push_back(ClusterTools::recHitEnergy(detId, recHits));
160  }
161 
162  return energies;
163  }
164 
165  // various energies in the matrix nxn surrounding the maximum energy crystal of the input cluster
166  //
167  // NOTE (29/10/08): we now use an eta/phi coordinate system rather than
168  // phi/eta to minmise possible screwups, for now e5x1 isnt
169  // defined all the majority of people who call it actually
170  // want e1x5 and it is thought it is better that their code
171  // doesnt compile rather than pick up the wrong function
172  // therefore in this version and later e1x5 = e5x1 in the old
173  // version so 1x5 is 1 crystal in eta and 5 crystals in phi
174  // note e3x2 does not have a definate eta/phi geometry, it
175  // takes the maximum 3x2 block containing the seed regardless
176  // of whether that 3 in eta or phi
177  float e1x3(const reco::BasicCluster &cluster) const {
178  return ClusterTools::e1x3(cluster, getEcalRecHitCollection(cluster), topology_);
179  }
180  float e3x1(const reco::BasicCluster &cluster) const {
181  return ClusterTools::e3x1(cluster, getEcalRecHitCollection(cluster), topology_);
182  }
183  float e1x5(const reco::BasicCluster &cluster) const {
184  return ClusterTools::e1x5(cluster, getEcalRecHitCollection(cluster), topology_);
185  }
186  float e5x1(const reco::BasicCluster &cluster) const {
187  return ClusterTools::e5x1(cluster, getEcalRecHitCollection(cluster), topology_);
188  }
189  float e2x2(const reco::BasicCluster &cluster) const {
190  return ClusterTools::e2x2(cluster, getEcalRecHitCollection(cluster), topology_);
191  }
192  float e3x2(const reco::BasicCluster &cluster) const {
193  return ClusterTools::e3x2(cluster, getEcalRecHitCollection(cluster), topology_);
194  }
195  float e3x3(const reco::BasicCluster &cluster) const {
196  return ClusterTools::e3x3(cluster, getEcalRecHitCollection(cluster), topology_);
197  }
198  float e4x4(const reco::BasicCluster &cluster) const {
199  return ClusterTools::e4x4(cluster, getEcalRecHitCollection(cluster), topology_);
200  }
201  float e5x5(const reco::BasicCluster &cluster) const {
202  return ClusterTools::e5x5(cluster, getEcalRecHitCollection(cluster), topology_);
203  }
204  int n5x5(const reco::BasicCluster &cluster) const {
205  return ClusterTools::n5x5(cluster, getEcalRecHitCollection(cluster), topology_);
206  }
207  // energy in the 2x5 strip right of the max crystal (does not contain max crystal)
208  // 2 crystals wide in eta, 5 wide in phi.
209  float e2x5Right(const reco::BasicCluster &cluster) const {
210  return ClusterTools::e2x5Right(cluster, getEcalRecHitCollection(cluster), topology_);
211  }
212  // energy in the 2x5 strip left of the max crystal (does not contain max crystal)
213  float e2x5Left(const reco::BasicCluster &cluster) const {
214  return ClusterTools::e2x5Left(cluster, getEcalRecHitCollection(cluster), topology_);
215  }
216  // energy in the 5x2 strip above the max crystal (does not contain max crystal)
217  // 5 crystals wide in eta, 2 wide in phi.
218  float e2x5Top(const reco::BasicCluster &cluster) const {
219  return ClusterTools::e2x5Top(cluster, getEcalRecHitCollection(cluster), topology_);
220  }
221 
222  // energy in the 5x2 strip below the max crystal (does not contain max crystal)
223  float e2x5Bottom(const reco::BasicCluster &cluster) const {
224  return ClusterTools::e2x5Bottom(cluster, getEcalRecHitCollection(cluster), topology_);
225  }
226  // energy in a 2x5 strip containing the seed (max) crystal.
227  // 2 crystals wide in eta, 5 wide in phi.
228  // it is the maximum of either (1x5left + 1x5center) or (1x5right + 1x5center)
229  float e2x5Max(const reco::BasicCluster &cluster) const {
230  return ClusterTools::e2x5Max(cluster, getEcalRecHitCollection(cluster), topology_);
231  }
232  // energies in the crystal left, right, top, bottom w.r.t. to the most energetic crystal
233  float eLeft(const reco::BasicCluster &cluster) const {
234  return ClusterTools::eLeft(cluster, getEcalRecHitCollection(cluster), topology_);
235  }
236  float eRight(const reco::BasicCluster &cluster) const {
237  return ClusterTools::eRight(cluster, getEcalRecHitCollection(cluster), topology_);
238  }
239  float eTop(const reco::BasicCluster &cluster) const {
240  return ClusterTools::eTop(cluster, getEcalRecHitCollection(cluster), topology_);
241  }
242  float eBottom(const reco::BasicCluster &cluster) const {
243  return ClusterTools::eBottom(cluster, getEcalRecHitCollection(cluster), topology_);
244  }
245  // the energy of the most energetic crystal in the cluster
246  float eMax(const reco::BasicCluster &cluster) const {
247  return ClusterTools::eMax(cluster, getEcalRecHitCollection(cluster));
248  }
249  // the energy of the second most energetic crystal in the cluster
250  float e2nd(const reco::BasicCluster &cluster) const {
251  return ClusterTools::e2nd(cluster, getEcalRecHitCollection(cluster));
252  }
253 
254  // get the DetId and the energy of the maximum energy crystal of the input cluster
255  std::pair<DetId, float> getMaximum(const reco::BasicCluster &cluster) const {
256  return ClusterTools::getMaximum(cluster, getEcalRecHitCollection(cluster));
257  }
258  std::vector<float> energyBasketFractionEta(const reco::BasicCluster &cluster) const {
259  return ClusterTools::energyBasketFractionEta(cluster, getEcalRecHitCollection(cluster));
260  }
261  std::vector<float> energyBasketFractionPhi(const reco::BasicCluster &cluster) const {
262  return ClusterTools::energyBasketFractionPhi(cluster, getEcalRecHitCollection(cluster));
263  }
264 
265  // return a vector v with v[0] = etaLat, v[1] = phiLat, v[2] = lat
266  std::vector<float> lat(const reco::BasicCluster &cluster, bool logW = true, float w0 = 4.7) const {
267  return ClusterTools::lat(cluster, getEcalRecHitCollection(cluster), geometry_, logW, w0);
268  }
269 
270  // return an array v with v[0] = covEtaEta, v[1] = covEtaPhi, v[2] = covPhiPhi
271  std::array<float, 3> covariances(const reco::BasicCluster &cluster, float w0 = 4.7) const {
272  return ClusterTools::covariances(cluster, getEcalRecHitCollection(cluster), topology_, geometry_, w0);
273  }
274 
275  // return an array v with v[0] = covIEtaIEta, v[1] = covIEtaIPhi, v[2] = covIPhiIPhi
276  // this function calculates differences in eta/phi in units of crystals not
277  // global eta/phi this is gives better performance in the crack regions of
278  // the calorimeter but gives otherwise identical results to covariances
279  // function this is only defined for the barrel, it returns covariances when
280  // the cluster is in the endcap Warning: covIEtaIEta has been studied by
281  // egamma, but so far covIPhiIPhi hasnt been studied extensively so there
282  // could be a bug in the covIPhiIEta or covIPhiIPhi calculations. I dont
283  // think there is but as it hasnt been heavily used, there might be one
284  std::array<float, 3> localCovariances(const reco::BasicCluster &cluster,
286  const EcalPFRecHitThresholds *rhthresholds = nullptr,
287  float multEB = 0.0,
288  float multEE = 0.0) const {
289  return ClusterTools::localCovariances(
290  cluster, getEcalRecHitCollection(cluster), topology_, w0, rhthresholds, multEB, multEE);
291  }
292  std::array<float, 3> scLocalCovariances(const reco::SuperCluster &cluster, float w0 = 4.7) const {
293  return ClusterTools::scLocalCovariances(cluster, getEcalRecHitCollection(cluster), topology_, w0);
294  }
295  double zernike20(const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7) const {
296  return ClusterTools::zernike20(cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0);
297  }
298  double zernike42(const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7) const {
299  return ClusterTools::zernike42(cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0);
300  }
301 
302 }; // class EcalClusterLazyToolsT
303 
304 namespace noZS {
306 }
308 
309 #endif
float e3x3(const reco::BasicCluster &cluster) const
std::vector< float > energyBasketFractionEta(const reco::BasicCluster &cluster) const
tuple optional
Definition: Types.py:198
const CaloGeometry * geometry_
EcalIntercalibConstantMap const * icalMap
const EcalRecHitCollection * esRecHits_
std::vector< float > getESHits(double X, double Y, double Z, const std::map< DetId, EcalRecHit > &rechits_map, const CaloGeometry *geometry, CaloSubdetectorTopology const *topology_p, int row=0, int plane=1)
EcalClusterLazyToolsT<::EcalClusterTools > EcalClusterLazyTools
int n5x5(const reco::BasicCluster &cluster) const
float SuperClusterSeedTime(const reco::SuperCluster &cluster)
ESGetTokens(edm::ConsumesCollector cc)
float eTop(const reco::BasicCluster &cluster) const
std::array< float, 3 > covariances(const reco::BasicCluster &cluster, float w0=4.7) const
float BasicClusterTime(const reco::BasicCluster &cluster, const edm::Event &ev)
float SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev)
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
float getESShape(const std::vector< float > &ESHits0)
float e2nd(const reco::BasicCluster &cluster) const
EcalClusterLazyToolsT(const edm::Event &ev, ESData const &esData, edm::EDGetTokenT< EcalRecHitCollection > token1, edm::EDGetTokenT< EcalRecHitCollection > token2)
float eRight(const reco::BasicCluster &cluster) const
edm::ESGetToken< EcalIntercalibConstants, EcalIntercalibConstantsRcd > ecalIntercalibConstantsToken_
EcalIntercalibConstants const * ical
EcalIntercalibConstants const & ecalIntercalibConstants
#define X(str)
Definition: MuonsGrabber.cc:38
std::array< float, 3 > scLocalCovariances(const reco::SuperCluster &cluster, float w0=4.7) const
bool ev
const EcalRecHitCollection * ebRecHits_
float eseffsixix(const reco::SuperCluster &cluster)
float e3x2(const reco::BasicCluster &cluster) const
EcalADCToGeVConstant const * agc
float e2x5Right(const reco::BasicCluster &cluster) const
double zernike20(const reco::BasicCluster &cluster, double R0=6.6, bool logW=true, float w0=4.7) const
EcalClusterLazyToolsT< noZS::EcalClusterTools > EcalClusterLazyTools
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
EcalADCToGeVConstant const & ecalADCToGeV
std::vector< float > energyMatrix(reco::BasicCluster const &cluster, int size) const
float e2x5Left(const reco::BasicCluster &cluster) const
float e5x1(const reco::BasicCluster &cluster) const
std::vector< float > lat(const reco::BasicCluster &cluster, bool logW=true, float w0=4.7) const
EcalClusterLazyToolsT(const edm::Event &ev, ESData const &esData, edm::EDGetTokenT< EcalRecHitCollection > token1, edm::EDGetTokenT< EcalRecHitCollection > token2, edm::EDGetTokenT< EcalRecHitCollection > token3)
std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster) const
float eMax(const reco::BasicCluster &cluster) const
edm::ESGetToken< EcalADCToGeVConstant, EcalADCToGeVConstantRcd > ecalADCToGeVConstantToken_
float e2x5Bottom(const reco::BasicCluster &cluster) const
float e1x5(const reco::BasicCluster &cluster) const
edm::ESGetToken< EcalLaserDbService, EcalLaserDbRecord > ecalLaserDbServiceToken_
double zernike42(const reco::BasicCluster &cluster, double R0=6.6, bool logW=true, float w0=4.7) const
EcalLaserDbService const * laser
std::array< float, 3 > localCovariances(const reco::BasicCluster &cluster, float w0=EgammaLocalCovParamDefaults::kRelEnCut, const EcalPFRecHitThresholds *rhthresholds=nullptr, float multEB=0.0, float multEE=0.0) const
float e2x5Top(const reco::BasicCluster &cluster) const
float e2x2(const reco::BasicCluster &cluster) const
Definition: DetId.h:17
float eseffsiyiy(const reco::SuperCluster &cluster)
EcalClusterLazyToolsBase(const edm::Event &ev, ESData const &esData, edm::EDGetTokenT< EcalRecHitCollection > token1, edm::EDGetTokenT< EcalRecHitCollection > token2, std::optional< edm::EDGetTokenT< EcalRecHitCollection >> token3)
std::unique_ptr< CaloSubdetectorTopology const > ecalPS_topology_
void getESRecHits(const edm::Event &ev, edm::EDGetTokenT< EcalRecHitCollection > const &esRecHitsToken)
EcalRecHitCollection const * getEcalRecHitCollection(const reco::BasicCluster &cluster) const
float e4x4(const reco::BasicCluster &cluster) const
float eLeft(const reco::BasicCluster &cluster) const
const EcalRecHitCollection * eeRecHits_
float e5x5(const reco::BasicCluster &cluster) const
float e2x5Max(const reco::BasicCluster &cluster) const
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
float e1x3(const reco::BasicCluster &cluster) const
float eBottom(const reco::BasicCluster &cluster) const
std::vector< float > energyBasketFractionPhi(const reco::BasicCluster &cluster) const
std::map< DetId, EcalRecHit > rechits_map_
EcalLaserDbService const & ecalLaserDbService
tuple size
Write out results.
float BasicClusterSeedTime(const reco::BasicCluster &cluster)
float e3x1(const reco::BasicCluster &cluster) const
const CaloTopology * topology_
float eseffsirir(const reco::SuperCluster &cluster)