CMS 3D CMS Logo

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