CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
EcalSampleMask Class Reference

#include <EcalSampleMask.h>

Public Member Functions

 EcalSampleMask ()
 
 EcalSampleMask (const unsigned int ebmask, const unsigned int eemask)
 
 EcalSampleMask (const std::vector< unsigned int > &ebmask, const std::vector< unsigned int > &eemask)
 
float getEcalSampleMaskRecordEB () const
 
float getEcalSampleMaskRecordEE () const
 
void print (std::ostream &s) const
 
void setEcalSampleMaskRecordEB (const unsigned int mask)
 
void setEcalSampleMaskRecordEB (const std::vector< unsigned int > &ebmask)
 
void setEcalSampleMaskRecordEE (const unsigned int mask)
 
void setEcalSampleMaskRecordEE (const std::vector< unsigned int > &eemask)
 
bool useSample (const int sampleId, DetId &theCrystal) const
 
bool useSampleEB (const int sampleId) const
 
bool useSampleEE (const int sampleId) const
 
 ~EcalSampleMask ()
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

unsigned int sampleMaskEB_
 
unsigned int sampleMaskEE_
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Author: Giovanni Franzoni, UMN Created: 09 Apr 2012

Id
EcalSampleMask.h,v 1.1 2012/05/10 08:22:10 argiro Exp

Definition at line 16 of file EcalSampleMask.h.

Constructor & Destructor Documentation

EcalSampleMask::EcalSampleMask ( )

Definition at line 15 of file EcalSampleMask.cc.

References EcalDataFrame::MAXSAMPLES, funct::pow(), sampleMaskEB_, and sampleMaskEE_.

16 {
17  // by default, all samples are set as active
20 }
unsigned int sampleMaskEB_
unsigned int sampleMaskEE_
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
EcalSampleMask::EcalSampleMask ( const unsigned int  ebmask,
const unsigned int  eemask 
)

Definition at line 23 of file EcalSampleMask.cc.

References sampleMaskEB_, and sampleMaskEE_.

23  {
24  sampleMaskEB_ = ebmask;
25  sampleMaskEE_ = eemask;
26 }
unsigned int sampleMaskEB_
unsigned int sampleMaskEE_
EcalSampleMask::EcalSampleMask ( const std::vector< unsigned int > &  ebmask,
const std::vector< unsigned int > &  eemask 
)

Definition at line 29 of file EcalSampleMask.cc.

References setEcalSampleMaskRecordEB(), and setEcalSampleMaskRecordEE().

29  {
30  setEcalSampleMaskRecordEB( ebmask );
31  setEcalSampleMaskRecordEE( eemask );
32 }
void setEcalSampleMaskRecordEE(const unsigned int mask)
void setEcalSampleMaskRecordEB(const unsigned int mask)
EcalSampleMask::~EcalSampleMask ( )

Definition at line 35 of file EcalSampleMask.cc.

35  {
36 
37 }

Member Function Documentation

float EcalSampleMask::getEcalSampleMaskRecordEB ( ) const
inline

Definition at line 32 of file EcalSampleMask.h.

References sampleMaskEB_.

Referenced by EcalTrivialObjectAnalyzer::analyze().

32 { return sampleMaskEB_; }
unsigned int sampleMaskEB_
float EcalSampleMask::getEcalSampleMaskRecordEE ( ) const
inline

Definition at line 33 of file EcalSampleMask.h.

References sampleMaskEE_.

Referenced by EcalTrivialObjectAnalyzer::analyze().

33 { return sampleMaskEE_; }
unsigned int sampleMaskEE_
void EcalSampleMask::print ( std::ostream &  s) const
inline

Definition at line 34 of file EcalSampleMask.h.

References sampleMaskEB_, sampleMaskEE_, useSample(), useSampleEB(), and useSampleEE().

34  {
35  s << "EcalSampleMask: EB " << sampleMaskEB_ << "; EE " << sampleMaskEE_ ;
36  }
unsigned int sampleMaskEB_
unsigned int sampleMaskEE_
template<class Archive >
void EcalSampleMask::serialize ( Archive &  ar,
const unsigned int  version 
)
private
void EcalSampleMask::setEcalSampleMaskRecordEB ( const unsigned int  mask)
inline
void EcalSampleMask::setEcalSampleMaskRecordEB ( const std::vector< unsigned int > &  ebmask)

Definition at line 40 of file EcalSampleMask.cc.

References EcalDataFrame::MAXSAMPLES, alignCSCRings::s, and sampleMaskEB_.

40  {
41 
42  // check that size of the vector is adequate
43  if( ebmask.size() != static_cast<unsigned int>(EcalDataFrame::MAXSAMPLES) ){
44  LogError("DataMismatch")<< " in EcalSampleMask::setEcalSampleMaskRecordEB size of ebmask (" << ebmask.size() << ") need to be: " << EcalDataFrame::MAXSAMPLES
45  << ". Bailing out."<< std::endl;
46  assert(0);
47  }
48 
49  // check that values of vector are allowed
50  for (unsigned int s=0; s<ebmask.size(); s++ ) {
51  if ( ebmask.at(s)==0 || ebmask.at(s)==1 ) {;}
52  else {
53  LogError("DataMismatch")<< "in EcalSampleMask::setEcalSampleMaskRecordEB ebmask can only have values 0 or 1, while " << ebmask.at(s) << " was found. Bailing out. " << std::endl;
54  assert(0);
55  }
56  }
57 
58  // ordering of bits:
59  // ebmask.at(0) refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEB_
60  // ebmask.at(EcalDataFrame::MAXSAMPLES) refers to the last sample read out and is mapped into the _least_ significant bit of sampleMaskEB_
61  sampleMaskEB_=0;
62  for (unsigned int sampleId=0; sampleId<ebmask.size(); sampleId++ ) {
63  sampleMaskEB_ |= (0x1 << (EcalDataFrame::MAXSAMPLES -(sampleId+1) ));
64  }
65 
66 }
unsigned int sampleMaskEB_
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
void EcalSampleMask::setEcalSampleMaskRecordEE ( const unsigned int  mask)
inline
void EcalSampleMask::setEcalSampleMaskRecordEE ( const std::vector< unsigned int > &  eemask)

Definition at line 68 of file EcalSampleMask.cc.

References EcalDataFrame::MAXSAMPLES, alignCSCRings::s, and sampleMaskEE_.

68  {
69 
70  // check that size of the vector is adequate
71  if( eemask.size() != static_cast<unsigned int>(EcalDataFrame::MAXSAMPLES) ){
72  LogError("DataMismatch") << " in EcalSampleMask::setEcalSampleMaskRecordEE size of eemask (" << eemask.size() << ") need to be: " << EcalDataFrame::MAXSAMPLES
73  << ". Bailing out."<< std::endl;
74  assert(0);
75  }
76 
77  // check that values of vector are allowed
78  for (unsigned int s=0; s<eemask.size(); s++ ) {
79  if ( eemask.at(s)==0 || eemask.at(s)==1 ) {;}
80  else {
81  LogError("DataMismatch") << "in EcalSampleMask::setEcalSampleMaskRecordEE eemask can only have values 0 or 1, while " << eemask.at(s) << " was found. Bailing out. " << std::endl;
82  assert(0);
83  }
84  }
85 
86  // ordering of bits:
87  // eemask.at(0) refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEE_
88  // eemask.at(EcalDataFrame::MAXSAMPLES) refers to the last sample read out and is mapped into the _least_ significant bit of sampleMaskEE_
89  sampleMaskEE_=0;
90  for (unsigned int sampleId=0; sampleId<eemask.size(); sampleId++ ) {
91  sampleMaskEE_ |= (0x1 << (EcalDataFrame::MAXSAMPLES -(sampleId+1) ));
92  }
93 
94 }
unsigned int sampleMaskEE_
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
bool EcalSampleMask::useSample ( const int  sampleId,
DetId theCrystal 
) const

Definition at line 129 of file EcalSampleMask.cc.

References EcalBarrel, EcalEndcap, EcalDataFrame::MAXSAMPLES, DetId::subdetId(), useSampleEB(), and useSampleEE().

Referenced by print().

129  {
130 
131  if( sampleId >= EcalDataFrame::MAXSAMPLES ){
132  LogError("DataMismatch")<< "in EcalSampleMask::useSample only sampleId up to: " << EcalDataFrame::MAXSAMPLES
133  << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
134  assert(0);
135  }
136 
137 
138  if (theCrystalId.subdetId()==EcalBarrel) {
139  return useSampleEB ( sampleId );
140  }
141  else if (theCrystalId.subdetId()==EcalEndcap) {
142  return useSampleEE ( sampleId );
143  }
144  else {
145  LogError("DataMismatch")<< "EcalSampleMaskuseSample::useSample can only be called for EcalBarrel or EcalEndcap DetID" << std::endl;
146  assert(0);
147  }
148 
149 }
bool useSampleEB(const int sampleId) const
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
bool useSampleEE(const int sampleId) const
bool EcalSampleMask::useSampleEB ( const int  sampleId) const

Definition at line 97 of file EcalSampleMask.cc.

References EcalDataFrame::MAXSAMPLES, sampleMaskEB_, and globals_cff::x1.

Referenced by print(), and useSample().

97  {
98 
99  if( sampleId >= EcalDataFrame::MAXSAMPLES ){
100  LogError("DataMismatch")<< "in EcalSampleMask::useSampleEB only sampleId up to: " << EcalDataFrame::MAXSAMPLES
101  << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
102  assert(0);
103  }
104 
105  // ordering convention:
106  // ebmask.at(0) refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEB_
107  // ebmask.at(EcalDataFrame::MAXSAMPLES) refers to the last sample read out and is mapped into the _least_ significant bit of sampleMaskEB_
108  return ( sampleMaskEB_ & ( 0x1<< (EcalDataFrame::MAXSAMPLES -(sampleId+1) )) );
109 
110 }
unsigned int sampleMaskEB_
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
bool EcalSampleMask::useSampleEE ( const int  sampleId) const

Definition at line 113 of file EcalSampleMask.cc.

References EcalDataFrame::MAXSAMPLES, sampleMaskEE_, and globals_cff::x1.

Referenced by print(), and useSample().

113  {
114 
115  if( sampleId >= EcalDataFrame::MAXSAMPLES ){
116  LogError("DataMismatch")<< "in EcalSampleMask::useSampleEE only sampleId up to: " << EcalDataFrame::MAXSAMPLES
117  << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
118  assert(0);
119  }
120 
121  // ordering convention:
122  // ebmask.at(0) refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEB_
123  // ebmask.at(EcalDataFrame::MAXSAMPLES) refers to the last sample read out and is mapped into the _least_ significant bit of sampleMaskEB_
124  return ( sampleMaskEE_ & ( 0x1<< (EcalDataFrame::MAXSAMPLES -(sampleId+1) )) );
125 
126 }
unsigned int sampleMaskEE_
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 47 of file EcalSampleMask.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 47 of file EcalSampleMask.h.

Member Data Documentation

unsigned int EcalSampleMask::sampleMaskEB_
private
unsigned int EcalSampleMask::sampleMaskEE_
private