Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CellID.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/GlastEvent/GlastEvent/Utilities/CellID.h,v 1.2 2001/04/18 19:07:26 igable Exp $
00002 #ifndef LHCBEVENT_CELLID_H
00003 #define LHCBEVENT_CELLID_H 1
00004 
00005 
00006 // Include files
00007 #include <iostream>
00008 #include "GaudiKernel/StreamBuffer.h"
00009 #include "GlastEvent/TopLevel/Definitions.h"
00010 
00011 
00012 //------------------------------------------------------------------------------
00013 //
00014 // ClassName:   CellID
00015 //  
00016 // Description: Cell identifier of the calorimeter cells
00017 //
00018 // Author:      Pavel Binko
00019 // Changes:     P.Binko 19/10/1999 : Formating of ASCII output
00020 //
00021 //------------------------------------------------------------------------------
00022 
00023 
00024 class CellID                                                                   {
00025 
00026   // Encoding taken from SICB
00027   // Restriction : CalorimeterEncoding > RawEncoding > ColumnEncoding
00028   //               If not, the code has to be changed
00029   enum { CalorimeterEncoding=1000000, RawEncoding=1000, ColumnEncoding=1 };
00030 
00031 public:
00032 
00034   CellID()
00035     : m_id(0)                                                                { }
00036   CellID( long cellID )
00037     : m_id(cellID)                                                           { }
00038   CellID( long calorimeterNumber, long rawNumber, long columnNumber )          {
00039     setID( calorimeterNumber, rawNumber, columnNumber );
00040   }
00042   ~CellID()                                                                  { }
00043 
00045   long calorimeterNumber() const                                               {
00046     return long( m_id / CalorimeterEncoding );
00047   }
00049   long rawNumber() const                                                       {
00050     return long( (m_id - calorimeterNumber()*CalorimeterEncoding)
00051       / RawEncoding );
00052   }
00054   long columnNumber() const                                                    {
00055     return long( (m_id - calorimeterNumber()*CalorimeterEncoding
00056       - rawNumber()*RawEncoding)
00057       / ColumnEncoding );
00058   }
00060   long id() const                                                              {
00061     return m_id;
00062   }
00064   void setID( long calorimeterNumber, long rawNumber, long columnNumber )      {
00065     m_id  = CalorimeterEncoding*calorimeterNumber
00066       + RawEncoding*rawNumber
00067       + ColumnEncoding*columnNumber;
00068   }
00069 
00071   friend StreamBuffer& operator<< ( StreamBuffer& s, const CellID& obj )       {
00072     return s << obj.m_id;
00073   }
00075   friend StreamBuffer& operator>> ( StreamBuffer& s, CellID& obj )             {
00076     return s >> obj.m_id;
00077   }
00078 
00080   friend std::ostream& operator<< ( std::ostream& s, const CellID& obj )       {
00081     return obj.fillStream(s);
00082   }
00084     std::ostream& fillStream( std::ostream& s ) const                          {
00085     return s
00086       << "class CellID (calorimeter, raw, column) : ( "
00087       << GlastEventField( GlastEvent::field5 )
00088       << calorimeterNumber()
00089       << ", "
00090       << GlastEventField( GlastEvent::field5 )
00091       << rawNumber()
00092       << ", "
00093       << GlastEventField( GlastEvent::field5 )
00094       << columnNumber() << " )";
00095   }
00096 
00097 private:
00098 
00099   // Cell identifier
00100   long m_id;
00101 
00102 };
00103 
00104 
00105 #endif    // LHCBEVENT_CELLID_H

Generated at Wed Nov 21 12:22:49 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000