CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/CalibFormats/SiPixelObjects/interface/PixelNameTranslation.h

Go to the documentation of this file.
00001 #ifndef PixelNameTranslation_h
00002 #define PixelNameTranslation_h
00003 
00012 #include <map>
00013 #include <string>
00014 #include <vector>
00015 #include <list>
00016 #include <set>
00017 #include <iostream>
00018 
00019 #include "CalibFormats/SiPixelObjects/interface/PixelConfigBase.h"
00020 #include "CalibFormats/SiPixelObjects/interface/PixelNameTranslation.h"
00021 #include "CalibFormats/SiPixelObjects/interface/PixelROCName.h"
00022 #include "CalibFormats/SiPixelObjects/interface/PixelModuleName.h"
00023 #include "CalibFormats/SiPixelObjects/interface/PixelChannel.h"
00024 #include "CalibFormats/SiPixelObjects/interface/PixelHdwAddress.h"
00025 
00026 namespace pos{
00027 
00028   class PixelDetectorConfig;
00029 
00041   class PixelNameTranslation: public PixelConfigBase {
00042 
00043   public:
00044  
00045     PixelNameTranslation(std::vector< std::vector<std::string> > &tableMat);
00046     PixelNameTranslation(std::string filename);
00047 
00048     virtual ~PixelNameTranslation(){}
00049 
00050     // Probably these functions should never be used, and instead we should call similar functions in PixelDetectorConfig.
00051     std::list<const PixelROCName*> getROCs() const;
00052     std::list<const PixelModuleName*> getModules() const;
00053     std::set<PixelChannel> getChannels() const; // returns all channels
00054     std::set<PixelChannel> getChannels(const PixelDetectorConfig& aDetectorConfig) const; // only returns channels on modules found in the detector config
00055 
00056     const PixelHdwAddress* getHdwAddress(const PixelROCName& aROC) const;
00057 
00058     //Should really use a different type of hdw address for a channel
00059     const PixelHdwAddress& getHdwAddress(const PixelChannel& aChannel) const;
00060     const PixelHdwAddress& firstHdwAddress(const PixelModuleName& aModule) const;
00061     
00062     const bool checkFor(const PixelROCName& aROC) const ; 
00063 
00064     // Added for Debbie (used there only) to allow integrity checks (Dario)
00065     bool checkROCExistence(const PixelROCName& aROC) const ;
00066  
00067     const PixelChannel& getChannelForROC(const PixelROCName& aROC) const;
00068     std::set< PixelChannel > getChannelsOnModule(const PixelModuleName& aModule) const;
00069     
00070     friend std::ostream& operator<<(std::ostream& s, const PixelNameTranslation& table);
00071 
00072     const std::vector<PixelROCName>& getROCsFromFEDChannel(unsigned int fednumber, 
00073                                                      unsigned int fedchannel) const;
00074     
00075     PixelROCName ROCNameFromFEDChannelROC(unsigned int fednumber, 
00076                                           unsigned int channel,
00077                                           unsigned int roc) const;
00078                                           
00079     bool ROCNameFromFEDChannelROCExists(unsigned int fednumber, 
00080                                         unsigned int channel,
00081                                         unsigned int roc) const;
00082                                           
00083     PixelChannel ChannelFromFEDChannel(unsigned int fednumber, unsigned int fedchannel) const;
00084 
00085     bool FEDChannelExist(unsigned int fednumber, unsigned int fedchannel) const;
00086                                           
00087     const std::vector<PixelROCName>& getROCsFromChannel(const PixelChannel& aChannel) const;
00088     std::vector<PixelROCName> getROCsFromModule(const PixelModuleName& aModule) const;
00089 
00090     void writeASCII(std::string dir="") const;
00091     void         writeXML(        pos::PixelConfigKey key, int version, std::string path)                   const   ;
00092     virtual void writeXMLHeader(  pos::PixelConfigKey key, 
00093                                   int version, 
00094                                   std::string path, 
00095                                   std::ofstream *out,
00096                                   std::ofstream *out1 = NULL,
00097                                   std::ofstream *out2 = NULL
00098                                   ) const ;
00099     virtual void writeXML(        std::ofstream *out,                                                       
00100                                   std::ofstream *out1 = NULL ,
00101                                   std::ofstream *out2 = NULL ) const ;
00102     virtual void writeXMLTrailer( std::ofstream *out, 
00103                                   std::ofstream *out1 = NULL,
00104                                   std::ofstream *out2 = NULL
00105                                   ) const ;
00106     
00107     bool ROCexists(PixelROCName theROC) ; // Added by Dario
00108     const PixelChannel& getChannelFromHdwAddress(const PixelHdwAddress& aHdwAddress) const;
00109 
00110 
00111     std::map <unsigned int, std::set<unsigned int> > getFEDsAndChannels() const;
00112 
00113   private:
00114   
00115         
00116     std::map<PixelROCName,PixelHdwAddress> translationtable_;  
00117 
00118     std::map<PixelHdwAddress, PixelROCName, PixelHdwAddress> fedlookup_;  
00119 
00120     // This is a bit ugly, since the PixelHdwAddress contains the ROC number, which isn't really relevant to a PixelChannel.
00121     std::map<PixelChannel, PixelHdwAddress > channelTranslationTable_;
00122     std::map<PixelHdwAddress, PixelChannel > hdwTranslationTable_;
00123 
00124     std::map<unsigned int, std::map<unsigned int, std::vector<PixelROCName> > > rocsFromFEDidAndChannel_;
00125     //       FED id                  FED channel
00126 
00127     std::vector<PixelROCName> buildROCsFromFEDChannel(unsigned int fednumber, 
00128                                                       unsigned int fedchannel) const;
00129 
00130 
00131   };
00132 }
00133 /* @} */
00134 #endif