CMS 3D CMS Logo

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