Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:16

0001 #include "DataFormats/EcalDigi/interface/EcalEBTriggerPrimitiveDigi.h"
0002 #include <iostream>
0003 
0004 EcalEBTriggerPrimitiveDigi::EcalEBTriggerPrimitiveDigi() : size_(0), data_(MAXSAMPLES) {}
0005 //EcalTriggerPrimitiveDigi::EcalTriggerPrimitiveDigi(const EcalTrigTowerDetId& id) : id_(id),
0006 //size_(0), data_(MAXSAMPLES) {
0007 //}
0008 
0009 EcalEBTriggerPrimitiveDigi::EcalEBTriggerPrimitiveDigi(const EBDetId& id) : id_(id), size_(0), data_(MAXSAMPLES) {}
0010 
0011 void EcalEBTriggerPrimitiveDigi::setSample(int i, const EcalEBTriggerPrimitiveSample& sam) {
0012   //  std::cout << " In setSample  i " << i << "  sam " << sam << std::endl;
0013   data_[i] = sam;
0014   //  std::cout << " In setSample data_[i] " << data_[i] << std::endl;
0015 }
0016 
0017 int EcalEBTriggerPrimitiveDigi::sampleOfInterest() const {
0018   if (size_ == 1)
0019     return 0;
0020   else if (size_ == 5)
0021     return 2;
0022   else
0023     return -1;
0024 }
0025 
0026 /// get the encoded/compressed Et of interesting sample
0027 int EcalEBTriggerPrimitiveDigi::encodedEt() const {
0028   int sample = sampleOfInterest();
0029   if (sample != -1)
0030     return data_[sample].encodedEt();
0031   else
0032     return -1;
0033 }
0034 
0035 bool EcalEBTriggerPrimitiveDigi::l1aSpike() const {
0036   int sample = sampleOfInterest();
0037   if (sample != -1)
0038     return data_[sample].l1aSpike();
0039   else
0040     return -1;
0041 }
0042 
0043 int EcalEBTriggerPrimitiveDigi::time() const {
0044   int sample = sampleOfInterest();
0045   if (sample != -1)
0046     return data_[sample].time();
0047   else
0048     return -1;
0049 }
0050 
0051 bool EcalEBTriggerPrimitiveDigi::isDebug() const {
0052   if (size_ == 1)
0053     return false;
0054   else if (size_ > 1)
0055     return true;
0056   return false;
0057 }
0058 
0059 void EcalEBTriggerPrimitiveDigi::setSize(int size) {
0060   if (size < 0)
0061     size_ = 0;
0062   else if (size > MAXSAMPLES)
0063     size_ = MAXSAMPLES;
0064   else
0065     size_ = size;
0066 }
0067 
0068 std::ostream& operator<<(std::ostream& s, const EcalEBTriggerPrimitiveDigi& digi) {
0069   s << digi.id() << " " << digi.size() << " samples " << std::endl;
0070   for (int i = 0; i < digi.size(); i++)
0071     s << "  " << digi.sample(i) << std::endl;
0072   return s;
0073 }