Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-10 01:54:09

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include <CondFormats/EcalObjects/interface/EcalTPGSlidingWindow.h>
0003 #include <CondFormats/EcalObjects/interface/EcalTPGTPMode.h>
0004 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixStripFormatEB.h>
0005 
0006 EcalFenixStripFormatEB::EcalFenixStripFormatEB() : shift_(0) {}
0007 
0008 EcalFenixStripFormatEB::~EcalFenixStripFormatEB() {}
0009 
0010 int EcalFenixStripFormatEB::setInput(
0011     int input_even, int inputEvenPeak, int input_odd, int inputOddPeak, int inputsFGVB) {
0012   inputsFGVB_ = inputsFGVB;
0013   inputEvenPeak_ = inputEvenPeak;
0014   input_even_ = input_even;
0015   inputOddPeak_ = inputOddPeak;
0016   input_odd_ = input_odd;
0017   return 0;
0018 }
0019 
0020 int EcalFenixStripFormatEB::process() {
0021   int even_output = 0;
0022   int odd_output = 0;
0023 
0024   // Applying sliding window on the strip output after the peak finder
0025   if (ecaltpgTPMode_->DisableEBEvenPeakFinder) {
0026     even_output = input_even_ >> shift_;
0027   } else {
0028     if (inputEvenPeak_ == 1)
0029       even_output = input_even_ >> shift_;
0030   }
0031 
0032   if (ecaltpgTPMode_->EnableEBOddPeakFinder) {
0033     if (inputOddPeak_ == 1)
0034       odd_output = input_odd_ >> shift_;
0035   } else {
0036     odd_output = input_odd_ >> shift_;
0037   }
0038 
0039   // Truncating the signals to 12 bit after peak finder sliding window
0040   if (odd_output > 0XFFF)
0041     odd_output = 0XFFF;
0042   if (even_output > 0XFFF)
0043     even_output = 0XFFF;
0044 
0045   // Prepare the amplitude output for the strip looking at the TPmode options
0046   int output = 0;
0047   bool is_odd_larger = false;
0048   if (ecaltpgTPMode_->EnableEBOddFilter && odd_output > even_output)
0049     is_odd_larger =
0050         true;  // If running with odd filter enabled, check if odd output is larger regardless of strip formatter output mode
0051   switch (ecaltpgTPMode_->FenixEBStripOutput) {
0052     case 0:  // even filter out
0053       output = even_output;
0054       break;
0055     case 1:  // odd filter out
0056       if (ecaltpgTPMode_->EnableEBOddFilter)
0057         output = odd_output;
0058       else
0059         output = even_output;
0060       break;
0061     case 2:  // larger between odd and even
0062       if (ecaltpgTPMode_->EnableEBOddFilter && odd_output > even_output) {
0063         output = odd_output;
0064       } else
0065         output = even_output;
0066       break;
0067     case 3:  // even + odd
0068       if (ecaltpgTPMode_->EnableEBOddFilter)
0069         output = even_output + odd_output;
0070       else
0071         output = even_output;
0072       break;
0073   }
0074 
0075   if (output > 0XFFF)
0076     output = 0XFFF;  // ok: barrel saturates at 12 bits
0077 
0078   // Info bits
0079   // bit12 is sFGVB, bit13 is for odd>even flagging
0080   output |= ((inputsFGVB_ & 0x1) << 12);
0081 
0082   // if the flagging mode is OFF the bit stays 0, since it is not used for other things
0083   if (ecaltpgTPMode_->EnableEBOddFilter && ecaltpgTPMode_->FenixEBStripInfobit2) {
0084     output |= ((is_odd_larger & 0x1) << 13);
0085   }
0086 
0087   return output;
0088 }
0089 
0090 void EcalFenixStripFormatEB::process(std::vector<int> &sFGVBout,
0091                                      std::vector<int> &peakout_even,
0092                                      std::vector<int> &filtout_even,
0093                                      std::vector<int> &peakout_odd,
0094                                      std::vector<int> &filtout_odd,
0095                                      std::vector<int> &output) {
0096   if (peakout_even.size() != filtout_even.size() || sFGVBout.size() != filtout_even.size() ||
0097       peakout_odd.size() != filtout_odd.size() || filtout_odd.size() != filtout_even.size()) {
0098     edm::LogWarning("EcalTPG") << " problem in EcalFenixStripFormatEB: sfgvb_out, peak_out and "
0099                                   "filt_out don't have the same size";
0100   }
0101   for (unsigned int i = 0; i < filtout_even.size(); i++) {
0102     setInput(filtout_even[i], peakout_even[i], filtout_odd[i], peakout_odd[i], sFGVBout[i]);
0103     output[i] = process();
0104   }
0105   return;
0106 }
0107 
0108 void EcalFenixStripFormatEB::setParameters(uint32_t &id,
0109                                            const EcalTPGSlidingWindow *&slWin,
0110                                            const EcalTPGTPMode *ecaltptTPMode) {
0111   // TP mode contains options for the formatter (odd/even filters config)
0112   ecaltpgTPMode_ = ecaltptTPMode;
0113   const EcalTPGSlidingWindowMap &slwinmap = slWin->getMap();
0114   EcalTPGSlidingWindowMapIterator it = slwinmap.find(id);
0115   if (it != slwinmap.end())
0116     shift_ = (*it).second;
0117   else
0118     edm::LogWarning("EcalTPG") << " could not find EcalTPGSlidingWindowMap entry for " << id;
0119 }