Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:33

0001 #ifndef CSCIndexerStartup_H
0002 #define CSCIndexerStartup_H
0003 
0004 /** \class CSCIndexerStartup
0005  * Concrete CSCIndexer class appropriate for CSC Conditions Data access for CMS
0006  * startup (2008-2013) in which most ME4/2 chambers do not exist and the 48
0007  * ME1/1A strips are ganged into 16 channels. <br> The conditions data are
0008  * stored in an order based on the hadrware channel order so this class has to
0009  * jump through hoops in order to map between that order and a CSCDetID order
0010  * offline.
0011  *
0012  * See documentation in base class CSCIndexerBase for more information.
0013  *
0014  * \warning This class is hard-wired for the CSC system at start-up of CMS in
0015  * 2008. with rings ME11, ME12, ME13, ME21, ME22, ME31, ME32, ME41 totalling 234
0016  * chambers per endcap. But ME42 is appended (to permit simulation studies), so
0017  * the chamber order is <br> +z ME11, ME12, ME13, ME21, ME22, ME31, ME32, ME41,
0018  * <br> -z ME11, ME12, ME13, ME21, ME22, ME31, ME32, ME41, <br> +z ME42, -z ME42
0019  * <br>
0020  *
0021  *  CSCIndexerBase::stripChannelIndex returns <br>
0022  *      1-217728 (CSCs 2008), 217729-252288 (ME42) (and ME1a channels are always
0023  * channels 65-80 of 1-80 in ME11)
0024  *
0025  *  CSCIndexerBase::chipIndex returns <br>
0026  *      1-13608 (CSCs 2008), 13609-15768 (ME42)
0027  *
0028  *  CSCIndexerBase::gasGainIndex returns <br>
0029  *     1-45144 (CSCs 2008), 45145-55944 (ME42)
0030  *
0031  * \warning This uses magic numbers galore!!
0032  * \warning EVERY LABEL COUNTS FROM ONE NOT ZERO.
0033  *
0034  */
0035 
0036 #include <CalibMuon/CSCCalibration/interface/CSCIndexerBase.h>
0037 
0038 class CSCIndexerStartup : public CSCIndexerBase {
0039 public:
0040   ~CSCIndexerStartup() override;
0041 
0042   std::string name() const override { return "CSCIndexerStartup"; }
0043 
0044   /// \name maxIndexMethods
0045   //@{
0046   LongIndexType maxStripChannelIndex() const override { return 252288; }
0047   IndexType maxChipIndex() const override { return 15768; }
0048   IndexType maxGasGainIndex() const override { return 55944; }
0049   //@}
0050 
0051   /// \name nonIndexCountingMethods
0052   //@{
0053   /**
0054    * How many online rings are there in station 'is'=1, 2, 3, 4 ?
0055    *
0056    * \warning: ME1a + ME1b are considered as single ME1/1
0057    * 'online' rings for the startup
0058    */
0059   IndexType onlineRingsInStation(IndexType is) const override {
0060     const IndexType nrings[5] = {0, 3, 2, 2, 2};
0061     return nrings[is];
0062   }
0063 
0064   /**
0065    * Number of strip readout channels per layer in an offline chamber
0066    * with ring 'ir' and station 'is'.
0067    * Works for ME1a (ring 4 of ME1) too.
0068    *
0069    * Assume ME1a has 16 ganged readout channels.
0070    */
0071   IndexType stripChannelsPerOfflineLayer(IndexType is, IndexType ir) const override {
0072     const IndexType nSC[16] = {64, 80, 64, 16, 80, 80, 0, 0, 80, 80, 0, 0, 80, 80, 0, 0};
0073     return nSC[(is - 1) * 4 + ir - 1];
0074   }
0075 
0076   /**
0077    * Number of strip readout channels per layer in an online chamber
0078    * with ring 'ir' and station 'is'.
0079    * Works for ME1a (ring 4 of ME1) too.
0080    *
0081    * Assume ME1a has 16 ganged readout channels. Online chamber has 64+16=80
0082    * channels.
0083    */
0084   IndexType stripChannelsPerOnlineLayer(IndexType is, IndexType ir) const override {
0085     const IndexType nSC[16] = {80, 80, 64, 80, 80, 80, 0, 0, 80, 80, 0, 0, 80, 80, 0, 0};
0086     return nSC[(is - 1) * 4 + ir - 1];
0087   }
0088 
0089   /**
0090    * Number of Buckeye chips per layer in an online chamber
0091    * in ring 'ir' of station 'is'.
0092    * Works for ME1a (ring 4 of ME1) too.
0093    *
0094    * 'Online' ME11 for the startup is considered as a single chamber with 5
0095    * chips
0096    */
0097   IndexType chipsPerOnlineLayer(IndexType is, IndexType ir) const override {
0098     const IndexType nCinL[16] = {5, 5, 4, 5, 5, 5, 0, 0, 5, 5, 0, 0, 5, 5, 0, 0};
0099     return nCinL[(is - 1) * 4 + ir - 1];
0100   }
0101 
0102   //@}
0103 
0104   /// \name stripIndexMethods
0105   //@{
0106   /**
0107    * Number of strip channel indices for a layer in a chamber
0108    * defined by station number 'is' and ring number 'ir'.
0109    *
0110    * Station label range 1-4, Ring label range 1-4 (4=ME1a)
0111    *
0112    * This depends on the ordering of the channels in the database.
0113    * In startup scenario there are 80 indices allocated per ME1/1 layer with
0114    * 1-64 belonging to ME1b and 65-80 belonging to ME1a. So the ME1/a database
0115    * indices are mapped to extend the ME1/b index ranges, which is how the raw
0116    * hardware channels numbering is implemented.
0117    */
0118   IndexType stripChannelsPerLayer(IndexType is, IndexType ir) const override {
0119     const IndexType nSCinC[16] = {80, 80, 64, 80, 80, 80, 0, 0, 80, 80, 0, 0, 80, 80, 0, 0};
0120     return nSCinC[(is - 1) * 4 + ir - 1];
0121   }
0122 
0123   /**
0124    * Linear index for 1st strip channel in ring 'ir' of station 'is' in endcap
0125    * 'ie'.
0126    *
0127    * Endcap label range 1-2, Station label range 1-4, Ring label range 1-4.
0128    *
0129    * WARNING: while ME1a channels are the last 16 of the 80 total in each layer
0130    * of an ME11 chamber, their start index here defaults to the start index of
0131    * ME1a.
0132    */
0133   LongIndexType stripChannelStart(IndexType ie, IndexType is, IndexType ir) const override {
0134     // These are in the ranges 1-217728 (CSCs 2008) and 217729-252288 (ME42).
0135     // There are 1-108884 channels per endcap (CSCs 2008) and 17280 channels per
0136     // endcap (ME42). Start of -z channels (CSCs 2008) is 108864 + 1 = 108865
0137     // Start of +z (ME42) is 217728 + 1 = 217729
0138     // Start of -z (ME42) is 217728 + 1 + 17280 = 235009
0139     const LongIndexType nStart[32] = {1, 17281,  34561,  1,      48385, 57025,  0,      0,      74305,  82945,  0,
0140                                       0, 100225, 217729, 0,      0,     108865, 126145, 143425, 108865, 157249, 165889,
0141                                       0, 0,      183169, 191809, 0,     0,      209089, 235009, 0,      0};
0142     return nStart[(ie - 1) * 16 + (is - 1) * 4 + ir - 1];
0143   }
0144   //@}
0145 
0146   /// \name chipIndexMethods
0147   //@{
0148   /**
0149    * Number of Buckeye chips indices per layer in a chamber
0150    * in offline ring 'ir' of station 'is'.
0151    *
0152    * Station label range 1-4, Ring label range 1-4 (4=ME1a)
0153    *
0154    * \warning: the ME1a CFEB is just the last 1 of the 5 total in each layer of
0155    * an ME11 chamber. So, the input of ir=4 is will just return the same 5 total
0156    * chips per whole ME11.
0157    *
0158    * Considers ME42 as standard 5 chip per layer chambers.
0159    */
0160   IndexType chipsPerLayer(IndexType is, IndexType ir) const override {
0161     const IndexType nCinL[16] = {5, 5, 4, 5, 5, 5, 0, 0, 5, 5, 0, 0, 5, 5, 0, 0};
0162     return nCinL[(is - 1) * 4 + ir - 1];
0163   }
0164 
0165   /**
0166    * Linear index for 1st Buckeye chip in offline ring 'ir' of station 'is' in
0167    * endcap 'ie'.
0168    *
0169    * Endcap label range 1-2, Station label range 1-4, Ring label range 1-3.
0170    *
0171    * \warning: while ME1a chip is the last 1 of the 5 chips total in each layer
0172    * of an ME11 chamber, here the ME1a input ir=4 defaults to the ME1b start
0173    * index (ir=4 <=> ir=1).
0174    */
0175   IndexType chipStart(IndexType ie, IndexType is, IndexType ir) const override {
0176     // These are in the ranges 1-13608 (CSCs 2008) and 13609-15768 (ME42).
0177     // There are 1-6804 chips per endcap (CSCs 2008) and 1080 channels per
0178     // endcap (ME42). Start of -z channels (CSCs 2008) is 6804 + 1 = 6805 Start
0179     // of +z (ME42) is 13608 + 1 = 13609 Start of -z (ME42) is 13608 + 1 + 1080
0180     // = 14689
0181     const IndexType nStart[32] = {1,    1081, 2161, 1,    3025, 3565,  0, 0, 4645,  5185,  0, 0, 6265,  13609, 0, 0,
0182                                   6805, 7885, 8965, 6805, 9829, 10369, 0, 0, 11449, 11989, 0, 0, 13069, 14689, 0, 0};
0183     return nStart[(ie - 1) * 16 + (is - 1) * 4 + ir - 1];
0184   }
0185   //@}
0186 
0187   /// \name gasGainIndexMethods
0188   //@{
0189   /**
0190    * Linear index for 1st Gas gain sector in ring 'ir' of station 'is' in endcap
0191    * 'ie'.
0192    *
0193    * Endcap label range 1-2, Station label range 1-4, Ring label range 1-4
0194    * (4=ME1a)
0195    *
0196    * \warning: ME1a chip is the last 1 of the 5 chips total in each layer of an
0197    * ME11 chamber, and an input ir=4 in this case would give the same result as
0198    * ir=1
0199    */
0200   IndexType sectorStart(IndexType ie, IndexType is, IndexType ir) const override {
0201     // There are 36 chambers * 6 layers * 5 CFEB's * 1 HV segment = 1080
0202     // gas-gain sectors in ME1/1 There are 36*6*5*3 = 3240 gas-gain sectors in
0203     // ME1/2 There are 36*6*4*3 = 2592 gas-gain sectors in ME1/3 There are
0204     // 18*6*5*3 = 1620 gas-gain sectors in ME[2-4]/1 There are 36*6*5*5 = 5400
0205     // gas-gain sectors in ME[2-4]/2 Start of -z channels (CSCs 2008) is 22572 +
0206     // 1 = 22573 Start of +z (ME42) is 45144 + 1 = 45145 Start of -z (ME42) is
0207     // 45144 + 1 + 5400 = 50545
0208     const IndexType nStart[32] = {1,     1081,  4321,
0209                                   1,  // ME+1/1,ME+1/2,ME+1/3,ME+1/4
0210                                   6913,  8533,  0,
0211                                   0,  // ME+2/1,ME+2/2,
0212                                   13933, 15553, 0,
0213                                   0,  // ME+3/1,ME+3/2,
0214                                   20953, 45145, 0,
0215                                   0,  // ME+4/1,ME+4/2,ME+4/3 (note, ME+4/2 index follows ME-4/1...)
0216                                   22573, 23653, 26893,
0217                                   22573,  // ME-1/1,ME-1/2,ME-1/3, ME-1/4
0218                                   29485, 31105, 0,
0219                                   0,  // ME-2/1,ME-2/2,ME-2/3
0220                                   36505, 38125, 0,
0221                                   0,  // ME-3/1,ME-3/2,ME-3/3
0222                                   43525, 50545, 0,
0223                                   0};  // ME-4/1,ME-4/2,ME-4/3 (note, ME-4/2 index follows ME+4/2...)
0224     return nStart[(ie - 1) * 16 + (is - 1) * 4 + ir - 1];
0225   }
0226   //@}
0227 
0228   /**
0229    *  Decode CSCDetId from various indexes and labels
0230    */
0231   std::pair<CSCDetId, IndexType> detIdFromStripChannelIndex(LongIndexType ichi) const override;
0232   std::pair<CSCDetId, IndexType> detIdFromChipIndex(IndexType ichi) const override;
0233   GasGainIndexType detIdFromGasGainIndex(IndexType igg) const override;
0234 
0235   /**
0236    * Build index used internally in online CSC conditions databases (the 'Igor
0237    * Index')
0238    *
0239    * This is the decimal integer ie*100000 + is*10000 + ir*1000 + ic*10 + il
0240    * <br> (ie=1-2, is=1-4, ir=1-4, ic=1-36, il=1-6) <br> Channels 1-16 in ME1A
0241    * (is=1, ir=4) are reset to channels 65-80 of ME11.
0242    */
0243   int dbIndex(const CSCDetId &id, int &channel) const override;
0244 };
0245 
0246 #endif