Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:31

0001 #ifndef SiPixelObjects_PixelROC_H
0002 #define SiPixelObjects_PixelROC_H
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include "CondFormats/SiPixelObjects/interface/FrameConversion.h"
0007 #include "CondFormats/SiPixelObjects/interface/LocalPixel.h"
0008 #include "CondFormats/SiPixelObjects/interface/GlobalPixel.h"
0009 #include <string>
0010 #include <cstdint>
0011 
0012 /** \class PixelROC
0013  * Represents ReadOut Chip of DetUnit. 
0014  * Converts pixel coordinates from Local (in ROC) to Global (in DetUnit).
0015  * The Local coordinates are double column (dcol) and pixel index in dcol.
0016  * The Global coordinates are row and column in DetUnit.
0017  */
0018 
0019 //class TrackerTopology;
0020 
0021 namespace sipixelobjects {
0022 
0023   class PixelROC {
0024   public:
0025     /// dummy
0026     PixelROC() : theDetUnit(0), theIdDU(0), theIdLk(0) {}
0027 
0028     /// ctor with DetUnit id,
0029     /// ROC number in DU (given by token passage),
0030     /// ROC number in Link (given by token passage),
0031     PixelROC(uint32_t du, int idInDU, int idLk);
0032 
0033     /// return the DetUnit to which this ROC belongs to.
0034     uint32_t rawId() const { return theDetUnit; }
0035 
0036     /// id of this ROC in DetUnit etermined by token path
0037     unsigned int idInDetUnit() const { return theIdDU; }
0038 
0039     /// id of this ROC in parent Link.
0040     unsigned int idInLink() const { return theIdLk; }
0041 
0042     /// converts DU position to local.
0043     /// If GlobalPixel is outside ROC the resulting LocalPixel is not inside ROC.
0044     /// (call to inside(..) recommended)
0045     LocalPixel toLocal(const GlobalPixel& glo) const {
0046       int rocRow = theFrameConverter.row().inverse(glo.row);
0047       int rocCol = theFrameConverter.collumn().inverse(glo.col);
0048 
0049       LocalPixel::RocRowCol rocRowCol = {rocRow, rocCol};
0050       return LocalPixel(rocRowCol);
0051     }
0052 
0053     /// converts LocalPixel in ROC to DU coordinates.
0054     /// LocalPixel must be inside ROC. Otherwise result is meaningless
0055     GlobalPixel toGlobal(const LocalPixel& loc) const {
0056       GlobalPixel result;
0057       result.col = theFrameConverter.collumn().convert(loc.rocCol());
0058       result.row = theFrameConverter.row().convert(loc.rocRow());
0059       return result;
0060     }
0061 
0062     // recognise the detector side and layer number
0063     // this methods use hardwired constants
0064     // if the numberg changes the methods have to be modified
0065     int bpixSidePhase0(uint32_t rawId) const;
0066     int fpixSidePhase0(uint32_t rawId) const;
0067     int bpixSidePhase1(uint32_t rawId) const;
0068     int fpixSidePhase1(uint32_t rawId) const;
0069     static int bpixLayerPhase1(uint32_t rawId);
0070 
0071     /// printout for debug
0072     std::string print(int depth = 0) const;
0073 
0074     void initFrameConversion();
0075     void initFrameConversionPhase1();
0076     //void initFrameConversion(const TrackerTopology *tt, bool phase1=false);
0077     // Frame conversion compatible with CMSSW_9_0_X Monte Carlo samples
0078     void initFrameConversionPhase1_CMSSW_9_0_X();
0079 
0080   private:
0081     uint32_t theDetUnit;
0082     unsigned int theIdDU, theIdLk;
0083     FrameConversion theFrameConverter COND_TRANSIENT;
0084 
0085     COND_SERIALIZABLE;
0086   };
0087 
0088 }  // namespace sipixelobjects
0089 
0090 #endif