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