CMS 3D CMS Logo

EcalEBPhase2AmplitudeReconstructor.cc
Go to the documentation of this file.
7 
8 #include <iostream>
9 
11  : debug_(debug), inputsAlreadyIn_(0), shift_(13) {}
12 
14 
16  if (input > 0X3FFF) {
17  edm::LogError("EcalEBPhase2AmplitudeReconstructor") << "ERROR IN INPUT OF AMPLITUDE FILTER" << std::endl;
18  return -1;
19  }
20 
22  if (debug_)
23  LogDebug("") << " EcalEBPhase2AmplitudeReconstructor::setInput inputsAlreadyIn_<5 input " << input << std::endl;
24 
27  } else {
28  for (int i = 0; i < (maxSamplesUsed_ - 1); i++) {
29  buffer_[i] = buffer_[i + 1];
30  if (debug_)
31  LogDebug("") << " EcalEBPhase2AmplitudeReconstructor::setInput inputsAlreadyIn buffer " << buffer_[i]
32  << std::endl;
33  }
35  }
36  return 1;
37 }
38 
39 void EcalEBPhase2AmplitudeReconstructor::process(std::vector<int> &linout, std::vector<int> &output) {
40  inputsAlreadyIn_ = 0;
41  for (unsigned int i = 0; i < maxSamplesUsed_; i++) {
42  buffer_[i] = 0;
43  }
44 
45  for (unsigned int i = 0; i < linout.size(); i++) {
46  setInput(linout[i]);
47  if (debug_) {
48  for (unsigned int j = 0; j < maxSamplesUsed_; j++) {
49  LogDebug("") << " buffer_ " << buffer_[j];
50  }
51  LogDebug("") << " " << std::endl;
52  }
53 
54  if (i == (maxSamplesUsed_ - 1)) {
55  process();
57  } else if (i == (ecalPh2::sampleSize - 1)) {
58  process();
60  }
61  }
62  return;
63 }
64 
66  processedOutput_ = 0;
68  return;
69  int64_t tmpIntOutput = 0;
70  for (int i = 0; i < maxSamplesUsed_; i++) {
71  tmpIntOutput += (weights_[i] * buffer_[i]);
72  if (debug_)
73  LogDebug("") << " AmplitudeFilter buffer " << buffer_[i] << " weight " << weights_[i] << std::endl;
74  }
75  if (tmpIntOutput < 0)
76  tmpIntOutput = 0;
77  tmpIntOutput = tmpIntOutput >> shift_;
78  if (debug_)
79  LogDebug("") << " AmplitudeFilter tmpIntOutput " << tmpIntOutput << " shift_ " << shift_ << std::endl;
80  if (tmpIntOutput > 0X1FFF)
81  tmpIntOutput = 0X1FFF;
82  uint output = tmpIntOutput; // should be 13 bit uint at this point
84  if (debug_)
85  LogDebug("") << " AmplitudeFilter processedOutput_ " << processedOutput_ << std::endl;
86 }
87 
89  const EcalEBPhase2TPGAmplWeightIdMap *ecaltpgWeightMap,
90  const EcalTPGWeightGroup *ecaltpgWeightGroup) {
91  uint32_t params_[maxSamplesUsed_];
92  const EcalTPGGroups::EcalTPGGroupsMap &groupmap = ecaltpgWeightGroup->getMap();
93  if (debug_)
94  LogDebug("") << " EcalEBPhase2AmplitudeReconstructor::setParameters groupmap size " << groupmap.size()
95  << " channel ID " << raw << std::endl;
96  EcalTPGGroups::EcalTPGGroupsMapItr it = groupmap.find(raw);
97  if (it != groupmap.end()) {
98  uint32_t weightid = (*it).second;
99 
100  const EcalEBPhase2TPGAmplWeightIdMap::EcalEBPhase2TPGAmplWeightMap &weightmap = ecaltpgWeightMap->getMap();
102 
103  (*itw).second.getValues(params_[0],
104  params_[1],
105  params_[2],
106  params_[3],
107  params_[4],
108  params_[5],
109  params_[6],
110  params_[7],
111  params_[8],
112  params_[9],
113  params_[10],
114  params_[11]);
115 
116  if (debug_)
117  LogDebug("") << " EcalEBPhase2AmplitudeReconstructor::setParameters weights after the map " << params_[0] << " "
118  << params_[1] << " " << params_[2] << " " << params_[3] << " " << params_[4] << " " << params_[5]
119  << " " << params_[6] << " " << params_[7] << " " << params_[8] << " " << params_[9] << " "
120  << params_[10] << " " << params_[11] << std::endl;
121 
122  // we have to transform negative coded in 13 bits into negative coded in 32 bits
123  // maybe this should go into the getValue method??
124 
125  for (int i = 0; i < maxSamplesUsed_; ++i) {
126  weights_[i] = (params_[i] & 0x1000) ? (int)(params_[i] | 0xfffff000) : (int)(params_[i]);
127  }
128 
129  if (debug_) {
130  for (int i = 0; i < maxSamplesUsed_; ++i) {
131  LogDebug("") << " EcalEBPhase2AmplitudeReconstructor::setParameters weights after the cooking " << weights_[i]
132  << std::endl;
133  }
134  LogDebug("") << std::endl;
135  }
136 
137  } else
138  edm::LogWarning("EcalTPG")
139  << " EcalEBPhase2AmplitudeReconstructor::setParameters could not find EcalTPGGroupsMap entry for " << raw;
140 }
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:20
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:25
Log< level::Error, false > LogError
static std::string const input
Definition: EdmProvDump.cc:50
static constexpr unsigned int sampleSize
Definition: EcalConstants.h:36
#define debug
Definition: HDRShower.cc:19
const EcalEBPhase2TPGAmplWeightMap & getMap() const
std::map< uint32_t, EcalEBPhase2TPGAmplWeights > EcalEBPhase2TPGAmplWeightMap
void setParameters(uint32_t raw, const EcalEBPhase2TPGAmplWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup)
Definition: output.py:1
Log< level::Warning, false > LogWarning
std::map< uint32_t, EcalEBPhase2TPGAmplWeights >::const_iterator EcalEBPhase2TPGAmplWeightMapItr
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:19
#define LogDebug(id)