Go to the documentation of this file.00001
00007 #include <assert.h>
00008 #include "CondFormats/EcalObjects/interface/EcalSampleMask.h"
00009 #include "DataFormats/EcalDigi/interface/EcalDataFrame.h"
00010
00011 EcalSampleMask::EcalSampleMask()
00012 {
00013
00014 sampleMaskEB_=pow(2, EcalDataFrame::MAXSAMPLES)-1;
00015 sampleMaskEB_=pow(2, EcalDataFrame::MAXSAMPLES)-1;
00016 }
00017
00018
00019 EcalSampleMask::EcalSampleMask(const unsigned int ebmask, const unsigned int eemask) {
00020 sampleMaskEB_ = ebmask;
00021 sampleMaskEE_ = eemask;
00022 }
00023
00024
00025 EcalSampleMask::EcalSampleMask( const std::vector<unsigned int> &ebmask, const std::vector<unsigned int> &eemask) {
00026 setEcalSampleMaskRecordEB( ebmask );
00027 setEcalSampleMaskRecordEB( eemask );
00028 }
00029
00030
00031 EcalSampleMask::~EcalSampleMask() {
00032
00033 }
00034
00035
00036 void EcalSampleMask::setEcalSampleMaskRecordEB( const std::vector<unsigned int> & ebmask ) {
00037
00038
00039 if( ebmask.size() != static_cast<unsigned int>(EcalDataFrame::MAXSAMPLES) ){
00040 std::cout << " in EcalSampleMask::setEcalSampleMaskRecordEB size of ebmask (" << ebmask.size() << ") need to be: " << EcalDataFrame::MAXSAMPLES
00041 << ". Bailing out."<< std::endl;
00042 assert(0);
00043 }
00044
00045
00046 for (unsigned int s=0; s<ebmask.size(); s++ ) {
00047 if ( ebmask.at(s)==0 || ebmask.at(s)==1 ) {;}
00048 else {
00049 std::cout << "in EcalSampleMask::setEcalSampleMaskRecordEB ebmask can only have values 0 or 1, while " << ebmask.at(s) << " was found. Bailing out. " << std::endl;
00050 assert(0);
00051 }
00052 }
00053
00054
00055
00056
00057 sampleMaskEB_=0;
00058 for (unsigned int sampleId=0; sampleId<ebmask.size(); sampleId++ ) {
00059 sampleMaskEB_ |= (0x1 << (EcalDataFrame::MAXSAMPLES -(sampleId+1) ));
00060 }
00061
00062 }
00063
00064 void EcalSampleMask::setEcalSampleMaskRecordEE( const std::vector<unsigned int> & eemask ) {
00065
00066
00067 if( eemask.size() != static_cast<unsigned int>(EcalDataFrame::MAXSAMPLES) ){
00068 std::cout << " in EcalSampleMask::setEcalSampleMaskRecordEE size of eemask (" << eemask.size() << ") need to be: " << EcalDataFrame::MAXSAMPLES
00069 << ". Bailing out."<< std::endl;
00070 assert(0);
00071 }
00072
00073
00074 for (unsigned int s=0; s<eemask.size(); s++ ) {
00075 if ( eemask.at(s)==0 || eemask.at(s)==1 ) {;}
00076 else {
00077 std::cout << "in EcalSampleMask::setEcalSampleMaskRecordEE eemask can only have values 0 or 1, while " << eemask.at(s) << " was found. Bailing out. " << std::endl;
00078 assert(0);
00079 }
00080 }
00081
00082
00083
00084
00085 sampleMaskEE_=0;
00086 for (unsigned int sampleId=0; sampleId<eemask.size(); sampleId++ ) {
00087 sampleMaskEE_ |= (0x1 << (EcalDataFrame::MAXSAMPLES -(sampleId+1) ));
00088 }
00089
00090 }
00091
00092
00093 bool EcalSampleMask::useSampleEB (const int sampleId) const {
00094
00095 if( sampleId >= EcalDataFrame::MAXSAMPLES ){
00096 std::cout << "in EcalSampleMask::useSampleEB only sampleId up to: " << EcalDataFrame::MAXSAMPLES
00097 << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
00098 assert(0);
00099 }
00100
00101
00102
00103
00104 return ( sampleMaskEB_ & ( 0x1<< (EcalDataFrame::MAXSAMPLES -(sampleId+1) )) );
00105
00106 }
00107
00108
00109 bool EcalSampleMask::useSampleEE (const int sampleId) const {
00110
00111 if( sampleId >= EcalDataFrame::MAXSAMPLES ){
00112 std::cout << "in EcalSampleMask::useSampleEE only sampleId up to: " << EcalDataFrame::MAXSAMPLES
00113 << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
00114 assert(0);
00115 }
00116
00117
00118
00119
00120 return ( sampleMaskEE_ & ( 0x1<< (EcalDataFrame::MAXSAMPLES -(sampleId+1) )) );
00121
00122 }
00123
00124
00125 bool EcalSampleMask::useSample (const int sampleId, DetId &theCrystalId) const {
00126
00127 if( sampleId >= EcalDataFrame::MAXSAMPLES ){
00128 std::cout << "in EcalSampleMask::useSample only sampleId up to: " << EcalDataFrame::MAXSAMPLES
00129 << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
00130 assert(0);
00131 }
00132
00133
00134 if (theCrystalId.subdetId()==EcalBarrel) {
00135 return useSampleEB ( sampleId );
00136 }
00137 else if (theCrystalId.subdetId()==EcalEndcap) {
00138 return useSampleEE ( sampleId );
00139 }
00140 else {
00141 std::cout << "EcalSampleMaskuseSample::useSample can only be called for EcalBarrel or EcalEndcap DetID" << std::endl;
00142 assert(0);
00143 }
00144
00145 }
00146
00147