00001 #ifndef PTrajectoryStateOnDet_H 00002 #define PTrajectoryStateOnDet_H 00003 00004 #include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h" 00005 #include<cassert> 00010 class PTrajectoryStateOnDet { 00011 private: 00012 // we assume that id cannot be calo! (i.e. det<4) 00013 static const unsigned int idMask = 0x3fffffff; 00014 // little endian... 00015 struct Packing { 00016 unsigned int rest : 30; 00017 unsigned char ss : 2; 00018 }; 00019 struct DetPack { 00020 unsigned int loc : 25; 00021 unsigned char sub : 3; 00022 unsigned char det : 4; 00023 }; 00024 union Pack { 00025 Pack(){} 00026 Pack(unsigned int pack) : packed(pack){} 00027 Pack(unsigned int id, int surfaceSide) : packed(id) { 00028 bytes.ss=surfaceSide; 00029 assert(surfaceSide<3); 00030 assert((id>>28)<4); 00031 } 00032 int side() const { return bytes.ss;} 00033 unsigned int id() const { return packed&idMask;} 00034 unsigned int packed; 00035 Packing bytes; 00036 DetPack det; 00037 }; 00038 00039 00040 public: 00041 00042 PTrajectoryStateOnDet() {} 00043 00044 PTrajectoryStateOnDet( const LocalTrajectoryParameters& param, 00045 unsigned int id, 00046 int surfaceSide) : 00047 theLocalParameters(param) 00048 { 00049 Pack p(id, surfaceSide); 00050 thePack = p.packed; 00051 theLocalErrors[0]=-99999.e10; 00052 } 00053 00054 PTrajectoryStateOnDet( const LocalTrajectoryParameters& param, 00055 float errmatrix[15], unsigned int id, 00056 int surfaceSide) : 00057 theLocalParameters( param) 00058 { 00059 Pack p(id, surfaceSide); 00060 thePack = p.packed; 00061 for (int i=0; i<15; i++) theLocalErrors[i] = errmatrix[i]; 00062 } 00063 00064 00065 const LocalTrajectoryParameters& parameters() const {return theLocalParameters;} 00066 bool hasError() const { return theLocalErrors[0] > -1.e10; } 00067 float & error(int i) {return theLocalErrors[i];} 00068 float error(int i) const {return theLocalErrors[i];} 00069 unsigned int detId() const { 00070 return thePack&idMask; 00071 } 00072 int surfaceSide() const { 00073 Pack p(thePack); 00074 return p.side(); 00075 } 00076 00077 private: 00078 00079 LocalTrajectoryParameters theLocalParameters; 00080 float theLocalErrors[15]; 00081 unsigned int thePack; 00082 //unsigned int theDetId; 00083 //int theSurfaceSide; 00084 00085 }; 00086 00087 #endif