CMS 3D CMS Logo

CalibElectron.cc
Go to the documentation of this file.
9 #include <iostream>
10 
11 using namespace calib;
12 using namespace std;
13 
14 CalibElectron::CalibElectron() : theElectron_(nullptr), theHits_(nullptr), theEEHits_(nullptr) {}
15 
16 std::vector<std::pair<int, float> > CalibElectron::getCalibModulesWeights(TString calibtype) {
17  std::vector<std::pair<int, float> > theWeights;
18 
19  if (calibtype == "RING") {
21 
22  for (int i = 0; i < EcalRingCalibrationTools::N_RING_TOTAL; ++i)
23  w_ring[i] = 0.;
24 
25  std::vector<std::pair<DetId, float> > scDetIds = theElectron_->superCluster()->hitsAndFractions();
26 
27  for (std::vector<std::pair<DetId, float> >::const_iterator idIt = scDetIds.begin(); idIt != scDetIds.end();
28  ++idIt) {
29  const EcalRecHit* rh = nullptr;
30  if ((*idIt).first.subdetId() == EcalBarrel)
31  rh = &*(theHits_->find((*idIt).first));
32  else if ((*idIt).first.subdetId() == EcalEndcap)
33  rh = &*(theEEHits_->find((*idIt).first));
34  if (!rh)
35  std::cout << "CalibElectron::BIG ERROR::RecHit NOT FOUND" << std::endl;
36  w_ring[EcalRingCalibrationTools::getRingIndex((*idIt).first)] += rh->energy();
37  }
38 
39  for (int i = 0; i < EcalRingCalibrationTools::N_RING_TOTAL; ++i)
40  if (w_ring[i] != 0.)
41  theWeights.push_back(std::pair<int, float>(i, w_ring[i]));
42  // std::cout << " ring " << i << " - energy sum " << w_ring[i] << std::endl;
43  }
44 
45  else if (calibtype == "MODULE") {
47 
49  w_ring[i] = 0.;
50 
51  std::vector<std::pair<DetId, float> > scDetIds = theElectron_->superCluster()->hitsAndFractions();
52 
53  for (std::vector<std::pair<DetId, float> >::const_iterator idIt = scDetIds.begin(); idIt != scDetIds.end();
54  ++idIt) {
55  const EcalRecHit* rh = nullptr;
56  if ((*idIt).first.subdetId() == EcalBarrel)
57  rh = &*(theHits_->find((*idIt).first));
58  else if ((*idIt).first.subdetId() == EcalEndcap)
59  rh = &*(theEEHits_->find((*idIt).first));
60  if (!rh)
61  std::cout << "CalibElectron::BIG ERROR::RecHit NOT FOUND" << std::endl;
62  w_ring[EcalRingCalibrationTools::getModuleIndex((*idIt).first)] += rh->energy();
63  }
64 
66  if (w_ring[i] != 0.)
67  theWeights.push_back(std::pair<int, float>(i, w_ring[i]));
68  // std::cout << " ring " << i << " - energy sum " << w_ring[i] << std::endl;
69 
70  }
71 
72  else if (calibtype == "ABS_SCALE") {
73  std::cout << "ENTERING CalibElectron, ABS SCALE mode" << std::endl;
74 
75  float w_ring(0.);
76 
77  std::vector<std::pair<DetId, float> > scDetIds = theElectron_->superCluster()->hitsAndFractions();
78 
79  for (std::vector<std::pair<DetId, float> >::const_iterator idIt = scDetIds.begin(); idIt != scDetIds.end();
80  ++idIt) {
81  const EcalRecHit* rh = nullptr;
82  if ((*idIt).first.subdetId() == EcalBarrel)
83  rh = &*(theHits_->find((*idIt).first));
84  else if ((*idIt).first.subdetId() == EcalEndcap)
85  rh = &*(theEEHits_->find((*idIt).first));
86  if (!rh)
87  std::cout << "CalibElectron::BIG ERROR::RecHit NOT FOUND" << std::endl;
88 
89  w_ring += rh->energy();
90  }
91 
92  if (w_ring != 0.)
93  theWeights.push_back(std::pair<int, float>(0, w_ring));
94  std::cout << " ABS SCALE - energy sum " << w_ring << std::endl;
95 
96  }
97 
98  else if (calibtype == "ETA_ET_MODE") {
99  float w_ring[200];
100 
101  for (int i = 0; i < EcalIndexingTools::getInstance()->getNumberOfChannels(); ++i)
102  w_ring[i] = 0.;
103 
104  std::vector<std::pair<DetId, float> > scDetIds = theElectron_->superCluster()->hitsAndFractions();
105 
106  for (std::vector<std::pair<DetId, float> >::const_iterator idIt = scDetIds.begin(); idIt != scDetIds.end();
107  ++idIt) {
108  const EcalRecHit* rh = nullptr;
109  if ((*idIt).first.subdetId() == EcalBarrel)
110  rh = &*(theHits_->find((*idIt).first));
111  else if ((*idIt).first.subdetId() == EcalEndcap)
112  rh = &*(theEEHits_->find((*idIt).first));
113  if (!rh)
114  std::cout << "CalibElectron::BIG ERROR::RecHit NOT FOUND" << std::endl;
115 
116  float eta = fabs(theElectron_->eta());
117  float theta = 2. * atan(exp(-eta));
118  float et = theElectron_->superCluster()->energy() * sin(theta);
119 
121 
122  w_ring[in] += rh->energy();
123  //w_ring[in]+=theElectron_->superCluster()->energy();
124 
125  std::cout << "CalibElectron::filling channel " << in << " with value " << theElectron_->superCluster()->energy()
126  << std::endl;
127  }
128 
129  for (int i = 0; i < EcalIndexingTools::getInstance()->getNumberOfChannels(); ++i) {
130  if (w_ring[i] != 0.) {
131  theWeights.push_back(std::pair<int, float>(i, w_ring[i]));
132  std::cout << " ring " << i << " - energy sum " << w_ring[i] << std::endl;
133  }
134  }
135 
136  }
137 
138  else {
139  std::cout << "CalibType not yet implemented" << std::endl;
140  }
141 
142  return theWeights;
143 }
static short getModuleIndex(DetId aDetId)
static constexpr short N_MODULES_BARREL
const EcalRecHitCollection * theEEHits_
Definition: CalibElectron.h:32
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static short getRingIndex(DetId aDetId)
Retrieve the phi-ring index corresponding to a DetId.
const EcalRecHitCollection * theHits_
Definition: CalibElectron.h:31
static EcalIndexingTools * getInstance()
std::vector< std::pair< int, float > > getCalibModulesWeights(TString calibtype)
static constexpr short N_RING_TOTAL
int getProgressiveIndex(double, double)
iterator find(key_type k)
float energy() const
Definition: EcalRecHit.h:69
const reco::GsfElectron * theElectron_
Definition: CalibElectron.h:29
Geom::Theta< T > theta() const
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
double eta() const final
momentum pseudorapidity