Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:29

0001 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixMaxof2.h>
0002 
0003 // global type definitions for class implementation in source file defined by
0004 // Tag entries in ArgoUML Result: typedef <typedef_global_source> <tag_value>;
0005 EcalFenixMaxof2::EcalFenixMaxof2(int maxNrSamples, int nbMaxStrips) : nbMaxStrips_(nbMaxStrips) {
0006   std::vector<int> vec(maxNrSamples, 0);
0007   for (int i2strip = 0; i2strip < nbMaxStrips_ - 1; ++i2strip)
0008     sumby2_.push_back(vec);
0009 }
0010 
0011 EcalFenixMaxof2::~EcalFenixMaxof2() {}
0012 
0013 void EcalFenixMaxof2::process(
0014     std::vector<std::vector<int>> &bypasslinout, int nstrip, int bitMask, int bitOddEven, std::vector<int> &output) {
0015   int mask = (1 << bitMask) - 1;
0016   bool strip_oddmask[nstrip][output.size()];
0017 
0018   for (int i2strip = 0; i2strip < nstrip - 1; ++i2strip)
0019     for (unsigned int i = 0; i < output.size(); i++)
0020       sumby2_[i2strip][i] = 0;
0021   for (unsigned int i = 0; i < output.size(); i++)
0022     output[i] = 0;
0023 
0024   // Prepare also the mask of strips to be avoided because of the odd>even energy flag
0025   for (int istrip = 0; istrip < nstrip; ++istrip) {
0026     for (unsigned int i = 0; i < output.size(); i++) {
0027       if ((bypasslinout[istrip][i] >> bitOddEven) & 1)
0028         strip_oddmask[istrip][i] = false;
0029       else
0030         strip_oddmask[istrip][i] = true;
0031     }
0032   }
0033 
0034   for (unsigned int i = 0; i < output.size(); i++) {
0035     if (nstrip - 1 == 0) {
0036       output[i] = strip_oddmask[0][i] * ((bypasslinout[0][i]) & mask);
0037     } else {
0038       for (int i2strip = 0; i2strip < nstrip - 1; ++i2strip) {
0039         sumby2_[i2strip][i] = strip_oddmask[i2strip][i] * ((bypasslinout[i2strip][i]) & mask) +
0040                               strip_oddmask[i2strip + 1][i] * ((bypasslinout[i2strip + 1][i]) & mask);
0041         if (sumby2_[i2strip][i] > output[i]) {
0042           output[i] = sumby2_[i2strip][i];
0043         }
0044       }
0045     }
0046   }
0047   return;
0048 }