CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/EventFilter/EcalTBRawToDigi/data/macro/Geom.h

Go to the documentation of this file.
00001 // H4Geom.h
00002 //
00003 // Class which manages geometry information of the super-module
00004 //
00005 // last change : $Date: 2010/10/21 17:33:47 $
00006 // by          : $Author: wmtan $
00007 //
00008 
00009 #ifndef H4Geom_H
00010 #define H4Geom_H
00011 
00012 
00013 #include <string>
00014 
00015 class H4Geom
00016 {
00017  public:
00018   // Geometry is period dependent. The different geometries are listed below
00019   enum GeomPeriod_t {
00020     Undef,      // Cause the program to crash
00021     Year2003,   // Test beam during 2003: SM0 and SM1
00022     Spring2004, // June-July 2004: E0' tests
00023     Automn2004  // Tests of one full supermodule
00024   };
00025 
00026   // Constants defining supermodule geometry
00027   enum SMGeom_t {
00028     kSModulesInEcal      = 36,   // Number of Super Modules in whole ECAL
00029     kModules                   = 4,    // Number of modules per supermodule
00030     kTriggerTowers         = 68,   // Number of trigger towers per supermodule
00031     kTTandMems            = 70,   // Number of tt per supermodule, including MEM boxes
00032     kTowersInPhi            = 4,    // Number of trigger towers in phi
00033     kTowersInEta            = 17,   // Number of trigger towers in eta
00034     kCrystals                   = 1700, // Number of crystals per supermodule
00035     kCrystalsWithMems           = 1750, // Number of channels per supermodule, mem included
00036     kCrystalsM1              = 500, // Number of crystals per supermodule
00037     kCrystalsM2              = 400, // Number of crystals per supermodule
00038     kCrystalsM3              = 400, // Number of crystals per supermodule
00039     kCrystalsM4              = 400, // Number of crystals per supermodule
00040     kCrystalsInPhi           = 20,   // Number of crystals in phi
00041     kCrystalsInEta           = 85,   // Number of crystals in eta
00042     kCrystalsInEtaM1      = 25,   // Number of crystals in eta for module 1
00043     kCrystalsInEtaM2      = 20,   // Number of crystals in eta for module 2
00044     kCrystalsInEtaM3      = 20,   // Number of crystals in eta for module 3
00045     kCrystalsInEtaM4      = 20,   // Number of crystals in eta for module 4
00046     kCrystalsPerTower   = 25,   // Number of crystals per trigger tower
00047     kCardsPerTower       = 5,    // Number of VFE cards per trigger tower
00048     kChannelsPerCard    =  5,     // Number of channels per VFE card
00049     kSamplesInEvent       =  10,    // Number of samples in event
00050     kSamplesInPNEvent  =  50,    // Number of samples in event
00051     kPNs                  = 10 // number of pn diode for laser monitoring (number [0,9])
00052   };
00053 
00054   // Default Constructor, mainly for Root
00055   H4Geom() ;
00056 
00057   // Destructor: Does nothing?
00058   virtual ~H4Geom();
00059 
00060   // Initialize geometry with config file
00061   bool init();
00062 
00063   // Retuns the crystal number in the super module for a given
00064   // tower number in the super module and crystal number in the tower
00065   int getSMCrystalNumber(int tower, int crystal) const ;
00066   
00067   // Retuns the crystal number in the super module for a given
00068   // tower number, strip_id number and crystal_id number
00069   // necessary for output of the data-parser, Ecal Monitoring
00070   int getSMCrystalNumber(int tower, int strip_id, int crystal_id) const ;
00071 
00072   // Retuns the tower number, strip_id number and crystal_id number
00073   // for a given crystal in the SM numbering
00074   // This is the inverse of int getSMCrystalNumber(int tower, int strip_id, int crystal_id) const ;
00075   void getTowerStripChannelNumber(int& tower, int& strip_id, int& crystal_id, int sm_num) const;
00076 
00077   // Retuns the crystal number in a tower for a given
00078   // crystal number in the super module
00079   void getTowerCrystalNumber(int &tower, int &crystal, int smCrystal) const ;
00080 
00081   // Returns the crystal number (readout order) in a tower 
00082   // for a given position in the tower (crystalNbGeom=0 is the 
00083   // lower-right corner and crystalNbGeom=24 is the upper-left corner)
00084   int getTowerCrystalNumber(int smTowerNb, int crystalNbGeom) const ;
00085 
00086   // Returns the crystal coordinates (eta, phi index) for a given
00087   // crystal number in the super module
00088   void getCrystalCoord(int &eta, int &phi, int smCrystal) const ;
00089 
00090   // Retuns the crystal number in the super module for given coordinates
00091   int getSMCrystalFromCoord(int eta, int phi) const ;
00092 
00093   // Returns left neighbour of a sm crystal.
00094   // Input and output are crystal numbers in the super module.
00095   // A negative output means outside of the supermodule.
00096   int getLeft(int smCrystal) const ;
00097 
00098   // Returns right neighbour of a sm crystal.
00099   // Input and output are crystal numbers in the super module.
00100   // A negative output means outside of the supermodule.
00101   int getRight(int smCrystal) const ;
00102 
00103   // Returns upper neighbour of a sm crystal.
00104   // Input and output are crystal numbers in the super module.
00105   // A negative output means outside of the supermodule.
00106   int getUpper(int smCrystal) const ;
00107 
00108   // Returns lower neighbour of a sm crystal.
00109   // Input and output are crystal numbers in the super module.
00110   // A negative output means outside of the supermodule.
00111   int getLower(int smCrystal) const ;
00112 
00113   // Returns left neighbour of a crystal referenced by its coordinates.
00114   // New coordonates overwrite the old ones. No check is done to see
00115   // if it corresponds to a real crystal. To be used with caution. 
00116   void mvLeft(int &eta, int &phi) const ;
00117 
00118   // Returns right neighbour of a crystal referenced by its coordinates.
00119   // New coordonates overwrite the old ones. No check is done to see
00120   // if it corresponds to a real crystal. To be used with caution. 
00121   void mvRight(int &eta, int &phi) const ;
00122 
00123   // Returns upper neighbour of a crystal referenced by its coordinates.
00124   // New coordonates overwrite the old ones. No check is done to see
00125   // if it corresponds to a real crystal. To be used with caution. 
00126   void mvUp(int &eta, int &phi) const ;
00127 
00128 
00129   // Returns lower neighbour of a crystal referenced by its coordinates.
00130   // New coordonates overwrite the old ones. No check is done to see
00131   // if it corresponds to a real crystal. To be used with caution. 
00132   void mvDown(int &eta, int &phi) const ;
00133 
00134   // Returns the 25 crystals of tower towerNb in the super module.
00135   // Output are crystal numbers in the super module.
00136   // By default, the order in the output array (tower) corresponds to
00137   // geometric order (index 0 is lower-right corner).
00138   // if order=readout, the order in the output array (tower) 
00139   // corresponds to the readout scheme (depends on the kind of tower) 
00140   void getTower(int * tower, int towerNb, std::string order = "geom") const ;
00141 
00142   // Returns the 5 crystals belonging to the same VFE board as smCrystal.
00143   // Input and output are crystal numbers in the super module.
00144   // By default, the order in the output array (VFE) corresponds to
00145   // The geometric order (index 0 is lower-right corner).
00146   // if order=readout, the order in the output array (VFE) 
00147   // corresponds to the readout scheme (depends on the kind of tower)
00148   void getVFE(int * VFE, int smCrystal, std::string order = "geom") const ;
00149 
00150   // Returns sm crystal numbers for crystals in a window of
00151   // size widthxheight centered around a given smCrystal.
00152   // width and height must be odd.
00153   // The order in the output array (window) is defined 
00154   // by the geometric order (index 0 is lower-right corner).
00155   void getWindow(int * window, int smCrystal, int width, int height) const ;
00156 
00157   // Tests if low voltage board is on the right size of the tower. 
00158   // Readout scheme depends on that.
00159   bool rightTower(int tower) const ;
00160 
00161   // Tests if low voltage board is on the left size of the tower
00162   // Readout scheme depends on that.
00163   bool leftTower(int tower) const ;
00164   
00165   // first half of SM, shown by one laser shot
00166   bool  isInFirstHalf(int numberInSM)
00167   {
00168     int eta;   int phi; 
00169     getCrystalCoord(eta,phi, numberInSM);
00170     if (phi > 19 || eta < 20 )
00171       {return true; }
00172     else
00173       {return false; }
00174   };
00175   
00176  
00177   GeomPeriod_t GetGeomPeriod() const {return geometry_;}
00178 
00179   static void SetGeomPeriod(GeomPeriod_t geometry);
00180 
00181   int getHalf(int TT);
00182  private:
00183   bool IsGeomPeriodDefined() const;
00184 
00185   const static int crystalChannelMap[5][5];
00186   const static int crystalMap[25];
00187   const static int WhichHalf[69];
00188   static GeomPeriod_t geometry_;
00189 };
00190 
00191 #endif