CMS 3D CMS Logo

PUSubtractionMethods.cc
Go to the documentation of this file.
1 // PUSubtractionMethods.cc
2 // Authors: Alex Barbieri
3 // Kalanand Mishra, Fermilab
4 // Inga Bucinskaite, UIC
5 //
6 // This file should contain the different algorithms used to perform PU, UE subtraction.
7 
8 //#include "DataFormats/L1TCalorimeter/interface/CaloRegion.h"
10 #include "TMath.h"
11 
12 //#include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
13 #include <vector>
14 
15 namespace l1t {
16 
18  void HICaloRingSubtraction(const std::vector<l1t::CaloRegion> &regions,
19  std::vector<l1t::CaloRegion> *subRegions,
20  CaloParamsHelper const *params) {
21  int puLevelHI[L1CaloRegionDetId::N_ETA];
22 
23  for (unsigned i = 0; i < L1CaloRegionDetId::N_ETA; ++i) {
24  puLevelHI[i] = 0;
25  }
26 
27  for (std::vector<CaloRegion>::const_iterator region = regions.begin(); region != regions.end(); region++) {
28  puLevelHI[region->hwEta()] += region->hwPt();
29  }
30 
31  for (unsigned i = 0; i < L1CaloRegionDetId::N_ETA; ++i) {
32  //puLevelHI[i] = floor(((double)puLevelHI[i] / (double)L1CaloRegionDetId::N_PHI)+0.5);
33  puLevelHI[i] = (puLevelHI[i] + 9) * 455 / (1 << 13); // approx equals X/18 +0.5
34  }
35 
36  for (std::vector<CaloRegion>::const_iterator region = regions.begin(); region != regions.end(); region++) {
37  int subPt = std::max(0, region->hwPt() - puLevelHI[region->hwEta()]);
38  int subEta = region->hwEta();
39  int subPhi = region->hwPhi();
40 
41  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0, 0, 0, 0);
42 
43  CaloRegion newSubRegion(
44  *&ldummy, 0, 0, subPt, subEta, subPhi, region->hwQual(), region->hwEtEm(), region->hwEtHad());
45  subRegions->push_back(newSubRegion);
46  }
47  }
48 
49  void simpleHWSubtraction(const std::vector<l1t::CaloRegion> &regions, std::vector<l1t::CaloRegion> *subRegions) {
50  for (std::vector<CaloRegion>::const_iterator region = regions.begin(); region != regions.end(); region++) {
51  int subEta = region->hwEta();
52  int subPhi = region->hwPhi();
53  int subPt = region->hwPt();
54 
55  if (subPt != (2 << 10) - 1)
56  subPt = subPt - (10 + subEta); // arbitrary value chosen in meeting
57  if (subPt < 0)
58  subPt = 0;
59  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0, 0, 0, 0);
60 
61  CaloRegion newSubRegion(
62  *&ldummy, 0, 0, subPt, subEta, subPhi, region->hwQual(), region->hwEtEm(), region->hwEtHad());
63  subRegions->push_back(newSubRegion);
64  }
65  }
66 
68 
69  void RegionCorrection(const std::vector<l1t::CaloRegion> &regions,
70  std::vector<l1t::CaloRegion> *subRegions,
71  CaloParamsHelper const *params) {
72  std::string regionPUSType = params->regionPUSType();
73 
74  if (regionPUSType == "None") {
75  for (std::vector<CaloRegion>::const_iterator notCorrectedRegion = regions.begin();
76  notCorrectedRegion != regions.end();
77  notCorrectedRegion++) {
78  const CaloRegion &newSubRegion = *notCorrectedRegion;
79  subRegions->push_back(newSubRegion);
80  }
81  }
82 
83  if (regionPUSType == "HICaloRingSub") {
84  HICaloRingSubtraction(regions, subRegions, params);
85  }
86 
87  if (regionPUSType == "PUM0") {
88  int puMult = 0;
89 
90  // ------------ This calulates PUM0 ------------------
91  for (std::vector<CaloRegion>::const_iterator notCorrectedRegion = regions.begin();
92  notCorrectedRegion != regions.end();
93  notCorrectedRegion++) {
94  int regionET = notCorrectedRegion->hwPt();
95  if (regionET > 0) {
96  puMult++;
97  }
98  }
99  int pumbin = (int)puMult / 22;
100  if (pumbin == 18)
101  pumbin = 17; // if puMult = 396 exactly there is an overflow
102 
103  for (std::vector<CaloRegion>::const_iterator notCorrectedRegion = regions.begin();
104  notCorrectedRegion != regions.end();
105  notCorrectedRegion++) {
106  int regionET = notCorrectedRegion->hwPt();
107  int regionEta = notCorrectedRegion->hwEta();
108  int regionPhi = notCorrectedRegion->hwPhi();
109 
110  //int puSub = ceil(regionPUSParams[18*regionEta+pumbin]*2);
111  int puSub = params->regionPUSValue(pumbin, regionEta);
112  // The values in regionSubtraction are MULTIPLIED by
113  // RegionLSB=.5 (physicalRegionEt), so to get back unmultiplied
114  // regionSubtraction we want to multiply the number by 2
115  // (aka divide by LSB).
116 
117  int regionEtCorr = std::max(0, regionET - puSub);
118  if (regionET == 1023)
119  regionEtCorr = 1023; // do not subtract overflow regions
120  if ((regionET == 255) && (regionEta < 4 || regionEta > 17))
121  regionEtCorr = 255;
122 
123  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > lorentz(0, 0, 0, 0);
124  CaloRegion newSubRegion(*&lorentz,
125  0,
126  0,
127  regionEtCorr,
128  regionEta,
129  regionPhi,
130  notCorrectedRegion->hwQual(),
131  notCorrectedRegion->hwEtEm(),
132  notCorrectedRegion->hwEtHad());
133  subRegions->push_back(newSubRegion);
134  }
135  }
136  }
137 } // namespace l1t
delete x;
Definition: CaloConfig.h:22
static const unsigned N_ETA
void RegionCorrection(const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::CaloRegion > *subRegions, CaloParamsHelper const *params)
------— New region correction (PUsub, no response correction at the moment) --------— ...
void simpleHWSubtraction(const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::CaloRegion > *subRegions)
void HICaloRingSubtraction(const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::CaloRegion > *subRegions, CaloParamsHelper const *params)
------------— For heavy ion ----------------------------------—