CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
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  {
21  int puLevelHI[L1CaloRegionDetId::N_ETA];
22  double r_puLevelHI[L1CaloRegionDetId::N_ETA];
23  int etaCount[L1CaloRegionDetId::N_ETA];
24  for(unsigned i = 0; i < L1CaloRegionDetId::N_ETA; ++i)
25  {
26  puLevelHI[i] = 0;
27  r_puLevelHI[i] = 0.0;
28  etaCount[i] = 0;
29  }
30 
31  for(std::vector<CaloRegion>::const_iterator region = regions.begin();
32  region != regions.end(); region++){
33  r_puLevelHI[region->hwEta()] += region->hwPt();
34  etaCount[region->hwEta()]++;
35  }
36 
37  for(unsigned i = 0; i < L1CaloRegionDetId::N_ETA; ++i)
38  {
39  puLevelHI[i] = floor(r_puLevelHI[i]/etaCount[i] + 0.5);
40  }
41 
42  for(std::vector<CaloRegion>::const_iterator region = regions.begin(); region!= regions.end(); region++){
43  int subPt = std::max(0, region->hwPt() - puLevelHI[region->hwEta()]);
44  int subEta = region->hwEta();
45  int subPhi = region->hwPhi();
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  //std::cout << "pre sub: " << subPt;
64  if(subPt != (2<<10)-1)
65  subPt = subPt - (10+subEta); // arbitrary value chosen in meeting
66  if(subPt < 0)
67  subPt = 0;
68  //std::cout << " post sub: " << subPt << std::endl;
69  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
70 
71  CaloRegion newSubRegion(*&ldummy, 0, 0, subPt, subEta, subPhi, region->hwQual(), region->hwEtEm(), region->hwEtHad());
72  subRegions->push_back(newSubRegion);
73  }
74  }
75 
76 
78 
79  void RegionCorrection(const std::vector<l1t::CaloRegion> & regions,
80  std::vector<l1t::CaloRegion> *subRegions,
81  std::vector<double> regionPUSParams,
82  std::string regionPUSType)
83  {
84 
85  if(regionPUSType == "None") {
86  for(std::vector<CaloRegion>::const_iterator notCorrectedRegion = regions.begin();
87  notCorrectedRegion != regions.end(); notCorrectedRegion++){
88  CaloRegion newSubRegion= *notCorrectedRegion;
89  subRegions->push_back(newSubRegion);
90  }
91  }
92 
93  if (regionPUSType == "HICaloRingSub") {
94  HICaloRingSubtraction(regions, subRegions);
95  }
96 
97  if (regionPUSType == "PUM0") {
98  int puMult = 0;
99 
100  // ------------ This calulates PUM0 ------------------
101  for(std::vector<CaloRegion>::const_iterator notCorrectedRegion = regions.begin();
102  notCorrectedRegion != regions.end(); notCorrectedRegion++){
103  int regionET = notCorrectedRegion->hwPt();
104  // cout << "regionET: " << regionET <<endl;
105  if (regionET > 0) {puMult++;}
106  }
107  int pumbin = (int) puMult/22;
108  if(pumbin == 18) pumbin = 17; // if puMult = 396 exactly there is an overflow
109 
110  for(std::vector<CaloRegion>::const_iterator notCorrectedRegion = regions.begin();
111  notCorrectedRegion != regions.end(); notCorrectedRegion++){
112 
113  int regionET = notCorrectedRegion->hwPt();
114  int regionEta = notCorrectedRegion->hwEta();
115  int regionPhi = notCorrectedRegion->hwPhi();
116 
117  int puSub = ceil(regionPUSParams[18*regionEta+pumbin]*2);
118  // The values in regionSubtraction are MULTIPLIED by
119  // RegionLSB=.5 (physicalRegionEt), so to get back unmultiplied
120  // regionSubtraction we want to multiply the number by 2
121  // (aka divide by LSB).
122 
123  //if(puSub > 0)
124  //std::cout << "eta: " << regionEta << " pusub: " << puSub << std::endl;
125 
126  int regionEtCorr = std::max(0, regionET - puSub);
127  if(regionET == 1023)
128  regionEtCorr = 1023; // do not subtract overflow regions
129 
130  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > lorentz(0,0,0,0);
131  CaloRegion newSubRegion(*&lorentz, 0, 0, regionEtCorr, regionEta, regionPhi, notCorrectedRegion->hwQual(), notCorrectedRegion->hwEtEm(), notCorrectedRegion->hwEtHad());
132  subRegions->push_back(newSubRegion);
133  }
134  //std::cout << "PUM0 " << puMult << std::endl;
135  }
136 
137  }
138 
139 }
int i
Definition: DBlmapReader.cc:9
void RegionCorrection(const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::CaloRegion > *subRegions, std::vector< double > regionPUSparams, std::string regionPUSType)
------— New region correction (PUsub, no response correction at the moment) --------— ...
static const unsigned N_ETA
void HICaloRingSubtraction(const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::CaloRegion > *subRegions)
------------— For heavy ion ----------------------------------—
void simpleHWSubtraction(const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::CaloRegion > *subRegions)