Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef PixelNameTranslation_h
0002 #define PixelNameTranslation_h
0003 /**
0004 * \file CalibFormats/SiPixelObjects/interface/PixelNameTranslation.h
0005 * \brief This class provides a translation from the naming documents standard to specify
0006 *        the ROC to the corresponding set of
0007 *        mfec, mfecchanner, hubaddress portadd and rocid
0008 *
0009 *   A longer explanation will be placed here later
0010 */
0011 
0012 #include <map>
0013 #include <string>
0014 #include <vector>
0015 #include <list>
0016 #include <set>
0017 #include <iostream>
0018 
0019 #include "CalibFormats/SiPixelObjects/interface/PixelConfigBase.h"
0020 #include "CalibFormats/SiPixelObjects/interface/PixelNameTranslation.h"
0021 #include "CalibFormats/SiPixelObjects/interface/PixelROCName.h"
0022 #include "CalibFormats/SiPixelObjects/interface/PixelModuleName.h"
0023 #include "CalibFormats/SiPixelObjects/interface/PixelChannel.h"
0024 #include "CalibFormats/SiPixelObjects/interface/PixelHdwAddress.h"
0025 
0026 namespace pos {
0027 
0028   class PixelDetectorConfig;
0029 
0030   /*!  \ingroup ConfigurationObjects "Configuration Objects"
0031 *    
0032 *  @{
0033 *
0034 *  \class PixelNameTranslation PixelNameTranslation.h
0035 *  \brief This is the documentation about PixelNameTranslation...
0036 *
0037 *   This class provides a translation from the naming documents standard to specify
0038 *   the ROC to the corresponding set of
0039 *   mfec, mfecchanner, hubaddress portadd and rocid
0040 */
0041   class PixelNameTranslation : public PixelConfigBase {
0042   public:
0043     PixelNameTranslation(std::vector<std::vector<std::string> >& tableMat);
0044     PixelNameTranslation(std::string filename);
0045 
0046     ~PixelNameTranslation() override {}
0047 
0048     // Probably these functions should never be used, and instead we should call similar functions in PixelDetectorConfig.
0049     std::list<const PixelROCName*> getROCs() const;
0050     std::list<const PixelModuleName*> getModules() const;
0051     std::set<PixelChannel> getChannels() const;  // returns all channels
0052     std::set<PixelChannel> getChannels(const PixelDetectorConfig& aDetectorConfig)
0053         const;  // only returns channels on modules found in the detector config
0054 
0055     const PixelHdwAddress* getHdwAddress(const PixelROCName& aROC) const;
0056 
0057     //Should really use a different type of hdw address for a channel
0058     const PixelHdwAddress& getHdwAddress(const PixelChannel& aChannel) const;
0059     const PixelHdwAddress& firstHdwAddress(const PixelModuleName& aModule) const;
0060 
0061     const bool checkFor(const PixelROCName& aROC) const;
0062 
0063     // Added for Debbie (used there only) to allow integrity checks (Dario)
0064     bool checkROCExistence(const PixelROCName& aROC) const;
0065 
0066     const PixelChannel& getChannelForROC(const PixelROCName& aROC) const;
0067     std::set<PixelChannel> getChannelsOnModule(const PixelModuleName& aModule) const;
0068 
0069     friend std::ostream& operator<<(std::ostream& s, const PixelNameTranslation& table);
0070 
0071     const std::vector<PixelROCName>& getROCsFromFEDChannel(unsigned int fednumber, unsigned int fedchannel) const;
0072 
0073     PixelROCName ROCNameFromFEDChannelROC(unsigned int fednumber, unsigned int channel, unsigned int roc) const;
0074 
0075     bool ROCNameFromFEDChannelROCExists(unsigned int fednumber, unsigned int channel, unsigned int roc) const;
0076 
0077     PixelChannel ChannelFromFEDChannel(unsigned int fednumber, unsigned int fedchannel) const;
0078 
0079     bool FEDChannelExist(unsigned int fednumber, unsigned int fedchannel) const;
0080 
0081     const std::vector<PixelROCName>& getROCsFromChannel(const PixelChannel& aChannel) const;
0082     std::vector<PixelROCName> getROCsFromModule(const PixelModuleName& aModule) const;
0083 
0084     void writeASCII(std::string dir = "") const override;
0085     void writeXML(pos::PixelConfigKey key, int version, std::string path) const override;
0086     void writeXMLHeader(pos::PixelConfigKey key,
0087                         int version,
0088                         std::string path,
0089                         std::ofstream* out,
0090                         std::ofstream* out1 = nullptr,
0091                         std::ofstream* out2 = nullptr) const override;
0092     void writeXML(std::ofstream* out, std::ofstream* out1 = nullptr, std::ofstream* out2 = nullptr) const override;
0093     void writeXMLTrailer(std::ofstream* out,
0094                          std::ofstream* out1 = nullptr,
0095                          std::ofstream* out2 = nullptr) const override;
0096 
0097     bool ROCexists(PixelROCName theROC);  // Added by Dario
0098     const PixelChannel& getChannelFromHdwAddress(const PixelHdwAddress& aHdwAddress) const;
0099 
0100     std::map<unsigned int, std::set<unsigned int> > getFEDsAndChannels() const;
0101 
0102   private:
0103     std::map<PixelROCName, PixelHdwAddress> translationtable_;
0104 
0105     std::map<PixelHdwAddress, PixelROCName, PixelHdwAddress> fedlookup_;
0106 
0107     // This is a bit ugly, since the PixelHdwAddress contains the ROC number, which isn't really relevant to a PixelChannel.
0108     std::map<PixelChannel, PixelHdwAddress> channelTranslationTable_;
0109     std::map<PixelHdwAddress, PixelChannel> hdwTranslationTable_;
0110 
0111     std::map<unsigned int, std::map<unsigned int, std::vector<PixelROCName> > > rocsFromFEDidAndChannel_;
0112     //       FED id                  FED channel
0113 
0114     std::vector<PixelROCName> buildROCsFromFEDChannel(unsigned int fednumber, unsigned int fedchannel) const;
0115   };
0116 }  // namespace pos
0117 /* @} */
0118 #endif