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