00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "StEmcRawHit.h"
00040 #include "StEmcUtil/geometry/StEmcGeom.h"
00041
00042 static const char rcsid[] = "$Id: StEmcRawHit.cxx,v 2.8 2007/01/25 02:52:35 ullrich Exp $";
00043
00044 ClassImp(StEmcRawHit)
00045
00046 StEmcGeom* StEmcRawHit::mGeom=0;
00047
00048 StEmcRawHit::StEmcRawHit()
00049 {
00050 mId = 0;
00051 mAdc = 0;
00052 mEnergy = 0;
00053 }
00054
00055 StEmcRawHit::StEmcRawHit(StDetectorId d, unsigned int m, unsigned int e, unsigned int s, unsigned int a)
00056 {
00057 setId(d, m, e, s);
00058 setAdc(a);
00059 setEnergy(0.0);
00060 }
00061
00062 StEmcRawHit::StEmcRawHit(StDetectorId d, unsigned int m, unsigned int e, unsigned int s, unsigned int a, float ene)
00063 {
00064 setId(d, m, e, s);
00065 setAdc(a);
00066 setEnergy(ene);
00067 }
00068
00069 StEmcRawHit::StEmcRawHit(const StEmcRawHit& h) : StObject(h){
00070 mId = h.mId;
00071 mAdc = h.mAdc;
00072 mEnergy = h.mEnergy;
00073 }
00074
00075 StEmcRawHit::~StEmcRawHit() {}
00076
00077 unsigned int
00078 StEmcRawHit::bits(unsigned int bit, unsigned int nbits) const
00079 {
00080 return (mId>>bit) & ~(~0UL<<nbits);
00081 }
00082
00083 void
00084 StEmcRawHit::setCalibrationType(unsigned int t){
00085 if(t<256){
00086 mId = mId & 0xffffff;
00087 mId += t << 24;
00088 }
00089 }
00090
00091 void
00092 StEmcRawHit::setId(StDetectorId d, unsigned int m, unsigned int e, unsigned int s)
00093 {
00094 mId = static_cast<unsigned int>(d - kBarrelEmcTowerId) << 20;
00095 mId += m << 13;
00096 mId += e << 4;
00097 mId += s;
00098 }
00099
00100 unsigned int
00101 StEmcRawHit::calibrationType() const {return bits(24, 8);}
00102
00103 StDetectorId
00104 StEmcRawHit::detector() const
00105 {
00106 return static_cast<StDetectorId>(bits(20, 4)+kBarrelEmcTowerId);
00107 }
00108
00109 unsigned int
00110 StEmcRawHit::module() const {return bits(13, 7);}
00111
00112 unsigned int
00113 StEmcRawHit::eta() const {return bits( 4, 9);}
00114
00115 unsigned int
00116 StEmcRawHit::softId(int det) const
00117 {
00118 mGeom = StEmcGeom::instance(det);
00119 if(mGeom==0) return 0;
00120
00121 int id=0, m=0, e=0, s=0;
00122 modEtaSub(m,e,s);
00123 mGeom->getId(m, e, s, id);
00124 return id;
00125 }
00126
00127 void StEmcRawHit::modEtaSub(int &m, int &e, int &s) const
00128 {
00129 m = module();
00130 e = eta();
00131 s = sub();
00132 }
00133
00134 int
00135 StEmcRawHit::sub() const {
00136 int sub;
00137 switch(detector()){
00138 case kBarrelSmdEtaStripId:
00139 case kEndcapSmdUStripId:
00140 case kEndcapSmdVStripId:
00141 sub = 1;
00142 break;
00143 default:
00144 sub = bits(0, 4);
00145 }
00146 return sub;
00147 }
00148
00149 unsigned int
00150 StEmcRawHit::adc() const {return mAdc;}
00151
00152 float
00153 StEmcRawHit::energy() const {return mEnergy;}
00154
00155 void
00156 StEmcRawHit::setAdc(const unsigned int adc) {mAdc=adc;}
00157
00158 void
00159 StEmcRawHit::setEnergy(const float energy) {mEnergy=energy;}