Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 23:59:48

0001 #ifndef _EcalElectronicsMapper_HH_
0002 #define _EcalElectronicsMapper_HH_
0003 
0004 /*
0005  *\ Class EcalElectronicsMapper
0006  *
0007  * Mapper for the ECAL electronics 
0008  
0009  * \file EcalElectronicsMapper.h
0010  *
0011  * \author N. Almeida
0012  * \author G. Franzoni
0013  *
0014 */
0015 
0016 #include <iostream>
0017 #include <sstream>
0018 #include <fstream>
0019 #include <string>
0020 #include <map>
0021 
0022 #include "DCCRawDataDefinitions.h"
0023 #include <DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h>
0024 #include <DataFormats/EcalDetId/interface/EcalElectronicsId.h>
0025 #include <DataFormats/EcalDetId/interface/EcalScDetId.h>
0026 #include <DataFormats/EcalDigi/interface/EcalDataFrame.h>
0027 #include <DataFormats/EcalDigi/interface/EcalTriggerPrimitiveDigi.h>
0028 #include <DataFormats/EcalDigi/interface/EcalPseudoStripInputDigi.h>
0029 #include <DataFormats/EcalDigi/interface/EcalSrFlag.h>
0030 #include <DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h>
0031 
0032 class EcalElectronicsMapping;
0033 
0034 class EcalElectronicsMapper {
0035 public:
0036   /**
0037    * Constructor
0038    */
0039   EcalElectronicsMapper(unsigned int numbOfXtalTSamples, unsigned int numbOfTriggerTSamples);
0040 
0041   /**
0042    * Destructor
0043    */
0044   ~EcalElectronicsMapper();
0045 
0046   void setEcalElectronicsMapping(const EcalElectronicsMapping*);
0047 
0048   void deletePointers();
0049   void resetPointers();
0050 
0051   /**
0052   * Set DCC id that is going to be unpacked for the event
0053   */
0054   bool setActiveDCC(unsigned int dccId);
0055 
0056   /**
0057    * Receives a string with a path and checks if file is accessible
0058    */
0059   bool setDCCMapFilePath(std::string);
0060 
0061   /**
0062    * Retrieves current path do the map file
0063    */
0064   std::string getDCCMapFilePath() const { return pathToMapFile_; }
0065 
0066   /**
0067    * Read map file (returns false if an error ocurred)
0068    *  deprecated by HLT environment
0069    */
0070   //  bool readDCCMapFile();
0071   //  bool readDCCMapFile(std::string );
0072 
0073   /**
0074    *  HLT friendly: load default mapping or, for non standatd mapping,
0075    *  use 2 vectors from cfg
0076    */
0077   bool makeMapFromVectors(std::vector<int>&, std::vector<int>&);
0078 
0079   /**
0080    * Get methods for DCCId/SMId and map
0081    */
0082   const std::map<unsigned int, unsigned int>& getDCCMap() const { return myDCCMap_; }
0083 
0084   DetId* getDetIdPointer(unsigned int feChannel, unsigned int strip, unsigned int xtal) {
0085     return xtalDetIds_[smId_ - 1][feChannel - 1][strip - 1][xtal - 1];
0086   }
0087 
0088   EcalTrigTowerDetId* getTTDetIdPointer(unsigned int tccId, unsigned int tower) {
0089     return ttDetIds_[tccId - 1][tower - 1];
0090   }
0091 
0092   EcalElectronicsId* getTTEleIdPointer(unsigned int tccId, unsigned int tower) {
0093     return ttEleIds_[tccId - 1][tower - 1];
0094   }
0095 
0096   EcalTriggerPrimitiveDigi* getTPPointer(unsigned int tccId, unsigned int tower) {
0097     return ttTPIds_[tccId - 1][tower - 1];
0098   }
0099 
0100   EcalScDetId* getSCDetIdPointer(unsigned int smId, unsigned int feChannel) {
0101     return scDetIds_[smId - 1][feChannel - 1];
0102   }
0103 
0104   EcalElectronicsId* getSCElectronicsPointer(unsigned int smId, unsigned int feChannel) {
0105     return scEleIds_[smId - 1][feChannel - 1];
0106   }
0107 
0108   EcalPseudoStripInputDigi* getPSInputDigiPointer(unsigned int tccId, unsigned int towerId, unsigned int psId) {
0109     return psInput_[tccId - 1][towerId - 1][psId - 1];
0110   }
0111 
0112   EcalPseudoStripInputDigi* getPSInputDigiPointer(unsigned int tccId, unsigned int psCounter) {
0113     return getPSInputDigiPointer(tccId, tTandPs_[tccId - 1][psCounter - 1][0], tTandPs_[tccId - 1][psCounter - 1][1]);
0114   }
0115 
0116   // this getter method needs be clarified.
0117   // Changed by Ph.G. on July 1, 09: return a vector instead of a single
0118   // element. One SRF can be associated to two  supercrystals, because of
0119   // channel grouping.
0120   std::vector<EcalSrFlag*> getSrFlagPointer(unsigned int feChannel) { return srFlags_[smId_ - 1][feChannel - 1]; }
0121 
0122   std::vector<unsigned int>* getTccs(unsigned int smId) { return mapSmIdToTccIds_[smId]; }
0123 
0124   unsigned int getActiveDCC() { return dccId_; }
0125 
0126   unsigned int getActiveSM() { return smId_; }
0127 
0128   unsigned int numbXtalTSamples() { return numbXtalTSamples_; }
0129 
0130   unsigned int numbTriggerTSamples() { return numbTriggerTSamples_; }
0131 
0132   unsigned int getUnfilteredTowerBlockLength() { return unfilteredFEBlockLength_; }
0133 
0134   unsigned int getEBTCCBlockLength() { return ebTccBlockLength_; }
0135 
0136   unsigned int getEETCCBlockLength() { return eeTccBlockLength_; }
0137 
0138   unsigned int getSRPBlockLength() { return srpBlockLength_; }
0139 
0140   unsigned int getDCCId(unsigned int aSMId) const;
0141 
0142   unsigned int getSMId(unsigned int aDCCId) const;
0143 
0144   unsigned int getNumChannelsInDcc(unsigned int aDCCId) { return numChannelsInDcc_[aDCCId - 1]; }
0145 
0146   const EcalElectronicsMapping* mapping() { return mappingBuilder_; }
0147 
0148   bool isTCCExternal(unsigned int TCCId);
0149 
0150   /**
0151    * Print current map
0152    */
0153   friend std::ostream& operator<<(std::ostream& o, const EcalElectronicsMapper& aEcalElectronicsMapper);
0154 
0155   // Mantain this here as long as everything is moved to a general mapping
0156   enum SMGeom_t {
0157     kModules = 4,            // Number of modules per supermodule
0158     kTriggerTowers = 68,     // Number of trigger towers per supermodule
0159     kTowersInPhi = 4,        // Number of trigger towers in phi
0160     kTowersInEta = 17,       // Number of trigger towers in eta
0161     kCrystals = 1700,        // Number of crystals per supermodule
0162     kPns = 10,               // Number of PN laser monitoring diodes per supermodule
0163     kCrystalsInPhi = 20,     // Number of crystals in phi
0164     kCrystalsInEta = 85,     // Number of crystals in eta
0165     kCrystalsPerTower = 25,  // Number of crystals per trigger tower
0166     kCardsPerTower = 5,      // Number of VFE cards per trigger tower
0167     kChannelsPerCard = 5,    // Number of channels per VFE card
0168     TTMAPMASK = 100
0169   };
0170 
0171 private:
0172   void fillMaps();
0173   unsigned int computeUnfilteredFEBlockLength();
0174   unsigned int computeEBTCCBlockLength();
0175   unsigned int computeEETCCBlockLength();
0176 
0177   std::string pathToMapFile_;
0178 
0179   unsigned int numbXtalTSamples_;
0180 
0181   unsigned int numbTriggerTSamples_;
0182 
0183   std::map<unsigned int, unsigned int> myDCCMap_;
0184 
0185   std::map<unsigned int, std::vector<unsigned int>*> mapSmIdToTccIds_;
0186 
0187   unsigned int dccId_;
0188 
0189   unsigned int smId_;
0190 
0191   unsigned int unfilteredFEBlockLength_;
0192 
0193   unsigned int srpBlockLength_;
0194 
0195   unsigned int ebTccBlockLength_, eeTccBlockLength_;
0196 
0197   static const unsigned int numChannelsInDcc_[NUMB_SM];
0198 
0199   // ARRAYS OF DetId
0200   DetId* xtalDetIds_[NUMB_SM][NUMB_FE][NUMB_STRIP][NUMB_XTAL];
0201   EcalScDetId* scDetIds_[NUMB_SM][NUMB_FE];
0202   EcalElectronicsId* scEleIds_[NUMB_SM][NUMB_FE];
0203   EcalTrigTowerDetId* ttDetIds_[NUMB_TCC][NUMB_FE];
0204   EcalElectronicsId* ttEleIds_[NUMB_TCC][NUMB_FE];
0205   EcalTriggerPrimitiveDigi* ttTPIds_[NUMB_TCC][NUMB_FE];
0206   std::vector<EcalSrFlag*> srFlags_[NUMB_SM][NUMB_FE];
0207   EcalPseudoStripInputDigi* psInput_[NUMB_TCC][TCC_EB_NUMBTTS][NUMB_STRIP];
0208 
0209   short tTandPs_[NUMB_TCC][5 * EcalTrigTowerDetId::kEBTowersPerSM][2];
0210 
0211   const EcalElectronicsMapping* mappingBuilder_;
0212 
0213   // functions and fields to work with 'ghost' VFEs:
0214 public:
0215   // check, does the given [FED (dcc), CCU (tower), VFE (strip)] belongs
0216   // to the list of VFEs with 'ghost' channels
0217   bool isGhost(const int FED, const int CCU, const int VFE);
0218 
0219 private:
0220   void setupGhostMap();
0221   std::map<int, std::map<int, std::map<int, bool> > > ghost_;
0222 };
0223 
0224 #endif