CMS 3D CMS Logo

EcalFenixAmplitudeFilter.cc
Go to the documentation of this file.
6 #include <iostream>
7 
9  :inputsAlreadyIn_(0), shift_(6) {
10  }
11 
13 
15 {
16  if(input>0X3FFFF)
17  {
18  std::cout<<"ERROR IN INPUT OF AMPLITUDE FILTER"<<std::endl;
19  return -1;
20  }
21  if(inputsAlreadyIn_<5)
22  {
23  //std::cout << " EcalFenixAmplitudeFilter::setInput inputsAlreadyIn_<5 input " << input << std::endl;
27  }
28  else
29  {
30  for(int i=0; i<4; i++)
31  {
32  buffer_[i]=buffer_[i+1];
33  //std::cout << " EcalFenixAmplitudeFilter::setInput inputsAlreadyIn buffer " << buffer_[i] << std::endl;
35  }
36  buffer_[4]=input;
37  fgvbBuffer_[4]=fgvb;
38  }
39  return 1;
40 }
41 
42 void EcalFenixAmplitudeFilter::process(std::vector<int> &addout,std::vector<int> &output, std::vector<int> &fgvbIn, std::vector<int> &fgvbOut)
43 {
44  // test
45 
47  for (unsigned int i =0;i<5;i++){
48  buffer_[i]=0;//FIXME: 5
49  fgvbBuffer_[i]=0;
50  }
51 
52  // test end
53 
54  //std::cout << " EcalFenixAmplitudeFilter::process(std::vector<int> &addout size " << addout.size() << std::endl;
55  for (unsigned int i =0;i<addout.size();i++){
56 
57  setInput(addout[i],fgvbIn[i]);
58  for (unsigned int i =0;i<5;i++){
59  // std::cout << " buffer_ " << buffer_[i];
60  }
61  //std::cout << " " << std::endl;
62  process();
63  output[i]=processedOutput_;
64  fgvbOut[i]=processedFgvbOutput_;
65  }
66  // shift the result by 1!
67  for (unsigned int i=0 ; i<(output.size());i++){
68  if (i!=output.size()-1){
69  output[i]=output[i+1];
70  fgvbOut[i] = fgvbOut[i+1];
71  }
72  else{
73  output[i]=0;
74  fgvbOut[i] = 0;
75  }
76  }
77  return;
78 }
79 
81 {
82  //UB FIXME: 5
83  processedOutput_ = 0;
85  if(inputsAlreadyIn_<5) return;
86  int output=0;
87  int fgvbInt = 0;
88  for(int i=0; i<5; i++)
89  {
90 
91  output+=(weights_[i]*buffer_[i])>>shift_;
92  //std::cout << " AmplitudeFilter buffer " << buffer_[i] << " weight " << weights_[i] << " output " << output << std::endl;
93  if((fgvbBuffer_[i] == 1 && i == 3) || fgvbInt == 1)
94  {
95  fgvbInt = 1;
96  }
97  }
98  if(output<0) output=0;
99  if(output>0X3FFFF) output=0X3FFFF;
101  processedFgvbOutput_ = fgvbInt;
102 }
103 
104 void EcalFenixAmplitudeFilter::setParameters(uint32_t raw,const EcalTPGWeightIdMap * ecaltpgWeightMap,const EcalTPGWeightGroup * ecaltpgWeightGroup)
105 {
106  uint32_t params_[5];
107  const EcalTPGGroups::EcalTPGGroupsMap & groupmap = ecaltpgWeightGroup -> getMap();
108  EcalTPGGroups::EcalTPGGroupsMapItr it = groupmap.find(raw);
109  if (it!=groupmap.end()) {
110  uint32_t weightid =(*it).second;
111  const EcalTPGWeightIdMap::EcalTPGWeightMap & weightmap = ecaltpgWeightMap -> getMap();
112  EcalTPGWeightIdMap::EcalTPGWeightMapItr itw = weightmap.find(weightid);
113  (*itw).second.getValues(params_[0],params_[1],params_[2],params_[3],params_[4]);
114 
115  // we have to transform negative coded in 7 bits into negative coded in 32 bits
116  // maybe this should go into the getValue method??
117  //std::cout << "peak flag settings" << std::endl;
118  for (int i=0;i<5;++i){
119  weights_[i] = (params_[i] & 0x40) ? (int)( params_[i] | 0xffffffc0) : (int)(params_[i]);
120 
121  // Construct the peakFlag for sFGVB processing
122  //peakFlag_[i] = ((params_[i] & 0x80) > 0x0) ? 1 : 0;
123  //std::cout << " " << params_[i] << std::endl;
124  //std::cout << " " << peakFlag_[i] << std::endl;
125  }
126  //std::cout << std::endl;
127  }
128  else edm::LogWarning("EcalTPG")<<" could not find EcalTPGGroupsMap entry for "<<raw;
129 }
130 
131 
132 
133 
std::map< uint32_t, EcalTPGWeights >::const_iterator EcalTPGWeightMapItr
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:23
static std::string const input
Definition: EdmProvDump.cc:48
int setInput(int input, int fgvb)
std::map< uint32_t, EcalTPGWeights > EcalTPGWeightMap
void setParameters(uint32_t raw, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup)
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:22