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> > *lorentz =
48  new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
49 
50  CaloRegion newSubRegion(*lorentz, 0, 0, subPt, subEta, subPhi, 0, 0, 0);
51  subRegions->push_back(newSubRegion);
52  }
53  }
54 
55 
57 
58  void RegionCorrection(const std::vector<l1t::CaloRegion> & regions,
59  const std::vector<l1t::CaloEmCand> & EMCands,
60  std::vector<l1t::CaloRegion> *subRegions,
61  std::vector<double> regionSubtraction,
62  bool PUSubtract)
63 {
64 
65  int puMult = 0;
66  // ------------ This calulates PUM0 -------------------
67  for(std::vector<CaloRegion>::const_iterator notCorrectedRegion = regions.begin();
68  notCorrectedRegion != regions.end(); notCorrectedRegion++){
69  int regionET = notCorrectedRegion->hwPt();
70  // cout << "regionET: " << regionET <<endl;
71  if (regionET > 0) {puMult++;}
72  }
73 
74  for(std::vector<CaloRegion>::const_iterator notCorrectedRegion = regions.begin();
75  notCorrectedRegion != regions.end(); notCorrectedRegion++){
76 
77  if(!PUSubtract) {
78  CaloRegion newSubRegion= *notCorrectedRegion;
79  subRegions->push_back(newSubRegion);
80  continue;
81  }
82 
83  int regionET = notCorrectedRegion->hwPt();
84  int regionEta = notCorrectedRegion->hwEta();
85  int regionPhi = notCorrectedRegion->hwPhi();
86 
87  int regionEtCorr (0);
88  // Only non-empty regions are corrected
89  if (regionET !=0) {
90  int energyECAL2x1=0;
91  // Find associated 2x1 ECAL energy (EG are calibrated,
92  // we should not scale them up, it affects the isolation routines)
93  // 2x1 regions have the MAX tower contained in the 4x4 region that its position points to.
94  // This is to not break isolation.
95  for(CaloEmCandBxCollection::const_iterator egCand = EMCands.begin();
96  egCand != EMCands.end(); egCand++) {
97  int et = egCand->hwPt();
98  if(egCand->hwPhi() == regionPhi && egCand->hwEta() == regionEta) {
99  energyECAL2x1=et;
100  break; // I do not really like "breaks"
101  }
102  }
103 
104  //comment out region corrections (below) at the moment since they're broken
105 
106  //double alpha = regionSF[2*regionEta + 0]; //Region Scale factor (See regionSF_cfi)
107  //double gamma = 2*((regionSF[2*regionEta + 1])/9); //Region Offset.
108  // It needs to be divided by nine from the jet derived value in the lookup table.
109  // Multiplied by 2 because gamma is given in regionPhysicalET (=regionEt*regionLSB),
110  // while we want regionEt= physicalEt/LSB and LSB=.5.
111 
112 
113  //if(!ResponseCorr || regionET<20) {alpha=1; gamma=0;}
114  double alpha=1; double gamma=0;
115 
116 
117  int pumbin = (int) puMult/22; //396 Regions. Bins are 22 wide. Dividing by 22 gives which bin# of the 18 bins.
118 
119  double puSub = regionSubtraction[18*regionEta+pumbin]*2;
120  // The values in regionSubtraction are MULTIPLIED by
121  // RegionLSB=.5 (physicalRegionEt), so to get back unmultiplied
122  // regionSubtraction we want to multiply the number by 2
123  // (aka divide by LSB).
124 
125  int corrpum0pt (0);
126  if(regionET - puSub>0) {
127  int pum0pt = (regionET - puSub-energyECAL2x1); //subtract ECAl energy
128 
129  corrpum0pt = pum0pt*alpha+gamma+energyECAL2x1;
130  //add back in ECAL energy, calibrate regions(not including the ECAL2x1).
131  if (corrpum0pt <0 || pum0pt<0) {corrpum0pt=0;} //zero floor
132  }
133  regionEtCorr = corrpum0pt;
134  }
135 
136  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *lorentz =
137  new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
138  CaloRegion newSubRegion(*lorentz, 0, 0, regionEtCorr, regionEta, regionPhi, 0, 0, 0);
139  subRegions->push_back(newSubRegion);
140  }
141 
142 }
143 
144 }
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
static const unsigned N_ETA
void HICaloRingSubtraction(const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::CaloRegion > *subRegions)
------------— For heavy ion ----------------------------------—
const T & max(const T &a, const T &b)
void RegionCorrection(const std::vector< l1t::CaloRegion > &regions, const std::vector< l1t::CaloEmCand > &EMCands, std::vector< l1t::CaloRegion > *subRegions, std::vector< double > regionSubtraction, bool PUSubtract)
------— New region correction (PUsub, no response correction at the moment) --------— ...
int hwPt() const
Definition: L1Candidate.cc:69
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:16