CMS 3D CMS Logo

L1EGammaCrystalsEmulatorProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1CaloTrigger
4 // Class: L1EGammaCrystalsEmulatorProducer
5 //
11 //
12 // Original Author: Cecile Caillol
13 // Created: Tue Aug 10 2018
14 //
15 // Redesign, Calibration: Vladimir Rekovic
16 // Date: Tue May 12 2020
17 //
18 // $Id$
19 //
20 //
21 
22 // system include files
23 #include <memory>
24 #include <array>
25 #include <iostream>
26 #include <cmath>
27 
28 // user include files
34 
43 
44 // ECAL TPs
46 
47 // HCAL TPs
49 
50 // Output tower collection
54 
58 
59 static constexpr bool do_brem = true;
60 
61 static constexpr int n_eta_bins = 2;
62 static constexpr int n_borders_phi = 18;
63 static constexpr int n_borders_eta = 18;
64 static constexpr int n_clusters_max = 5;
65 static constexpr int n_clusters_link = 3;
66 static constexpr int n_clusters_4link = 4 * 3;
67 static constexpr int n_crystals_towerEta = 5;
68 static constexpr int n_crystals_towerPhi = 5;
69 static constexpr int n_crystals_3towers = 3 * 5;
70 static constexpr int n_towers_per_link = 17;
71 static constexpr int n_clusters_per_link = 2;
72 static constexpr int n_towers_Eta = 34;
73 static constexpr int n_towers_Phi = 72;
74 static constexpr int n_towers_halfPhi = 36;
75 static constexpr int n_links_card = 4;
76 static constexpr int n_links_GCTcard = 48;
77 static constexpr int n_GCTcards = 3;
78 static constexpr float ECAL_eta_range = 1.4841;
79 static constexpr float half_crystal_size = 0.00873;
80 static constexpr float slideIsoPtThreshold = 80;
81 static constexpr float a0_80 = 0.85, a1_80 = 0.0080, a0 = 0.21; // passes_iso
82 static constexpr float b0 = 0.38, b1 = 1.9, b2 = 0.05; //passes_looseTkiso
83 static constexpr float c0_ss = 0.94, c1_ss = 0.052, c2_ss = 0.044; //passes_ss
84 static constexpr float d0 = 0.96, d1 = 0.0003; //passes_photon
85 static constexpr float e0_looseTkss = 0.944, e1_looseTkss = 0.65, e2_looseTkss = 0.4; //passes_looseTkss
86 static constexpr float cut_500_MeV = 0.5;
87 
88 // absolue IDs range from 0-33
89 // 0-16 are iEta -17 to -1
90 // 17 to 33 are iEta 1 to 17
91 static constexpr int toweriEta_fromAbsoluteID_shift = 16;
92 
93 // absolue IDs range from 0-71.
94 // To align with detector tower IDs (1 - n_towers_Phi)
95 // shift all indices by 37 and loop over after 72
96 static constexpr int toweriPhi_fromAbsoluteID_shift_lowerHalf = 37;
97 static constexpr int toweriPhi_fromAbsoluteID_shift_upperHalf = 35;
98 
99 float getEta_fromL2LinkCardTowerCrystal(int link, int card, int tower, int crystal) {
101  crystal % n_crystals_towerEta;
102  float size_cell = 2 * ECAL_eta_range / (n_crystals_towerEta * n_towers_Eta);
103  return etaID * size_cell - ECAL_eta_range + half_crystal_size;
104 }
105 
106 float getPhi_fromL2LinkCardTowerCrystal(int link, int card, int tower, int crystal) {
107  int phiID = n_crystals_towerPhi * ((card * 24) + (n_links_card * (link / 8)) + (tower / n_towers_per_link)) +
108  crystal / n_crystals_towerPhi;
109  float size_cell = 2 * M_PI / (n_crystals_towerPhi * n_towers_Phi);
110  return phiID * size_cell - M_PI + half_crystal_size;
111 }
112 
113 int getCrystal_etaID(float eta) {
114  float size_cell = 2 * ECAL_eta_range / (n_crystals_towerEta * n_towers_Eta);
115  int etaID = int((eta + ECAL_eta_range) / size_cell);
116  return etaID;
117 }
118 
120 
121 int convert_L2toL1_tower(int tower) { return tower; }
122 
123 int convert_L2toL1_card(int card, int link) { return card * n_clusters_4link + link / n_links_card; }
124 
125 int getCrystal_phiID(float phi) {
126  float size_cell = 2 * M_PI / (n_crystals_towerPhi * n_towers_Phi);
127  int phiID = int((phi + M_PI) / size_cell);
128  return phiID;
129 }
130 
132  float size_cell = 2 * ECAL_eta_range / n_towers_Eta;
133  int etaID = int((eta + ECAL_eta_range) / size_cell);
134  return etaID;
135 }
136 
138  float size_cell = 2 * M_PI / n_towers_Phi;
139  int phiID = int((phi + M_PI) / size_cell);
140  return phiID;
141 }
142 
144  if (id < n_towers_per_link)
145  return id - n_towers_per_link;
146  else
147  return id - toweriEta_fromAbsoluteID_shift;
148 }
149 
151  if (id < n_towers_Phi / 2)
153  else
155 }
156 
158  float size_cell = 2 * ECAL_eta_range / n_towers_Eta;
159  float eta = (id * size_cell) - ECAL_eta_range + 0.5 * size_cell;
160  return eta;
161 }
162 
164  float size_cell = 2 * M_PI / n_towers_Phi;
165  float phi = (id * size_cell) - M_PI + 0.5 * size_cell;
166  return phi;
167 }
168 
169 int getCrystalIDInTower(int etaID, int phiID) {
170  return int(n_crystals_towerPhi * (phiID % n_crystals_towerPhi) + (etaID % n_crystals_towerEta));
171 }
172 
173 int get_towerEta_fromCardTowerInCard(int card, int towerincard) {
174  return n_towers_per_link * (card % 2) + towerincard % n_towers_per_link;
175 }
176 
177 int get_towerPhi_fromCardTowerInCard(int card, int towerincard) {
178  return 4 * (card / 2) + towerincard / n_towers_per_link;
179 }
180 
181 int get_towerEta_fromCardLinkTower(int card, int link, int tower) { return n_towers_per_link * (card % 2) + tower; }
182 
183 int get_towerPhi_fromCardLinkTower(int card, int link, int tower) { return 4 * (card / 2) + link; }
184 
185 int getTowerID(int etaID, int phiID) {
186  return int(n_towers_per_link * ((phiID / n_crystals_towerPhi) % 4) +
188 }
189 
190 int getTower_phiID(int cluster_phiID) { // Tower ID in card given crystal ID in total detector
191  return int((cluster_phiID / n_crystals_towerPhi) % 4);
192 }
193 
194 int getTower_etaID(int cluster_etaID) { // Tower ID in card given crystal ID in total detector
195  return int((cluster_etaID / n_crystals_towerEta) % n_towers_per_link);
196 }
197 
198 int getEtaMax_card(int card) {
199  int etamax = 0;
200  if (card % 2 == 0)
201  etamax = n_towers_per_link * n_crystals_towerEta - 1; // First eta half. 5 crystals in eta in 1 tower.
202  else
204  return etamax;
205 }
206 
207 int getEtaMin_card(int card) {
208  int etamin = 0;
209  if (card % 2 == 0)
210  etamin = 0 * n_crystals_towerEta; // First eta half. 5 crystals in eta in 1 tower.
211  else
213  return etamin;
214 }
215 
216 int getPhiMax_card(int card) {
217  int phimax = ((card / 2) + 1) * 4 * n_crystals_towerPhi - 1;
218  return phimax;
219 }
220 
221 int getPhiMin_card(int card) {
222  int phimin = (card / 2) * 4 * n_crystals_towerPhi;
223  return phimin;
224 }
225 
227 public:
230 
231 private:
232  void produce(edm::Event&, const edm::EventSetup&) override;
233  bool passes_ss(float pt, float ss);
234  bool passes_photon(float pt, float pss);
235  bool passes_iso(float pt, float iso);
236  bool passes_looseTkss(float pt, float ss);
237  bool passes_looseTkiso(float pt, float iso);
238  float get_calibrate(float uncorr);
239 
243 
245 
251 
252  struct mycluster {
253  float c2x2_;
254  float c2x5_;
255  float c5x5_;
260  float cpt; // ECAL pt
261  int cbrem_; // if brem corrections were applied
264  float ciso_; // pt of cluster divided by 7x7 ECAL towers
265  float chovere_; // 5x5 HCAL towers divided by the ECAL cluster pt
266  float craweta_; // coordinates between -1.44 and 1.44
267  float crawphi_; // coordinates between -pi and pi
268  float chcal_; // 5x5 HCAL towers
269  float ceta_; // eta ID in the whole detector (between 0 and 5*34-1)
270  float cphi_; // phi ID in the whole detector (between 0 and 5*72-1)
271  int ccrystalid_; // crystal ID inside tower (between 0 and 24)
273  int ctowerid_; // tower ID inside card (between 0 and 4*n_towers_per_link-1)
274  };
275 
277  private:
278  float pt_ = 0;
279  float energy_ = 0.;
280  bool isEndcapHit_ = false; // If using endcap, we won't be using integer crystal indices
281  bool stale_ = false; // Hits become stale once used in clustering algorithm to prevent overlap in clusters
282  bool used_ = false;
283  GlobalVector position_; // As opposed to GlobalPoint, so we can add them (for weighted average)
286 
287  public:
288  // tool functions
289  inline void setPt() { pt_ = (position_.mag2() > 0) ? energy_ * sin(position_.theta()) : 0; };
290  inline void setEnergy(float et) { energy_ = et / sin(position_.theta()); };
291  inline void setIsEndcapHit(bool isEC) { isEndcapHit_ = isEC; };
292  inline void setUsed(bool isUsed) { used_ = isUsed; };
293  inline void setPosition(const GlobalVector& pos) { position_ = pos; };
294  inline void setIdHcal(const HcalDetId& idhcal) { id_hcal_ = idhcal; };
295  inline void setId(const EBDetId& id) { id_ = id; };
296 
297  inline float pt() const { return pt_; };
298  inline float energy() const { return energy_; };
299  inline bool isEndcapHit() const { return isEndcapHit_; };
300  inline bool used() const { return used_; };
301  inline const GlobalVector& position() const { return position_; };
302  inline const EBDetId& id() const { return id_; };
303 
304  inline float deta(SimpleCaloHit& other) const { return position_.eta() - other.position().eta(); };
305  int dieta(SimpleCaloHit& other) const {
306  if (isEndcapHit_ || other.isEndcapHit())
307  return 9999; // We shouldn't compare integer indices in endcap, the map is not linear
308  if (id_.ieta() * other.id().ieta() > 0)
309  return id_.ieta() - other.id().ieta();
310  return id_.ieta() - other.id().ieta() - 1;
311  };
312  inline float dphi(SimpleCaloHit& other) const {
313  return reco::deltaPhi(static_cast<float>(position_.phi()), static_cast<float>(other.position().phi()));
314  };
315  int diphi(SimpleCaloHit& other) const {
316  if (isEndcapHit_ || other.isEndcapHit())
317  return 9999; // We shouldn't compare integer indices in endcap, the map is not linear
318  // Logic from EBDetId::distancePhi() without the abs()
319  static constexpr int PI = 180;
320  int result = id().iphi() - other.id().iphi();
321  while (result > PI)
322  result -= 2 * PI;
323  while (result <= -PI)
324  result += 2 * PI;
325  return result;
326  };
328  // Treat position as a point, measure 3D distance
329  // This is used for endcap hits, where we don't have a rectangular mapping
330  return (position() - other.position()).mag();
331  };
333  return (id_ == other.id() && position() == other.position() && energy_ == other.energy() &&
334  isEndcapHit_ == other.isEndcapHit());
335  };
336  };
337 };
338 
340  : ecalTPEBToken_(consumes<EcalEBTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("ecalTPEB"))),
341  hcalTPToken_(
342  consumes<edm::SortedCollection<HcalTriggerPrimitiveDigi> >(iConfig.getParameter<edm::InputTag>("hcalTP"))),
343  calib_(iConfig.getParameter<edm::ParameterSet>("calib")) {
344  produces<l1tp2::CaloCrystalClusterCollection>();
345  produces<BXVector<l1t::EGamma> >();
346  produces<l1tp2::CaloTowerCollection>();
347 }
348 
350 
352  using namespace edm;
353 
355  iEvent.getByToken(ecalTPEBToken_, pcalohits);
356 
362  HcalTrigTowerGeometry theTrigTowerGeometry(hcTopology_);
363  iSetup.get<CaloTPGRecord>().get(decoder_);
364 
365  //****************************************************************
366  //******************* Get all the hits ***************************
367  //****************************************************************
368 
369  // Get all the ECAL hits
370  iEvent.getByToken(ecalTPEBToken_, pcalohits);
371  std::vector<SimpleCaloHit> ecalhits;
372 
373  for (const auto& hit : *pcalohits.product()) {
374  if (hit.encodedEt() > 0) // hit.encodedEt() returns an int corresponding to 2x the crystal Et
375  {
376  // Et is 10 bit, by keeping the ADC saturation Et at 120 GeV it means that you have to divide by 8
377  float et = hit.encodedEt() / 8.;
378  if (et < cut_500_MeV)
379  continue; // keep the 500 MeV ET Cut
380 
381  auto cell = ebGeometry->getGeometry(hit.id());
382 
383  SimpleCaloHit ehit;
384  ehit.setId(hit.id());
385  ehit.setPosition(GlobalVector(cell->getPosition().x(), cell->getPosition().y(), cell->getPosition().z()));
386  ehit.setEnergy(et);
387  ehit.setPt();
388  ecalhits.push_back(ehit);
389  }
390  }
391 
392  // Get all the HCAL hits
393  std::vector<SimpleCaloHit> hcalhits;
395  iEvent.getByToken(hcalTPToken_, hbhecoll);
396  for (const auto& hit : *hbhecoll.product()) {
397  float et = decoder_->hcaletValue(hit.id(), hit.t0());
398  if (et <= 0)
399  continue;
400  if (!(hcTopology_->validHT(hit.id()))) {
401  LogError("L1EGCrystalClusterEmulatorProducer")
402  << " -- Hcal hit DetID not present in HCAL Geom: " << hit.id() << std::endl;
403  throw cms::Exception("L1EGCrystalClusterEmulatorProducer");
404  continue;
405  }
406  const std::vector<HcalDetId>& hcId = theTrigTowerGeometry.detIds(hit.id());
407  if (hcId.empty()) {
408  LogError("L1EGCrystalClusterEmulatorProducer")
409  << "Cannot find any HCalDetId corresponding to " << hit.id() << std::endl;
410  throw cms::Exception("L1EGCrystalClusterEmulatorProducer");
411  continue;
412  }
413  if (hcId[0].subdetId() > 1)
414  continue;
415  GlobalVector hcal_tp_position = GlobalVector(0., 0., 0.);
416  for (const auto& hcId_i : hcId) {
417  if (hcId_i.subdetId() > 1)
418  continue;
419  auto cell = hbGeometry->getGeometry(hcId_i);
420  if (cell == nullptr)
421  continue;
422  GlobalVector tmpVector = GlobalVector(cell->getPosition().x(), cell->getPosition().y(), cell->getPosition().z());
423  hcal_tp_position = tmpVector;
424  break;
425  }
426  SimpleCaloHit hhit;
427  hhit.setId(hit.id());
428  hhit.setIdHcal(hit.id());
429  hhit.setPosition(hcal_tp_position);
430  hhit.setEnergy(et);
431  hhit.setPt();
432  hcalhits.push_back(hhit);
433  }
434 
435  //*******************************************************************
436  //********************** Do layer 1 *********************************
437  //*******************************************************************
438 
439  // Definition of L1 outputs
440  // 36 L1 cards send each 4 links with 17 towers
441  float ECAL_tower_L1Card[n_links_card][n_towers_per_link][n_towers_halfPhi];
442  float HCAL_tower_L1Card[n_links_card][n_towers_per_link][n_towers_halfPhi];
443  int iEta_tower_L1Card[n_links_card][n_towers_per_link][n_towers_halfPhi];
444  int iPhi_tower_L1Card[n_links_card][n_towers_per_link][n_towers_halfPhi];
445  // 36 L1 cards send each 4 links with 3 clusters
446  float energy_cluster_L1Card[n_links_card][n_clusters_link][n_towers_halfPhi];
447  // 36 L1 cards send each 4 links with 3 clusters
448  int brem_cluster_L1Card[n_links_card][n_clusters_link][n_towers_halfPhi];
449  int towerID_cluster_L1Card[n_links_card][n_clusters_link][n_towers_halfPhi];
450  int crystalID_cluster_L1Card[n_links_card][n_clusters_link][n_towers_halfPhi];
451  int showerShape_cluster_L1Card[n_links_card][n_clusters_link][n_towers_halfPhi];
452  int showerShapeLooseTk_cluster_L1Card[n_links_card][n_clusters_link][n_towers_halfPhi];
453  int photonShowerShape_cluster_L1Card[n_links_card][n_clusters_link][n_towers_halfPhi];
454 
455  for (int ii = 0; ii < n_links_card; ++ii) {
456  for (int jj = 0; jj < n_towers_per_link; ++jj) {
457  for (int ll = 0; ll < n_towers_halfPhi; ++ll) {
458  ECAL_tower_L1Card[ii][jj][ll] = 0;
459  HCAL_tower_L1Card[ii][jj][ll] = 0;
460  iPhi_tower_L1Card[ii][jj][ll] = -999;
461  iEta_tower_L1Card[ii][jj][ll] = -999;
462  }
463  }
464  }
465  for (int ii = 0; ii < n_links_card; ++ii) {
466  for (int jj = 0; jj < n_clusters_link; ++jj) {
467  for (int ll = 0; ll < n_towers_halfPhi; ++ll) {
468  energy_cluster_L1Card[ii][jj][ll] = 0;
469  brem_cluster_L1Card[ii][jj][ll] = 0;
470  towerID_cluster_L1Card[ii][jj][ll] = 0;
471  crystalID_cluster_L1Card[ii][jj][ll] = 0;
472  }
473  }
474  }
475 
476  // There is one list of clusters per card. We take the 12 highest pt per card
477  vector<mycluster> cluster_list[n_towers_halfPhi];
478  // After merging the clusters in different regions of a single L1 card
479  vector<mycluster> cluster_list_merged[n_towers_halfPhi];
480 
481  for (int cc = 0; cc < n_towers_halfPhi; ++cc) { // Loop over 36 L1 cards
482  // Loop over 3x4 etaxphi regions to search for max 5 clusters
483  for (int nregion = 0; nregion <= n_clusters_max; ++nregion) {
484  int nclusters = 0;
485  bool build_cluster = true;
486 
487  // Continue until 5 clusters have been built or there is no cluster left
488  while (nclusters < n_clusters_max && build_cluster) {
489  build_cluster = false;
490  SimpleCaloHit centerhit;
491 
492  for (const auto& hit : ecalhits) {
493  if (getCrystal_phiID(hit.position().phi()) <= getPhiMax_card(cc) &&
494  getCrystal_phiID(hit.position().phi()) >= getPhiMin_card(cc) &&
495  getCrystal_etaID(hit.position().eta()) <= getEtaMax_card(cc) &&
496  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) &&
497  // Check that the hit is in the good card
498  getCrystal_etaID(hit.position().eta()) < getEtaMin_card(cc) + n_crystals_3towers * (nregion + 1) &&
499  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) + n_crystals_3towers * nregion &&
500  !hit.used() && hit.pt() >= 1.0 && hit.pt() > centerhit.pt()) // 3 towers x 5 crystals
501  {
502  // Highest hit in good region with pt>1 and not used in any other cluster
503  centerhit = hit;
504  build_cluster = true;
505  }
506  }
507  if (build_cluster)
508  nclusters++;
509 
510  // Use only the 5 most energetic clusters
511  if (build_cluster && nclusters > 0 && nclusters <= n_clusters_max) {
512  mycluster mc1;
513  mc1.cpt = 0.0;
514  mc1.cWeightedEta_ = 0.0;
515  mc1.cWeightedPhi_ = 0.0;
516  float leftlobe = 0;
517  float rightlobe = 0;
518  float e5x5 = 0;
519  float n5x5 = 0;
520  float e2x5_1 = 0;
521  float n2x5_1 = 0;
522  float e2x5_2 = 0;
523  float n2x5_2 = 0;
524  float e2x2_1 = 0;
525  float n2x2_1 = 0;
526  float e2x2_2 = 0;
527  float n2x2_2 = 0;
528  float e2x2_3 = 0;
529  float n2x2_3 = 0;
530  float e2x2_4 = 0;
531  float n2x2_4 = 0;
532  for (auto& hit : ecalhits) {
533  if (getCrystal_phiID(hit.position().phi()) <= getPhiMax_card(cc) &&
534  getCrystal_phiID(hit.position().phi()) >= getPhiMin_card(cc) &&
535  getCrystal_etaID(hit.position().eta()) <= getEtaMax_card(cc) &&
536  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) && hit.pt() > 0 &&
537  getCrystal_etaID(hit.position().eta()) < getEtaMin_card(cc) + n_crystals_3towers * (nregion + 1) &&
538  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) + n_crystals_3towers * nregion) {
539  if (abs(hit.dieta(centerhit)) <= 1 && hit.diphi(centerhit) > 2 && hit.diphi(centerhit) <= 7) {
540  rightlobe += hit.pt();
541  }
542  if (abs(hit.dieta(centerhit)) <= 1 && hit.diphi(centerhit) < -2 && hit.diphi(centerhit) >= -7) {
543  leftlobe += hit.pt();
544  }
545  if (abs(hit.dieta(centerhit)) <= 2 && abs(hit.diphi(centerhit)) <= 2) {
546  e5x5 += hit.energy();
547  n5x5++;
548  }
549  if ((hit.dieta(centerhit) == 1 or hit.dieta(centerhit) == 0) &&
550  (hit.diphi(centerhit) == 1 or hit.diphi(centerhit) == 0)) {
551  e2x2_1 += hit.energy();
552  n2x2_1++;
553  }
554  if ((hit.dieta(centerhit) == 0 or hit.dieta(centerhit) == -1) &&
555  (hit.diphi(centerhit) == 0 or hit.diphi(centerhit) == 1)) {
556  e2x2_2 += hit.energy();
557  n2x2_2++;
558  }
559  if ((hit.dieta(centerhit) == 0 or hit.dieta(centerhit) == 1) &&
560  (hit.diphi(centerhit) == 0 or hit.diphi(centerhit) == -1)) {
561  e2x2_3 += hit.energy();
562  n2x2_3++;
563  }
564  if ((hit.dieta(centerhit) == 0 or hit.dieta(centerhit) == -1) &&
565  (hit.diphi(centerhit) == 0 or hit.diphi(centerhit) == -1)) {
566  e2x2_4 += hit.energy();
567  n2x2_4++;
568  }
569  if ((hit.dieta(centerhit) == 0 or hit.dieta(centerhit) == 1) && abs(hit.diphi(centerhit)) <= 2) {
570  e2x5_1 += hit.energy();
571  n2x5_1++;
572  }
573  if ((hit.dieta(centerhit) == 0 or hit.dieta(centerhit) == -1) && abs(hit.diphi(centerhit)) <= 2) {
574  e2x5_2 += hit.energy();
575  n2x5_2++;
576  }
577  }
578  if (getCrystal_phiID(hit.position().phi()) <= getPhiMax_card(cc) &&
579  getCrystal_phiID(hit.position().phi()) >= getPhiMin_card(cc) &&
580  getCrystal_etaID(hit.position().eta()) <= getEtaMax_card(cc) &&
581  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) && !hit.used() && hit.pt() > 0 &&
582  abs(hit.dieta(centerhit)) <= 1 && abs(hit.diphi(centerhit)) <= 2 &&
583  getCrystal_etaID(hit.position().eta()) < getEtaMin_card(cc) + n_crystals_3towers * (nregion + 1) &&
584  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) + n_crystals_3towers * nregion) {
585  // clusters 3x5 in etaxphi using only the hits in the corresponding card and in the corresponding 3x4 region
586  hit.setUsed(true);
587  mc1.cpt += hit.pt();
588  mc1.cWeightedEta_ += float(hit.pt()) * float(hit.position().eta());
589  mc1.cWeightedPhi_ = mc1.cWeightedPhi_ + (float(hit.pt()) * float(hit.position().phi()));
590  }
591  }
592  if (do_brem && (rightlobe > 0.10 * mc1.cpt or leftlobe > 0.10 * mc1.cpt)) {
593  for (auto& hit : ecalhits) {
594  if (getCrystal_phiID(hit.position().phi()) <= getPhiMax_card(cc) &&
595  getCrystal_phiID(hit.position().phi()) >= getPhiMin_card(cc) &&
596  getCrystal_etaID(hit.position().eta()) <= getEtaMax_card(cc) &&
597  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) && hit.pt() > 0 &&
598  getCrystal_etaID(hit.position().eta()) < getEtaMin_card(cc) + n_crystals_3towers * (nregion + 1) &&
599  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) + n_crystals_3towers * nregion &&
600  !hit.used()) {
601  if (rightlobe > 0.10 * mc1.cpt && (leftlobe < 0.10 * mc1.cpt or rightlobe > leftlobe) &&
602  abs(hit.dieta(centerhit)) <= 1 && hit.diphi(centerhit) > 2 && hit.diphi(centerhit) <= 7) {
603  mc1.cpt += hit.pt();
604  hit.setUsed(true);
605  mc1.cbrem_ = 1;
606  }
607  if (leftlobe > 0.10 * mc1.cpt && (rightlobe < 0.10 * mc1.cpt or leftlobe >= rightlobe) &&
608  abs(hit.dieta(centerhit)) <= 1 && hit.diphi(centerhit) < -2 && hit.diphi(centerhit) >= -7) {
609  mc1.cpt += hit.pt();
610  hit.setUsed(true);
611  mc1.cbrem_ = 1;
612  }
613  }
614  }
615  }
616  mc1.c5x5_ = e5x5;
617  mc1.c2x5_ = max(e2x5_1, e2x5_2);
618  mc1.c2x2_ = e2x2_1;
619  if (e2x2_2 > mc1.c2x2_)
620  mc1.c2x2_ = e2x2_2;
621  if (e2x2_3 > mc1.c2x2_)
622  mc1.c2x2_ = e2x2_3;
623  if (e2x2_4 > mc1.c2x2_)
624  mc1.c2x2_ = e2x2_4;
625  mc1.cWeightedEta_ = mc1.cWeightedEta_ / mc1.cpt;
626  mc1.cWeightedPhi_ = mc1.cWeightedPhi_ / mc1.cpt;
627  mc1.ceta_ = getCrystal_etaID(centerhit.position().eta());
628  mc1.cphi_ = getCrystal_phiID(centerhit.position().phi());
629  mc1.crawphi_ = centerhit.position().phi();
630  mc1.craweta_ = centerhit.position().eta();
631  cluster_list[cc].push_back(mc1);
632  } // End if 5 clusters per region
633  } // End while to find the 5 clusters
634  } // End loop over regions to search for clusters
635  std::sort(begin(cluster_list[cc]), end(cluster_list[cc]), [](mycluster a, mycluster b) { return a.cpt > b.cpt; });
636 
637  // Merge clusters from different regions
638  for (unsigned int jj = 0; jj < unsigned(cluster_list[cc].size()); ++jj) {
639  for (unsigned int kk = jj + 1; kk < unsigned(cluster_list[cc].size()); ++kk) {
640  if (std::abs(cluster_list[cc][jj].ceta_ - cluster_list[cc][kk].ceta_) < 2 &&
641  std::abs(cluster_list[cc][jj].cphi_ - cluster_list[cc][kk].cphi_) < 2) { //Diagonale + exact neighbors
642  if (cluster_list[cc][kk].cpt > cluster_list[cc][jj].cpt) {
643  cluster_list[cc][kk].cpt += cluster_list[cc][jj].cpt;
644  cluster_list[cc][kk].c5x5_ += cluster_list[cc][jj].c5x5_;
645  cluster_list[cc][kk].c2x5_ += cluster_list[cc][jj].c2x5_;
646  cluster_list[cc][jj].cpt = 0;
647  cluster_list[cc][jj].c5x5_ = 0;
648  cluster_list[cc][jj].c2x5_ = 0;
649  cluster_list[cc][jj].c2x2_ = 0;
650  } else {
651  cluster_list[cc][jj].cpt += cluster_list[cc][kk].cpt;
652  cluster_list[cc][jj].c5x5_ += cluster_list[cc][kk].c5x5_;
653  cluster_list[cc][jj].c2x5_ += cluster_list[cc][kk].c2x5_;
654  cluster_list[cc][kk].cpt = 0;
655  cluster_list[cc][kk].c2x2_ = 0;
656  cluster_list[cc][kk].c2x5_ = 0;
657  cluster_list[cc][kk].c5x5_ = 0;
658  }
659  }
660  }
661  if (cluster_list[cc][jj].cpt > 0) {
662  cluster_list[cc][jj].cpt =
663  cluster_list[cc][jj].cpt *
664  calib_(cluster_list[cc][jj].cpt,
665  std::abs(cluster_list[cc][jj].craweta_)); //Mark's calibration as a function of eta and pt
666  cluster_list_merged[cc].push_back(cluster_list[cc][jj]);
667  }
668  }
669  std::sort(begin(cluster_list_merged[cc]), end(cluster_list_merged[cc]), [](mycluster a, mycluster b) {
670  return a.cpt > b.cpt;
671  });
672 
673  // Fill cluster information in the arrays. We keep max 12 clusters (distributed between 4 links)
674  for (unsigned int jj = 0; jj < unsigned(cluster_list_merged[cc].size()) && jj < n_clusters_4link; ++jj) {
675  crystalID_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] =
676  getCrystalIDInTower(cluster_list_merged[cc][jj].ceta_, cluster_list_merged[cc][jj].cphi_);
677  towerID_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] =
678  getTowerID(cluster_list_merged[cc][jj].ceta_, cluster_list_merged[cc][jj].cphi_);
679  energy_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] = cluster_list_merged[cc][jj].cpt;
680  brem_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] = cluster_list_merged[cc][jj].cbrem_;
681  if (passes_ss(cluster_list_merged[cc][jj].cpt,
682  cluster_list_merged[cc][jj].c2x5_ / cluster_list_merged[cc][jj].c5x5_))
683  showerShape_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] = 1;
684  else
685  showerShape_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] = 0;
686  if (passes_looseTkss(cluster_list_merged[cc][jj].cpt,
687  cluster_list_merged[cc][jj].c2x5_ / cluster_list_merged[cc][jj].c5x5_))
688  showerShapeLooseTk_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] = 1;
689  else
690  showerShapeLooseTk_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] = 0;
691  if (passes_photon(cluster_list_merged[cc][jj].cpt,
692  cluster_list_merged[cc][jj].c2x2_ / cluster_list_merged[cc][jj].c2x5_))
693  photonShowerShape_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] = 1;
694  else
695  photonShowerShape_cluster_L1Card[jj % n_links_card][jj / n_links_card][cc] = 0;
696  }
697 
698  // Loop over calo ecal hits to get the ECAL towers. Take only hits that have not been used to make clusters
699  for (const auto& hit : ecalhits) {
700  if (getCrystal_phiID(hit.position().phi()) <= getPhiMax_card(cc) &&
701  getCrystal_phiID(hit.position().phi()) >= getPhiMin_card(cc) &&
702  getCrystal_etaID(hit.position().eta()) <= getEtaMax_card(cc) &&
703  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) &&
704  !hit.used()) { // Take all the hits inside the card that have not been used yet
705  for (int jj = 0; jj < n_links_card; ++jj) { // loop over 4 links per card
706  if ((getCrystal_phiID(hit.position().phi()) / n_crystals_towerPhi) % 4 == jj) { // Go to ID tower modulo 4
707  for (int ii = 0; ii < n_towers_per_link; ++ii) {
708  //Apply Mark's calibration at the same time (row of the lowest pT, as a function of eta)
709  if ((getCrystal_etaID(hit.position().eta()) / n_crystals_towerEta) % n_towers_per_link == ii) {
710  ECAL_tower_L1Card[jj][ii][cc] += hit.pt() * calib_(0, std::abs(hit.position().eta()));
711  iEta_tower_L1Card[jj][ii][cc] = getTower_absoluteEtaID(hit.position().eta()); //hit.id().ieta();
712  iPhi_tower_L1Card[jj][ii][cc] = getTower_absolutePhiID(hit.position().phi()); //hit.id().iphi();
713  }
714  } // end of loop over eta towers
715  }
716  } // end of loop over phi links
717  // Make sure towers with 0 ET are initialized with proper iEta, iPhi coordinates
718  static constexpr float tower_width = 0.0873;
719  for (int jj = 0; jj < n_links_card; ++jj) {
720  for (int ii = 0; ii < n_towers_per_link; ++ii) {
721  float phi = getPhiMin_card(cc) * tower_width / n_crystals_towerPhi - M_PI + (jj + 0.5) * tower_width;
722  float eta = getEtaMin_card(cc) * tower_width / n_crystals_towerEta - n_towers_per_link * tower_width +
723  (ii + 0.5) * tower_width;
724  iEta_tower_L1Card[jj][ii][cc] = getTower_absoluteEtaID(eta);
725  iPhi_tower_L1Card[jj][ii][cc] = getTower_absolutePhiID(phi);
726  }
727  }
728 
729  } // end of check if inside card
730  } // end of loop over hits to build towers
731 
732  // Loop over hcal hits to get the HCAL towers.
733  for (const auto& hit : hcalhits) {
734  if (getCrystal_phiID(hit.position().phi()) <= getPhiMax_card(cc) &&
735  getCrystal_phiID(hit.position().phi()) >= getPhiMin_card(cc) &&
736  getCrystal_etaID(hit.position().eta()) <= getEtaMax_card(cc) &&
737  getCrystal_etaID(hit.position().eta()) >= getEtaMin_card(cc) && hit.pt() > 0) {
738  for (int jj = 0; jj < n_links_card; ++jj) {
739  if ((getCrystal_phiID(hit.position().phi()) / n_crystals_towerPhi) % n_links_card == jj) {
740  for (int ii = 0; ii < n_towers_per_link; ++ii) {
741  if ((getCrystal_etaID(hit.position().eta()) / n_crystals_towerEta) % n_towers_per_link == ii) {
742  HCAL_tower_L1Card[jj][ii][cc] += hit.pt();
743  iEta_tower_L1Card[jj][ii][cc] = getTower_absoluteEtaID(hit.position().eta()); //hit.id().ieta();
744  iPhi_tower_L1Card[jj][ii][cc] = getTower_absolutePhiID(hit.position().phi()); //hit.id().iphi();
745  }
746  } // end of loop over eta towers
747  }
748  } // end of loop over phi links
749  } // end of check if inside card
750  } // end of loop over hits to build towers
751 
752  // Give back energy of not used clusters to the towers (if there are more than 12 clusters)
753  for (unsigned int kk = n_clusters_4link; kk < cluster_list_merged[cc].size(); ++kk) {
754  if (cluster_list_merged[cc][kk].cpt > 0) {
755  ECAL_tower_L1Card[getTower_phiID(cluster_list_merged[cc][kk].cphi_)]
756  [getTower_etaID(cluster_list_merged[cc][kk].ceta_)][cc] += cluster_list_merged[cc][kk].cpt;
757  }
758  }
759  } //End of loop over cards
760 
761  //*********************************************************
762  //******************** Do layer 2 *************************
763  //*********************************************************
764 
765  // Definition of L2 outputs
766  float HCAL_tower_L2Card[n_links_GCTcard][n_towers_per_link]
767  [n_GCTcards]; // 3 L2 cards send each 48 links with 17 towers
768  float ECAL_tower_L2Card[n_links_GCTcard][n_towers_per_link][n_GCTcards];
769  int iEta_tower_L2Card[n_links_GCTcard][n_towers_per_link][n_GCTcards];
770  int iPhi_tower_L2Card[n_links_GCTcard][n_towers_per_link][n_GCTcards];
771  float energy_cluster_L2Card[n_links_GCTcard][n_clusters_per_link]
772  [n_GCTcards]; // 3 L2 cards send each 48 links with 2 clusters
773  float brem_cluster_L2Card[n_links_GCTcard][n_clusters_per_link][n_GCTcards];
774  int towerID_cluster_L2Card[n_links_GCTcard][n_clusters_per_link][n_GCTcards];
775  int crystalID_cluster_L2Card[n_links_GCTcard][n_clusters_per_link][n_GCTcards];
776  float isolation_cluster_L2Card[n_links_GCTcard][n_clusters_per_link][n_GCTcards];
777  float HE_cluster_L2Card[n_links_GCTcard][n_clusters_per_link][n_GCTcards];
778  int showerShape_cluster_L2Card[n_links_GCTcard][n_clusters_per_link][n_GCTcards];
779  int showerShapeLooseTk_cluster_L2Card[n_links_GCTcard][n_clusters_per_link][n_GCTcards];
780  int photonShowerShape_cluster_L2Card[n_links_GCTcard][n_clusters_per_link][n_GCTcards];
781 
782  for (int ii = 0; ii < n_links_GCTcard; ++ii) {
783  for (int jj = 0; jj < n_towers_per_link; ++jj) {
784  for (int ll = 0; ll < n_GCTcards; ++ll) {
785  HCAL_tower_L2Card[ii][jj][ll] = 0;
786  ECAL_tower_L2Card[ii][jj][ll] = 0;
787  iEta_tower_L2Card[ii][jj][ll] = 0;
788  iPhi_tower_L2Card[ii][jj][ll] = 0;
789  }
790  }
791  }
792  for (int ii = 0; ii < n_links_GCTcard; ++ii) {
793  for (int jj = 0; jj < n_clusters_per_link; ++jj) {
794  for (int ll = 0; ll < n_GCTcards; ++ll) {
795  energy_cluster_L2Card[ii][jj][ll] = 0;
796  brem_cluster_L2Card[ii][jj][ll] = 0;
797  towerID_cluster_L2Card[ii][jj][ll] = 0;
798  crystalID_cluster_L2Card[ii][jj][ll] = 0;
799  isolation_cluster_L2Card[ii][jj][ll] = 0;
800  HE_cluster_L2Card[ii][jj][ll] = 0;
801  photonShowerShape_cluster_L2Card[ii][jj][ll] = 0;
802  showerShape_cluster_L2Card[ii][jj][ll] = 0;
803  showerShapeLooseTk_cluster_L2Card[ii][jj][ll] = 0;
804  }
805  }
806  }
807 
808  // There is one list of clusters per equivalent of L1 card. We take the 8 highest pt.
809  vector<mycluster> cluster_list_L2[n_towers_halfPhi];
810 
811  // Merge clusters on the phi edges
812  for (int ii = 0; ii < n_borders_phi; ++ii) { // 18 borders in phi
813  for (int jj = 0; jj < n_eta_bins; ++jj) { // 2 eta bins
814  int card_left = 2 * ii + jj;
815  int card_right = 2 * ii + jj + 2;
816  if (card_right > 35)
817  card_right = card_right - n_towers_halfPhi;
818  for (int kk = 0; kk < n_clusters_4link; ++kk) { // 12 clusters in the first card. We check the right side
819  if (towerID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] > 50 &&
820  crystalID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] > 19 &&
821  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] > 0) {
822  for (int ll = 0; ll < n_clusters_4link; ++ll) { // We check the 12 clusters in the card on the right
823  if (towerID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] < n_towers_per_link &&
824  crystalID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] < 5 &&
825  std::abs(
826  5 * (towerID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right]) % n_towers_per_link +
827  crystalID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] % 5 -
828  5 * (towerID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left]) % n_towers_per_link -
829  crystalID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] % 5) < 2) {
830  if (energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] >
831  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right]) {
832  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] +=
833  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right];
834  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] = 0;
835  } // The least energetic cluster is merged to the most energetic one
836  else {
837  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] +=
838  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left];
839  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] = 0;
840  }
841  }
842  }
843  }
844  }
845  }
846  }
847 
848  // Bremsstrahlung corrections. Merge clusters on the phi edges depending on pT (pt more than 10 percent, dphi leq 5, deta leq 1)
849  if (do_brem) {
850  for (int ii = 0; ii < n_borders_phi; ++ii) { // 18 borders in phi
851  for (int jj = 0; jj < n_eta_bins; ++jj) { // 2 eta bins
852  int card_left = 2 * ii + jj;
853  int card_right = 2 * ii + jj + 2;
854  if (card_right > 35)
855  card_right = card_right - n_towers_halfPhi;
856  // 12 clusters in the first card. We check the right side crystalID_cluster_L1Card[kk%4][kk/4][card_left]
857  for (int kk = 0; kk < n_clusters_4link; ++kk) {
858  // if the tower is at the edge there might be brem corrections, whatever the crystal ID
859  if (towerID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] > 50 &&
860  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] > 0) {
861  for (int ll = 0; ll < n_clusters_4link; ++ll) { // We check the 12 clusters in the card on the right
862  //Distance of 1 max in eta
863  if (towerID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] < n_towers_per_link &&
864  std::abs(5 * (towerID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right]) %
866  crystalID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] % 5 -
867  5 * (towerID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left]) %
869  crystalID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] % 5) <= 1) {
870  //Distance of 5 max in phi
871  if (towerID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] < n_towers_per_link &&
872  std::abs(5 + crystalID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] / 5 -
873  (crystalID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] / 5)) <= 5) {
874  if (energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] >
875  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] &&
876  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] >
877  0.10 * energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left]) {
878  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] +=
879  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right];
880  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] = 0;
881  brem_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] = 1;
882  }
883  // The least energetic cluster is merged to the most energetic one, if its pt is at least ten percent
884  else if (energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_right] >=
885  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_left] &&
886  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_left] >
887  0.10 * energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_right]) {
888  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] +=
889  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left];
890  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_left] = 0;
891  brem_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_right] = 1;
892  }
893  } //max distance eta
894  } //max distance phi
895  } //max distance phi
896  }
897  }
898  }
899  }
900  }
901 
902  // Merge clusters on the eta edges
903  for (int ii = 0; ii < n_borders_eta; ++ii) { // 18 borders in eta
904  int card_bottom = 2 * ii;
905  int card_top = 2 * ii + 1;
906  for (int kk = 0; kk < n_clusters_4link; ++kk) { // 12 clusters in the first card. We check the top side
907  if (towerID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_bottom] % n_towers_per_link == 16 &&
908  crystalID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_bottom] % 5 == n_links_card &&
909  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_bottom] >
910  0) { // If there is one cluster on the right side of the first card
911  for (int ll = 0; ll < n_clusters_4link; ++ll) { // We check the card on the right
912  if (std::abs(
913  5 * (towerID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_bottom] / n_towers_per_link) +
914  crystalID_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_bottom] / 5 -
915  5 * (towerID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_top] / n_towers_per_link) -
916  crystalID_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_top] / 5) < 2) {
917  if (energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_bottom] >
918  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_bottom]) {
919  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_bottom] +=
920  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_top];
921  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_top] = 0;
922  } else {
923  energy_cluster_L1Card[ll % n_links_card][ll / n_links_card][card_top] +=
924  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_bottom];
925  energy_cluster_L1Card[kk % n_links_card][kk / n_links_card][card_bottom] = 0;
926  }
927  }
928  }
929  }
930  }
931  }
932 
933  // Regroup the new clusters per equivalent of L1 card geometry
934  for (int ii = 0; ii < n_towers_halfPhi; ++ii) {
935  for (int jj = 0; jj < n_clusters_4link; ++jj) {
936  if (energy_cluster_L1Card[jj % n_links_card][jj / n_links_card][ii] > 0) {
937  mycluster mc1;
938  mc1.cpt = energy_cluster_L1Card[jj % n_links_card][jj / n_links_card][ii];
939  mc1.cbrem_ = brem_cluster_L1Card[jj % n_links_card][jj / n_links_card][ii];
940  mc1.ctowerid_ = towerID_cluster_L1Card[jj % n_links_card][jj / n_links_card][ii];
941  mc1.ccrystalid_ = crystalID_cluster_L1Card[jj % n_links_card][jj / n_links_card][ii];
942  mc1.cshowershape_ = showerShape_cluster_L1Card[jj % n_links_card][jj / n_links_card][ii];
943  mc1.cshowershapeloosetk_ = showerShapeLooseTk_cluster_L1Card[jj % n_links_card][jj / n_links_card][ii];
944  mc1.cphotonshowershape_ = photonShowerShape_cluster_L1Card[jj % n_links_card][jj / n_links_card][ii];
945  cluster_list_L2[ii].push_back(mc1);
946  }
947  }
948  std::sort(
949  begin(cluster_list_L2[ii]), end(cluster_list_L2[ii]), [](mycluster a, mycluster b) { return a.cpt > b.cpt; });
950  }
951 
952  // If there are more than 8 clusters per equivalent of L1 card we need to put them back in the towers
953  for (int ii = 0; ii < n_towers_halfPhi; ++ii) {
954  for (unsigned int jj = 8; jj < n_clusters_4link && jj < cluster_list_L2[ii].size(); ++jj) {
955  if (cluster_list_L2[ii][jj].cpt > 0) {
956  ECAL_tower_L1Card[cluster_list_L2[ii][jj].ctowerid_ / n_towers_per_link]
957  [cluster_list_L2[ii][jj].ctowerid_ % n_towers_per_link][ii] += cluster_list_L2[ii][jj].cpt;
958  cluster_list_L2[ii][jj].cpt = 0;
959  cluster_list_L2[ii][jj].ctowerid_ = 0;
960  cluster_list_L2[ii][jj].ccrystalid_ = 0;
961  }
962  }
963  }
964 
965  // Compute isolation (7*7 ECAL towers) and HCAL energy (5x5 HCAL towers)
966  for (int ii = 0; ii < n_towers_halfPhi; ++ii) { // Loop over the new cluster list (stored in 36x8 format)
967  for (unsigned int jj = 0; jj < 8 && jj < cluster_list_L2[ii].size(); ++jj) {
968  int cluster_etaOfTower_fullDetector = get_towerEta_fromCardTowerInCard(ii, cluster_list_L2[ii][jj].ctowerid_);
969  int cluster_phiOfTower_fullDetector = get_towerPhi_fromCardTowerInCard(ii, cluster_list_L2[ii][jj].ctowerid_);
970  float hcal_nrj = 0.0;
971  float isolation = 0.0;
972  int ntowers = 0;
973  for (int iii = 0; iii < n_towers_halfPhi; ++iii) { // The clusters have to be added to the isolation
974  for (unsigned int jjj = 0; jjj < 8 && jjj < cluster_list_L2[iii].size(); ++jjj) {
975  if (!(iii == ii && jjj == jj)) {
976  int cluster2_eta = get_towerEta_fromCardTowerInCard(iii, cluster_list_L2[iii][jjj].ctowerid_);
977  int cluster2_phi = get_towerPhi_fromCardTowerInCard(iii, cluster_list_L2[iii][jjj].ctowerid_);
978  if (abs(cluster2_eta - cluster_etaOfTower_fullDetector) <= 2 &&
979  (abs(cluster2_phi - cluster_phiOfTower_fullDetector) <= 2 or
980  abs(cluster2_phi - n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
981  isolation += cluster_list_L2[iii][jjj].cpt;
982  }
983  }
984  }
985  }
986  for (int kk = 0; kk < n_towers_halfPhi; ++kk) { // 36 cards
987  for (int ll = 0; ll < n_links_card; ++ll) { // 4 links per card
988  for (int mm = 0; mm < n_towers_per_link; ++mm) { // 17 towers per link
989  int etaOftower_fullDetector = get_towerEta_fromCardLinkTower(kk, ll, mm);
990  int phiOftower_fullDetector = get_towerPhi_fromCardLinkTower(kk, ll, mm);
991  // First do ECAL
992  // The towers are within 3. Needs to stitch the two phi sides together
993  if (abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
994  (abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2 or
995  abs(phiOftower_fullDetector - n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
996  // Remove the column outside of the L2 card: values (0,71), (23,26), (24,21), (47,50), (48,50), (71,2)
997  if (!((cluster_phiOfTower_fullDetector == 0 && phiOftower_fullDetector == 71) or
998  (cluster_phiOfTower_fullDetector == 23 && phiOftower_fullDetector == 26) or
999  (cluster_phiOfTower_fullDetector == 24 && phiOftower_fullDetector == 21) or
1000  (cluster_phiOfTower_fullDetector == 47 && phiOftower_fullDetector == 50) or
1001  (cluster_phiOfTower_fullDetector == 48 && phiOftower_fullDetector == 45) or
1002  (cluster_phiOfTower_fullDetector == 71 && phiOftower_fullDetector == 2))) {
1003  isolation += ECAL_tower_L1Card[ll][mm][kk];
1004  ntowers++;
1005  }
1006  }
1007  // Now do HCAL
1008  // The towers are within 2. Needs to stitch the two phi sides together
1009  if (abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
1010  (abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2 or
1011  abs(phiOftower_fullDetector - n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
1012  hcal_nrj += HCAL_tower_L1Card[ll][mm][kk];
1013  }
1014  }
1015  }
1016  }
1017  cluster_list_L2[ii][jj].ciso_ = ((isolation) * (25.0 / ntowers)) / cluster_list_L2[ii][jj].cpt;
1018  cluster_list_L2[ii][jj].chovere_ = hcal_nrj / cluster_list_L2[ii][jj].cpt;
1019  }
1020  }
1021 
1022  //Reformat the information inside the 3 L2 cards
1023  //First let's fill the towers
1024  for (int ii = 0; ii < n_links_GCTcard; ++ii) {
1025  for (int jj = 0; jj < n_towers_per_link; ++jj) {
1026  for (int ll = 0; ll < 3; ++ll) {
1027  ECAL_tower_L2Card[ii][jj][ll] =
1029  HCAL_tower_L2Card[ii][jj][ll] =
1031  iEta_tower_L2Card[ii][jj][ll] =
1033  iPhi_tower_L2Card[ii][jj][ll] =
1035  }
1036  }
1037  }
1038 
1039  //Second let's fill the clusters
1040  for (int ii = 0; ii < n_towers_halfPhi; ++ii) { // The cluster list is still in the L1 like geometry
1041  for (unsigned int jj = 0; jj < unsigned(cluster_list_L2[ii].size()) && jj < n_clusters_4link; ++jj) {
1042  crystalID_cluster_L2Card[n_links_card * (ii % n_clusters_4link) + jj % n_links_card][jj / n_links_card]
1043  [ii / n_clusters_4link] = cluster_list_L2[ii][jj].ccrystalid_;
1044  towerID_cluster_L2Card[n_links_card * (ii % n_clusters_4link) + jj % n_links_card][jj / n_links_card]
1045  [ii / n_clusters_4link] = cluster_list_L2[ii][jj].ctowerid_;
1046  energy_cluster_L2Card[n_links_card * (ii % n_clusters_4link) + jj % n_links_card][jj / n_links_card]
1047  [ii / n_clusters_4link] = cluster_list_L2[ii][jj].cpt;
1048  brem_cluster_L2Card[n_links_card * (ii % n_clusters_4link) + jj % n_links_card][jj / n_links_card]
1049  [ii / n_clusters_4link] = cluster_list_L2[ii][jj].cbrem_;
1050  isolation_cluster_L2Card[n_links_card * (ii % n_clusters_4link) + jj % n_links_card][jj / n_links_card]
1051  [ii / n_clusters_4link] = cluster_list_L2[ii][jj].ciso_;
1052  HE_cluster_L2Card[n_links_card * (ii % n_clusters_4link) + jj % n_links_card][jj / n_links_card]
1053  [ii / n_clusters_4link] = cluster_list_L2[ii][jj].chovere_;
1054  showerShape_cluster_L2Card[n_links_card * (ii % n_clusters_4link) + jj % n_links_card][jj / n_links_card]
1055  [ii / n_clusters_4link] = cluster_list_L2[ii][jj].cshowershape_;
1056  showerShapeLooseTk_cluster_L2Card[n_links_card * (ii % n_clusters_4link) + jj % n_links_card][jj / n_links_card]
1057  [ii / n_clusters_4link] = cluster_list_L2[ii][jj].cshowershapeloosetk_;
1058  photonShowerShape_cluster_L2Card[n_links_card * (ii % n_clusters_4link) + jj % n_links_card][jj / n_links_card]
1059  [ii / n_clusters_4link] = cluster_list_L2[ii][jj].cphotonshowershape_;
1060  }
1061  }
1062 
1063  auto L1EGXtalClusters = std::make_unique<l1tp2::CaloCrystalClusterCollection>();
1064  auto L1EGammas = std::make_unique<l1t::EGammaBxCollection>();
1065  auto L1CaloTowers = std::make_unique<l1tp2::CaloTowerCollection>();
1066 
1067  // Fill the cluster collection and towers as well
1068  for (int ii = 0; ii < n_links_GCTcard; ++ii) { // 48 links
1069  for (int ll = 0; ll < n_GCTcards; ++ll) { // 3 cards
1070  // For looping over the Towers a few lines below
1071  for (int jj = 0; jj < 2; ++jj) { // 2 L1EGs
1072  if (energy_cluster_L2Card[ii][jj][ll] > 0.45) {
1074  energy_cluster_L2Card[ii][jj][ll],
1076  ii, ll, towerID_cluster_L2Card[ii][jj][ll], crystalID_cluster_L2Card[ii][jj][ll]),
1078  ii, ll, towerID_cluster_L2Card[ii][jj][ll], crystalID_cluster_L2Card[ii][jj][ll]),
1079  0.);
1080  SimpleCaloHit centerhit;
1081  bool is_iso = passes_iso(energy_cluster_L2Card[ii][jj][ll], isolation_cluster_L2Card[ii][jj][ll]);
1082  bool is_looseTkiso =
1083  passes_looseTkiso(energy_cluster_L2Card[ii][jj][ll], isolation_cluster_L2Card[ii][jj][ll]);
1084  bool is_ss = (showerShape_cluster_L2Card[ii][jj][ll] == 1);
1085  bool is_photon = (photonShowerShape_cluster_L2Card[ii][jj][ll] == 1) && is_ss && is_iso;
1086  bool is_looseTkss = (showerShapeLooseTk_cluster_L2Card[ii][jj][ll] == 1);
1087  // All the ID set to Standalone WP! Some dummy values for non calculated variables
1088  l1tp2::CaloCrystalCluster cluster(p4calibrated,
1089  energy_cluster_L2Card[ii][jj][ll],
1090  HE_cluster_L2Card[ii][jj][ll],
1091  isolation_cluster_L2Card[ii][jj][ll],
1092  centerhit.id(),
1093  -1000,
1094  float(brem_cluster_L2Card[ii][jj][ll]),
1095  -1000,
1096  -1000,
1097  energy_cluster_L2Card[ii][jj][ll],
1098  -1,
1099  is_iso&& is_ss,
1100  is_iso&& is_ss,
1101  is_photon,
1102  is_iso&& is_ss,
1103  is_looseTkiso&& is_looseTkss,
1104  is_iso&& is_ss);
1105  // Experimental parameters, don't want to bother with hardcoding them in data format
1106  std::map<std::string, float> params;
1107  params["standaloneWP_showerShape"] = is_ss;
1108  params["standaloneWP_isolation"] = is_iso;
1109  params["trkMatchWP_showerShape"] = is_looseTkss;
1110  params["trkMatchWP_isolation"] = is_looseTkiso;
1111  params["TTiEta"] = getToweriEta_fromAbsoluteID(getTower_absoluteEtaID(p4calibrated.eta()));
1112  params["TTiPhi"] = getToweriPhi_fromAbsoluteID(getTower_absolutePhiID(p4calibrated.phi()));
1113  cluster.setExperimentalParams(params);
1114  L1EGXtalClusters->push_back(cluster);
1115 
1116  int standaloneWP = (int)(is_iso && is_ss);
1117  int looseL1TkMatchWP = (int)(is_looseTkiso && is_looseTkss);
1118  int photonWP = (int)(is_photon);
1119  int quality =
1120  (standaloneWP * std::pow(2, 0)) + (looseL1TkMatchWP * std::pow(2, 1)) + (photonWP * std::pow(2, 2));
1121  L1EGammas->push_back(
1122  0, l1t::EGamma(p4calibrated, p4calibrated.pt(), p4calibrated.eta(), p4calibrated.phi(), quality, 1));
1123  }
1124  }
1125  }
1126  }
1127 
1128  for (int ii = 0; ii < n_links_GCTcard; ++ii) { // 48 links
1129  for (int ll = 0; ll < n_GCTcards; ++ll) { // 3 cards
1130  // Fill the tower collection
1131  for (int jj = 0; jj < n_towers_per_link; ++jj) { // 17 TTs
1132  l1tp2::CaloTower l1CaloTower;
1133  l1CaloTower.setEcalTowerEt(ECAL_tower_L2Card[ii][jj][ll]);
1134  l1CaloTower.setHcalTowerEt(HCAL_tower_L2Card[ii][jj][ll]);
1135  l1CaloTower.setTowerIEta(getToweriEta_fromAbsoluteID(iEta_tower_L2Card[ii][jj][ll]));
1136  l1CaloTower.setTowerIPhi(getToweriPhi_fromAbsoluteID(iPhi_tower_L2Card[ii][jj][ll]));
1137  l1CaloTower.setTowerEta(getTowerEta_fromAbsoluteID(iEta_tower_L2Card[ii][jj][ll]));
1138  l1CaloTower.setTowerPhi(getTowerPhi_fromAbsoluteID(iPhi_tower_L2Card[ii][jj][ll]));
1139  // Some towers have incorrect eta/phi because that wasn't initialized in certain cases, fix these
1140  static float constexpr towerEtaUpperUnitialized = -80;
1141  static float constexpr towerPhiUpperUnitialized = -90;
1142  if (l1CaloTower.towerEta() < towerEtaUpperUnitialized && l1CaloTower.towerPhi() < towerPhiUpperUnitialized) {
1143  l1CaloTower.setTowerEta(l1t::CaloTools::towerEta(l1CaloTower.towerIEta()));
1144  l1CaloTower.setTowerPhi(l1t::CaloTools::towerPhi(l1CaloTower.towerIEta(), l1CaloTower.towerIPhi()));
1145  }
1146  l1CaloTower.setIsBarrel(true);
1147 
1148  // Add L1EGs if they match in iEta / iPhi
1149  // L1EGs are already pT ordered, we will take the ID info for the leading one, but pT as the sum
1150  for (const auto& l1eg : *L1EGXtalClusters) {
1151  if (l1eg.experimentalParam("TTiEta") != l1CaloTower.towerIEta())
1152  continue;
1153  if (l1eg.experimentalParam("TTiPhi") != l1CaloTower.towerIPhi())
1154  continue;
1155 
1156  int n_L1eg = l1CaloTower.nL1eg();
1157  l1CaloTower.setNL1eg(n_L1eg++);
1158  l1CaloTower.setL1egTowerEt(l1CaloTower.l1egTowerEt() + l1eg.pt());
1159  // Don't record L1EG quality info for subleading L1EG
1160  if (l1CaloTower.nL1eg() > 1)
1161  continue;
1162  l1CaloTower.setL1egTrkSS(l1eg.experimentalParam("trkMatchWP_showerShape"));
1163  l1CaloTower.setL1egTrkIso(l1eg.experimentalParam("trkMatchWP_isolation"));
1164  l1CaloTower.setL1egStandaloneSS(l1eg.experimentalParam("standaloneWP_showerShape"));
1165  l1CaloTower.setL1egStandaloneIso(l1eg.experimentalParam("standaloneWP_isolation"));
1166  }
1167 
1168  L1CaloTowers->push_back(l1CaloTower);
1169  }
1170  }
1171  }
1172 
1173  iEvent.put(std::move(L1EGXtalClusters));
1174  iEvent.put(std::move(L1EGammas));
1175  iEvent.put(std::move(L1CaloTowers));
1176 }
1177 
1179  if (pt < slideIsoPtThreshold) {
1180  if (!((a0_80 - a1_80 * pt) > iso))
1181  return false;
1182  } else {
1183  if (iso > a0)
1184  return false;
1185  }
1186  return true;
1187 }
1188 
1190  return (b0 + b1 * std::exp(-b2 * pt) > iso);
1191 }
1192 
1194  return ((c0_ss + c1_ss * std::exp(-c2_ss * pt)) <= ss);
1195 }
1196 
1197 bool L1EGCrystalClusterEmulatorProducer::passes_photon(float pt, float pss) { return (pss > d0 - d1 * pt); }
1198 
1200  return ((e0_looseTkss - e1_looseTkss * std::exp(-e2_looseTkss * pt)) <= ss);
1201 }
1202 
1203 //define this as a plug-in
Vector3DBase
Definition: Vector3DBase.h:8
getTower_etaID
int getTower_etaID(int cluster_etaID)
Definition: L1EGammaCrystalsEmulatorProducer.cc:194
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::energy_
float energy_
Definition: L1EGammaCrystalsEmulatorProducer.cc:279
CaloTower.h
getEtaMax_card
int getEtaMax_card(int card)
Definition: L1EGammaCrystalsEmulatorProducer.cc:198
PI
Definition: PayloadInspector.h:20
l1tp2::CaloTower::towerIEta
int towerIEta() const
Definition: CaloTower.h:38
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
L1EGCrystalClusterEmulatorProducer::passes_ss
bool passes_ss(float pt, float ss)
Definition: L1EGammaCrystalsEmulatorProducer.cc:1193
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::dieta
int dieta(SimpleCaloHit &other) const
Definition: L1EGammaCrystalsEmulatorProducer.cc:305
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
EcalBarrelGeometry.h
convert_L2toL1_tower
int convert_L2toL1_tower(int tower)
Definition: L1EGammaCrystalsEmulatorProducer.cc:121
CaloTools.h
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
l1tp2::CaloTower::towerEta
float towerEta() const
Definition: CaloTower.h:40
L1EGCrystalClusterEmulatorProducer::mycluster::cWeightedPhi_
float cWeightedPhi_
Definition: L1EGammaCrystalsEmulatorProducer.cc:263
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
edm::Handle::product
T const * product() const
Definition: Handle.h:70
getPhiMax_card
int getPhiMax_card(int card)
Definition: L1EGammaCrystalsEmulatorProducer.cc:216
getTowerID
int getTowerID(int etaID, int phiID)
Definition: L1EGammaCrystalsEmulatorProducer.cc:185
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::setEnergy
void setEnergy(float et)
Definition: L1EGammaCrystalsEmulatorProducer.cc:290
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
getTower_absoluteEtaID
int getTower_absoluteEtaID(float eta)
Definition: L1EGammaCrystalsEmulatorProducer.cc:131
ESHandle.h
L1EGCrystalClusterEmulatorProducer::ecalTPEBToken_
edm::EDGetTokenT< EcalEBTrigPrimDigiCollection > ecalTPEBToken_
Definition: L1EGammaCrystalsEmulatorProducer.cc:240
l1tp2::CaloTower::setTowerPhi
void setTowerPhi(float phi)
Definition: CaloTower.h:53
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::position_
GlobalVector position_
Definition: L1EGammaCrystalsEmulatorProducer.cc:283
PI
#define PI
Definition: QcdUeDQM.h:37
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
slideIsoPtThreshold
static constexpr float slideIsoPtThreshold
Definition: L1EGammaCrystalsEmulatorProducer.cc:80
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
edm::EDGetTokenT
Definition: EDGetToken.h:33
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::deta
float deta(SimpleCaloHit &other) const
Definition: L1EGammaCrystalsEmulatorProducer.cc:304
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
pss
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
getCrystalIDInTower
int getCrystalIDInTower(int etaID, int phiID)
Definition: L1EGammaCrystalsEmulatorProducer.cc:169
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::setIdHcal
void setIdHcal(const HcalDetId &idhcal)
Definition: L1EGammaCrystalsEmulatorProducer.cc:294
reco::Candidate::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::isEndcapHit
bool isEndcapHit() const
Definition: L1EGammaCrystalsEmulatorProducer.cc:299
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::stale_
bool stale_
Definition: L1EGammaCrystalsEmulatorProducer.cc:281
pos
Definition: PixelAliasList.h:18
HcalTopology
Definition: HcalTopology.h:26
L1EGCrystalClusterEmulatorProducer::decoder_
edm::ESHandle< CaloTPGTranscoder > decoder_
Definition: L1EGammaCrystalsEmulatorProducer.cc:242
L1EGCrystalClusterEmulatorProducer::mycluster::c2x5_
float c2x5_
Definition: L1EGammaCrystalsEmulatorProducer.cc:254
DetId::Hcal
Definition: DetId.h:28
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::setPosition
void setPosition(const GlobalVector &pos)
Definition: L1EGammaCrystalsEmulatorProducer.cc:293
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
n_towers_Phi
static constexpr int n_towers_Phi
Definition: L1EGammaCrystalsEmulatorProducer.cc:73
L1EGCrystalClusterEmulatorProducer::mycluster::cbrem_
int cbrem_
Definition: L1EGammaCrystalsEmulatorProducer.cc:261
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
l1tp2::CaloTower::setL1egTowerEt
void setL1egTowerEt(float et)
Definition: CaloTower.h:55
n_links_card
static constexpr int n_links_card
Definition: L1EGammaCrystalsEmulatorProducer.cc:75
EDProducer.h
edm::SortedCollection
Definition: SortedCollection.h:49
L1EGCrystalClusterEmulatorProducer::mycluster::ctowerid_
int ctowerid_
Definition: L1EGammaCrystalsEmulatorProducer.cc:273
L1EGCrystalClusterEmulatorProducer::mycluster::craweta_
float craweta_
Definition: L1EGammaCrystalsEmulatorProducer.cc:266
L1EGCrystalClusterEmulatorProducer::mycluster::cWeightedEta_
float cWeightedEta_
Definition: L1EGammaCrystalsEmulatorProducer.cc:262
L1EGCrystalClusterEmulatorProducer::mycluster::chcal_
float chcal_
Definition: L1EGammaCrystalsEmulatorProducer.cc:268
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::id_hcal_
HcalDetId id_hcal_
Definition: L1EGammaCrystalsEmulatorProducer.cc:284
do_brem
static constexpr bool do_brem
Definition: L1EGammaCrystalsEmulatorProducer.cc:59
l1tp2::CaloTower::setHcalTowerEt
void setHcalTowerEt(float et)
Definition: CaloTower.h:50
a1_80
static constexpr float a1_80
Definition: L1EGammaCrystalsEmulatorProducer.cc:81
getEtaMin_card
int getEtaMin_card(int card)
Definition: L1EGammaCrystalsEmulatorProducer.cc:207
n_towers_Eta
static constexpr int n_towers_Eta
Definition: L1EGammaCrystalsEmulatorProducer.cc:72
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
HcalBarrel
Definition: HcalAssistant.h:33
b2
static constexpr float b2
Definition: L1EGammaCrystalsEmulatorProducer.cc:82
CaloTPGTranscoder.h
toweriPhi_fromAbsoluteID_shift_upperHalf
static constexpr int toweriPhi_fromAbsoluteID_shift_upperHalf
Definition: L1EGammaCrystalsEmulatorProducer.cc:97
n_towers_halfPhi
static constexpr int n_towers_halfPhi
Definition: L1EGammaCrystalsEmulatorProducer.cc:74
PV3DBase::mag2
T mag2() const
Definition: PV3DBase.h:63
getPhi_fromL2LinkCardTowerCrystal
float getPhi_fromL2LinkCardTowerCrystal(int link, int card, int tower, int crystal)
Definition: L1EGammaCrystalsEmulatorProducer.cc:106
edm::Handle
Definition: AssociativeIterator.h:50
L1EGCrystalClusterEmulatorProducer::passes_looseTkss
bool passes_looseTkss(float pt, float ss)
Definition: L1EGammaCrystalsEmulatorProducer.cc:1199
EcalBarrel
Definition: EcalSubdetector.h:10
n_borders_phi
static constexpr int n_borders_phi
Definition: L1EGammaCrystalsEmulatorProducer.cc:62
n_clusters_max
static constexpr int n_clusters_max
Definition: L1EGammaCrystalsEmulatorProducer.cc:64
ParametricCalibration.h
muonTiming_cfi.etamin
etamin
Definition: muonTiming_cfi.py:30
HcalTriggerPrimitiveDigi.h
L1EGCrystalClusterEmulatorProducer::mycluster::crawphi_
float crawphi_
Definition: L1EGammaCrystalsEmulatorProducer.cc:267
L1EGCrystalClusterEmulatorProducer::mycluster::c2x2_
float c2x2_
Definition: L1EGammaCrystalsEmulatorProducer.cc:253
cc
l1tp2::CaloTower::nL1eg
int nL1eg() const
Definition: CaloTower.h:42
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::energy
float energy() const
Definition: L1EGammaCrystalsEmulatorProducer.cc:298
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::pt_
float pt_
Definition: L1EGammaCrystalsEmulatorProducer.cc:278
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
b1
static constexpr float b1
Definition: L1EGammaCrystalsEmulatorProducer.cc:82
convert_L2toL1_card
int convert_L2toL1_card(int card, int link)
Definition: L1EGammaCrystalsEmulatorProducer.cc:123
MakerMacros.h
L1EGCrystalClusterEmulatorProducer::~L1EGCrystalClusterEmulatorProducer
~L1EGCrystalClusterEmulatorProducer() override
Definition: L1EGammaCrystalsEmulatorProducer.cc:349
L1EGCrystalClusterEmulatorProducer::mycluster::cpt
float cpt
Definition: L1EGammaCrystalsEmulatorProducer.cc:260
n_borders_eta
static constexpr int n_borders_eta
Definition: L1EGammaCrystalsEmulatorProducer.cc:63
l1t::CaloTools::towerPhi
static float towerPhi(int ieta, int iphi)
Definition: CaloTools.cc:208
e0_looseTkss
static constexpr float e0_looseTkss
Definition: L1EGammaCrystalsEmulatorProducer.cc:85
getTower_absolutePhiID
int getTower_absolutePhiID(float phi)
Definition: L1EGammaCrystalsEmulatorProducer.cc:137
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
L1EGCrystalClusterEmulatorProducer::ebGeometry
const CaloSubdetectorGeometry * ebGeometry
Definition: L1EGammaCrystalsEmulatorProducer.cc:247
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
e2_looseTkss
static constexpr float e2_looseTkss
Definition: L1EGammaCrystalsEmulatorProducer.cc:85
getCrystal_phiID
int getCrystal_phiID(float phi)
Definition: L1EGammaCrystalsEmulatorProducer.cc:125
EGamma.h
getEta_fromL2LinkCardTowerCrystal
float getEta_fromL2LinkCardTowerCrystal(int link, int card, int tower, int crystal)
Definition: L1EGammaCrystalsEmulatorProducer.cc:99
n_towers_per_link
static constexpr int n_towers_per_link
Definition: L1EGammaCrystalsEmulatorProducer.cc:70
PVValHelper::eta
Definition: PVValidationHelpers.h:69
L1EGCrystalClusterEmulatorProducer::hbGeometry
const CaloSubdetectorGeometry * hbGeometry
Definition: L1EGammaCrystalsEmulatorProducer.cc:248
l1tp2::CaloCrystalCluster
Definition: CaloCrystalCluster.h:14
mps_fire.end
end
Definition: mps_fire.py:242
EcalDigiCollections.h
edm::ESHandle< CaloTPGTranscoder >
c2_ss
static constexpr float c2_ss
Definition: L1EGammaCrystalsEmulatorProducer.cc:83
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::position
const GlobalVector & position() const
Definition: L1EGammaCrystalsEmulatorProducer.cc:301
convert_L2toL1_link
int convert_L2toL1_link(int link)
Definition: L1EGammaCrystalsEmulatorProducer.cc:119
L1EGCrystalClusterEmulatorProducer::mycluster::ceta_
float ceta_
Definition: L1EGammaCrystalsEmulatorProducer.cc:269
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::id_
EBDetId id_
Definition: L1EGammaCrystalsEmulatorProducer.cc:285
l1tp2::CaloTower::setL1egStandaloneIso
void setL1egStandaloneIso(int staIso)
Definition: CaloTower.h:60
half_crystal_size
static constexpr float half_crystal_size
Definition: L1EGammaCrystalsEmulatorProducer.cc:79
trackingPlots.other
other
Definition: trackingPlots.py:1467
GetRecoTauVFromDQM_MC_cff.kk
kk
Definition: GetRecoTauVFromDQM_MC_cff.py:84
HcalTopology::validHT
bool validHT(const HcalTrigTowerDetId &id) const
Definition: HcalTopology.cc:239
c0_ss
static constexpr float c0_ss
Definition: L1EGammaCrystalsEmulatorProducer.cc:83
n_links_GCTcard
static constexpr int n_links_GCTcard
Definition: L1EGammaCrystalsEmulatorProducer.cc:76
n_GCTcards
static constexpr int n_GCTcards
Definition: L1EGammaCrystalsEmulatorProducer.cc:77
b
double b
Definition: hdecay.h:118
l1tp2::CaloTower
Definition: CaloTower.h:16
getCrystal_etaID
int getCrystal_etaID(float eta)
Definition: L1EGammaCrystalsEmulatorProducer.cc:113
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
getToweriEta_fromAbsoluteID
int getToweriEta_fromAbsoluteID(int id)
Definition: L1EGammaCrystalsEmulatorProducer.cc:143
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::setId
void setId(const EBDetId &id)
Definition: L1EGammaCrystalsEmulatorProducer.cc:295
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::distanceTo
float distanceTo(SimpleCaloHit &other) const
Definition: L1EGammaCrystalsEmulatorProducer.cc:327
L1EGCrystalClusterEmulatorProducer
Definition: L1EGammaCrystalsEmulatorProducer.cc:226
getTower_phiID
int getTower_phiID(int cluster_phiID)
Definition: L1EGammaCrystalsEmulatorProducer.cc:190
L1EGCrystalClusterEmulatorProducer::caloGeometry_
edm::ESHandle< CaloGeometry > caloGeometry_
Definition: L1EGammaCrystalsEmulatorProducer.cc:246
HcalTriggerPrimitiveDigi
Definition: HcalTriggerPrimitiveDigi.h:13
L1EGCrystalClusterEmulatorProducer::mycluster::chovere_
float chovere_
Definition: L1EGammaCrystalsEmulatorProducer.cc:265
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
Event.h
ParameterSet
Definition: Functions.h:16
c1_ss
static constexpr float c1_ss
Definition: L1EGammaCrystalsEmulatorProducer.cc:83
PVValHelper::phi
Definition: PVValidationHelpers.h:68
getPhiMin_card
int getPhiMin_card(int card)
Definition: L1EGammaCrystalsEmulatorProducer.cc:221
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::dphi
float dphi(SimpleCaloHit &other) const
Definition: L1EGammaCrystalsEmulatorProducer.cc:312
CaloTPGRecord
Definition: CaloTPGRecord.h:26
toweriPhi_fromAbsoluteID_shift_lowerHalf
static constexpr int toweriPhi_fromAbsoluteID_shift_lowerHalf
Definition: L1EGammaCrystalsEmulatorProducer.cc:96
HcalDetId.h
L1EGCrystalClusterEmulatorProducer::calib_
l1tp2::ParametricCalibration calib_
Definition: L1EGammaCrystalsEmulatorProducer.cc:244
n_crystals_towerPhi
static constexpr int n_crystals_towerPhi
Definition: L1EGammaCrystalsEmulatorProducer.cc:68
L1EGCrystalClusterEmulatorProducer::hcalTPToken_
edm::EDGetTokenT< edm::SortedCollection< HcalTriggerPrimitiveDigi > > hcalTPToken_
Definition: L1EGammaCrystalsEmulatorProducer.cc:241
n_crystals_towerEta
static constexpr int n_crystals_towerEta
Definition: L1EGammaCrystalsEmulatorProducer.cc:67
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::used_
bool used_
Definition: L1EGammaCrystalsEmulatorProducer.cc:282
l1tp2::CaloTower::setTowerEta
void setTowerEta(float eta)
Definition: CaloTower.h:54
HcalDetId
Definition: HcalDetId.h:12
createfilelist.int
int
Definition: createfilelist.py:10
l1tp2::CaloTower::setEcalTowerEt
void setEcalTowerEt(float et)
Definition: CaloTower.h:49
n_clusters_4link
static constexpr int n_clusters_4link
Definition: L1EGammaCrystalsEmulatorProducer.cc:66
iEvent
int iEvent
Definition: GenABIO.cc:224
l1tp2::CaloTower::towerIPhi
int towerIPhi() const
Definition: CaloTower.h:37
L1EGCrystalClusterEmulatorProducer::passes_looseTkiso
bool passes_looseTkiso(float pt, float iso)
Definition: L1EGammaCrystalsEmulatorProducer.cc:1189
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
l1tp2::CaloTower::setL1egStandaloneSS
void setL1egStandaloneSS(int staSS)
Definition: CaloTower.h:59
L1EGCrystalClusterEmulatorProducer::mycluster::cphotonshowershape_
int cphotonshowershape_
Definition: L1EGammaCrystalsEmulatorProducer.cc:259
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::isEndcapHit_
bool isEndcapHit_
Definition: L1EGammaCrystalsEmulatorProducer.cc:280
l1tp2::CaloTower::setTowerIPhi
void setTowerIPhi(int iPhi)
Definition: CaloTower.h:51
n_clusters_link
static constexpr int n_clusters_link
Definition: L1EGammaCrystalsEmulatorProducer.cc:65
edm::stream::EDProducer
Definition: EDProducer.h:38
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::setIsEndcapHit
void setIsEndcapHit(bool isEC)
Definition: L1EGammaCrystalsEmulatorProducer.cc:291
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
l1t::EGamma
Definition: EGamma.h:20
b0
static constexpr float b0
Definition: L1EGammaCrystalsEmulatorProducer.cc:82
l1tp2::CaloTower::towerPhi
float towerPhi() const
Definition: CaloTower.h:39
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
L1EGCrystalClusterEmulatorProducer::mycluster::c5x5_
float c5x5_
Definition: L1EGammaCrystalsEmulatorProducer.cc:255
edm::EventSetup
Definition: EventSetup.h:57
HcalSubdetector.h
HcalTrigTowerGeometry.h
CaloCrystalCluster.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
l1tp2::ParametricCalibration
Definition: ParametricCalibration.h:12
DetId::Ecal
Definition: DetId.h:27
HcalTrigTowerGeometry
Definition: HcalTrigTowerGeometry.h:10
CaloTPGRecord.h
get
#define get
L1EGCrystalClusterEmulatorProducer::mycluster::cshowershape_
int cshowershape_
Definition: L1EGammaCrystalsEmulatorProducer.cc:256
get_towerEta_fromCardTowerInCard
int get_towerEta_fromCardTowerInCard(int card, int towerincard)
Definition: L1EGammaCrystalsEmulatorProducer.cc:173
a0_80
static constexpr float a0_80
Definition: L1EGammaCrystalsEmulatorProducer.cc:81
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::setUsed
void setUsed(bool isUsed)
Definition: L1EGammaCrystalsEmulatorProducer.cc:292
e1_looseTkss
static constexpr float e1_looseTkss
Definition: L1EGammaCrystalsEmulatorProducer.cc:85
L1EGCrystalClusterEmulatorProducer::get_calibrate
float get_calibrate(float uncorr)
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
DDAxes::phi
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
L1EGCrystalClusterEmulatorProducer::passes_iso
bool passes_iso(float pt, float iso)
Definition: L1EGammaCrystalsEmulatorProducer.cc:1178
eostools.move
def move(src, dest)
Definition: eostools.py:511
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::setPt
void setPt()
Definition: L1EGammaCrystalsEmulatorProducer.cc:289
L1EGCrystalClusterEmulatorProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: L1EGammaCrystalsEmulatorProducer.cc:351
l1t::CaloTools::towerEta
static float towerEta(int ieta)
Definition: CaloTools.cc:201
l1tp2::CaloTower::setIsBarrel
void setIsBarrel(bool isBarrel)
Definition: CaloTower.h:61
get_towerEta_fromCardLinkTower
int get_towerEta_fromCardLinkTower(int card, int link, int tower)
Definition: L1EGammaCrystalsEmulatorProducer.cc:181
qcdUeDQM_cfi.quality
quality
Definition: qcdUeDQM_cfi.py:31
L1EGCrystalClusterEmulatorProducer::mycluster::cinsidecrystalid_
int cinsidecrystalid_
Definition: L1EGammaCrystalsEmulatorProducer.cc:272
n_crystals_3towers
static constexpr int n_crystals_3towers
Definition: L1EGammaCrystalsEmulatorProducer.cc:69
Exception
Definition: hltDiff.cc:246
muonTiming_cfi.etamax
etamax
Definition: muonTiming_cfi.py:23
CaloGeometry.h
l1tp2::CaloTower::setL1egTrkIso
void setL1egTrkIso(int trkIso)
Definition: CaloTower.h:58
toweriEta_fromAbsoluteID_shift
static constexpr int toweriEta_fromAbsoluteID_shift
Definition: L1EGammaCrystalsEmulatorProducer.cc:91
l1tp2::CaloTower::setNL1eg
void setNL1eg(int n)
Definition: CaloTower.h:56
findQualityFiles.jj
string jj
Definition: findQualityFiles.py:188
L1EGCrystalClusterEmulatorProducer::hcTopology_
const HcalTopology * hcTopology_
Definition: L1EGammaCrystalsEmulatorProducer.cc:250
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::used
bool used() const
Definition: L1EGammaCrystalsEmulatorProducer.cc:300
EventSetup.h
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
cut_500_MeV
static constexpr float cut_500_MeV
Definition: L1EGammaCrystalsEmulatorProducer.cc:86
L1EGCrystalClusterEmulatorProducer::mycluster::cshowershapeloosetk_
int cshowershapeloosetk_
Definition: L1EGammaCrystalsEmulatorProducer.cc:257
L1EGCrystalClusterEmulatorProducer::mycluster::ciso_
float ciso_
Definition: L1EGammaCrystalsEmulatorProducer.cc:264
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::operator==
bool operator==(SimpleCaloHit &other) const
Definition: L1EGammaCrystalsEmulatorProducer.cc:332
ECAL_eta_range
static constexpr float ECAL_eta_range
Definition: L1EGammaCrystalsEmulatorProducer.cc:78
L1EGCrystalClusterEmulatorProducer::L1EGCrystalClusterEmulatorProducer
L1EGCrystalClusterEmulatorProducer(const edm::ParameterSet &)
Definition: L1EGammaCrystalsEmulatorProducer.cc:339
CaloTPGTranscoder::hcaletValue
virtual double hcaletValue(const int &ieta, const int &iphi, const int &version, const int &compressedValue) const =0
L1EGCrystalClusterEmulatorProducer::mycluster::cvalueshowershape_
float cvalueshowershape_
Definition: L1EGammaCrystalsEmulatorProducer.cc:258
L1EGCrystalClusterEmulatorProducer::mycluster
Definition: L1EGammaCrystalsEmulatorProducer.cc:252
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
get_towerPhi_fromCardLinkTower
int get_towerPhi_fromCardLinkTower(int card, int link, int tower)
Definition: L1EGammaCrystalsEmulatorProducer.cc:183
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
getTowerEta_fromAbsoluteID
float getTowerEta_fromAbsoluteID(int id)
Definition: L1EGammaCrystalsEmulatorProducer.cc:157
get_towerPhi_fromCardTowerInCard
int get_towerPhi_fromCardTowerInCard(int card, int towerincard)
Definition: L1EGammaCrystalsEmulatorProducer.cc:177
n_eta_bins
static constexpr int n_eta_bins
Definition: L1EGammaCrystalsEmulatorProducer.cc:61
l1tp2::CaloTower::setL1egTrkSS
void setL1egTrkSS(int trkSS)
Definition: CaloTower.h:57
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
L1EGCrystalClusterEmulatorProducer::mycluster::ccrystalid_
int ccrystalid_
Definition: L1EGammaCrystalsEmulatorProducer.cc:271
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit
Definition: L1EGammaCrystalsEmulatorProducer.cc:276
edm::Event
Definition: Event.h:73
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::pt
float pt() const
Definition: L1EGammaCrystalsEmulatorProducer.cc:297
L1EGCrystalClusterEmulatorProducer::hbTopology
edm::ESHandle< HcalTopology > hbTopology
Definition: L1EGammaCrystalsEmulatorProducer.cc:249
d0
static constexpr float d0
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
l1tp2::CaloTower::l1egTowerEt
float l1egTowerEt() const
Definition: CaloTower.h:41
a0
static constexpr float a0
Definition: L1EGammaCrystalsEmulatorProducer.cc:81
L1EGCrystalClusterEmulatorProducer::mycluster::cphi_
float cphi_
Definition: L1EGammaCrystalsEmulatorProducer.cc:270
l1tp2::CaloTower::setTowerIEta
void setTowerIEta(int iEta)
Definition: CaloTower.h:52
getTowerPhi_fromAbsoluteID
float getTowerPhi_fromAbsoluteID(int id)
Definition: L1EGammaCrystalsEmulatorProducer.cc:163
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::diphi
int diphi(SimpleCaloHit &other) const
Definition: L1EGammaCrystalsEmulatorProducer.cc:315
cuy.ii
ii
Definition: cuy.py:590
L1EGCrystalClusterEmulatorProducer::passes_photon
bool passes_photon(float pt, float pss)
Definition: L1EGammaCrystalsEmulatorProducer.cc:1197
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
HcalTrigTowerGeometry::detIds
std::vector< HcalDetId > detIds(const HcalTrigTowerDetId &) const
Definition: HcalTrigTowerGeometry.cc:84
d1
static constexpr float d1
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
isolation
double isolation
Definition: AssociatedVariableMaxCutCandRefSelector.cc:25
hit
Definition: SiStripHitEffFromCalibTree.cc:88
L1EGCrystalClusterEmulatorProducer::SimpleCaloHit::id
const EBDetId & id() const
Definition: L1EGammaCrystalsEmulatorProducer.cc:302
n_clusters_per_link
static constexpr int n_clusters_per_link
Definition: L1EGammaCrystalsEmulatorProducer.cc:71
getToweriPhi_fromAbsoluteID
int getToweriPhi_fromAbsoluteID(int id)
Definition: L1EGammaCrystalsEmulatorProducer.cc:150
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443