CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/DataFormats/HcalDigi/src/HcalUpgradeDataFrame.cc

Go to the documentation of this file.
00001 #include "DataFormats/HcalDigi/interface/HcalUpgradeDataFrame.h"
00002 #include "DataFormats/HcalDigi/interface/HcalUpgradeQIESample.h"
00003 
00004 HcalUpgradeDataFrame::HcalUpgradeDataFrame() : id_(0), 
00005                                      capId_(0),
00006                                      size_(0),
00007                                      presamples_(0)
00008 {
00009 }
00010 
00011 HcalUpgradeDataFrame::HcalUpgradeDataFrame(HcalDetId id) : id_(id),
00012                                                            capId_(0),
00013                                                            size_(0),
00014                                                            presamples_(0) 
00015 {
00016 }
00017 
00018 HcalUpgradeDataFrame::HcalUpgradeDataFrame(HcalDetId id, int capId, int samples, int presamples) 
00019 : id_(id),
00020   capId_(capId)
00021 {
00022     setSize(samples) ;
00023     setPresamples(presamples) ;
00024 }
00025 
00026 void HcalUpgradeDataFrame::setSize(int size) {
00027   if (size>MAXSAMPLES) size_=MAXSAMPLES;
00028   else if (size<=0) size_=0;
00029   else size_=size;
00030 }
00031 
00032 void HcalUpgradeDataFrame::setPresamples(int presamples) {
00033   if (presamples>MAXSAMPLES) presamples_=MAXSAMPLES;
00034   else if (presamples<=0) presamples_=0;
00035   else presamples_=presamples;
00036 }
00037 
00038 HcalUpgradeQIESample HcalUpgradeDataFrame::operator[](int i) const {
00039   return HcalUpgradeQIESample(adc(i), (capId_+i)%4, 0, 0);
00040 }
00041 
00042 void HcalUpgradeDataFrame::setSample(int iSample,
00043                                 uint16_t adc,
00044                                 uint16_t tdc,
00045                                 bool dv) { 
00046 
00047     if ( iSample < MAXSAMPLES && iSample>=0) { 
00048         adc_[iSample] = adc&0xFF ; 
00049         tdc_[iSample] = tdc&0xFFFF ; 
00050         dv_[iSample] = dv ; 
00051     }    
00052 }
00053 
00054 
00055 std::ostream& operator<<(std::ostream& s, const HcalUpgradeDataFrame& digi) {
00056     s << digi.id() << " " << digi.size() << " samples  " << digi.presamples() << " presamples \n";
00057     for (int i=0; i<digi.size(); i++) {
00058         if ( i < digi.presamples() ) s << " (PRE) " ;
00059         else s << "       " ;
00060         s << int(digi.capId(i)) << " (capId)  ";
00061         s << int(digi.adc(i)) << " (adc)  " ;
00062         s << int(digi.tdc(i)) << " (tdc)  " ;
00063         if ( digi.valid(i) ) s << " (DV) " ; 
00064         s << std::endl ;
00065     }
00066     return s;
00067 }
00068   
00069