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 }
EcalRecHit
Definition: EcalRecHit.h:15
mps_fire.i
i
Definition: mps_fire.py:355
calib::CalibElectron::theEEHits_
const EcalRecHitCollection * theEEHits_
Definition: CalibElectron.h:32
EcalRingCalibrationTools::getRingIndex
static short getRingIndex(DetId aDetId)
Retrieve the phi-ring index corresponding to a DetId.
Definition: EcalRingCalibrationTools.cc:24
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EBDetId.h
EcalRecHit::energy
float energy() const
Definition: EcalRecHit.h:68
EcalBarrel
Definition: EcalSubdetector.h:10
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
calib::CalibElectron::theHits_
const EcalRecHitCollection * theHits_
Definition: CalibElectron.h:31
PVValHelper::eta
Definition: PVValidationHelpers.h:69
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
CalibElectron.h
calib
Definition: CalibElectron.h:12
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
EcalRingCalibrationTools::N_RING_TOTAL
static constexpr short N_RING_TOTAL
Definition: EcalRingCalibrationTools.h:37
EcalIndexingTools::getInstance
static EcalIndexingTools * getInstance()
Definition: EcalIndexingTools.h:23
calib::CalibElectron::theElectron_
const reco::GsfElectron * theElectron_
Definition: CalibElectron.h:29
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
recoMuon::in
Definition: RecoMuonEnumerators.h:6
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
EcalRecHit.h
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
Electron.h
std
Definition: JetResolutionObject.h:76
SuperCluster.h
EcalRingCalibrationTools::getModuleIndex
static short getModuleIndex(DetId aDetId)
Definition: EcalRingCalibrationTools.cc:49
reco::GsfElectron::superCluster
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:163
EcalIndexingTools::getProgressiveIndex
int getProgressiveIndex(double, double)
Definition: EcalIndexingTools.cc:27
calib::CalibElectron::getCalibModulesWeights
std::vector< std::pair< int, float > > getCalibModulesWeights(TString calibtype)
Definition: CalibElectron.cc:16
EcalIndexingTools.h
calib::CalibElectron::CalibElectron
CalibElectron()
Definition: CalibElectron.cc:14
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
EcalRingCalibrationTools::N_MODULES_BARREL
static constexpr short N_MODULES_BARREL
Definition: EcalRingCalibrationTools.h:41
EcalRingCalibrationTools.h
EcalIndexingTools::getNumberOfChannels
int getNumberOfChannels()
Definition: EcalIndexingTools.h:32