CMS 3D CMS Logo

Public Member Functions | Private Attributes

EcalSampleMask Class Reference

#include <EcalSampleMask.h>

List of all members.

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 std::vector< unsigned int > &eemask)
void setEcalSampleMaskRecordEE (const unsigned int mask)
bool useSample (const int sampleId, DetId &theCrystal) const
bool useSampleEB (const int sampleId) const
bool useSampleEE (const int sampleId) const
 ~EcalSampleMask ()

Private Attributes

unsigned int sampleMaskEB_
unsigned int sampleMaskEE_

Detailed Description

Author: Giovanni Franzoni, UMN Created: 09 Apr 2012

Id:
EcalSampleMask.h,v 1.2 2012/05/10 14:59:40 argiro Exp

Definition at line 14 of file EcalSampleMask.h.


Constructor & Destructor Documentation

EcalSampleMask::EcalSampleMask ( )

Author: Giovanni Franzoni, UMN Created: 08 May 2012

Id:
EcalSampleMask.cc,v 1.2 2012/05/10 14:59:38 argiro Exp

Definition at line 11 of file EcalSampleMask.cc.

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

{
  // by default, all samples are set as active
  sampleMaskEB_=pow(2, EcalDataFrame::MAXSAMPLES)-1;
  sampleMaskEB_=pow(2, EcalDataFrame::MAXSAMPLES)-1;
}
EcalSampleMask::EcalSampleMask ( const unsigned int  ebmask,
const unsigned int  eemask 
)

Definition at line 19 of file EcalSampleMask.cc.

References sampleMaskEB_, and sampleMaskEE_.

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

Definition at line 25 of file EcalSampleMask.cc.

References setEcalSampleMaskRecordEB().

EcalSampleMask::~EcalSampleMask ( )

Definition at line 31 of file EcalSampleMask.cc.

                                {

}

Member Function Documentation

float EcalSampleMask::getEcalSampleMaskRecordEB ( ) const [inline]

Definition at line 30 of file EcalSampleMask.h.

References sampleMaskEB_.

{ return sampleMaskEB_; }
float EcalSampleMask::getEcalSampleMaskRecordEE ( ) const [inline]

Definition at line 31 of file EcalSampleMask.h.

References sampleMaskEE_.

{ return sampleMaskEE_; }
void EcalSampleMask::print ( std::ostream &  s) const [inline]

Definition at line 32 of file EcalSampleMask.h.

References sampleMaskEB_, and sampleMaskEE_.

                                    {
      s << "EcalSampleMask: EB " << sampleMaskEB_ << "; EE " << sampleMaskEE_ ;
    }
void EcalSampleMask::setEcalSampleMaskRecordEB ( const unsigned int  mask) [inline]

Definition at line 25 of file EcalSampleMask.h.

References sampleMaskEB_.

Referenced by EcalSampleMask().

{ sampleMaskEB_ = mask; }
void EcalSampleMask::setEcalSampleMaskRecordEB ( const std::vector< unsigned int > &  ebmask)

Definition at line 36 of file EcalSampleMask.cc.

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

                                                                                       {
  
  // check that size of the vector is adequate 
  if( ebmask.size() != static_cast<unsigned int>(EcalDataFrame::MAXSAMPLES) ){
    std::cout << " in EcalSampleMask::setEcalSampleMaskRecordEB size of ebmask (" << ebmask.size() << ") need to be: " << EcalDataFrame::MAXSAMPLES 
              << ". Bailing out."<< std::endl;
    assert(0);
  }

  // check that values of vector are allowed
  for (unsigned int s=0; s<ebmask.size(); s++ ) {
    if    ( ebmask.at(s)==0 || ebmask.at(s)==1  ) {;}
    else {
      std::cout << "in EcalSampleMask::setEcalSampleMaskRecordEB ebmask can only have values 0 or 1, while " << ebmask.at(s) << " was found. Bailing out. " << std::endl;
      assert(0);
    }
  }
  
  // ordering of bits:
  // ebmask.at(0)                         refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEB_ 
  // ebmask.at(EcalDataFrame::MAXSAMPLES) refers to the last  sample read out and is mapped into the _least_ significant bit of sampleMaskEB_ 
  sampleMaskEB_=0;
  for (unsigned int sampleId=0; sampleId<ebmask.size(); sampleId++ ) {
    sampleMaskEB_ |= (0x1 << (EcalDataFrame::MAXSAMPLES -(sampleId+1) ));
  }

}
void EcalSampleMask::setEcalSampleMaskRecordEE ( const std::vector< unsigned int > &  eemask)

Definition at line 64 of file EcalSampleMask.cc.

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

                                                                                       {

  // check that size of the vector is adequate 
  if( eemask.size() != static_cast<unsigned int>(EcalDataFrame::MAXSAMPLES) ){
    std::cout << " in EcalSampleMask::setEcalSampleMaskRecordEE size of eemask (" << eemask.size() << ") need to be: " << EcalDataFrame::MAXSAMPLES 
              << ". Bailing out."<< std::endl;
    assert(0);
  }

  // check that values of vector are allowed
  for (unsigned int s=0; s<eemask.size(); s++ ) {
    if    ( eemask.at(s)==0 || eemask.at(s)==1  ) {;}
    else {
      std::cout << "in EcalSampleMask::setEcalSampleMaskRecordEE eemask can only have values 0 or 1, while " << eemask.at(s) << " was found. Bailing out. " << std::endl;
      assert(0);
    }
  }
  
  // ordering of bits:
  // eemask.at(0)                         refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEE_ 
  // eemask.at(EcalDataFrame::MAXSAMPLES) refers to the last  sample read out and is mapped into the _least_ significant bit of sampleMaskEE_ 
  sampleMaskEE_=0;
  for (unsigned int sampleId=0; sampleId<eemask.size(); sampleId++ ) {
    sampleMaskEE_ |= (0x1 << (EcalDataFrame::MAXSAMPLES -(sampleId+1) ));
  }

}
void EcalSampleMask::setEcalSampleMaskRecordEE ( const unsigned int  mask) [inline]

Definition at line 26 of file EcalSampleMask.h.

References sampleMaskEB_.

{ sampleMaskEB_ = mask; }
bool EcalSampleMask::useSample ( const int  sampleId,
DetId theCrystal 
) const

Definition at line 125 of file EcalSampleMask.cc.

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

                                                                              {
  
  if( sampleId >= EcalDataFrame::MAXSAMPLES ){
    std::cout << "in EcalSampleMask::useSample only sampleId up to: "  << EcalDataFrame::MAXSAMPLES 
              << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
    assert(0);
  }
  
  
  if       (theCrystalId.subdetId()==EcalBarrel) {
    return useSampleEB ( sampleId );
  }
  else if  (theCrystalId.subdetId()==EcalEndcap) {
    return useSampleEE ( sampleId );
  }
  else {
    std::cout << "EcalSampleMaskuseSample::useSample can only be called for EcalBarrel or EcalEndcap DetID" << std::endl; 
    assert(0);
  }
  
}
bool EcalSampleMask::useSampleEB ( const int  sampleId) const

Definition at line 93 of file EcalSampleMask.cc.

References gather_cfg::cout, EcalDataFrame::MAXSAMPLES, and sampleMaskEB_.

Referenced by useSample().

                                                          {
  
  if( sampleId >= EcalDataFrame::MAXSAMPLES ){
    std::cout << "in EcalSampleMask::useSampleEB only sampleId up to: "  << EcalDataFrame::MAXSAMPLES 
              << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
    assert(0);
  }
  
  // ordering convention:
  // ebmask.at(0)                         refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEB_ 
  // ebmask.at(EcalDataFrame::MAXSAMPLES) refers to the last  sample read out and is mapped into the _least_ significant bit of sampleMaskEB_ 
  return ( sampleMaskEB_ & ( 0x1<< (EcalDataFrame::MAXSAMPLES -(sampleId+1) )) );
  
}
bool EcalSampleMask::useSampleEE ( const int  sampleId) const

Definition at line 109 of file EcalSampleMask.cc.

References gather_cfg::cout, EcalDataFrame::MAXSAMPLES, and sampleMaskEE_.

Referenced by useSample().

                                                          {
  
  if( sampleId >= EcalDataFrame::MAXSAMPLES ){
    std::cout << "in EcalSampleMask::useSampleEE only sampleId up to: "  << EcalDataFrame::MAXSAMPLES 
              << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
    assert(0);
  }
  
  // ordering convention:
  // ebmask.at(0)                         refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEB_ 
  // ebmask.at(EcalDataFrame::MAXSAMPLES) refers to the last  sample read out and is mapped into the _least_ significant bit of sampleMaskEB_ 
  return ( sampleMaskEE_ & ( 0x1<< (EcalDataFrame::MAXSAMPLES -(sampleId+1) )) );
  
}

Member Data Documentation

unsigned int EcalSampleMask::sampleMaskEB_ [private]
unsigned int EcalSampleMask::sampleMaskEE_ [private]