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