CMS 3D CMS Logo

Public Member Functions | Static Public Attributes | Private Attributes

ChannelPattern Class Reference

#include <HtrXmlPatternSet.h>

List of all members.

Public Member Functions

 ChannelPattern ()
void encode ()
void Fill (HtrXmlPatternToolParameters *params, HBHEDigiCollection::const_iterator data)
void Fill (HtrXmlPatternToolParameters *params, HFDigiCollection::const_iterator data)
void Fill (HtrXmlPatternToolParameters *params, HODigiCollection::const_iterator data)
void Fill_by_hand (const HcalElectronicsMap *, int)
int getChan () const
int getCoded (int bc) const
int getCrate () const
double getQuantized (int bc) const
int getSlot () const
int getTB () const
double & operator[] (int bc)
const double operator[] (int bc) const
void setLoc (int crate, int slot, int tb, int chan)

Static Public Attributes

static const int NUM_CRATES = 18
static const int NUM_SLOTS = 22
static const int SAMPLES = 512

Private Attributes

int fCCoded [SAMPLES]
double fCQuantized [SAMPLES]
double fCReal [SAMPLES]
int m_chan
int m_crate
int m_sample_pos
int m_slot
int m_tb

Detailed Description

Definition at line 8 of file HtrXmlPatternSet.h.


Constructor & Destructor Documentation

ChannelPattern::ChannelPattern ( )

Definition at line 5 of file HtrXmlPatternSet.cc.

References fCCoded, fCQuantized, fCReal, i, m_sample_pos, and SAMPLES.

                               {
  for (int i=0; i<SAMPLES; i++) {
    fCReal[i]=0;
    fCCoded[i]=0;
    fCQuantized[i]=0;
  }
  m_sample_pos=0;
}

Member Function Documentation

void ChannelPattern::encode ( )
void ChannelPattern::Fill ( HtrXmlPatternToolParameters params,
HBHEDigiCollection::const_iterator  data 
)

Definition at line 123 of file HtrXmlPatternSet.cc.

References fCCoded, fCQuantized, getHLTprescales::index, HtrXmlPatternToolParameters::m_presamples_per_event, m_sample_pos, HtrXmlPatternToolParameters::m_samples_per_event, and SAMPLES.

Referenced by HtrXmlPatternTool::Fill().

                                                                                                   {
  //first fill with pedestal value (currently hard-coded to 0)
  for (int samples=0; samples<params->m_samples_per_event; samples++) {
    int index = m_sample_pos + samples;
    if (index>=SAMPLES) continue;

    fCCoded    [index] = 0;
    fCQuantized[index] = 0;
  }

  //now fill with actual samples
  for (int samples=0; samples<data->size(); samples++) {
    int index = m_sample_pos + params->m_presamples_per_event - data->presamples() + samples;
    if (index<m_sample_pos || 
        index>=(m_sample_pos+params->m_samples_per_event) ||
        index>=SAMPLES) continue;

    fCCoded    [index] = data->sample(samples).adc();
    fCQuantized[index] = data->sample(samples).nominal_fC();
  }
  
  m_sample_pos+=params->m_samples_per_event;
}
void ChannelPattern::Fill ( HtrXmlPatternToolParameters params,
HFDigiCollection::const_iterator  data 
)
void ChannelPattern::Fill ( HtrXmlPatternToolParameters params,
HODigiCollection::const_iterator  data 
)
void ChannelPattern::Fill_by_hand ( const HcalElectronicsMap emap,
int  pattern_number 
)

Definition at line 14 of file HtrXmlPatternSet.cc.

References gather_cfg::cout, HcalDetId::depth(), fCCoded, fCQuantized, i, HcalDetId::ietaAbs(), HcalDetId::iphi(), j, HcalElectronicsMap::lookup(), m_chan, m_crate, m_slot, m_tb, NUM_CRATES, phi, SAMPLES, HcalElectronicsId::setHTR(), HcalDetId::subdet(), and HcalDetId::zside().

Referenced by HtrXmlPattern::do_hand_fill().

                                                                                   {

  for (int iSample=0;iSample<SAMPLES;iSample++) {
    fCCoded    [iSample]=0;
    fCQuantized[iSample]=0;
  }

  int dcc9[NUM_CRATES];
  int dcc19[NUM_CRATES];
  for (int jCrate=0;jCrate<NUM_CRATES;jCrate++) {
    dcc9[jCrate]=-1;
    dcc19[jCrate]=-1;
  }

  int iCrate;
  iCrate=4 ; dcc9[iCrate]=700; dcc19[iCrate]=701;
  iCrate=0 ; dcc9[iCrate]=702; dcc19[iCrate]=703;
  iCrate=1 ; dcc9[iCrate]=704; dcc19[iCrate]=705;
  iCrate=5 ; dcc9[iCrate]=706; dcc19[iCrate]=707;
  iCrate=11; dcc9[iCrate]=708; dcc19[iCrate]=709;
  iCrate=15; dcc9[iCrate]=710; dcc19[iCrate]=711;
  iCrate=17; dcc9[iCrate]=712; dcc19[iCrate]=713;
  iCrate=14; dcc9[iCrate]=714; dcc19[iCrate]=715;
  iCrate=10; dcc9[iCrate]=716; dcc19[iCrate]=717;
  iCrate=2 ; dcc9[iCrate]=718; dcc19[iCrate]=719;
  iCrate=9 ; dcc9[iCrate]=720; dcc19[iCrate]=721;
  iCrate=12; dcc9[iCrate]=722; dcc19[iCrate]=723;
  iCrate=3 ; dcc9[iCrate]=724; dcc19[iCrate]=725;
  iCrate=7 ; dcc9[iCrate]=726; dcc19[iCrate]=727;
  iCrate=6 ; dcc9[iCrate]=728; dcc19[iCrate]=729;
  iCrate=13; dcc9[iCrate]=730; dcc19[iCrate]=731;

  int *dcc=0;
  int spigot=-100;
  if (m_slot>=2 && m_slot<=8) {
    spigot=2*m_slot-m_tb-3;
    dcc=dcc9;
  }
  else if (m_slot>=13 && m_slot<=18) {
    spigot=2*m_slot-m_tb-25;
    dcc=dcc19;
  }
  else return;

  int fiber_channel=(m_chan-1)%3;
  int fiber=(m_chan-fiber_channel-1)/3 +1;
  int dcc_num=dcc[m_crate]-700;

  HcalElectronicsId heid(fiber_channel,fiber,spigot,dcc_num);
  heid.setHTR(m_crate,m_slot,m_tb);

  //if (heid.readoutVMECrateId()!=m_crate) std::cout << "crate: " << heid.readoutVMECrateId() << "; " << m_crate << std::endl;
  //if (heid.htrSlot()!=m_slot) std::cout << "slot:  " << heid.htrSlot() << "; " << m_slot << std::endl;
  //if (heid.htrTopBottom()!=m_tb) std::cout << "tb:    " << heid.htrTopBottom() << "; " << m_tb << std::endl;
  //if (heid.htrChanId()!=m_chan) std::cout << "chan:  " << heid.htrChanId() << "; " << m_chan << std::endl;
  //
  //if (heid.readoutVMECrateId()==14 && heid.htrTopBottom()==0 && heid.htrChanId()==3) {
  //  std::cout << heid.rawId() << " " << heid << std::endl;
  //}

  try {
    const HcalDetId hdid=emap->lookup(heid);

    int etaabs=hdid.ietaAbs();
    int phi=hdid.iphi();
    int side=hdid.zside();
    int depth=hdid.depth();
    int subdet=hdid.subdet();

    if (pattern_number==1) {
      if (m_crate==2 || m_crate==9 || m_crate==12) return;
      //fill only one channel per half-crate
      if (m_slot!=2 && m_slot!=13) return;
      if (m_tb!=0) return;
      if (m_chan!=5) return;
  
      //put some data here
      fCCoded[31]=17;
    }
    if (pattern_number==2) {
      if (depth>1) return;
      if (subdet==4 && etaabs<30) return;
      
      if ((etaabs+2)%4!=0) return;
      int i=(etaabs+2)/4;
      if (i<1 || i>7) return;
      
      if ((phi+3)%4!=0) return;
      int j=(phi+3)/4;
      if (j<1 || j>18) return;
      
      //add one to BX?
      if (side<0) fCCoded[phi+10]=i;
      if (side>0) fCCoded[phi+10]=i+16;
    }
    if (pattern_number==3) {
      if (depth>1 || etaabs!=18 || side!=1 || phi!=32) return;
      std::cout << "hello" << std::endl;
      //add one to BX?
      if (side>0) fCCoded[15]=20;
    }
    
  }
  catch (...) {return;}
}
int ChannelPattern::getChan ( ) const [inline]

Definition at line 20 of file HtrXmlPatternSet.h.

References m_chan.

{ return m_chan; }
int ChannelPattern::getCoded ( int  bc) const [inline]

Definition at line 24 of file HtrXmlPatternSet.h.

References fCCoded.

Referenced by HtrXmlPatternTool::createHists(), and HtrXmlPatternWriter::writePattern().

{ return fCCoded[bc]; }
int ChannelPattern::getCrate ( ) const [inline]

Definition at line 17 of file HtrXmlPatternSet.h.

References m_crate.

{ return m_crate; }
double ChannelPattern::getQuantized ( int  bc) const [inline]

Definition at line 25 of file HtrXmlPatternSet.h.

References fCQuantized.

Referenced by HtrXmlPatternTool::createHists().

{ return fCQuantized[bc]; }
int ChannelPattern::getSlot ( ) const [inline]

Definition at line 18 of file HtrXmlPatternSet.h.

References m_slot.

{ return m_slot; }
int ChannelPattern::getTB ( ) const [inline]

Definition at line 19 of file HtrXmlPatternSet.h.

References m_tb.

{ return m_tb; }
double& ChannelPattern::operator[] ( int  bc) [inline]

Definition at line 21 of file HtrXmlPatternSet.h.

References fCReal.

{ return fCReal[bc]; }
const double ChannelPattern::operator[] ( int  bc) const [inline]

Definition at line 22 of file HtrXmlPatternSet.h.

References fCReal.

{ return fCReal[bc]; }
void ChannelPattern::setLoc ( int  crate,
int  slot,
int  tb,
int  chan 
) [inline]

Definition at line 16 of file HtrXmlPatternSet.h.

References m_chan, m_crate, m_slot, and m_tb.

{ m_crate=crate; m_slot=slot; m_tb=tb; m_chan=chan; }

Member Data Documentation

Definition at line 33 of file HtrXmlPatternSet.h.

Referenced by ChannelPattern(), Fill(), Fill_by_hand(), and getCoded().

Definition at line 32 of file HtrXmlPatternSet.h.

Referenced by ChannelPattern(), Fill(), Fill_by_hand(), and getQuantized().

double ChannelPattern::fCReal[SAMPLES] [private]

Definition at line 31 of file HtrXmlPatternSet.h.

Referenced by ChannelPattern(), and operator[]().

int ChannelPattern::m_chan [private]

Definition at line 34 of file HtrXmlPatternSet.h.

Referenced by Fill_by_hand(), getChan(), and setLoc().

int ChannelPattern::m_crate [private]

Definition at line 34 of file HtrXmlPatternSet.h.

Referenced by Fill_by_hand(), getCrate(), and setLoc().

Definition at line 35 of file HtrXmlPatternSet.h.

Referenced by ChannelPattern(), and Fill().

int ChannelPattern::m_slot [private]

Definition at line 34 of file HtrXmlPatternSet.h.

Referenced by Fill_by_hand(), getSlot(), and setLoc().

int ChannelPattern::m_tb [private]

Definition at line 34 of file HtrXmlPatternSet.h.

Referenced by Fill_by_hand(), getTB(), and setLoc().

const int ChannelPattern::NUM_CRATES = 18 [static]
const int ChannelPattern::NUM_SLOTS = 22 [static]
const int ChannelPattern::SAMPLES = 512 [static]