CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

MEChannel Class Reference

#include <MEChannel.h>

List of all members.

Public Member Functions

MEChanneld (unsigned ii)
MEChannelgetAncestor (int ig)
MEChannelgetChannel (int ix, int iy)
MEChannelgetChannel (int ig, int ix, int iy)
MEChannelgetDaughter (int ix, int iy, int ig)
MEChannelgetDescendant (int ig, int ii)
MEChannelgetFirstDescendant (int ig)
bool getListOfAncestors (std::vector< MEChannel * > &)
bool getListOfChannels (std::vector< MEChannel * > &)
bool getListOfDescendants (std::vector< MEChannel * > &)
bool getListOfDescendants (int ig, std::vector< MEChannel * > &)
int id () const
int ig () const
int ix () const
int iy () const
MEChannelm ()
 MEChannel (int ix, int iy, int ii, MEChannel *mother)
unsigned n () const
TString oneLine (int ig)
TString oneLine ()
TString oneWord ()
TString oneWord (int ig)
void print (std::ostream &o, bool recursif=false) const
virtual ~MEChannel ()

Private Member Functions

MEChanneladdDaughter (int ix, int iy, int ii)

Private Attributes

std::vector< MEChannel * > _d
std::vector< int > _id
int _ig
int _ix
int _iy
MEChannel_m

Detailed Description

Definition at line 12 of file MEChannel.h.


Constructor & Destructor Documentation

MEChannel::MEChannel ( int  ix,
int  iy,
int  ii,
MEChannel mother 
)

Definition at line 12 of file MEChannel.cc.

References _id, _ig, _ix, _iy, _m, ix(), and iy().

Referenced by addDaughter().

  : _m(mother)
{
  if( _m==0 ) 
    {
      _ig=0;      
    }
  else 
    {
      _ig = _m->_ig+1;
    }
  _id.resize( _ig+1, -1 );
  for( int ii=0; ii<_ig; ii++ )
    {
      _id[ii] = _m->_id[ii];
    }
  _id[_ig] = id_;
  _ix = ix;
  _iy = iy;
}
MEChannel::~MEChannel ( ) [virtual]

Definition at line 33 of file MEChannel.cc.

References _d.

{
  for( unsigned ii=0; ii<_d.size(); ii++ )
    {
      delete _d[ii];
    }
}

Member Function Documentation

MEChannel * MEChannel::addDaughter ( int  ix,
int  iy,
int  ii 
) [private]

Definition at line 55 of file MEChannel.cc.

References _d, d(), and MEChannel().

Referenced by getDaughter().

{
  MEChannel* d = new MEChannel( ix, iy, id_, this );
  _d.push_back( d );
  return d;
}
MEChannel* MEChannel::d ( unsigned  ii) [inline]

Definition at line 25 of file MEChannel.h.

References _d, and n().

Referenced by addDaughter().

{ if( ii>=n() ) return 0; return _d[ii]; }
MEChannel * MEChannel::getAncestor ( int  ig)

Definition at line 97 of file MEChannel.cc.

References _ig, getAncestor(), and m().

Referenced by getAncestor().

{
  if( _ig==g ) return this;
  
  MEChannel* mother = this->m();
  if( mother!=0 )
    {
      if( mother->_ig==g ) return mother;
      return mother->getAncestor( g );
    }

  return 0;
}
MEChannel * MEChannel::getChannel ( int  ig,
int  ix,
int  iy 
)

Definition at line 159 of file MEChannel.cc.

References _ig, _m, getChannel(), and python::Node::leaf.

{
  assert( ig>=0 );
  MEChannel* leaf = getChannel( ix, iy );
  if( leaf==0 ) return 0;
  while( ig!=leaf->_ig )
    {
      leaf = leaf->_m;
    }
  return leaf;
}
MEChannel * MEChannel::getChannel ( int  ix,
int  iy 
)

Definition at line 172 of file MEChannel.cc.

References _d, _ix, _iy, python::Node::leaf, and n().

Referenced by getChannel().

{
  if( n()==0 )
    {
      if( ix==_ix && iy==_iy )
        {
          return this;
        }
      else
        return 0;
    }
  MEChannel* leaf(0);
  for( unsigned ii=0; ii<n(); ii++ )
    {
      leaf =  _d[ii]->getChannel( ix, iy ); 
      if( leaf!=0 ) break;
    }
  return leaf;
}
MEChannel * MEChannel::getDaughter ( int  ix,
int  iy,
int  ig 
)

Definition at line 42 of file MEChannel.cc.

References _d, and addDaughter().

Referenced by ME::regTree().

{
  for( unsigned ii=0; ii<_d.size(); ii++ )
    {
      if( _d[ii]->id()==id_ ) 
        {
          return _d[ii];
        }
    }  
  return addDaughter( ix, iy, id_ );
}
MEChannel * MEChannel::getDescendant ( int  ig,
int  ii 
)

Definition at line 135 of file MEChannel.cc.

References getListOfDescendants(), id(), and python::Node::leaf.

Referenced by ME::lmrTree().

{
  std::vector< MEChannel* > vec;
  bool OK = getListOfDescendants( ig, vec );
  if( !OK ) return 0;
  MEChannel* leaf(0);
  for( unsigned int ii=0; ii<vec.size(); ii++ )
    {
      leaf = vec[ii];
      if( leaf->id()==id_ ) return leaf;
    }
  return leaf;
}
MEChannel * MEChannel::getFirstDescendant ( int  ig)

Definition at line 150 of file MEChannel.cc.

References getListOfDescendants().

{
  std::vector< MEChannel* > vec;
  bool OK = getListOfDescendants( ig, vec );
  if( !OK ) return 0;
  return vec[0];
}
bool MEChannel::getListOfAncestors ( std::vector< MEChannel * > &  vec)

Definition at line 85 of file MEChannel.cc.

References getListOfAncestors(), and m().

Referenced by getListOfAncestors().

{
  MEChannel* mother = this->m();
  if( mother!=0 )
    {
      vec.push_back( mother );
      mother->getListOfAncestors( vec );
    }
  return true;
}
bool MEChannel::getListOfChannels ( std::vector< MEChannel * > &  vec)

Definition at line 69 of file MEChannel.cc.

References _d, n(), and convertSQLiteXML::ok.

Referenced by oneLine().

{
  if( n()==0 ) 
    {
      vec.push_back( this );
      return true;
    }
  for( unsigned ii=0; ii<n(); ii++ )
    {
      bool ok = _d[ii]->getListOfChannels( vec ); 
      assert( ok );
    }
  return true;
}
bool MEChannel::getListOfDescendants ( std::vector< MEChannel * > &  vec)

Definition at line 112 of file MEChannel.cc.

References _d, and n().

Referenced by getDescendant(), getFirstDescendant(), and getListOfDescendants().

{
  for( unsigned ii=0; ii<n(); ii++ )
    {
      vec.push_back(_d[ii]);
      _d[ii]->getListOfDescendants( vec ); 
    }
  return true;
}
bool MEChannel::getListOfDescendants ( int  ig,
std::vector< MEChannel * > &  vec 
)

Definition at line 123 of file MEChannel.cc.

References _d, _ig, getListOfDescendants(), and n().

{
  for( unsigned ii=0; ii<n(); ii++ )
    {
      MEChannel* curLeaf = _d[ii];
      if( curLeaf->_ig==ig ) vec.push_back(curLeaf);
      curLeaf->getListOfDescendants( ig, vec ); 
    }
  return true;
}
int MEChannel::id ( void  ) const

Definition at line 63 of file MEChannel.cc.

References _id, and _ig.

Referenced by getDescendant().

{
  return _id[_ig];
}
int MEChannel::ig ( ) const [inline]

Definition at line 27 of file MEChannel.h.

References _ig.

{ return _ig; }
int MEChannel::ix ( ) const [inline]

Definition at line 20 of file MEChannel.h.

References _ix.

Referenced by MEChannel(), oneLine(), and oneWord().

{ return _ix; }
int MEChannel::iy ( ) const [inline]

Definition at line 21 of file MEChannel.h.

References _iy.

Referenced by MEChannel(), oneLine(), and oneWord().

{ return _iy; }
MEChannel* MEChannel::m ( ) [inline]

Definition at line 24 of file MEChannel.h.

References _m.

Referenced by getAncestor(), and getListOfAncestors().

{ return _m; }
unsigned MEChannel::n ( ) const [inline]

Definition at line 26 of file MEChannel.h.

References _d.

Referenced by d(), getChannel(), getListOfChannels(), and getListOfDescendants().

{ return _d.size(); }
TString MEChannel::oneLine ( int  ig)

Definition at line 219 of file MEChannel.cc.

References _id, _ig, ME::dccAndSide(), getListOfChannels(), ME::iCrystal, ME::iEBM, ME::iEBP, ME::iEcalRegion, ME::iLMModule, ME::iLMRegion, ME::iSector, ME::iSuperCrystal, ix(), iy(), MEEBGeom::localCoord(), nchan, dbtoconf::out, ME::region, and ME::smName().

{
  assert( ig>=ME::iEcalRegion );
  int reg_ = _id[ME::iEcalRegion];
  TString out;
  if( ig<ME::iLMRegion )
    {
      out += ME::region[reg_];
      if( ig==ME::iSector ) out+="/S="; out+=_id[ME::iSector];
      return out;
    }
  int lmr_ = _id[ME::iLMRegion];
  std::pair<int,int> p_ = ME::dccAndSide( lmr_ );
  out+= ME::granularity[ME::iLMRegion]; 
  out+="=";out += lmr_;
  int dcc_=p_.first; 
  int side_=p_.second; 
  out+="(DCC="; out+=dcc_; out+=","; 
  out+= ME::smName(lmr_);
  out+="/"; out+=side_; out+=")";
  if( ig>=_ig ) ig=_ig;
  if( ig>=ME::iLMModule )
    {
      int lmm_=_id[ME::iLMModule]; 
      out+="/"; 
      out+=ME::granularity[ME::iLMModule];
      out+="=";
      out+=lmm_;
      if( ig>=ME::iSuperCrystal )
        {
          int sc_=_id[ME::iSuperCrystal];
          out+="/"; 
          out+=ME::granularity[ME::iSuperCrystal];
          out+="=";
          out+=sc_;
          if( ig>=ME::iCrystal )
            {
              int c_=_id[ME::iCrystal];
              out+="/"; 
              out+=ME::granularity[ME::iCrystal];
              out+="=";
              out+=c_;
              if( reg_==ME::iEBM || reg_==ME::iEBP )
                {
                  out += "/ieta="; out+=ix();
                  out += "/iphi="; out+=iy();
                  MEEBGeom::XYCoord ixy_ = 
                    MEEBGeom::localCoord( ix(), iy() );
                  out += "(ix="; out+=ixy_.first;
                  out += "/iy="; out+=ixy_.second;
                  out += ")";
                }
              else
                {
                  out += "/ix="; out+=ix();
                  out += "/iy="; out+=iy();
                }
            }
        }
    }
  if( ig<ME::iCrystal )
    {
      std::vector< MEChannel* > _channels;
      getListOfChannels( _channels );
      int nchan = _channels.size();
      if( nchan>1 )
        {
          out += "(";
          out += nchan;
          out += "xTals)";
        }
    }
  return out;
}
TString MEChannel::oneLine ( ) [inline]

Definition at line 41 of file MEChannel.h.

References _ig, and oneLine().

Referenced by oneLine().

{ return oneLine( _ig ); }
TString MEChannel::oneWord ( ) [inline]

Definition at line 43 of file MEChannel.h.

References _ig, and oneWord().

Referenced by oneWord().

{ return oneWord( _ig ); }
TString MEChannel::oneWord ( int  ig)

Definition at line 295 of file MEChannel.cc.

References _id, _ig, ME::iCrystal, ME::iEBM, ME::iEBP, ME::iEcalRegion, ME::iLMModule, ME::iLMRegion, ME::iSector, ME::iSuperCrystal, ix(), iy(), MEEBGeom::localCoord(), dbtoconf::out, and ME::region.

{
  assert( ig>=ME::iEcalRegion );
  int reg_ = _id[ME::iEcalRegion];
  TString out;
  if( ig<ME::iLMRegion )
    {
      out = "ECAL_"; 
      out += ME::region[reg_];
      if( ig==ME::iSector ) out+="_S"; out+=_id[ME::iSector];
      return out;
    }
  int lmr_ = _id[ME::iLMRegion];
  out+= ME::granularity[ME::iLMRegion]; 
  out+=lmr_;
  if( ig>=_ig ) ig=_ig;
  if( ig>=ME::iLMModule )
    {
      int lmm_=_id[ME::iLMModule]; 
      out+="_"; 
      out+=ME::granularity[ME::iLMModule];
      out+=lmm_;
      if( ig>=ME::iSuperCrystal )
        {
          int sc_=_id[ME::iSuperCrystal];
          out+="_"; 
          out+=ME::granularity[ME::iSuperCrystal];
          out+=sc_;
          if( ig>=ME::iCrystal )
            {
              int c_=_id[ME::iCrystal];
              out+="_"; 
              out+=ME::granularity[ME::iCrystal];
              out+=c_;
              if( reg_==ME::iEBM || reg_==ME::iEBP )
                {
                  MEEBGeom::XYCoord ixy_ = 
                    MEEBGeom::localCoord( ix(), iy() );
                  out += "_"; out+=ixy_.first;
                  out += "_"; out+=ixy_.second;
                }
              else
                {
                  out += "_"; out+=ix();
                  out += "_"; out+=iy();
                }
            }
        }
    }
  return out;
}
void MEChannel::print ( std::ostream &  o,
bool  recursif = false 
) const

Member Data Documentation

std::vector< MEChannel* > MEChannel::_d [private]
std::vector< int > MEChannel::_id [private]

Definition at line 59 of file MEChannel.h.

Referenced by id(), MEChannel(), oneLine(), and oneWord().

int MEChannel::_ig [private]

Definition at line 52 of file MEChannel.h.

Referenced by getAncestor(), getChannel(), getListOfDescendants(), id(), ig(), MEChannel(), oneLine(), and oneWord().

int MEChannel::_ix [private]

Definition at line 55 of file MEChannel.h.

Referenced by getChannel(), ix(), and MEChannel().

int MEChannel::_iy [private]

Definition at line 56 of file MEChannel.h.

Referenced by getChannel(), iy(), and MEChannel().

Definition at line 48 of file MEChannel.h.

Referenced by getChannel(), m(), and MEChannel().