Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:36

0001 // H4Geom.h
0002 //
0003 // Class which manages geometry information of the super-module
0004 // Author: Giovanni Franzoni
0005 //
0006 
0007 #ifndef H4Geom_H
0008 #define H4Geom_H
0009 
0010 
0011 #include <string>
0012 
0013 class H4Geom
0014 {
0015  public:
0016   // Geometry is period dependent. The different geometries are listed below
0017   enum GeomPeriod_t {
0018     Undef,      // Cause the program to crash
0019     Year2003,   // Test beam during 2003: SM0 and SM1
0020     Spring2004, // June-July 2004: E0' tests
0021     Automn2004  // Tests of one full supermodule
0022   };
0023 
0024   // Constants defining supermodule geometry
0025   enum SMGeom_t {
0026     kSModulesInEcal      = 36,   // Number of Super Modules in whole ECAL
0027     kModules                   = 4,    // Number of modules per supermodule
0028     kTriggerTowers         = 68,   // Number of trigger towers per supermodule
0029     kTTandMems            = 70,   // Number of tt per supermodule, including MEM boxes
0030     kTowersInPhi            = 4,    // Number of trigger towers in phi
0031     kTowersInEta            = 17,   // Number of trigger towers in eta
0032     kCrystals                   = 1700, // Number of crystals per supermodule
0033     kCrystalsWithMems           = 1750, // Number of channels per supermodule, mem included
0034     kCrystalsM1              = 500, // Number of crystals per supermodule
0035     kCrystalsM2              = 400, // Number of crystals per supermodule
0036     kCrystalsM3              = 400, // Number of crystals per supermodule
0037     kCrystalsM4              = 400, // Number of crystals per supermodule
0038     kCrystalsInPhi           = 20,   // Number of crystals in phi
0039     kCrystalsInEta           = 85,   // Number of crystals in eta
0040     kCrystalsInEtaM1      = 25,   // Number of crystals in eta for module 1
0041     kCrystalsInEtaM2      = 20,   // Number of crystals in eta for module 2
0042     kCrystalsInEtaM3      = 20,   // Number of crystals in eta for module 3
0043     kCrystalsInEtaM4      = 20,   // Number of crystals in eta for module 4
0044     kCrystalsPerTower   = 25,   // Number of crystals per trigger tower
0045     kCardsPerTower       = 5,    // Number of VFE cards per trigger tower
0046     kChannelsPerCard    =  5,     // Number of channels per VFE card
0047     kSamplesInEvent       =  10,    // Number of samples in event
0048     kSamplesInPNEvent  =  50,    // Number of samples in event
0049     kPNs                  = 10 // number of pn diode for laser monitoring (number [0,9])
0050   };
0051 
0052   // Default Constructor, mainly for Root
0053   H4Geom() ;
0054 
0055   // Destructor: Does nothing?
0056   virtual ~H4Geom();
0057 
0058   // Initialize geometry with config file
0059   bool init();
0060 
0061   // Retuns the crystal number in the super module for a given
0062   // tower number in the super module and crystal number in the tower
0063   int getSMCrystalNumber(int tower, int crystal) const ;
0064   
0065   // Retuns the crystal number in the super module for a given
0066   // tower number, strip_id number and crystal_id number
0067   // necessary for output of the data-parser, Ecal Monitoring
0068   int getSMCrystalNumber(int tower, int strip_id, int crystal_id) const ;
0069 
0070   // Retuns the tower number, strip_id number and crystal_id number
0071   // for a given crystal in the SM numbering
0072   // This is the inverse of int getSMCrystalNumber(int tower, int strip_id, int crystal_id) const ;
0073   void getTowerStripChannelNumber(int& tower, int& strip_id, int& crystal_id, int sm_num) const;
0074 
0075   // Retuns the crystal number in a tower for a given
0076   // crystal number in the super module
0077   void getTowerCrystalNumber(int &tower, int &crystal, int smCrystal) const ;
0078 
0079   // Returns the crystal number (readout order) in a tower 
0080   // for a given position in the tower (crystalNbGeom=0 is the 
0081   // lower-right corner and crystalNbGeom=24 is the upper-left corner)
0082   int getTowerCrystalNumber(int smTowerNb, int crystalNbGeom) const ;
0083 
0084   // Returns the crystal coordinates (eta, phi index) for a given
0085   // crystal number in the super module
0086   void getCrystalCoord(int &eta, int &phi, int smCrystal) const ;
0087 
0088   // Retuns the crystal number in the super module for given coordinates
0089   int getSMCrystalFromCoord(int eta, int phi) const ;
0090 
0091   // Returns left neighbour of a sm crystal.
0092   // Input and output are crystal numbers in the super module.
0093   // A negative output means outside of the supermodule.
0094   int getLeft(int smCrystal) const ;
0095 
0096   // Returns right neighbour of a sm crystal.
0097   // Input and output are crystal numbers in the super module.
0098   // A negative output means outside of the supermodule.
0099   int getRight(int smCrystal) const ;
0100 
0101   // Returns upper neighbour of a sm crystal.
0102   // Input and output are crystal numbers in the super module.
0103   // A negative output means outside of the supermodule.
0104   int getUpper(int smCrystal) const ;
0105 
0106   // Returns lower neighbour of a sm crystal.
0107   // Input and output are crystal numbers in the super module.
0108   // A negative output means outside of the supermodule.
0109   int getLower(int smCrystal) const ;
0110 
0111   // Returns left neighbour of a crystal referenced by its coordinates.
0112   // New coordonates overwrite the old ones. No check is done to see
0113   // if it corresponds to a real crystal. To be used with caution. 
0114   void mvLeft(int &eta, int &phi) const ;
0115 
0116   // Returns right neighbour of a crystal referenced by its coordinates.
0117   // New coordonates overwrite the old ones. No check is done to see
0118   // if it corresponds to a real crystal. To be used with caution. 
0119   void mvRight(int &eta, int &phi) const ;
0120 
0121   // Returns upper neighbour of a crystal referenced by its coordinates.
0122   // New coordonates overwrite the old ones. No check is done to see
0123   // if it corresponds to a real crystal. To be used with caution. 
0124   void mvUp(int &eta, int &phi) const ;
0125 
0126 
0127   // Returns lower neighbour of a crystal referenced by its coordinates.
0128   // New coordonates overwrite the old ones. No check is done to see
0129   // if it corresponds to a real crystal. To be used with caution. 
0130   void mvDown(int &eta, int &phi) const ;
0131 
0132   // Returns the 25 crystals of tower towerNb in the super module.
0133   // Output are crystal numbers in the super module.
0134   // By default, the order in the output array (tower) corresponds to
0135   // geometric order (index 0 is lower-right corner).
0136   // if order=readout, the order in the output array (tower) 
0137   // corresponds to the readout scheme (depends on the kind of tower) 
0138   void getTower(int * tower, int towerNb, std::string order = "geom") const ;
0139 
0140   // Returns the 5 crystals belonging to the same VFE board as smCrystal.
0141   // Input and output are crystal numbers in the super module.
0142   // By default, the order in the output array (VFE) corresponds to
0143   // The geometric order (index 0 is lower-right corner).
0144   // if order=readout, the order in the output array (VFE) 
0145   // corresponds to the readout scheme (depends on the kind of tower)
0146   void getVFE(int * VFE, int smCrystal, std::string order = "geom") const ;
0147 
0148   // Returns sm crystal numbers for crystals in a window of
0149   // size widthxheight centered around a given smCrystal.
0150   // width and height must be odd.
0151   // The order in the output array (window) is defined 
0152   // by the geometric order (index 0 is lower-right corner).
0153   void getWindow(int * window, int smCrystal, int width, int height) const ;
0154 
0155   // Tests if low voltage board is on the right size of the tower. 
0156   // Readout scheme depends on that.
0157   bool rightTower(int tower) const ;
0158 
0159   // Tests if low voltage board is on the left size of the tower
0160   // Readout scheme depends on that.
0161   bool leftTower(int tower) const ;
0162   
0163   // first half of SM, shown by one laser shot
0164   bool  isInFirstHalf(int numberInSM)
0165   {
0166     int eta;   int phi; 
0167     getCrystalCoord(eta,phi, numberInSM);
0168     if (phi > 19 || eta < 20 )
0169       {return true; }
0170     else
0171       {return false; }
0172   };
0173   
0174  
0175   GeomPeriod_t GetGeomPeriod() const {return geometry_;}
0176 
0177   static void SetGeomPeriod(GeomPeriod_t geometry);
0178 
0179   int getHalf(int TT);
0180  private:
0181   bool IsGeomPeriodDefined() const;
0182 
0183   const static int crystalChannelMap[5][5];
0184   const static int crystalMap[25];
0185   const static int WhichHalf[69];
0186   static GeomPeriod_t geometry_;
0187 };
0188 
0189 #endif