Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-14 02:22:58

0001 #include <SimCalorimetry/EcalEBTrigPrimAlgos/interface/EcalEBFenixPeakFinder.h>
0002 #include <iostream>
0003 
0004 EcalEBFenixPeakFinder::EcalEBFenixPeakFinder() : inputsAlreadyIn_(0) {}
0005 
0006 EcalEBFenixPeakFinder::~EcalEBFenixPeakFinder() {}
0007 
0008 int EcalEBFenixPeakFinder::setInput(int input) {
0009   if (inputsAlreadyIn_ < 3) {
0010     //std::cout << " EcalEBFenixPeakFinder::setInput inputsAlreadyIn_<3 input " << input << std::endl;
0011     buffer_[inputsAlreadyIn_] = input;
0012     inputsAlreadyIn_++;
0013   } else {
0014     for (int i = 0; i < 2; i++) {
0015       buffer_[i] = buffer_[i + 1];
0016       //std::cout << " EcalEBFenixPeakFinder::setInput inputsAlreadyIn buffer " << buffer_[i] << std::endl;
0017     }
0018     buffer_[2] = input;
0019   }
0020   return 1;
0021 }
0022 
0023 int EcalEBFenixPeakFinder::process() {
0024   if (inputsAlreadyIn_ < 3)
0025     return 0;
0026   if (buffer_[1] > buffer_[0] && buffer_[1] > buffer_[2])
0027     return 1;
0028   else
0029     return 0;
0030 }
0031 
0032 std::vector<int> EcalEBFenixPeakFinder::process(std::vector<int> &filtout, std::vector<int> &output) {
0033   // FIXME: 3
0034   inputsAlreadyIn_ = 0;
0035   for (unsigned int i = 0; i < 3; i++)
0036     buffer_[i] = 0;
0037 
0038   //  std::vector<int> output;
0039 
0040   //std::cout << "  EcalEBFenixPeakFinder::process(   " << filtout.size() << std::endl;
0041   // attention, we have to shift by one, because the peak is found one too late
0042   for (unsigned int i = 0; i < filtout.size(); i++) {
0043     setInput(filtout[i]);
0044     for (unsigned int i = 0; i < 3; i++) {
0045       //  std::cout << " buffer_ " << buffer_[i];
0046     }
0047     //std::cout << "  " << std::endl;
0048 
0049     if (i > 0) {
0050       //      int outone = process();
0051       //      output.push_back(outone);
0052       output[i - 1] = process();
0053     }
0054   }
0055   //  output.resize(filtout.size());
0056 
0057   return output;
0058 }